Move IES profile importer into ContentImporters module
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
|
||||
|
||||
#if COMPILE_WITH_ASSETS_IMPORTER
|
||||
|
||||
#include "ImportIES.h"
|
||||
#include "Engine/Core/Log.h"
|
||||
#include "Engine/Core/RandomStream.h"
|
||||
#include "Engine/Core/Math/Packed.h"
|
||||
#include "IESLoader.h"
|
||||
|
||||
#define MAX_LINE 200
|
||||
|
||||
@@ -84,7 +86,7 @@ static bool ReadLine(const uint8*& bufferPos, int32& ret)
|
||||
#define PARSE_FLOAT(x) float x; if (!ReadFloat(bufferPos, x)) { return true; }
|
||||
#define PARSE_INT(x) int32 x; if (!ReadLine(bufferPos, x)) { return true; }
|
||||
|
||||
bool IESLoader::Load(const byte* buffer)
|
||||
bool ImportIES::Load(const byte* buffer)
|
||||
{
|
||||
// Referenced IES file format:
|
||||
// http://www.ltblight.com/English.lproj/LTBLhelp/pages/iesformat.html
|
||||
@@ -214,7 +216,7 @@ bool IESLoader::Load(const byte* buffer)
|
||||
#undef PARSE_FLOAT
|
||||
#undef PARSE_INT
|
||||
|
||||
float IESLoader::ExtractInR16(Array<byte>& output)
|
||||
float ImportIES::ExtractInR16(Array<byte>& output)
|
||||
{
|
||||
const uint32 width = GetWidth();
|
||||
const uint32 height = GetHeight();
|
||||
@@ -263,14 +265,14 @@ float IESLoader::ExtractInR16(Array<byte>& output)
|
||||
return maxValue / integral;
|
||||
}
|
||||
|
||||
float IESLoader::InterpolatePoint(int32 x, int32 y) const
|
||||
float ImportIES::InterpolatePoint(int32 x, int32 y) const
|
||||
{
|
||||
x %= _hAngles.Count();
|
||||
y %= _vAngles.Count();
|
||||
return _candalaValues[y + _vAngles.Count() * x];
|
||||
}
|
||||
|
||||
float IESLoader::InterpolateBilinear(float x, float y) const
|
||||
float ImportIES::InterpolateBilinear(float x, float y) const
|
||||
{
|
||||
const int32 xInt = static_cast<int32>(x);
|
||||
const int32 yInt = static_cast<int32>(y);
|
||||
@@ -289,7 +291,7 @@ float IESLoader::InterpolateBilinear(float x, float y) const
|
||||
return Math::Lerp(p0, p1, xFrac);
|
||||
}
|
||||
|
||||
float IESLoader::ComputeFilterPos(float value, const Array<float>& sortedValues)
|
||||
float ImportIES::ComputeFilterPos(float value, const Array<float>& sortedValues)
|
||||
{
|
||||
ASSERT(sortedValues.HasItems());
|
||||
|
||||
@@ -336,3 +338,5 @@ float IESLoader::ComputeFilterPos(float value, const Array<float>& sortedValues)
|
||||
|
||||
return startPos + fraction;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -2,13 +2,15 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#if COMPILE_WITH_ASSETS_IMPORTER
|
||||
|
||||
#include "Engine/Core/Types/BaseTypes.h"
|
||||
#include "Engine/Core/Collections/Array.h"
|
||||
|
||||
/// <summary>
|
||||
/// Utility for loading IES files and extract light emission information.
|
||||
/// </summary>
|
||||
class IESLoader
|
||||
class ImportIES
|
||||
{
|
||||
private:
|
||||
|
||||
@@ -56,3 +58,5 @@ private:
|
||||
float InterpolateBilinear(float x, float y) const;
|
||||
static float ComputeFilterPos(float value, const Array<float>& sortedValues);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "Engine/Graphics/Textures/TextureUtils.h"
|
||||
#include "Engine/Graphics/PixelFormatExtensions.h"
|
||||
#include "Engine/Content/Storage/ContentStorageManager.h"
|
||||
#include "Engine/Content/Utilities/IESLoader.h"
|
||||
#include "Engine/ContentImporters/ImportIES.h"
|
||||
#include "Engine/Content/Assets/CubeTexture.h"
|
||||
#include "Engine/Content/Assets/IESProfile.h"
|
||||
#include "Engine/Content/Assets/Texture.h"
|
||||
@@ -527,7 +527,7 @@ CreateAssetResult ImportTexture::ImportIES(class CreateAssetContext& context)
|
||||
fileData.Add('\0');
|
||||
|
||||
// Load IES profile data
|
||||
IESLoader loader;
|
||||
::ImportIES loader;
|
||||
if (loader.Load(fileData.Get()))
|
||||
{
|
||||
return CreateAssetResult::Error;
|
||||
|
||||
Reference in New Issue
Block a user