- Uplift renderer entry point to DVector3 and provide wrappers for old setups.

This commit is contained in:
Mitchell Richters 2022-09-06 21:35:50 +10:00 committed by Christoph Oelckers
parent 056bb9b0cd
commit f72d42bb8e
7 changed files with 22 additions and 13 deletions

View file

@ -192,13 +192,13 @@ void RenderViewpoint(FRenderViewpoint& mainvp, IntRect* bounds, float fov, float
//
//===========================================================================
FRenderViewpoint SetupViewpoint(DCoreActor* cam, const vec3_t& position, int sectnum, DAngle angle, fixedhoriz horizon, DAngle rollang, float fov = -1)
FRenderViewpoint SetupViewpoint(DCoreActor* cam, const DVector3& position, int sectnum, DAngle angle, fixedhoriz horizon, DAngle rollang, float fov = -1)
{
FRenderViewpoint r_viewpoint{};
r_viewpoint.CameraActor = cam;
r_viewpoint.SectNums = nullptr;
r_viewpoint.SectCount = sectnum;
r_viewpoint.Pos = { position.X / 16.f, position.Y / -16.f, position.Z / -256.f };
r_viewpoint.Pos = { position.X, -position.Y, -position.Z };
r_viewpoint.HWAngles.Yaw = FAngle::fromDeg(-90.f + (float)angle.Degrees());
r_viewpoint.HWAngles.Pitch = FAngle::fromDeg(-horizon.aspitch());
r_viewpoint.HWAngles.Roll = FAngle::fromDeg(-(float)rollang.Degrees());
@ -305,11 +305,11 @@ static void CheckTimer(FRenderState &state, uint64_t ShaderStartTime)
void animatecamsprite(double s);
void render_drawrooms(DCoreActor* playersprite, const vec3_t& position, int sectnum, DAngle angle, fixedhoriz horizon, DAngle rollang, double smoothratio, float fov)
void render_drawrooms(DCoreActor* playersprite, const DVector3& position, int sectnum, DAngle angle, fixedhoriz horizon, DAngle rollang, double smoothratio, float fov)
{
checkRotatedWalls();
updatesector(position.X, position.Y, &sectnum);
updatesector(position, &sectnum);
if (sectnum < 0) return;
iter_dlightf = iter_dlight = draw_dlight = draw_dlightf = 0;
@ -360,9 +360,9 @@ void render_drawrooms(DCoreActor* playersprite, const vec3_t& position, int sect
All.Unclock();
}
void render_camtex(DCoreActor* playersprite, const vec3_t& position, sectortype* sect, DAngle angle, fixedhoriz horizon, DAngle rollang, FGameTexture* camtex, IntRect& rect, double smoothratio)
void render_camtex(DCoreActor* playersprite, const DVector3& position, sectortype* sect, DAngle angle, fixedhoriz horizon, DAngle rollang, FGameTexture* camtex, IntRect& rect, double smoothratio)
{
updatesector(position.X, position.Y, &sect);
updatesector(position, &sect);
if (!sect) return;
screen->RenderState()->SetVertexBuffer(screen->mVertexData);

View file

@ -5,8 +5,17 @@
class FSerializer;
struct IntRect;
void render_drawrooms(DCoreActor* playersprite, const vec3_t& position, int sectnum, DAngle angle, fixedhoriz horizon, DAngle rollang, double smoothratio, float fov = -1);
void render_camtex(DCoreActor* playersprite, const vec3_t& position, sectortype* sect, DAngle angle, fixedhoriz horizon, DAngle rollang, FGameTexture* camtex, IntRect& rect, double smoothratio);
void render_drawrooms(DCoreActor* playersprite, const DVector3& position, int sectnum, DAngle angle, fixedhoriz horizon, DAngle rollang, double smoothratio, float fov = -1);
void render_camtex(DCoreActor* playersprite, const DVector3& position, sectortype* sect, DAngle angle, fixedhoriz horizon, DAngle rollang, FGameTexture* camtex, IntRect& rect, double smoothratio);
inline void render_drawrooms(DCoreActor* playersprite, const vec3_t& position, int sectnum, DAngle angle, fixedhoriz horizon, DAngle rollang, double smoothratio, float fov = -1)
{
render_drawrooms(playersprite, DVector3(position.X * inttoworld, position.Y * inttoworld, position.Z * zinttoworld), sectnum, angle, horizon, rollang, smoothratio, fov);
}
inline void render_camtex(DCoreActor* playersprite, const vec3_t& position, sectortype* sect, DAngle angle, fixedhoriz horizon, DAngle rollang, FGameTexture* camtex, IntRect& rect, double smoothratio)
{
render_camtex(playersprite, DVector3(position.X* inttoworld, position.Y * inttoworld, position.Z* zinttoworld), sect, angle, horizon, rollang, camtex, rect, smoothratio);
}
struct PortalDesc
{

View file

@ -769,7 +769,7 @@ void viewDrawScreen(bool sceneonly)
fixedhoriz deliriumPitchI = interpolatedhorizon(q16horiz(deliriumPitchO), q16horiz(deliriumPitch), gInterpolate);
auto bakCstat = gView->actor->spr.cstat;
gView->actor->spr.cstat |= (gViewPos == 0) ? CSTAT_SPRITE_INVISIBLE : CSTAT_SPRITE_TRANSLUCENT | CSTAT_SPRITE_TRANS_FLIP;
render_drawrooms(gView->actor, { cX, cY, cZ }, sectnum(pSector), cA, cH + deliriumPitchI, rotscrnang, gInterpolate);
render_drawrooms(gView->actor, vec3_t( cX, cY, cZ ), sectnum(pSector), cA, cH + deliriumPitchI, rotscrnang, gInterpolate);
gView->actor->spr.cstat = bakCstat;
bDeliriumOld = bDelirium && gDeliriumBlur;

View file

@ -62,7 +62,7 @@ BEGIN_DUKE_NS
void renderView(DDukeActor* playersprite, sectortype* sect, int x, int y, int z, DAngle a, fixedhoriz h, DAngle rotscrnang, double smoothratio, bool sceneonly, float fov)
{
if (!sceneonly) drawweapon(smoothratio);
render_drawrooms(playersprite, { x, y, z }, sectnum(sect), a, h, rotscrnang, smoothratio, fov);
render_drawrooms(playersprite, vec3_t( x, y, z ), sectnum(sect), a, h, rotscrnang, smoothratio, fov);
}
//---------------------------------------------------------------------------

View file

@ -336,7 +336,7 @@ void DrawView(double smoothRatio, bool sceneonly)
if (!nFreeze && !sceneonly)
DrawWeapons(smoothRatio);
render_drawrooms(nullptr, { int(nCamera.X * worldtoint), int(nCamera.Y * worldtoint), viewz }, sectnum(pSector), nCameraa, nCamerapan, rotscrnang, smoothRatio);
render_drawrooms(nullptr, vec3_t( int(nCamera.X * worldtoint), int(nCamera.Y * worldtoint), viewz ), sectnum(pSector), nCameraa, nCamerapan, rotscrnang, smoothRatio);
if (HavePLURemap())
{

View file

@ -1480,7 +1480,7 @@ void drawscreen(PLAYER* pp, double smoothratio, bool sceneonly)
if (!sceneonly) UpdatePanel(smoothratio);
UpdateWallPortalState();
render_drawrooms(pp->actor, { tx, ty, tz }, sectnum(tsect), tang, thoriz, trotscrnang, smoothratio);
render_drawrooms(pp->actor, vec3_t( tx, ty, tz ), sectnum(tsect), tang, thoriz, trotscrnang, smoothratio);
RestorePortalState();
if (sceneonly)

View file

@ -410,7 +410,7 @@ void drawroomstotile(int daposx, int daposy, int daposz,
screen->RenderTextureView(canvas, [=](IntRect& rect)
{
render_camtex(nullptr, { daposx, daposy, daposz }, dacursect, ang, horiz, nullAngle, tileGetTexture(tilenume), rect, smoothratio);
render_camtex(nullptr, vec3_t( daposx, daposy, daposz ), dacursect, ang, horiz, nullAngle, tileGetTexture(tilenume), rect, smoothratio);
});
}