Skip to content

Commit

Permalink
Consolidated isometric mode commits.
Browse files Browse the repository at this point in the history
  • Loading branch information
dileepvr authored and dpjudas committed Aug 11, 2024
1 parent f1b9e68 commit 8a5e744
Show file tree
Hide file tree
Showing 33 changed files with 870 additions and 98 deletions.
4 changes: 2 additions & 2 deletions src/am_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2822,7 +2822,7 @@ void DAutomap::drawPlayers ()
int numarrowlines;

double vh = players[consoleplayer].viewheight;
DVector2 pos = players[consoleplayer].camera->InterpolatedPosition(r_viewpoint.TicFrac).XY();
DVector2 pos = players[consoleplayer].mo->InterpolatedPosition(r_viewpoint.TicFrac).XY();
pt.x = pos.X;
pt.y = pos.Y;
if (am_rotate == 1 || (am_rotate == 2 && viewactive))
Expand All @@ -2832,7 +2832,7 @@ void DAutomap::drawPlayers ()
}
else
{
angle = players[consoleplayer].camera->InterpolatedAngles(r_viewpoint.TicFrac).Yaw;
angle = players[consoleplayer].mo->InterpolatedAngles(r_viewpoint.TicFrac).Yaw;
}

if (am_cheat != 0 && CheatMapArrow.Size() > 0)
Expand Down
3 changes: 3 additions & 0 deletions src/common/rendering/hwrenderer/data/hw_cvars.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,6 @@ EXTERN_CVAR(Bool, gl_debug_breakpoint)
EXTERN_CVAR(Bool, gl_brightfog)
EXTERN_CVAR(Bool, gl_lightadditivesurfaces)
EXTERN_CVAR(Bool, gl_notexturefill)

EXTERN_CVAR(Bool, r_radarclipper)
EXTERN_CVAR(Bool, r_dithertransparency)
1 change: 1 addition & 0 deletions src/common/rendering/hwrenderer/data/hw_renderstate.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ enum ERenderEffect
EFF_BURN,
EFF_STENCIL,
EFF_PORTAL,
EFF_DITHERTRANS,

MAX_EFFECTS
};
Expand Down
20 changes: 18 additions & 2 deletions src/common/rendering/hwrenderer/data/hw_vrmodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,27 @@ float VREyeInfo::getShift() const
return vr_swap_eyes ? -res : res;
}

VSMatrix VREyeInfo::GetProjection(float fov, float aspectRatio, float fovRatio) const
VSMatrix VREyeInfo::GetProjection(float fov, float aspectRatio, float fovRatio, bool iso_ortho) const
{
VSMatrix result;

if (mShiftFactor == 0)
if (iso_ortho) // Orthographic projection for isometric viewpoint
{
double zNear = -3.0/fovRatio; // 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)
{
float fovy = (float)(2 * RAD2DEG(atan(tan(DEG2RAD(fov) / 2) / fovRatio)));
result.perspective(fovy, aspectRatio, screen->GetZNear(), screen->GetZFar());
Expand Down
2 changes: 1 addition & 1 deletion src/common/rendering/hwrenderer/data/hw_vrmodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ struct VREyeInfo
float mShiftFactor;
float mScaleFactor;

VSMatrix GetProjection(float fov, float aspectRatio, float fovRatio) const;
VSMatrix GetProjection(float fov, float aspectRatio, float fovRatio, bool iso_ortho) const;
DVector3 GetViewShift(float yaw) const;
private:
float getShift() const;
Expand Down
1 change: 1 addition & 0 deletions src/common/rendering/vulkan/shaders/vk_shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ VkShaderProgram* VkShaderManager::Get(const VkShaderKey& key)
{ "burn", "shaders/scene/frag_burn.glsl", nullptr, nullptr, nullptr, "#define SIMPLE\n#define NO_ALPHATEST\n" },
{ "stencil", "shaders/scene/frag_stencil.glsl", nullptr, nullptr, nullptr, "#define SIMPLE\n#define NO_ALPHATEST\n" },
{ "portal", "shaders/scene/frag_portal.glsl", nullptr, nullptr, nullptr, "#define SIMPLE\n#define NO_ALPHATEST\n" },
{ "dithertrans", "shaders/scene/frag_main.glsl", "shaders/scene/material_default.glsl", "shaders/scene/mateffect_default.glsl", "shaders/scene/lightmodel_normal.glsl", "#define NO_ALPHATEST\n#define DITHERTRANS\n" },
};

const auto& desc = effectshaders[key.SpecialEffect];
Expand Down
7 changes: 7 additions & 0 deletions src/common/utility/m_bbox.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ class FBoundingBox
m_Box[BOXTOP] = pos.Y;
}

bool CheckOverlap(const FBoundingBox &box2)
{
bool hori = (Left() > box2.Right()) || (Right() < box2.Left());
bool vert = (Bottom() > box2.Top()) || (Top() < box2.Bottom());
return !(hori || vert); // [DVR] For alternative space partition
}

inline double Top () const { return m_Box[BOXTOP]; }
inline double Bottom () const { return m_Box[BOXBOTTOM]; }
inline double Left () const { return m_Box[BOXLEFT]; }
Expand Down
1 change: 1 addition & 0 deletions src/gamedata/g_mapinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1823,6 +1823,7 @@ MapFlagHandlers[] =
{ "disableskyboxao", MITYPE_CLRFLAG3, LEVEL3_SKYBOXAO, 0 },
{ "avoidmelee", MITYPE_SETFLAG3, LEVEL3_AVOIDMELEE, 0 },
{ "attenuatelights", MITYPE_SETFLAG3, LEVEL3_ATTENUATE, 0 },
{ "nofogofwar", MITYPE_SETFLAG3, LEVEL3_NOFOGOFWAR, 0 },
{ "nousersave", MITYPE_SETVKDFLAG, VKDLEVELFLAG_NOUSERSAVE, 0 },
{ "noautomap", MITYPE_SETVKDFLAG, VKDLEVELFLAG_NOAUTOMAP, 0 },
{ "noautosaveonenter", MITYPE_SETVKDFLAG, VKDLEVELFLAG_NOAUTOSAVEONENTER, 0 },
Expand Down
1 change: 1 addition & 0 deletions src/gamedata/g_mapinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ enum ELevelFlags : unsigned int
LEVEL3_AVOIDMELEE = 0x00020000, // global flag needed for proper MBF support.
LEVEL3_NOJUMPDOWN = 0x00040000, // only for MBF21. Inverse of MBF's dog_jumping flag.
LEVEL3_LIGHTCREATED = 0x00080000, // a light had been created in the last frame
LEVEL3_NOFOGOFWAR = 0x00100000, // disables effect of r_radarclipper CVAR on this map

// VKDoom custom flags
VKDLEVELFLAG_NOUSERSAVE = 0x00000001,
Expand Down
4 changes: 4 additions & 0 deletions src/gamedata/r_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ struct secplane_t
DVector3 normal;
double D, negiC; // negative iC because that also saves a negation in all methods using this.
public:
bool dithertransflag; // Render plane with dithering transparency shader (gets reset every frame)
friend FSerializer &Serialize(FSerializer &arc, const char *key, secplane_t &p, secplane_t *def);

void set(double aa, double bb, double cc, double dd)
Expand Down Expand Up @@ -1186,6 +1187,8 @@ enum
WALLF_ABSLIGHTING_TOP = WALLF_ABSLIGHTING_TIER << 0, // Top tier light is absolute instead of relative
WALLF_ABSLIGHTING_MID = WALLF_ABSLIGHTING_TIER << 1, // Mid tier light is absolute instead of relative
WALLF_ABSLIGHTING_BOTTOM = WALLF_ABSLIGHTING_TIER << 2, // Bottom tier light is absolute instead of relative

WALLF_DITHERTRANS = 8192, // Render with dithering transparency shader (gets reset every frame)
};

struct side_t
Expand Down Expand Up @@ -1664,6 +1667,7 @@ struct subsector_t
uint32_t numlines;
uint16_t flags;
short mapsection;
FBoundingBox bbox; // [DVR] For alternative space culling in orthographic projection with no fog of war

// subsector related GL data
int validcount;
Expand Down
19 changes: 19 additions & 0 deletions src/maploader/maploader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3525,4 +3525,23 @@ void MapLoader::LoadLevel(MapData *map, const char *lumpname, int position)
}

Level->aabbTree = new DoomLevelAABBTree(Level);

// [DVR] Populate subsector->bbox for alternative space culling in orthographic projection with no fog of war
subsector_t* sub = &Level->subsectors[0];
seg_t* seg;
for (unsigned int kk = 0; kk < Level->subsectors.Size(); kk++)
{
sub[kk].bbox.ClearBox();
unsigned int count = sub[kk].numlines;
seg = sub[kk].firstline;
while(count--)
{
if((seg->v1 != nullptr) && (seg->v2 != nullptr))
{
sub[kk].bbox.AddToBox(seg->v1->fPos());
sub[kk].bbox.AddToBox(seg->v2->fPos());
}
seg++;
}
}
}
9 changes: 7 additions & 2 deletions src/playsim/actor.h
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,7 @@ enum ActorRenderFlag2
RF2_FLIPSPRITEOFFSETY = 0x0020,
RF2_CAMFOLLOWSPLAYER = 0x0040, // Matches the cam's base position and angles to the main viewpoint.
RF2_NOMIPMAP = 0x0080, // [Nash] forces no mipmapping on sprites. Useful for tiny sprites that need to remain visually crisp
RF2_ISOMETRICSPRITES = 0x0100,
};

// This translucency value produces the closest match to Heretic's TINTTAB.
Expand Down Expand Up @@ -692,8 +693,10 @@ struct FDropItem

enum EViewPosFlags // [MC] Flags for SetViewPos.
{
VPSF_ABSOLUTEOFFSET = 1 << 1, // Don't include angles.
VPSF_ABSOLUTEPOS = 1 << 2, // Use absolute position.
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 (hardware renderer only).
};

enum EAnimOverrideFlags
Expand Down Expand Up @@ -1123,6 +1126,8 @@ class AActor final : public DThinker
DAngle SpriteAngle;
DAngle SpriteRotation;
DVector2 AutomapOffsets; // Offset the actors' sprite view on the automap by these coordinates.
float isoscaleY; // Y-scale to compensate for Y-billboarding for isometric sprites
float isotheta; // Rotation angle to compensate for Y-billboarding for isometric sprites
DRotator Angles;
DRotator ViewAngles; // Angle offsets for cameras
TObjPtr<DViewPosition*> ViewPos; // Position offsets for cameras
Expand Down
34 changes: 22 additions & 12 deletions src/playsim/p_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
#include "p_blockmap.h"
#include "p_3dmidtex.h"
#include "vm.h"
#include "d_main.h"

#include "decallib.h"

Expand Down Expand Up @@ -5577,33 +5578,42 @@ void R_OffsetView(FRenderViewpoint& viewPoint, const DVector3& dir, const double
{
const DAngle baseYaw = dir.Angle();
FTraceResults trace = {};
if (Trace(viewPoint.Pos, viewPoint.sector, dir, distance, 0u, 0u, nullptr, trace))
if (viewPoint.IsAllowedOoB() && V_IsHardwareRenderer())
{
viewPoint.Pos += dir * distance;
viewPoint.sector = viewPoint.ViewLevel->PointInRenderSubsector(viewPoint.Pos)->sector;
}
else if (Trace(viewPoint.Pos, viewPoint.sector, dir, distance, 0u, 0u, nullptr, trace))
{
viewPoint.Pos = trace.HitPos - trace.HitVector * min<double>(5.0, trace.Distance);
viewPoint.sector = viewPoint.ViewLevel->PointInRenderSubsector(viewPoint.Pos)->sector;
viewPoint.Angles.Yaw += deltaangle(baseYaw, trace.SrcAngleFromTarget);
}
else
{
viewPoint.Pos = trace.HitPos;
viewPoint.sector = trace.Sector;
viewPoint.Angles.Yaw += deltaangle(baseYaw, trace.SrcAngleFromTarget);
}

viewPoint.Angles.Yaw += deltaangle(baseYaw, trace.SrcAngleFromTarget);
// TODO: Why does this even need to be done? Please fix tracers already.
if (dir.Z < 0.0)
if (!viewPoint.IsAllowedOoB() || !V_IsHardwareRenderer())
{
while (!viewPoint.sector->PortalBlocksMovement(sector_t::floor) && viewPoint.Pos.Z < viewPoint.sector->GetPortalPlaneZ(sector_t::floor))
if (dir.Z < 0.0)
{
viewPoint.Pos += viewPoint.sector->GetPortalDisplacement(sector_t::floor);
viewPoint.sector = viewPoint.sector->GetPortal(sector_t::floor)->mDestination;
while (!viewPoint.sector->PortalBlocksMovement(sector_t::floor) && viewPoint.Pos.Z < viewPoint.sector->GetPortalPlaneZ(sector_t::floor))
{
viewPoint.Pos += viewPoint.sector->GetPortalDisplacement(sector_t::floor);
viewPoint.sector = viewPoint.sector->GetPortal(sector_t::floor)->mDestination;
}
}
}
else if (dir.Z > 0.0)
{
while (!viewPoint.sector->PortalBlocksMovement(sector_t::ceiling) && viewPoint.Pos.Z > viewPoint.sector->GetPortalPlaneZ(sector_t::ceiling))
else if (dir.Z > 0.0)
{
viewPoint.Pos += viewPoint.sector->GetPortalDisplacement(sector_t::ceiling);
viewPoint.sector = viewPoint.sector->GetPortal(sector_t::ceiling)->mDestination;
while (!viewPoint.sector->PortalBlocksMovement(sector_t::ceiling) && viewPoint.Pos.Z > viewPoint.sector->GetPortalPlaneZ(sector_t::ceiling))
{
viewPoint.Pos += viewPoint.sector->GetPortalDisplacement(sector_t::ceiling);
viewPoint.sector = viewPoint.sector->GetPortal(sector_t::ceiling)->mDestination;
}
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/playsim/p_trace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,9 @@ bool FTraceInfo::LineCheck(intercept_t *in, double dist, DVector3 hit, bool spec
case TRACE_Stop:
return false;

case TRACE_ContinueOutOfBounds:
return true;

case TRACE_Abort:
Results->HitType = TRACE_HitNone;
return false;
Expand Down Expand Up @@ -732,6 +735,7 @@ bool FTraceInfo::ThingCheck(intercept_t *in, double dist, DVector3 hit)
switch (TraceCallback(*Results, TraceCallbackData))
{
case TRACE_Continue: return true;
case TRACE_ContinueOutOfBounds: return true;
case TRACE_Stop: return false;
case TRACE_Abort: Results->HitType = TRACE_HitNone; return false;
case TRACE_Skip: Results->HitType = TRACE_HitNone; return true;
Expand Down
1 change: 1 addition & 0 deletions src/playsim/p_trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ enum ETraceStatus
TRACE_Continue, // continue the trace, returning this hit if there are none further along
TRACE_Skip, // continue the trace; do not return this hit
TRACE_Abort, // stop the trace, returning no hits
TRACE_ContinueOutOfBounds, // continue the trace through walls; don't use this for railguns
};

bool Trace(const DVector3 &start, sector_t *sector, const DVector3 &direction, double maxDist,
Expand Down
6 changes: 5 additions & 1 deletion src/rendering/hwrenderer/hw_entrypoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,11 @@ 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
di->VPUniforms.mProjectionMatrix = eye.GetProjection(fov, ratio, fovratio);
float inv_iso_dist = 1.0f;
bool iso_ortho = (camera->ViewPos != NULL) && (camera->ViewPos->Flags & VPSF_ORTHOGRAPHIC);
if (iso_ortho && (camera->ViewPos->Offset.Length() > 0)) inv_iso_dist = 1.0/camera->ViewPos->Offset.Length();
di->VPUniforms.mProjectionMatrix = eye.GetProjection(fov, ratio, fovratio * inv_iso_dist, iso_ortho);

// 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);
Expand Down
Loading

0 comments on commit 8a5e744

Please sign in to comment.