mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-02-18 02:01:18 +00:00
Squashed commit of the following:
commit ad25b50089b6e01b8e4291e34cfe3a008af9128d Author: Rachael Alexanderson <madame-rachelle@users.noreply.github.com> Date: Fri Feb 9 12:12:46 2024 -0500 Revert "Adding isometric camera mode with orthographic projection to current state of master branch of GZDoom." This reverts commitd2c2c93cf1
. commit 8537f0d8db804f0076b90daa66b750e44dccf44c Author: Rachael Alexanderson <madame-rachelle@users.noreply.github.com> Date: Fri Feb 9 12:12:41 2024 -0500 Revert "Changed all of the isometric functionality to mapinfo and playerinfo variables. Retained function of most of the CVars." This reverts commitdc897eacc0
. commit d45f6ebf11f31d246f2de4f3bbd11f7970783125 Author: Rachael Alexanderson <madame-rachelle@users.noreply.github.com> Date: Fri Feb 9 12:10:21 2024 -0500 Revert "Restored r_orthographic behavior." This reverts commit26908f5bc5
. commit be0836feef9b95f12828eeed4319c726ef13780d Author: Rachael Alexanderson <madame-rachelle@users.noreply.github.com> Date: Fri Feb 9 12:09:15 2024 -0500 Revert "Adding isometric camera mode with orthographic projection to current state of master branch of GZDoom." This reverts commit08b03e6b19
. commit 688288a9199b912203022cb4db37503f6270e0c3 Author: Rachael Alexanderson <madame-rachelle@users.noreply.github.com> Date: Fri Feb 9 12:09:06 2024 -0500 Revert "Changed all of the isometric functionality to mapinfo and playerinfo variables. Retained function of most of the CVars." This reverts commitd3405837ce
. commit 72b7df9fa1841d665c2846dd31a89c6f48123e55 Author: Rachael Alexanderson <madame-rachelle@users.noreply.github.com> Date: Fri Feb 9 12:08:59 2024 -0500 Revert "Restored r_orthographic behavior." This reverts commite171f4eb6a
. commit aa954132bf29f2f8a51bf09dae127e5ffe2c5670 Author: Rachael Alexanderson <madame-rachelle@users.noreply.github.com> Date: Fri Feb 9 12:08:48 2024 -0500 Revert "Merged with latest master and made small change (zcenter -> center.Z) to hw_sprites.cpp. Now compiles and works." This reverts commitc8a7507e8e
. commit 3ce90e87a3a9956b615995b57b90619e89bbcff4 Author: Rachael Alexanderson <madame-rachelle@users.noreply.github.com> Date: Fri Feb 9 12:00:46 2024 -0500 Revert "Cleaning up implementation of isometric camera with optional orthographic projection." This reverts commit25f1407228
. commit 3aafd363e40c8d1d2ebbe3c61aeb2b80a74e565a Author: Rachael Alexanderson <madame-rachelle@users.noreply.github.com> Date: Fri Feb 9 11:59:25 2024 -0500 Revert "Small change to SpectatorCamera actor." This reverts commit2b555d7556
. commit a41911f8907731c098de71ca3e14261ac432ec8c Author: Rachael Alexanderson <madame-rachelle@users.noreply.github.com> Date: Fri Feb 9 11:59:16 2024 -0500 Revert "SpectatorCamera can now follow the 'tracer' actor. Also added a 'lagdistance' property for lazy follow." This reverts commit7fbb4cd06c
. commit 19398edd065b7b483b8c7be42cb16026695e241a Author: Rachael Alexanderson <madame-rachelle@users.noreply.github.com> Date: Fri Feb 9 11:59:05 2024 -0500 Revert "Minor addition toe SpectatorCamera. Added three chase modes to lazy follow. 0: Catch up until tracer is centered again. 1: Same but don't move if tracer isn't moving (camera moving when character is not is jarring). 2: Stop chasing if tracer is closer than lagdistance. Game modes benefit from a 'center camera' button but that doesn't have to be hard-baked into the engine." This reverts commitc3ca564cfc
.
This commit is contained in:
parent
07d6b1448a
commit
d8ef27e0ed
11 changed files with 37 additions and 192 deletions
|
@ -35,7 +35,6 @@
|
|||
|
||||
#include <time.h>
|
||||
#include <stdexcept>
|
||||
#include <cstdint>
|
||||
#include "w_zip.h"
|
||||
#include "ancientzip.h"
|
||||
#include "resourcefile.h"
|
||||
|
|
|
@ -146,27 +146,11 @@ float VREyeInfo::getShift() const
|
|||
return vr_swap_eyes ? -res : res;
|
||||
}
|
||||
|
||||
VSMatrix VREyeInfo::GetProjection(float fov, float aspectRatio, float fovRatio, bool iso_ortho) const
|
||||
VSMatrix VREyeInfo::GetProjection(float fov, float aspectRatio, float fovRatio) const
|
||||
{
|
||||
VSMatrix result;
|
||||
|
||||
if (iso_ortho) // Orthographic projection for isometric viewpoint
|
||||
{
|
||||
double zNear = -1.0; // screen->GetZNear();
|
||||
double zFar = screen->GetZFar();
|
||||
|
||||
double fH = tan(DEG2RAD(fov) / 2) / fovRatio;
|
||||
double fW = fH * aspectRatio * mScaleFactor;
|
||||
double left = -fW;
|
||||
double right = fW;
|
||||
double bottom = -fH;
|
||||
double top = fH;
|
||||
|
||||
VSMatrix fmat(1);
|
||||
fmat.ortho((float)left, (float)right, (float)bottom, (float)top, (float)zNear, (float)zFar);
|
||||
return fmat;
|
||||
}
|
||||
else if (mShiftFactor == 0)
|
||||
if (mShiftFactor == 0)
|
||||
{
|
||||
float fovy = (float)(2 * RAD2DEG(atan(tan(DEG2RAD(fov) / 2) / fovRatio)));
|
||||
result.perspective(fovy, aspectRatio, screen->GetZNear(), screen->GetZFar());
|
||||
|
|
|
@ -27,7 +27,7 @@ struct VREyeInfo
|
|||
float mShiftFactor;
|
||||
float mScaleFactor;
|
||||
|
||||
VSMatrix GetProjection(float fov, float aspectRatio, float fovRatio, bool iso_ortho) const;
|
||||
VSMatrix GetProjection(float fov, float aspectRatio, float fovRatio) const;
|
||||
DVector3 GetViewShift(float yaw) const;
|
||||
private:
|
||||
float getShift() const;
|
||||
|
|
|
@ -692,9 +692,6 @@ enum EViewPosFlags // [MC] Flags for SetViewPos.
|
|||
{
|
||||
VPSF_ABSOLUTEOFFSET = 1 << 1, // Don't include angles.
|
||||
VPSF_ABSOLUTEPOS = 1 << 2, // Use absolute position.
|
||||
VPSF_ALLOWOUTOFBOUNDS = 1 << 3, // Allow viewpoint to go out of bounds (hardware renderer only).
|
||||
VPSF_ORTHOGRAPHIC = 1 << 4, // Use orthographic projection.
|
||||
VPSF_ISOMETRICSPRITES = 1 << 5, // Displace sprites towards camera and don't billboard (drawn from isometric perspective).
|
||||
};
|
||||
|
||||
enum EAnimOverrideFlags
|
||||
|
|
|
@ -163,11 +163,7 @@ sector_t* RenderViewpoint(FRenderViewpoint& mainvp, AActor* camera, IntRect* bou
|
|||
di->Viewpoint.FieldOfView = DAngle::fromDeg(fov); // Set the real FOV for the current scene (it's not necessarily the same as the global setting in r_viewpoint)
|
||||
|
||||
// Stereo mode specific perspective projection
|
||||
float inv_iso_dist = 1.0f;
|
||||
bool iso_ortho = (camera->ViewPos != NULL) && (camera->ViewPos->Flags & VPSF_ORTHOGRAPHIC);
|
||||
if (iso_ortho && (camera->ViewPos->Offset.XY().Length() > 0)) inv_iso_dist = 3.0f/camera->ViewPos->Offset.XY().Length();
|
||||
di->VPUniforms.mProjectionMatrix = eye.GetProjection(fov, ratio, fovratio * inv_iso_dist, iso_ortho);
|
||||
|
||||
di->VPUniforms.mProjectionMatrix = eye.GetProjection(fov, ratio, fovratio);
|
||||
// Stereo mode specific viewpoint adjustment
|
||||
vp.Pos += eye.GetViewShift(vp.HWAngles.Yaw.Degrees());
|
||||
di->SetupView(RenderState, vp.Pos.X, vp.Pos.Y, vp.Pos.Z, false, false);
|
||||
|
|
|
@ -489,7 +489,7 @@ bool HWSprite::CalculateVertices(HWDrawInfo* di, FVector3* v, DVector3* vp)
|
|||
}
|
||||
else // traditional "Y" billboard mode
|
||||
{
|
||||
if (doRoll || !offset.isZero() || ((di->Viewpoint.camera->ViewPos != NULL) && (di->Viewpoint.camera->ViewPos->Flags & VPSF_ISOMETRICSPRITES)))
|
||||
if (doRoll || !offset.isZero())
|
||||
{
|
||||
mat.MakeIdentity();
|
||||
|
||||
|
@ -507,16 +507,6 @@ bool HWSprite::CalculateVertices(HWDrawInfo* di, FVector3* v, DVector3* vp)
|
|||
mat.Translate(-center.X, -center.Z, -center.Y);
|
||||
}
|
||||
|
||||
if ((di->Viewpoint.camera->ViewPos != NULL) && (di->Viewpoint.camera->ViewPos->Flags & VPSF_ISOMETRICSPRITES))
|
||||
{
|
||||
float angleRad = (FAngle::fromDeg(270.) - HWAngles.Yaw).Radians();
|
||||
mat.Translate(center.X, center.Z, center.Y);
|
||||
mat.Translate(0.0, z2 - center.Z, 0.0);
|
||||
mat.Rotate(-sin(angleRad), 0, cos(angleRad), -HWAngles.Pitch.Degrees());
|
||||
mat.Translate(0.0, center.Z - z2, 0.0);
|
||||
mat.Translate(-center.X, -center.Z, -center.Y);
|
||||
}
|
||||
|
||||
v[0] = mat * FVector3(x1, z1, y1);
|
||||
v[1] = mat * FVector3(x2, z1, y2);
|
||||
v[2] = mat * FVector3(x1, z2, y1);
|
||||
|
@ -910,7 +900,6 @@ void HWSprite::Process(HWDrawInfo *di, AActor* thing, sector_t * sector, area_t
|
|||
{
|
||||
bool mirror = false;
|
||||
DAngle ang = (thingpos - vp.Pos).Angle();
|
||||
if((di->Viewpoint.camera->ViewPos != NULL) && (di->Viewpoint.camera->ViewPos->Flags & VPSF_ISOMETRICSPRITES)) ang = vp.Angles.Yaw;
|
||||
FTextureID patch;
|
||||
// [ZZ] add direct picnum override
|
||||
if (isPicnumOverride)
|
||||
|
@ -1030,20 +1019,6 @@ void HWSprite::Process(HWDrawInfo *di, AActor* thing, sector_t * sector, area_t
|
|||
x2 = x - viewvecY*rightfac;
|
||||
y1 = y + viewvecX*leftfac;
|
||||
y2 = y + viewvecX*rightfac;
|
||||
if((di->Viewpoint.camera->ViewPos != NULL) && (di->Viewpoint.camera->ViewPos->Flags & VPSF_ISOMETRICSPRITES)) // If sprites are drawn from an isometric perspective
|
||||
{
|
||||
float signX = 1.0;
|
||||
float signY = 1.0;
|
||||
if(viewvecX < 0) signX = -1.0;
|
||||
if(viewvecY < 0) signY = -1.0;
|
||||
if(viewvecX == 0) signX = 0.0;
|
||||
if(viewvecY == 0) signY = 0.0;
|
||||
|
||||
x1 -= signX * thing->radius;
|
||||
x2 -= signX * thing->radius;
|
||||
y1 -= signY * thing->radius;
|
||||
y2 -= signY * thing->radius;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case RF_FLATSPRITE:
|
||||
|
@ -1084,7 +1059,6 @@ void HWSprite::Process(HWDrawInfo *di, AActor* thing, sector_t * sector, area_t
|
|||
}
|
||||
|
||||
depth = (float)((x - vp.Pos.X) * vp.TanCos + (y - vp.Pos.Y) * vp.TanSin);
|
||||
if(((di->Viewpoint.camera->ViewPos != NULL) && (di->Viewpoint.camera->ViewPos->Flags & VPSF_ISOMETRICSPRITES))) depth = depth * vp.PitchCos - vp.PitchSin * z2; // Helps with stacking actors with small xy offsets
|
||||
if (isSpriteShadow) depth += 1.f/65536.f; // always sort shadows behind the sprite.
|
||||
|
||||
// light calculation
|
||||
|
|
|
@ -66,7 +66,6 @@
|
|||
#include "i_system.h"
|
||||
#include "v_draw.h"
|
||||
#include "i_interface.h"
|
||||
#include "d_main.h"
|
||||
|
||||
// EXTERNAL DATA DECLARATIONS ----------------------------------------------
|
||||
|
||||
|
@ -154,8 +153,6 @@ FRenderViewpoint::FRenderViewpoint()
|
|||
Sin = 0.0;
|
||||
TanCos = 0.0;
|
||||
TanSin = 0.0;
|
||||
PitchCos = 0.0;
|
||||
PitchSin = 0.0;
|
||||
camera = nullptr;
|
||||
sector = nullptr;
|
||||
FieldOfView = DAngle::fromDeg(90.); // Angles in the SCREENWIDTH wide window
|
||||
|
@ -603,7 +600,7 @@ void R_InterpolateView (FRenderViewpoint &viewpoint, player_t *player, double Fr
|
|||
else break;
|
||||
}
|
||||
}
|
||||
if (moved && !viewpoint.showviewer) viewpoint.noviewer = true;
|
||||
if (moved) viewpoint.noviewer = true;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
@ -633,9 +630,6 @@ void FRenderViewpoint::SetViewAngle (const FViewWindow &viewwindow)
|
|||
TanSin = viewwindow.FocalTangent * Sin;
|
||||
TanCos = viewwindow.FocalTangent * Cos;
|
||||
|
||||
PitchSin = Angles.Pitch.Sin();
|
||||
PitchCos = Angles.Pitch.Cos();
|
||||
|
||||
DVector2 v = Angles.Yaw.ToVector();
|
||||
ViewVector.X = v.X;
|
||||
ViewVector.Y = v.Y;
|
||||
|
@ -865,7 +859,6 @@ void R_SetupFrame (FRenderViewpoint &viewpoint, FViewWindow &viewwindow, AActor
|
|||
{
|
||||
iview->otic = nowtic;
|
||||
iview->Old = iview->New;
|
||||
viewpoint.noviewer = false;
|
||||
}
|
||||
//==============================================================================================
|
||||
// Handles offsetting the camera with ChaseCam and/or viewpos.
|
||||
|
@ -888,7 +881,7 @@ void R_SetupFrame (FRenderViewpoint &viewpoint, FViewWindow &viewwindow, AActor
|
|||
P_AimCamera(viewpoint.camera, campos, camangle, viewpoint.sector, unlinked); // fixme: This needs to translate the angle, too.
|
||||
iview->New.Pos = campos;
|
||||
iview->New.Angles.Yaw = camangle;
|
||||
viewpoint.noviewer = false;
|
||||
|
||||
viewpoint.showviewer = true;
|
||||
// Interpolating this is a very complicated thing because nothing keeps track of the aim camera's movement, so whenever we detect a portal transition
|
||||
// it's probably best to just reset the interpolation for this move.
|
||||
|
@ -955,11 +948,7 @@ void R_SetupFrame (FRenderViewpoint &viewpoint, FViewWindow &viewwindow, AActor
|
|||
// Interpolation still happens with everything else though and seems to work fine.
|
||||
DefaultDraw = false;
|
||||
viewpoint.NoPortalPath = true;
|
||||
// Allow VPSF_ALLOWOUTOFBOUNDS camera viewpoints to go out of bounds when using HW renderer
|
||||
if (!(VP->Flags & VPSF_ALLOWOUTOFBOUNDS) || !V_IsHardwareRenderer())
|
||||
{
|
||||
P_AdjustViewPos(mo, orig, next, viewpoint.sector, unlinked, VP, &viewpoint);
|
||||
}
|
||||
|
||||
if (viewpoint.sector->PortalGroup != oldsector->PortalGroup || (unlinked && ((iview->New.Pos.XY() - iview->Old.Pos.XY()).LengthSquared()) > 256 * 256))
|
||||
{
|
||||
|
@ -1006,10 +995,7 @@ void R_SetupFrame (FRenderViewpoint &viewpoint, FViewWindow &viewwindow, AActor
|
|||
viewpoint.SetViewAngle (viewwindow);
|
||||
|
||||
// Keep the view within the sector's floor and ceiling
|
||||
// But allow VPSF_ALLOWOUTOFBOUNDS camera viewpoints to go out of bounds when using hardware renderer
|
||||
bool disembodied = false;
|
||||
if (viewpoint.camera->ViewPos != NULL) disembodied = viewpoint.camera->ViewPos->Flags & VPSF_ALLOWOUTOFBOUNDS;
|
||||
if (viewpoint.sector->PortalBlocksMovement(sector_t::ceiling) && (!disembodied || !V_IsHardwareRenderer()))
|
||||
if (viewpoint.sector->PortalBlocksMovement(sector_t::ceiling))
|
||||
{
|
||||
double theZ = viewpoint.sector->ceilingplane.ZatPoint(viewpoint.Pos) - 4;
|
||||
if (viewpoint.Pos.Z > theZ)
|
||||
|
@ -1018,7 +1004,7 @@ void R_SetupFrame (FRenderViewpoint &viewpoint, FViewWindow &viewwindow, AActor
|
|||
}
|
||||
}
|
||||
|
||||
if (viewpoint.sector->PortalBlocksMovement(sector_t::floor) && (!disembodied || !V_IsHardwareRenderer()))
|
||||
if (viewpoint.sector->PortalBlocksMovement(sector_t::floor))
|
||||
{
|
||||
double theZ = viewpoint.sector->floorplane.ZatPoint(viewpoint.Pos) + 4;
|
||||
if (viewpoint.Pos.Z < theZ)
|
||||
|
|
|
@ -33,8 +33,6 @@ struct FRenderViewpoint
|
|||
double Sin; // sin(Angles.Yaw)
|
||||
double TanCos; // FocalTangent * cos(Angles.Yaw)
|
||||
double TanSin; // FocalTangent * sin(Angles.Yaw)
|
||||
double PitchCos; // cos(Angles.Pitch)
|
||||
double PitchSin; // sin(Angles.Pitch)
|
||||
|
||||
AActor *camera; // camera actor
|
||||
sector_t *sector; // [RH] keep track of sector viewing from
|
||||
|
|
|
@ -128,89 +128,3 @@ class AimingCamera : SecurityCamera
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
class SpectatorCamera : Actor
|
||||
{
|
||||
|
||||
bool chasingtracer;
|
||||
double lagdistance; // camera gives chase (lazy follow) if tracer gets > lagdistance away from camera.pos
|
||||
int chasemode; // 0: chase until tracer centered, 1: same but only when tracer is moving, 2: stop chase if tracer within lagdistance
|
||||
property lagdistance : lagdistance;
|
||||
property chasingtracer : chasingtracer;
|
||||
property chasemode : chasemode;
|
||||
|
||||
default
|
||||
{
|
||||
+NOBLOCKMAP
|
||||
+NOGRAVITY
|
||||
+NOSECTOR
|
||||
+NOINTERACTION
|
||||
RenderStyle "None";
|
||||
CameraHeight 0;
|
||||
SpectatorCamera.chasingtracer false;
|
||||
SpectatorCamera.lagdistance 0.0;
|
||||
SpectatorCamera.chasemode 0;
|
||||
}
|
||||
|
||||
void Init(double dist, double yaw, double inpitch, int inflags)
|
||||
{
|
||||
if(((inflags > 0) && (inflags & VPSF_ORTHOGRAPHIC)) || ((inflags < 0) && (ViewPos.Flags & VPSF_ORTHOGRAPHIC))) dist *= 3.0;
|
||||
|
||||
double zshift = 0.0;
|
||||
if(tracer != NULL)
|
||||
{
|
||||
if(player != NULL) zshift = -0.5*tracer.height;
|
||||
else zshift = 0.5*tracer.height;
|
||||
}
|
||||
else if (player != NULL && player.mo != NULL) zshift = -0.5*player.mo.height;
|
||||
|
||||
SetViewPos((-dist*Cos(yaw), -dist*Sin(yaw), dist*Tan(inpitch)+zshift), inflags);
|
||||
LookAtSelf(inpitch);
|
||||
}
|
||||
|
||||
void LookAtSelf(double inpitch)
|
||||
{
|
||||
if(ViewPos.Offset != (0., 0., 0.))
|
||||
{
|
||||
Vector3 negviewpos = (-1.0) * ViewPos.Offset;
|
||||
angle = negviewpos.Angle();
|
||||
pitch = inpitch;
|
||||
}
|
||||
}
|
||||
|
||||
override void Tick()
|
||||
{
|
||||
if(tracer != NULL)
|
||||
{
|
||||
Vector3 distvec = tracer.pos - pos;
|
||||
double dist = distvec.length();
|
||||
if((dist <= 4 && chasingtracer) || lagdistance <= 0.0) // Keep tracer centered on screen
|
||||
{
|
||||
SetOrigin(tracer.pos, true);
|
||||
chasingtracer = false;
|
||||
}
|
||||
else // Lazy follow tracer
|
||||
{
|
||||
if(dist >= 2*lagdistance)
|
||||
{
|
||||
SetOrigin(tracer.pos, true);
|
||||
chasingtracer = false;
|
||||
}
|
||||
else if(dist > lagdistance && !chasingtracer) chasingtracer = true;
|
||||
|
||||
if(chasingtracer)
|
||||
{
|
||||
speed = tracer.vel.xy.length()/dist;
|
||||
if((speed == 0.0) && (chasemode == 0)) speed = tracer.speed/dist;
|
||||
SetOrigin(pos + 2*distvec*speed, true);
|
||||
if(chasemode > 1) chasingtracer = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(player != NULL && player.mo != NULL)
|
||||
{
|
||||
cameraFOV = player.FOV;
|
||||
SetOrigin(player.mo.pos, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -420,9 +420,6 @@ enum EViewPosFlags
|
|||
{
|
||||
VPSF_ABSOLUTEOFFSET = 1 << 1, // Don't include angles.
|
||||
VPSF_ABSOLUTEPOS = 1 << 2, // Use absolute position.
|
||||
VPSF_ALLOWOUTOFBOUNDS = 1 << 3, // Allow viewpoint to go out of bounds (hardware renderer only).
|
||||
VPSF_ORTHOGRAPHIC = 1 << 4, // Use orthographic projection.
|
||||
VPSF_ISOMETRICSPRITES = 1 << 5, // Displace sprites towards camera and don't billboard (drawn from isometric perspective).
|
||||
};
|
||||
|
||||
// Flags for A_TakeInventory and A_TakeFromTarget
|
||||
|
|
Loading…
Reference in a new issue