nullptr crash with FLATSPRITES

Bugs that have been resolved.

Moderator: Graf Zahl

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

nullptr crash with FLATSPRITES

Post by Major Cooke »

So apparently this can happen.
Spoiler: nullptr traces
1. Grab D4D here http://forum.zdoom.org/viewtopic.php?f=19&t=52164
2. Give D4Chaingun + SovietToken + SovietActive
3. Chasecam on
4. Start firing. Bam.
User avatar
Graf Zahl
GZDoom Developer
GZDoom Developer
Posts: 7148
Joined: Wed Jul 20, 2005 9:48
Location: Germany
Contact:

Re: nullptr crash with FLATSPRITES

Post by Graf Zahl »

Yes, of course this can happen. With the chasecam on there is no viewactor. And even disregarding that, the viewactor's position is not necessarily the actual camera position for the current frame. If you want to do checks against the camera, do not check against ViewActor but against ViewPos. And you should check the actual rendering values, not the actor they are derived from. This also needs to take into account what pivot you are using for rotation.

Essentially the code to determine flipping does not look correct at all. What this really needs to do is to check is that the actual camera point (ViewPos) is above or below the tilted sprite. To be honest, I have no clue what you are actually doing there.

Which also begs the question: Why is the 'noflip' check only present for flat sprites and not for wall sprites?
Major Cooke
Developer
Developer
Posts: 240
Joined: Wed Mar 04, 2009 19:25

Re: nullptr crash with FLATSPRITES

Post by Major Cooke »

Graf Zahl wrote:Yes, of course this can happen. With the chasecam on there is no viewactor. And even disregarding that, the viewactor's position is not necessarily the actual camera position for the current frame. If you want to do checks against the camera, do not check against ViewActor but against ViewPos. And you should check the actual rendering values, not the actor they are derived from. This also needs to take into account what pivot you are using for rotation.
I'm not sure what you mean by actual rendering values. Do you mean things similar to how the billboard sprites are handled using xcenter and all?
Graf Zahl wrote:Essentially the code to determine flipping does not look correct at all. What this really needs to do is to check is that the actual camera point (ViewPos) is above or below the tilted sprite. To be honest, I have no clue what you are actually doing there.
And I'm honestly just as confused as you are, because I didn't do most of this work. I simply maintained it for the people who made it (although the noflip is my fault).
Graf Zahl wrote:Which also begs the question: Why is the 'noflip' check only present for flat sprites and not for wall sprites?
When I last tried it a while ago, I think it did something to the decals. I'll check again to see if that's still the case.
Last edited by Major Cooke on Thu Jul 21, 2016 14:05, edited 1 time in total.
User avatar
Graf Zahl
GZDoom Developer
GZDoom Developer
Posts: 7148
Joined: Wed Jul 20, 2005 9:48
Location: Germany
Contact:

Re: nullptr crash with FLATSPRITES

Post by Graf Zahl »

Major Cooke wrote:
Graf Zahl wrote:Yes, of course this can happen. With the chasecam on there is no viewactor. And even disregarding that, the viewactor's position is not necessarily the actual camera position for the current frame. If you want to do checks against the camera, do not check against ViewActor but against ViewPos. And you should check the actual rendering values, not the actor they are derived from. This also needs to take into account what pivot you are using for rotation.
I'm not sure what you mean by actual rendering values. Do you mean things similar to how the billboard sprites are handled using xcenter and all?
It's actually quite simple:

You are using the playsim position of the camera and the actor being rendered.
But what needs to be used is the actual view position and the interpolated actor position (and no portal offsetting, that's already factored in.)
It also needs to consider if a sprite is rotated around its center or its pivot.

Right now, by looking at the code that decides the flipping, I can't make any sense of it.
Major Cooke
Developer
Developer
Posts: 240
Joined: Wed Mar 04, 2009 19:25

Re: nullptr crash with FLATSPRITES

Post by Major Cooke »

ViewPos - actor->Pos() then? I'm assuming by not including portals you mean not to use PosRelative.

I'll make sure to factor in the pivot/center as well.
User avatar
Graf Zahl
GZDoom Developer
GZDoom Developer
Posts: 7148
Joined: Wed Jul 20, 2005 9:48
Location: Germany
Contact:

Re: nullptr crash with FLATSPRITES

Post by Graf Zahl »

No, not even that. You have to take the position from the GLSprite. But about the formula itself I can't help you, I have no idea what it actually does.
Major Cooke
Developer
Developer
Posts: 240
Joined: Wed Mar 04, 2009 19:25

Re: nullptr crash with FLATSPRITES

Post by Major Cooke »

Alright, I think I managed to fix most of it. Now I just need to factor in the actor's pitch.

However, there's still something else that's been around for a while. This only happens whenever there's 3D floors or complex map geometry around:
Spoiler: Image
That splitting issue has been prevalent especially with camera facing sprites and has been existing from said cam-facing sprites introduction.
Major Cooke
Developer
Developer
Posts: 240
Joined: Wed Mar 04, 2009 19:25

Re: nullptr crash with FLATSPRITES

Post by Major Cooke »

Also I forgot to mention, DONTFLIP is already taken into account for the wallsprites.

Code: Select all

else if (spritetype == RF_WALLSPRITE)
				{
					mat.Rotate(0, 1, 0, 0);
					if (drawRollSpriteActor)
					{
						if (useOffsets)	mat.Translate(xx, zz, yy); //Handled here
						mat.Rotate(yawvecX, 0, yawvecY, rollDegrees);
						if (useOffsets) mat.Translate(-xx, -zz, -yy); //And here
					}
				}
Alright... All I need to do now is factor in the actor's pitch somehow...
Major Cooke
Developer
Developer
Posts: 240
Joined: Wed Mar 04, 2009 19:25

Re: nullptr crash with FLATSPRITES

Post by Major Cooke »

https://github.com/coelckers/gzdoom/pull/60

This fixes the crash at least. I've been trying to flip the sprite appropriately with pitch inclusion, but I've had no luck so far. So for now it's still just the angle at the moment.

I'll keep trying but I do suggest the crash fix go in ASAP.
Locked

Return to “Closed Bugs”