Skip to main content

TransformType.ixx File

Defines transform inheritance flags for scene graph hierarchies. More...

Included Headers

#include <cstdint>

Namespaces Index

namespacehelios
namespacemath

Mathematical operations and types. More...

Description

Defines transform inheritance flags for scene graph hierarchies.

File Listing

The file content with the documentation metadata removed is:

1/**
2 * @file TransformType.ixx
3 * @brief Defines transform inheritance flags for scene graph hierarchies.
4 */
5module;
6
7#include <cstdint>
8
9export module helios.math.TransformType;
10
11
12export namespace helios::math {
13
14 /**
15 * @brief Bitmask enum controlling which transform components a child node inherits from its parent.
16 *
17 * When a SceneNode is attached to a parent, its final world transform is computed by
18 * combining the parent's world transform with the child's local transform. The `Inherit`
19 * flags determine which components (Translation, Rotation, Scale) of the parent transform
20 * are applied to the child.
21 *
22 * This enables flexible scene graph behaviors such as:
23 * - A camera that follows an object's position but maintains its own orientation (`TransformType::Translation`)
24 * - UI elements that inherit full transforms (`TransformType::All`)
25 * - Objects that only inherit rotation for billboard effects (`TransformType::Rotation`)
26 *
27 * Example usage:
28 * ```cpp
29 * using namespace helios::math;
30 *
31 * // Camera follows spaceship position only
32 * cameraNode->setInheritance(TransformType::Translation);
33 *
34 * // Full transform inheritance (default)
35 * childNode->setInheritance(TransformType::All);
36 *
37 * // Combine specific flags
38 * node->setInheritance(TransformType::Translation | TransformType::Rotation);
39 * ```
40 */
41 enum class TransformType : uint8_t {
42 /**
43 * @brief Inherit only the translation component from the parent.
44 *
45 * The child's world position is offset by the parent's world position,
46 * but rotation and scale remain unaffected by the parent.
47 */
48 Translation = 1 << 0,
49
50 /**
51 * @brief Inherit only the rotation component from the parent.
52 *
53 * The child's orientation is combined with the parent's orientation,
54 * but position and scale remain unaffected.
55 */
56 Rotation = 1 << 1,
57
58 /**
59 * @brief Inherit only the scale component from the parent.
60 *
61 * The child's scale is multiplied by the parent's scale,
62 * but position and rotation remain unaffected.
63 */
64 Scale = 1 << 2,
65
66 /**
67 * @brief Inherit all transform components (Translation, Rotation, Scale).
68 *
69 * This is the default behavior where the child's world transform is
70 * the full composition of parent and local transforms.
71 */
73 };
74
75 /**
76 * @brief Combines two Inherit flags using bitwise OR.
77 *
78 * @param a The first inheritance flag.
79 * @param b The second inheritance flag.
80 *
81 * @return The combined inheritance mask.
82 */
84 return static_cast<TransformType>(static_cast<uint8_t>(a) | static_cast<uint8_t>(b));
85 }
86
87
88 /**
89 * @brief Checks if a specific inheritance flag is set in a mask.
90 *
91 * @param mask The inheritance mask to check against.
92 * @param flag The specific flag to test for.
93 *
94 * @return `true` if the flag is present in the mask, `false` otherwise.
95 *
96 * Example usage:
97 * ```cpp
98 * using namespace helios::math;
99 *
100 * TransformType mode = TransformType::Translation | TransformType::Rotation;
101 *
102 * if (transformTypeMatch(mode, TransformType::Translation)) {
103 * // Apply parent translation...
104 * }
105 * ```
106 */
108 return (static_cast<uint8_t>(mask) & static_cast<uint8_t>(flag)) != 0;
109 }
110}

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.