Open 3D Engine EMotionFX 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.
MCore::TCompressedVector3< StorageType > Class Template Reference

#include <CompressedVector.h>

Public Types

enum  { CONVERT_VALUE = (1 << (sizeof(StorageType) << 3)) - 1 }
 

Public Member Functions

MCORE_INLINE TCompressedVector3 ()
 
MCORE_INLINE TCompressedVector3 (StorageType x, StorageType y, StorageType z)
 
MCORE_INLINE TCompressedVector3 (const AZ::Vector3 &vec, float minValue, float maxValue)
 
MCORE_INLINE void FromVector3 (const AZ::Vector3 &vec, float minValue, float maxValue)
 
MCORE_INLINE AZ::Vector3 ToVector3 (float minValue, float maxValue) const
 

Public Attributes

StorageType m_x
 
StorageType m_y
 
StorageType m_z
 

Detailed Description

template<class StorageType>
class MCore::TCompressedVector3< StorageType >

The compressed / packed vector class. The class can automatically compress a vector which has components of type 'float' into a vector that represents these component values inside 'StorageType' component types. An example would be a Vector3 object of floats (float=float) compressed into a CompressedVector3 that stores the xyz components as 16-byte unsigned shorts. This would reduce the Vector3 size from 12 bytes into 6 bytes, at the trade of a bit loss in precision and CPU overhead for uncompression into a Vector3 of floats again. When used with care, the CPU overhead and precision loss are negligible. During both compression and uncompression you also have to specify the range (minimum and maximum possible values) of the components of the vector you want to compress/decompress. If you are dealing with normalized normals, the minimum value would be -1, and the maximum value would be +1. When uncompressing (converting back to a Vector3 of floats) you have to be sure you use the same minimum and maximum values as when you used to compress it! This is very important! The bigger the range, the more precision loss. There is however no performance impact linked to the range.

Constructor & Destructor Documentation

◆ TCompressedVector3() [1/3]

template<class StorageType >
MCORE_INLINE TCompressedVector3::TCompressedVector3 ( )

Default constructor. This leaves the members uninitialized, so if you get the uncompressed version, the result is unknown.

◆ TCompressedVector3() [2/3]

template<class StorageType >
MCORE_INLINE MCore::TCompressedVector3< StorageType >::TCompressedVector3 ( StorageType  x,
StorageType  y,
StorageType  z 
)
inline

The constructor that sets the compressed values directly.

Parameters
xThe compressed x component.
yThe compressed y component.
zThe compressed z component.

◆ TCompressedVector3() [3/3]

template<class StorageType >
MCORE_INLINE TCompressedVector3::TCompressedVector3 ( const AZ::Vector3 &  vec,
float  minValue,
float  maxValue 
)

Create a compressed vector from an uncompressed one.

Parameters
vecThe vector you want to compress.
minValueThe minimum possible value of the xyz components of the uncompressed vector. So in case of a normalized normal, this would be -1.
maxValueThe maximum possible value of the xyz components of the uncompressed vector. So in case of a normalized normal, this would be +1.

Member Function Documentation

◆ FromVector3()

template<class StorageType >
MCORE_INLINE void TCompressedVector3::FromVector3 ( const AZ::Vector3 &  vec,
float  minValue,
float  maxValue 
)

Create a compressed vector from an uncompressed one.

Parameters
vecThe vector you want to compress.
minValueThe minimum possible value of the xyz components of the uncompressed vector. So in case of a normalized normal, this would be -1.
maxValueThe maximum possible value of the xyz components of the uncompressed vector. So in case of a normalized normal, this would be +1.

◆ ToVector3()

template<class StorageType >
MCORE_INLINE AZ::Vector3 TCompressedVector3::ToVector3 ( float  minValue,
float  maxValue 
) const

Uncompress this compressed vector into an uncompressed Vector3 of floats. Please note that the minimum and maximum values you specify are the same as when you created this compressed vector3 or when you for the last time called the FromVector3 method.

Parameters
minValueThe minimum possible value of the xyz components of the uncompressed vector. So in case of a normalized normal, this would be -1.
maxValueThe maximum possible value of the xyz components of the uncompressed vector. So in case of a normalized normal, this would be +1.
Returns
The uncompressed version of this vector.

Member Data Documentation

◆ m_z

template<class StorageType >
StorageType MCore::TCompressedVector3< StorageType >::m_z

The compressed/packed vector components.


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