From 88608e068290c727a84f3b5a9948ce4dac9487a9 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Wed, 23 Sep 2020 14:42:33 +1000 Subject: [PATCH] - Duke: Interpolate camera sprite angle in `animatecamsprite()`. Fixes a "fixme". --- source/games/duke/src/actors.cpp | 1 + source/games/duke/src/render.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index 03d9c44b1..911b55752 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -1997,6 +1997,7 @@ void camera(int i) if (s->hitag > 0) { + hittype[i].tempang = s->ang; if (t[1] < s->hitag) s->ang += 8; else if (t[1] < (s->hitag * 3)) diff --git a/source/games/duke/src/render.cpp b/source/games/duke/src/render.cpp index f455fa8c5..049003fa6 100644 --- a/source/games/duke/src/render.cpp +++ b/source/games/duke/src/render.cpp @@ -244,7 +244,7 @@ void renderMirror(int cposx, int cposy, int cposz, binangle cang, fixedhoriz cho // //--------------------------------------------------------------------------- -void animatecamsprite(int smoothRatio) +void animatecamsprite(double smoothratio) { const int VIEWSCREEN_ACTIVE_DISTANCE = 8192; @@ -268,12 +268,12 @@ void animatecamsprite(int smoothRatio) screen->RenderTextureView(canvas, [=](IntRect& rect) { - // fixme: This needs to interpolate the camera's angle. Position is not relevant because cameras do not move. auto camera = &sprite[sp->owner]; + auto ang = hittype[sp->owner].tempang + xs_CRoundToInt(fmulscale16(((camera->ang - hittype[sp->owner].tempang + 1024) & 2047) - 1024, smoothratio)); // Note: no ROR or camera here for now - the current setup has no means to detect these things before rendering the scene itself. - drawrooms(camera->x, camera->y, camera->z, camera->ang, 100 + camera->shade, camera->sectnum); // why 'shade'...? + drawrooms(camera->x, camera->y, camera->z, ang, 100 + camera->shade, camera->sectnum); // why 'shade'...? display_mirror = 1; // should really be 'display external view'. - fi.animatesprites(camera->x, camera->y, camera->ang, smoothRatio); + fi.animatesprites(camera->x, camera->y, ang, smoothratio); display_mirror = 0; renderDrawMasks(); });