Open 3D Engine SurfaceData Gem API Reference 23.10.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
SurfaceData::SurfaceTagWeights Class Reference

#include <SurfaceDataTypes.h>

Public Member Functions

 SurfaceTagWeights (const AzFramework::SurfaceData::SurfaceTagWeightList &weights)
 
void AssignSurfaceTagWeights (const AzFramework::SurfaceData::SurfaceTagWeightList &weights)
 
void AssignSurfaceTagWeights (const SurfaceTagVector &tags, float weight)
 
void AddSurfaceTagWeight (const AZ::Crc32 tag, const float weight)
 
void AddSurfaceTagWeights (const SurfaceTagVector &tags, const float weight)
 
void AddSurfaceTagWeights (const SurfaceTagWeights &weights)
 
bool operator== (const SurfaceTagWeights &rhs) const
 Equality comparison operator for SurfaceTagWeights.
 
bool operator!= (const SurfaceTagWeights &rhs) const
 Inequality comparison operator for SurfaceTagWeights.
 
bool SurfaceWeightsAreEqual (const AzFramework::SurfaceData::SurfaceTagWeightList &compareWeights) const
 
void Clear ()
 Clear the surface tag weight collection.
 
size_t GetSize () const
 
AzFramework::SurfaceData::SurfaceTagWeightList GetSurfaceTagWeightList () const
 
void EnumerateWeights (AZStd::function< bool(AZ::Crc32 tag, float weight)> weightCallback) const
 
bool HasValidTags () const
 
bool HasMatchingTag (AZ::Crc32 sampleTag) const
 
bool HasMatchingTag (AZ::Crc32 sampleTag, float weightMin, float weightMax) const
 
bool HasAnyMatchingTags (AZStd::span< const SurfaceTag > sampleTags) const
 
bool HasAnyMatchingTags (AZStd::span< const SurfaceTag > sampleTags, float weightMin, float weightMax) const
 

Detailed Description

SurfaceTagWeights stores a collection of surface tags and weights. A surface tag can only appear once in the collection. Attempting to add it multiple times will always preserve the highest weight value.

Constructor & Destructor Documentation

◆ SurfaceTagWeights()

SurfaceData::SurfaceTagWeights::SurfaceTagWeights ( const AzFramework::SurfaceData::SurfaceTagWeightList &  weights)
inline

Construct a collection of SurfaceTagWeights from the given SurfaceTagWeightList.

Parameters
weights- The list of weights to assign to the new instance.

Member Function Documentation

◆ AddSurfaceTagWeight()

void SurfaceData::SurfaceTagWeights::AddSurfaceTagWeight ( const AZ::Crc32  tag,
const float  weight 
)
inline

Add a surface tag weight to this collection. If the tag already exists, the higher weight will be preserved. (This method is intentionally inlined for its performance impact)

Parameters
tag- The surface tag.
weight- The surface tag weight.

◆ AddSurfaceTagWeights() [1/2]

void SurfaceData::SurfaceTagWeights::AddSurfaceTagWeights ( const SurfaceTagVector &  tags,
const float  weight 
)
inline

Add surface tags and weights to this collection. If a tag already exists, the higher weight will be preserved. (This method is intentionally inlined for its performance impact)

Parameters
tags- The surface tags to replace/add.
weight- The surface tag weight to use for each tag.

◆ AddSurfaceTagWeights() [2/2]

void SurfaceData::SurfaceTagWeights::AddSurfaceTagWeights ( const SurfaceTagWeights weights)
inline

Add surface tags and weights to this collection. If a tag already exists, the higher weight will be preserved. (This method is intentionally inlined for its performance impact)

Parameters
weights- The surface tags and weights to replace/add.

◆ AssignSurfaceTagWeights() [1/2]

void SurfaceData::SurfaceTagWeights::AssignSurfaceTagWeights ( const AzFramework::SurfaceData::SurfaceTagWeightList &  weights)

Replace the existing surface tag weights with the given set.

Parameters
weights- The list of weights to assign to this instance.

◆ AssignSurfaceTagWeights() [2/2]

void SurfaceData::SurfaceTagWeights::AssignSurfaceTagWeights ( const SurfaceTagVector &  tags,
float  weight 
)

Replace the existing surface tag weights with the given set.

Parameters
tags- The list of tags to assign to this instance.
weight- The weight to assign to each tag.

◆ EnumerateWeights()

void SurfaceData::SurfaceTagWeights::EnumerateWeights ( AZStd::function< bool(AZ::Crc32 tag, float weight)>  weightCallback) const

Enumerate every tag and weight and call a callback for each one found. Callback params: AZ::Crc32 - The surface tag. float - The surface tag weight. return - true to keep enumerating, false to stop.

Parameters
weightCallback- the callback to use for each surface tag / weight found.

◆ GetSize()

size_t SurfaceData::SurfaceTagWeights::GetSize ( ) const

Get the size of the surface tag weight collection.

Returns
The size of the collection.

◆ GetSurfaceTagWeightList()

AzFramework::SurfaceData::SurfaceTagWeightList SurfaceData::SurfaceTagWeights::GetSurfaceTagWeightList ( ) const

Get the collection of surface tag weights as a SurfaceTagWeightList.

Returns
SurfaceTagWeightList containing the same tags and weights as this collection.

◆ HasAnyMatchingTags() [1/2]

bool SurfaceData::SurfaceTagWeights::HasAnyMatchingTags ( AZStd::span< const SurfaceTag sampleTags) const

Check to see if the collection contains any of the given tags.

Parameters
sampleTags- The tags to look for.
Returns
True if any of the tags is found, false if none are found.

◆ HasAnyMatchingTags() [2/2]

bool SurfaceData::SurfaceTagWeights::HasAnyMatchingTags ( AZStd::span< const SurfaceTag sampleTags,
float  weightMin,
float  weightMax 
) const

Check to see if the collection contains the given tag with the given weight range. The range check is inclusive on both sides of the range: [weightMin, weightMax]

Parameters
sampleTags- The tags to look for.
weightMin- The minimum weight for this tag.
weightMax- The maximum weight for this tag.
Returns
True if any of the tags is found, false if none are found.

◆ HasMatchingTag() [1/2]

bool SurfaceData::SurfaceTagWeights::HasMatchingTag ( AZ::Crc32  sampleTag) const

Check to see if the collection contains the given tag.

Parameters
sampleTag- The tag to look for.
Returns
True if the tag is found, false if it isn't.

◆ HasMatchingTag() [2/2]

bool SurfaceData::SurfaceTagWeights::HasMatchingTag ( AZ::Crc32  sampleTag,
float  weightMin,
float  weightMax 
) const

Check to see if the collection contains the given tag with the given weight range. The range check is inclusive on both sides of the range: [weightMin, weightMax]

Parameters
sampleTag- The tag to look for.
weightMin- The minimum weight for this tag.
weightMax- The maximum weight for this tag.
Returns
True if the tag is found, false if it isn't.

◆ HasValidTags()

bool SurfaceData::SurfaceTagWeights::HasValidTags ( ) const

Check to see if the collection has any valid tags stored within it. A tag of "Unassigned" is considered an invalid tag.

Returns
True if there is at least one valid tag, false if there isn't.

◆ SurfaceWeightsAreEqual()

bool SurfaceData::SurfaceTagWeights::SurfaceWeightsAreEqual ( const AzFramework::SurfaceData::SurfaceTagWeightList &  compareWeights) const

Compares a SurfaceTagWeightList with a SurfaceTagWeights instance to look for equality. They will be equal if they have the exact same set of tags and weights.

Parameters
compareWeights- the set of weights to compare against.

The documentation for this class was generated from the following file: