Merge branch 'optimize-actors-search' of https://github.com/RuanLucasGD/FlaxEngine into RuanLucasGD-optimize-actors-search

This commit is contained in:
Wojtek Figat
2024-02-18 20:31:04 +01:00
5 changed files with 40 additions and 25 deletions

View File

@@ -1386,14 +1386,16 @@ Actor* Actor::FindActor(const StringView& name) const
return result;
}
Actor* Actor::FindActor(const MClass* type) const
Actor* Actor::FindActor(const MClass* type, bool activeOnly) const
{
CHECK_RETURN(type, nullptr);
if (activeOnly && !_isActive)
return nullptr;
if (GetClass()->IsSubClassOf(type))
return const_cast<Actor*>(this);
for (auto child : Children)
{
const auto actor = child->FindActor(type);
const auto actor = child->FindActor(type, activeOnly);
if (actor)
return actor;
}
@@ -1414,14 +1416,16 @@ Actor* Actor::FindActor(const MClass* type, const StringView& name) const
return nullptr;
}
Actor* Actor::FindActor(const MClass* type, const Tag& tag) const
Actor* Actor::FindActor(const MClass* type, const Tag& tag, bool activeOnly) const
{
CHECK_RETURN(type, nullptr);
if (activeOnly && !_isActive)
return nullptr;
if (GetClass()->IsSubClassOf(type) && HasTag(tag))
return const_cast<Actor*>(this);
for (auto child : Children)
{
const auto actor = child->FindActor(type, tag);
const auto actor = child->FindActor(type, tag, activeOnly);
if (actor)
return actor;
}