From f91342634871564dfade41a8d629c0f9046107d4 Mon Sep 17 00:00:00 2001 From: Robert Beckebans Date: Fri, 17 May 2024 16:28:32 +0200 Subject: [PATCH] Allow scalable models like in Quake 3. Close #668 --- neo/d3xp/Entity.cpp | 43 ++++++++++++++++++++++++++++++++----------- neo/d3xp/Light.cpp | 11 ++++++++++- 2 files changed, 42 insertions(+), 12 deletions(-) diff --git a/neo/d3xp/Entity.cpp b/neo/d3xp/Entity.cpp index 3d660096..046d32da 100644 --- a/neo/d3xp/Entity.cpp +++ b/neo/d3xp/Entity.cpp @@ -320,18 +320,19 @@ void idGameEdit::ParseSpawnArgsToRenderEntity( const idDict* args, renderEntity_ if( !args->GetMatrix( "rotation", "1 0 0 0 1 0 0 0 1", renderEntity->axis ) ) { // RB: TrenchBroom interop - // support "angles" like in Quake 3 + // support "angles", "modelscale" and "modelscale_vec" like in Quake 3 idAngles angles; + idMat3 rotMat; + idMat3 scaleMat; + + rotMat.Identity(); + scaleMat.Identity(); if( args->GetAngles( "angles", "0 0 0", angles ) ) { if( angles.pitch != 0.0f || angles.yaw != 0.0f || angles.roll != 0.0f ) { - renderEntity->axis = angles.ToMat3(); - } - else - { - renderEntity->axis.Identity(); + rotMat = angles.ToMat3(); } } else @@ -339,13 +340,33 @@ void idGameEdit::ParseSpawnArgsToRenderEntity( const idDict* args, renderEntity_ angle = args->GetFloat( "angle" ); if( angle != 0.0f ) { - renderEntity->axis = idAngles( 0.0f, angle, 0.0f ).ToMat3(); - } - else - { - renderEntity->axis.Identity(); + rotMat = idAngles( 0.0f, angle, 0.0f ).ToMat3(); } } + + idVec3 scaleVec; + if( args->GetVector( "modelscale_vec", "1 1 1", scaleVec ) ) + { + // don't allow very small and negative values + if( ( scaleVec.x != 1.0f || scaleVec.y != 1.0f || scaleVec.z != 1.0f ) && ( scaleVec.x > 0.01f && scaleVec.y > 0.01f && scaleVec.z > 0.01f ) ) + { + scaleMat[0][0] = scaleVec.x; + scaleMat[1][1] = scaleVec.y; + scaleMat[2][2] = scaleVec.z; + } + } + else + { + float scale = args->GetFloat( "modelscale", 1.0f ); + if( scale != 1.0f && scale > 0.01f ) + { + scaleMat[0][0] = scale; + scaleMat[1][1] = scale; + scaleMat[2][2] = scale; + } + } + + renderEntity->axis = scaleMat * rotMat; // RB end } diff --git a/neo/d3xp/Light.cpp b/neo/d3xp/Light.cpp index e9c56271..34f419f0 100644 --- a/neo/d3xp/Light.cpp +++ b/neo/d3xp/Light.cpp @@ -234,7 +234,16 @@ void idLight::UpdateChangeableSpawnArgs( const idDict* source ) // link func_static modelTarget modelTarget = NULL; - const char* target = source->GetString( "modelTarget" ); + const char* target = NULL; + if( source ) + { + target = source->GetString( "modelTarget" ); + } + else + { + target = spawnArgs.GetString( "modelTarget" ); + } + if( target != NULL && target[0] != '\0' ) { PostEventMS( &EV_Light_UpdateModelTarget, 0 );