Added code for rotating the PSprite, courtesy of IvanDobrovski.

- However, the XY offsets are relative as a result.This must be made toggleable.
This commit is contained in:
Major Cooke 2020-09-30 14:47:00 -05:00 committed by Christoph Oelckers
commit 8f74cebd44
4 changed files with 59 additions and 19 deletions

View file

@ -142,8 +142,6 @@ DEFINE_FIELD(DPSprite, oldscalex)
DEFINE_FIELD(DPSprite, oldscaley)
DEFINE_FIELD(DPSprite, rotation)
DEFINE_FIELD(DPSprite, oldrotation)
DEFINE_FIELD(DPSprite, PivotPercent)
DEFINE_FIELD(DPSprite, PivotScreen)
DEFINE_FIELD(DPSprite, firstTic)
DEFINE_FIELD(DPSprite, Tics)
DEFINE_FIELD(DPSprite, Translation)
@ -157,6 +155,7 @@ DEFINE_FIELD_BIT(DPSprite, Flags, bMirror, PSPF_MIRROR)
DEFINE_FIELD_BIT(DPSprite, Flags, bPlayerTranslated, PSPF_PLAYERTRANSLATED)
DEFINE_FIELD_BIT(DPSprite, Flags, bPivotPercent, PSPF_PIVOTPERCENT)
DEFINE_FIELD_BIT(DPSprite, Flags, bPivotScreen, PSPF_PIVOTSCREEN)
DEFINE_FIELD_BIT(DPSprite, Flags, bPivotOffsetRel, PSPF_PIVOTOFFSETREL)
//------------------------------------------------------------------------
//
@ -185,7 +184,8 @@ DPSprite::DPSprite(player_t *owner, AActor *caller, int id)
oldpx(.0), oldpy(.0),
oldrotation(.0),
PivotPercent(true),
PivotScreen(false)
PivotScreen(false),
PivotOffsetRel(false)
{
alpha = 1;
Renderstyle = STYLE_Normal;

View file

@ -73,6 +73,7 @@ enum PSPFlags
PSPF_PLAYERTRANSLATED = 1 << 10,
PSPF_PIVOTPERCENT = 1 << 11,
PSPF_PIVOTSCREEN = 1 << 12,
PSPF_PIVOTOFFSETREL = 1 << 13,
};
class DPSprite : public DObject
@ -101,6 +102,7 @@ public:
bool PivotScreen; // If true, the pivot is based on the entire screen width/height instead of the image's dimensions/position.
bool PivotPercent; // If true, the pivot goes between [0.0, 1.0]. Otherwise, it's a pixel position offset from the image size.
bool PivotOffsetRel; // If true, x & y are relative to rotation. Otherwise, x is left/right and y is up/down.
double px, py; // pivot points
double oldpx, oldpy;
double rotation; // How much rotation to apply.