Another compilation fix

This commit is contained in:
Wojtek Figat
2025-01-14 23:26:26 +01:00
parent be8686bbb2
commit d0a6edbb2c
5 changed files with 28 additions and 30 deletions

View File

@@ -404,7 +404,7 @@ bool Model::SaveHeader(WriteStream& stream)
{ {
if (ModelBase::SaveHeader(stream)) if (ModelBase::SaveHeader(stream))
return true; return true;
static_assert(HeaderVersion == 2, "Update code"); static_assert(MODEL_HEADER_VERSION == 2, "Update code");
// LODs // LODs
stream.Write((byte)LODs.Count()); stream.Write((byte)LODs.Count());
@@ -431,7 +431,7 @@ bool Model::SaveHeader(WriteStream& stream, const ModelData& modelData)
{ {
if (ModelBase::SaveHeader(stream, modelData)) if (ModelBase::SaveHeader(stream, modelData))
return true; return true;
static_assert(HeaderVersion == 2, "Update code"); static_assert(MODEL_HEADER_VERSION == 2, "Update code");
// LODs // LODs
stream.Write((byte)modelData.LODs.Count()); stream.Write((byte)modelData.LODs.Count());

View File

@@ -66,7 +66,7 @@ public:
Array<MeshBase*> meshes; Array<MeshBase*> meshes;
model->GetMeshes(meshes, _lodIndex); model->GetMeshes(meshes, _lodIndex);
byte meshVersion = stream.ReadByte(); byte meshVersion = stream.ReadByte();
if (meshVersion < 2 || meshVersion > ModelBase::MeshVersion) if (meshVersion < 2 || meshVersion > MODEL_MESH_VERSION)
{ {
LOG(Warning, "Unsupported mesh version {}", meshVersion); LOG(Warning, "Unsupported mesh version {}", meshVersion);
return true; return true;
@@ -315,12 +315,12 @@ bool ModelBase::LoadHeader(ReadStream& stream, byte& headerVersion)
{ {
// Basic info // Basic info
stream.Read(headerVersion); stream.Read(headerVersion);
if (headerVersion < 2 || headerVersion > HeaderVersion) if (headerVersion < 2 || headerVersion > MODEL_HEADER_VERSION)
{ {
LOG(Warning, "Unsupported model asset header version {}", headerVersion); LOG(Warning, "Unsupported model asset header version {}", headerVersion);
return true; return true;
} }
static_assert(HeaderVersion == 2, "Update code"); static_assert(MODEL_HEADER_VERSION == 2, "Update code");
stream.Read(MinScreenSize); stream.Read(MinScreenSize);
// Materials // Materials
@@ -344,7 +344,7 @@ bool ModelBase::LoadHeader(ReadStream& stream, byte& headerVersion)
bool ModelBase::LoadMesh(MemoryReadStream& stream, byte meshVersion, MeshBase* mesh, MeshData* dataIfReadOnly) bool ModelBase::LoadMesh(MemoryReadStream& stream, byte meshVersion, MeshBase* mesh, MeshData* dataIfReadOnly)
{ {
// Load descriptor // Load descriptor
static_assert(MeshVersion == 2, "Update code"); static_assert(MODEL_MESH_VERSION == 2, "Update code");
uint32 vertices, triangles; uint32 vertices, triangles;
stream.Read(vertices); stream.Read(vertices);
stream.Read(triangles); stream.Read(triangles);
@@ -402,8 +402,8 @@ bool ModelBase::LoadMesh(MemoryReadStream& stream, byte meshVersion, MeshBase* m
bool ModelBase::SaveHeader(WriteStream& stream) bool ModelBase::SaveHeader(WriteStream& stream)
{ {
// Basic info // Basic info
static_assert(HeaderVersion == 2, "Update code"); static_assert(MODEL_HEADER_VERSION == 2, "Update code");
stream.Write(HeaderVersion); stream.Write(MODEL_HEADER_VERSION);
stream.Write(MinScreenSize); stream.Write(MinScreenSize);
// Materials // Materials
@@ -446,8 +446,8 @@ bool ModelBase::SaveHeader(WriteStream& stream, const ModelData& modelData)
} }
// Basic info // Basic info
static_assert(HeaderVersion == 2, "Update code"); static_assert(MODEL_HEADER_VERSION == 2, "Update code");
stream.Write(HeaderVersion); stream.Write(MODEL_HEADER_VERSION);
stream.Write(modelData.MinScreenSize); stream.Write(modelData.MinScreenSize);
// Materials // Materials
@@ -518,8 +518,8 @@ bool ModelBase::SaveLOD(WriteStream& stream, int32 lodIndex) const
return true; return true;
// Create meshes data // Create meshes data
static_assert(MeshVersion == 2, "Update code"); static_assert(MODEL_MESH_VERSION == 2, "Update code");
stream.Write(MeshVersion); stream.Write(MODEL_MESH_VERSION);
for (int32 meshIndex = 0; meshIndex < meshesCount; meshIndex++) for (int32 meshIndex = 0; meshIndex < meshesCount; meshIndex++)
{ {
const auto& mesh = *meshes[meshIndex]; const auto& mesh = *meshes[meshIndex];
@@ -609,8 +609,8 @@ bool ModelBase::SaveLOD(WriteStream& stream, int32 lodIndex) const
bool ModelBase::SaveLOD(WriteStream& stream, const ModelData& modelData, int32 lodIndex, bool saveMesh(WriteStream& stream, const ModelData& modelData, int32 lodIndex, int32 meshIndex)) bool ModelBase::SaveLOD(WriteStream& stream, const ModelData& modelData, int32 lodIndex, bool saveMesh(WriteStream& stream, const ModelData& modelData, int32 lodIndex, int32 meshIndex))
{ {
// Create meshes data // Create meshes data
static_assert(MeshVersion == 2, "Update code"); static_assert(MODEL_MESH_VERSION == 2, "Update code");
stream.Write(MeshVersion); stream.Write(MODEL_MESH_VERSION);
const auto& lod = modelData.LODs[lodIndex]; const auto& lod = modelData.LODs[lodIndex];
for (int32 meshIndex = 0; meshIndex < lod.Meshes.Count(); meshIndex++) for (int32 meshIndex = 0; meshIndex < lod.Meshes.Count(); meshIndex++)
{ {

View File

@@ -18,6 +18,9 @@
// Chunk 15: SDF // Chunk 15: SDF
#define MODEL_LOD_TO_CHUNK_INDEX(lod) (lod + 1) #define MODEL_LOD_TO_CHUNK_INDEX(lod) (lod + 1)
#define MODEL_HEADER_VERSION (byte)2
#define MODEL_MESH_VERSION (byte)2
class MeshBase; class MeshBase;
class StreamModelLODTask; class StreamModelLODTask;
struct RenderContextBatch; struct RenderContextBatch;
@@ -114,9 +117,6 @@ API_CLASS(Abstract, NoSpawn) class FLAXENGINE_API ModelBase : public BinaryAsset
friend StreamModelLODTask; friend StreamModelLODTask;
protected: protected:
static constexpr byte HeaderVersion = 2;
static constexpr byte MeshVersion = 2;
bool _initialized = false; bool _initialized = false;
int32 _loadedLODs = 0; int32 _loadedLODs = 0;
StreamModelLODTask* _streamingTask = nullptr; StreamModelLODTask* _streamingTask = nullptr;

View File

@@ -533,7 +533,7 @@ bool SkinnedModel::LoadMesh(MemoryReadStream& stream, byte meshVersion, MeshBase
{ {
if (ModelBase::LoadMesh(stream, meshVersion, mesh, dataIfReadOnly)) if (ModelBase::LoadMesh(stream, meshVersion, mesh, dataIfReadOnly))
return true; return true;
static_assert(MeshVersion == 2, "Update code"); static_assert(MODEL_MESH_VERSION == 2, "Update code");
auto skinnedMesh = (SkinnedMesh*)mesh; auto skinnedMesh = (SkinnedMesh*)mesh;
// Blend Shapes // Blend Shapes
@@ -562,7 +562,7 @@ bool SkinnedModel::LoadHeader(ReadStream& stream, byte& headerVersion)
{ {
if (ModelBase::LoadHeader(stream, headerVersion)) if (ModelBase::LoadHeader(stream, headerVersion))
return true; return true;
static_assert(HeaderVersion == 2, "Update code"); static_assert(MODEL_HEADER_VERSION == 2, "Update code");
// LODs // LODs
byte lods = stream.ReadByte(); byte lods = stream.ReadByte();
@@ -665,7 +665,7 @@ bool SkinnedModel::SaveHeader(WriteStream& stream)
{ {
if (ModelBase::SaveHeader(stream)) if (ModelBase::SaveHeader(stream))
return true; return true;
static_assert(HeaderVersion == 2, "Update code"); static_assert(MODEL_HEADER_VERSION == 2, "Update code");
// LODs // LODs
stream.Write((byte)LODs.Count()); stream.Write((byte)LODs.Count());
@@ -727,7 +727,7 @@ bool SkinnedModel::SaveHeader(WriteStream& stream, const ModelData& modelData)
{ {
if (ModelBase::SaveHeader(stream, modelData)) if (ModelBase::SaveHeader(stream, modelData))
return true; return true;
static_assert(HeaderVersion == 2, "Update code"); static_assert(MODEL_HEADER_VERSION == 2, "Update code");
// LODs // LODs
stream.Write((byte)modelData.LODs.Count()); stream.Write((byte)modelData.LODs.Count());
@@ -788,7 +788,7 @@ bool SkinnedModel::SaveMesh(WriteStream& stream, const MeshBase* mesh) const
{ {
if (ModelBase::SaveMesh(stream, mesh)) if (ModelBase::SaveMesh(stream, mesh))
return true; return true;
static_assert(MeshVersion == 2, "Update code"); static_assert(MODEL_MESH_VERSION == 2, "Update code");
auto skinnedMesh = (const SkinnedMesh*)mesh; auto skinnedMesh = (const SkinnedMesh*)mesh;
// Blend Shapes // Blend Shapes
@@ -802,7 +802,7 @@ bool SkinnedModel::SaveMesh(WriteStream& stream, const MeshBase* mesh) const
bool SkinnedModel::SaveMesh(WriteStream& stream, const ModelData& modelData, int32 lodIndex, int32 meshIndex) bool SkinnedModel::SaveMesh(WriteStream& stream, const ModelData& modelData, int32 lodIndex, int32 meshIndex)
{ {
static_assert(MeshVersion == 2, "Update code"); static_assert(MODEL_MESH_VERSION == 2, "Update code");
auto& mesh = modelData.LODs[lodIndex].Meshes[meshIndex]; auto& mesh = modelData.LODs[lodIndex].Meshes[meshIndex];
// Blend Shapes // Blend Shapes

View File

@@ -14,10 +14,8 @@
#include "Engine/Core/Collections/Dictionary.h" #include "Engine/Core/Collections/Dictionary.h"
#include "Engine/Utilities/StringConverter.h" #include "Engine/Utilities/StringConverter.h"
#include "Engine/Graphics/RenderTask.h" #include "Engine/Graphics/RenderTask.h"
#include "Engine/Graphics/PixelFormatSampler.h"
#include "Engine/Graphics/Textures/TextureData.h" #include "Engine/Graphics/Textures/TextureData.h"
// hack using TextureTool in Platform module -> TODO: move texture data sampling to texture data itself
#define COMPILE_WITH_TEXTURE_TOOL 1
#include "Engine/Tools/TextureTool/TextureTool.h"
#include "IncludeX11.h" #include "IncludeX11.h"
// ICCCM // ICCCM
@@ -888,13 +886,13 @@ void LinuxWindow::SetIcon(TextureData& icon)
const auto mipData = mip.Data.Get<Color32>(); const auto mipData = mip.Data.Get<Color32>();
const auto iconData = icon.GetData(0, 0); const auto iconData = icon.GetData(0, 0);
const Int2 iconSize(icon.Width, icon.Height); const Int2 iconSize(icon.Width, icon.Height);
const auto sampler = TextureTool::GetSampler(icon.Format); const auto sampler = PixelFormatSampler::GetSampler(icon.Format);
for (int32 y = 0; y < icon.Height; y++) for (int32 y = 0; y < icon.Height; y++)
{ {
for (int32 x = 0; x < icon.Width; x++) for (int32 x = 0; x < icon.Width; x++)
{ {
const Float2 uv((float)x / icon.Width, (float)y / icon.Height); const Float2 uv((float)x / icon.Width, (float)y / icon.Height);
Color color = TextureTool::SampleLinear(sampler, uv, iconData->Data.Get(), iconSize, iconData->RowPitch); Color color = sampler->SampleLinear(iconData->Data.Get(), uv, iconSize, iconData->RowPitch);
*(mipData + y * icon.Width + x) = Color32(color); *(mipData + y * icon.Width + x) = Color32(color);
} }
} }
@@ -932,13 +930,13 @@ void LinuxWindow::SetIcon(TextureData& icon)
const auto mipData = mip.Data.Get<Color32>(); const auto mipData = mip.Data.Get<Color32>();
const auto iconData = icon.GetData(0, 0); const auto iconData = icon.GetData(0, 0);
const Int2 iconSize(icon.Width, icon.Height); const Int2 iconSize(icon.Width, icon.Height);
const auto sampler = TextureTool::GetSampler(img.Format); const auto sampler = PixelFormatSampler::GetSampler(img.Format);
for (int32 y = 0; y < newHeight; y++) for (int32 y = 0; y < newHeight; y++)
{ {
for (int32 x = 0; x < newWidth; x++) for (int32 x = 0; x < newWidth; x++)
{ {
const Float2 uv((float)x / newWidth, (float)y / newHeight); const Float2 uv((float)x / newWidth, (float)y / newHeight);
Color color = TextureTool::SampleLinear(sampler, uv, iconData->Data.Get(), iconSize, iconData->RowPitch); Color color = sampler->SampleLinear(iconData->Data.Get(), uv, iconSize, iconData->RowPitch);
*(mipData + y * newWidth + x) = Color32(color); *(mipData + y * newWidth + x) = Color32(color);
} }
} }