- fixed display of player in mirrors.

This commit is contained in:
Christoph Oelckers 2021-03-29 21:48:23 +02:00
parent d2a1f9ea88
commit 92bb9c5319
11 changed files with 79 additions and 21 deletions

View file

@ -12,6 +12,7 @@ bool System_WantGuiCapture(); // During playing this tells us whether the game m
class FSerializer; class FSerializer;
struct FRenderViewpoint; struct FRenderViewpoint;
struct spritetype;
struct GameStats struct GameStats
{ {
@ -104,6 +105,8 @@ struct GameInterface
virtual int chaseCamZ(fixedhoriz horiz) { return 0; } virtual int chaseCamZ(fixedhoriz horiz) { return 0; }
virtual void processSprites(int viewx, int viewy, int viewz, binangle viewang, double smoothRatio) = 0; virtual void processSprites(int viewx, int viewy, int viewz, binangle viewang, double smoothRatio) = 0;
virtual void UpdateCameras(double smoothratio) {} virtual void UpdateCameras(double smoothratio) {}
virtual void EnterPortal(spritetype* viewer, int type) {}
virtual void LeavePortal(spritetype* viewer, int type) {}
virtual FString statFPS() virtual FString statFPS()
{ {

View file

@ -390,6 +390,24 @@ void HWPortal::RemoveStencil(HWDrawInfo *di, FRenderState &state, bool usestenci
} }
//-----------------------------------------------------------------------------
//
//
//
//-----------------------------------------------------------------------------
void HWScenePortalBase::DrawContents(HWDrawInfo* di, FRenderState& state)
{
if (Setup(di, state, di->mClipper))
{
gi->EnterPortal(di->Viewpoint.CameraSprite, GetType());
di->DrawScene(DM_PORTAL);
gi->LeavePortal(di->Viewpoint.CameraSprite, GetType());
Shutdown(di, state);
}
else state.ClearScreen();
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// //
// //
@ -570,13 +588,6 @@ bool HWMirrorPortal::Setup(HWDrawInfo *di, FRenderState &rstate, Clipper *clippe
vp.TanCos = FocalTangent * an.Cos(); vp.TanCos = FocalTangent * an.Cos();
vp.ViewVector = an.ToVector(); vp.ViewVector = an.ToVector();
int oldstat = 0;
if (vp.CameraSprite)
{
oldstat = vp.CameraSprite->cstat;
vp.CameraSprite->cstat &= ~CSTAT_SPRITE_INVISIBLE;
}
state->MirrorFlag++; state->MirrorFlag++;
di->SetClipLine(line); di->SetClipLine(line);
di->SetupView(rstate, vp.Pos.X, vp.Pos.Y, vp.Pos.Z, !!(state->MirrorFlag & 1), !!(state->PlaneMirrorFlag & 1)); di->SetupView(rstate, vp.Pos.X, vp.Pos.Y, vp.Pos.Z, !!(state->MirrorFlag & 1), !!(state->PlaneMirrorFlag & 1));

View file

@ -160,6 +160,7 @@ public:
virtual bool NeedDepthBuffer() { return true; } virtual bool NeedDepthBuffer() { return true; }
virtual void DrawContents(HWDrawInfo *di, FRenderState &state) = 0; virtual void DrawContents(HWDrawInfo *di, FRenderState &state) = 0;
virtual void RenderAttached(HWDrawInfo *di) {} virtual void RenderAttached(HWDrawInfo *di) {}
virtual int GetType() { return -1; }
void SetupStencil(HWDrawInfo *di, FRenderState &state, bool usestencil); void SetupStencil(HWDrawInfo *di, FRenderState &state, bool usestencil);
void RemoveStencil(HWDrawInfo *di, FRenderState &state, bool usestencil); void RemoveStencil(HWDrawInfo *di, FRenderState &state, bool usestencil);
@ -221,15 +222,7 @@ protected:
public: public:
void ClearClipper(HWDrawInfo *di, Clipper *clipper); void ClearClipper(HWDrawInfo *di, Clipper *clipper);
virtual bool NeedDepthBuffer() { return true; } virtual bool NeedDepthBuffer() { return true; }
virtual void DrawContents(HWDrawInfo *di, FRenderState &state) virtual void DrawContents(HWDrawInfo* di, FRenderState& state);
{
if (Setup(di, state, di->mClipper))
{
di->DrawScene(DM_PORTAL);
Shutdown(di, state);
}
else state.ClearScreen();
}
virtual bool Setup(HWDrawInfo *di, FRenderState &rstate, Clipper *clipper) = 0; virtual bool Setup(HWDrawInfo *di, FRenderState &rstate, Clipper *clipper) = 0;
virtual void Shutdown(HWDrawInfo *di, FRenderState &rstate) {} virtual void Shutdown(HWDrawInfo *di, FRenderState &rstate) {}
}; };
@ -267,12 +260,12 @@ protected:
struct HWMirrorPortal : public HWLinePortal struct HWMirrorPortal : public HWLinePortal
{ {
protected: protected:
bool Setup(HWDrawInfo *di, FRenderState &rstate, Clipper *clipper) override; bool Setup(HWDrawInfo *di, FRenderState &rstate, Clipper *clipper) override;
void Shutdown(HWDrawInfo *di, FRenderState &rstate) override; void Shutdown(HWDrawInfo *di, FRenderState &rstate) override;
void * GetSource() const override { return line; } void * GetSource() const override { return line; }
const char *GetName() override; const char *GetName() override;
virtual int GetType() { return PORTAL_WALL_MIRROR; }
public: public:
@ -291,6 +284,7 @@ protected:
virtual void * GetSource() const override { return origin; } virtual void * GetSource() const override { return origin; }
virtual const char *GetName() override; virtual const char *GetName() override;
virtual walltype *ClipLine() override { return line; } virtual walltype *ClipLine() override { return line; }
virtual int GetType() { return PORTAL_WALL_VIEW; }
public: public:
@ -309,6 +303,7 @@ protected:
virtual void* GetSource() const override { return origin; } virtual void* GetSource() const override { return origin; }
virtual const char* GetName() override; virtual const char* GetName() override;
virtual walltype* ClipLine() override { return line; } virtual walltype* ClipLine() override { return line; }
virtual int GetType() { return PORTAL_WALL_TO_SPRITE; }
public: public:
@ -358,6 +353,7 @@ protected:
virtual void * GetSource() const { return origin; } virtual void * GetSource() const { return origin; }
virtual bool IsSky() { return true; } // although this isn't a real sky it can be handled as one. virtual bool IsSky() { return true; } // although this isn't a real sky it can be handled as one.
virtual const char *GetName(); virtual const char *GetName();
virtual int GetType() { return PORTAL_SECTOR_CEILING; }
PortalDesc *origin; PortalDesc *origin;
public: public:

View file

@ -892,4 +892,24 @@ void GameInterface::processSprites(int viewx, int viewy, int viewz, binangle vie
viewProcessSprites(viewx, viewy, viewz, viewang.asbuild(), int(smoothRatio)); viewProcessSprites(viewx, viewy, viewz, viewang.asbuild(), int(smoothRatio));
} }
int display_mirror;
void GameInterface::EnterPortal(spritetype* viewer, int type)
{
if (type == PORTAL_WALL_MIRROR)
{
display_mirror++;
if (viewer) viewer->cstat &= ~CSTAT_SPRITE_INVISIBLE;
}
}
void GameInterface::LeavePortal(spritetype* viewer, int type)
{
if (type == PORTAL_WALL_MIRROR)
{
display_mirror--;
if (viewer && display_mirror == 0 && !(viewer->cstat & CSTAT_SPRITE_TRANSLUCENT)) viewer->cstat |= CSTAT_SPRITE_INVISIBLE;
}
}
END_BLD_NS END_BLD_NS

View file

@ -148,6 +148,8 @@ struct GameInterface : ::GameInterface
int chaseCamY(binangle ang) override { return MulScale(-Sin(ang.asbuild()), 1280, 30); } int chaseCamY(binangle ang) override { return MulScale(-Sin(ang.asbuild()), 1280, 30); }
int chaseCamZ(fixedhoriz horiz) override { return FixedToInt(MulScale(horiz.asq16(), 1280, 3)) - (16 << 8); } int chaseCamZ(fixedhoriz horiz) override { return FixedToInt(MulScale(horiz.asq16(), 1280, 3)) - (16 << 8); }
void processSprites(int viewx, int viewy, int viewz, binangle viewang, double smoothRatio) override; void processSprites(int viewx, int viewy, int viewz, binangle viewang, double smoothRatio) override;
void EnterPortal(spritetype* viewer, int type) override;
void LeavePortal(spritetype* viewer, int type) override;
GameStats getStats() override; GameStats getStats() override;
}; };

View file

@ -67,6 +67,8 @@ struct GameInterface : public ::GameInterface
int chaseCamZ(fixedhoriz horiz) { return horiz.asq16() >> 9; } int chaseCamZ(fixedhoriz horiz) { return horiz.asq16() >> 9; }
void processSprites(int viewx, int viewy, int viewz, binangle viewang, double smoothRatio) override; void processSprites(int viewx, int viewy, int viewz, binangle viewang, double smoothRatio) override;
void UpdateCameras(double smoothratio) override; void UpdateCameras(double smoothratio) override;
void EnterPortal(spritetype* viewer, int type) override;
void LeavePortal(spritetype* viewer, int type) override;
}; };

View file

@ -134,6 +134,16 @@ void GameInterface::UpdateCameras(double smoothratio)
} }
} }
void GameInterface::EnterPortal(spritetype* viewer, int type)
{
if (type == PORTAL_WALL_MIRROR) display_mirror++;
}
void GameInterface::LeavePortal(spritetype* viewer, int type)
{
if (type == PORTAL_WALL_MIRROR) display_mirror--;
}
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// //
// RRRA's drug distortion effect // RRRA's drug distortion effect

View file

@ -317,7 +317,7 @@ void JS_DrawMirrors(PLAYERp pp, int tx, int ty, int tz, fixed_t tpq16ang, fixed
// position into tposx, tposy, and tang (tposz == cposz) // position into tposx, tposy, and tang (tposz == cposz)
// Must call preparemirror before drawrooms and // Must call preparemirror before drawrooms and
// completemirror after drawrooms // completemirror after drawrooms
display_mirror = true;
renderPrepareMirror(tx, ty, tz, tpq16ang, tpq16horiz, renderPrepareMirror(tx, ty, tz, tpq16ang, tpq16horiz,
mirror[cnt].mirrorwall, /*mirror[cnt].mirrorsector,*/ &tposx, &tposy, &tang); mirror[cnt].mirrorwall, /*mirror[cnt].mirrorsector,*/ &tposx, &tposy, &tang);
@ -327,7 +327,7 @@ void JS_DrawMirrors(PLAYERp pp, int tx, int ty, int tz, fixed_t tpq16ang, fixed
renderDrawMasks(); renderDrawMasks();
renderCompleteMirror(); // Reverse screen x-wise in this renderCompleteMirror(); // Reverse screen x-wise in this
// function display_mirror = false;
} }

View file

@ -62,6 +62,7 @@ EXTERN_CVAR(Bool, testnewrenderer)
BEGIN_SW_NS BEGIN_SW_NS
int display_mirror;
static int OverlapDraw = false; static int OverlapDraw = false;
extern bool QuitFlag, SpriteInfo; extern bool QuitFlag, SpriteInfo;
extern bool Voxel; extern bool Voxel;
@ -753,7 +754,7 @@ analyzesprites(int viewx, int viewy, int viewz, int camang)
if ((Player + screenpeek)->PlayerSprite == tu->SpriteNum) if ((Player + screenpeek)->PlayerSprite == tu->SpriteNum)
{ {
PLAYERp pp = Player + screenpeek; PLAYERp pp = Player + screenpeek;
if (mirror || TEST(pp->Flags, PF_VIEW_FROM_OUTSIDE|PF_VIEW_FROM_CAMERA)) if (display_mirror || TEST(pp->Flags, PF_VIEW_FROM_OUTSIDE|PF_VIEW_FROM_CAMERA))
{ {
if (TEST(pp->Flags, PF_VIEW_FROM_OUTSIDE)) if (TEST(pp->Flags, PF_VIEW_FROM_OUTSIDE))
SET(tsp->cstat, CSTAT_SPRITE_TRANSLUCENT); SET(tsp->cstat, CSTAT_SPRITE_TRANSLUCENT);
@ -869,6 +870,7 @@ analyzesprites(int viewx, int viewy, int viewz, int camang)
} }
#if 1 #if 1
tspriteptr_t get_tsprite(short SpriteNum) tspriteptr_t get_tsprite(short SpriteNum)
{ {
@ -1568,7 +1570,6 @@ drawscreen(PLAYERp pp, double smoothratio)
{ {
UpdateWallPortalState(); UpdateWallPortalState();
auto cstat = pp->SpriteP->cstat; auto cstat = pp->SpriteP->cstat;
if (!TEST(pp->Flags, PF_VIEW_FROM_OUTSIDE)) pp->SpriteP->cstat |= CSTAT_SPRITE_INVISIBLE;
render_drawrooms(pp->SpriteP, { tx, ty, tz }, tsectnum, tang, thoriz, trotscrnang); render_drawrooms(pp->SpriteP, { tx, ty, tz }, tsectnum, tang, thoriz, trotscrnang);
pp->SpriteP->cstat = cstat; pp->SpriteP->cstat = cstat;
} }

View file

@ -2250,6 +2250,8 @@ struct GameInterface : ::GameInterface
int chaseCamZ(fixedhoriz horiz) { return horiz.asq16() >> 8; } int chaseCamZ(fixedhoriz horiz) { return horiz.asq16() >> 8; }
void processSprites(int viewx, int viewy, int viewz, binangle viewang, double smoothRatio) override; void processSprites(int viewx, int viewy, int viewz, binangle viewang, double smoothRatio) override;
void UpdateCameras(double smoothratio) override; void UpdateCameras(double smoothratio) override;
void EnterPortal(spritetype* viewer, int type) override;
void LeavePortal(spritetype* viewer, int type) override;
GameStats getStats() override; GameStats getStats() override;

View file

@ -739,6 +739,7 @@ void JS_DrawCameras(PLAYERp pp, int tx, int ty, int tz, double smoothratio)
// Need to stash the parameters for later use. This is only used to find the nearest camera. // Need to stash the parameters for later use. This is only used to find the nearest camera.
static PLAYERp cam_pp; static PLAYERp cam_pp;
static int cam_tx, cam_ty, cam_tz; static int cam_tx, cam_ty, cam_tz;
static int oldstat;
void JS_CameraParms(PLAYERp pp, int tx, int ty, int tz) void JS_CameraParms(PLAYERp pp, int tx, int ty, int tz)
{ {
@ -753,6 +754,16 @@ void GameInterface::UpdateCameras(double smoothratio)
JS_DrawCameras(cam_pp, cam_tx, cam_ty, cam_tz, smoothratio); JS_DrawCameras(cam_pp, cam_tx, cam_ty, cam_tz, smoothratio);
} }
void GameInterface::EnterPortal(spritetype* viewer, int type)
{
if (type == PORTAL_WALL_MIRROR) display_mirror++;
}
void GameInterface::LeavePortal(spritetype* viewer, int type)
{
if (type == PORTAL_WALL_MIRROR) display_mirror--;
}
void void
DoAutoSize(tspriteptr_t tspr) DoAutoSize(tspriteptr_t tspr)