mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-02-16 17:21:10 +00:00
Add WorldOffset field
Adjusts the thing's 3D position on render side. This allows for adjusting a thing's visual position without impacting their hitbox. # Conflicts: # src/playsim/p_mobj.cpp
This commit is contained in:
parent
6b7ef697be
commit
a98c1efc26
6 changed files with 11 additions and 6 deletions
|
@ -1049,6 +1049,7 @@ public:
|
|||
DVector3 OldRenderPos;
|
||||
DVector3 Vel;
|
||||
DVector2 SpriteOffset;
|
||||
DVector3 WorldOffset;
|
||||
double Speed;
|
||||
double FloatSpeed;
|
||||
|
||||
|
|
|
@ -371,7 +371,8 @@ void AActor::Serialize(FSerializer &arc)
|
|||
A("friction", Friction)
|
||||
A("SpriteOffset", SpriteOffset)
|
||||
("viewpos", ViewPos)
|
||||
A("userlights", UserLights);
|
||||
A("userlights", UserLights)
|
||||
A("WorldOffset", WorldOffset);
|
||||
|
||||
SerializeTerrain(arc, "floorterrain", floorterrain, &def->floorterrain);
|
||||
SerializeArgs(arc, "args", args, def->args, special);
|
||||
|
|
|
@ -702,7 +702,7 @@ void HWSprite::Process(HWDrawInfo *di, AActor* thing, sector_t * sector, area_t
|
|||
return;
|
||||
}
|
||||
|
||||
const auto &vp = di->Viewpoint;
|
||||
const auto &vp = di->Viewpoint;
|
||||
AActor *camera = vp.camera;
|
||||
|
||||
if (thing->renderflags & RF_INVISIBLE || !thing->RenderStyle.IsVisible(thing->Alpha))
|
||||
|
@ -797,9 +797,9 @@ void HWSprite::Process(HWDrawInfo *di, AActor* thing, sector_t * sector, area_t
|
|||
bottomclip = rendersector->PortalBlocksMovement(sector_t::floor) ? -LARGE_VALUE : rendersector->GetPortalPlaneZ(sector_t::floor);
|
||||
|
||||
uint32_t spritetype = (thing->renderflags & RF_SPRITETYPEMASK);
|
||||
x = thingpos.X;
|
||||
z = thingpos.Z;
|
||||
y = thingpos.Y;
|
||||
x = thingpos.X + thing->WorldOffset.X;
|
||||
z = thingpos.Z + thing->WorldOffset.Z;
|
||||
y = thingpos.Y + thing->WorldOffset.Y;
|
||||
if (spritetype == RF_FACESPRITE) z -= thing->Floorclip; // wall and flat sprites are to be considered di->Level-> geometry so this may not apply.
|
||||
|
||||
// snap shadow Z to the floor
|
||||
|
@ -917,7 +917,7 @@ void HWSprite::Process(HWDrawInfo *di, AActor* thing, sector_t * sector, area_t
|
|||
thing->renderflags ^= RF_XFLIP;
|
||||
|
||||
r.Scale(sprscale.X, isSpriteShadow ? sprscale.Y * 0.15 : sprscale.Y);
|
||||
|
||||
|
||||
float SpriteOffY = thing->SpriteOffset.Y;
|
||||
float rightfac = -r.left - thing->SpriteOffset.X;
|
||||
float leftfac = rightfac - r.width;
|
||||
|
|
|
@ -1027,6 +1027,7 @@ namespace swrenderer
|
|||
{
|
||||
// The X offsetting (SpriteOffset.X) is performed in r_sprite.cpp, in RenderSprite::Project().
|
||||
sprite.pos = thing->InterpolatedPosition(Thread->Viewport->viewpoint.TicFrac);
|
||||
sprite.pos += thing->WorldOffset;
|
||||
sprite.pos.Z += thing->GetBobOffset(Thread->Viewport->viewpoint.TicFrac) - thing->SpriteOffset.Y;
|
||||
sprite.spritenum = thing->sprite;
|
||||
sprite.tex = nullptr;
|
||||
|
|
|
@ -1851,6 +1851,7 @@ 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, WorldOffset)
|
||||
DEFINE_FIELD(AActor, Prev)
|
||||
DEFINE_FIELD(AActor, SpriteAngle)
|
||||
DEFINE_FIELD(AActor, SpriteRotation)
|
||||
|
|
|
@ -100,6 +100,7 @@ class Actor : Thinker native
|
|||
native vector3 Prev;
|
||||
native uint ThruBits;
|
||||
native vector2 SpriteOffset;
|
||||
native vector3 WorldOffset;
|
||||
native double spriteAngle;
|
||||
native double spriteRotation;
|
||||
native float VisibleStartAngle;
|
||||
|
|
Loading…
Reference in a new issue