Minor improvements

This commit is contained in:
Wojtek Figat
2023-10-14 18:03:21 +02:00
parent eb430b05be
commit e51aab0c56
3 changed files with 43 additions and 10 deletions

View File

@@ -318,7 +318,9 @@ void MeshData::BuildIndexBuffer()
}
const auto endTime = Platform::GetTimeSeconds();
LOG(Info, "Generated index buffer for mesh in {0}s ({1} vertices, {2} indices)", Utilities::RoundTo2DecimalPlaces(endTime - startTime), Positions.Count(), Indices.Count());
const double time = Utilities::RoundTo2DecimalPlaces(endTime - startTime);
if (time > 0.5f) // Don't log if generation was fast enough
LOG(Info, "Generated {3} for mesh in {0}s ({1} vertices, {2} indices)", time, vertexCount, Indices.Count(), TEXT("indices"));
}
void MeshData::FindPositions(const Float3& position, float epsilon, Array<int32>& result)
@@ -449,7 +451,9 @@ bool MeshData::GenerateNormals(float smoothingAngle)
}
const auto endTime = Platform::GetTimeSeconds();
LOG(Info, "Generated tangents for mesh in {0}s ({1} vertices, {2} indices)", Utilities::RoundTo2DecimalPlaces(endTime - startTime), vertexCount, indexCount);
const double time = Utilities::RoundTo2DecimalPlaces(endTime - startTime);
if (time > 0.5f) // Don't log if generation was fast enough
LOG(Info, "Generated {3} for mesh in {0}s ({1} vertices, {2} indices)", time, vertexCount, indexCount, TEXT("normals"));
return false;
}
@@ -685,7 +689,10 @@ bool MeshData::GenerateTangents(float smoothingAngle)
#endif
const auto endTime = Platform::GetTimeSeconds();
LOG(Info, "Generated tangents for mesh in {0}s ({1} vertices, {2} indices)", Utilities::RoundTo2DecimalPlaces(endTime - startTime), vertexCount, indexCount);
const double time = Utilities::RoundTo2DecimalPlaces(endTime - startTime);
if (time > 0.5f) // Don't log if generation was fast enough
LOG(Info, "Generated {3} for mesh in {0}s ({1} vertices, {2} indices)", time, vertexCount, indexCount, TEXT("tangents"));
return false;
}
@@ -872,7 +879,9 @@ void MeshData::ImproveCacheLocality()
Allocator::Free(piCandidates);
const auto endTime = Platform::GetTimeSeconds();
LOG(Info, "Cache relevant optimize for {0} vertices and {1} indices. Average output ACMR is {2}. Time: {3}s", vertexCount, indexCount, (float)iCacheMisses / indexCount / 3, Utilities::RoundTo2DecimalPlaces(endTime - startTime));
const double time = Utilities::RoundTo2DecimalPlaces(endTime - startTime);
if (time > 0.5f) // Don't log if generation was fast enough
LOG(Info, "Generated {3} for mesh in {0}s ({1} vertices, {2} indices)", time, vertexCount, indexCount, TEXT("optimized indices"));
}
float MeshData::CalculateTrianglesArea() const

View File

@@ -138,6 +138,29 @@ bool ShaderGraphValue::IsOne() const
}
}
bool ShaderGraphValue::IsLiteral() const
{
switch (Type)
{
case VariantType::Types::Bool:
case VariantType::Types::Int:
case VariantType::Types::Uint:
case VariantType::Types::Float:
if (Value.HasChars())
{
for (int32 i = 0; i < Value.Length(); i++)
{
const Char c = Value[i];
if (!StringUtils::IsDigit(c) && c != '.')
return false;
}
return true;
}
default:
return false;
}
}
ShaderGraphValue ShaderGraphValue::InitForZero(VariantType::Types type)
{
const Char* v;

View File

@@ -143,8 +143,7 @@ public:
/// <summary>
/// Returns true if value is valid.
/// </summary>
/// <returns>True if is valid, otherwise false.</returns>
bool IsValid() const
FORCE_INLINE bool IsValid() const
{
return Type != VariantType::Types::Null;
}
@@ -152,8 +151,7 @@ public:
/// <summary>
/// Returns true if value is invalid.
/// </summary>
/// <returns>True if is invalid, otherwise false.</returns>
bool IsInvalid() const
FORCE_INLINE bool IsInvalid() const
{
return Type == VariantType::Types::Null;
}
@@ -161,15 +159,18 @@ public:
/// <summary>
/// Checks if value contains static part with zero.
/// </summary>
/// <returns>True if contains zero number.</returns>
bool IsZero() const;
/// <summary>
/// Checks if value contains static part with one.
/// </summary>
/// <returns>True if contains one number.</returns>
bool IsOne() const;
/// <summary>
/// Checks if value is a compile-time constant literal (eg. int, bool or float).
/// </summary>
bool IsLiteral() const;
/// <summary>
/// Clears this instance.
/// </summary>