X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fmodel%2FShape.hpp;h=c6964f9c410110d10e4ed48933b07bce0512eb42;hb=c52405fad9c070e1370f852234c6eb723b52916c;hp=5d4036b6d30e925ab77c256f80326b1490b3853b;hpb=b7d09e1e35ef90282c97509e0020b20db3c7ea9f;p=blank.git diff --git a/src/model/Shape.hpp b/src/model/Shape.hpp index 5d4036b..c6964f9 100644 --- a/src/model/Shape.hpp +++ b/src/model/Shape.hpp @@ -2,7 +2,7 @@ #define BLANK_MODEL_SHAPE_HPP_ #include "BlockModel.hpp" -#include "Model.hpp" +#include "EntityModel.hpp" #include "OutlineModel.hpp" #include @@ -11,6 +11,7 @@ namespace blank { +class AABB; class Ray; struct Shape { @@ -20,26 +21,26 @@ struct Shape { /// the number of vertex indices this shape has size_t VertexIndexCount() const noexcept { return vtx_idx.size(); } - const Model::Normal &VertexNormal(size_t idx) const noexcept { return vtx_nrm[idx]; } - Model::Normal VertexNormal( + const EntityModel::Normal &VertexNormal(size_t idx) const noexcept { return vtx_nrm[idx]; } + EntityModel::Normal VertexNormal( size_t idx, const glm::mat4 &transform ) const noexcept { - return Model::Normal(transform * glm::vec4(vtx_nrm[idx], 0.0f)); + return EntityModel::Normal(transform * glm::vec4(vtx_nrm[idx], 0.0f)); } /// fill given buffers with this shape's elements with an /// optional transform and offset void Vertices( - Model::Positions &vertex, - Model::Normals &normal, - Model::Indices &index + EntityModel::Positions &vertex, + EntityModel::Normals &normal, + EntityModel::Indices &index ) const; void 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 = 0 + EntityModel::Index idx_offset = 0 ) const; void Vertices( BlockModel::Positions &vertex, @@ -73,8 +74,18 @@ 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, + float &depth, + glm::vec3 &normal + ) const noexcept = 0; + protected: - void SetShape(const Model::Positions &pos, const Model::Normals &nrm, const Model::Indices &idx) { + void SetShape(const EntityModel::Positions &pos, const EntityModel::Normals &nrm, const EntityModel::Indices &idx) { vtx_pos = pos; vtx_nrm = nrm; vtx_idx = idx; @@ -85,9 +96,9 @@ protected: } private: - Model::Positions vtx_pos; - Model::Normals vtx_nrm; - Model::Indices vtx_idx; + EntityModel::Positions vtx_pos; + EntityModel::Normals vtx_nrm; + EntityModel::Indices vtx_idx; OutlineModel::Positions out_pos; OutlineModel::Indices out_idx;