namespace blank {
+class AABB;
class Ray;
struct Shape {
glm::vec3 &normal
) const noexcept = 0;
+ /// Check for intersection with given OBB.
+ /// The OBB is defined by box and box_M, M is applied to the shape.
+ virtual bool Intersects(
+ const glm::mat4 &M,
+ const AABB &box,
+ const glm::mat4 &box_M
+ ) const noexcept = 0;
+
protected:
void SetShape(const Model::Positions &pos, const Model::Normals &nrm, const Model::Indices &idx) {
vtx_pos = pos;
return false;
}
+bool NullShape::Intersects(
+ const glm::mat4 &,
+ const AABB &,
+ const glm::mat4 &
+) const noexcept {
+ return false;
+}
+
CuboidShape::CuboidShape(const AABB &b)
: Shape()
return Intersection(ray, bb, M, &dist, &normal);
}
+bool CuboidShape::Intersects(
+ const glm::mat4 &M,
+ const AABB &box,
+ const glm::mat4 &box_M
+) const noexcept {
+ return Intersection(bb, M, box, box_M);
+}
+
StairShape::StairShape(const AABB &bb, const glm::vec2 &clip)
: Shape()
}
}
+bool StairShape::Intersects(
+ const glm::mat4 &M,
+ const AABB &box,
+ const glm::mat4 &box_M
+) const noexcept {
+ return Intersection(bot, M, box, box_M) || Intersection(top, M, box, box_M);
+}
+
}
NullShape();
bool Intersects(const Ray &, const glm::mat4 &, float &, glm::vec3 &) const noexcept override;
+ bool Intersects(const glm::mat4 &, const AABB &, const glm::mat4 &) const noexcept override;
};
CuboidShape(const AABB &bounds);
bool Intersects(const Ray &, const glm::mat4 &, float &, glm::vec3 &) const noexcept override;
+ bool Intersects(const glm::mat4 &, const AABB &, const glm::mat4 &) const noexcept override;
private:
AABB bb;
StairShape(const AABB &bounds, const glm::vec2 &clip);
bool Intersects(const Ray &, const glm::mat4 &, float &, glm::vec3 &) const noexcept override;
+ bool Intersects(const glm::mat4 &, const AABB &, const glm::mat4 &) const noexcept override;
private:
AABB top, bot;