Open 3D Engine SurfaceData Gem API Reference
24.09
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
|
#include <SurfacePointList.h>
Public Member Functions | |
AZ_CLASS_ALLOCATOR (SurfacePointList, AZ::SystemAllocator) | |
AZ_TYPE_INFO (SurfacePointList, "{DBA02848-2131-4279-BDEF-3581B76AB736}") | |
void | Clear () |
Clear the surface point list. | |
SurfacePointList (AZStd::span< const AzFramework::SurfaceData::SurfacePoint > surfacePoints) | |
void | StartListConstruction (AZStd::span< const AzFramework::SurfaceData::SurfacePoint > surfacePoints) |
void | StartListConstruction (AZStd::span< const AZ::Vector3 > inPositions, size_t maxPointsPerInput, AZStd::span< const SurfaceTag > filterTags) |
void | AddSurfacePoint (const AZ::EntityId &entityId, const AZ::Vector3 &inPosition, const AZ::Vector3 &position, const AZ::Vector3 &normal, const SurfaceTagWeights &weights) |
void | ModifySurfaceWeights (const SurfaceDataRegistryHandle &surfaceModifierHandle) |
void | EndListConstruction () |
bool | IsEmpty () const |
bool | IsEmpty (size_t inputPositionIndex) const |
size_t | GetSize () const |
size_t | GetSize (size_t inputPositionIndex) const |
size_t | GetInputPositionSize () const |
void | EnumeratePoints (AZStd::function< bool(size_t inputPositionIndex, const AZ::Vector3 &position, const AZ::Vector3 &normal, const SurfaceTagWeights &surfaceWeights)> pointCallback) const |
void | EnumeratePoints (size_t inputPositionIndex, AZStd::function< bool(const AZ::Vector3 &position, const AZ::Vector3 &normal, const SurfaceTagWeights &surfaceWeights)> pointCallback) const |
AzFramework::SurfaceData::SurfacePoint | GetHighestSurfacePoint (size_t inputPositionIndex) const |
AZ::Aabb | GetSurfacePointAabb () const |
Protected Member Functions | |
void | FilterPoints (AZStd::span< const SurfaceTag > desiredTags) |
size_t | GetInPositionIndexFromPosition (const AZ::Vector3 &inPosition) const |
size_t | GetSurfacePointStartIndexFromInPositionIndex (size_t inPositionIndex) const |
Protected Attributes | |
AZStd::span< const SurfaceTag > | m_filterTags |
AZStd::span< const AZ::Vector3 > | m_inputPositions |
size_t | m_inputPositionSize = 0 |
size_t | m_lastInputPositionIndex = 0 |
AZStd::vector< size_t > | m_numSurfacePointsPerInput |
AZ::Aabb | m_surfacePointBounds = AZ::Aabb::CreateNull() |
size_t | m_maxSurfacePointsPerInput = 0 |
bool | m_listIsBeingConstructed = false |
AZStd::vector< size_t > | m_sortedSurfacePointIndices |
AZStd::vector< AZ::Vector3 > | m_surfacePositionList |
AZStd::vector< AZ::Vector3 > | m_surfaceNormalList |
AZStd::vector< SurfaceTagWeights > | m_surfaceWeightsList |
AZStd::vector< AZ::EntityId > | m_surfaceCreatorIdList |
SurfacePointList stores a collection of surface point data, which consists of positions, normals, and surface tag weights. This class is specifically designed to be used in the following ways.
List construction: StartListConstruction() - This clears the structure, temporarily holds on to the list of input positions, and preallocates the data. AddSurfacePoint() - Add surface points to the list. They're expected to get added in input position order. ModifySurfaceWeights() - Modify the surface weights for the set of input points. FilterPoints() - Remove any generated surface points that don't fit the filter criteria EndListConstruction() - "Freeze" and compact the data.
List usage: Any of the query APIs can be used in any order after the list has finished being constructed.
This class is specifically designed around the usage patterns described above to minimize the amount of allocations and data shifting that needs to occur. There are some tricky bits that need to be accounted for:
The solution is that we always add new surface point data to the end of their respective vectors, but we also keep a helper structure that's a list of lists of sorted indices. We can incrementally re-sort the indices quickly without having to shift all the surface point data around.
SurfaceData::SurfacePointList::SurfacePointList | ( | AZStd::span< const AzFramework::SurfaceData::SurfacePoint > | surfacePoints | ) |
Constructor for creating a SurfacePointList from a list of SurfacePoint data. Primarily used as a convenience for unit tests.
surfacePoints | - A set of SurfacePoint points to store in the SurfacePointList. Each point that's passed in will be treated as both the input and output position. The list will be fully constructed and queryable after this runs. |
void SurfaceData::SurfacePointList::AddSurfacePoint | ( | const AZ::EntityId & | entityId, |
const AZ::Vector3 & | inPosition, | ||
const AZ::Vector3 & | position, | ||
const AZ::Vector3 & | normal, | ||
const SurfaceTagWeights & | weights | ||
) |
Add a surface point to the list. To use this method optimally, the points should get added in increasing inPosition index order.
entityId | - The entity creating the surface point. |
inPosition | - The input position that produced this surface point. |
position | - The position of the surface point. |
normal | - The normal for the surface point. |
weights | - The surface tags and weights for this surface point. |
void SurfaceData::SurfacePointList::EndListConstruction | ( | ) |
End construction of the SurfacePointList. After this is called, surface points can no longer be added or modified, and all of the query APIs can start getting used.
void SurfaceData::SurfacePointList::EnumeratePoints | ( | AZStd::function< bool(size_t inputPositionIndex, const AZ::Vector3 &position, const AZ::Vector3 &normal, const SurfaceTagWeights &surfaceWeights)> | pointCallback | ) | const |
Enumerate every surface point and call a callback for each point found. Note: There is no guaranteed order to which the points will be enumerated. @pointCallback - The method to call with each surface point.
void SurfaceData::SurfacePointList::EnumeratePoints | ( | size_t | inputPositionIndex, |
AZStd::function< bool(const AZ::Vector3 &position, const AZ::Vector3 &normal, const SurfaceTagWeights &surfaceWeights)> | pointCallback | ||
) | const |
Enumerate every surface point for a given input position and call a callback for each point found. Note: There is no guaranteed order to which the points will be enumerated. @inputPositionIndex - The input position to get the outputs for. @pointCallback - The method to call with each surface point.
AzFramework::SurfaceData::SurfacePoint SurfaceData::SurfacePointList::GetHighestSurfacePoint | ( | size_t | inputPositionIndex | ) | const |
Get the surface point with the highest Z value for a given input position. @inputPositionIndex - The input position to get the highest surface point for.
|
inline |
Return the total number of input positions. Normally the caller would already be expected to know this, but in the case of using region-based queries, the number of input positions might not be entirely obvious.
size_t SurfaceData::SurfacePointList::GetSize | ( | ) | const |
Return the total number of output points generated.
size_t SurfaceData::SurfacePointList::GetSize | ( | size_t | inputPositionIndex | ) | const |
Return the total number of output points generated from a specific input position index.
inputPositionIndex | - The input position to look for output points for. |
|
inline |
Get the AABB that encapsulates all of the generated output surface points.
bool SurfaceData::SurfacePointList::IsEmpty | ( | ) | const |
Return whether or not the entire surface point list is empty.
bool SurfaceData::SurfacePointList::IsEmpty | ( | size_t | inputPositionIndex | ) | const |
Return whether or not a given input position index has any output points associated with it.
inputPositionIndex | - The input position to look for output points for. |
void SurfaceData::SurfacePointList::ModifySurfaceWeights | ( | const SurfaceDataRegistryHandle & | surfaceModifierHandle | ) |
Modify the surface weights for each surface point in the list.
surfaceModifierHandle | - The handle to the surface modifier that will modify the surface weights. |
void SurfaceData::SurfacePointList::StartListConstruction | ( | AZStd::span< const AZ::Vector3 > | inPositions, |
size_t | maxPointsPerInput, | ||
AZStd::span< const SurfaceTag > | filterTags | ||
) |
Start construction of a SurfacePointList.
inPositions | - the list of input positions that will be used to generate this list. This list is expected to remain valid until EndListConstruction() is called. |
maxPointsPerInput | - the maximum number of potential surface points that will be generated for each input. This is used for allocating internal structures during list construction and is enforced to be correct. |
filterTags | - optional list of tags to filter the generated surface points by. If this list is provided, every surface point remaining in the list after construction will contain at least one of these tags. If the list is empty, all generated points will remain in the list. The filterTags list is expected to remain valid until EndListConstruction() is called. |
void SurfaceData::SurfacePointList::StartListConstruction | ( | AZStd::span< const AzFramework::SurfaceData::SurfacePoint > | surfacePoints | ) |
Start construction of a SurfacePointList from a list of SurfacePoint data. Primarily used as a convenience for unit tests.
surfacePoints | - A set of SurfacePoint points to store in the SurfacePointList. The list will remain in the "constructing" state after this is called, so it will still be possible to add/modify points, and EndListConstruction() will still need to be called. |