mirror of
https://github.com/ZDoom/qzdoom.git
synced 2025-02-13 15:41:30 +00:00
Major Cooke: Added A_SpriteOffset
- Coordinates work akin to A_OverlayOffset: +X shifts to the right, +Y shifts down.
This commit is contained in:
parent
d2ecc535c1
commit
39bcc7b3fb
9 changed files with 39 additions and 3 deletions
|
@ -989,6 +989,7 @@ public:
|
|||
|
||||
DVector3 OldRenderPos;
|
||||
DVector3 Vel;
|
||||
DVector2 SpriteOffset;
|
||||
double Speed;
|
||||
double FloatSpeed;
|
||||
|
||||
|
|
|
@ -366,7 +366,8 @@ void AActor::Serialize(FSerializer &arc)
|
|||
A("spawntime", SpawnTime)
|
||||
A("spawnorder", SpawnOrder)
|
||||
A("friction", Friction)
|
||||
A("userlights", UserLights);
|
||||
A("userlights", UserLights)
|
||||
A("SpriteOffset", SpriteOffset);
|
||||
}
|
||||
|
||||
#undef A
|
||||
|
|
|
@ -847,11 +847,21 @@ void HWSprite::Process(HWDrawInfo *di, AActor* thing, sector_t * sector, area_t
|
|||
|
||||
r.Scale(sprscale.X, sprscale.Y);
|
||||
|
||||
float rightfac = -r.left;
|
||||
// Disable this for flat/wall sprites. Facing sprites work just fine though.
|
||||
float SOX = thing->SpriteOffset.X;
|
||||
float SOY = thing->SpriteOffset.Y;
|
||||
|
||||
if (spritetype & (RF_FLATSPRITE | RF_WALLSPRITE))
|
||||
{
|
||||
SOX = 0.f;
|
||||
SOY = 0.f;
|
||||
}
|
||||
|
||||
float rightfac = -r.left - SOX;
|
||||
float leftfac = rightfac - r.width;
|
||||
float bottomfac = -r.top;
|
||||
float topfac = bottomfac - r.height;
|
||||
z1 = z - r.top;
|
||||
z1 = z - r.top - SOY;
|
||||
z2 = z1 - r.height;
|
||||
|
||||
float spriteheight = sprscale.Y * r.height;
|
||||
|
|
|
@ -66,6 +66,10 @@ bool RenderPolySprite::GetLine(AActor *thing, DVector2 &left, DVector2 &right)
|
|||
else
|
||||
offsetX = tex->GetLeftOffsetPo() * thingxscalemul;
|
||||
|
||||
uint32_t type = (thing->renderflags & RF_SPRITETYPEMASK);
|
||||
if (!(type & (RF_FLATSPRITE | RF_WALLSPRITE)))
|
||||
offsetX -= thing->SpriteOffset.X;
|
||||
|
||||
left = DVector2(pos.X - viewpoint.Sin * offsetX, pos.Y + viewpoint.Cos * offsetX);
|
||||
right = DVector2(left.X + viewpoint.Sin * spriteWidth, left.Y - viewpoint.Cos * spriteWidth);
|
||||
return true;
|
||||
|
@ -115,6 +119,9 @@ void RenderPolySprite::Render(PolyRenderThread *thread, AActor *thing, subsector
|
|||
posZ -= (tex->GetHeight() - tex->GetTopOffsetPo()) * thingyscalemul;
|
||||
posZ = PerformSpriteClipAdjustment(thing, thingpos, spriteHeight, posZ);
|
||||
|
||||
if (!(spritetype & (RF_FLATSPRITE | RF_WALLSPRITE)))
|
||||
posZ -= thing->SpriteOffset.Y;
|
||||
|
||||
//double depth = 1.0;
|
||||
//visstyle_t visstyle = GetSpriteVisStyle(thing, depth);
|
||||
// Rumor has it that AlterWeaponSprite needs to be called with visstyle passed in somewhere around here..
|
||||
|
|
|
@ -1005,6 +1005,11 @@ namespace swrenderer
|
|||
sprite.pos = thing->InterpolatedPosition(Thread->Viewport->viewpoint.TicFrac);
|
||||
sprite.pos.Z += thing->GetBobOffset(Thread->Viewport->viewpoint.TicFrac);
|
||||
|
||||
// The X offsetting is performed in r_sprite.cpp, in RenderSprite::Project().
|
||||
uint32_t type = (thing->renderflags & RF_SPRITETYPEMASK);
|
||||
if (!(type & (RF_FLATSPRITE | RF_WALLSPRITE)))
|
||||
sprite.pos.Z -= thing->SpriteOffset.Y;
|
||||
|
||||
sprite.spritenum = thing->sprite;
|
||||
sprite.tex = nullptr;
|
||||
sprite.voxel = nullptr;
|
||||
|
|
|
@ -95,6 +95,11 @@ namespace swrenderer
|
|||
}
|
||||
//tx2 = tx >> 4;
|
||||
|
||||
// The Y offsetting is done in r_opaque_pass.cpp, in RenderOpaquePass::GetThingSprite().
|
||||
uint32_t type = (thing->renderflags & RF_SPRITETYPEMASK);
|
||||
if (!(type & (RF_FLATSPRITE | RF_WALLSPRITE)))
|
||||
tx += thing->SpriteOffset.X;
|
||||
|
||||
// too far off the side?
|
||||
if (fabs(tx / 64) > fabs(tz))
|
||||
{
|
||||
|
|
|
@ -1711,6 +1711,7 @@ DEFINE_FIELD_NAMED(AActor, __Pos, pos)
|
|||
DEFINE_FIELD_NAMED(AActor, __Pos.X, x)
|
||||
DEFINE_FIELD_NAMED(AActor, __Pos.Y, y)
|
||||
DEFINE_FIELD_NAMED(AActor, __Pos.Z, z)
|
||||
DEFINE_FIELD(AActor, SpriteOffset)
|
||||
DEFINE_FIELD(AActor, Prev)
|
||||
DEFINE_FIELD(AActor, SpriteAngle)
|
||||
DEFINE_FIELD(AActor, SpriteRotation)
|
||||
|
|
|
@ -95,4 +95,9 @@ extend class Actor
|
|||
}
|
||||
}
|
||||
|
||||
void A_SpriteOffset(double ox = 0.0, double oy = 0.0)
|
||||
{
|
||||
SpriteOffset.X = ox;
|
||||
SpriteOffset.Y = oy;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -89,6 +89,7 @@ class Actor : Thinker native
|
|||
native PlayerInfo Player;
|
||||
native readonly vector3 Pos;
|
||||
native vector3 Prev;
|
||||
native vector2 SpriteOffset;
|
||||
native double spriteAngle;
|
||||
native double spriteRotation;
|
||||
native double VisibleStartAngle;
|
||||
|
|
Loading…
Reference in a new issue