candlewick 0.1.0
A renderer
Loading...
Searching...
No Matches
Collision.h
Go to the documentation of this file.
1#pragma once
2#include "math_types.h"
3#include <coal/BV/AABB.h>
4#include <coal/BV/OBB.h>
5
6namespace candlewick {
7
8using coal::AABB;
9using coal::OBB;
10
11inline Mat4f toTransformationMatrix(const AABB &aabb) {
12 Mat4f T = Mat4f::Identity();
13 Float3 halfExtents = 0.5f * (aabb.max_ - aabb.min_).cast<float>();
14 T.block<3, 3>(0, 0) = halfExtents.asDiagonal();
15 T.topRightCorner<3, 1>() = aabb.center().cast<float>();
16 return T;
17}
18
19inline Mat4f toTransformationMatrix(const OBB &obb) {
20 Mat4f T = Mat4f::Identity();
21 auto D = obb.extent.asDiagonal();
22 T.block<3, 3>(0, 0) = (obb.axes * D).cast<float>();
23 T.topRightCorner<3, 1>() = obb.center().cast<float>();
24 return T;
25}
26
27} // namespace candlewick
Definition Camera.h:8
Eigen::Vector3f Float3
Definition math_types.h:8
Mat4f toTransformationMatrix(const AABB &aabb)
Definition Collision.h:11
Eigen::Matrix4f Mat4f
Definition math_types.h:11