From bac12948e5f1a62b1820dc8d66e5fd1a8a503d8c Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Sat, 14 Oct 2023 10:35:28 -0400 Subject: [PATCH] - add `forcecullbackfaces` in `modeldef` --- src/r_data/models.cpp | 4 ++++ src/r_data/models.h | 29 +++++++++++++------------- src/rendering/hwrenderer/hw_models.cpp | 4 ++-- 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/src/r_data/models.cpp b/src/r_data/models.cpp index ab632b34f..85f646b41 100644 --- a/src/r_data/models.cpp +++ b/src/r_data/models.cpp @@ -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); diff --git a/src/r_data/models.h b/src/r_data/models.h index 568ad5399..b80550ab2 100644 --- a/src/r_data/models.h +++ b/src/r_data/models.h @@ -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); diff --git a/src/rendering/hwrenderer/hw_models.cpp b/src/rendering/hwrenderer/hw_models.cpp index b0fb572be..733f54d2f 100644 --- a/src/rendering/hwrenderer/hw_models.cpp +++ b/src/rendering/hwrenderer/hw_models.cpp @@ -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); }