Add global lightmap control into ZScript
This commit is contained in:
parent
9564de3f16
commit
b3ba1cf49e
2 changed files with 73 additions and 7 deletions
|
|
@ -15,6 +15,8 @@
|
|||
#include "hwrenderer/scene/hw_flatdispatcher.h"
|
||||
#include <unordered_map>
|
||||
|
||||
#include "vm.h"
|
||||
|
||||
static bool RequireLevelMesh()
|
||||
{
|
||||
if (level.levelMesh)
|
||||
|
|
@ -36,6 +38,20 @@ static bool RequireLightmap()
|
|||
return false;
|
||||
}
|
||||
|
||||
static int InvalidateLightmap()
|
||||
{
|
||||
int count = 0;
|
||||
|
||||
for (auto& tile : level.levelMesh->LightmapTiles)
|
||||
{
|
||||
if (!tile.NeedsUpdate)
|
||||
++count;
|
||||
tile.NeedsUpdate = true;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
ADD_STAT(lightmap)
|
||||
{
|
||||
FString out;
|
||||
|
|
@ -71,13 +87,8 @@ CCMD(invalidatelightmap)
|
|||
{
|
||||
if (!RequireLightmap()) return;
|
||||
|
||||
int count = 0;
|
||||
for (auto& tile : level.levelMesh->LightmapTiles)
|
||||
{
|
||||
if (!tile.NeedsUpdate)
|
||||
++count;
|
||||
tile.NeedsUpdate = true;
|
||||
}
|
||||
int count = InvalidateLightmap();
|
||||
|
||||
Printf("Marked %d out of %d tiles for update.\n", count, level.levelMesh->LightmapTiles.Size());
|
||||
}
|
||||
|
||||
|
|
@ -1176,3 +1187,43 @@ void DoomLevelMesh::CreatePortals(FLevelLocals& doomMap)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// struct lightmap
|
||||
|
||||
DEFINE_ACTION_FUNCTION(_Lightmap, Invalidate)
|
||||
{
|
||||
PARAM_PROLOGUE;
|
||||
InvalidateLightmap();
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(_Lightmap, SetSunDirection)
|
||||
{
|
||||
PARAM_PROLOGUE;
|
||||
PARAM_FLOAT(x);
|
||||
PARAM_FLOAT(y);
|
||||
PARAM_FLOAT(z);
|
||||
|
||||
auto vec = FVector3(float(x), float(y), float(z));
|
||||
|
||||
if (!vec.isZero())
|
||||
{
|
||||
vec.MakeUnit();
|
||||
level.SunDirection = vec;
|
||||
level.levelMesh->SunDirection = vec;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(_Lightmap, SetSunColor)
|
||||
{
|
||||
PARAM_PROLOGUE;
|
||||
PARAM_FLOAT(x);
|
||||
PARAM_FLOAT(y);
|
||||
PARAM_FLOAT(z);
|
||||
|
||||
auto vec = FVector3(float(x), float(y), float(z));
|
||||
level.SunColor = vec;
|
||||
level.levelMesh->SunColor = vec;
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue