diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index 0fa34845e..66b68c2c3 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -170,10 +170,10 @@ void FGLRenderer::ProcessLowerMiniseg(seg_t *seg, sector_t * frontsector, sector // //=========================================================================== -void FGLRenderer::ProcessSprite(AActor *thing, sector_t *sector) +void FGLRenderer::ProcessSprite(AActor *thing, sector_t *sector, bool thruportal) { GLSprite glsprite; - glsprite.Process(thing, sector); + glsprite.Process(thing, sector, thruportal); } //=========================================================================== diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index 2a3763551..a2f4c7d34 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -118,7 +118,7 @@ public: void Clear(int left, int top, int right, int bottom, int palcolor, uint32 color); void ProcessLowerMiniseg(seg_t *seg, sector_t * frontsector, sector_t * backsector); - void ProcessSprite(AActor *thing, sector_t *sector); + void ProcessSprite(AActor *thing, sector_t *sector, bool thruportal); void ProcessParticle(particle_t *part, sector_t *sector); void ProcessSector(sector_t *fakesector); void FlushTextures(); diff --git a/src/gl/scene/gl_bsp.cpp b/src/gl/scene/gl_bsp.cpp index bb7cbce4e..ca7eaf849 100644 --- a/src/gl/scene/gl_bsp.cpp +++ b/src/gl/scene/gl_bsp.cpp @@ -368,24 +368,37 @@ static inline void RenderThings(subsector_t * sub, sector_t * sector) SetupSprite.Clock(); sector_t * sec=sub->sector; - if (sec->thinglist != NULL) + // Handle all things in sector. + for (AActor * thing = sec->thinglist; thing; thing = thing->snext) { - // Handle all things in sector. - for (AActor * thing = sec->thinglist; thing; thing = thing->snext) + FIntCVar *cvar = thing->GetClass()->distancecheck; + if (cvar != NULL && *cvar >= 0) { - FIntCVar *cvar = thing->GetClass()->distancecheck; - if (cvar != NULL && *cvar >= 0) + double dist = (thing->Pos() - ViewPos).LengthSquared(); + double check = (double)**cvar; + if (dist >= check * check) { - double dist = (thing->Pos() - ViewPos).LengthSquared(); - double check = (double)**cvar; - if (dist >= check * check) - { - continue; - } + continue; } - - GLRenderer->ProcessSprite(thing, sector); } + + GLRenderer->ProcessSprite(thing, sector, false); + } + for (msecnode_t *node = sec->render_thinglist; node; node = node->m_snext) + { + AActor *thing = node->m_thing; + FIntCVar *cvar = thing->GetClass()->distancecheck; + if (cvar != NULL && *cvar >= 0) + { + double dist = (thing->Pos() - ViewPos).LengthSquared(); + double check = (double)**cvar; + if (dist >= check * check) + { + continue; + } + } + + GLRenderer->ProcessSprite(thing, sector, true); } SetupSprite.Unclock(); } diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 9269734b4..4b797f71f 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -504,10 +504,11 @@ void GLSprite::Process(AActor* thing, sector_t * sector, bool thruportal) } // If this thing is in a map section that's not in view it can't possibly be visible - if (!(currentmapsection[thing->subsector->mapsection >> 3] & (1 << (thing->subsector->mapsection & 7)))) return; + if (!thruportal && !(currentmapsection[thing->subsector->mapsection >> 3] & (1 << (thing->subsector->mapsection & 7)))) return; // [RH] Interpolate the sprite's position to make it look smooth DVector3 thingpos = thing->InterpolatedPosition(r_TicFracF); + if (thruportal) thingpos += Displacements.getOffset(thing->Sector->PortalGroup, sector->PortalGroup); // Too close to the camera. This doesn't look good if it is a sprite. if (fabs(thingpos.X - ViewPos.X) < 2 && fabs(thingpos.Y - ViewPos.Y) < 2) diff --git a/src/p_trace.cpp b/src/p_trace.cpp index 0e11e29a6..db78fa5e2 100644 --- a/src/p_trace.cpp +++ b/src/p_trace.cpp @@ -308,6 +308,7 @@ void FTraceInfo::Setup3DFloors() { Results->Crossed3DWater = rover; Results->Crossed3DWaterPos = Results->HitPos; + Results->Distance = 0; } } @@ -444,6 +445,7 @@ bool FTraceInfo::LineCheck(intercept_t *in, double dist, DVector3 hit) { Results->CrossedWater = §ors[CurSector->sectornum]; Results->CrossedWaterPos = Results->HitPos; + Results->Distance = 0; } } @@ -747,6 +749,7 @@ bool FTraceInfo::TraceTraverse (int ptflags) { Results->Crossed3DWater = rover; Results->Crossed3DWaterPos = Results->HitPos; + Results->Distance = 0; } } } @@ -835,6 +838,7 @@ bool FTraceInfo::TraceTraverse (int ptflags) { Results->CrossedWater = §ors[CurSector->sectornum]; Results->CrossedWaterPos = Results->HitPos; + Results->Distance = 0; } Results = res; }