Просмотр исходного кода

Add function to search for a node given its hashed name

Daniele Bartolini 12 лет назад
Родитель
Сommit
fab5cd96ad
2 измененных файлов с 10 добавлено и 3 удалено
  1. 7 3
      engine/world/SceneGraph.cpp
  2. 3 0
      engine/world/SceneGraph.h

+ 7 - 3
engine/world/SceneGraph.cpp

@@ -80,17 +80,21 @@ void SceneGraph::destroy()
 //-----------------------------------------------------------------------------
 int32_t SceneGraph::node(const char* name) const
 {
-	StringId32 name_hash = hash::murmur2_32(name, string::strlen(name), 0);
+	return node(hash::murmur2_32(name, string::strlen(name)));
+}
 
+//-----------------------------------------------------------------------------
+int32_t SceneGraph::node(StringId32 name) const
+{
 	for (uint32_t i = 0; i < m_num_nodes; i++)
 	{
-		if (m_names[i] == name_hash)
+		if (m_names[i] == name)
 		{
 			return i;
 		}
 	}
 
-	CE_ASSERT(false, "Node not found: '%s'", name);
+	CE_FATAL("Node not found");
 }
 
 //-----------------------------------------------------------------------------

+ 3 - 0
engine/world/SceneGraph.h

@@ -52,6 +52,9 @@ struct SceneGraph
 	/// Returns the index of the node with the given @a name
 	int32_t			node(const char* name) const;
 
+	/// @copydoc SceneGraph::node()
+	int32_t			node(StringId32 name) const;
+
 	/// Returns whether the graph has the node with the given @a name.
 	bool			has_node(const char* name) const;