mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-25 21:41:03 +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();
|
||||
|
||||
// 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;
|
||||
objectToWorldMatrix.scale(1, stretch, 1);
|
||||
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);
|
||||
}
|
||||
|
||||
// Applying model transformations:
|
||||
// 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->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;
|
||||
|
||||
renderer->BeginDrawModel(actor->RenderStyle, smf, objectToWorldMatrix, orientation < 0);
|
||||
|
@ -846,6 +859,10 @@ static void ParseModelDefLump(int Lump)
|
|||
smf.rotationCenterY = 0.;
|
||||
smf.rotationCenterZ = 0.;
|
||||
}
|
||||
else if (sc.Compare("correctpixelstretch"))
|
||||
{
|
||||
smf.flags |= MDL_CORRECTPIXELSTRETCH;
|
||||
}
|
||||
else
|
||||
{
|
||||
sc.ScriptMessage("Unrecognized string \"%s\"", sc.String);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright(C) 2005-2016 Christoph Oelckers
|
||||
|
@ -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_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_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);
|
||||
|
|
Loading…
Reference in a new issue