1 parent 8072e4a commit a0a7e40Copy full SHA for a0a7e40
1 file changed
src/include/sndx/collision/rect.hpp
@@ -311,4 +311,18 @@ namespace sndx::collision {
311
static_assert(VolumeN<Rect2D, 2>);
312
static_assert(VolumeN<Rect3D, 3>);
313
static_assert(VolumeN<Rect4D, 4>);
314
+
315
+ [[nodiscard]]
316
+ inline Rect3D transform(const Rect3D& in, const glm::mat4& tform) {
317
+ glm::vec3 center{ tform * glm::vec4(in.getCenter(), 1.0f) };
318
319
+ auto absT = glm::mat3{
320
+ glm::abs(glm::vec3(tform[0])),
321
+ glm::abs(glm::vec3(tform[1])),
322
+ glm::abs(glm::vec3(tform[2]))
323
+ };
324
+ glm::vec3 extents{ absT * in.getSize() };
325
326
+ return sndx::collision::Rect3D{ center - extents, center + extents };
327
+ }
328
}
0 commit comments