FLATSPRITE discussion

Advanced OpenGL source port fork from ZDoom, picking up where ZDoomGL left off.
[Home] [Download] [Git builds (Win)] [Git builds (Mac)] [Wiki] [Repo] [Bugs&Suggestions]

Moderator: Graf Zahl

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

Re: FLATSPRITE discussion

Post by Major Cooke » Tue Sep 13, 2016 17:57

...No wonder why it wasn't working! I simply forgot to perform mat.Translate(x,z,y) with mat.Translate(-x, -z, -y) after it.

As for the deleted posts, sorry about that. I thought I discovered something and then realized quickly it wasn't going to work.

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

Re: FLATSPRITE discussion

Post by Major Cooke » Tue Sep 13, 2016 20:14

Alright, roll's done.

I just need to do two more things: Insert DONTFLIP and proper ROLLCENTER support.

The latter has proven to be quite tricky and directly collides with the code used to scale the sprites in that switch statement.
--------------------------------------------------------------------------------------------------------------------------------
Also, this still doesn't fix the splicing issue no matter what way you put it:
Image

Still affects rolling sprites and flat sprites all the same.
Last edited by Rachael on Tue Sep 13, 2016 20:54, edited 3 times in total.
Reason: Removed [spoiler] tag on images - corrected issue with my own editing

User avatar
Graf Zahl
GZDoom Developer
GZDoom Developer
Posts: 7148
Joined: Wed Jul 20, 2005 9:48
Location: Germany
Contact:

Re: FLATSPRITE discussion

Post by Graf Zahl » Tue Sep 13, 2016 20:17

Do you really need DONTFLIP here? Can you give a link to what you are doing? I'd like to comment before you declare it ready.

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

Re: FLATSPRITE discussion

Post by Major Cooke » Tue Sep 13, 2016 20:18

https://github.com/MajorCooke/GZDoom/tree/FlatSpritesV3

It's not ready yet for certain. But it's certainly getting closer. However, the sprite offsets are proving to be a problem. That section with the //needs careful rethinking in particular.

And I suppose I could let off with DONTFLIP entirely and turn it into another flag, one that would allow my lightning rotations to be so much easier.

If you want I could make a fake pull request so you can view all the code changed thus far.

I shall pause and await your input before proceeding.

User avatar
Nash
Developer
Developer
Posts: 1226
Joined: Sun Sep 25, 2005 1:49
Location: Kuala Lumpur, Malaysia
Contact:

Re: FLATSPRITE discussion

Post by Nash » Wed Sep 14, 2016 6:34

Are you sure this isn't turning into the mish mash of compensations and over-convoluted-ness like what the old thing was (and basically back to square one)? I mean if the sprite splitting is happening again, looks to me that whatever is happening or being done here isn't anything new or improved. Just checking. :mrgreen:

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

Re: FLATSPRITE discussion

Post by Major Cooke » Wed Sep 14, 2016 14:01

To be completely honest, unsure. Sometimes it feels like a guessing game -- keep trying different things until it starts to work, though thankfully I haven't had to do that most of the time.

What I do understand is the rotation and the scale so far. Now I just need to make the position actually work and respect ROLLCENTER, which is proving to be far more difficult than it sounds.

I know nothing about the slicing issue unfortunately. I don't think any of this will ever address it -- it might be more of something that needs addressing with the scissoring itself, perhaps.

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

Re: FLATSPRITE discussion

Post by Major Cooke » Thu Sep 15, 2016 3:19

Here's a FAKE pull request so everyone can see all the changes in one.

Graf, I'll need input from you before I can continue -- further attempts to make ROLLCENTER and non-centered positioning have not gone over well.

Also... MetaDoom is drawing a lot of attention towards this.

User avatar
Graf Zahl
GZDoom Developer
GZDoom Developer
Posts: 7148
Joined: Wed Jul 20, 2005 9:48
Location: Germany
Contact:

Re: FLATSPRITE discussion

Post by Graf Zahl » Thu Sep 15, 2016 7:08

Please make a real pull request. I cannot access the necessary information from this one to merge it into my code base for testing.

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

Re: FLATSPRITE discussion

Post by Major Cooke » Thu Sep 15, 2016 10:28


User avatar
Graf Zahl
GZDoom Developer
GZDoom Developer
Posts: 7148
Joined: Wed Jul 20, 2005 9:48
Location: Germany
Contact:

Re: FLATSPRITE discussion

Post by Graf Zahl » Thu Sep 15, 2016 10:32

One thing I can tell you outright:

Code: Select all

		{
-			// Flat sprites cannot rotate in a predictable manner.
-			patch = gl_GetSpriteFrame(spritenum, thing->frame, 0, 0, &mirror);
+			patch = gl_GetSpriteFrame(spritenum, thing->frame, -1, (ang - (thing->Angles.Yaw + thing->SpriteRotation)).BAMs(), &mirror);
 		
Sorry, but no. This is dead wrong and will never work. That's why it was disabled. You cannot use face sprite projection to determine the rotation being used here.

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

Re: FLATSPRITE discussion

Post by Major Cooke » Thu Sep 15, 2016 11:54

Reversed.

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

Re: FLATSPRITE discussion

Post by Major Cooke » Thu Sep 15, 2016 14:17

I've pushed another commit. While ROLLCENTER works, the inverse does not. Currently toying with order of rotations to achieve its old effect.

Code: Select all

Actor A
{
	+NOINTERACTION
	+ROLLSPRITE
	+FLATSPRITE
	+DONTFLIP
	+SPRITEANGLE
	+ROLLCENTER
	States
	{
	Spawn:
		HEAD A 1 
		{
			angle += 1;
			angle %= 360;
			pitch = 45;
			A_SetRoll(roll + 20,SPF_INTERPOLATE);
			roll %= 360;
		}
		Loop
	}
}
And one thing to note in case if it's more important than I realize:

Code: Select all

					v[0] = mat * FVector3(x1, z, y1);
					v[1] = mat * FVector3(x1, z, y2);
					v[2] = mat * FVector3(x2, z, y1);
					v[3] = mat * FVector3(x2, z, y2);
I replaced the z1 and z2 with just z because I couldn't get it flat otherwise.

User avatar
Graf Zahl
GZDoom Developer
GZDoom Developer
Posts: 7148
Joined: Wed Jul 20, 2005 9:48
Location: Germany
Contact:

Re: FLATSPRITE discussion

Post by Graf Zahl » Thu Sep 15, 2016 17:42

Obviously for an unrotated flat sprite z must be the same in all 4 corners, so no surprise here. :P

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

Re: FLATSPRITE discussion

Post by Major Cooke » Thu Sep 15, 2016 18:33

Okay, I'm out of ideas. I need some help here. https://github.com/coelckers/gzdoom/pull/99

I'm attempting to offset the sprite by its offsets but this isn't working out at all.

I'm trying to make it respect the natural offsets but this is just giving me a giant headache.

Code: Select all

if (!(actor->renderflags & RF_ROLLCENTER))
					{
						float cz = (-z + (z1 + z2) * 0.5) + (z2 - z1) * 0.5;
						float cy = -y + (y1 + y2) * 0.5;
						float cx = -x + (x1 + x2) * 0.5;
						
						mat.Translate(cx, cz, cy);
						mat.Rotate(0, 1, 0, actor->Angles.Yaw.Degrees);
						//mat.Translate(-cx, -cz, -cy);
						mat.Rotate(0, 0, 1, -actor->Angles.Pitch.Degrees);
						//mat.Translate(cx, cz, cy);
						mat.Rotate(0, 1, 0, actor->Angles.Roll.Degrees);
						mat.Translate(-cx, -cz, -cy);
					}

User avatar
Graf Zahl
GZDoom Developer
GZDoom Developer
Posts: 7148
Joined: Wed Jul 20, 2005 9:48
Location: Germany
Contact:

Re: FLATSPRITE discussion

Post by Graf Zahl » Thu Sep 15, 2016 23:25

I see one big error in here. When you calculate the initial coordinates you use leftfac and rightfac to offset x and y. But these are only the x-offset. For y you need to do the same calculations with the sprite's y-offset (think topfac and bottomfac.)

That causes the sprite to get placed incorrectly and all rotations around the pivot will fail.

Locked

Return to “GZDoom”