add optional parameter to find only active actors on Level.FindActorsByParentTag
This commit is contained in:
@@ -750,8 +750,10 @@ void FindActorsRecursive(Actor* node, const Tag& tag, const bool activeOnly, Arr
|
||||
FindActorsRecursive(child, tag, activeOnly, result);
|
||||
}
|
||||
|
||||
void FindActorsRecursiveByParentTags(Actor* node, const Array<Tag>& tags, Array<Actor*>& result)
|
||||
void FindActorsRecursiveByParentTags(Actor* node, const Array<Tag>& tags, const bool activeOnly, Array<Actor*>& result)
|
||||
{
|
||||
if (activeOnly && !node->GetIsActive())
|
||||
return;
|
||||
for (Tag tag : tags)
|
||||
{
|
||||
if (node->HasTag(tag))
|
||||
@@ -761,7 +763,7 @@ void FindActorsRecursiveByParentTags(Actor* node, const Array<Tag>& tags, Array<
|
||||
}
|
||||
}
|
||||
for (Actor* child : node->Children)
|
||||
FindActorsRecursiveByParentTags(child, tags, result);
|
||||
FindActorsRecursiveByParentTags(child, tags, activeOnly, result);
|
||||
}
|
||||
|
||||
Actor* Level::FindActor(const Tag& tag, Actor* root)
|
||||
@@ -804,7 +806,7 @@ Array<Actor*> Level::FindActors(const Tag& tag, const bool activeOnly, Actor* ro
|
||||
return result;
|
||||
}
|
||||
|
||||
Array<Actor*> Level::FindActorsByParentTag(const Tag& parentTag, Actor* root)
|
||||
Array<Actor*> Level::FindActorsByParentTag(const Tag& parentTag, const bool activeOnly, Actor* root)
|
||||
{
|
||||
PROFILE_CPU();
|
||||
Array<Actor*> result;
|
||||
@@ -816,19 +818,19 @@ Array<Actor*> Level::FindActorsByParentTag(const Tag& parentTag, Actor* root)
|
||||
}
|
||||
if (subTags.Count() == 1)
|
||||
{
|
||||
result = FindActors(subTags[0], root);
|
||||
result = FindActors(subTags[0], activeOnly, root);
|
||||
return result;
|
||||
}
|
||||
|
||||
if (root)
|
||||
{
|
||||
FindActorsRecursiveByParentTags(root, subTags, result);
|
||||
FindActorsRecursiveByParentTags(root, subTags, activeOnly, result);
|
||||
}
|
||||
else
|
||||
{
|
||||
ScopeLock lock(ScenesLock);
|
||||
for (Scene* scene : Scenes)
|
||||
FindActorsRecursiveByParentTags(scene, subTags, result);
|
||||
FindActorsRecursiveByParentTags(scene, subTags, activeOnly, result);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
@@ -503,9 +503,10 @@ public:
|
||||
/// Search actors using a parent parentTag.
|
||||
/// </summary>
|
||||
/// <param name="parentTag">The tag to search actors with subtags belonging to this tag</param>
|
||||
/// <param name="activeOnly">Find only active actors.</param>
|
||||
/// <param name="root">The custom root actor to start searching from (hierarchical), otherwise null to search all loaded scenes.</param>
|
||||
/// <returns>Returns all actors that have subtags belonging to the given parent parentTag</returns>
|
||||
API_FUNCTION() static Array<Actor*> FindActorsByParentTag(const Tag& parentTag, Actor* root = nullptr);
|
||||
API_FUNCTION() static Array<Actor*> FindActorsByParentTag(const Tag& parentTag, const bool activeOnly = false, Actor* root = nullptr);
|
||||
|
||||
private:
|
||||
// Actor API
|
||||
|
||||
Reference in New Issue
Block a user