Add +ONLYVISIBLEINMIRRORS and +INVISIBLEINMIRRORS actor flags. The former makes the actor only visible in reflections, while the latter makes the actor not cast reflections in mirrors.

This commit is contained in:
nashmuhandes 2022-06-19 17:25:59 +08:00 committed by Christoph Oelckers
commit 593627f049
7 changed files with 41 additions and 0 deletions

View file

@ -735,6 +735,17 @@ void HWSprite::Process(HWDrawInfo *di, AActor* thing, sector_t * sector, area_t
viewmaster = thing->master;
}
// [Nash] filter visibility in mirrors
bool isInMirror = di->mCurrentPortal && (di->mCurrentPortal->mState->MirrorFlag > 0 || di->mCurrentPortal->mState->PlaneMirrorFlag > 0);
if (thing->renderflags2 & RF2_INVISIBLEINMIRRORS && isInMirror)
{
return;
}
else if (thing->renderflags2 & RF2_ONLYVISIBLEINMIRRORS && !isInMirror)
{
return;
}
// Some added checks if the camera actor is not supposed to be seen. It can happen that some portal setup has this actor in view in which case it may not be skipped here
if (viewmaster == camera && !vp.showviewer)
{

View file

@ -1028,6 +1028,17 @@ namespace swrenderer
if (!renderportal->CurrentPortalInSkybox && renderportal->CurrentPortal && !!P_PointOnLineSidePrecise(thing->Pos(), renderportal->CurrentPortal->dst))
return false;
// [Nash] filter visibility in mirrors
bool isInMirror = renderportal != nullptr && renderportal->IsInMirrorRecursively;
if (thing->renderflags2 & RF2_INVISIBLEINMIRRORS && isInMirror)
{
return false;
}
else if (thing->renderflags2 & RF2_ONLYVISIBLEINMIRRORS && !isInMirror)
{
return false;
}
double distanceSquared = (thing->Pos() - Thread->Viewport->viewpoint.Pos).LengthSquared();
if (distanceSquared > sprite_distance_cull)
return false;

View file

@ -339,6 +339,8 @@ namespace swrenderer
if (pds->mirror)
{
IsInMirrorRecursively = true;
//vertex_t *v1 = ds->curline->v1;
vertex_t *v1 = pds->src->v1;
@ -465,6 +467,7 @@ namespace swrenderer
CurrentPortal = prevpds;
MirrorFlags = prevmf;
IsInMirrorRecursively = false;
viewpoint.Angles.Yaw = startang;
viewpoint.Pos = startpos;
viewpoint.Path[0] = savedpath[0];

View file

@ -48,6 +48,10 @@ namespace swrenderer
int WindowRight = 0;
uint16_t MirrorFlags = 0;
// [Nash] this is set when first entering a mirror portal, and is unset when leaving the final mirror portal recursion
// Used for the RF2_INVISIBLEINMIRRORS and RF2_ONLYVISIBLEINMIRRORS features
bool IsInMirrorRecursively = false;
PortalDrawseg* CurrentPortal = nullptr;
int CurrentPortalUniq = 0;
bool CurrentPortalInSkybox = false;