Merge remote-tracking branch 'origin/master' into 1.9
# Conflicts: # Source/Engine/UI/GUI/Common/Button.cs
This commit is contained in:
@@ -1,9 +1,16 @@
|
||||
// Copyright (c) 2012-2024 Wojciech Figat. All rights reserved.
|
||||
|
||||
#include "LogContext.h"
|
||||
#include "Engine/Core/Log.h"
|
||||
#include "Engine/Core/Types/Guid.h"
|
||||
#include "Engine/Core/Types/String.h"
|
||||
#include "Engine/Core/Types/StringBuilder.h"
|
||||
#include "Engine/Core/Collections/Array.h"
|
||||
#include "Engine/Scripting/Scripting.h"
|
||||
#include "Engine/Scripting/Script.h"
|
||||
#include "Engine/Content/Asset.h"
|
||||
#include "Engine/Content/Content.h"
|
||||
#include "Engine/Level/Actor.h"
|
||||
#include "Engine/Threading/ThreadLocal.h"
|
||||
|
||||
struct LogContextThreadData
|
||||
@@ -30,7 +37,7 @@ struct LogContextThreadData
|
||||
Count--;
|
||||
}
|
||||
|
||||
LogContextData Peek()
|
||||
LogContextData Peek() const
|
||||
{
|
||||
return Count > 0 ? Ptr[Count - 1] : LogContextData();
|
||||
}
|
||||
@@ -38,12 +45,58 @@ struct LogContextThreadData
|
||||
|
||||
ThreadLocal<LogContextThreadData> GlobalLogContexts;
|
||||
|
||||
String LogContext::GetInfo()
|
||||
void LogContext::Print(LogType verbosity)
|
||||
{
|
||||
LogContextData context = LogContext::Get();
|
||||
if (context.ObjectID != Guid::Empty)
|
||||
return String::Format(TEXT("(Loading source was {0})"), context.ObjectID);
|
||||
return String::Empty;
|
||||
auto& stack = GlobalLogContexts.Get();
|
||||
if (stack.Count == 0)
|
||||
return;
|
||||
const StringView indentation(TEXT(" "));
|
||||
StringBuilder msg;
|
||||
for (int32 index = (int32)stack.Count - 1; index >= 0; index--)
|
||||
{
|
||||
// Build call hierarchy via indentation
|
||||
msg.Clear();
|
||||
for (uint32 i = index; i < stack.Count; i++)
|
||||
msg.Append(indentation);
|
||||
|
||||
LogContextData& context = stack.Ptr[index];
|
||||
if (context.ObjectID != Guid::Empty)
|
||||
{
|
||||
// Object reference context
|
||||
msg.Append(TEXT(" Referenced by "));
|
||||
if (ScriptingObject* object = Scripting::TryFindObject(context.ObjectID))
|
||||
{
|
||||
const StringAnsiView typeName(object->GetType().Fullname);
|
||||
if (Asset* asset = ScriptingObject::Cast<Asset>(object))
|
||||
{
|
||||
msg.AppendFormat(TEXT("asset '{}' ({}, {})"), asset->GetPath(), asset->GetTypeName(), context.ObjectID);
|
||||
}
|
||||
else if (Actor* actor = ScriptingObject::Cast<Actor>(object))
|
||||
{
|
||||
msg.AppendFormat(TEXT("actor '{}' ({}, {})"), actor->GetNamePath(), String(typeName), context.ObjectID);
|
||||
}
|
||||
else if (Script* script = ScriptingObject::Cast<Script>(object))
|
||||
{
|
||||
msg.AppendFormat(TEXT("script '{}' ({}, {})"), script->GetNamePath(), String(typeName), context.ObjectID);
|
||||
}
|
||||
else
|
||||
{
|
||||
msg.AppendFormat(TEXT("object {} ({})"), String(typeName), context.ObjectID);
|
||||
}
|
||||
}
|
||||
else if (Asset* asset = Content::GetAsset(context.ObjectID))
|
||||
{
|
||||
msg.AppendFormat(TEXT("asset '{}' ({}, {})"), asset->GetPath(), asset->GetTypeName(), context.ObjectID);
|
||||
}
|
||||
else
|
||||
{
|
||||
msg.AppendFormat(TEXT("object {}"), context.ObjectID);
|
||||
}
|
||||
}
|
||||
|
||||
// Print message
|
||||
Log::Logger::Write(verbosity, msg.ToStringView());
|
||||
}
|
||||
}
|
||||
|
||||
void LogContext::Push(const Guid& id)
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Engine/Core/Log.h"
|
||||
#include "Engine/Core/Config.h"
|
||||
#include "Engine/Scripting/ScriptingType.h"
|
||||
|
||||
@@ -9,7 +10,7 @@ class String;
|
||||
struct Guid;
|
||||
|
||||
/// <summary>
|
||||
/// Log context data structure. Contains different kinds of context data for different situtations.
|
||||
/// Log context data structure. Contains different kinds of context data for different situations.
|
||||
/// </summary>
|
||||
API_STRUCT(NoDefault) struct FLAXENGINE_API LogContextData
|
||||
{
|
||||
@@ -54,10 +55,10 @@ API_CLASS(Static) class FLAXENGINE_API LogContext
|
||||
API_FUNCTION() static LogContextData Get();
|
||||
|
||||
/// <summary>
|
||||
/// Returns a string which represents the current log context on the stack.
|
||||
/// Prints the current log context to the log. Does nothing it
|
||||
/// </summary>
|
||||
/// <returns>The formatted string representing the current log context.</returns>
|
||||
API_FUNCTION() static String GetInfo();
|
||||
/// <param name="verbosity">The verbosity of the log.</param>
|
||||
API_FUNCTION() static void Print(LogType verbosity);
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -542,10 +542,8 @@ void Quaternion::RotationYawPitchRoll(float yaw, float pitch, float roll, Quater
|
||||
Quaternion Quaternion::GetRotationFromNormal(const Vector3& normal, const Transform& reference)
|
||||
{
|
||||
Float3 up = reference.GetUp();
|
||||
const float dot = Vector3::Dot(normal, up);
|
||||
const Real dot = Vector3::Dot(normal, up);
|
||||
if (Math::NearEqual(Math::Abs(dot), 1))
|
||||
{
|
||||
up = reference.GetRight();
|
||||
}
|
||||
return Quaternion::LookRotation(normal, up);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user