Browse Source

Minor change

Panagiotis Christopoulos Charitos 2 years ago
parent
commit
73514a9c8c
2 changed files with 16 additions and 6 deletions
  1. 0 5
      AnKi/Scene/Components/LightComponent.cpp
  2. 16 1
      AnKi/Scene/Components/SceneComponent.h

+ 0 - 5
AnKi/Scene/Components/LightComponent.cpp

@@ -65,11 +65,6 @@ void LightComponent::setLightComponentType(LightComponentType type)
 	}
 	}
 
 
 	m_type = type;
 	m_type = type;
-
-	if(type != LightComponentType::kDirectional)
-	{
-		refreshUuid();
-	}
 }
 }
 
 
 Error LightComponent::update(SceneComponentUpdateInfo& info, Bool& updated)
 Error LightComponent::update(SceneComponentUpdateInfo& info, Bool& updated)

+ 16 - 1
AnKi/Scene/Components/SceneComponent.h

@@ -213,16 +213,31 @@ public:
 
 
 	static T* tryFindComponent(U32 uuid)
 	static T* tryFindComponent(U32 uuid)
 	{
 	{
+		ANKI_ASSERT(uuid != 0);
 		auto it = m_uuidToSceneComponent.find(uuid);
 		auto it = m_uuidToSceneComponent.find(uuid);
 		return (it != m_uuidToSceneComponent.getEnd()) ? *it : nullptr;
 		return (it != m_uuidToSceneComponent.getEnd()) ? *it : nullptr;
 	}
 	}
 
 
+	static T* tryFindComponentThreadSafe(U32 uuid)
+	{
+		LockGuard lock(m_uuidToSceneComponentLock);
+		return tryFindComponent(uuid);
+	}
+
 protected:
 protected:
 	/// @note Not thread-safe.
 	/// @note Not thread-safe.
 	void refreshUuid()
 	void refreshUuid()
 	{
 	{
+		refreshUuidCustom(SceneGraph::getSingleton().getNewUuid());
+	}
+
+	/// @note Not thread-safe.
+	void refreshUuidCustom(U32 customUuid)
+	{
+		ANKI_ASSERT(customUuid != 0);
+
 		const U32 oldUuid = m_uuid;
 		const U32 oldUuid = m_uuid;
-		m_uuid = SceneGraph::getSingleton().getNewUuid();
+		m_uuid = customUuid;
 
 
 		LockGuard lock(m_uuidToSceneComponentLock);
 		LockGuard lock(m_uuidToSceneComponentLock);
 		if(oldUuid != 0)
 		if(oldUuid != 0)