X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fmodel%2Fshape.cpp;h=e9364bd45498d0f06bea9efa09435998fe502e48;hb=5998b18978bd8e7a0c9deb516474634e1d3521c9;hp=1c831498e6e36a16cd6d1710c806405f7ca6c076;hpb=b7d09e1e35ef90282c97509e0020b20db3c7ea9f;p=blank.git diff --git a/src/model/shape.cpp b/src/model/shape.cpp index 1c83149..e9364bd 100644 --- a/src/model/shape.cpp +++ b/src/model/shape.cpp @@ -5,9 +5,9 @@ namespace blank { void Shape::Vertices( - Model::Positions &vertex, - Model::Normals &normal, - Model::Indices &index + EntityModel::Positions &vertex, + EntityModel::Normals &normal, + EntityModel::Indices &index ) const { for (const auto &pos : vtx_pos) { vertex.emplace_back(pos); @@ -21,11 +21,11 @@ void Shape::Vertices( } void Shape::Vertices( - Model::Positions &vertex, - Model::Normals &normal, - Model::Indices &index, + EntityModel::Positions &vertex, + EntityModel::Normals &normal, + EntityModel::Indices &index, const glm::mat4 &transform, - Model::Index idx_offset + EntityModel::Index idx_offset ) const { for (const auto &pos : vtx_pos) { vertex.emplace_back(transform * glm::vec4(pos, 1.0f)); @@ -80,6 +80,16 @@ bool NullShape::Intersects( return false; } +bool NullShape::Intersects( + const glm::mat4 &, + const AABB &, + const glm::mat4 &, + float &, + glm::vec3 & +) const noexcept { + return false; +} + CuboidShape::CuboidShape(const AABB &b) : Shape() @@ -167,6 +177,16 @@ bool CuboidShape::Intersects( return Intersection(ray, bb, M, &dist, &normal); } +bool CuboidShape::Intersects( + const glm::mat4 &M, + const AABB &box, + const glm::mat4 &box_M, + float &depth, + glm::vec3 &normal +) const noexcept { + return Intersection(bb, M, box, box_M, depth, normal); +} + StairShape::StairShape(const AABB &bb, const glm::vec2 &clip) : Shape() @@ -326,4 +346,15 @@ bool StairShape::Intersects( } } +bool StairShape::Intersects( + const glm::mat4 &M, + const AABB &box, + const glm::mat4 &box_M, + float &depth, + glm::vec3 &normal +) const noexcept { + // TODO: this is wrong, but simple. so for now will have to do + return Intersection(bot, M, box, box_M, depth, normal) || Intersection(top, M, box, box_M, depth, normal); +} + }