VisuTwin Canvas
C++ 3D Engine — Metal Backend
Loading...
Searching...
No Matches
orientedBox.h
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2// Copyright 2025-2026 Arnis Lektauers
3#pragma once
4
5#include <core/math/matrix4.h>
6#include <core/math/vector3.h>
9#include <core/shape/ray.h>
10
11namespace visutwin::canvas
12{
14 {
15 public:
18
19 const Matrix4& worldTransform() const { return _worldTransform; }
20 void setWorldTransform(const Matrix4& value);
21 const Vector3& halfExtents() const { return _halfExtents; }
23 bool intersectsRay(const Ray& ray, Vector3* point = nullptr) const;
24 bool containsPoint(const Vector3& point) const;
25 bool intersectsBoundingSphere(const BoundingSphere& sphere) const;
26
27 private:
28 bool intersectsLocalAabbRay(const Ray& localRay, Vector3* localPoint) const;
29 bool fastIntersectsLocalAabbRay(const Ray& localRay) const;
30 Vector3 closestPointOnLocalAabb(const Vector3& localPoint) const;
31
32 Vector3 _halfExtents;
33 Matrix4 _modelTransform;
34 Matrix4 _worldTransform;
35 BoundingBox _aabb;
36 };
37}
Axis-Aligned Bounding Box defined by center and half-extents.
Definition boundingBox.h:21
Bounding sphere defined by center and radius for intersection and containment tests.
bool intersectsBoundingSphere(const BoundingSphere &sphere) const
bool containsPoint(const Vector3 &point) const
const Vector3 & halfExtents() const
Definition orientedBox.h:21
const Matrix4 & worldTransform() const
Definition orientedBox.h:19
void setHalfExtents(const Vector3 &halfExtents)
bool intersectsRay(const Ray &ray, Vector3 *point=nullptr) const
void setWorldTransform(const Matrix4 &value)
Infinite ray defined by origin and direction for raycasting and picking.
Definition ray.h:14
4x4 column-major transformation matrix with SIMD acceleration.
Definition matrix4.h:31
3D vector for positions, directions, and normals with multi-backend SIMD acceleration.
Definition vector3.h:29