diff --git a/Content/Editor/CubeTexturePreviewMaterial.flax b/Content/Editor/CubeTexturePreviewMaterial.flax index 28860d3cc..828d620d2 100644 --- a/Content/Editor/CubeTexturePreviewMaterial.flax +++ b/Content/Editor/CubeTexturePreviewMaterial.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c04e226f6f8aa0de1049694ed813b0bd75864da76be2df43fb9db08162daadaa -size 31647 +oid sha256:28e5aaeb274e7590bc9ec13212e041d4d14baef562487507ea3621ec040c393b +size 31807 diff --git a/Content/Editor/Gizmo/Material.flax b/Content/Editor/Gizmo/Material.flax index d44e7590a..80d319a03 100644 --- a/Content/Editor/Gizmo/Material.flax +++ b/Content/Editor/Gizmo/Material.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8b8d0157ba0eb18a8ab9613b4429343b4f52fdeb14d1adc73c0682a75b6a7466 -size 32411 +oid sha256:fc18e2ff1f55cfc41a5b083843b11e1573ac7066bc58153262b2b61ea6105fce +size 32486 diff --git a/Content/Editor/TexturePreviewMaterial.flax b/Content/Editor/TexturePreviewMaterial.flax index d4ff0c0cd..b21daaa5a 100644 --- a/Content/Editor/TexturePreviewMaterial.flax +++ b/Content/Editor/TexturePreviewMaterial.flax @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2970eb5c0000661663a3cadffb1b8e67215f4425da24d5313e1d07fc44f0594d -size 10413 +oid sha256:52921ebe6efaf3a74950e817a4e2224ef2ef54e0698efc042ba9cd2c17693e54 +size 10568 diff --git a/Flax.flaxproj b/Flax.flaxproj index 7cebe1714..50fcaeda3 100644 --- a/Flax.flaxproj +++ b/Flax.flaxproj @@ -3,7 +3,7 @@ "Version": { "Major": 1, "Minor": 6, - "Build": 6343 + "Build": 6344 }, "Company": "Flax", "Copyright": "Copyright (c) 2012-2023 Wojciech Figat. All rights reserved.", diff --git a/Source/Editor/CustomEditors/Editors/ColorEditor.cs b/Source/Editor/CustomEditors/Editors/ColorEditor.cs index 2877fe29e..4edbde432 100644 --- a/Source/Editor/CustomEditors/Editors/ColorEditor.cs +++ b/Source/Editor/CustomEditors/Editors/ColorEditor.cs @@ -41,7 +41,17 @@ namespace FlaxEditor.CustomEditors.Editors } else { - element.CustomControl.Value = (Color)Values[0]; + var value = Values[0]; + if (value is Color asColor) + element.CustomControl.Value = asColor; + else if (value is Color32 asColor32) + element.CustomControl.Value = asColor32; + else if (value is Float4 asFloat4) + element.CustomControl.Value = asFloat4; + else if (value is Double4 asDouble4) + element.CustomControl.Value = (Float4)asDouble4; + else if (value is Vector4 asVector4) + element.CustomControl.Value = asVector4; } } } diff --git a/Source/Editor/CustomEditors/Editors/TagEditor.cs b/Source/Editor/CustomEditors/Editors/TagEditor.cs index 948663892..ab5fd5d1a 100644 --- a/Source/Editor/CustomEditors/Editors/TagEditor.cs +++ b/Source/Editor/CustomEditors/Editors/TagEditor.cs @@ -390,7 +390,6 @@ namespace FlaxEditor.CustomEditors.Editors if (addTagDropPanel.IsClosed) { - Debug.Log("Hit"); nameTextBox.BorderColor = Color.Transparent; nameTextBox.BorderSelectedColor = FlaxEngine.GUI.Style.Current.BackgroundSelected; return; diff --git a/Source/Editor/Surface/ContextMenu/VisjectCM.cs b/Source/Editor/Surface/ContextMenu/VisjectCM.cs index 3f74e4c07..bae62556e 100644 --- a/Source/Editor/Surface/ContextMenu/VisjectCM.cs +++ b/Source/Editor/Surface/ContextMenu/VisjectCM.cs @@ -363,7 +363,6 @@ namespace FlaxEditor.Surface.ContextMenu Profiler.BeginEvent("VisjectCM.RemoveGroup"); if (group.Archetypes.Count == 0) { - Debug.Log("Remove"); _groups.RemoveAt(i); group.Dispose(); } diff --git a/Source/Engine/Content/Assets/VisualScript.cpp b/Source/Engine/Content/Assets/VisualScript.cpp index b11a2af96..e292a0133 100644 --- a/Source/Engine/Content/Assets/VisualScript.cpp +++ b/Source/Engine/Content/Assets/VisualScript.cpp @@ -618,7 +618,7 @@ void VisualScriptExecutor::ProcessGroupFunction(Box* boxBase, Node* node, Value& // Return case 5: { - auto& scope = ThreadStacks.Get().Stack->Scope; + auto scope = ThreadStacks.Get().Stack->Scope; scope->FunctionReturn = tryGetValue(node->GetBox(1), Value::Zero); break; } @@ -634,7 +634,7 @@ void VisualScriptExecutor::ProcessGroupFunction(Box* boxBase, Node* node, Value& else { // Evaluate method parameter value from the current scope - auto& scope = ThreadStacks.Get().Stack->Scope; + auto scope = ThreadStacks.Get().Stack->Scope; int32 index = boxBase->ID - 1; if (index < scope->Parameters.Length()) value = scope->Parameters.Get()[index]; @@ -1138,7 +1138,7 @@ void VisualScriptExecutor::ProcessGroupFlow(Box* boxBase, Node* node, Value& val break; } int32 arrayIndex = 0; - for (; iteratorIndex < scope->ReturnedValues.Count(); arrayIndex++) + for (; arrayIndex < scope->ReturnedValues.Count(); arrayIndex++) { const auto& e = scope->ReturnedValues[arrayIndex]; if (e.NodeId == node->ID && e.BoxId == 1) diff --git a/Source/Engine/Core/Types/String.cpp b/Source/Engine/Core/Types/String.cpp index 3de255039..e53f04af7 100644 --- a/Source/Engine/Core/Types/String.cpp +++ b/Source/Engine/Core/Types/String.cpp @@ -113,6 +113,7 @@ void String::Append(const char* chars, int32 count) Platform::MemoryCopy(_data, oldData, oldLength * sizeof(Char)); StringUtils::ConvertANSI2UTF16(chars, _data + oldLength, count, _length); + _length += oldLength; _data[_length] = 0; Platform::Free(oldData); diff --git a/Source/Engine/Engine/NativeInterop.Marshallers.cs b/Source/Engine/Engine/NativeInterop.Marshallers.cs index 0a23bfcbd..2e3bc9183 100644 --- a/Source/Engine/Engine/NativeInterop.Marshallers.cs +++ b/Source/Engine/Engine/NativeInterop.Marshallers.cs @@ -399,7 +399,7 @@ namespace FlaxEngine.Interop } numElements = managed.Length; ManagedArray managedArray = ManagedArray.AllocatePooledArray(managed.Length); - return (TUnmanagedElement*)ManagedHandle.ToIntPtr(managedArray, GCHandleType.Weak); + return (TUnmanagedElement*)ManagedHandle.ToIntPtr(managedArray, GCHandleType.Normal); } public static ReadOnlySpan GetManagedValuesSource(T[] managed) => managed; diff --git a/Source/Engine/Engine/NativeInterop.Unmanaged.cs b/Source/Engine/Engine/NativeInterop.Unmanaged.cs index d4a8d44f8..17b8b73af 100644 --- a/Source/Engine/Engine/NativeInterop.Unmanaged.cs +++ b/Source/Engine/Engine/NativeInterop.Unmanaged.cs @@ -770,6 +770,13 @@ namespace FlaxEngine.Interop field.field.SetValue(fieldOwner, value); } + [UnmanagedCallersOnly] + internal static int FieldGetOffset(ManagedHandle fieldHandle) + { + FieldHolder field = Unsafe.As(fieldHandle.Target); + return (int)Marshal.OffsetOf(field.field.DeclaringType, field.field.Name); + } + [UnmanagedCallersOnly] internal static void FieldGetValue(ManagedHandle fieldOwnerHandle, ManagedHandle fieldHandle, IntPtr valuePtr) { @@ -778,6 +785,15 @@ namespace FlaxEngine.Interop field.toNativeMarshaller(field.field, fieldOwner, valuePtr, out int fieldOffset); } + [UnmanagedCallersOnly] + internal static IntPtr FieldGetValueBoxed(ManagedHandle fieldOwnerHandle, ManagedHandle fieldHandle) + { + object fieldOwner = fieldOwnerHandle.Target; + FieldHolder field = Unsafe.As(fieldHandle.Target); + object fieldValue = field.field.GetValue(fieldOwner); + return Invoker.MarshalReturnValueGeneric(field.field.FieldType, fieldValue); + } + [UnmanagedCallersOnly] internal static void WriteArrayReference(ManagedHandle arrayHandle, IntPtr valueHandle, int index) { @@ -924,7 +940,7 @@ namespace FlaxEngine.Interop if (nativeType.IsClass) size = sizeof(IntPtr); else - size = Marshal.SizeOf(nativeType); + size = GetTypeSize(nativeType); return size; } diff --git a/Source/Engine/Engine/NativeInterop.cs b/Source/Engine/Engine/NativeInterop.cs index e82cb3858..acfd7181b 100644 --- a/Source/Engine/Engine/NativeInterop.cs +++ b/Source/Engine/Engine/NativeInterop.cs @@ -1095,7 +1095,10 @@ namespace FlaxEngine.Interop { try { - size = Marshal.SizeOf(type); + var marshalType = type; + if (type.IsEnum) + marshalType = type.GetEnumUnderlyingType(); + size = Marshal.SizeOf(marshalType); } catch { diff --git a/Source/Engine/Level/Actor.cpp b/Source/Engine/Level/Actor.cpp index 67d84b81d..08fb77223 100644 --- a/Source/Engine/Level/Actor.cpp +++ b/Source/Engine/Level/Actor.cpp @@ -1337,6 +1337,20 @@ Actor* Actor::FindActor(const MClass* type, const StringView& name) const return nullptr; } +Actor* Actor::FindActor(const MClass* type, const Tag& tag) const +{ + CHECK_RETURN(type, nullptr); + if (GetClass()->IsSubClassOf(type) && HasTag(tag)) + return const_cast(this); + for (auto child : Children) + { + const auto actor = child->FindActor(type, tag); + if (actor) + return actor; + } + return nullptr; +} + Script* Actor::FindScript(const MClass* type) const { CHECK_RETURN(type, nullptr); diff --git a/Source/Engine/Level/Actor.cs b/Source/Engine/Level/Actor.cs index 957d09c7a..661b350cb 100644 --- a/Source/Engine/Level/Actor.cs +++ b/Source/Engine/Level/Actor.cs @@ -269,6 +269,17 @@ namespace FlaxEngine { return FindActor(typeof(T), name) as T; } + + /// + /// Tries to find actor of the given type and tag in this actor hierarchy (checks this actor and all children hierarchy). + /// + /// A tag on the object. + /// Type of the object. + /// Actor instance if found, null otherwise. + public T FindActor(Tag tag) where T : Actor + { + return FindActor(typeof(T), tag) as T; + } /// /// Searches for all actors of a specific type in this actor children list. diff --git a/Source/Engine/Level/Actor.h b/Source/Engine/Level/Actor.h index fb9fb0848..510bc9eb8 100644 --- a/Source/Engine/Level/Actor.h +++ b/Source/Engine/Level/Actor.h @@ -739,6 +739,14 @@ public: /// Actor instance if found, null otherwise. API_FUNCTION() Actor* FindActor(API_PARAM(Attributes="TypeReference(typeof(Actor))") const MClass* type, const StringView& name) const; + /// + /// Tries to find the actor of the given type and tag in this actor hierarchy. + /// + /// Type of the actor to search for. Includes any actors derived from the type. + /// The tag of the actor to search for. + /// Actor instance if found, null otherwise. + API_FUNCTION() Actor* FindActor(API_PARAM(Attributes="TypeReference(typeof(Actor))") const MClass* type, const Tag& tag) const; + /// /// Tries to find the actor of the given type in this actor hierarchy (checks this actor and all children hierarchy). /// @@ -759,6 +767,17 @@ public: { return (T*)FindActor(T::GetStaticClass(), name); } + + /// + /// Tries to find the actor of the given type and tag in this actor hierarchy (checks this actor and all children hierarchy). + /// + /// The tag of the actor to search for. + /// Actor instance if found, null otherwise. + template + FORCE_INLINE T* FindActor(const Tag& tag) const + { + return (T*)FindActor(T::GetStaticClass(), tag); + } /// /// Tries to find the script of the given type in this actor hierarchy (checks this actor and all children hierarchy). diff --git a/Source/Engine/Level/Level.cpp b/Source/Engine/Level/Level.cpp index ab8a9bbfe..587d20331 100644 --- a/Source/Engine/Level/Level.cpp +++ b/Source/Engine/Level/Level.cpp @@ -726,116 +726,6 @@ int32 Level::GetLayerIndex(const StringView& layer) return result; } -Actor* FindActorRecursive(Actor* node, const Tag& tag) -{ - if (node->HasTag(tag)) - return node; - Actor* result = nullptr; - for (Actor* child : node->Children) - { - result = FindActorRecursive(child, tag); - if (result) - break; - } - return result; -} - -void FindActorsRecursive(Actor* node, const Tag& tag, const bool activeOnly, Array& result) -{ - if (activeOnly && !node->GetIsActive()) - return; - if (node->HasTag(tag)) - result.Add(node); - for (Actor* child : node->Children) - FindActorsRecursive(child, tag, activeOnly, result); -} - -void FindActorsRecursiveByParentTags(Actor* node, const Array& tags, const bool activeOnly, Array& result) -{ - if (activeOnly && !node->GetIsActive()) - return; - for (Tag tag : tags) - { - if (node->HasTag(tag)) - { - result.Add(node); - break; - } - } - for (Actor* child : node->Children) - FindActorsRecursiveByParentTags(child, tags, activeOnly, result); -} - -Actor* Level::FindActor(const Tag& tag, Actor* root) -{ - PROFILE_CPU(); - if (root) - return FindActorRecursive(root, tag); - Actor* result = nullptr; - for (Scene* scene : Scenes) - { - result = FindActorRecursive(scene, tag); - if (result) - break; - } - return result; -} - -void FindActorRecursive(Actor* node, const Tag& tag, Array& result) -{ - if (node->HasTag(tag)) - result.Add(node); - for (Actor* child : node->Children) - FindActorRecursive(child, tag, result); -} - -Array Level::FindActors(const Tag& tag, const bool activeOnly, Actor* root) -{ - PROFILE_CPU(); - Array result; - if (root) - { - FindActorsRecursive(root, tag, activeOnly, result); - } - else - { - ScopeLock lock(ScenesLock); - for (Scene* scene : Scenes) - FindActorsRecursive(scene, tag, activeOnly, result); - } - return result; -} - -Array Level::FindActorsByParentTag(const Tag& parentTag, const bool activeOnly, Actor* root) -{ - PROFILE_CPU(); - Array result; - const Array subTags = Tags::GetSubTags(parentTag); - - if (subTags.Count() == 0) - { - return result; - } - if (subTags.Count() == 1) - { - result = FindActors(subTags[0], activeOnly, root); - return result; - } - - if (root) - { - FindActorsRecursiveByParentTags(root, subTags, activeOnly, result); - } - else - { - ScopeLock lock(ScenesLock); - for (Scene* scene : Scenes) - FindActorsRecursiveByParentTags(scene, subTags, activeOnly, result); - } - - return result; -} - void Level::callActorEvent(ActorEventType eventType, Actor* a, Actor* b) { PROFILE_CPU(); @@ -1505,6 +1395,143 @@ Actor* Level::FindActor(const MClass* type, const StringView& name) return result; } +Actor* FindActorRecursive(Actor* node, const Tag& tag) +{ + if (node->HasTag(tag)) + return node; + Actor* result = nullptr; + for (Actor* child : node->Children) + { + result = FindActorRecursive(child, tag); + if (result) + break; + } + return result; +} + +Actor* FindActorRecursiveByType(Actor* node, const MClass* type, const Tag& tag) +{ + CHECK_RETURN(type, nullptr); + if (node->HasTag(tag) && node->GetClass()->IsSubClassOf(type)) + return node; + Actor* result = nullptr; + for (Actor* child : node->Children) + { + result = FindActorRecursiveByType(child, type, tag); + if (result) + break; + } + return result; +} + +void FindActorsRecursive(Actor* node, const Tag& tag, const bool activeOnly, Array& result) +{ + if (activeOnly && !node->GetIsActive()) + return; + if (node->HasTag(tag)) + result.Add(node); + for (Actor* child : node->Children) + FindActorsRecursive(child, tag, activeOnly, result); +} + +void FindActorsRecursiveByParentTags(Actor* node, const Array& tags, const bool activeOnly, Array& result) +{ + if (activeOnly && !node->GetIsActive()) + return; + for (Tag tag : tags) + { + if (node->HasTag(tag)) + { + result.Add(node); + break; + } + } + for (Actor* child : node->Children) + FindActorsRecursiveByParentTags(child, tags, activeOnly, result); +} + +Actor* Level::FindActor(const Tag& tag, Actor* root) +{ + PROFILE_CPU(); + if (root) + return FindActorRecursive(root, tag); + Actor* result = nullptr; + for (Scene* scene : Scenes) + { + result = FindActorRecursive(scene, tag); + if (result) + break; + } + return result; +} + +Actor* Level::FindActor(const MClass* type, const Tag& tag, Actor* root) +{ + CHECK_RETURN(type, nullptr); + if (root) + return FindActorRecursiveByType(root, type, tag); + Actor* result = nullptr; + ScopeLock lock(ScenesLock); + for (int32 i = 0; result == nullptr && i < Scenes.Count(); i++) + result = Scenes[i]->FindActor(type, tag); + return result; +} + +void FindActorRecursive(Actor* node, const Tag& tag, Array& result) +{ + if (node->HasTag(tag)) + result.Add(node); + for (Actor* child : node->Children) + FindActorRecursive(child, tag, result); +} + +Array Level::FindActors(const Tag& tag, const bool activeOnly, Actor* root) +{ + PROFILE_CPU(); + Array result; + if (root) + { + FindActorsRecursive(root, tag, activeOnly, result); + } + else + { + ScopeLock lock(ScenesLock); + for (Scene* scene : Scenes) + FindActorsRecursive(scene, tag, activeOnly, result); + } + return result; +} + +Array Level::FindActorsByParentTag(const Tag& parentTag, const bool activeOnly, Actor* root) +{ + PROFILE_CPU(); + Array result; + const Array subTags = Tags::GetSubTags(parentTag); + + if (subTags.Count() == 0) + { + return result; + } + if (subTags.Count() == 1) + { + result = FindActors(subTags[0], activeOnly, root); + return result; + } + + if (root) + { + FindActorsRecursiveByParentTags(root, subTags, activeOnly, result); + } + else + { + ScopeLock lock(ScenesLock); + for (Scene* scene : Scenes) + FindActorsRecursiveByParentTags(scene, subTags, activeOnly, result); + } + + return result; +} + Script* Level::FindScript(const MClass* type) { CHECK_RETURN(type, nullptr); diff --git a/Source/Engine/Level/Level.cs b/Source/Engine/Level/Level.cs index c38b287ca..1e8524f2c 100644 --- a/Source/Engine/Level/Level.cs +++ b/Source/Engine/Level/Level.cs @@ -77,6 +77,18 @@ namespace FlaxEngine { return FindActor(typeof(T), name) as T; } + + /// + /// Tries to find actor of the given type and tag in a root actor or all loaded scenes. + /// + /// A tag on the object. + /// The custom root actor to start searching from (hierarchical), otherwise null to search all loaded scenes. + /// Type of the object. + /// Found actor or null. + public static T FindActor(Tag tag, Actor root = null) where T : Actor + { + return FindActor(typeof(T), tag, root) as T; + } /// /// Tries to find actor with the given ID in all loaded scenes. It's very fast O(1) lookup. diff --git a/Source/Engine/Level/Level.h b/Source/Engine/Level/Level.h index 9a041bda9..1f0acda2d 100644 --- a/Source/Engine/Level/Level.h +++ b/Source/Engine/Level/Level.h @@ -371,6 +371,41 @@ public: /// Actor instance if found, null otherwise. API_FUNCTION() static Actor* FindActor(API_PARAM(Attributes="TypeReference(typeof(Actor))") const MClass* type, const StringView& name); + /// + /// Tries to find the actor with the given tag (returns the first one found). + /// + /// The tag of the actor to search for. + /// The custom root actor to start searching from (hierarchical), otherwise null to search all loaded scenes. + /// Found actor or null. + API_FUNCTION() static Actor* FindActor(const Tag& tag, Actor* root = nullptr); + + /// + /// Tries to find the actor of the given type and tag in all the loaded scenes. + /// + /// Type of the actor to search for. Includes any actors derived from the type. + /// The tag of the actor to search for. + /// The custom root actor to start searching from (hierarchical), otherwise null to search all loaded scenes. + /// Actor instance if found, null otherwise. + API_FUNCTION() static Actor* FindActor(API_PARAM(Attributes="TypeReference(typeof(Actor))") const MClass* type, const Tag& tag, Actor* root = nullptr); + + /// + /// Tries to find the actors with the given tag (returns all found). + /// + /// The tag of the actor to search for. + /// Find only active actors. + /// The custom root actor to start searching from (hierarchical), otherwise null to search all loaded scenes. + /// Found actors or empty if none. + API_FUNCTION() static Array FindActors(const Tag& tag, const bool activeOnly = false, Actor* root = nullptr); + + /// + /// Search actors using a parent parentTag. + /// + /// The tag to search actors with subtags belonging to this tag + /// Find only active actors. + /// The custom root actor to start searching from (hierarchical), otherwise null to search all loaded scenes. + /// Returns all actors that have subtags belonging to the given parent parentTag + API_FUNCTION() static Array FindActorsByParentTag(const Tag& parentTag, const bool activeOnly = false, Actor* root = nullptr); + /// /// Tries to find the actor of the given type in all the loaded scenes. /// @@ -392,6 +427,18 @@ public: return (T*)FindActor(T::GetStaticClass(), name); } + /// + /// Tries to find the actor of the given type and tag in a root actor or all the loaded scenes. + /// The tag of the actor to search for. + /// The custom root actor to start searching from (hierarchical), otherwise null to search all loaded scenes. + /// + /// Actor instance if found, null otherwise. + template + FORCE_INLINE static T* FindActor(const Tag& tag, Actor* root = nullptr) + { + return (T*)FindActor(T::GetStaticClass(), tag, root); + } + /// /// Tries to find the script of the given type in all the loaded scenes. /// @@ -481,33 +528,6 @@ public: /// API_FUNCTION() static int32 GetLayerIndex(const StringView& layer); -public: - /// - /// Tries to find the actor with the given tag (returns the first one found). - /// - /// The tag of the actor to search for. - /// The custom root actor to start searching from (hierarchical), otherwise null to search all loaded scenes. - /// Found actor or null. - API_FUNCTION() static Actor* FindActor(const Tag& tag, Actor* root = nullptr); - - /// - /// Tries to find the actors with the given tag (returns all found). - /// - /// The tag of the actor to search for. - /// Find only active actors. - /// The custom root actor to start searching from (hierarchical), otherwise null to search all loaded scenes. - /// Found actors or empty if none. - API_FUNCTION() static Array FindActors(const Tag& tag, const bool activeOnly = false, Actor* root = nullptr); - - /// - /// Search actors using a parent parentTag. - /// - /// The tag to search actors with subtags belonging to this tag - /// Find only active actors. - /// The custom root actor to start searching from (hierarchical), otherwise null to search all loaded scenes. - /// Returns all actors that have subtags belonging to the given parent parentTag - API_FUNCTION() static Array FindActorsByParentTag(const Tag& parentTag, const bool activeOnly = false, Actor* root = nullptr); - private: // Actor API enum class ActorEventType diff --git a/Source/Engine/Level/Scene/SceneRendering.cpp b/Source/Engine/Level/Scene/SceneRendering.cpp index b75cd6851..48420ed49 100644 --- a/Source/Engine/Level/Scene/SceneRendering.cpp +++ b/Source/Engine/Level/Scene/SceneRendering.cpp @@ -157,14 +157,16 @@ void SceneRendering::UpdateActor(Actor* a, int32& key) const int32 category = a->_drawCategory; ScopeLock lock(Locker); auto& list = Actors[category]; - if (list.IsEmpty()) + if (list.Count() <= key) // Ignore invalid key softly return; auto& e = list[key]; - ASSERT_LOW_LAYER(a == e.Actor); - for (auto* listener : _listeners) - listener->OnSceneRenderingUpdateActor(a, e.Bounds); - e.LayerMask = a->GetLayerMask(); - e.Bounds = a->GetSphere(); + if (e.Actor == a) + { + for (auto* listener : _listeners) + listener->OnSceneRenderingUpdateActor(a, e.Bounds); + e.LayerMask = a->GetLayerMask(); + e.Bounds = a->GetSphere(); + } } void SceneRendering::RemoveActor(Actor* a, int32& key) @@ -172,14 +174,16 @@ void SceneRendering::RemoveActor(Actor* a, int32& key) const int32 category = a->_drawCategory; ScopeLock lock(Locker); auto& list = Actors[category]; - if (list.HasItems()) + if (list.Count() > key) // Ignore invalid key softly (eg. list after batch clear during scene unload) { - auto& e = list[key]; - ASSERT_LOW_LAYER(a == e.Actor); - for (auto* listener : _listeners) - listener->OnSceneRenderingRemoveActor(a); - e.Actor = nullptr; - e.LayerMask = 0; + auto& e = list.Get()[key]; + if (e.Actor == a) + { + for (auto* listener : _listeners) + listener->OnSceneRenderingRemoveActor(a); + e.Actor = nullptr; + e.LayerMask = 0; + } } key = -1; } diff --git a/Source/Engine/Platform/Base/WindowBase.cpp b/Source/Engine/Platform/Base/WindowBase.cpp index e2460e373..5cff76361 100644 --- a/Source/Engine/Platform/Base/WindowBase.cpp +++ b/Source/Engine/Platform/Base/WindowBase.cpp @@ -125,6 +125,7 @@ WindowBase::~WindowBase() { ASSERT(!RenderTask); ASSERT(!_swapChain); + WindowsManager::Unregister((Window*)this); } bool WindowBase::IsMain() const diff --git a/Source/Engine/Platform/Base/WindowsManager.cpp b/Source/Engine/Platform/Base/WindowsManager.cpp index ed2106cf5..0d58008d8 100644 --- a/Source/Engine/Platform/Base/WindowsManager.cpp +++ b/Source/Engine/Platform/Base/WindowsManager.cpp @@ -25,7 +25,6 @@ WindowsManagerService WindowsManagerServiceInstance; Window* WindowsManager::GetByNativePtr(void* handle) { Window* result = nullptr; - WindowsLocker.Lock(); for (int32 i = 0; i < Windows.Count(); i++) { @@ -36,7 +35,6 @@ Window* WindowsManager::GetByNativePtr(void* handle) } } WindowsLocker.Unlock(); - return result; } @@ -61,7 +59,7 @@ void WindowsManagerService::Update() // Update windows const float deltaTime = Time::Update.UnscaledDeltaTime.GetTotalSeconds(); WindowsManager::WindowsLocker.Lock(); - for (auto& win : WindowsManager::Windows) + for (Window* win : WindowsManager::Windows) { if (win && win->IsVisible()) win->OnUpdate(deltaTime); @@ -74,7 +72,7 @@ void WindowsManagerService::Dispose() // Close remaining windows WindowsManager::WindowsLocker.Lock(); auto windows = WindowsManager::Windows; - for (auto& win : windows) + for (Window* win : windows) { win->Close(ClosingReason::EngineExit); } diff --git a/Source/Engine/Platform/Win32/Win32StringUtils.cpp b/Source/Engine/Platform/Win32/Win32StringUtils.cpp index 2a9bcf174..ea1eb8fe9 100644 --- a/Source/Engine/Platform/Win32/Win32StringUtils.cpp +++ b/Source/Engine/Platform/Win32/Win32StringUtils.cpp @@ -182,7 +182,7 @@ const char* StringUtils::Find(const char* str, const char* toFind) void StringUtils::ConvertANSI2UTF16(const char* from, Char* to, int32 fromLength, int32& toLength) { if (fromLength) - toLength = mbstowcs(to, from, fromLength); + toLength = (int32)mbstowcs(to, from, fromLength); else toLength = 0; } diff --git a/Source/Engine/Scripting/Runtime/DotNet.cpp b/Source/Engine/Scripting/Runtime/DotNet.cpp index 246c1620f..8d75d7a95 100644 --- a/Source/Engine/Scripting/Runtime/DotNet.cpp +++ b/Source/Engine/Scripting/Runtime/DotNet.cpp @@ -1163,8 +1163,8 @@ MType* MField::GetType() const int32 MField::GetOffset() const { - MISSING_CODE("TODO: MField::GetOffset"); // TODO: MField::GetOffset - return 0; + static void* FieldGetOffsetPtr = GetStaticMethodPointer(TEXT("FieldGetOffset")); + return CallStaticMethod(FieldGetOffsetPtr, _handle); } void MField::GetValue(MObject* instance, void* result) const @@ -1175,8 +1175,8 @@ void MField::GetValue(MObject* instance, void* result) const MObject* MField::GetValueBoxed(MObject* instance) const { - MISSING_CODE("TODO: MField::GetValueBoxed"); // TODO: MField::GetValueBoxed - return nullptr; + static void* FieldGetValueBoxedPtr = GetStaticMethodPointer(TEXT("FieldGetValueBoxed")); + return CallStaticMethod(FieldGetValueBoxedPtr, instance, _handle); } void MField::SetValue(MObject* instance, void* value) const diff --git a/Source/Shaders/Common.hlsl b/Source/Shaders/Common.hlsl index 13d2ad28f..19ba3f861 100644 --- a/Source/Shaders/Common.hlsl +++ b/Source/Shaders/Common.hlsl @@ -26,6 +26,7 @@ #define FEATURE_LEVEL_ES3_1 2 #define FEATURE_LEVEL_SM4 3 #define FEATURE_LEVEL_SM5 4 +#define FEATURE_LEVEL_SM6 5 #if !defined(FEATURE_LEVEL) #error "Invalid platform defines" #endif diff --git a/Source/Tools/Flax.Build/Build/DotNet/DotNetSdk.cs b/Source/Tools/Flax.Build/Build/DotNet/DotNetSdk.cs index e8739a9fc..d3a706a43 100644 --- a/Source/Tools/Flax.Build/Build/DotNet/DotNetSdk.cs +++ b/Source/Tools/Flax.Build/Build/DotNet/DotNetSdk.cs @@ -199,7 +199,11 @@ namespace Flax.Build if (rid == ridFallback) ridFallback = ""; if (string.IsNullOrEmpty(dotnetPath)) - dotnetPath = "/usr/share/dotnet/"; + { + dotnetPath = "/usr/lib/dotnet/"; + if (!Directory.Exists(dotnetPath)) + dotnetPath = "/usr/share/dotnet/"; + } break; } case TargetPlatform.Mac: