Skip to content

Commit

Permalink
Added PitchFromMomentum, UseActorPitch and UseActorRoll to VOXELDEF. …
Browse files Browse the repository at this point in the history
…Behaves exactly like their 3D model counterparts. Hardware renderer only.
  • Loading branch information
nashmuhandes authored and coelckers committed Jul 25, 2022
1 parent eb94f81 commit 351a4c9
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/common/models/voxels.h
Expand Up @@ -70,6 +70,9 @@ struct FVoxelDef
int VoxeldefIndex; // Needed by GZDoom
double Scale;
DAngle AngleOffset;// added to actor's angle to compensate for wrong-facing voxels
bool PitchFromMomentum;
bool UseActorPitch;
bool UseActorRoll;
};

extern TDeletingArray<FVoxel *> Voxels; // used only to auto-delete voxels on exit.
Expand Down
3 changes: 3 additions & 0 deletions src/r_data/models.cpp
Expand Up @@ -390,6 +390,9 @@ void InitModels()
smf.skinIDs[0] = md->GetPaletteTexture();
smf.xscale = smf.yscale = smf.zscale = VoxelDefs[i]->Scale;
smf.angleoffset = VoxelDefs[i]->AngleOffset.Degrees;
if (VoxelDefs[i]->PitchFromMomentum) smf.flags |= MDL_PITCHFROMMOMENTUM;
if (VoxelDefs[i]->UseActorPitch) smf.flags |= MDL_USEACTORPITCH;
if (VoxelDefs[i]->UseActorRoll) smf.flags |= MDL_USEACTORROLL;
if (VoxelDefs[i]->PlacedSpin != 0)
{
smf.yrotate = 1.f;
Expand Down
21 changes: 20 additions & 1 deletion src/r_data/voxeldef.cpp
Expand Up @@ -53,14 +53,18 @@
struct VoxelOptions
{
VoxelOptions()
: DroppedSpin(0), PlacedSpin(0), Scale(1.), AngleOffset(90.), OverridePalette(false)
: DroppedSpin(0), PlacedSpin(0), Scale(1.), AngleOffset(90.), OverridePalette(false),
PitchFromMomentum(false), UseActorPitch(false), UseActorRoll(false)
{}

int DroppedSpin;
int PlacedSpin;
double Scale;
DAngle AngleOffset;
bool OverridePalette;
bool PitchFromMomentum;
bool UseActorPitch;
bool UseActorRoll;
};

void VOX_AddVoxel(int sprnum, int frame, FVoxelDef* def);
Expand Down Expand Up @@ -180,6 +184,18 @@ static void VOX_ReadOptions(FScanner &sc, VoxelOptions &opts)
{
opts.OverridePalette = true;
}
else if (sc.Compare("pitchfrommomentum"))
{
opts.PitchFromMomentum = true;
}
else if (sc.Compare("useactorpitch"))
{
opts.UseActorPitch = true;
}
else if (sc.Compare("useactorroll"))
{
opts.UseActorRoll = true;
}
else
{
sc.ScriptMessage("Unknown voxel option '%s'\n", sc.String);
Expand Down Expand Up @@ -249,6 +265,9 @@ void R_InitVoxels()
def->DroppedSpin = opts.DroppedSpin;
def->PlacedSpin = opts.PlacedSpin;
def->AngleOffset = opts.AngleOffset;
def->PitchFromMomentum = opts.PitchFromMomentum;
def->UseActorPitch = opts.UseActorPitch;
def->UseActorRoll = opts.UseActorRoll;
VoxelDefs.Push(def);

for (unsigned i = 0; i < vsprites.Size(); ++i)
Expand Down

0 comments on commit 351a4c9

Please sign in to comment.