From c0ef052d07d5c8fe0e576277c3197a7dd45f1d01 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 29 Jan 2017 13:13:00 +0100 Subject: [PATCH] - added interpolation for actor angles which for models is needed. --- src/actor.h | 8 ++++++++ src/gl/scene/gl_sprite.cpp | 25 +++++++++++-------------- src/gl/scene/gl_wall.h | 1 + 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/src/actor.h b/src/actor.h index 9f6d00e02..d83446827 100644 --- a/src/actor.h +++ b/src/actor.h @@ -1318,6 +1318,14 @@ public: { return Prev + (ticFrac * (Pos() - Prev)); } + DRotator InterpolatedAngles(double ticFrac) const + { + DRotator result; + result.Yaw = PrevAngles.Yaw + deltaangle(PrevAngles.Yaw, Angles.Yaw) * ticFrac; + result.Pitch = PrevAngles.Pitch + deltaangle(PrevAngles.Pitch, Angles.Pitch) * ticFrac; + result.Roll = PrevAngles.Roll + deltaangle(PrevAngles.Roll, Angles.Roll) * ticFrac; + return result; + } DVector3 PosPlusZ(double zadd) const { return { X(), Y(), Z() + zadd }; diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 1a69ca8ac..8c0e6c6b7 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -119,11 +119,11 @@ void GLSprite::CalculateVertices(FVector3 *v) // Tilt the actor up or down based on pitch (increase 'somersaults' forward). // Then counteract the roll and DO A BARREL ROLL. - FAngle pitch = (float)-actor->Angles.Pitch.Degrees; + FAngle pitch = (float)-Angles.Pitch.Degrees; pitch.Normalized180(); mat.Translate(x, z, y); - mat.Rotate(0, 1, 0, 270. - actor->Angles.Yaw.Degrees); + mat.Rotate(0, 1, 0, 270. - Angles.Yaw.Degrees); mat.Rotate(1, 0, 0, pitch.Degrees); if (actor->renderflags & RF_ROLLCENTER) @@ -132,12 +132,12 @@ void GLSprite::CalculateVertices(FVector3 *v) float cy = (y1 + y2) * 0.5; mat.Translate(cx - x, 0, cy - y); - mat.Rotate(0, 1, 0, - actor->Angles.Roll.Degrees); + mat.Rotate(0, 1, 0, - Angles.Roll.Degrees); mat.Translate(-cx, -z, -cy); } else { - mat.Rotate(0, 1, 0, - actor->Angles.Roll.Degrees); + mat.Rotate(0, 1, 0, - Angles.Roll.Degrees); mat.Translate(-x, -z, -y); } v[0] = mat * FVector3(x2, z, y2); @@ -199,11 +199,11 @@ void GLSprite::CalculateVertices(FVector3 *v) // [fgsfds] calculate yaw vectors float yawvecX = 0, yawvecY = 0, rollDegrees = 0; float angleRad = (270. - GLRenderer->mAngles.Yaw).Radians(); - if (actor) rollDegrees = actor->Angles.Roll.Degrees; + if (actor) rollDegrees = Angles.Roll.Degrees; if (isFlatSprite) { - yawvecX = actor->Angles.Yaw.Cos(); - yawvecY = actor->Angles.Yaw.Sin(); + yawvecX = Angles.Yaw.Cos(); + yawvecY = Angles.Yaw.Sin(); } // [fgsfds] Rotate the sprite about the sight vector (roll) @@ -712,10 +712,6 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal) } } } - if (thing == camera) - { - int a = 0; - } // don't draw first frame of a player missile if (thing->flags&MF_MISSILE) @@ -737,6 +733,7 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal) int clipres = GLRenderer->mClipPortal->ClipPoint(thingpos); if (clipres == GLPortal::PClip_InFront) return; } + Angles = thing->InterpolatedAngles(r_TicFracF); player_t *player = &players[consoleplayer]; FloatRect r; @@ -783,7 +780,7 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal) } else if (!(thing->renderflags & RF_FLATSPRITE)) { - patch = gl_GetSpriteFrame(spritenum, thing->frame, -1, (ang - (thing->Angles.Yaw + thing->SpriteRotation)).BAMs(), &mirror); + patch = gl_GetSpriteFrame(spritenum, thing->frame, -1, (ang - (Angles.Yaw + thing->SpriteRotation)).BAMs(), &mirror); } else { @@ -854,8 +851,8 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal) } break; case RF_WALLSPRITE: - viewvecX = thing->Angles.Yaw.Cos(); - viewvecY = thing->Angles.Yaw.Sin(); + viewvecX = Angles.Yaw.Cos(); + viewvecY = Angles.Yaw.Sin(); x1 = x + viewvecY*leftfac; x2 = x + viewvecY*rightfac; diff --git a/src/gl/scene/gl_wall.h b/src/gl/scene/gl_wall.h index 151a5ef71..7206c86c5 100644 --- a/src/gl/scene/gl_wall.h +++ b/src/gl/scene/gl_wall.h @@ -376,6 +376,7 @@ public: AActor * actor; particle_t * particle; TArray *lightlist; + DRotator Angles; void SplitSprite(sector_t * frontsector, bool translucent); void SetLowerParam();