From 6d95c9d54468d69584a516e965f278571ab4ea35 Mon Sep 17 00:00:00 2001 From: Christopher Bruns Date: Sat, 30 Apr 2016 17:27:18 -0400 Subject: [PATCH] Fix floating point update for camera facing billboard mode. --- src/gl/scene/gl_sprite.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 4fac679599..70669fb336 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -278,7 +278,6 @@ void GLSprite::Draw(int pass) float xcenter = (x1 + x2)*0.5; float ycenter = (y1 + y2)*0.5; float zcenter = (z1 + z2)*0.5; - float angleRad = (270. - GLRenderer->mAngles.Yaw).Radians(); Matrix3x4 mat; mat.MakeIdentity(); @@ -288,10 +287,10 @@ void GLSprite::Draw(int pass) if (drawBillboardFacingCamera) { // [CMB] Rotate relative to camera XY position, not just camera direction, // which is nicer in VR - float xrel = xcenter - FIXED2FLOAT(GLRenderer->mViewActor->X()); - float yrel = ycenter - FIXED2FLOAT(GLRenderer->mViewActor->Y()); + float xrel = xcenter - GLRenderer->mViewActor->X(); + float yrel = ycenter - GLRenderer->mViewActor->Y(); float absAngleDeg = RAD2DEG(atan2(-yrel, xrel)); - float counterRotationDeg = 270. - float(GLRenderer->mAngles.Yaw); // counteracts existing sprite rotation + float counterRotationDeg = 270. - GLRenderer->mAngles.Yaw.Degrees; // counteracts existing sprite rotation float relAngleDeg = counterRotationDeg + absAngleDeg; mat.Rotate(0, 1, 0, relAngleDeg); @@ -302,6 +301,8 @@ void GLSprite::Draw(int pass) // Rotate the sprite about the vector starting at the center of the sprite // triangle strip and with direction orthogonal to where the player is looking // in the x/y plane. + float angleRad = (270. - GLRenderer->mAngles.Yaw).Radians(); + mat.Rotate(-sin(angleRad), 0, cos(angleRad), -GLRenderer->mAngles.Pitch.Degrees); } mat.Translate(-xcenter, -zcenter, -ycenter); // retreat from sprite center