- Update render_drawrooms() and render_camtex() to work off DAngle objects.

This commit is contained in:
Mitchell Richters 2022-08-27 17:50:44 +10:00 committed by Christoph Oelckers
parent c935fc2226
commit ebac932efe
7 changed files with 17 additions and 18 deletions

View file

@ -192,18 +192,18 @@ void RenderViewpoint(FRenderViewpoint& mainvp, IntRect* bounds, float fov, float
//
//===========================================================================
FRenderViewpoint SetupViewpoint(DCoreActor* cam, const vec3_t& position, int sectnum, binangle angle, fixedhoriz horizon, binangle rollang, float fov = -1)
FRenderViewpoint SetupViewpoint(DCoreActor* cam, const vec3_t& 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.HWAngles.Yaw = FAngle::fromDeg(- 90.f + angle.asdeg());
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(-rollang.asdeg());
r_viewpoint.HWAngles.Roll = FAngle::fromDeg(-(float)rollang.Degrees());
r_viewpoint.FieldOfView = FAngle::fromDeg(fov > 0? fov : (float)r_fov);
r_viewpoint.RotAngle = angle.asbam();
r_viewpoint.RotAngle = angle.BAMs();
double FocalTangent = tan(r_viewpoint.FieldOfView.Radians() / 2);
DAngle an = DAngle::fromDeg(270. - r_viewpoint.HWAngles.Yaw.Degrees());
r_viewpoint.TanSin = FocalTangent * an.Sin();
@ -305,7 +305,7 @@ static void CheckTimer(FRenderState &state, uint64_t ShaderStartTime)
void animatecamsprite(double s);
void render_drawrooms(DCoreActor* playersprite, const vec3_t& position, int sectnum, binangle angle, fixedhoriz horizon, binangle rollang, double smoothratio, float fov)
void render_drawrooms(DCoreActor* playersprite, const vec3_t& position, int sectnum, DAngle angle, fixedhoriz horizon, DAngle rollang, double smoothratio, float fov)
{
checkRotatedWalls();
@ -360,7 +360,7 @@ void render_drawrooms(DCoreActor* playersprite, const vec3_t& position, int sect
All.Unclock();
}
void render_camtex(DCoreActor* playersprite, const vec3_t& position, sectortype* sect, binangle angle, fixedhoriz horizon, binangle rollang, FGameTexture* camtex, IntRect& rect, double smoothratio)
void render_camtex(DCoreActor* playersprite, const vec3_t& position, sectortype* sect, DAngle angle, fixedhoriz horizon, DAngle rollang, FGameTexture* camtex, IntRect& rect, double smoothratio)
{
updatesector(position.X, position.Y, &sect);
if (!sect) return;

View file

@ -5,8 +5,8 @@
class FSerializer;
struct IntRect;
void render_drawrooms(DCoreActor* playersprite, const vec3_t& position, int sectnum, binangle angle, fixedhoriz horizon, binangle rollang, double smoothratio, float fov = -1);
void render_camtex(DCoreActor* playersprite, const vec3_t& position, sectortype* sect, binangle angle, fixedhoriz horizon, binangle rollang, FGameTexture* camtex, IntRect& rect, double smoothratio);
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);
struct PortalDesc
{

View file

@ -772,7 +772,7 @@ void viewDrawScreen(bool sceneonly)
fixedhoriz deliriumPitchI = q16horiz(interpolatedvalue(IntToFixed(deliriumPitchO), IntToFixed(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, { cX, cY, cZ }, sectnum(pSector), DAngle::fromBam(cA.asbam()), cH + deliriumPitchI, DAngle::fromBam(rotscrnang.asbam()), 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, binangle a, fixedhoriz h, binangle 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, { x, y, z }, sectnum(sect), DAngle::fromBam(a.asbam()), h, DAngle::fromBam(rotscrnang.asbam()), smoothratio, fov);
}
//---------------------------------------------------------------------------
@ -92,11 +92,10 @@ void GameInterface::UpdateCameras(double smoothratio)
screen->RenderTextureView(canvas, [=](IntRect& rect)
{
auto camera = camsprite->GetOwner();
auto ang = buildang(camera->interpolatedang(smoothratio));
display_mirror = 1; // should really be 'display external view'.
auto cstat = camera->spr.cstat;
camera->spr.cstat = CSTAT_SPRITE_INVISIBLE;
render_camtex(camera, camera->int_pos(), camera->sector(), ang, buildhoriz(camera->spr.shade), buildang(0), tex, rect, smoothratio);
render_camtex(camera, camera->int_pos(), camera->sector(), DAngle::fromBuild(camera->interpolatedang(smoothratio)), buildhoriz(camera->spr.shade), DAngle::fromDeg(0.), tex, rect, smoothratio);
camera->spr.cstat = cstat;
display_mirror = 0;
});

View file

@ -346,7 +346,7 @@ void DrawView(double smoothRatio, bool sceneonly)
if (!nFreeze && !sceneonly)
DrawWeapons(smoothRatio);
render_drawrooms(nullptr, { nCamerax, nCameray, viewz }, sectnum(pSector), nCameraa, nCamerapan, rotscrnang, smoothRatio);
render_drawrooms(nullptr, { nCamerax, nCameray, viewz }, sectnum(pSector), DAngle::fromBam(nCameraa.asbam()), nCamerapan, DAngle::fromBam(rotscrnang.asbam()), smoothRatio);
if (HavePLURemap())
{

View file

@ -1493,7 +1493,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, { tx, ty, tz }, sectnum(tsect), DAngle::fromBam(tang.asbam()), thoriz, DAngle::fromBam(trotscrnang.asbam()), smoothratio);
RestorePortalState();
if (sceneonly)

View file

@ -403,14 +403,14 @@ void JS_InitMirrors(void)
// Draw a 3d screen to a specific tile
/////////////////////////////////////////////////////
void drawroomstotile(int daposx, int daposy, int daposz,
binangle ang, fixedhoriz horiz, sectortype* dacursect, short tilenume, double smoothratio)
DAngle ang, fixedhoriz horiz, sectortype* dacursect, short tilenume, double smoothratio)
{
auto canvas = tileGetCanvas(tilenume);
if (!canvas) return;
screen->RenderTextureView(canvas, [=](IntRect& rect)
{
render_camtex(nullptr, { daposx, daposy, daposz }, dacursect, ang, horiz, buildang(0), tileGetTexture(tilenume), rect, smoothratio);
render_camtex(nullptr, { daposx, daposy, daposz }, dacursect, ang, horiz, DAngle::fromDeg(0.), tileGetTexture(tilenume), rect, smoothratio);
});
}
@ -626,11 +626,11 @@ void JS_DrawCameras(PLAYER* pp, int tx, int ty, int tz, double smoothratio)
if (TEST_BOOL11(camactor) && numplayers > 1)
{
drawroomstotile(cp->pos.X, cp->pos.Y, cp->pos.Z, cp->angle.ang, cp->horizon.horiz, cp->cursector, mirror[cnt].campic, smoothratio);
drawroomstotile(cp->pos.X, cp->pos.Y, cp->pos.Z, DAngle::fromBam(cp->angle.ang.asbam()), cp->horizon.horiz, cp->cursector, mirror[cnt].campic, smoothratio);
}
else
{
drawroomstotile(camactor->int_pos().X, camactor->int_pos().Y, camactor->int_pos().Z, buildang(SP_TAG5(camactor)), camhoriz, camactor->sector(), mirror[cnt].campic, smoothratio);
drawroomstotile(camactor->int_pos().X, camactor->int_pos().Y, camactor->int_pos().Z, DAngle::fromBuild(SP_TAG5(camactor)), camhoriz, camactor->sector(), mirror[cnt].campic, smoothratio);
}
}
}