A high-performance matrix stack implementation for hierarchical transformations.
MatrixStack implements a traditional matrix stack commonly used in 3D graphics for managing hierarchical transformations. It allows pushing and popping matrices to create parent-child relationships between transformations, which is essential for scene graphs, skeletal animations, and other hierarchical structures.
Key features of this implementation:
Common usage patterns:
This implementation is designed for performance-critical rendering paths where predictable memory usage and cache-friendly operations are essential. The fixed-size stack ensures that no dynamic memory allocation occurs during traversal of a scene hierarchy, which is particularly important for real-time applications.
#include <matrix_stack.hpp>
Public Member Functions | |
| MatrixStack () | |
| Default constructor. | |
| void | Clear () |
| Clear stack to identity matrix. | |
| size_t | GetDepth () const |
| Get current stack depth. | |
| bool | IsEmpty () const |
| Check if stack is empty (only identity matrix). | |
| void | Pop () |
| Pop matrix from stack. | |
| void | Push (const Matrix43 &matrix) |
| Push matrix onto stack. | |
| void | RotateTop (const Angle &angleX, const Angle &angleY, const Angle &angleZ) |
| Rotate top matrix. | |
| void | ScaleTop (const Vector3D &scale) |
| Scale top matrix. | |
| Matrix43 & | Top () |
| Get reference to top matrix. | |
| const Matrix43 & | Top () const |
| Get const reference to top matrix. | |
| Vector3D | TransformPoint (const Vector3D &point) const |
| Transform point by current matrix. | |
| Vector3D | TransformVector (const Vector3D &vector) const |
| Transform vector by current matrix (no translation). | |
| void | TranslateTop (const Vector3D &translation) |
| Translate top matrix. | |
Static Public Attributes | |
| static constexpr size_t | MAX_DEPTH = 16 |
| Maximum depth of the matrix stack. | |