DONTFLIP Bugfix inside

Bugs that have been resolved.

Moderator: Graf Zahl

Major Cooke
Developer
Developer
Posts: 240
Joined: Wed Mar 04, 2009 19:25

DONTFLIP Bugfix inside

Post by Major Cooke »

Pull Request

Note however there's currently no way to tell if the player is actually crouching or not. ViewPos doesn't appear to update based on that factor. A minor detail, but otherwise this works out pretty nicely.
Spoiler: Old Post
Last edited by Major Cooke on Wed Aug 31, 2016 18:12, edited 2 times in total.
User avatar
Graf Zahl
GZDoom Developer
GZDoom Developer
Posts: 7148
Joined: Wed Jul 20, 2005 9:48
Location: Germany
Contact:

Re: Fixing the DONTFLIP bug

Post by Graf Zahl »

I think the only way to really fix it is to calculate on which side of the plane the camera is and then position the sprite accordingly.
Major Cooke
Developer
Developer
Posts: 240
Joined: Wed Mar 04, 2009 19:25

Re: Fixing the DONTFLIP bug

Post by Major Cooke »

Alright, here we go.

There's only one small detail that I cannot seem to figure a way around, and it's whether the player is crouching or not. It seems ViewPos does not update the z position whenever the player crouches.

Otherwise, it works much better now.
User avatar
Graf Zahl
GZDoom Developer
GZDoom Developer
Posts: 7148
Joined: Wed Jul 20, 2005 9:48
Location: Germany
Contact:

Re: DONTFLIP Bugfix inside

Post by Graf Zahl »

ViewPos is the actual camera position so it already has crouching factored in.
Major Cooke
Developer
Developer
Posts: 240
Joined: Wed Mar 04, 2009 19:25

Re: DONTFLIP Bugfix inside

Post by Major Cooke »

Weird. I can crouch under the caco rfom the side and flip the sprite over but DONTFLIP still doesn't apply despite my adding a check for it... Anything you might recommend?
Major Cooke
Developer
Developer
Posts: 240
Joined: Wed Mar 04, 2009 19:25

Re: DONTFLIP Bugfix inside

Post by Major Cooke »

For now, can this be included? I don't know what else to do. It does what it needs to at least and allows proper backside viewing.
User avatar
Graf Zahl
GZDoom Developer
GZDoom Developer
Posts: 7148
Joined: Wed Jul 20, 2005 9:48
Location: Germany
Contact:

Re: DONTFLIP Bugfix inside

Post by Graf Zahl »

Does it?

What's with "(ViewPos.Z < zcenter)"? Does this really work or is this just a hotfix that patches over the most glaring problems?
Major Cooke
Developer
Developer
Posts: 240
Joined: Wed Mar 04, 2009 19:25

Re: DONTFLIP Bugfix inside

Post by Major Cooke »

Yes, save for the aforementioned crouching issue.

Code: Select all

Actor A
{
	+NOINTERACTION
	+ROLLSPRITE
	+FLATSPRITE
	+DONTFLIP
	+ROLLCENTER
	States
	{
	Spawn:
		HEAD A 1 
		{
			pitch += 2;
			roll += 4;
		}
		Loop
	}
}
Summon this caco and let it roll until its about like this, and freeze the game:
Image

When you crouch, you'll notice that the flip doesn't happen (mouth's on the left).
Image

When you move to the right, it performs the anti-flip exactly as expected (mouth's on the right), especially when not crouching.
Image

That viewpos.z code was my attempt to check for crouching, but it really doesn't work out. I don't know what to do for that. Do you have any ideas on that part?
User avatar
Graf Zahl
GZDoom Developer
GZDoom Developer
Posts: 7148
Joined: Wed Jul 20, 2005 9:48
Location: Germany
Contact:

Re: DONTFLIP Bugfix inside

Post by Graf Zahl »

This will be fixed for real, not patched over. The proper fix has to be to check on which side of the plane the viewpoint is.
Major Cooke
Developer
Developer
Posts: 240
Joined: Wed Mar 04, 2009 19:25

Re: DONTFLIP Bugfix inside

Post by Major Cooke »

If this doesn't do it, then how? How am I supposed to check which side it's on?
User avatar
Graf Zahl
GZDoom Developer
GZDoom Developer
Posts: 7148
Joined: Wed Jul 20, 2005 9:48
Location: Germany
Contact:

Re: DONTFLIP Bugfix inside

Post by Graf Zahl »

By using 3D vector math.
Major Cooke
Developer
Developer
Posts: 240
Joined: Wed Mar 04, 2009 19:25

Re: DONTFLIP Bugfix inside

Post by Major Cooke »

Code: Select all

float pitchDegrees = -actor->Angles.Pitch.Degrees;
			DVector3 apos = { xcenter, ycenter, zcenter };
			DVector3 diff = ViewPos - apos;
			DAngle angto = diff.Angle();
			DAngle pitchto = diff.Pitch();
			DAngle result = deltaangle(angto, pitchto);

			bool noFlipSprite = (!dontFlip || (fabs(result) < 90.));
This is the closest I could get it but it's still broken somewhat. Help would be appreciated.
User avatar
Rachael
Developer
Developer
Posts: 3646
Joined: Sat May 13, 2006 10:30

Re: DONTFLIP Bugfix inside

Post by Rachael »

What is the feasibility of ditching the checks entirely, and rendering all quads as one-sided (so it's invisible from behind) with +DONTFLIP, and simply render both sides, knowing only one is ever going to show at a time?

It's just an idea, but if I was working on this feature this is how I would handle it.

The two sprite quads would render to the same coordinates, just the other side would be reversed. On what axis, hopefully, you can get the right one (I would imagine swapping the X coordinates for the "back side" quad to be enough).

I am sorry if this suggestion ignores the problems entirely, I may not be understanding this feature well.
User avatar
Graf Zahl
GZDoom Developer
GZDoom Developer
Posts: 7148
Joined: Wed Jul 20, 2005 9:48
Location: Germany
Contact:

Re: DONTFLIP Bugfix inside

Post by Graf Zahl »

I'm going to have to review the code. But my guess is that the entire DONTFLIP thing is going to be ditched. It and some other stuff in here is just the result of a bad implementation. For wall and flat sprites coordinates should not be derived from the current viewpoint at all. They need to, as you said, be fixed, no matter from where you look at them (and possibly always show the front angle.)

In clear English: The calculation needs to be done explicitly in the Process function, not by a retroactive rotation before display.

And since there is no face culling one poly is enough.

To make one thing clear: Unless I find the time to think about it, I won't accept any pull requests that further muck around with this stuff. I also won't do a release before this isn't ok. And if some mod gets affected: Bad luck. They are called "development builds" for good reasons.
User avatar
Nash
Developer
Developer
Posts: 1226
Joined: Sun Sep 25, 2005 1:49
Location: Kuala Lumpur, Malaysia
Contact:

Re: DONTFLIP Bugfix inside

Post by Nash »

To be honest I really wouldn't mind at all if the entire code was just dumped and redone from scratch, except properly and cleanly. I'm currently only making use of flat sprites and rolling sprites, and only for cosmetic visual FX (smoke, clouds etc)... nothing complex or gameplay-ey. Good call moving that stuff out of GLSprite::Draw
Locked

Return to “Closed Bugs”