Add additional methods for layers.

This commit is contained in:
Chandler Cox
2025-04-07 11:14:33 -05:00
parent 368ef9185b
commit e17b96b2d6
4 changed files with 100 additions and 2 deletions

View File

@@ -59,11 +59,31 @@ void LargeWorlds::UpdateOrigin(Vector3& origin, const Vector3& position)
}
}
bool LayersMask::HasLayer(const StringView& layerName) const
bool LayersMask::HasLayer(const StringView& layerName)
{
return HasLayer(Level::GetLayerIndex(layerName));
}
LayersMask LayersMask::GetMask(StringView layerNames[])
{
LayersMask mask(0);
if (layerNames == nullptr)
return mask;
for (int i = 0; i < layerNames->Length(); i++)
{
StringView& layerName = layerNames[i];
// Ignore blank entries
if (layerName.Length() == 0)
continue;
int index = Level::GetLayerIndex(layerName);
if (index != -1 && !mask.HasLayer(index))
{
mask.Mask |= static_cast<uint32>(1 << index);
}
}
return mask;
}
enum class SceneEventType
{
OnSceneSaving = 0,
@@ -728,6 +748,18 @@ int32 Level::GetLayerIndex(const StringView& layer)
return result;
}
StringView Level::GetLayerName(const int32 layerIndex)
{
for (int32 i = 0; i < 32; i++)
{
if (i == layerIndex)
{
return Layers[i];
}
}
return TEXT("");
}
void Level::callActorEvent(ActorEventType eventType, Actor* a, Actor* b)
{
PROFILE_CPU();

View File

@@ -534,6 +534,13 @@ public:
/// </summary>
API_FUNCTION() static int32 GetLayerIndex(const StringView& layer);
/// <summary>
/// Gets the name of the layer based on the index.
/// </summary>
/// <param name="layerIndex">The index to find the layer string. 0 - 32.</param>
/// <returns>The layer string. Returns a blank string if index not found.</returns>
API_FUNCTION() static StringView GetLayerName(const int32 layerIndex);
private:
// Actor API
enum class ActorEventType