mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-29 07:22:07 +00:00
Moved flatsprite code into CalculateVertices.
This commit is contained in:
parent
66d20726c2
commit
d01b0e061e
1 changed files with 39 additions and 49 deletions
|
@ -107,6 +107,43 @@ static const float LARGE_VALUE = 1e19f;
|
|||
|
||||
void GLSprite::CalculateVertices(FVector3 *v)
|
||||
{
|
||||
if (actor != nullptr && (actor->renderflags & RF_SPRITETYPEMASK) == RF_FLATSPRITE)
|
||||
{
|
||||
Matrix3x4 mat;
|
||||
mat.MakeIdentity();
|
||||
|
||||
float cx, cy, cz = z;
|
||||
if ((actor->renderflags & RF_ROLLCENTER))
|
||||
{
|
||||
cx = (x1 + x2) * 0.5;
|
||||
cy = (y1 + y2) * 0.5;
|
||||
}
|
||||
else
|
||||
{
|
||||
cx = x;
|
||||
cy = y;
|
||||
}
|
||||
|
||||
// [MC] Rotate around the center or offsets given to the sprites.
|
||||
// Counteract any existing rotations, then rotate the angle.
|
||||
// Tilt the actor up or down based on pitch (increase 'somersaults' forward).
|
||||
// Then counteract the roll and DO A BARREL ROLL.
|
||||
|
||||
FAngle pitch = (float)-actor->Angles.Pitch.Degrees;
|
||||
pitch.Normalized180();
|
||||
|
||||
mat.Translate(cx, cz, cy);
|
||||
mat.Rotate(0, 1, 0, 270. - actor->Angles.Yaw.Degrees + 90);
|
||||
mat.Rotate(0, 0, 1, pitch.Degrees);
|
||||
mat.Rotate(0, 1, 0, 270. - actor->Angles.Roll.Degrees);
|
||||
mat.Translate(-cx, -cz, -cy);
|
||||
v[0] = mat * FVector3(x1, z, y2);
|
||||
v[1] = mat * FVector3(x2, z, y2);
|
||||
v[2] = mat * FVector3(x1, z, y1);
|
||||
v[3] = mat * FVector3(x2, z, y1);
|
||||
return;
|
||||
}
|
||||
|
||||
// [BB] Billboard stuff
|
||||
const bool drawWithXYBillboard = ((particle && gl_billboard_particles) || (!(actor && actor->renderflags & RF_FORCEYBILLBOARD)
|
||||
//&& GLRenderer->mViewActor != NULL
|
||||
|
@ -363,54 +400,7 @@ void GLSprite::Draw(int pass)
|
|||
gl_RenderState.Apply();
|
||||
|
||||
FVector3 v[4];
|
||||
if (actor != nullptr)
|
||||
{
|
||||
if ((actor->renderflags & RF_SPRITETYPEMASK) == RF_FLATSPRITE)
|
||||
{
|
||||
Matrix3x4 mat;
|
||||
mat.MakeIdentity();
|
||||
|
||||
float cx, cy, cz = z;
|
||||
if ((actor->renderflags & RF_ROLLCENTER))
|
||||
{
|
||||
cx = (x1 + x2) * 0.5;
|
||||
cy = (y1 + y2) * 0.5;
|
||||
}
|
||||
else
|
||||
{
|
||||
cx = x;
|
||||
cy = y;
|
||||
}
|
||||
|
||||
// [MC] Rotate around the center or offsets given to the sprites.
|
||||
// Counteract any existing rotations, then rotate the angle.
|
||||
// Tilt the actor up or down based on pitch (increase 'somersaults' forward).
|
||||
// Then counteract the roll and DO A BARREL ROLL.
|
||||
|
||||
FAngle pitch = (float)-actor->Angles.Pitch.Degrees;
|
||||
pitch.Normalized180();
|
||||
|
||||
mat.Translate(cx, cz, cy);
|
||||
mat.Rotate(0, 1, 0, 270. - actor->Angles.Yaw.Degrees + 90);
|
||||
mat.Rotate(0, 0, 1, pitch.Degrees);
|
||||
mat.Rotate(0, 1, 0, 270. - actor->Angles.Roll.Degrees);
|
||||
mat.Translate(-cx, -cz, -cy);
|
||||
v[0] = mat * FVector3(x1, z, y2);
|
||||
v[1] = mat * FVector3(x2, z, y2);
|
||||
v[2] = mat * FVector3(x1, z, y1);
|
||||
v[3] = mat * FVector3(x2, z, y1);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
CalculateVertices(v);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CalculateVertices(v);
|
||||
}
|
||||
|
||||
CalculateVertices(v);
|
||||
|
||||
FQuadDrawer qd;
|
||||
qd.Set(0, v[0][0], v[0][1], v[0][2], ul, vt);
|
||||
|
|
Loading…
Reference in a new issue