mirror of
https://github.com/ZDoom/ZDRay.git
synced 2024-11-24 21:01:15 +00:00
Fix edge case where relativePosition of light is valid at 0,0,0
This commit is contained in:
parent
ea5b1a3cac
commit
91c0871b0b
3 changed files with 6 additions and 5 deletions
|
@ -8,7 +8,7 @@ include( CheckCXXCompilerFlag )
|
|||
|
||||
project( ZDRay )
|
||||
|
||||
SET( CMAKE_CXX_STANDARD 14 )
|
||||
SET( CMAKE_CXX_STANDARD 17 )
|
||||
|
||||
IF( NOT CMAKE_BUILD_TYPE )
|
||||
SET( CMAKE_BUILD_TYPE Debug CACHE STRING
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "math/mathlib.h"
|
||||
#include <memory>
|
||||
#include <cmath>
|
||||
#include <optional>
|
||||
#undef MIN
|
||||
#undef MAX
|
||||
#undef min
|
||||
|
@ -346,15 +347,15 @@ struct ThingLight
|
|||
MapSubsectorEx *ssect;
|
||||
|
||||
// Portal related functionality
|
||||
vec3 relativePosition = vec3(0);
|
||||
std::optional<vec3> relativePosition;
|
||||
int sectorGroup = 0;
|
||||
|
||||
// Portal aware position
|
||||
vec3 LightRelativeOrigin() const
|
||||
{
|
||||
if (relativePosition != vec3(0))
|
||||
if (relativePosition)
|
||||
{
|
||||
return relativePosition;
|
||||
return *relativePosition;
|
||||
}
|
||||
return LightOrigin();
|
||||
}
|
||||
|
|
|
@ -205,7 +205,7 @@ void LevelMesh::PropagateLight(FLevel& doomMap, ThingLight *light)
|
|||
{
|
||||
auto fakeLight = std::make_unique<ThingLight>(*light);
|
||||
|
||||
fakeLight->relativePosition = portal->TransformPosition(light->LightRelativeOrigin());
|
||||
fakeLight->relativePosition.emplace(portal->TransformPosition(light->LightRelativeOrigin()));
|
||||
fakeLight->sectorGroup = portal->targetSectorGroup;
|
||||
|
||||
PropagateLight(doomMap, fakeLight.get());
|
||||
|
|
Loading…
Reference in a new issue