mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-02-20 11:03:08 +00:00
Make model stretch fix opt-in with a flag.
This commit is contained in:
parent
0509d3a4e7
commit
eab675c0cb
2 changed files with 21 additions and 3 deletions
|
@ -135,8 +135,15 @@ void RenderModel(FModelRenderer *renderer, float x, float y, float z, FSpriteMod
|
||||||
angle += actor->SpriteRotation.Degrees();
|
angle += actor->SpriteRotation.Degrees();
|
||||||
|
|
||||||
// consider the pixel stretching. For non-voxels this must be factored out here
|
// consider the pixel stretching. For non-voxels this must be factored out here
|
||||||
float stretch = (smf->modelIDs[0] != -1 ? Models[smf->modelIDs[0]]->getAspectFactor(actor->Level->info->pixelstretch) : 1.f) / actor->Level->info->pixelstretch;
|
float stretch = 1.f;
|
||||||
|
|
||||||
|
// [MK] distortions might happen depending on when the pixel stretch is compensated for
|
||||||
|
// so we make the "undistorted" behavior opt-in
|
||||||
|
if (smf->flags & MDL_CORRECTPIXELSTRETCH)
|
||||||
|
{
|
||||||
|
stretch = (smf->modelIDs[0] != -1 ? Models[smf->modelIDs[0]]->getAspectFactor(actor->Level->info->pixelstretch) : 1.f) / actor->Level->info->pixelstretch;
|
||||||
objectToWorldMatrix.scale(1, stretch, 1);
|
objectToWorldMatrix.scale(1, stretch, 1);
|
||||||
|
}
|
||||||
|
|
||||||
// Applying model transformations:
|
// Applying model transformations:
|
||||||
// 1) Applying actor angle, pitch and roll to the model
|
// 1) Applying actor angle, pitch and roll to the model
|
||||||
|
@ -173,6 +180,12 @@ void RenderModel(FModelRenderer *renderer, float x, float y, float z, FSpriteMod
|
||||||
objectToWorldMatrix.rotate(smf->pitchoffset, 0, 0, 1);
|
objectToWorldMatrix.rotate(smf->pitchoffset, 0, 0, 1);
|
||||||
objectToWorldMatrix.rotate(-smf->rolloffset, 1, 0, 0);
|
objectToWorldMatrix.rotate(-smf->rolloffset, 1, 0, 0);
|
||||||
|
|
||||||
|
if (!(smf->flags & MDL_CORRECTPIXELSTRETCH))
|
||||||
|
{
|
||||||
|
stretch = (smf->modelIDs[0] != -1 ? Models[smf->modelIDs[0]]->getAspectFactor(actor->Level->info->pixelstretch) : 1.f) / actor->Level->info->pixelstretch;
|
||||||
|
objectToWorldMatrix.scale(1, stretch, 1);
|
||||||
|
}
|
||||||
|
|
||||||
float orientation = scaleFactorX * scaleFactorY * scaleFactorZ;
|
float orientation = scaleFactorX * scaleFactorY * scaleFactorZ;
|
||||||
|
|
||||||
renderer->BeginDrawModel(actor->RenderStyle, smf, objectToWorldMatrix, orientation < 0);
|
renderer->BeginDrawModel(actor->RenderStyle, smf, objectToWorldMatrix, orientation < 0);
|
||||||
|
@ -846,6 +859,10 @@ static void ParseModelDefLump(int Lump)
|
||||||
smf.rotationCenterY = 0.;
|
smf.rotationCenterY = 0.;
|
||||||
smf.rotationCenterZ = 0.;
|
smf.rotationCenterZ = 0.;
|
||||||
}
|
}
|
||||||
|
else if (sc.Compare("correctpixelstretch"))
|
||||||
|
{
|
||||||
|
smf.flags |= MDL_CORRECTPIXELSTRETCH;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sc.ScriptMessage("Unrecognized string \"%s\"", sc.String);
|
sc.ScriptMessage("Unrecognized string \"%s\"", sc.String);
|
||||||
|
|
|
@ -58,6 +58,7 @@ enum
|
||||||
MDL_NOPERPIXELLIGHTING = 1024, // forces a model to not use per-pixel lighting. useful for voxel-converted-to-model objects.
|
MDL_NOPERPIXELLIGHTING = 1024, // forces a model to not use per-pixel lighting. useful for voxel-converted-to-model objects.
|
||||||
MDL_SCALEWEAPONFOV = 2048, // scale weapon view model with higher user FOVs
|
MDL_SCALEWEAPONFOV = 2048, // scale weapon view model with higher user FOVs
|
||||||
MDL_MODELSAREATTACHMENTS = 4096, // any model index after 0 is treated as an attachment, and therefore will use the bone results of index 0
|
MDL_MODELSAREATTACHMENTS = 4096, // any model index after 0 is treated as an attachment, and therefore will use the bone results of index 0
|
||||||
|
MDL_CORRECTPIXELSTRETCH = 8192, // ensure model does not distort with pixel stretch when pitch/roll is applied
|
||||||
};
|
};
|
||||||
|
|
||||||
FSpriteModelFrame * FindModelFrame(const PClass * ti, int sprite, int frame, bool dropped);
|
FSpriteModelFrame * FindModelFrame(const PClass * ti, int sprite, int frame, bool dropped);
|
||||||
|
|
Loading…
Reference in a new issue