Add documentation for collision detection and mesh classes

Co-authored-by: orange-cpp <59374393+orange-cpp@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2025-11-13 15:19:36 +00:00
parent d118e88f6b
commit 190a8bf91e
11 changed files with 2482 additions and 0 deletions

View File

@@ -0,0 +1,119 @@
# `omath::frostbite_engine::MeshTrait` — mesh transformation trait for Frostbite Engine
> Header: `omath/engines/frostbite_engine/traits/mesh_trait.hpp`
> Namespace: `omath::frostbite_engine`
> Purpose: provide Frostbite Engine-specific rotation matrix computation for `omath::primitives::Mesh`
---
## Summary
`MeshTrait` is a trait class that provides the `rotation_matrix` function for transforming meshes in Frostbite's coordinate system. It serves as a template parameter to `omath::primitives::Mesh`, enabling engine-specific rotation behavior.
---
## Coordinate System
**Frostbite Engine** uses:
* **Up axis**: +Y
* **Forward axis**: +Z
* **Right axis**: +X
* **Handedness**: Right-handed
* **Rotation order**: Pitch (X) → Yaw (Y) → Roll (Z)
---
## API
```cpp
namespace omath::frostbite_engine {
class MeshTrait final {
public:
[[nodiscard]]
static Mat4X4 rotation_matrix(const ViewAngles& rotation);
};
} // namespace omath::frostbite_engine
```
---
## Method: `rotation_matrix`
```cpp
static Mat4X4 rotation_matrix(const ViewAngles& rotation);
```
Computes a 4×4 rotation matrix from Frostbite-style Euler angles.
**Parameters**:
* `rotation``ViewAngles` containing pitch, yaw, and roll angles
**Returns**: 4×4 rotation matrix suitable for mesh transformation
**Implementation**: Delegates to `frostbite_engine::rotation_matrix(rotation)` defined in `formulas.hpp`.
---
## Usage
### With Mesh
```cpp
using namespace omath::frostbite_engine;
// Create mesh (MeshTrait is used automatically)
Mesh my_mesh(vertices, indices);
// Set rotation using ViewAngles
ViewAngles angles;
angles.pitch = PitchAngle::from_degrees(30.0f);
angles.yaw = YawAngle::from_degrees(45.0f);
angles.roll = RollAngle::from_degrees(0.0f);
my_mesh.set_rotation(angles);
// The rotation matrix is computed using MeshTrait::rotation_matrix
auto matrix = my_mesh.get_to_world_matrix();
```
---
## Rotation Conventions
Frostbite uses a right-handed Y-up coordinate system:
1. **Pitch** (rotation around X-axis / right axis)
* Positive pitch looks upward (+Y direction)
* Range: typically [-89°, 89°]
2. **Yaw** (rotation around Y-axis / up axis)
* Positive yaw rotates counterclockwise when viewed from above (right-handed)
* Range: [-180°, 180°]
3. **Roll** (rotation around Z-axis / forward axis)
* Positive roll tilts right
* Range: [-180°, 180°]
---
## Type Alias
```cpp
namespace omath::frostbite_engine {
using Mesh = primitives::Mesh<Mat4X4, ViewAngles, MeshTrait, float>;
}
```
---
## See Also
- [Mesh Documentation](../../3d_primitives/mesh.md) - Mesh primitive
- [Formulas Documentation](formulas.md) - Frostbite rotation formula
- [CameraTrait Documentation](camera_trait.md) - Camera trait
---
*Last updated: 13 Nov 2025*

View File

@@ -0,0 +1,119 @@
# `omath::iw_engine::MeshTrait` — mesh transformation trait for IW Engine
> Header: `omath/engines/iw_engine/traits/mesh_trait.hpp`
> Namespace: `omath::iw_engine`
> Purpose: provide IW Engine-specific rotation matrix computation for `omath::primitives::Mesh`
---
## Summary
`MeshTrait` is a trait class that provides the `rotation_matrix` function for transforming meshes in IW Engine's (Infinity Ward) coordinate system. It serves as a template parameter to `omath::primitives::Mesh`, enabling engine-specific rotation behavior.
---
## Coordinate System
**IW Engine** (Call of Duty) uses:
* **Up axis**: +Z
* **Forward axis**: +Y
* **Right axis**: +X
* **Handedness**: Right-handed
* **Rotation order**: Pitch (X) → Yaw (Z) → Roll (Y)
---
## API
```cpp
namespace omath::iw_engine {
class MeshTrait final {
public:
[[nodiscard]]
static Mat4X4 rotation_matrix(const ViewAngles& rotation);
};
} // namespace omath::iw_engine
```
---
## Method: `rotation_matrix`
```cpp
static Mat4X4 rotation_matrix(const ViewAngles& rotation);
```
Computes a 4×4 rotation matrix from IW Engine-style Euler angles.
**Parameters**:
* `rotation``ViewAngles` containing pitch, yaw, and roll angles
**Returns**: 4×4 rotation matrix suitable for mesh transformation
**Implementation**: Delegates to `iw_engine::rotation_matrix(rotation)` defined in `formulas.hpp`.
---
## Usage
### With Mesh
```cpp
using namespace omath::iw_engine;
// Create mesh (MeshTrait is used automatically)
Mesh my_mesh(vertices, indices);
// Set rotation using ViewAngles
ViewAngles angles;
angles.pitch = PitchAngle::from_degrees(30.0f);
angles.yaw = YawAngle::from_degrees(45.0f);
angles.roll = RollAngle::from_degrees(0.0f);
my_mesh.set_rotation(angles);
// The rotation matrix is computed using MeshTrait::rotation_matrix
auto matrix = my_mesh.get_to_world_matrix();
```
---
## Rotation Conventions
IW Engine uses a right-handed Z-up coordinate system (similar to Source Engine):
1. **Pitch** (rotation around X-axis / right axis)
* Positive pitch looks upward (+Z direction)
* Range: typically [-89°, 89°]
2. **Yaw** (rotation around Z-axis / up axis)
* Positive yaw rotates counterclockwise when viewed from above
* Range: [-180°, 180°]
3. **Roll** (rotation around Y-axis / forward axis)
* Positive roll tilts right
* Range: [-180°, 180°]
---
## Type Alias
```cpp
namespace omath::iw_engine {
using Mesh = primitives::Mesh<Mat4X4, ViewAngles, MeshTrait, float>;
}
```
---
## See Also
- [Mesh Documentation](../../3d_primitives/mesh.md) - Mesh primitive
- [Formulas Documentation](formulas.md) - IW Engine rotation formula
- [CameraTrait Documentation](camera_trait.md) - Camera trait
---
*Last updated: 13 Nov 2025*

View File

@@ -0,0 +1,121 @@
# `omath::opengl_engine::MeshTrait` — mesh transformation trait for OpenGL
> Header: `omath/engines/opengl_engine/traits/mesh_trait.hpp`
> Namespace: `omath::opengl_engine`
> Purpose: provide OpenGL-specific rotation matrix computation for `omath::primitives::Mesh`
---
## Summary
`MeshTrait` is a trait class that provides the `rotation_matrix` function for transforming meshes in OpenGL's canonical coordinate system. It serves as a template parameter to `omath::primitives::Mesh`, enabling engine-specific rotation behavior.
---
## Coordinate System
**OpenGL** (canonical) uses:
* **Up axis**: +Y
* **Forward axis**: +Z (toward viewer)
* **Right axis**: +X
* **Handedness**: Right-handed
* **Rotation order**: Pitch (X) → Yaw (Y) → Roll (Z)
---
## API
```cpp
namespace omath::opengl_engine {
class MeshTrait final {
public:
[[nodiscard]]
static Mat4X4 rotation_matrix(const ViewAngles& rotation);
};
} // namespace omath::opengl_engine
```
---
## Method: `rotation_matrix`
```cpp
static Mat4X4 rotation_matrix(const ViewAngles& rotation);
```
Computes a 4×4 rotation matrix from OpenGL-style Euler angles.
**Parameters**:
* `rotation``ViewAngles` containing pitch, yaw, and roll angles
**Returns**: 4×4 rotation matrix suitable for mesh transformation
**Implementation**: Delegates to `opengl_engine::rotation_matrix(rotation)` defined in `formulas.hpp`.
---
## Usage
### With Mesh
```cpp
using namespace omath::opengl_engine;
// Create mesh (MeshTrait is used automatically)
Mesh my_mesh(vertices, indices);
// Set rotation using ViewAngles
ViewAngles angles;
angles.pitch = PitchAngle::from_degrees(30.0f);
angles.yaw = YawAngle::from_degrees(45.0f);
angles.roll = RollAngle::from_degrees(0.0f);
my_mesh.set_rotation(angles);
// The rotation matrix is computed using MeshTrait::rotation_matrix
auto matrix = my_mesh.get_to_world_matrix();
```
---
## Rotation Conventions
OpenGL uses a right-handed Y-up coordinate system:
1. **Pitch** (rotation around X-axis / right axis)
* Positive pitch looks upward (+Y direction)
* Range: typically [-89°, 89°]
2. **Yaw** (rotation around Y-axis / up axis)
* Positive yaw rotates counterclockwise when viewed from above (right-handed)
* Range: [-180°, 180°]
3. **Roll** (rotation around Z-axis / depth axis)
* Positive roll tilts right
* Range: [-180°, 180°]
**Note**: In OpenGL, +Z points toward the viewer in view space, but away from the viewer in world space.
---
## Type Alias
```cpp
namespace omath::opengl_engine {
using Mesh = primitives::Mesh<Mat4X4, ViewAngles, MeshTrait, float>;
}
```
---
## See Also
- [Mesh Documentation](../../3d_primitives/mesh.md) - Mesh primitive
- [Formulas Documentation](formulas.md) - OpenGL rotation formula
- [CameraTrait Documentation](camera_trait.md) - Camera trait
---
*Last updated: 13 Nov 2025*

View File

@@ -0,0 +1,182 @@
# `omath::source_engine::MeshTrait` — mesh transformation trait for Source Engine
> Header: `omath/engines/source_engine/traits/mesh_trait.hpp`
> Namespace: `omath::source_engine`
> Purpose: provide Source Engine-specific rotation matrix computation for `omath::primitives::Mesh`
---
## Summary
`MeshTrait` is a trait class that provides the `rotation_matrix` function for transforming meshes in Source Engine's coordinate system. It serves as a template parameter to `omath::primitives::Mesh`, enabling engine-specific rotation behavior.
---
## Coordinate System
**Source Engine** uses:
* **Up axis**: +Z
* **Forward axis**: +Y
* **Right axis**: +X
* **Handedness**: Right-handed
* **Rotation order**: Pitch (X) → Yaw (Z) → Roll (Y)
---
## API
```cpp
namespace omath::source_engine {
class MeshTrait final {
public:
[[nodiscard]]
static Mat4X4 rotation_matrix(const ViewAngles& rotation);
};
} // namespace omath::source_engine
```
---
## Method: `rotation_matrix`
```cpp
static Mat4X4 rotation_matrix(const ViewAngles& rotation);
```
Computes a 4×4 rotation matrix from Source Engine-style Euler angles.
**Parameters**:
* `rotation``ViewAngles` containing pitch, yaw, and roll angles
**Returns**: 4×4 rotation matrix suitable for mesh transformation
**Implementation**: Delegates to `source_engine::rotation_matrix(rotation)` defined in `formulas.hpp`.
---
## Usage
### With Mesh
```cpp
using namespace omath::source_engine;
// Create mesh (MeshTrait is used automatically)
Mesh my_mesh(vertices, indices);
// Set rotation using ViewAngles
ViewAngles angles;
angles.pitch = PitchAngle::from_degrees(30.0f);
angles.yaw = YawAngle::from_degrees(45.0f);
angles.roll = RollAngle::from_degrees(0.0f);
my_mesh.set_rotation(angles);
// The rotation matrix is computed using MeshTrait::rotation_matrix
auto matrix = my_mesh.get_to_world_matrix();
```
### Direct Usage
```cpp
using namespace omath::source_engine;
ViewAngles angles;
angles.pitch = PitchAngle::from_degrees(45.0f);
angles.yaw = YawAngle::from_degrees(90.0f);
angles.roll = RollAngle::from_degrees(0.0f);
Mat4X4 rot_matrix = MeshTrait::rotation_matrix(angles);
// Use the matrix directly
Vector3<float> local_point{1, 0, 0};
auto rotated = rot_matrix * mat_column_from_vector(local_point);
```
---
## Rotation Conventions
The rotation matrix is built following Source Engine's conventions:
1. **Pitch** (rotation around X-axis / right axis)
* Positive pitch looks upward (+Z direction)
* Range: typically [-89°, 89°]
2. **Yaw** (rotation around Z-axis / up axis)
* Positive yaw rotates counterclockwise when viewed from above
* Range: [-180°, 180°]
3. **Roll** (rotation around Y-axis / forward axis)
* Positive roll tilts right
* Range: [-180°, 180°]
**Composition**: The matrices are combined in the order Pitch × Yaw × Roll, producing a rotation that:
* First applies roll around the forward axis
* Then applies yaw around the up axis
* Finally applies pitch around the right axis
This matches Source Engine's internal rotation order.
---
## Related Functions
The trait delegates to the formula defined in `formulas.hpp`:
```cpp
[[nodiscard]]
Mat4X4 rotation_matrix(const ViewAngles& angles) noexcept;
```
See [Formulas Documentation](formulas.md) for details on the rotation matrix computation.
---
## Type Alias
The Source Engine mesh type is pre-defined:
```cpp
namespace omath::source_engine {
using Mesh = primitives::Mesh<Mat4X4, ViewAngles, MeshTrait, float>;
}
```
Use this alias to ensure correct trait usage:
```cpp
using namespace omath::source_engine;
// Correct: uses Source Engine trait
Mesh my_mesh(vbo, vao);
// Avoid: manually specifying template parameters
primitives::Mesh<Mat4X4, ViewAngles, MeshTrait, float> verbose_mesh(vbo, vao);
```
---
## Notes
* **Angle ranges**: Ensure angles are within valid ranges (pitch: [-89°, 89°], yaw/roll: [-180°, 180°])
* **Performance**: Matrix computation is O(1) with ~64 floating-point operations
* **Caching**: The mesh caches the transformation matrix; recomputed only when rotation changes
* **Compatibility**: Works with all Source Engine games (CS:GO, TF2, Portal, Half-Life 2, etc.)
---
## See Also
- [Mesh Documentation](../../3d_primitives/mesh.md) - Mesh primitive using this trait
- [MeshCollider Documentation](../../collision/mesh_collider.md) - Collision wrapper for meshes
- [Formulas Documentation](formulas.md) - Source Engine rotation formula
- [CameraTrait Documentation](camera_trait.md) - Camera transformation trait
- [Constants Documentation](constants.md) - Source Engine constants
- [API Overview](../../api_overview.md) - High-level API reference
---
*Last updated: 13 Nov 2025*

View File

@@ -0,0 +1,119 @@
# `omath::unity_engine::MeshTrait` — mesh transformation trait for Unity Engine
> Header: `omath/engines/unity_engine/traits/mesh_trait.hpp`
> Namespace: `omath::unity_engine`
> Purpose: provide Unity Engine-specific rotation matrix computation for `omath::primitives::Mesh`
---
## Summary
`MeshTrait` is a trait class that provides the `rotation_matrix` function for transforming meshes in Unity's coordinate system. It serves as a template parameter to `omath::primitives::Mesh`, enabling engine-specific rotation behavior.
---
## Coordinate System
**Unity Engine** uses:
* **Up axis**: +Y
* **Forward axis**: +Z
* **Right axis**: +X
* **Handedness**: Left-handed
* **Rotation order**: Pitch (X) → Yaw (Y) → Roll (Z)
---
## API
```cpp
namespace omath::unity_engine {
class MeshTrait final {
public:
[[nodiscard]]
static Mat4X4 rotation_matrix(const ViewAngles& rotation);
};
} // namespace omath::unity_engine
```
---
## Method: `rotation_matrix`
```cpp
static Mat4X4 rotation_matrix(const ViewAngles& rotation);
```
Computes a 4×4 rotation matrix from Unity-style Euler angles.
**Parameters**:
* `rotation``ViewAngles` containing pitch, yaw, and roll angles
**Returns**: 4×4 rotation matrix suitable for mesh transformation
**Implementation**: Delegates to `unity_engine::rotation_matrix(rotation)` defined in `formulas.hpp`.
---
## Usage
### With Mesh
```cpp
using namespace omath::unity_engine;
// Create mesh (MeshTrait is used automatically)
Mesh my_mesh(vertices, indices);
// Set rotation using ViewAngles
ViewAngles angles;
angles.pitch = PitchAngle::from_degrees(30.0f);
angles.yaw = YawAngle::from_degrees(45.0f);
angles.roll = RollAngle::from_degrees(0.0f);
my_mesh.set_rotation(angles);
// The rotation matrix is computed using MeshTrait::rotation_matrix
auto matrix = my_mesh.get_to_world_matrix();
```
---
## Rotation Conventions
Unity uses a left-handed coordinate system with Y-up:
1. **Pitch** (rotation around X-axis / right axis)
* Positive pitch looks upward (+Y direction)
* Range: typically [-89°, 89°]
2. **Yaw** (rotation around Y-axis / up axis)
* Positive yaw rotates clockwise when viewed from above (left-handed)
* Range: [-180°, 180°]
3. **Roll** (rotation around Z-axis / forward axis)
* Positive roll tilts right
* Range: [-180°, 180°]
---
## Type Alias
```cpp
namespace omath::unity_engine {
using Mesh = primitives::Mesh<Mat4X4, ViewAngles, MeshTrait, float>;
}
```
---
## See Also
- [Mesh Documentation](../../3d_primitives/mesh.md) - Mesh primitive
- [Formulas Documentation](formulas.md) - Unity rotation formula
- [CameraTrait Documentation](camera_trait.md) - Camera trait
---
*Last updated: 13 Nov 2025*

View File

@@ -0,0 +1,121 @@
# `omath::unreal_engine::MeshTrait` — mesh transformation trait for Unreal Engine
> Header: `omath/engines/unreal_engine/traits/mesh_trait.hpp`
> Namespace: `omath::unreal_engine`
> Purpose: provide Unreal Engine-specific rotation matrix computation for `omath::primitives::Mesh`
---
## Summary
`MeshTrait` is a trait class that provides the `rotation_matrix` function for transforming meshes in Unreal Engine's coordinate system. It serves as a template parameter to `omath::primitives::Mesh`, enabling engine-specific rotation behavior.
---
## Coordinate System
**Unreal Engine** uses:
* **Up axis**: +Z
* **Forward axis**: +X
* **Right axis**: +Y
* **Handedness**: Left-handed
* **Rotation order**: Roll (Y) → Pitch (X) → Yaw (Z)
---
## API
```cpp
namespace omath::unreal_engine {
class MeshTrait final {
public:
[[nodiscard]]
static Mat4X4 rotation_matrix(const ViewAngles& rotation);
};
} // namespace omath::unreal_engine
```
---
## Method: `rotation_matrix`
```cpp
static Mat4X4 rotation_matrix(const ViewAngles& rotation);
```
Computes a 4×4 rotation matrix from Unreal-style Euler angles.
**Parameters**:
* `rotation``ViewAngles` containing pitch, yaw, and roll angles
**Returns**: 4×4 rotation matrix suitable for mesh transformation
**Implementation**: Delegates to `unreal_engine::rotation_matrix(rotation)` defined in `formulas.hpp`.
---
## Usage
### With Mesh
```cpp
using namespace omath::unreal_engine;
// Create mesh (MeshTrait is used automatically)
Mesh my_mesh(vertices, indices);
// Set rotation using ViewAngles
ViewAngles angles;
angles.pitch = PitchAngle::from_degrees(30.0f);
angles.yaw = YawAngle::from_degrees(45.0f);
angles.roll = RollAngle::from_degrees(0.0f);
my_mesh.set_rotation(angles);
// The rotation matrix is computed using MeshTrait::rotation_matrix
auto matrix = my_mesh.get_to_world_matrix();
```
---
## Rotation Conventions
Unreal uses a left-handed Z-up coordinate system:
1. **Roll** (rotation around Y-axis / right axis)
* Positive roll rotates forward axis upward
* Range: [-180°, 180°]
2. **Pitch** (rotation around X-axis / forward axis)
* Positive pitch looks upward
* Range: typically [-89°, 89°]
3. **Yaw** (rotation around Z-axis / up axis)
* Positive yaw rotates clockwise when viewed from above (left-handed)
* Range: [-180°, 180°]
**Note**: Unreal applies rotations in Roll-Pitch-Yaw order, different from most other engines.
---
## Type Alias
```cpp
namespace omath::unreal_engine {
using Mesh = primitives::Mesh<Mat4X4, ViewAngles, MeshTrait, float>;
}
```
---
## See Also
- [Mesh Documentation](../../3d_primitives/mesh.md) - Mesh primitive
- [Formulas Documentation](formulas.md) - Unreal rotation formula
- [CameraTrait Documentation](camera_trait.md) - Camera trait
---
*Last updated: 13 Nov 2025*