mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-24 21:11:52 +00:00
- updated GL renderer.
This commit is contained in:
parent
348c384bb6
commit
af78937a15
22 changed files with 238 additions and 306 deletions
|
@ -47,8 +47,7 @@ struct GLSectorStackPortal;
|
|||
|
||||
struct FPortal
|
||||
{
|
||||
fixed_t xDisplacement;
|
||||
fixed_t yDisplacement;
|
||||
DVector2 mDisplacement;
|
||||
int plane;
|
||||
GLSectorStackPortal *glportal; // for quick access to the render data. This is only valid during BSP traversal!
|
||||
|
||||
|
|
|
@ -64,15 +64,13 @@
|
|||
|
||||
struct FPortalID
|
||||
{
|
||||
fixed_t mXDisplacement;
|
||||
fixed_t mYDisplacement;
|
||||
DVector2 mDisplacement;
|
||||
|
||||
// for the hash code
|
||||
operator intptr_t() const { return (mXDisplacement >> 8) + (mYDisplacement << 8); }
|
||||
operator intptr_t() const { return (FLOAT2FIXED(mDisplacement.X) >> 8) + (FLOAT2FIXED(mDisplacement.Y) << 8); }
|
||||
bool operator != (const FPortalID &other) const
|
||||
{
|
||||
return mXDisplacement != other.mXDisplacement ||
|
||||
mYDisplacement != other.mYDisplacement;
|
||||
return mDisplacement != other.mDisplacement;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -331,8 +329,8 @@ void gl_BuildPortalCoverage(FPortalCoverage *coverage, subsector_t *subsector, F
|
|||
shape.Resize(subsector->numlines);
|
||||
for(unsigned i=0; i<subsector->numlines; i++)
|
||||
{
|
||||
centerx += (shape[i].x = subsector->firstline[i].v1->fixX() + portal->xDisplacement);
|
||||
centery += (shape[i].y = subsector->firstline[i].v1->fixY() + portal->yDisplacement);
|
||||
centerx += (shape[i].x = FLOAT2FIXED(subsector->firstline[i].v1->fX() + portal->mDisplacement.X));
|
||||
centery += (shape[i].y = FLOAT2FIXED(subsector->firstline[i].v1->fY() + portal->mDisplacement.Y));
|
||||
}
|
||||
|
||||
FCoverageBuilder build(subsector, portal);
|
||||
|
@ -361,7 +359,7 @@ static void CollectPortalSectors(FPortalMap &collection)
|
|||
ASkyViewpoint *SkyBox = barrier_cast<ASkyViewpoint*>(sec->SkyBoxes[j]);
|
||||
if (SkyBox != NULL && SkyBox->bAlways && SkyBox->Mate != NULL)
|
||||
{
|
||||
FPortalID id = { SkyBox->_f_X() - SkyBox->Mate->_f_X(), SkyBox->_f_Y() - SkyBox->Mate->_f_Y() };
|
||||
FPortalID id = { {SkyBox->X() - SkyBox->Mate->X(), SkyBox->Y() - SkyBox->Mate->Y()} };
|
||||
|
||||
FPortalSectors &sss = collection[id];
|
||||
FPortalSector ss = { sec, j };
|
||||
|
@ -406,8 +404,7 @@ void gl_InitPortals()
|
|||
if (planeflags & i)
|
||||
{
|
||||
FPortal *portal = new FPortal;
|
||||
portal->xDisplacement = pair->Key.mXDisplacement;
|
||||
portal->yDisplacement = pair->Key.mYDisplacement;
|
||||
portal->mDisplacement = pair->Key.mDisplacement;
|
||||
portal->plane = (i==1? sector_t::floor : sector_t::ceiling); /**/
|
||||
portal->glportal = NULL;
|
||||
portals.Push(portal);
|
||||
|
@ -505,8 +502,8 @@ CCMD(dumpportals)
|
|||
{
|
||||
for(unsigned i=0;i<portals.Size(); i++)
|
||||
{
|
||||
double xdisp = portals[i]->xDisplacement/65536.;
|
||||
double ydisp = portals[i]->yDisplacement/65536.;
|
||||
double xdisp = portals[i]->mDisplacement.X;
|
||||
double ydisp = portals[i]->mDisplacement.Y;
|
||||
Printf(PRINT_LOG, "Portal #%d, %s, displacement = (%f,%f)\n", i, portals[i]->plane==0? "floor":"ceiling",
|
||||
xdisp, ydisp);
|
||||
Printf(PRINT_LOG, "Coverage:\n");
|
||||
|
|
|
@ -93,8 +93,8 @@ public:
|
|||
void SetViewport(GL_IRECT *bounds);
|
||||
sector_t *RenderViewpoint (AActor * camera, GL_IRECT * bounds, float fov, float ratio, float fovratio, bool mainview, bool toscreen);
|
||||
void RenderView(player_t *player);
|
||||
void SetViewAngle(angle_t viewangle);
|
||||
void SetupView(fixed_t viewx, fixed_t viewy, fixed_t viewz, angle_t viewangle, bool mirror, bool planemirror);
|
||||
void SetViewAngle(DAngle viewangle);
|
||||
void SetupView(float viewx, float viewy, float viewz, DAngle viewangle, bool mirror, bool planemirror);
|
||||
|
||||
void Initialize();
|
||||
|
||||
|
@ -132,7 +132,7 @@ public:
|
|||
|
||||
void SetProjection(float fov, float ratio, float fovratio);
|
||||
void SetProjection(VSMatrix matrix); // raw matrix input from stereo 3d modes
|
||||
void SetViewMatrix(fixed_t viewx, fixed_t viewy, fixed_t viewz, bool mirror, bool planemirror);
|
||||
void SetViewMatrix(float vx, float vy, float vz, bool mirror, bool planemirror);
|
||||
void ProcessScene(bool toscreen = false);
|
||||
|
||||
bool StartOffscreen();
|
||||
|
|
|
@ -388,7 +388,13 @@ angle_t Clipper::AngleToPseudo(angle_t ang)
|
|||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
angle_t R_PointToPseudoAngle (fixed_t viewx, fixed_t viewy, fixed_t x, fixed_t y)
|
||||
void R_SetView()
|
||||
{
|
||||
viewx = FLOAT2FIXED(ViewPos.X);
|
||||
viewy = FLOAT2FIXED(ViewPos.Y);
|
||||
}
|
||||
|
||||
angle_t R_PointToPseudoAngle (fixed_t x, fixed_t y)
|
||||
{
|
||||
// Note: float won't work here as it's less precise than the BAM values being passed as parameters
|
||||
double vecx = double(x-viewx);
|
||||
|
@ -450,8 +456,8 @@ bool Clipper::CheckBox(const fixed_t *bspcoord)
|
|||
if (boxpos == 5) return true;
|
||||
|
||||
check = checkcoord[boxpos];
|
||||
angle1 = R_PointToPseudoAngle (viewx, viewy, bspcoord[check[0]], bspcoord[check[1]]);
|
||||
angle2 = R_PointToPseudoAngle (viewx, viewy, bspcoord[check[2]], bspcoord[check[3]]);
|
||||
angle1 = R_PointToPseudoAngle (bspcoord[check[0]], bspcoord[check[1]]);
|
||||
angle2 = R_PointToPseudoAngle (bspcoord[check[2]], bspcoord[check[3]]);
|
||||
|
||||
return SafeCheckRange(angle2, angle1);
|
||||
}
|
||||
|
|
|
@ -136,12 +136,13 @@ public:
|
|||
|
||||
extern Clipper clipper;
|
||||
|
||||
angle_t R_PointToPseudoAngle (fixed_t viewx, fixed_t viewy, fixed_t x, fixed_t y);
|
||||
angle_t R_PointToPseudoAngle (fixed_t x, fixed_t y);
|
||||
void R_SetView();
|
||||
|
||||
// Used to speed up angle calculations during clipping
|
||||
inline angle_t vertex_t::GetClipAngle()
|
||||
{
|
||||
return angletime == Clipper::anglecache? viewangle : (angletime = Clipper::anglecache, viewangle = R_PointToPseudoAngle(viewx, viewy, x,y));
|
||||
return angletime == Clipper::anglecache? viewangle : (angletime = Clipper::anglecache, viewangle = R_PointToPseudoAngle(x,y));
|
||||
}
|
||||
|
||||
#endif
|
|
@ -243,39 +243,39 @@ SortNode * GLDrawList::FindSortPlane(SortNode * head)
|
|||
//==========================================================================
|
||||
SortNode * GLDrawList::FindSortWall(SortNode * head)
|
||||
{
|
||||
fixed_t farthest=INT_MIN;
|
||||
fixed_t nearest=INT_MAX;
|
||||
SortNode * best=NULL;
|
||||
SortNode * node=head;
|
||||
fixed_t bestdist=INT_MAX;
|
||||
float farthest = -FLT_MAX;
|
||||
float nearest = FLT_MAX;
|
||||
SortNode * best = NULL;
|
||||
SortNode * node = head;
|
||||
float bestdist = FLT_MAX;
|
||||
|
||||
while (node)
|
||||
{
|
||||
GLDrawItem * it=&drawitems[node->itemindex];
|
||||
if (it->rendertype==GLDIT_WALL)
|
||||
GLDrawItem * it = &drawitems[node->itemindex];
|
||||
if (it->rendertype == GLDIT_WALL)
|
||||
{
|
||||
fixed_t d=walls[it->index].viewdistance;
|
||||
if (d>farthest) farthest=d;
|
||||
if (d<nearest) nearest=d;
|
||||
float d = walls[it->index].ViewDistance;
|
||||
if (d > farthest) farthest = d;
|
||||
if (d < nearest) nearest = d;
|
||||
}
|
||||
node=node->next;
|
||||
node = node->next;
|
||||
}
|
||||
if (farthest==INT_MIN) return NULL;
|
||||
node=head;
|
||||
farthest=(farthest+nearest)>>1;
|
||||
if (farthest == INT_MIN) return NULL;
|
||||
node = head;
|
||||
farthest = (farthest + nearest) / 2;
|
||||
while (node)
|
||||
{
|
||||
GLDrawItem * it=&drawitems[node->itemindex];
|
||||
if (it->rendertype==GLDIT_WALL)
|
||||
GLDrawItem * it = &drawitems[node->itemindex];
|
||||
if (it->rendertype == GLDIT_WALL)
|
||||
{
|
||||
fixed_t di=abs(walls[it->index].viewdistance-farthest);
|
||||
if (!best || di<bestdist)
|
||||
float di = fabsf(walls[it->index].ViewDistance - farthest);
|
||||
if (!best || di < bestdist)
|
||||
{
|
||||
best=node;
|
||||
bestdist=di;
|
||||
best = node;
|
||||
bestdist = di;
|
||||
}
|
||||
}
|
||||
node=node->next;
|
||||
node = node->next;
|
||||
}
|
||||
return best;
|
||||
}
|
||||
|
@ -309,7 +309,7 @@ void GLDrawList::SortWallIntoPlane(SortNode * head,SortNode * sort)
|
|||
GLFlat * fh=&flats[drawitems[head->itemindex].index];
|
||||
GLWall * ws=&walls[drawitems[sort->itemindex].index];
|
||||
|
||||
bool ceiling = fh->z > FIXED2FLOAT(viewz);
|
||||
bool ceiling = fh->z > ViewPos.Z;
|
||||
|
||||
if ((ws->ztop[0] > fh->z || ws->ztop[1] > fh->z) && (ws->zbottom[0] < fh->z || ws->zbottom[1] < fh->z))
|
||||
{
|
||||
|
@ -350,7 +350,7 @@ void GLDrawList::SortSpriteIntoPlane(SortNode * head,SortNode * sort)
|
|||
GLFlat * fh=&flats[drawitems[head->itemindex].index];
|
||||
GLSprite * ss=&sprites[drawitems[sort->itemindex].index];
|
||||
|
||||
bool ceiling = fh->z > FIXED2FLOAT(viewz);
|
||||
bool ceiling = fh->z > ViewPos.Z;
|
||||
|
||||
if ((ss->z1>fh->z && ss->z2<fh->z) || ss->modelframe)
|
||||
{
|
||||
|
@ -708,7 +708,7 @@ void GLDrawList::DoDrawSorted(SortNode * head)
|
|||
if (drawitems[head->itemindex].rendertype == GLDIT_FLAT)
|
||||
{
|
||||
z = flats[drawitems[head->itemindex].index].z;
|
||||
relation = z > FIXED2FLOAT(viewz)? 1 : -1;
|
||||
relation = z > ViewPos.Z ? 1 : -1;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1112,9 +1112,9 @@ void FDrawInfo::DrawFloodedPlane(wallseg * ws, float planez, sector_t * sec, boo
|
|||
gl_SetFog(lightlevel, rel, &Colormap, false);
|
||||
gl_RenderState.SetMaterial(gltexture, CLAMP_NONE, 0, -1, false);
|
||||
|
||||
float fviewx = FIXED2FLOAT(viewx);
|
||||
float fviewy = FIXED2FLOAT(viewy);
|
||||
float fviewz = FIXED2FLOAT(viewz);
|
||||
float fviewx = ViewPos.X;
|
||||
float fviewy = ViewPos.Y;
|
||||
float fviewz = ViewPos.Z;
|
||||
|
||||
gl_SetPlaneTextureRotation(&plane, gltexture);
|
||||
gl_RenderState.Apply();
|
||||
|
@ -1165,11 +1165,11 @@ void FDrawInfo::FloodUpperGap(seg_t * seg)
|
|||
|
||||
// Although the plane can be sloped this code will only be called
|
||||
// when the edge itself is not.
|
||||
fixed_t backz = fakebsector->ceilingplane.ZatPoint(seg->v1->x, seg->v1->y);
|
||||
fixed_t frontz = fakefsector->ceilingplane.ZatPoint(seg->v1->x, seg->v1->y);
|
||||
double backz = fakebsector->ceilingplane.ZatPoint(seg->v1);
|
||||
double frontz = fakefsector->ceilingplane.ZatPoint(seg->v1);
|
||||
|
||||
if (fakebsector->GetTexture(sector_t::ceiling)==skyflatnum) return;
|
||||
if (backz < viewz) return;
|
||||
if (backz < ViewPos.Z) return;
|
||||
|
||||
if (seg->sidedef == seg->linedef->sidedef[0])
|
||||
{
|
||||
|
@ -1187,8 +1187,8 @@ void FDrawInfo::FloodUpperGap(seg_t * seg)
|
|||
ws.x2 = v2->fX();
|
||||
ws.y2 = v2->fY();
|
||||
|
||||
ws.z1= FIXED2FLOAT(frontz);
|
||||
ws.z2= FIXED2FLOAT(backz);
|
||||
ws.z1= frontz;
|
||||
ws.z2= backz;
|
||||
|
||||
// Step1: Draw a stencil into the gap
|
||||
SetupFloodStencil(&ws);
|
||||
|
@ -1217,12 +1217,12 @@ void FDrawInfo::FloodLowerGap(seg_t * seg)
|
|||
|
||||
// Although the plane can be sloped this code will only be called
|
||||
// when the edge itself is not.
|
||||
fixed_t backz = fakebsector->floorplane.ZatPoint(seg->v1->x, seg->v1->y);
|
||||
fixed_t frontz = fakefsector->floorplane.ZatPoint(seg->v1->x, seg->v1->y);
|
||||
double backz = fakebsector->floorplane.ZatPoint(seg->v1);
|
||||
double frontz = fakefsector->floorplane.ZatPoint(seg->v1);
|
||||
|
||||
|
||||
if (fakebsector->GetTexture(sector_t::floor) == skyflatnum) return;
|
||||
if (fakebsector->GetPlaneTexZ(sector_t::floor) > viewz) return;
|
||||
if (fakebsector->GetPlaneTexZF(sector_t::floor) > ViewPos.Z) return;
|
||||
|
||||
if (seg->sidedef == seg->linedef->sidedef[0])
|
||||
{
|
||||
|
@ -1240,8 +1240,8 @@ void FDrawInfo::FloodLowerGap(seg_t * seg)
|
|||
ws.x2 = v2->fX();
|
||||
ws.y2 = v2->fY();
|
||||
|
||||
ws.z2= FIXED2FLOAT(frontz);
|
||||
ws.z1= FIXED2FLOAT(backz);
|
||||
ws.z2= frontz;
|
||||
ws.z1= backz;
|
||||
|
||||
// Step1: Draw a stencil into the gap
|
||||
SetupFloodStencil(&ws);
|
||||
|
|
|
@ -516,7 +516,7 @@ void GLFlat::ProcessSector(sector_t * frontsector)
|
|||
//
|
||||
//
|
||||
//
|
||||
if (frontsector->floorplane.ZatPoint(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy)) <= FIXED2FLOAT(viewz))
|
||||
if (frontsector->floorplane.ZatPoint(ViewPos) <= ViewPos.Z)
|
||||
{
|
||||
// process the original floor first.
|
||||
|
||||
|
@ -577,7 +577,7 @@ void GLFlat::ProcessSector(sector_t * frontsector)
|
|||
//
|
||||
//
|
||||
//
|
||||
if (frontsector->ceilingplane.ZatPoint(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy)) >= FIXED2FLOAT(viewz))
|
||||
if (frontsector->ceilingplane.ZatPoint(ViewPos) >= ViewPos.Z)
|
||||
{
|
||||
// process the original ceiling first.
|
||||
|
||||
|
@ -669,7 +669,7 @@ void GLFlat::ProcessSector(sector_t * frontsector)
|
|||
fixed_t ff_top=FLOAT2FIXED(rover->top.plane->ZatPoint(sector->centerspot));
|
||||
if (ff_top<lastceilingheight)
|
||||
{
|
||||
if (FIXED2FLOAT(viewz) <= rover->top.plane->ZatPoint(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy)))
|
||||
if (ViewPos.Z <= rover->top.plane->ZatPoint(ViewPos))
|
||||
{
|
||||
SetFrom3DFloor(rover, true, !!(rover->flags&FF_FOG));
|
||||
Colormap.FadeColor=frontsector->ColorMap->Fade;
|
||||
|
@ -683,7 +683,7 @@ void GLFlat::ProcessSector(sector_t * frontsector)
|
|||
fixed_t ff_bottom=FLOAT2FIXED(rover->bottom.plane->ZatPoint(sector->centerspot));
|
||||
if (ff_bottom<lastceilingheight)
|
||||
{
|
||||
if (FIXED2FLOAT(viewz)<=rover->bottom.plane->ZatPoint(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy)))
|
||||
if (ViewPos.Z <=rover->bottom.plane->ZatPoint(ViewPos))
|
||||
{
|
||||
SetFrom3DFloor(rover, false, !(rover->flags&FF_FOG));
|
||||
Colormap.FadeColor=frontsector->ColorMap->Fade;
|
||||
|
@ -709,7 +709,7 @@ void GLFlat::ProcessSector(sector_t * frontsector)
|
|||
fixed_t ff_bottom=FLOAT2FIXED(rover->bottom.plane->ZatPoint(sector->centerspot));
|
||||
if (ff_bottom>lastfloorheight || (rover->flags&FF_FIX))
|
||||
{
|
||||
if (FIXED2FLOAT(viewz) >= rover->bottom.plane->ZatPoint(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy)))
|
||||
if (ViewPos.Z >= rover->bottom.plane->ZatPoint(ViewPos))
|
||||
{
|
||||
SetFrom3DFloor(rover, false, !(rover->flags&FF_FOG));
|
||||
Colormap.FadeColor=frontsector->ColorMap->Fade;
|
||||
|
@ -730,7 +730,7 @@ void GLFlat::ProcessSector(sector_t * frontsector)
|
|||
fixed_t ff_top=FLOAT2FIXED(rover->top.plane->ZatPoint(sector->centerspot));
|
||||
if (ff_top>lastfloorheight)
|
||||
{
|
||||
if (FIXED2FLOAT(viewz) >= rover->top.plane->ZatPoint(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy)))
|
||||
if (ViewPos.Z >= rover->top.plane->ZatPoint(ViewPos))
|
||||
{
|
||||
SetFrom3DFloor(rover, true, !!(rover->flags&FF_FOG));
|
||||
Colormap.FadeColor=frontsector->ColorMap->Fade;
|
||||
|
|
|
@ -307,11 +307,9 @@ bool GLPortal::Start(bool usestencil, bool doquery)
|
|||
gl_RenderState.SetClipHeightTop(65536.f);
|
||||
|
||||
// save viewpoint
|
||||
savedviewx=viewx;
|
||||
savedviewy=viewy;
|
||||
savedviewz=viewz;
|
||||
savedViewPos = ViewPos;
|
||||
savedAngle = ViewAngle;
|
||||
savedviewactor=GLRenderer->mViewActor;
|
||||
savedviewangle=viewangle;
|
||||
savedviewarea=in_area;
|
||||
savedshowviewer = r_showviewer;
|
||||
|
||||
|
@ -324,7 +322,7 @@ bool GLPortal::Start(bool usestencil, bool doquery)
|
|||
|
||||
inline void GLPortal::ClearClipper()
|
||||
{
|
||||
fixed_t angleOffset = viewangle - savedviewangle;
|
||||
DAngle angleOffset = deltaangle(savedAngle, ViewAngle);
|
||||
|
||||
clipper.Clear();
|
||||
|
||||
|
@ -332,23 +330,20 @@ inline void GLPortal::ClearClipper()
|
|||
|
||||
// Set the clipper to the minimal visible area
|
||||
clipper.SafeAddClipRange(0,0xffffffff);
|
||||
for(unsigned int i=0;i<lines.Size();i++)
|
||||
for (unsigned int i = 0; i < lines.Size(); i++)
|
||||
{
|
||||
angle_t startAngle = R_PointToAnglePrecise(savedviewx, savedviewy,
|
||||
FLOAT2FIXED(lines[i].glseg.x2), FLOAT2FIXED(lines[i].glseg.y2));
|
||||
DAngle startAngle = (DVector2(lines[i].glseg.x2, lines[i].glseg.y2) - savedViewPos).Angle() + angleOffset;
|
||||
DAngle endAngle = (DVector2(lines[i].glseg.x1, lines[i].glseg.y1) - savedViewPos).Angle() + angleOffset;
|
||||
|
||||
angle_t endAngle = R_PointToAnglePrecise(savedviewx, savedviewy,
|
||||
FLOAT2FIXED(lines[i].glseg.x1), FLOAT2FIXED(lines[i].glseg.y1));
|
||||
|
||||
if (startAngle-endAngle>0)
|
||||
if (deltaangle(endAngle, startAngle) < 0)
|
||||
{
|
||||
clipper.SafeRemoveClipRangeRealAngles(startAngle + angleOffset, endAngle + angleOffset);
|
||||
clipper.SafeRemoveClipRangeRealAngles(startAngle.BAMs(), endAngle.BAMs());
|
||||
}
|
||||
}
|
||||
|
||||
// and finally clip it to the visible area
|
||||
angle_t a1 = GLRenderer->FrustumAngle();
|
||||
if (a1<ANGLE_180) clipper.SafeAddClipRangeRealAngles(viewangle+a1, viewangle-a1);
|
||||
if (a1 < ANGLE_180) clipper.SafeAddClipRangeRealAngles(ViewAngle.BAMs() + a1, ViewAngle.BAMs() - a1);
|
||||
|
||||
// lock the parts that have just been clipped out.
|
||||
clipper.SetSilhouette();
|
||||
|
@ -379,14 +374,12 @@ void GLPortal::End(bool usestencil)
|
|||
if (needdepth) FDrawInfo::EndDrawInfo();
|
||||
|
||||
// Restore the old view
|
||||
viewx=savedviewx;
|
||||
viewy=savedviewy;
|
||||
viewz=savedviewz;
|
||||
viewangle=savedviewangle;
|
||||
ViewPos = savedViewPos;
|
||||
ViewAngle = savedAngle;
|
||||
GLRenderer->mViewActor=savedviewactor;
|
||||
in_area=savedviewarea;
|
||||
r_showviewer = savedshowviewer;
|
||||
GLRenderer->SetupView(viewx, viewy, viewz, viewangle, !!(MirrorFlag & 1), !!(PlaneMirrorFlag & 1));
|
||||
GLRenderer->SetupView(ViewPos.X, ViewPos.Y, ViewPos.Z, ViewAngle, !!(MirrorFlag & 1), !!(PlaneMirrorFlag & 1));
|
||||
|
||||
{
|
||||
ScopedColorMask colorMask(0, 0, 0, 0); // glColorMask(0, 0, 0, 0); // no graphics
|
||||
|
@ -438,14 +431,12 @@ void GLPortal::End(bool usestencil)
|
|||
glDepthMask(true);
|
||||
}
|
||||
// Restore the old view
|
||||
viewx=savedviewx;
|
||||
viewy=savedviewy;
|
||||
viewz=savedviewz;
|
||||
viewangle=savedviewangle;
|
||||
ViewPos = savedViewPos;
|
||||
ViewAngle = savedAngle;
|
||||
GLRenderer->mViewActor=savedviewactor;
|
||||
in_area=savedviewarea;
|
||||
r_showviewer = savedshowviewer;
|
||||
GLRenderer->SetupView(viewx, viewy, viewz, viewangle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1));
|
||||
GLRenderer->SetupView(ViewPos.X, ViewPos.Y, ViewPos.Z, ViewAngle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1));
|
||||
|
||||
// This draws a valid z-buffer into the stencil's contents to ensure it
|
||||
// doesn't get overwritten by the level's geometry.
|
||||
|
@ -655,28 +646,24 @@ void GLSkyboxPortal::DrawContents()
|
|||
PlaneMirrorMode = 0;
|
||||
|
||||
bool oldclamp = gl_RenderState.SetDepthClamp(false);
|
||||
DVector3 viewpos = origin->InterpolatedPosition(r_TicFracF);
|
||||
viewangle += (origin->PrevAngles.Yaw + deltaangle(origin->PrevAngles.Yaw, origin->Angles.Yaw) * r_TicFracF).BAMs();
|
||||
ViewPos = origin->InterpolatedPosition(r_TicFracF);
|
||||
ViewAngle += (origin->PrevAngles.Yaw + deltaangle(origin->PrevAngles.Yaw, origin->Angles.Yaw) * r_TicFracF);
|
||||
|
||||
// Don't let the viewpoint be too close to a floor or ceiling
|
||||
double floorh = origin->Sector->floorplane.ZatPoint(origin->Pos());
|
||||
double ceilh = origin->Sector->ceilingplane.ZatPoint(origin->Pos());
|
||||
if (viewpos.Z < floorh + 4) viewpos.Z = floorh + 4;
|
||||
if (viewpos.Z > ceilh - 4) viewz = ceilh - 4;
|
||||
|
||||
viewx = FLOAT2FIXED(viewpos.X);
|
||||
viewy = FLOAT2FIXED(viewpos.Y);
|
||||
viewz = FLOAT2FIXED(viewpos.Z);
|
||||
if (ViewPos.Z < floorh + 4) ViewPos.Z = floorh + 4;
|
||||
if (ViewPos.Z > ceilh - 4) ViewPos.Z = ceilh - 4;
|
||||
|
||||
GLRenderer->mViewActor = origin;
|
||||
|
||||
validcount++;
|
||||
inskybox = true;
|
||||
GLRenderer->SetupView(viewx, viewy, viewz, viewangle, !!(MirrorFlag & 1), !!(PlaneMirrorFlag & 1));
|
||||
GLRenderer->SetupView(ViewPos.X, ViewPos.Y, ViewPos.Z, ViewAngle, !!(MirrorFlag & 1), !!(PlaneMirrorFlag & 1));
|
||||
GLRenderer->SetViewArea();
|
||||
ClearClipper();
|
||||
|
||||
int mapsection = R_PointInSubsector(viewx, viewy)->mapsection;
|
||||
int mapsection = R_PointInSubsector(ViewPos)->mapsection;
|
||||
|
||||
SaveMapSection();
|
||||
currentmapsection[mapsection >> 3] |= 1 << (mapsection & 7);
|
||||
|
@ -761,8 +748,7 @@ void GLSectorStackPortal::DrawContents()
|
|||
{
|
||||
FPortal *portal = origin;
|
||||
|
||||
viewx += origin->xDisplacement;
|
||||
viewy += origin->yDisplacement;
|
||||
ViewPos += origin->mDisplacement;
|
||||
GLRenderer->mViewActor = NULL;
|
||||
|
||||
|
||||
|
@ -771,7 +757,7 @@ void GLSectorStackPortal::DrawContents()
|
|||
// avoid recursions!
|
||||
if (origin->plane != -1) instack[origin->plane]++;
|
||||
|
||||
GLRenderer->SetupView(viewx, viewy, viewz, viewangle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1));
|
||||
GLRenderer->SetupView(ViewPos.X, ViewPos.Y, ViewPos.Z, ViewAngle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1));
|
||||
SaveMapSection();
|
||||
SetupCoverage();
|
||||
ClearClipper();
|
||||
|
@ -807,8 +793,8 @@ void GLPlaneMirrorPortal::DrawContents()
|
|||
|
||||
int old_pm=PlaneMirrorMode;
|
||||
|
||||
fixed_t planez = origin->ZatPoint(viewx, viewy);
|
||||
viewz = 2*planez - viewz;
|
||||
double planez = origin->ZatPoint(ViewPos);
|
||||
ViewPos.Z = 2 * planez - ViewPos.Z;
|
||||
GLRenderer->mViewActor = NULL;
|
||||
PlaneMirrorMode = origin->fC() < 0 ? -1 : 1;
|
||||
r_showviewer = true;
|
||||
|
@ -816,18 +802,17 @@ void GLPlaneMirrorPortal::DrawContents()
|
|||
validcount++;
|
||||
|
||||
PlaneMirrorFlag++;
|
||||
GLRenderer->SetupView(viewx, viewy, viewz, viewangle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1));
|
||||
GLRenderer->SetupView(ViewPos.X, ViewPos.Y, ViewPos.Z, ViewAngle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1));
|
||||
ClearClipper();
|
||||
|
||||
float f = FIXED2FLOAT(planez);
|
||||
if (PlaneMirrorMode < 0)
|
||||
{
|
||||
gl_RenderState.SetClipHeightTop(f); // ceiling mirror: clip everything with a z lower than the portal's ceiling
|
||||
gl_RenderState.SetClipHeightTop(planez); // ceiling mirror: clip everything with a z lower than the portal's ceiling
|
||||
gl_RenderState.SetClipHeightBottom(-65536.f);
|
||||
}
|
||||
else
|
||||
{
|
||||
gl_RenderState.SetClipHeightBottom(f); // floor mirror: clip everything with a z higher than the portal's floor
|
||||
gl_RenderState.SetClipHeightBottom(planez); // floor mirror: clip everything with a z higher than the portal's floor
|
||||
gl_RenderState.SetClipHeightTop(65536.f);
|
||||
}
|
||||
|
||||
|
@ -872,31 +857,30 @@ void GLMirrorPortal::DrawContents()
|
|||
}
|
||||
|
||||
GLRenderer->mCurrentPortal = this;
|
||||
angle_t startang = viewangle;
|
||||
fixed_t startx = viewx;
|
||||
fixed_t starty = viewy;
|
||||
DAngle StartAngle = ViewAngle;
|
||||
DVector3 StartPos = ViewPos;
|
||||
|
||||
vertex_t *v1 = linedef->v1;
|
||||
vertex_t *v2 = linedef->v2;
|
||||
|
||||
// Reflect the current view behind the mirror.
|
||||
if (linedef->Delta().X == 0)
|
||||
{
|
||||
{
|
||||
// vertical mirror
|
||||
viewx = v1->fixX() - startx + v1->fixX();
|
||||
ViewPos.X = 2 * v1->fX() - StartPos.X;
|
||||
|
||||
// Compensation for reendering inaccuracies
|
||||
if (startx<v1->fixX()) viewx -= FRACUNIT/2;
|
||||
else viewx += FRACUNIT/2;
|
||||
if (StartPos.X < v1->fX()) ViewPos.X -= 0.1;
|
||||
else ViewPos.X += 0.1;
|
||||
}
|
||||
else if (linedef->Delta().Y == 0)
|
||||
{
|
||||
// horizontal mirror
|
||||
viewy = v1->fixY() - starty + v1->fixY();
|
||||
ViewPos.Y = 2*v1->fY() - StartPos.Y;
|
||||
|
||||
// Compensation for reendering inaccuracies
|
||||
if (starty<v1->fixY()) viewy -= FRACUNIT/2;
|
||||
else viewy += FRACUNIT/2;
|
||||
if (StartPos.Y<v1->fY()) ViewPos.Y -= 0.1;
|
||||
else ViewPos.Y += 0.1;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -907,25 +891,23 @@ void GLMirrorPortal::DrawContents()
|
|||
double dy = v2->fY() - v1->fY();
|
||||
double x1 = v1->fX();
|
||||
double y1 = v1->fY();
|
||||
double x = FIXED2DBL(startx);
|
||||
double y = FIXED2DBL(starty);
|
||||
double x = StartPos.X;
|
||||
double y = StartPos.Y;
|
||||
|
||||
// the above two cases catch len == 0
|
||||
double r = ((x - x1)*dx + (y - y1)*dy) / (dx*dx + dy*dy);
|
||||
|
||||
viewx = FLOAT2FIXED((x1 + r * dx)*2 - x);
|
||||
viewy = FLOAT2FIXED((y1 + r * dy)*2 - y);
|
||||
ViewPos.X = (x1 + r * dx)*2 - x;
|
||||
ViewPos.Y = (y1 + r * dy)*2 - y;
|
||||
|
||||
// Compensation for reendering inaccuracies
|
||||
FVector2 v(-dx, dy);
|
||||
v.MakeUnit();
|
||||
|
||||
viewx+= FLOAT2FIXED(v[1] * renderdepth / 2);
|
||||
viewy+= FLOAT2FIXED(v[0] * renderdepth / 2);
|
||||
ViewPos.X+= v[1] * renderdepth / 2;
|
||||
ViewPos.Y+= v[0] * renderdepth / 2;
|
||||
}
|
||||
// we cannot afford any imprecisions caused by R_PointToAngle2 here. They'd be visible as seams around the mirror.
|
||||
viewangle = 2*R_PointToAnglePrecise (linedef->v1->fixX(), linedef->v1->fixY(),
|
||||
linedef->v2->fixX(), linedef->v2->fixY()) - startang;
|
||||
ViewAngle = linedef->Delta().Angle() * 2. - StartAngle;
|
||||
|
||||
GLRenderer->mViewActor = NULL;
|
||||
r_showviewer = true;
|
||||
|
@ -933,12 +915,12 @@ void GLMirrorPortal::DrawContents()
|
|||
validcount++;
|
||||
|
||||
MirrorFlag++;
|
||||
GLRenderer->SetupView(viewx, viewy, viewz, viewangle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1));
|
||||
GLRenderer->SetupView(ViewPos.X, ViewPos.Y, ViewPos.Z, ViewAngle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1));
|
||||
|
||||
clipper.Clear();
|
||||
|
||||
angle_t af = GLRenderer->FrustumAngle();
|
||||
if (af<ANGLE_180) clipper.SafeAddClipRangeRealAngles(viewangle+af, viewangle-af);
|
||||
if (af<ANGLE_180) clipper.SafeAddClipRangeRealAngles(ViewAngle.BAMs()+af, ViewAngle.BAMs()-af);
|
||||
|
||||
angle_t a2 = linedef->v1->GetClipAngle();
|
||||
angle_t a1 = linedef->v2->GetClipAngle();
|
||||
|
@ -952,7 +934,12 @@ void GLMirrorPortal::DrawContents()
|
|||
|
||||
int GLLinePortal::ClipSeg(seg_t *seg)
|
||||
{
|
||||
return PClip_Inside;// P_ClipLineToPortal(seg->linedef, line(), viewx, viewy) ? PClip_InFront : PClip_Inside;
|
||||
line_t *linedef = seg->linedef;
|
||||
if (!linedef)
|
||||
{
|
||||
return PClip_Inside; // should be handled properly.
|
||||
}
|
||||
return P_ClipLineToPortal(linedef, line(), ViewPos) ? PClip_InFront : PClip_Inside;
|
||||
}
|
||||
|
||||
int GLLinePortal::ClipSubsector(subsector_t *sub)
|
||||
|
@ -960,14 +947,14 @@ int GLLinePortal::ClipSubsector(subsector_t *sub)
|
|||
// this seg is completely behind the mirror!
|
||||
for(unsigned int i=0;i<sub->numlines;i++)
|
||||
{
|
||||
if (P_PointOnLineSidePrecise(sub->firstline[i].v1->fixX(), sub->firstline[i].v1->fixY(), line()) == 0) return PClip_Inside;
|
||||
if (P_PointOnLineSidePrecise(sub->firstline[i].v1->fPos(), line()) == 0) return PClip_Inside;
|
||||
}
|
||||
return PClip_InFront;
|
||||
}
|
||||
|
||||
int GLLinePortal::ClipPoint(fixed_t x, fixed_t y)
|
||||
int GLLinePortal::ClipPoint(const DVector2 &pos)
|
||||
{
|
||||
if (P_PointOnLineSidePrecise(x, y, line()))
|
||||
if (P_PointOnLineSidePrecise(pos, line()))
|
||||
{
|
||||
return PClip_InFront;
|
||||
}
|
||||
|
@ -1002,11 +989,9 @@ void GLLineToLinePortal::DrawContents()
|
|||
GLRenderer->mCurrentPortal = this;
|
||||
|
||||
line_t *origin = glport->reference->mOrigin;
|
||||
P_TranslatePortalXY(origin, viewx, viewy);
|
||||
DAngle va = ANGLE2DBL(viewangle);
|
||||
P_TranslatePortalAngle(origin, va);
|
||||
viewangle = va.BAMs();
|
||||
P_TranslatePortalZ(origin, viewz);
|
||||
P_TranslatePortalXY(origin, ViewPos.X, ViewPos.Y);
|
||||
P_TranslatePortalAngle(origin, ViewAngle);
|
||||
P_TranslatePortalZ(origin, ViewPos.Z);
|
||||
|
||||
SaveMapSection();
|
||||
|
||||
|
@ -1023,52 +1008,13 @@ void GLLineToLinePortal::DrawContents()
|
|||
|
||||
GLRenderer->mViewActor = NULL;
|
||||
validcount++;
|
||||
GLRenderer->SetupView(viewx, viewy, viewz, viewangle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1));
|
||||
GLRenderer->SetupView(ViewPos.X, ViewPos.Y, ViewPos.Z, ViewAngle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1));
|
||||
|
||||
ClearClipper();
|
||||
GLRenderer->DrawScene();
|
||||
RestoreMapSection();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
int GLLineToLinePortal::ClipSeg(seg_t *seg)
|
||||
{
|
||||
line_t *linedef = lines[0].seg->linedef->getPortalDestination();
|
||||
// this seg is completely behind the portal
|
||||
//we cannot use P_PointOnLineSide here because it loses the special meaning of 0 == 'on the line'.
|
||||
int side1 = DMulScale32(seg->v1->y - linedef->v1->y, linedef->dx, linedef->v1->x - seg->v1->x, linedef->dy);
|
||||
int side2 = DMulScale32(seg->v2->y - linedef->v1->y, linedef->dx, linedef->v1->x - seg->v2->x, linedef->dy);
|
||||
|
||||
if (side1 >= 0 && side2 >= 0)
|
||||
{
|
||||
return PClip_InFront;
|
||||
}
|
||||
return PClip_Inside;
|
||||
}
|
||||
|
||||
int GLLineToLinePortal::ClipSubsector(subsector_t *sub)
|
||||
{
|
||||
line_t *masterline = lines[0].seg->linedef->getPortalDestination();
|
||||
|
||||
for(unsigned int i=0;i<sub->numlines;i++)
|
||||
{
|
||||
if (P_PointOnLineSidePrecise(sub->firstline[i].v1->x, sub->firstline[i].v1->y, masterline) == 0) return PClip_Inside;
|
||||
}
|
||||
return PClip_InFront;
|
||||
}
|
||||
|
||||
int GLLineToLinePortal::ClipPoint(fixed_t x, fixed_t y)
|
||||
{
|
||||
line_t *masterline = lines[0].seg->linedef->getPortalDestination();
|
||||
if (P_PointOnLineSidePrecise(x, y, masterline))
|
||||
{
|
||||
return PClip_InFront;
|
||||
}
|
||||
return PClip_Inside;
|
||||
}
|
||||
*/
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
|
@ -1112,7 +1058,7 @@ void GLHorizonPortal::DrawContents()
|
|||
PortalAll.Unclock();
|
||||
return;
|
||||
}
|
||||
gl_RenderState.SetCameraPos(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy), FIXED2FLOAT(viewz));
|
||||
gl_RenderState.SetCameraPos(ViewPos.X, ViewPos.Y, ViewPos.Z);
|
||||
|
||||
|
||||
z=sp->Texheight;
|
||||
|
@ -1141,8 +1087,8 @@ void GLHorizonPortal::DrawContents()
|
|||
|
||||
|
||||
|
||||
float vx=FIXED2FLOAT(viewx);
|
||||
float vy=FIXED2FLOAT(viewy);
|
||||
float vx= ViewPos.X;
|
||||
float vy= ViewPos.Y;
|
||||
|
||||
// Draw to some far away boundary
|
||||
// This is not drawn as larher strips because it causes visual glitches.
|
||||
|
@ -1163,7 +1109,7 @@ void GLHorizonPortal::DrawContents()
|
|||
}
|
||||
}
|
||||
|
||||
float vz=FIXED2FLOAT(viewz);
|
||||
float vz= ViewPos.Z;
|
||||
float tz=(z-vz);///64.0f;
|
||||
|
||||
// fill the gap between the polygon and the true horizon
|
||||
|
@ -1238,7 +1184,7 @@ void GLEEHorizonPortal::DrawContents()
|
|||
horz.colormap = origin->Sector->ColorMap;
|
||||
if (origin->special1 == SKYBOX_PLANE)
|
||||
{
|
||||
horz.plane.Texheight = FIXED2FLOAT(viewz) + fabs(horz.plane.Texheight);
|
||||
horz.plane.Texheight = ViewPos.Z + fabs(horz.plane.Texheight);
|
||||
}
|
||||
GLHorizonPortal ceil(&horz, true);
|
||||
ceil.DrawContents();
|
||||
|
@ -1251,7 +1197,7 @@ void GLEEHorizonPortal::DrawContents()
|
|||
horz.colormap = origin->Sector->ColorMap;
|
||||
if (origin->special1 == SKYBOX_PLANE)
|
||||
{
|
||||
horz.plane.Texheight = FIXED2FLOAT(viewz) - fabs(horz.plane.Texheight);
|
||||
horz.plane.Texheight = ViewPos.Z - fabs(horz.plane.Texheight);
|
||||
}
|
||||
GLHorizonPortal floor(&horz, true);
|
||||
floor.DrawContents();
|
||||
|
|
|
@ -101,10 +101,8 @@ public:
|
|||
private:
|
||||
void DrawPortalStencil();
|
||||
|
||||
fixed_t savedviewx;
|
||||
fixed_t savedviewy;
|
||||
fixed_t savedviewz;
|
||||
angle_t savedviewangle;
|
||||
DVector3 savedViewPos;
|
||||
DAngle savedAngle;
|
||||
AActor * savedviewactor;
|
||||
area_t savedviewarea;
|
||||
bool savedshowviewer;
|
||||
|
@ -165,7 +163,7 @@ public:
|
|||
|
||||
virtual int ClipSeg(seg_t *seg) { return PClip_Inside; }
|
||||
virtual int ClipSubsector(subsector_t *sub) { return PClip_Inside; }
|
||||
virtual int ClipPoint(fixed_t x, fixed_t y) { return PClip_Inside; }
|
||||
virtual int ClipPoint(const DVector2 &pos) { return PClip_Inside; }
|
||||
|
||||
static void BeginScene();
|
||||
static void StartFrame();
|
||||
|
@ -186,8 +184,7 @@ struct GLLinePortal : public GLPortal
|
|||
{
|
||||
v1 = line->v1;
|
||||
v2 = line->v2;
|
||||
dx = FLOAT2FIXED(line->Delta().X);
|
||||
dy = FLOAT2FIXED(line->Delta().Y);
|
||||
CalcDelta();
|
||||
}
|
||||
|
||||
GLLinePortal(FGLLinePortal *line)
|
||||
|
@ -198,17 +195,21 @@ struct GLLinePortal : public GLPortal
|
|||
line_t *lline = line->reference->mDestination;
|
||||
v1 = lline->v1;
|
||||
v2 = lline->v2;
|
||||
dx = FLOAT2FIXED(lline->Delta().X);
|
||||
dy = FLOAT2FIXED(lline->Delta().Y);
|
||||
}
|
||||
else
|
||||
{
|
||||
// For linked portals we can check the merged span.
|
||||
v1 = line->v1;
|
||||
v2 = line->v2;
|
||||
dx = line->dx;
|
||||
dy = line->dy;
|
||||
}
|
||||
CalcDelta();
|
||||
}
|
||||
|
||||
void CalcDelta()
|
||||
{
|
||||
DVector2 delta = v2->fPos() - v1->fPos();
|
||||
dx = FLOAT2FIXED(delta.X);
|
||||
dy = FLOAT2FIXED(delta.Y);
|
||||
}
|
||||
|
||||
line_t *line()
|
||||
|
@ -219,7 +220,7 @@ struct GLLinePortal : public GLPortal
|
|||
|
||||
virtual int ClipSeg(seg_t *seg);
|
||||
virtual int ClipSubsector(subsector_t *sub);
|
||||
virtual int ClipPoint(fixed_t x, fixed_t y);
|
||||
virtual int ClipPoint(const DVector2 &pos);
|
||||
virtual bool NeedCap() { return false; }
|
||||
};
|
||||
|
||||
|
|
|
@ -506,7 +506,7 @@ void FDrawInfo::HandleMissingTextures()
|
|||
HandledSubsectors.Clear();
|
||||
validcount++;
|
||||
|
||||
if (MissingUpperTextures[i].planez > viewz)
|
||||
if (MissingUpperTextures[i].planez > FLOAT2FIXED(ViewPos.Z))
|
||||
{
|
||||
// close the hole only if all neighboring sectors are an exact height match
|
||||
// Otherwise just fill in the missing textures.
|
||||
|
@ -578,7 +578,7 @@ void FDrawInfo::HandleMissingTextures()
|
|||
HandledSubsectors.Clear();
|
||||
validcount++;
|
||||
|
||||
if (MissingLowerTextures[i].planez < viewz)
|
||||
if (MissingLowerTextures[i].planez < FLOAT2FIXED(ViewPos.Z))
|
||||
{
|
||||
// close the hole only if all neighboring sectors are an exact height match
|
||||
// Otherwise just fill in the missing textures.
|
||||
|
@ -668,7 +668,7 @@ void FDrawInfo::DrawUnhandledMissingTextures()
|
|||
// already done!
|
||||
if (seg->linedef->validcount==validcount) continue; // already done
|
||||
seg->linedef->validcount=validcount;
|
||||
if (seg->frontsector->GetPlaneTexZ(sector_t::ceiling) < viewz) continue; // out of sight
|
||||
if (seg->frontsector->GetPlaneTexZF(sector_t::ceiling) < ViewPos.Z) continue; // out of sight
|
||||
//if (seg->frontsector->ceilingpic==skyflatnum) continue;
|
||||
|
||||
// FIXME: The check for degenerate subsectors should be more precise
|
||||
|
@ -692,7 +692,7 @@ void FDrawInfo::DrawUnhandledMissingTextures()
|
|||
if (seg->linedef->validcount==validcount) continue; // already done
|
||||
seg->linedef->validcount=validcount;
|
||||
if (!(sectorrenderflags[seg->backsector->sectornum] & SSRF_RENDERFLOOR)) continue;
|
||||
if (seg->frontsector->GetPlaneTexZ(sector_t::floor) > viewz) continue; // out of sight
|
||||
if (seg->frontsector->GetPlaneTexZF(sector_t::floor) > ViewPos.Z) continue; // out of sight
|
||||
if (seg->backsector->transdoor) continue;
|
||||
if (seg->backsector->GetTexture(sector_t::floor)==skyflatnum) continue;
|
||||
if (seg->backsector->portals[sector_t::floor] != NULL) continue;
|
||||
|
@ -793,17 +793,17 @@ bool FDrawInfo::CollectSubsectorsFloor(subsector_t * sub, sector_t * anchor)
|
|||
// We must collect any subsector that either is connected to this one with a miniseg
|
||||
// or has the same visplane.
|
||||
// We must not collect any subsector that has the anchor's visplane!
|
||||
if (!(sub->flags & SSECF_DEGENERATE))
|
||||
if (!(sub->flags & SSECF_DEGENERATE))
|
||||
{
|
||||
// Is not being rendered so don't bother.
|
||||
if (!(ss_renderflags[DWORD(sub-subsectors)]&SSRF_PROCESSED)) return true;
|
||||
if (!(ss_renderflags[DWORD(sub - subsectors)] & SSRF_PROCESSED)) return true;
|
||||
|
||||
if (sub->render_sector->GetTexture(sector_t::floor) != anchor->GetTexture(sector_t::floor) ||
|
||||
sub->render_sector->GetPlaneTexZ(sector_t::floor)!=anchor->GetPlaneTexZ(sector_t::floor) ||
|
||||
sub->render_sector->GetFloorLight() != anchor->GetFloorLight())
|
||||
sub->render_sector->GetPlaneTexZF(sector_t::floor) != anchor->GetPlaneTexZF(sector_t::floor) ||
|
||||
sub->render_sector->GetFloorLight() != anchor->GetFloorLight())
|
||||
{
|
||||
if (sub==viewsubsector && viewz<anchor->GetPlaneTexZ(sector_t::floor)) inview=true;
|
||||
HandledSubsectors.Push (sub);
|
||||
if (sub == viewsubsector && ViewPos.Z < anchor->GetPlaneTexZF(sector_t::floor)) inview = true;
|
||||
HandledSubsectors.Push(sub);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -952,7 +952,7 @@ void FDrawInfo::HandleHackedSubsectors()
|
|||
totalssms.Reset();
|
||||
totalssms.Clock();
|
||||
|
||||
viewsubsector = R_PointInSubsector(viewx, viewy);
|
||||
viewsubsector = R_PointInSubsector(ViewPos);
|
||||
|
||||
// Each subsector may only be processed once in this loop!
|
||||
validcount++;
|
||||
|
|
|
@ -131,18 +131,18 @@ angle_t FGLRenderer::FrustumAngle()
|
|||
void FGLRenderer::SetViewArea()
|
||||
{
|
||||
// The render_sector is better suited to represent the current position in GL
|
||||
viewsector = R_PointInSubsector(viewx, viewy)->render_sector;
|
||||
viewsector = R_PointInSubsector(ViewPos)->render_sector;
|
||||
|
||||
// Get the heightsec state from the render sector, not the current one!
|
||||
if (viewsector->heightsec && !(viewsector->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC))
|
||||
{
|
||||
in_area = viewz<=viewsector->heightsec->floorplane.ZatPoint(viewx,viewy) ? area_below :
|
||||
(viewz>viewsector->heightsec->ceilingplane.ZatPoint(viewx,viewy) &&
|
||||
!(viewsector->heightsec->MoreFlags&SECF_FAKEFLOORONLY)) ? area_above:area_normal;
|
||||
in_area = ViewPos.Z <= viewsector->heightsec->floorplane.ZatPoint(ViewPos) ? area_below :
|
||||
(ViewPos.Z > viewsector->heightsec->ceilingplane.ZatPoint(ViewPos) &&
|
||||
!(viewsector->heightsec->MoreFlags&SECF_FAKEFLOORONLY)) ? area_above : area_normal;
|
||||
}
|
||||
else
|
||||
{
|
||||
in_area=area_default; // depends on exposed lower sectors
|
||||
in_area = area_default; // depends on exposed lower sectors
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -218,12 +218,12 @@ void FGLRenderer::SetViewport(GL_IRECT *bounds)
|
|||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void FGLRenderer::SetViewAngle(angle_t viewangle)
|
||||
void FGLRenderer::SetViewAngle(DAngle viewangle)
|
||||
{
|
||||
float fviewangle=(float)(viewangle>>ANGLETOFINESHIFT)*360.0f/FINEANGLES;
|
||||
|
||||
mAngles.Yaw = 270.0f-fviewangle;
|
||||
mViewVector = FVector2(cos(DEG2RAD(fviewangle)), sin(DEG2RAD(fviewangle)));
|
||||
mAngles.Yaw = float(270.0-viewangle.Degrees);
|
||||
DVector2 v = ViewAngle.ToVector();
|
||||
mViewVector.X = v.X;
|
||||
mViewVector.Y = v.Y;
|
||||
|
||||
R_SetViewAngle();
|
||||
}
|
||||
|
@ -258,7 +258,7 @@ void FGLRenderer::SetProjection(VSMatrix matrix)
|
|||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void FGLRenderer::SetViewMatrix(fixed_t viewx, fixed_t viewy, fixed_t viewz, bool mirror, bool planemirror)
|
||||
void FGLRenderer::SetViewMatrix(float vx, float vy, float vz, bool mirror, bool planemirror)
|
||||
{
|
||||
float mult = mirror? -1:1;
|
||||
float planemult = planemirror? -glset.pixelstretch : glset.pixelstretch;
|
||||
|
@ -267,7 +267,7 @@ void FGLRenderer::SetViewMatrix(fixed_t viewx, fixed_t viewy, fixed_t viewz, boo
|
|||
gl_RenderState.mViewMatrix.rotate(GLRenderer->mAngles.Roll.Degrees, 0.0f, 0.0f, 1.0f);
|
||||
gl_RenderState.mViewMatrix.rotate(GLRenderer->mAngles.Pitch.Degrees, 1.0f, 0.0f, 0.0f);
|
||||
gl_RenderState.mViewMatrix.rotate(GLRenderer->mAngles.Yaw.Degrees, 0.0f, mult, 0.0f);
|
||||
gl_RenderState.mViewMatrix.translate(FIXED2FLOAT(viewx) * mult, -FIXED2FLOAT(viewz) * planemult , -FIXED2FLOAT(viewy));
|
||||
gl_RenderState.mViewMatrix.translate(vx * mult, -vz * planemult , -vy);
|
||||
gl_RenderState.mViewMatrix.scale(-mult, planemult, 1);
|
||||
}
|
||||
|
||||
|
@ -278,10 +278,10 @@ void FGLRenderer::SetViewMatrix(fixed_t viewx, fixed_t viewy, fixed_t viewz, boo
|
|||
// Setup the view rotation matrix for the given viewpoint
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
void FGLRenderer::SetupView(fixed_t viewx, fixed_t viewy, fixed_t viewz, angle_t viewangle, bool mirror, bool planemirror)
|
||||
void FGLRenderer::SetupView(float vx, float vy, float vz, DAngle va, bool mirror, bool planemirror)
|
||||
{
|
||||
SetViewAngle(viewangle);
|
||||
SetViewMatrix(viewx, viewy, viewz, mirror, planemirror);
|
||||
SetViewAngle(va);
|
||||
SetViewMatrix(vx, vy, vz, mirror, planemirror);
|
||||
gl_RenderState.ApplyMatrices();
|
||||
}
|
||||
|
||||
|
@ -305,6 +305,7 @@ void FGLRenderer::CreateScene()
|
|||
for(unsigned i=0;i<portals.Size(); i++) portals[i]->glportal = NULL;
|
||||
gl_spriteindex=0;
|
||||
Bsp.Clock();
|
||||
R_SetView();
|
||||
gl_RenderBSPNode (nodes + numnodes - 1);
|
||||
Bsp.Unclock();
|
||||
|
||||
|
@ -333,7 +334,7 @@ void FGLRenderer::RenderScene(int recursion)
|
|||
glDepthMask(true);
|
||||
if (!gl_no_skyclear) GLPortal::RenderFirstSkyPortal(recursion);
|
||||
|
||||
gl_RenderState.SetCameraPos(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy), FIXED2FLOAT(viewz));
|
||||
gl_RenderState.SetCameraPos(ViewPos.X, ViewPos.Y, ViewPos.Z);
|
||||
|
||||
gl_RenderState.EnableFog(true);
|
||||
gl_RenderState.BlendFunc(GL_ONE,GL_ZERO);
|
||||
|
@ -455,7 +456,7 @@ void FGLRenderer::RenderTranslucent()
|
|||
RenderAll.Clock();
|
||||
|
||||
glDepthMask(false);
|
||||
gl_RenderState.SetCameraPos(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy), FIXED2FLOAT(viewz));
|
||||
gl_RenderState.SetCameraPos(ViewPos.X, ViewPos.Y, ViewPos.Z);
|
||||
|
||||
// final pass: translucent stuff
|
||||
gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_sprite_threshold);
|
||||
|
@ -567,13 +568,13 @@ void FGLRenderer::DrawBlend(sector_t * viewsector)
|
|||
|
||||
for (unsigned int i = 0; i < lightlist.Size(); i++)
|
||||
{
|
||||
fixed_t lightbottom;
|
||||
double lightbottom;
|
||||
if (i < lightlist.Size() - 1)
|
||||
lightbottom = lightlist[i + 1].plane.ZatPoint(viewx, viewy);
|
||||
lightbottom = lightlist[i + 1].plane.ZatPoint(ViewPos);
|
||||
else
|
||||
lightbottom = viewsector->floorplane.ZatPoint(viewx, viewy);
|
||||
lightbottom = viewsector->floorplane.ZatPoint(ViewPos);
|
||||
|
||||
if (lightbottom < viewz && (!lightlist[i].caster || !(lightlist[i].caster->flags&FF_FADEWALLS)))
|
||||
if (lightbottom < ViewPos.Z && (!lightlist[i].caster || !(lightlist[i].caster->flags&FF_FADEWALLS)))
|
||||
{
|
||||
// 3d floor 'fog' is rendered as a blending value
|
||||
blendv = lightlist[i].blend;
|
||||
|
@ -706,7 +707,7 @@ void FGLRenderer::ProcessScene(bool toscreen)
|
|||
iter_dlightf = iter_dlight = draw_dlight = draw_dlightf = 0;
|
||||
GLPortal::BeginScene();
|
||||
|
||||
int mapsection = R_PointInSubsector(viewx, viewy)->mapsection;
|
||||
int mapsection = R_PointInSubsector(ViewPos)->mapsection;
|
||||
memset(¤tmapsection[0], 0, currentmapsection.Size());
|
||||
currentmapsection[mapsection>>3] |= 1 << (mapsection & 7);
|
||||
DrawScene(toscreen);
|
||||
|
@ -771,10 +772,7 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo
|
|||
SetViewArea();
|
||||
|
||||
// We have to scale the pitch to account for the pixel stretching, because the playsim doesn't know about this and treats it as 1:1.
|
||||
double radPitch = (viewpitch)* M_PI / 0x80000000;
|
||||
if (radPitch > PI) radPitch -= 2 * PI;
|
||||
radPitch = clamp(radPitch, -PI / 2, PI / 2);
|
||||
|
||||
double radPitch = clamp(ViewPitch.Normalized180().Radians(), -PI / 2, PI / 2);
|
||||
double angx = cos(radPitch);
|
||||
double angy = sin(radPitch) * glset.pixelstretch;
|
||||
double alen = sqrt(angx*angx + angy*angy);
|
||||
|
@ -815,16 +813,16 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo
|
|||
// Stereo mode specific perspective projection
|
||||
SetProjection( eye->GetProjection(fov, ratio, fovratio) );
|
||||
// SetProjection(fov, ratio, fovratio); // switch to perspective mode and set up clipper
|
||||
SetViewAngle(viewangle);
|
||||
SetViewAngle(ViewAngle);
|
||||
// Stereo mode specific viewpoint adjustment - temporarily shifts global viewx, viewy, viewz
|
||||
eye->GetViewShift(GLRenderer->mAngles.Yaw.Degrees, viewShift);
|
||||
s3d::ScopedViewShifter viewShifter(viewShift);
|
||||
SetViewMatrix(viewx, viewy, viewz, false, false);
|
||||
SetViewMatrix(ViewPos.X, ViewPos.Y, ViewPos.Z, false, false);
|
||||
gl_RenderState.ApplyMatrices();
|
||||
|
||||
clipper.Clear();
|
||||
angle_t a1 = FrustumAngle();
|
||||
clipper.SafeAddClipRangeRealAngles(viewangle + a1, viewangle - a1);
|
||||
clipper.SafeAddClipRangeRealAngles(ViewAngle.BAMs() + a1, ViewAngle.BAMs() - a1);
|
||||
|
||||
ProcessScene(toscreen);
|
||||
if (mainview) EndDrawScene(retval); // do not call this for camera textures.
|
||||
|
|
|
@ -173,8 +173,8 @@ void GLWall::SkyPlane(sector_t *sector, int plane, bool allowreflect)
|
|||
}
|
||||
else if (allowreflect && sector->GetReflect(plane) > 0)
|
||||
{
|
||||
if ((plane == sector_t::ceiling && FIXED2DBL(viewz) > sector->ceilingplane.fD()) ||
|
||||
(plane == sector_t::floor && FIXED2DBL(viewz) < -sector->floorplane.fD())) return;
|
||||
if ((plane == sector_t::ceiling && ViewPos.Z > sector->ceilingplane.fD()) ||
|
||||
(plane == sector_t::floor && ViewPos.Z < -sector->floorplane.fD())) return;
|
||||
ptype = PORTALTYPE_PLANEMIRROR;
|
||||
planemirror = plane == sector_t::ceiling ? §or->ceilingplane : §or->floorplane;
|
||||
}
|
||||
|
@ -361,7 +361,7 @@ void GLWall::SkyBottom(seg_t * seg,sector_t * fs,sector_t * bs,vertex_t * v1,ver
|
|||
else
|
||||
{
|
||||
// Special hack for Vrack2b
|
||||
if (bs->floorplane.ZatPoint(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy)) > FIXED2FLOAT(viewz)) return;
|
||||
if (bs->floorplane.ZatPoint(ViewPos) > ViewPos.Z) return;
|
||||
}
|
||||
}
|
||||
zbottom[0]=zbottom[1]=-32768.0f;
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include "sc_man.h"
|
||||
#include "w_wad.h"
|
||||
#include "r_state.h"
|
||||
#include "r_utility.h"
|
||||
//#include "gl/gl_intern.h"
|
||||
|
||||
#include "gl/system/gl_interface.h"
|
||||
|
@ -492,7 +493,7 @@ void GLSkyPortal::DrawContents()
|
|||
bool oldClamp = gl_RenderState.SetDepthClamp(true);
|
||||
|
||||
gl_MatrixStack.Push(gl_RenderState.mViewMatrix);
|
||||
GLRenderer->SetupView(0, 0, 0, viewangle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1));
|
||||
GLRenderer->SetupView(0, 0, 0, ViewAngle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1));
|
||||
|
||||
if (origin->texture[0] && origin->texture[0]->tex->gl_info.bSkybox)
|
||||
{
|
||||
|
|
|
@ -154,10 +154,7 @@ void GLSprite::Draw(int pass)
|
|||
// fog + fuzz don't work well without some fiddling with the alpha value!
|
||||
if (!gl_isBlack(Colormap.FadeColor))
|
||||
{
|
||||
float xcamera=FIXED2FLOAT(viewx);
|
||||
float ycamera=FIXED2FLOAT(viewy);
|
||||
|
||||
float dist=Dist2(xcamera,ycamera, x,y);
|
||||
float dist=Dist2(ViewPos.X, ViewPos.Y, x,y);
|
||||
|
||||
if (!Colormap.FadeColor.a) Colormap.FadeColor.a=clamp<int>(255-lightlevel,60,255);
|
||||
|
||||
|
@ -397,8 +394,8 @@ void GLSprite::PerformSpriteClipAdjustment(AActor *thing, fixed_t thingx, fixed_
|
|||
for (unsigned int i = 0; i < x.ffloors.Size(); i++)
|
||||
{
|
||||
F3DFloor * ff = x.ffloors[i];
|
||||
float floorh = FIXED2FLOAT(ff->top.plane->ZatPoint(thingx, thingy));
|
||||
float ceilingh = FIXED2FLOAT(ff->bottom.plane->ZatPoint(thingx, thingy));
|
||||
float floorh = FIXED2FLOAT(ff->top.plane->ZatPointFixed(thingx, thingy));
|
||||
float ceilingh = FIXED2FLOAT(ff->bottom.plane->ZatPointFixed(thingx, thingy));
|
||||
if (floorh == thing->floorz)
|
||||
{
|
||||
btm = floorh;
|
||||
|
@ -416,7 +413,7 @@ void GLSprite::PerformSpriteClipAdjustment(AActor *thing, fixed_t thingx, fixed_
|
|||
else if (thing->Sector->heightsec && !(thing->Sector->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC))
|
||||
{
|
||||
if (thing->flags2&MF2_ONMOBJ && thing->floorz ==
|
||||
FIXED2FLOAT(thing->Sector->heightsec->floorplane.ZatPoint(thingx, thingy)))
|
||||
FIXED2FLOAT(thing->Sector->heightsec->floorplane.ZatPointFixed(thingx, thingy)))
|
||||
{
|
||||
btm = thing->floorz;
|
||||
top = thing->ceilingz;
|
||||
|
@ -425,7 +422,7 @@ void GLSprite::PerformSpriteClipAdjustment(AActor *thing, fixed_t thingx, fixed_
|
|||
if (btm == 1000000.0f)
|
||||
btm = thing->Sector->floorplane.ZatPoint(thing) - thing->Floorclip;
|
||||
if (top == -1000000.0f)
|
||||
top = FIXED2FLOAT(thing->Sector->ceilingplane.ZatPoint(thingx, thingy));
|
||||
top = FIXED2FLOAT(thing->Sector->ceilingplane.ZatPointFixed(thingx, thingy));
|
||||
|
||||
// +/-1 to account for the one pixel empty frame around the sprite.
|
||||
float diffb = (z2+1) - btm;
|
||||
|
@ -512,9 +509,9 @@ void GLSprite::Process(AActor* thing,sector_t * sector)
|
|||
DVector3 thingpos = thing->InterpolatedPosition(r_TicFracF);
|
||||
|
||||
// Too close to the camera. This doesn't look good if it is a sprite.
|
||||
if (fabs(thingpos.X - FIXED2DBL(viewx) < 2 && fabs(thingpos.Y - FIXED2DBL(viewy) < 2)))
|
||||
if (fabs(thingpos.X - ViewPos.X) < 2 && fabs(thingpos.Y - ViewPos.Y) < 2)
|
||||
{
|
||||
if (FIXED2DBL(viewz) >= thingpos.Z - 2 && FIXED2DBL(viewz) <= thingpos.Z + thing->Height + 2)
|
||||
if (ViewPos.Z >= thingpos.Z - 2 && ViewPos.Z <= thingpos.Z + thing->Height + 2)
|
||||
{
|
||||
// exclude vertically moving objects from this check.
|
||||
if (!thing->Vel.isZero())
|
||||
|
@ -533,14 +530,14 @@ void GLSprite::Process(AActor* thing,sector_t * sector)
|
|||
if (!(thing->flags7 & MF7_FLYCHEAT) && thing->target==GLRenderer->mViewActor && GLRenderer->mViewActor != NULL)
|
||||
{
|
||||
double clipdist = clamp(thing->Speed, thing->target->radius, thing->target->radius*2);
|
||||
if (P_AproxDistance(thingpos.X-viewx, thingpos.Y-viewy) < clipdist) return;
|
||||
if ((thingpos-ViewPos).LengthSquared() < clipdist * clipdist) return;
|
||||
}
|
||||
thing->flags7 |= MF7_FLYCHEAT; // do this only once for the very first frame, but not if it gets into range again.
|
||||
}
|
||||
|
||||
if (GLRenderer->mCurrentPortal)
|
||||
{
|
||||
int clipres = GLRenderer->mCurrentPortal->ClipPoint(FLOAT2FIXED(thingpos.X), FLOAT2FIXED(thingpos.Y));
|
||||
int clipres = GLRenderer->mCurrentPortal->ClipPoint(thingpos);
|
||||
if (clipres == GLPortal::PClip_InFront) return;
|
||||
}
|
||||
|
||||
|
@ -571,10 +568,9 @@ void GLSprite::Process(AActor* thing,sector_t * sector)
|
|||
modelframe = gl_FindModelFrame(thing->GetClass(), spritenum, thing->frame, !!(thing->flags & MF_DROPPED));
|
||||
if (!modelframe)
|
||||
{
|
||||
angle_t ang = R_PointToAngle(FLOAT2FIXED(thingpos.X), FLOAT2FIXED(thingpos.Y));
|
||||
|
||||
bool mirror;
|
||||
FTextureID patch = gl_GetSpriteFrame(spritenum, thing->frame, -1, ang - thing->Angles.Yaw.BAMs(), &mirror);
|
||||
DAngle ang = (thingpos - ViewPos).Angle();
|
||||
FTextureID patch = gl_GetSpriteFrame(spritenum, thing->frame, -1, (ang - thing->Angles.Yaw).BAMs(), &mirror);
|
||||
if (!patch.isValid()) return;
|
||||
int type = thing->renderflags & RF_SPRITETYPEMASK;
|
||||
gltexture = FMaterial::ValidateTexture(patch, (type == RF_FACESPRITE), false);
|
||||
|
@ -644,7 +640,7 @@ void GLSprite::Process(AActor* thing,sector_t * sector)
|
|||
gltexture=NULL;
|
||||
}
|
||||
|
||||
depth = DMulScale20 (FLOAT2FIXED(thingpos.X)-viewx, viewtancos, FLOAT2FIXED(thingpos.Y)-viewy, viewtansin);
|
||||
depth = (int)((x - ViewPos.X) * viewtancos + (y - ViewPos.Y) * viewtansin);
|
||||
|
||||
// light calculation
|
||||
|
||||
|
@ -841,7 +837,7 @@ void GLSprite::ProcessParticle (particle_t *particle, sector_t *sector)//, int s
|
|||
{
|
||||
if (GLRenderer->mCurrentPortal)
|
||||
{
|
||||
int clipres = GLRenderer->mCurrentPortal->ClipPoint(particle->x, particle->y);
|
||||
int clipres = GLRenderer->mCurrentPortal->ClipPoint(particle->Pos);
|
||||
if (clipres == GLPortal::PClip_InFront) return;
|
||||
}
|
||||
|
||||
|
@ -860,15 +856,15 @@ void GLSprite::ProcessParticle (particle_t *particle, sector_t *sector)//, int s
|
|||
else if (!particle->bright)
|
||||
{
|
||||
TArray<lightlist_t> & lightlist=sector->e->XFloor.lightlist;
|
||||
int lightbottom;
|
||||
double lightbottom;
|
||||
|
||||
Colormap = sector->ColorMap;
|
||||
for(unsigned int i=0;i<lightlist.Size();i++)
|
||||
{
|
||||
if (i<lightlist.Size()-1) lightbottom = lightlist[i+1].plane.ZatPoint(particle->x,particle->y);
|
||||
else lightbottom = sector->floorplane.ZatPoint(particle->x,particle->y);
|
||||
if (i<lightlist.Size()-1) lightbottom = lightlist[i+1].plane.ZatPoint(particle->Pos);
|
||||
else lightbottom = sector->floorplane.ZatPoint(particle->Pos);
|
||||
|
||||
if (lightbottom < particle->y)
|
||||
if (lightbottom < particle->Pos.Z)
|
||||
{
|
||||
lightlevel = *lightlist[i].p_lightlevel;
|
||||
Colormap.LightColor = (lightlist[i].extra_colormap)->Color;
|
||||
|
@ -920,9 +916,9 @@ void GLSprite::ProcessParticle (particle_t *particle, sector_t *sector)//, int s
|
|||
}
|
||||
}
|
||||
|
||||
x= FIXED2FLOAT(particle->x);
|
||||
y= FIXED2FLOAT(particle->y);
|
||||
z= FIXED2FLOAT(particle->z);
|
||||
x = particle->Pos.X;
|
||||
y = particle->Pos.Y;
|
||||
z = particle->Pos.Z;
|
||||
|
||||
float scalefac=particle->size/4.0f;
|
||||
// [BB] The smooth particles are smaller than the other ones. Compensate for this here.
|
||||
|
@ -939,7 +935,7 @@ void GLSprite::ProcessParticle (particle_t *particle, sector_t *sector)//, int s
|
|||
z1=z-scalefac;
|
||||
z2=z+scalefac;
|
||||
|
||||
depth = DMulScale20 (particle->x-viewx, viewtancos, particle->y-viewy, viewtansin);
|
||||
depth = (int)((x - ViewPos.X) * viewtancos + (y - ViewPos.Y) * viewtansin);
|
||||
|
||||
actor=NULL;
|
||||
this->particle=particle;
|
||||
|
|
|
@ -142,6 +142,6 @@ void gl_SetDynSpriteLight(AActor *thing, particle_t *particle)
|
|||
}
|
||||
else if (particle != NULL)
|
||||
{
|
||||
gl_SetDynSpriteLight(NULL, FIXED2FLOAT(particle->x), FIXED2FLOAT(particle->y), FIXED2FLOAT(particle->z), particle->subsector);
|
||||
gl_SetDynSpriteLight(NULL, particle->Pos.X, particle->Pos.Y, particle->Pos.Z, particle->subsector);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -128,7 +128,7 @@ public:
|
|||
FColormap Colormap;
|
||||
ERenderStyle RenderStyle;
|
||||
|
||||
fixed_t viewdistance;
|
||||
float ViewDistance;
|
||||
|
||||
TArray<lightlist_t> *lightlist;
|
||||
int lightlevel;
|
||||
|
|
|
@ -134,8 +134,7 @@ void GLWall::PutWall(bool translucent)
|
|||
|
||||
if (translucent) // translucent walls
|
||||
{
|
||||
viewdistance = P_AproxDistance(((seg->linedef->v1->fX() + seg->linedef->v2->fX()) /2) - viewx,
|
||||
((seg->linedef->v1->fY() + seg->linedef->v2->fY()) /2) - viewy);
|
||||
ViewDistance = (ViewPos - (seg->linedef->v1->fPos() + seg->linedef->Delta() / 2)).XY().LengthSquared();
|
||||
gl_drawinfo->drawlists[GLDL_TRANSLUCENT].AddWall(this);
|
||||
}
|
||||
else
|
||||
|
@ -370,13 +369,13 @@ bool GLWall::DoHorizon(seg_t * seg,sector_t * fs, vertex_t * v1,vertex_t * v2)
|
|||
lightlist_t * light;
|
||||
|
||||
// ZDoom doesn't support slopes in a horizon sector so I won't either!
|
||||
ztop[1] = ztop[0] = FIXED2FLOAT(fs->GetPlaneTexZ(sector_t::ceiling));
|
||||
zbottom[1] = zbottom[0] = FIXED2FLOAT(fs->GetPlaneTexZ(sector_t::floor));
|
||||
ztop[1] = ztop[0] = fs->GetPlaneTexZF(sector_t::ceiling);
|
||||
zbottom[1] = zbottom[0] = fs->GetPlaneTexZF(sector_t::floor);
|
||||
|
||||
if (viewz < fs->GetPlaneTexZ(sector_t::ceiling))
|
||||
if (ViewPos.Z < fs->GetPlaneTexZF(sector_t::ceiling))
|
||||
{
|
||||
if (viewz > fs->GetPlaneTexZ(sector_t::floor))
|
||||
zbottom[1] = zbottom[0] = FIXED2FLOAT(viewz);
|
||||
if (ViewPos.Z > fs->GetPlaneTexZF(sector_t::floor))
|
||||
zbottom[1] = zbottom[0] = ViewPos.Z;
|
||||
|
||||
if (fs->GetTexture(sector_t::ceiling) == skyflatnum)
|
||||
{
|
||||
|
@ -1105,8 +1104,8 @@ __forceinline void GLWall::GetPlanePos(F3DFloor::planeref *planeref, fixed_t &le
|
|||
{
|
||||
if (planeref->plane->isSlope())
|
||||
{
|
||||
left=planeref->plane->ZatPoint(vertexes[0]->x, vertexes[0]->y);
|
||||
right=planeref->plane->ZatPoint(vertexes[1]->x, vertexes[1]->y);
|
||||
left=planeref->plane->ZatPointFixed(vertexes[0]);
|
||||
right=planeref->plane->ZatPointFixed(vertexes[1]);
|
||||
}
|
||||
else if(planeref->isceiling == sector_t::ceiling)
|
||||
{
|
||||
|
@ -1452,8 +1451,8 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector)
|
|||
// Save a little time (up to 0.3 ms per frame ;) )
|
||||
if (frontsector->floorplane.isSlope())
|
||||
{
|
||||
ffh1 = segfront->floorplane.ZatPoint(v1->x, v1->y);
|
||||
ffh2 = segfront->floorplane.ZatPoint(v2->x, v2->y);
|
||||
ffh1 = segfront->floorplane.ZatPointFixed(v1);
|
||||
ffh2 = segfront->floorplane.ZatPointFixed(v2);
|
||||
zfloor[0] = FIXED2FLOAT(ffh1);
|
||||
zfloor[1] = FIXED2FLOAT(ffh2);
|
||||
}
|
||||
|
@ -1465,8 +1464,8 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector)
|
|||
|
||||
if (segfront->ceilingplane.isSlope())
|
||||
{
|
||||
fch1 = segfront->ceilingplane.ZatPoint(v1->x, v1->y);
|
||||
fch2 = segfront->ceilingplane.ZatPoint(v2->x, v2->y);
|
||||
fch1 = segfront->ceilingplane.ZatPointFixed(v1);
|
||||
fch2 = segfront->ceilingplane.ZatPointFixed(v2);
|
||||
zceil[0] = FIXED2FLOAT(fch1);
|
||||
zceil[1] = FIXED2FLOAT(fch2);
|
||||
}
|
||||
|
@ -1522,8 +1521,8 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector)
|
|||
|
||||
if (segback->floorplane.isSlope())
|
||||
{
|
||||
bfh1 = segback->floorplane.ZatPoint(v1->x, v1->y);
|
||||
bfh2 = segback->floorplane.ZatPoint(v2->x, v2->y);
|
||||
bfh1 = segback->floorplane.ZatPointFixed(v1);
|
||||
bfh2 = segback->floorplane.ZatPointFixed(v2);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1532,8 +1531,8 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector)
|
|||
|
||||
if (segback->ceilingplane.isSlope())
|
||||
{
|
||||
bch1 = segback->ceilingplane.ZatPoint(v1->x, v1->y);
|
||||
bch2 = segback->ceilingplane.ZatPoint(v2->x, v2->y);
|
||||
bch1 = segback->ceilingplane.ZatPointFixed(v1);
|
||||
bch2 = segback->ceilingplane.ZatPointFixed(v2);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -258,15 +258,15 @@ void FGLRenderer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep)
|
|||
TArray<lightlist_t> & lightlist = viewsector->e->XFloor.lightlist;
|
||||
for(i=0;i<lightlist.Size();i++)
|
||||
{
|
||||
int lightbottom;
|
||||
double lightbottom;
|
||||
|
||||
if (i<lightlist.Size()-1)
|
||||
{
|
||||
lightbottom=lightlist[i+1].plane.ZatPoint(viewx,viewy);
|
||||
lightbottom=lightlist[i+1].plane.ZatPoint(ViewPos);
|
||||
}
|
||||
else
|
||||
{
|
||||
lightbottom=viewsector->floorplane.ZatPoint(viewx,viewy);
|
||||
lightbottom=viewsector->floorplane.ZatPoint(ViewPos);
|
||||
}
|
||||
|
||||
if (lightbottom<player->viewz)
|
||||
|
|
|
@ -42,24 +42,15 @@ namespace s3d {
|
|||
ScopedViewShifter::ScopedViewShifter(float dxyz[3]) // in meters
|
||||
{
|
||||
// save original values
|
||||
cachedViewx = viewx;
|
||||
cachedViewy = viewy;
|
||||
cachedViewz = viewz;
|
||||
cachedView = ViewPos;
|
||||
// modify values
|
||||
float fViewx = FIXED2FLOAT(viewx) - dxyz[0];
|
||||
float fViewy = FIXED2FLOAT(viewy) + dxyz[1];
|
||||
float fViewz = FIXED2FLOAT(viewz) + dxyz[2];
|
||||
viewx = FLOAT2FIXED(fViewx);
|
||||
viewy = FLOAT2FIXED(fViewy);
|
||||
viewz = FLOAT2FIXED(fViewz);
|
||||
ViewPos += DVector3(dxyz[0], dxyz[1], dxyz[2]);
|
||||
}
|
||||
|
||||
ScopedViewShifter::~ScopedViewShifter()
|
||||
{
|
||||
// restore original values
|
||||
viewx = cachedViewx;
|
||||
viewy = cachedViewy;
|
||||
viewz = cachedViewz;
|
||||
ViewPos = cachedView;
|
||||
}
|
||||
|
||||
}
|
|
@ -38,6 +38,7 @@
|
|||
#define GL_STEREO3D_SCOPED_VIEW_SHIFTER_H_
|
||||
|
||||
#include "basictypes.h"
|
||||
#include "vectors.h"
|
||||
|
||||
namespace s3d {
|
||||
|
||||
|
@ -51,9 +52,7 @@ namespace s3d {
|
|||
~ScopedViewShifter();
|
||||
|
||||
private:
|
||||
fixed_t cachedViewx;
|
||||
fixed_t cachedViewy;
|
||||
fixed_t cachedViewz;
|
||||
DVector3 cachedView;
|
||||
};
|
||||
|
||||
} /* namespace s3d */
|
||||
|
|
|
@ -184,9 +184,8 @@ void CheckBench()
|
|||
FString compose;
|
||||
|
||||
compose.Format("Map %s: \"%s\",\nx = %1.4f, y = %1.4f, z = %1.4f, angle = %1.4f, pitch = %1.4f\n",
|
||||
level.MapName.GetChars(), level.LevelName.GetChars(), FIXED2FLOAT(viewx), FIXED2FLOAT(viewy), FIXED2FLOAT(viewz),
|
||||
AngleToFloat(viewangle), AngleToFloat(viewpitch));
|
||||
|
||||
level.MapName.GetChars(), level.LevelName.GetChars(), ViewPos.X, ViewPos.Y, ViewPos.Z, ViewAngle.Degrees, ViewPitch.Degrees);
|
||||
|
||||
AppendRenderStats(compose);
|
||||
AppendRenderTimes(compose);
|
||||
AppendLightStats(compose);
|
||||
|
|
|
@ -902,7 +902,6 @@ struct sector_t
|
|||
return FIXED2DBL(planes[pos].TexZ);
|
||||
}
|
||||
|
||||
void SetPlaneTexZ(int pos, double val)
|
||||
void SetPlaneTexZ(int pos, double val, bool dirtify = false) // This mainly gets used by init code. The only place where it must set the vertex to dirty is the interpolation code.
|
||||
{
|
||||
planes[pos].TexZ = FLOAT2FIXED(val);
|
||||
|
|
Loading…
Reference in a new issue