From bba3027d3792d70fa7135d3a97495a4f510dd80e Mon Sep 17 00:00:00 2001 From: InsanityBringer Date: Wed, 28 Feb 2018 13:35:01 -0600 Subject: [PATCH] Add option to use Rotation-Center for an actor's normal pitch/angle/roll rotation. --- src/r_data/models/models.cpp | 15 +++++++++++++++ src/r_data/models/models.h | 1 + 2 files changed, 16 insertions(+) diff --git a/src/r_data/models/models.cpp b/src/r_data/models/models.cpp index ff799b14dd..3198afd7f6 100644 --- a/src/r_data/models/models.cpp +++ b/src/r_data/models/models.cpp @@ -125,9 +125,17 @@ void FModelRenderer::RenderModel(float x, float y, float z, FSpriteModelFrame *s // Applying model transformations: // 1) Applying actor angle, pitch and roll to the model + if (smf->flags & MDL_USEROTATIONCENTER) + { + objectToWorldMatrix.translate(smf->rotationCenterX, smf->rotationCenterZ, smf->rotationCenterY); + } objectToWorldMatrix.rotate(-angle, 0, 1, 0); objectToWorldMatrix.rotate(pitch, 0, 0, 1); objectToWorldMatrix.rotate(-roll, 1, 0, 0); + if (smf->flags & MDL_USEROTATIONCENTER) + { + objectToWorldMatrix.translate(-smf->rotationCenterX, -smf->rotationCenterZ, -smf->rotationCenterY); + } // 2) Applying Doomsday like rotation of the weapon pickup models // The rotation angle is based on the elapsed time. @@ -789,6 +797,13 @@ void gl_InitModels() { smf.flags |= MDL_DONTCULLBACKFACES; } + else if (sc.Compare("userotationcenter")) + { + smf.flags |= MDL_USEROTATIONCENTER; + smf.rotationCenterX = 0.; + smf.rotationCenterY = 0.; + smf.rotationCenterZ = 0.; + } else { sc.ScriptMessage("Unrecognized string \"%s\"", sc.String); diff --git a/src/r_data/models/models.h b/src/r_data/models/models.h index 4a8678fa6f..e6786a7210 100644 --- a/src/r_data/models/models.h +++ b/src/r_data/models/models.h @@ -447,6 +447,7 @@ enum MDL_USEACTORROLL = 64, MDL_BADROTATION = 128, MDL_DONTCULLBACKFACES = 256, + MDL_USEROTATIONCENTER = 512, }; struct FSpriteModelFrame