mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-02-23 04:21:00 +00:00
Add some of the sunlight trace code
This commit is contained in:
parent
1b81e40842
commit
2bcab0e34d
2 changed files with 27 additions and 0 deletions
|
@ -24,6 +24,18 @@ class DoomLevelMesh : public hwrenderer::LevelMesh
|
|||
public:
|
||||
DoomLevelMesh(FLevelLocals &doomMap);
|
||||
|
||||
bool TraceSky(const FVector3& start, FVector3 direction, float dist)
|
||||
{
|
||||
FVector3 end = start + direction * dist;
|
||||
TraceHit hit = TriangleMeshShape::find_first_hit(Collision.get(), start, end);
|
||||
if (hit.fraction == 1.0f)
|
||||
return true;
|
||||
|
||||
int surfaceIndex = MeshSurfaces[hit.triangle];
|
||||
const Surface& surface = Surfaces[surfaceIndex];
|
||||
return surface.bSky;
|
||||
}
|
||||
|
||||
TArray<Surface> Surfaces;
|
||||
|
||||
private:
|
||||
|
|
|
@ -59,6 +59,11 @@ static bool TraceLightVisbility(FLightNode* node, const FVector3& L, float dist)
|
|||
return level.levelMesh->Trace(FVector3((float)light->Pos.X, (float)light->Pos.Y, (float)light->Pos.Z), FVector3(-L.X, -L.Y, -L.Z), dist);
|
||||
}
|
||||
|
||||
static bool TraceSunVisibility(float x, float y, float z)
|
||||
{
|
||||
return level.levelMesh->TraceSky(FVector3(x, y, z), FVector3(0.0f, 0.0, 1.0f), 10000.0f);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// Sets a single light value from all dynamic lights affecting the specified location
|
||||
|
@ -73,6 +78,11 @@ void HWDrawInfo::GetDynSpriteLight(AActor *self, float x, float y, float z, FLig
|
|||
|
||||
out[0] = out[1] = out[2] = 0.f;
|
||||
|
||||
if (TraceSunVisibility(x, y, z))
|
||||
{
|
||||
//out[0] = 1.0f;
|
||||
}
|
||||
|
||||
// Go through both light lists
|
||||
while (node)
|
||||
{
|
||||
|
@ -183,6 +193,11 @@ void hw_GetDynModelLight(AActor *self, FDynLightData &modellightdata)
|
|||
float radiusSquared = actorradius * actorradius;
|
||||
dl_validcount++;
|
||||
|
||||
if (TraceSunVisibility(x, y, z))
|
||||
{
|
||||
//AddSunLightToList(modellightdata);
|
||||
}
|
||||
|
||||
BSPWalkCircle(self->Level, x, y, radiusSquared, [&](subsector_t *subsector) // Iterate through all subsectors potentially touched by actor
|
||||
{
|
||||
auto section = subsector->section;
|
||||
|
|
Loading…
Reference in a new issue