diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index a4ed87d25..1b8a0a9b4 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -4415,7 +4415,7 @@ void G_DrawRooms(int32_t snum, int32_t smoothratio) CAMERA(sect) = p->cursectnum; G_DoInterpolations(smoothratio); - G_AnimateCamSprite(); + G_AnimateCamSprite(smoothratio); if (ud.camerasprite >= 0) { @@ -4595,12 +4595,13 @@ void G_DrawRooms(int32_t snum, int32_t smoothratio) } else { + vec3_t cam = G_GetCameraPosition(p->newowner, smoothratio); + // looking through viewscreen - Bmemcpy(&CAMERA(pos), &p->pos, sizeof(vec3_t)); + Bmemcpy(&CAMERA(pos), &cam, sizeof(vec3_t)); CAMERA(ang) = p->ang + p->look_ang; CAMERA(horiz) = 100+sprite[p->newowner].shade; CAMERA(sect) = sprite[p->newowner].sectnum; - smoothratio = 65536; } cz = actor[p->i].ceilingz; @@ -11641,7 +11642,6 @@ int32_t app_main(int32_t argc, const char **argv) // getpackets(); MAIN_LOOP_RESTART: - M_ChangeMenu(MENU_MAIN); if (g_networkMode != NET_DEDICATED_SERVER) diff --git a/polymer/eduke32/source/sector.c b/polymer/eduke32/source/sector.c index 070c54b96..d58337f2a 100644 --- a/polymer/eduke32/source/sector.c +++ b/polymer/eduke32/source/sector.c @@ -363,18 +363,20 @@ int32_t SetAnimation(int32_t animsect,int32_t *animptr, int32_t thegoal, int32_t return j; } -static void G_SetupCamTile(int32_t i, int32_t wn) +static void G_SetupCamTile(int32_t i, int32_t wn, int32_t smoothratio) { + vec3_t cam = G_GetCameraPosition(i, smoothratio); + const int32_t mir = display_mirror; //if (waloff[wn] == 0) loadtile(wn); setviewtotile(wn, tilesiz[wn].y, tilesiz[wn].x); yax_preparedrawrooms(); - drawrooms(SX, SY, SZ, SA, 100+sprite[i].shade, SECT); - yax_drawrooms(G_DoSpriteAnimations, SECT, 0, 65536); + drawrooms(cam.x, cam.y, cam.z, SA, 100+sprite[i].shade, SECT); + yax_drawrooms(G_DoSpriteAnimations, SECT, 0, smoothratio); display_mirror = 3; - G_DoSpriteAnimations(SX, SY, SA, 65536L); + G_DoSpriteAnimations(cam.x, cam.y, SA, smoothratio); display_mirror = mir; drawmasks(); @@ -383,7 +385,7 @@ static void G_SetupCamTile(int32_t i, int32_t wn) invalidatetile(wn, -1, 255); } -void G_AnimateCamSprite(void) +void G_AnimateCamSprite(int32_t smoothratio) { const int32_t i = g_curViewscreen; @@ -407,7 +409,7 @@ void G_AnimateCamSprite(void) else walock[TILE_VIEWSCR] = 255; - G_SetupCamTile(OW, TILE_VIEWSCR); + G_SetupCamTile(OW, TILE_VIEWSCR, smoothratio); #ifdef POLYMER // Force texture update on viewscreen sprite in Polymer! if (getrendermode() == REND_POLYMER) diff --git a/polymer/eduke32/source/sector.h b/polymer/eduke32/source/sector.h index d7a168621..0364b99b9 100644 --- a/polymer/eduke32/source/sector.h +++ b/polymer/eduke32/source/sector.h @@ -117,7 +117,7 @@ void A_DamageWall(int32_t spr,int32_t dawallnum,const vec3_t *pos,int32_t atwith int32_t __fastcall A_FindPlayer(const spritetype *s,int32_t *d); void G_AlignWarpElevators(void); int32_t CheckDoorTile(int32_t dapic); -void G_AnimateCamSprite(void); +void G_AnimateCamSprite(int32_t smoothratio); void G_AnimateWalls(void); int32_t G_ActivateWarpElevators(int32_t s,int32_t d); int32_t G_CheckActivatorMotion(int32_t lotag); @@ -149,6 +149,20 @@ static inline int32_t G_GetForcefieldPicnum(int32_t wallnum) return picnum; } +// Returns the interpolated position of the camera that the player is looking +// through (using a viewscreen). should be the player's ->newowner member. +static inline vec3_t G_GetCameraPosition(int32_t i, int32_t smoothratio) +{ + const spritetype *const cs = &sprite[i]; + const actor_t *const ca = &actor[i]; + + vec3_t cam = { ca->bpos.x + mulscale16(cs->x - ca->bpos.x, smoothratio), + ca->bpos.y + mulscale16(cs->y - ca->bpos.y, smoothratio), + ca->bpos.z + mulscale16(cs->z - ca->bpos.z, smoothratio) + }; + return cam; +} + #ifdef __cplusplus } #endif