Open 3D Engine AzFramework 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.
Physics::MaterialPropertyValue Class Referencefinal

#include <PhysicsMaterialPropertyValue.h>

Public Types

using ValueType = AZStd::variant< AZStd::monostate, bool, AZ::s32, AZ::u32, float, AZ::Vector2, AZ::Vector3, AZ::Vector4, AZ::Color, AZStd::string >
 

Public Member Functions

 AZ_TYPE_INFO (Physics::MaterialPropertyValue, "{2D9822B6-B4AD-4635-87FD-08F857EEB152}")
 
 MaterialPropertyValue (bool value)
 
 MaterialPropertyValue (AZ::s32 value)
 
 MaterialPropertyValue (AZ::u32 value)
 
 MaterialPropertyValue (float value)
 
 MaterialPropertyValue (const AZ::Vector2 &value)
 
 MaterialPropertyValue (const AZ::Vector3 &value)
 
 MaterialPropertyValue (const AZ::Vector4 &value)
 
 MaterialPropertyValue (const AZ::Color &value)
 
 MaterialPropertyValue (const AZStd::string &value)
 
 MaterialPropertyValue (const MaterialPropertyValue &value)
 Copy constructor.
 
template<typename T >
MaterialPropertyValueoperator= (const T &value)
 
template<typename T >
const T & GetValue () const
 
template<typename T >
constexpr bool Is () const
 Check if the type holding is T.
 
AZ::TypeId GetTypeId () const
 Get TypeId of the type holding.
 
constexpr bool IsValid () const
 Check if the variant is holding a valid value.
 
bool operator== (const MaterialPropertyValue &other) const
 
bool operator!= (const MaterialPropertyValue &other) const
 
MaterialPropertyValue CastToType (AZ::TypeId requestedType) const
 

Static Public Member Functions

static void Reflect (AZ::ReflectContext *context)
 
static MaterialPropertyValue FromAny (const AZStd::any &value)
 
static AZStd::any ToAny (const MaterialPropertyValue &value)
 

Detailed Description

This is a variant data type that represents the value of a physics material property. Used by Physics material assets.

Member Typedef Documentation

◆ ValueType

using Physics::MaterialPropertyValue::ValueType = AZStd::variant< AZStd::monostate, bool, AZ::s32, AZ::u32, float, AZ::Vector2, AZ::Vector3, AZ::Vector4, AZ::Color, AZStd::string>

Variant type definition. AZStd::monostate is used as default and invalid value.

Member Function Documentation

◆ CastToType()

MaterialPropertyValue Physics::MaterialPropertyValue::CastToType ( AZ::TypeId  requestedType) const

Attempt to cast the value to another type, handling numerical types (e.g. int to float, bool to int), vector types (e.g. Vector2 to Vector3) and color<->vector types (e.g. Vector[3-4] to Color). In conversions between vector based types of different dimension, the result gets truncated or padded with zeroes as needed. Conversions between color and vector types are only supported for 3 and 4 dimensional vectors. In case of incompatible types (e.g. string to float, Vector2 to Color), the current object is returned as-is.

◆ GetValue()

template<typename T >
const T& Physics::MaterialPropertyValue::GetValue ( ) const
inline

Get actual value from the variant. The type will be restricted as in operator=().

◆ operator=()

template<typename T >
MaterialPropertyValue& Physics::MaterialPropertyValue::operator= ( const T &  value)
inline

Templated assignment. The type will be restricted to those defined in the variant at compile time. If out-of-definition type is used, the compiler will report error.


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