mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2026-05-17 07:21:43 +00:00
Add CreationState to fill in lightdef lookup start.
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
#include "LightDefAssetCreationStateIW4.h"
|
||||
|
||||
#include "Utils/Logging/Log.h"
|
||||
|
||||
using namespace IW4;
|
||||
|
||||
LightDefAssetCreationState::LightDefAssetCreationState()
|
||||
: m_lmap_pixels_used_for_falloff(0)
|
||||
{
|
||||
}
|
||||
|
||||
void LightDefAssetCreationState::SetLightDefLookupStart(GfxLightDef* lightDef, AssetCreationContext& context)
|
||||
{
|
||||
const auto* image = lightDef->attenuation.image;
|
||||
if (!image)
|
||||
return;
|
||||
|
||||
// We need the actual image to determine the width, so force load it, if it is a reference
|
||||
if (image->name && image->name[0] == ',')
|
||||
{
|
||||
const auto forceLoadedImage = context.ForceLoadDependency<AssetImage>(&image->name[1]);
|
||||
if (!forceLoadedImage)
|
||||
return;
|
||||
|
||||
image = forceLoadedImage->Asset();
|
||||
}
|
||||
|
||||
const int newLmapUsage = image->width + 2;
|
||||
if (m_lmap_pixels_used_for_falloff + newLmapUsage > MAX_LMAP_USAGE)
|
||||
{
|
||||
con::error(
|
||||
"Total pixel width of all attenuation textures plus 2 border pixels is {} > {}", m_lmap_pixels_used_for_falloff + newLmapUsage, MAX_LMAP_USAGE);
|
||||
}
|
||||
|
||||
lightDef->lmapLookupStart = m_lmap_pixels_used_for_falloff + 1;
|
||||
m_lmap_pixels_used_for_falloff += newLmapUsage;
|
||||
}
|
||||
Reference in New Issue
Block a user