Page 3 of 4

Re: FLATSPRITE discussion

Posted: Tue Sep 13, 2016 17:57
by Major Cooke
...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.

Re: FLATSPRITE discussion

Posted: Tue Sep 13, 2016 20:14
by Major Cooke
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.

Re: FLATSPRITE discussion

Posted: Tue Sep 13, 2016 20:17
by Graf Zahl
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.

Re: FLATSPRITE discussion

Posted: Tue Sep 13, 2016 20:18
by Major Cooke
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.

Re: FLATSPRITE discussion

Posted: Wed Sep 14, 2016 6:34
by Nash
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:

Re: FLATSPRITE discussion

Posted: Wed Sep 14, 2016 14:01
by Major Cooke
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.

Re: FLATSPRITE discussion

Posted: Thu Sep 15, 2016 3:19
by Major Cooke
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.

Re: FLATSPRITE discussion

Posted: Thu Sep 15, 2016 7:08
by Graf Zahl
Please make a real pull request. I cannot access the necessary information from this one to merge it into my code base for testing.

Re: FLATSPRITE discussion

Posted: Thu Sep 15, 2016 10:28
by Major Cooke

Re: FLATSPRITE discussion

Posted: Thu Sep 15, 2016 10:32
by Graf Zahl
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.

Re: FLATSPRITE discussion

Posted: Thu Sep 15, 2016 11:54
by Major Cooke
Reversed.

Re: FLATSPRITE discussion

Posted: Thu Sep 15, 2016 14:17
by Major Cooke
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.

Re: FLATSPRITE discussion

Posted: Thu Sep 15, 2016 17:42
by Graf Zahl
Obviously for an unrotated flat sprite z must be the same in all 4 corners, so no surprise here. :P

Re: FLATSPRITE discussion

Posted: Thu Sep 15, 2016 18:33
by Major Cooke
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);
					}

Re: FLATSPRITE discussion

Posted: Thu Sep 15, 2016 23:25
by Graf Zahl
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.