From fd8a59bd249f936a702765a0025b4869e3bfc172 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 4 May 2016 12:23:40 +0200 Subject: [PATCH] - fixed: INHERITACTORPITCH was inverted. - changed PITCHFORMOMENTUM to do nothing for very small velocities. --- src/gl/models/gl_models.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/gl/models/gl_models.cpp b/src/gl/models/gl_models.cpp index e2187c59c..22a4913a7 100644 --- a/src/gl/models/gl_models.cpp +++ b/src/gl/models/gl_models.cpp @@ -933,16 +933,19 @@ void gl_RenderModel(GLSprite * spr) const double x = spr->actor->Vel.X; const double y = spr->actor->Vel.Y; const double z = spr->actor->Vel.Z; - - // [BB] Calculate the pitch using spherical coordinates. - if(z || x || y) pitch = float(atan( z/sqrt(x*x+y*y) ) / M_PI * 180); - - // Correcting pitch if model is moving backwards - if(x || y) + + if (spr->actor->Vel.LengthSquared() > EQUAL_EPSILON) { - if((x * cos(angle * M_PI / 180) + y * sin(angle * M_PI / 180)) / sqrt(x * x + y * y) < 0) pitch *= -1; + // [BB] Calculate the pitch using spherical coordinates. + if (z || x || y) pitch = float(atan(z / sqrt(x*x + y*y)) / M_PI * 180); + + // Correcting pitch if model is moving backwards + if (fabs(x) > EQUAL_EPSILON || fabs(y) > EQUAL_EPSILON) + { + if ((x * cos(angle * M_PI / 180) + y * sin(angle * M_PI / 180)) / sqrt(x * x + y * y) < 0) pitch *= -1; + } + else pitch = fabs(pitch); } - else pitch = fabs(pitch); } if( smf->flags & MDL_ROTATING ) @@ -964,7 +967,7 @@ void gl_RenderModel(GLSprite * spr) // Applying model transformations: // 1) Applying actor angle, pitch and roll to the model gl_RenderState.mModelMatrix.rotate(-angle, 0, 1, 0); - gl_RenderState.mModelMatrix.rotate(pitch, 0, 0, 1); + gl_RenderState.mModelMatrix.rotate(-pitch, 0, 0, 1); gl_RenderState.mModelMatrix.rotate(-roll, 1, 0, 0); // 2) Applying Doomsday like rotation of the weapon pickup models