- add `forcecullbackfaces` in `modeldef`

This commit is contained in:
Rachael Alexanderson 2023-10-14 10:35:28 -04:00
parent dccce46d5b
commit bac12948e5
3 changed files with 21 additions and 16 deletions

View File

@ -931,6 +931,10 @@ static void ParseModelDefLump(int Lump)
{
smf.flags |= MDL_CORRECTPIXELSTRETCH;
}
else if (sc.Compare("forcecullbackfaces"))
{
smf.flags |= MDL_FORCECULLBACKFACES;
}
else
{
sc.ScriptMessage("Unrecognized string \"%s\"", sc.String);

View File

@ -45,20 +45,21 @@ enum
{
// [BB] Color translations for the model skin are ignored. This is
// useful if the skin texture is not using the game palette.
MDL_IGNORETRANSLATION = 1,
MDL_PITCHFROMMOMENTUM = 2,
MDL_ROTATING = 4,
MDL_INTERPOLATEDOUBLEDFRAMES = 8,
MDL_NOINTERPOLATION = 16,
MDL_USEACTORPITCH = 32,
MDL_USEACTORROLL = 64,
MDL_BADROTATION = 128,
MDL_DONTCULLBACKFACES = 256,
MDL_USEROTATIONCENTER = 512,
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
MDL_IGNORETRANSLATION = 1>>0,
MDL_PITCHFROMMOMENTUM = 1>>1,
MDL_ROTATING = 1>>2,
MDL_INTERPOLATEDOUBLEDFRAMES = 1>>3,
MDL_NOINTERPOLATION = 1>>4,
MDL_USEACTORPITCH = 1>>5,
MDL_USEACTORROLL = 1>>6,
MDL_BADROTATION = 1>>7,
MDL_DONTCULLBACKFACES = 1>>8,
MDL_USEROTATIONCENTER = 1>>9,
MDL_NOPERPIXELLIGHTING = 1>>10, // forces a model to not use per-pixel lighting. useful for voxel-converted-to-model objects.
MDL_SCALEWEAPONFOV = 1>11, // scale weapon view model with higher user FOVs
MDL_MODELSAREATTACHMENTS = 1>>12, // any model index after 0 is treated as an attachment, and therefore will use the bone results of index 0
MDL_CORRECTPIXELSTRETCH = 1>>13, // ensure model does not distort with pixel stretch when pitch/roll is applied
MDL_FORCECULLBACKFACES = 1>>14,
};
FSpriteModelFrame * FindModelFrame(const PClass * ti, int sprite, int frame, bool dropped);

View File

@ -61,7 +61,7 @@ void FHWModelRenderer::BeginDrawModel(FRenderStyle style, FSpriteModelFrame *smf
// This solves a few of the problems caused by the lack of depth sorting.
// [Nash] Don't do back face culling if explicitly specified in MODELDEF
// TO-DO: Implement proper depth sorting.
if (!(style == DefaultRenderStyle()) && !(smf->flags & MDL_DONTCULLBACKFACES))
if ((smf->flags & MDL_FORCECULLBACKFACES) || (!(style == DefaultRenderStyle()) && !(smf->flags & MDL_DONTCULLBACKFACES)))
{
state.SetCulling((mirrored ^ portalState.isMirrored()) ? Cull_CCW : Cull_CW);
}
@ -75,7 +75,7 @@ void FHWModelRenderer::EndDrawModel(FRenderStyle style, FSpriteModelFrame *smf)
state.SetBoneIndexBase(-1);
state.EnableModelMatrix(false);
state.SetDepthFunc(DF_Less);
if (!(style == DefaultRenderStyle()) && !(smf->flags & MDL_DONTCULLBACKFACES))
if ((smf->flags & MDL_FORCECULLBACKFACES) || (!(style == DefaultRenderStyle()) && !(smf->flags & MDL_DONTCULLBACKFACES)))
state.SetCulling(Cull_None);
}