mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2026-05-16 23:11:42 +00:00
Add CreationState to fill in lightdef lookup start.
This commit is contained in:
@@ -0,0 +1,37 @@
|
|||||||
|
#include "LightDefAssetCreationStateIW3.h"
|
||||||
|
|
||||||
|
#include "Utils/Logging/Log.h"
|
||||||
|
|
||||||
|
using namespace IW3;
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Asset/IZoneAssetCreationState.h"
|
||||||
|
#include "Asset/AssetCreationContext.h"
|
||||||
|
#include "Game/IW3/IW3.h"
|
||||||
|
|
||||||
|
namespace IW3
|
||||||
|
{
|
||||||
|
constexpr auto MAX_LMAP_USAGE = 512;
|
||||||
|
|
||||||
|
class LightDefAssetCreationState : public IZoneAssetCreationState
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
LightDefAssetCreationState();
|
||||||
|
|
||||||
|
void SetLightDefLookupStart(GfxLightDef* lightDef, AssetCreationContext& context);
|
||||||
|
|
||||||
|
private:
|
||||||
|
int m_lmap_pixels_used_for_falloff;
|
||||||
|
};
|
||||||
|
} // namespace
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Asset/IZoneAssetCreationState.h"
|
||||||
|
#include "Asset/AssetCreationContext.h"
|
||||||
|
#include "Game/IW4/IW4.h"
|
||||||
|
|
||||||
|
namespace IW4
|
||||||
|
{
|
||||||
|
constexpr auto MAX_LMAP_USAGE = 512;
|
||||||
|
|
||||||
|
class LightDefAssetCreationState : public IZoneAssetCreationState
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
LightDefAssetCreationState();
|
||||||
|
|
||||||
|
void SetLightDefLookupStart(GfxLightDef* lightDef, AssetCreationContext& context);
|
||||||
|
|
||||||
|
private:
|
||||||
|
int m_lmap_pixels_used_for_falloff;
|
||||||
|
};
|
||||||
|
} // namespace
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
#include "LightDefAssetCreationStateIW5.h"
|
||||||
|
|
||||||
|
#include "Utils/Logging/Log.h"
|
||||||
|
|
||||||
|
using namespace IW5;
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Asset/IZoneAssetCreationState.h"
|
||||||
|
#include "Asset/AssetCreationContext.h"
|
||||||
|
#include "Game/IW5/IW5.h"
|
||||||
|
|
||||||
|
namespace IW5
|
||||||
|
{
|
||||||
|
constexpr auto MAX_LMAP_USAGE = 512;
|
||||||
|
|
||||||
|
class LightDefAssetCreationState : public IZoneAssetCreationState
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
LightDefAssetCreationState();
|
||||||
|
|
||||||
|
void SetLightDefLookupStart(GfxLightDef* lightDef, AssetCreationContext& context);
|
||||||
|
|
||||||
|
private:
|
||||||
|
int m_lmap_pixels_used_for_falloff;
|
||||||
|
};
|
||||||
|
} // namespace light_def
|
||||||
Reference in New Issue
Block a user