Skip to content

Commit

Permalink
Fixes for anim graphs, animation bone weights, container POD correctness
Browse files Browse the repository at this point in the history
  • Loading branch information
jankrassnigg authored Jul 19, 2023
2 parents 4ee275c + 3425a38 commit 3c90cba
Show file tree
Hide file tree
Showing 48 changed files with 770 additions and 116 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ void ezAssetCurator::StartInitialize(const ezApplicationFileSystemConfig& cfg)

m_pAssetTableWriter = EZ_DEFAULT_NEW(ezAssetTableWriter, m_FileSystemConfig);

ezSharedPtr<ezDelegateTask<void>> pInitTask = EZ_DEFAULT_NEW(ezDelegateTask<void>, "AssetCuratorUpdateCache", [this]() {
ezSharedPtr<ezDelegateTask<void>> pInitTask = EZ_DEFAULT_NEW(ezDelegateTask<void>, "AssetCuratorUpdateCache", ezTaskNesting::Never, [this]() {
EZ_LOCK(m_CuratorMutex);

m_CuratorMutex.Unlock();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ void ezAssetDocument::InternalAfterSaveDocument()
{
ezUuid docGuid = GetGuid();

ezSharedPtr<ezDelegateTask<void>> pTask = EZ_DEFAULT_NEW(ezDelegateTask<void>, "TransformAfterSaveDocument", [docGuid]() {
ezSharedPtr<ezDelegateTask<void>> pTask = EZ_DEFAULT_NEW(ezDelegateTask<void>, "TransformAfterSaveDocument", ezTaskNesting::Never, [docGuid]() {
ezDocument* pDoc = ezDocumentManager::GetDocumentByGuid(docGuid);
if (pDoc == nullptr)
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ ezStatus ezAnimatedMeshAssetDocument::CreateMeshFromFile(ezAnimatedMeshAssetProp
opt.m_pMeshOutput = &desc;
opt.m_MeshNormalsPrecision = pProp->m_NormalPrecision;
opt.m_MeshTexCoordsPrecision = pProp->m_TexCoordPrecision;
//opt.m_RootTransform = CalculateTransformationMatrix(pProp);
opt.m_MeshBoneWeightPrecision = pProp->m_BoneWeightPrecision;
opt.m_bNormalizeWeights = pProp->m_bNormalizeWeights;
// opt.m_RootTransform = CalculateTransformationMatrix(pProp);

if (pImporter->Import(opt).Failed())
return ezStatus("Model importer was unable to read this asset.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ EZ_BEGIN_DYNAMIC_REFLECTED_TYPE(ezAnimatedMeshAssetProperties, 2, ezRTTIDefaultA
EZ_MEMBER_PROPERTY("RecalculateTangents", m_bRecalculateTrangents)->AddAttributes(new ezDefaultValueAttribute(true)),
EZ_ENUM_MEMBER_PROPERTY("NormalPrecision", ezMeshNormalPrecision, m_NormalPrecision),
EZ_ENUM_MEMBER_PROPERTY("TexCoordPrecision", ezMeshTexCoordPrecision, m_TexCoordPrecision),
EZ_ENUM_MEMBER_PROPERTY("BoneWeightPrecision", ezMeshBoneWeigthPrecision, m_BoneWeightPrecision),
EZ_MEMBER_PROPERTY("NormalizeWeights", m_bNormalizeWeights)->AddAttributes(new ezDefaultValueAttribute(true)),
EZ_MEMBER_PROPERTY("ImportMaterials", m_bImportMaterials)->AddAttributes(new ezDefaultValueAttribute(true)),
EZ_ARRAY_MEMBER_PROPERTY("Materials", m_Slots)->AddAttributes(new ezContainerAttribute(false, true, true)),
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ class ezAnimatedMeshAssetProperties : public ezReflectedClass

bool m_bRecalculateNormals = false;
bool m_bRecalculateTrangents = true;
bool m_bNormalizeWeights = false;
bool m_bImportMaterials = true;

ezEnum<ezMeshNormalPrecision> m_NormalPrecision;
ezEnum<ezMeshTexCoordPrecision> m_TexCoordPrecision;
ezEnum<ezMeshBoneWeigthPrecision> m_BoneWeightPrecision;

ezHybridArray<ezMaterialResourceSlot, 8> m_Slots;
};
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class ezMeshAssetProperties : public ezReflectedClass
ezEnum<ezBasisAxis> m_UpDir = ezBasisAxis::PositiveZ;
bool m_bFlipForwardDir = false;

ezMeshPrimitive::Enum m_PrimitiveType;
ezMeshPrimitive::Enum m_PrimitiveType = ezMeshPrimitive::Default;

bool m_bRecalculateNormals = false;
bool m_bRecalculateTrangents = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,15 @@ namespace ezMeshImportUtils
return ezString();
}

sFinalTextureName.Prepend("Embedded");
itTex.Value().GenerateFileName(sFinalTextureName);

ezStringBuilder sEmbededFile;
sEmbededFile = szImportTargetFolder;
sEmbededFile.AppendPath(sFinalTextureName);
sEmbededFile.ChangeFileExtension(itTex.Value().m_sFileFormatExtension);

// ezFileWriter out;
// if (out.Open(sEmbededFile).Succeeded())
//{
// out.WriteBytes(itTex.Value().m_RawData.GetPtr(), itTex.Value().m_RawData.GetCount()).AssertSuccess();
// }

relTexturePath = sEmbededFile;
}


ezStringBuilder newAssetPathAbs = szImportTargetFolder;
newAssetPathAbs.AppendPath(sFinalTextureName);
newAssetPathAbs.ChangeFileExtension("ezTextureAsset");
Expand Down Expand Up @@ -376,7 +368,9 @@ namespace ezMeshImportUtils
{
EZ_PROFILE_SCOPE("ImportMeshAssetMaterials");

const ezStringBuilder targetDirectory(szDocumentDirectory, "_data/");
ezStringBuilder targetDirectory = szDocumentDirectory;
targetDirectory.RemoveFileExtension();
targetDirectory.Append("_data/");
const ezStringBuilder sourceDirectory = ezPathUtils::GetFileDirectory(pImporter->GetImportOptions().m_sSourceFile);

ezStringBuilder tmp;
Expand Down Expand Up @@ -411,13 +405,11 @@ namespace ezMeshImportUtils
}

ezStringBuilder sFinalTextureName;
ezPathUtils::MakeValidFilename(itTex.Key().GetFileName(), '_', sFinalTextureName);
sFinalTextureName.Prepend("Embedded");
itTex.Value().GenerateFileName(sFinalTextureName);

ezStringBuilder sEmbededFile;
sEmbededFile = targetDirectory;
sEmbededFile.AppendPath(sFinalTextureName);
sEmbededFile.ChangeFileExtension(itTex.Value().m_sFileFormatExtension);

ezDeferredFileWriter out;
out.SetOutput(sEmbededFile, true);
Expand Down
2 changes: 1 addition & 1 deletion Code/Engine/Core/World/Implementation/World.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ EZ_END_STATIC_REFLECTED_TYPE;
ezWorld::ezWorld(ezWorldDesc& ref_desc)
: m_Data(ref_desc)
{
m_pUpdateTask = EZ_DEFAULT_NEW(ezDelegateTask<void>, "", ezMakeDelegate(&ezWorld::UpdateFromThread, this));
m_pUpdateTask = EZ_DEFAULT_NEW(ezDelegateTask<void>, "WorldUpdate", ezTaskNesting::Never, ezMakeDelegate(&ezWorld::UpdateFromThread, this));
m_Data.m_pCoordinateSystemProvider->m_pOwnerWorld = this;

ezStringBuilder sb = ref_desc.m_sName.GetString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,8 @@ void ezArrayBase<T, Derived>::SetCountUninitialized(ezUInt32 uiCount)
if (uiNewCount > uiOldCount)
{
static_cast<Derived*>(this)->Reserve(uiNewCount);
ezMemoryUtils::Construct(static_cast<Derived*>(this)->GetElementsPtr() + uiOldCount, uiNewCount - uiOldCount);
}
else if (uiNewCount < uiOldCount)
{
ezMemoryUtils::Destruct(static_cast<Derived*>(this)->GetElementsPtr() + uiNewCount, uiOldCount - uiNewCount);
// we already assert above that T is a POD type
// don't construct anything, leave the memory untouched
}

m_uiCount = uiCount;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,8 @@ template <typename T>
EZ_ALWAYS_INLINE void ezMemoryUtils::Destruct(T* pDestination, size_t uiCount, ezTypeIsPod)
{
// Nothing to do here. See Construct of for more info.

static_assert(std::is_trivially_destructible<T>::value != 0, "Class is declared as POD but has a non-trivial destructor. Remove the destructor or don't declare it as POD.");
}

template <typename T>
Expand Down
8 changes: 4 additions & 4 deletions Code/Engine/Foundation/Profiling/Implementation/Profiling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ ezResult ezProfilingSystem::ProfilingData::Write(ezStreamWriter& ref_outputStrea
for (const CPUScope& e : sortedScopes)
{
writer.BeginObject();
writer.AddVariableString("name", e.m_szName);
writer.AddVariableString("name", static_cast<const char*>(e.m_szName));
writer.AddVariableUInt32("pid", m_uiProcessID);
writer.AddVariableUInt64("tid", uiThreadId);
writer.AddVariableUInt64("ts", static_cast<ezUInt64>(e.m_BeginTime.GetMicroseconds()));
Expand All @@ -434,7 +434,7 @@ ezResult ezProfilingSystem::ProfilingData::Write(ezStreamWriter& ref_outputStrea
if (e.m_EndTime.IsPositive())
{
writer.BeginObject();
writer.AddVariableString("name", e.m_szName);
writer.AddVariableString("name", static_cast<const char*>(e.m_szName));
writer.AddVariableUInt32("pid", m_uiProcessID);
writer.AddVariableUInt64("tid", uiThreadId);
writer.AddVariableUInt64("ts", static_cast<ezUInt64>(e.m_EndTime.GetMicroseconds()));
Expand Down Expand Up @@ -499,15 +499,15 @@ ezResult ezProfilingSystem::ProfilingData::Write(ezStreamWriter& ref_outputStrea
const auto& e = sortedGpuScopes[i];

writer.BeginObject();
writer.AddVariableString("name", e.m_szName);
writer.AddVariableString("name", static_cast<const char*>(e.m_szName));
writer.AddVariableUInt32("pid", m_uiProcessID);
writer.AddVariableUInt64("tid", gpuIndex);
writer.AddVariableUInt64("ts", static_cast<ezUInt64>(e.m_BeginTime.GetMicroseconds()));
writer.AddVariableString("ph", "B");
writer.EndObject();

writer.BeginObject();
writer.AddVariableString("name", e.m_szName);
writer.AddVariableString("name", static_cast<const char*>(e.m_szName));
writer.AddVariableUInt32("pid", m_uiProcessID);
writer.AddVariableUInt64("tid", gpuIndex);
writer.AddVariableUInt64("ts", static_cast<ezUInt64>(e.m_EndTime.GetMicroseconds()));
Expand Down
15 changes: 15 additions & 0 deletions Code/Engine/Foundation/SimdMath/Implementation/SimdMat4f_inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ EZ_ALWAYS_INLINE void ezSimdMat4f::SetIdentity()
m_col3.Set(0, 0, 0, 1);
}

EZ_ALWAYS_INLINE void ezSimdMat4f::SetZero()
{
m_col0.SetZero();
m_col1.SetZero();
m_col2.SetZero();
m_col3.SetZero();
}

// static
EZ_ALWAYS_INLINE ezSimdMat4f ezSimdMat4f::IdentityMatrix()
{
Expand All @@ -68,6 +76,13 @@ EZ_ALWAYS_INLINE ezSimdMat4f ezSimdMat4f::IdentityMatrix()
return result;
}

EZ_ALWAYS_INLINE ezSimdMat4f ezSimdMat4f::ZeroMatrix()
{
ezSimdMat4f result;
result.SetZero();
return result;
}

EZ_ALWAYS_INLINE ezSimdMat4f ezSimdMat4f::GetTranspose() const
{
ezSimdMat4f result = *this;
Expand Down
6 changes: 6 additions & 0 deletions Code/Engine/Foundation/SimdMath/SimdMat4f.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,15 @@ class EZ_FOUNDATION_DLL ezSimdMat4f
/// \brief Sets all elements to zero, except the diagonal, which is set to one.
void SetIdentity(); // [tested]

/// \brief Sets all elements to zero.
void SetZero(); // [tested]

/// \brief Returns an Identity Matrix.
static ezSimdMat4f IdentityMatrix(); // [tested]

/// \brief Returns a Matrix where all elements are zero.
static ezSimdMat4f ZeroMatrix(); // [tested]

public:
/// \brief Transposes this matrix.
void Transpose(); // [tested]
Expand Down
2 changes: 2 additions & 0 deletions Code/Engine/Foundation/Strings/HashedString.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,10 @@ class EZ_FOUNDATION_DLL ezHashedString
/// \brief Moves the given ezHashedString.
ezHashedString(ezHashedString&& rhs); // [tested]

#if EZ_ENABLED(EZ_HASHED_STRING_REF_COUNTING)
/// \brief Releases the reference to the internal data. Does NOT deallocate any data, even if this held the last reference to some string.
~ezHashedString();
#endif

/// \brief Copies the given ezHashedString.
void operator=(const ezHashedString& rhs); // [tested]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ inline ezHashedString::~ezHashedString()
m_Data.Value().m_iRefCount.Decrement();
}
}
#else
EZ_FORCE_INLINE ezHashedString::~ezHashedString() = default;
#endif

inline void ezHashedString::operator=(const ezHashedString& rhs)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ const char* ezTranslatorMakeMoreReadable::Translate(const char* szString, ezUInt
continue;
}

if (IsNumber(uiPrev) != IsNumber(uiCur))
if (uiPrev != '[' && uiCur != ']' && IsNumber(uiPrev) != IsNumber(uiCur))
{
result.Append(" ");
result.Append(uiCur);
Expand Down
8 changes: 4 additions & 4 deletions Code/Engine/Foundation/Threading/DelegateTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ class ezDelegateTask final : public ezTask
public:
using FunctionType = ezDelegate<void(const T&)>;

ezDelegateTask(const char* szTaskName, FunctionType func, const T& param)
ezDelegateTask(const char* szTaskName, ezTaskNesting taskNesting, FunctionType func, const T& param)
{
m_Func = func;
m_param = param;
ConfigureTask(szTaskName, ezTaskNesting::Never);
ConfigureTask(szTaskName, taskNesting);
}

private:
Expand All @@ -29,10 +29,10 @@ class ezDelegateTask<void> final : public ezTask
public:
using FunctionType = ezDelegate<void()>;

ezDelegateTask(const char* szTaskName, FunctionType func)
ezDelegateTask(const char* szTaskName, ezTaskNesting taskNesting, FunctionType func)
{
m_Func = func;
ConfigureTask(szTaskName, ezTaskNesting::Never);
ConfigureTask(szTaskName, taskNesting);
}

private:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ ezGameApplication::ezGameApplication(const char* szAppName, const char* szProjec
: ezGameApplicationBase(szAppName)
, m_sAppProjectPath(szProjectPath)
{
m_pUpdateTask = EZ_DEFAULT_NEW(ezDelegateTask<void>, "", ezMakeDelegate(&ezGameApplication::UpdateWorldsAndExtractViews, this));
m_pUpdateTask = EZ_DEFAULT_NEW(ezDelegateTask<void>, "UpdateWorldsAndExtractViews", ezTaskNesting::Never, ezMakeDelegate(&ezGameApplication::UpdateWorldsAndExtractViews, this));
m_pUpdateTask->ConfigureTask("GameApplication.Update", ezTaskNesting::Maybe);

s_pGameApplicationInstance = this;
Expand Down
Loading

0 comments on commit 3c90cba

Please sign in to comment.