Fix game build
This commit is contained in:
@@ -617,17 +617,24 @@ bool Model::GenerateSDF(float resolutionScale, int32 lodIndex, bool cacheData)
|
|||||||
LOG(Warning, "Cannot generate SDF for virtual models on a main thread.");
|
LOG(Warning, "Cannot generate SDF for virtual models on a main thread.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
cacheData &= Storage != nullptr; // Cache only if has storage linked
|
|
||||||
lodIndex = Math::Clamp(lodIndex, HighestResidentLODIndex(), LODs.Count() - 1);
|
lodIndex = Math::Clamp(lodIndex, HighestResidentLODIndex(), LODs.Count() - 1);
|
||||||
|
|
||||||
// Generate SDF
|
// Generate SDF
|
||||||
|
#if USE_EDITOR
|
||||||
|
cacheData &= Storage != nullptr; // Cache only if has storage linked
|
||||||
MemoryWriteStream sdfStream;
|
MemoryWriteStream sdfStream;
|
||||||
if (ModelTool::GenerateModelSDF(this, nullptr, resolutionScale, lodIndex, &SDF, cacheData ? &sdfStream : nullptr, GetPath()))
|
MemoryWriteStream* outputStream = cacheData ? &sdfStream : nullptr;
|
||||||
|
#else
|
||||||
|
class MemoryWriteStream* outputStream = nullptr;
|
||||||
|
#endif
|
||||||
|
if (ModelTool::GenerateModelSDF(this, nullptr, resolutionScale, lodIndex, &SDF, outputStream, GetPath()))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
#if USE_EDITOR
|
||||||
// Set asset data
|
// Set asset data
|
||||||
if (cacheData)
|
if (cacheData)
|
||||||
GetOrCreateChunk(15)->Data.Copy(sdfStream.GetHandle(), sdfStream.GetPosition());
|
GetOrCreateChunk(15)->Data.Copy(sdfStream.GetHandle(), sdfStream.GetPosition());
|
||||||
|
#endif
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -212,7 +212,7 @@ public:
|
|||||||
/// <remarks>Can be called in async in case of SDF generation on a CPU (assuming model is not during rendering).</remarks>
|
/// <remarks>Can be called in async in case of SDF generation on a CPU (assuming model is not during rendering).</remarks>
|
||||||
/// <param name="resolutionScale">The SDF texture resolution scale. Use higher values for more precise data but with significant performance and memory overhead.</param>
|
/// <param name="resolutionScale">The SDF texture resolution scale. Use higher values for more precise data but with significant performance and memory overhead.</param>
|
||||||
/// <param name="lodIndex">The index of the LOD to use for the SDF building.</param>
|
/// <param name="lodIndex">The index of the LOD to use for the SDF building.</param>
|
||||||
/// <param name="cacheData">If true, the generated SDF texture data will be cached on CPU (in asset chunk storage) to allow saving it later, otherwise it will be runtime for GPU-only. Ignored for virtual assets.</param>
|
/// <param name="cacheData">If true, the generated SDF texture data will be cached on CPU (in asset chunk storage) to allow saving it later, otherwise it will be runtime for GPU-only. Ignored for virtual assets or in build.</param>
|
||||||
/// <returns>True if failed, otherwise false.</returns>
|
/// <returns>True if failed, otherwise false.</returns>
|
||||||
API_FUNCTION() bool GenerateSDF(float resolutionScale = 1.0f, int32 lodIndex = 6, bool cacheData = true);
|
API_FUNCTION() bool GenerateSDF(float resolutionScale = 1.0f, int32 lodIndex = 6, bool cacheData = true);
|
||||||
|
|
||||||
|
|||||||
@@ -531,6 +531,17 @@ void MeshData::TransformBuffer(const Matrix& matrix)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MeshData::NormalizeBlendWeights()
|
||||||
|
{
|
||||||
|
ASSERT(Positions.Count() == BlendWeights.Count());
|
||||||
|
for (int32 i = 0; i < Positions.Count(); i++)
|
||||||
|
{
|
||||||
|
const float sum = BlendWeights[i].SumValues();
|
||||||
|
const float invSum = sum > ZeroTolerance ? 1.0f / sum : 0.0f;
|
||||||
|
BlendWeights[i] *= invSum;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MeshData::Merge(MeshData& other)
|
void MeshData::Merge(MeshData& other)
|
||||||
{
|
{
|
||||||
// Merge index buffer (and remap indices)
|
// Merge index buffer (and remap indices)
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Engine/Core/Common.h"
|
|
||||||
#include "Engine/Core/Math/BoundingSphere.h"
|
#include "Engine/Core/Math/BoundingSphere.h"
|
||||||
#include "Engine/Core/Math/BoundingBox.h"
|
#include "Engine/Core/Math/BoundingBox.h"
|
||||||
#include "Engine/Core/Math/Int4.h"
|
#include "Engine/Core/Math/Int4.h"
|
||||||
@@ -281,16 +280,7 @@ public:
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Normalizes the blend weights. Requires to have vertices with positions and blend weights setup.
|
/// Normalizes the blend weights. Requires to have vertices with positions and blend weights setup.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void NormalizeBlendWeights()
|
void NormalizeBlendWeights();
|
||||||
{
|
|
||||||
ASSERT(Positions.Count() == BlendWeights.Count());
|
|
||||||
for (int32 i = 0; i < Positions.Count(); i++)
|
|
||||||
{
|
|
||||||
const float sum = BlendWeights[i].SumValues();
|
|
||||||
const float invSum = sum > ZeroTolerance ? 1.0f / sum : 0.0f;
|
|
||||||
BlendWeights[i] *= invSum;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Merges this mesh data with the specified other mesh.
|
/// Merges this mesh data with the specified other mesh.
|
||||||
|
|||||||
@@ -183,7 +183,7 @@ bool GlobalSignDistanceFieldPass::setupResources()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if USE_EDITOR
|
#if COMPILE_WITH_DEV_ENV
|
||||||
|
|
||||||
void GlobalSignDistanceFieldPass::OnShaderReloading(Asset* obj)
|
void GlobalSignDistanceFieldPass::OnShaderReloading(Asset* obj)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -12,7 +12,9 @@
|
|||||||
#include "Engine/Threading/JobSystem.h"
|
#include "Engine/Threading/JobSystem.h"
|
||||||
#include "Engine/Graphics/RenderTools.h"
|
#include "Engine/Graphics/RenderTools.h"
|
||||||
#include "Engine/Graphics/Async/GPUTask.h"
|
#include "Engine/Graphics/Async/GPUTask.h"
|
||||||
|
#include "Engine/Graphics/Textures/GPUTexture.h"
|
||||||
#include "Engine/Graphics/Textures/TextureData.h"
|
#include "Engine/Graphics/Textures/TextureData.h"
|
||||||
|
#include "Engine/Graphics/Models/ModelData.h"
|
||||||
#include "Engine/Content/Assets/Model.h"
|
#include "Engine/Content/Assets/Model.h"
|
||||||
#include "Engine/Serialization/MemoryWriteStream.h"
|
#include "Engine/Serialization/MemoryWriteStream.h"
|
||||||
#if USE_EDITOR
|
#if USE_EDITOR
|
||||||
|
|||||||
@@ -12,7 +12,6 @@
|
|||||||
#include "Engine/Graphics/Models/SkeletonData.h"
|
#include "Engine/Graphics/Models/SkeletonData.h"
|
||||||
#include "Engine/Animations/AnimationData.h"
|
#include "Engine/Animations/AnimationData.h"
|
||||||
|
|
||||||
class MemoryWriteStream;
|
|
||||||
class JsonWriter;
|
class JsonWriter;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -186,7 +185,7 @@ public:
|
|||||||
|
|
||||||
// Optional: inputModel or modelData
|
// Optional: inputModel or modelData
|
||||||
// Optional: outputSDF or null, outputStream or null
|
// Optional: outputSDF or null, outputStream or null
|
||||||
static bool GenerateModelSDF(Model* inputModel, ModelData* modelData, float resolutionScale, int32 lodIndex, ModelBase::SDFData* outputSDF, MemoryWriteStream* outputStream, const StringView& assetName);
|
static bool GenerateModelSDF(class Model* inputModel, class ModelData* modelData, float resolutionScale, int32 lodIndex, ModelBase::SDFData* outputSDF, class MemoryWriteStream* outputStream, const StringView& assetName);
|
||||||
|
|
||||||
#if USE_EDITOR
|
#if USE_EDITOR
|
||||||
public:
|
public:
|
||||||
|
|||||||
Reference in New Issue
Block a user