Minor fixes and improvements
This commit is contained in:
@@ -191,6 +191,8 @@ bool BinaryAsset::HasDependenciesModified() const
|
||||
|
||||
FlaxChunk* BinaryAsset::GetOrCreateChunk(int32 index)
|
||||
{
|
||||
if (IsVirtual()) // Virtual assets don't own storage container
|
||||
return nullptr;
|
||||
ASSERT(Math::IsInRange(index, 0, ASSET_FILE_DATA_CHUNKS - 1));
|
||||
|
||||
// Try get
|
||||
|
||||
@@ -75,8 +75,7 @@ public:
|
||||
};
|
||||
|
||||
private:
|
||||
Upgrader const* _upgraders;
|
||||
int32 _upgradersCount;
|
||||
Array<Upgrader, InlinedAllocation<8>> _upgraders;
|
||||
|
||||
public:
|
||||
/// <summary>
|
||||
@@ -87,10 +86,8 @@ public:
|
||||
/// <returns>True if cannot upgrade or upgrade failed, otherwise false</returns>
|
||||
bool Upgrade(uint32 serializedVersion, AssetMigrationContext& context) const
|
||||
{
|
||||
// Find upgrader
|
||||
for (int32 i = 0; i < _upgradersCount; i++)
|
||||
for (auto& upgrader : _upgraders)
|
||||
{
|
||||
auto& upgrader = _upgraders[i];
|
||||
if (upgrader.CurrentVersion == serializedVersion)
|
||||
{
|
||||
// Set target version and preserve metadata
|
||||
@@ -105,7 +102,6 @@ public:
|
||||
return upgrader.Handler(context);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -127,7 +123,6 @@ public:
|
||||
context.Output.Header.Chunks[chunkIndex]->Data.Copy(srcChunk->Data);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -176,27 +171,22 @@ public:
|
||||
protected:
|
||||
BinaryAssetUpgrader()
|
||||
{
|
||||
_upgraders = nullptr;
|
||||
_upgradersCount = 0;
|
||||
}
|
||||
|
||||
void setup(Upgrader const* upgraders, int32 upgradersCount)
|
||||
{
|
||||
_upgraders = upgraders;
|
||||
_upgradersCount = upgradersCount;
|
||||
_upgraders.Add(upgraders, upgradersCount);
|
||||
}
|
||||
|
||||
public:
|
||||
// [IAssetUpgrader]
|
||||
bool ShouldUpgrade(uint32 serializedVersion) const override
|
||||
{
|
||||
// Find upgrader
|
||||
for (int32 i = 0; i < _upgradersCount; i++)
|
||||
for (auto& upgrader : _upgraders)
|
||||
{
|
||||
if (_upgraders[i].CurrentVersion == serializedVersion)
|
||||
if (upgrader.CurrentVersion == serializedVersion)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -663,7 +663,7 @@ bool MaterialParams::Load(ReadStream* stream)
|
||||
param->_type = static_cast<MaterialParameterType>(stream->ReadByte());
|
||||
param->_isPublic = stream->ReadBool();
|
||||
param->_override = param->_isPublic;
|
||||
stream->ReadString(¶m->_name, 10421);
|
||||
stream->Read(param->_name, 10421);
|
||||
param->_registerIndex = stream->ReadByte();
|
||||
stream->ReadUint16(¶m->_offset);
|
||||
|
||||
@@ -738,7 +738,7 @@ bool MaterialParams::Load(ReadStream* stream)
|
||||
stream->Read(param->_paramId);
|
||||
param->_isPublic = stream->ReadBool();
|
||||
param->_override = param->_isPublic;
|
||||
stream->ReadString(¶m->_name, 10421);
|
||||
stream->Read(param->_name, 10421);
|
||||
param->_registerIndex = stream->ReadByte();
|
||||
stream->ReadUint16(¶m->_offset);
|
||||
|
||||
|
||||
@@ -67,6 +67,8 @@ enum class MeshBufferType
|
||||
/// The vertex buffer (third).
|
||||
/// </summary>
|
||||
Vertex2 = 3,
|
||||
|
||||
MAX,
|
||||
};
|
||||
|
||||
// Vertex structure for all models (versioned)
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace
|
||||
String VertexElement::ToString() const
|
||||
{
|
||||
#if GPU_ENABLE_RESOURCE_NAMING
|
||||
return String::Format(TEXT("{}, format {}, offset {}, per-instance {}, slot {}"), ScriptingEnum::ToString(Type), ScriptingEnum::ToString(Format), Offset, PerInstance, Slot);
|
||||
return String::Format(TEXT("{}, {}, offset {}, {}, slot {}"), ScriptingEnum::ToString(Type), ScriptingEnum::ToString(Format), Offset, PerInstance ? TEXT("per-instance") : TEXT("per-vertex"), Slot);
|
||||
#else
|
||||
return TEXT("VertexElement");
|
||||
#endif
|
||||
@@ -116,6 +116,18 @@ void GPUVertexLayout::SetElements(const Elements& elements, bool explicitOffsets
|
||||
_stride += offset;
|
||||
}
|
||||
|
||||
String GPUVertexLayout::GetElementsString() const
|
||||
{
|
||||
String result;
|
||||
for (int32 i = 0; i < _elements.Count(); i++)
|
||||
{
|
||||
if (i != 0)
|
||||
result += '\n';
|
||||
result += _elements[i].ToString();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
GPUVertexLayout* GPUVertexLayout::Get(const Elements& elements, bool explicitOffsets)
|
||||
{
|
||||
// Hash input layout
|
||||
|
||||
@@ -34,6 +34,11 @@ public:
|
||||
return _elements;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of elements used by this layout as a text (each element in a new line).
|
||||
/// </summary>
|
||||
API_PROPERTY() String GetElementsString() const;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the size in bytes of all elements in the layout structure (including their offsets).
|
||||
/// </summary>
|
||||
|
||||
@@ -331,11 +331,11 @@ void MeshAccelerationStructure::Add(Model* model, int32 lodIndex)
|
||||
}
|
||||
}
|
||||
|
||||
void MeshAccelerationStructure::Add(ModelData* modelData, int32 lodIndex, bool copy)
|
||||
void MeshAccelerationStructure::Add(const ModelData* modelData, int32 lodIndex, bool copy)
|
||||
{
|
||||
PROFILE_CPU();
|
||||
lodIndex = Math::Clamp(lodIndex, 0, modelData->LODs.Count() - 1);
|
||||
ModelLodData& lod = modelData->LODs[lodIndex];
|
||||
const ModelLodData& lod = modelData->LODs[lodIndex];
|
||||
_meshes.EnsureCapacity(_meshes.Count() + lod.Meshes.Count());
|
||||
for (int32 i = 0; i < lod.Meshes.Count(); i++)
|
||||
{
|
||||
|
||||
@@ -61,7 +61,7 @@ public:
|
||||
void Add(Model* model, int32 lodIndex);
|
||||
|
||||
// Adds the model geometry for the build to the structure.
|
||||
void Add(ModelData* modelData, int32 lodIndex, bool copy = false);
|
||||
void Add(const ModelData* modelData, int32 lodIndex, bool copy = false);
|
||||
|
||||
// Adds the triangles geometry for the build to the structure.
|
||||
void Add(Float3* vb, int32 vertices, void* ib, int32 indices, bool use16BitIndex, bool copy = false);
|
||||
|
||||
@@ -81,7 +81,7 @@ class GPUModelSDFTask : public GPUTask
|
||||
ConditionVariable* _signal;
|
||||
AssetReference<Shader> _shader;
|
||||
Model* _inputModel;
|
||||
ModelData* _modelData;
|
||||
const ModelData* _modelData;
|
||||
int32 _lodIndex;
|
||||
Int3 _resolution;
|
||||
ModelBase::SDFData* _sdf;
|
||||
@@ -104,7 +104,7 @@ class GPUModelSDFTask : public GPUTask
|
||||
});
|
||||
|
||||
public:
|
||||
GPUModelSDFTask(ConditionVariable& signal, Model* inputModel, ModelData* modelData, int32 lodIndex, const Int3& resolution, ModelBase::SDFData* sdf, GPUTexture* sdfResult, const Float3& xyzToLocalMul, const Float3& xyzToLocalAdd)
|
||||
GPUModelSDFTask(ConditionVariable& signal, Model* inputModel, const ModelData* modelData, int32 lodIndex, const Int3& resolution, ModelBase::SDFData* sdf, GPUTexture* sdfResult, const Float3& xyzToLocalMul, const Float3& xyzToLocalAdd)
|
||||
: GPUTask(Type::Custom)
|
||||
, _signal(&signal)
|
||||
, _shader(Content::LoadAsyncInternal<Shader>(TEXT("Shaders/SDF")))
|
||||
@@ -350,7 +350,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
bool ModelTool::GenerateModelSDF(Model* inputModel, ModelData* modelData, float resolutionScale, int32 lodIndex, ModelBase::SDFData* outputSDF, MemoryWriteStream* outputStream, const StringView& assetName, float backfacesThreshold, bool useGPU)
|
||||
bool ModelTool::GenerateModelSDF(Model* inputModel, const ModelData* modelData, float resolutionScale, int32 lodIndex, ModelBase::SDFData* outputSDF, MemoryWriteStream* outputStream, const StringView& assetName, float backfacesThreshold, bool useGPU)
|
||||
{
|
||||
PROFILE_CPU();
|
||||
auto startTime = Platform::GetTimeSeconds();
|
||||
|
||||
@@ -98,7 +98,7 @@ API_CLASS(Namespace="FlaxEngine.Tools", Static) class FLAXENGINE_API ModelTool
|
||||
|
||||
// Optional: inputModel or modelData
|
||||
// Optional: outputSDF or null, outputStream or null
|
||||
static bool GenerateModelSDF(class Model* inputModel, class ModelData* modelData, float resolutionScale, int32 lodIndex, ModelBase::SDFData* outputSDF, class MemoryWriteStream* outputStream, const StringView& assetName, float backfacesThreshold = 0.6f, bool useGPU = true);
|
||||
static bool GenerateModelSDF(class Model* inputModel, const class ModelData* modelData, float resolutionScale, int32 lodIndex, ModelBase::SDFData* outputSDF, class MemoryWriteStream* outputStream, const StringView& assetName, float backfacesThreshold = 0.6f, bool useGPU = true);
|
||||
|
||||
#if USE_EDITOR
|
||||
|
||||
|
||||
Reference in New Issue
Block a user