mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-29 07:12:36 +00:00
Added A_SpriteOffset. (#895)
- Coordinates work akin to A_OverlayOffset: +X shifts to the right, +Y shifts down.
This commit is contained in:
parent
3e69e44763
commit
85759e3bd0
8 changed files with 36 additions and 16 deletions
|
@ -995,6 +995,7 @@ public:
|
|||
|
||||
DVector3 OldRenderPos;
|
||||
DVector3 Vel;
|
||||
DVector2 SpriteOffset;
|
||||
double Speed;
|
||||
double FloatSpeed;
|
||||
|
||||
|
|
|
@ -365,6 +365,7 @@ void AActor::Serialize(FSerializer &arc)
|
|||
A("spawntime", SpawnTime)
|
||||
A("spawnorder", SpawnOrder)
|
||||
A("friction", Friction)
|
||||
A("SpriteOffset", SpriteOffset)
|
||||
A("userlights", UserLights);
|
||||
|
||||
SerializeTerrain(arc, "floorterrain", floorterrain, &def->floorterrain);
|
||||
|
|
|
@ -899,11 +899,10 @@ void HWSprite::Process(HWDrawInfo *di, AActor* thing, sector_t * sector, area_t
|
|||
|
||||
r.Scale(sprscale.X, sprscale.Y);
|
||||
|
||||
float rightfac = -r.left;
|
||||
float SpriteOffY = thing->SpriteOffset.Y;
|
||||
float rightfac = -r.left - thing->SpriteOffset.X;
|
||||
float leftfac = rightfac - r.width;
|
||||
float bottomfac = -r.top;
|
||||
float topfac = bottomfac - r.height;
|
||||
z1 = z - r.top;
|
||||
z1 = z - r.top - SpriteOffY;
|
||||
z2 = z1 - r.height;
|
||||
|
||||
float spriteheight = sprscale.Y * r.height;
|
||||
|
@ -914,31 +913,39 @@ void HWSprite::Process(HWDrawInfo *di, AActor* thing, sector_t * sector, area_t
|
|||
PerformSpriteClipAdjustment(thing, thingpos, spriteheight);
|
||||
}
|
||||
|
||||
float viewvecX;
|
||||
float viewvecY;
|
||||
switch (spritetype)
|
||||
{
|
||||
case RF_FACESPRITE:
|
||||
viewvecX = vp.ViewVector.X;
|
||||
viewvecY = vp.ViewVector.Y;
|
||||
{
|
||||
float viewvecX = vp.ViewVector.X;
|
||||
float viewvecY = vp.ViewVector.Y;
|
||||
|
||||
x1 = x - viewvecY*leftfac;
|
||||
x2 = x - viewvecY*rightfac;
|
||||
y1 = y + viewvecX*leftfac;
|
||||
y2 = y + viewvecX*rightfac;
|
||||
break;
|
||||
|
||||
}
|
||||
case RF_FLATSPRITE:
|
||||
{
|
||||
float bottomfac = -r.top - SpriteOffY;
|
||||
float topfac = bottomfac - r.height;
|
||||
|
||||
x1 = x + leftfac;
|
||||
x2 = x + rightfac;
|
||||
y1 = y - topfac;
|
||||
y2 = y - bottomfac;
|
||||
// [MC] Counteract in case of any potential problems. Tests so far haven't
|
||||
// shown any outstanding issues but that doesn't mean they won't appear later
|
||||
// when more features are added.
|
||||
z1 += SpriteOffY;
|
||||
z2 += SpriteOffY;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case RF_WALLSPRITE:
|
||||
viewvecX = Angles.Yaw.Cos();
|
||||
viewvecY = Angles.Yaw.Sin();
|
||||
{
|
||||
float viewvecX = Angles.Yaw.Cos();
|
||||
float viewvecY = Angles.Yaw.Sin();
|
||||
|
||||
x1 = x + viewvecY*leftfac;
|
||||
x2 = x + viewvecY*rightfac;
|
||||
|
@ -946,6 +953,7 @@ void HWSprite::Process(HWDrawInfo *di, AActor* thing, sector_t * sector, area_t
|
|||
y2 = y - viewvecX*rightfac;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -1004,9 +1004,9 @@ namespace swrenderer
|
|||
|
||||
bool RenderOpaquePass::GetThingSprite(AActor *thing, ThingSprite &sprite)
|
||||
{
|
||||
// The X offsetting (SpriteOffset.X) is performed in r_sprite.cpp, in RenderSprite::Project().
|
||||
sprite.pos = thing->InterpolatedPosition(Thread->Viewport->viewpoint.TicFrac);
|
||||
sprite.pos.Z += thing->GetBobOffset(Thread->Viewport->viewpoint.TicFrac);
|
||||
|
||||
sprite.pos.Z += thing->GetBobOffset(Thread->Viewport->viewpoint.TicFrac) - thing->SpriteOffset.Y;
|
||||
sprite.spritenum = thing->sprite;
|
||||
sprite.tex = nullptr;
|
||||
sprite.voxel = nullptr;
|
||||
|
|
|
@ -81,8 +81,11 @@ namespace swrenderer
|
|||
const double thingxscalemul = spriteScale.X / tex->GetScale().X;
|
||||
|
||||
// Calculate billboard line for the sprite
|
||||
double SpriteOffX = (thing) ? thing->SpriteOffset.X : 0.;
|
||||
DVector2 dir = { viewport->viewpoint.Sin, -viewport->viewpoint.Cos };
|
||||
DVector2 pt1 = pos.XY() - viewport->viewpoint.Pos.XY() - dir * (((renderflags & RF_XFLIP) ? (tex->GetWidth() - tex->GetLeftOffsetSW() - 1) : tex->GetLeftOffsetSW()) * thingxscalemul);
|
||||
DVector2 trs = pos.XY() - viewport->viewpoint.Pos.XY();
|
||||
trs = { trs.X + SpriteOffX * dir.X, trs.Y + SpriteOffX * dir.Y };
|
||||
DVector2 pt1 = trs - dir * (((renderflags & RF_XFLIP) ? (tex->GetWidth() - tex->GetLeftOffsetSW() - 1) : tex->GetLeftOffsetSW()) * thingxscalemul);
|
||||
DVector2 pt2 = pt1 + dir * (tex->GetWidth() * thingxscalemul);
|
||||
|
||||
FWallCoords wallc;
|
||||
|
|
|
@ -1775,6 +1775,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