Ensure both eyes see same sprite rotation frame

This commit is contained in:
Simon 2020-04-03 19:05:25 +01:00
parent d6d6085740
commit 959c8ebdf5
3 changed files with 9 additions and 7 deletions

View file

@ -893,6 +893,7 @@ sector_t * GLSceneDrawer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, f
SetViewAngle(r_viewpoint.Angles.Yaw);
// Stereo mode specific viewpoint adjustment - temporarily shifts global ViewPos
eye->GetViewShift(GLRenderer->mAngles.Yaw.Degrees, viewShift);
r_viewpoint.CenterEyePos = r_viewpoint.Pos; // Retain unshifted center eye pos so all sprites show the same frame
s3d::ScopedViewShifter viewShifter(viewShift);
SetViewMatrix(r_viewpoint.Pos.X, r_viewpoint.Pos.Y, r_viewpoint.Pos.Z, false, false);
gl_RenderState.ApplyMatrices();

View file

@ -762,13 +762,13 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal)
// Thing is invisible if close to the camera.
if (thing->renderflags & RF_MAYBEINVISIBLE)
{
if (fabs(thingpos.X - r_viewpoint.Pos.X) < 32 && fabs(thingpos.Y - r_viewpoint.Pos.Y) < 32) return;
if (fabs(thingpos.X - r_viewpoint.CenterEyePos.X) < 32 && fabs(thingpos.Y - r_viewpoint.CenterEyePos.Y) < 32) return;
}
// Too close to the camera. This doesn't look good if it is a sprite.
if (fabs(thingpos.X - r_viewpoint.Pos.X) < 2 && fabs(thingpos.Y - r_viewpoint.Pos.Y) < 2)
if (fabs(thingpos.X - r_viewpoint.CenterEyePos.X) < 2 && fabs(thingpos.Y - r_viewpoint.CenterEyePos.Y) < 2)
{
if (r_viewpoint.Pos.Z >= thingpos.Z - 2 && r_viewpoint.Pos.Z <= thingpos.Z + thing->Height + 2)
if (r_viewpoint.CenterEyePos.Z >= thingpos.Z - 2 && r_viewpoint.CenterEyePos.Z <= thingpos.Z + thing->Height + 2)
{
// exclude vertically moving objects from this check.
if (!thing->Vel.isZero())
@ -790,7 +790,7 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal)
if (speed >= thing->target->radius / 2)
{
double clipdist = clamp(thing->Speed, thing->target->radius, thing->target->radius * 2);
if ((thingpos - r_viewpoint.Pos).LengthSquared() < clipdist * clipdist) return;
if ((thingpos - r_viewpoint.CenterEyePos).LengthSquared() < clipdist * clipdist) return;
}
}
thing->flags7 |= MF7_FLYCHEAT; // do this only once for the very first frame, but not if it gets into range again.
@ -840,7 +840,7 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal)
if (!modelframe)
{
bool mirror;
DAngle ang = (thingpos - r_viewpoint.Pos).Angle();
DAngle ang = (thingpos - r_viewpoint.CenterEyePos).Angle();
FTextureID patch;
// [ZZ] add direct picnum override
if (isPicnumOverride)
@ -958,7 +958,7 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal)
gltexture = NULL;
}
depth = FloatToFixed((x - r_viewpoint.Pos.X) * r_viewpoint.TanCos + (y - r_viewpoint.Pos.Y) * r_viewpoint.TanSin);
depth = FloatToFixed((x - r_viewpoint.CenterEyePos.X) * r_viewpoint.TanCos + (y - r_viewpoint.CenterEyePos.Y) * r_viewpoint.TanSin);
// light calculation
@ -1286,7 +1286,7 @@ void GLSprite::ProcessParticle (particle_t *particle, sector_t *sector)//, int s
z1=z-scalefac;
z2=z+scalefac;
depth = FloatToFixed((x - r_viewpoint.Pos.X) * r_viewpoint.TanCos + (y - r_viewpoint.Pos.Y) * r_viewpoint.TanSin);
depth = FloatToFixed((x - r_viewpoint.CenterEyePos.X) * r_viewpoint.TanCos + (y - r_viewpoint.CenterEyePos.Y) * r_viewpoint.TanSin);
actor=NULL;
this->particle=particle;

View file

@ -18,6 +18,7 @@ struct FRenderViewpoint
player_t *player; // For which player is this viewpoint being renderered? (can be null for camera textures)
DVector3 Pos; // Camera position
DVector3 CenterEyePos; // Camera position without view shift
DVector3 ActorPos; // Camera actor's position
DRotator Angles; // Camera angles
DVector3 Path[2]; // View path for portal calculations