diff --git a/engine/inc/renderer/3d/bbox/bbox.hpp b/engine/inc/renderer/3d/bbox/bbox.hpp index 57777d1..7ef8a90 100644 --- a/engine/inc/renderer/3d/bbox/bbox.hpp +++ b/engine/inc/renderer/3d/bbox/bbox.hpp @@ -22,6 +22,8 @@ class BBox : public CoreBBox { explicit BBox(CoreBBox** t_bboxes, const u32& count); explicit BBox(Vec4* t_vertices, u32* faces, u32 t_count); explicit BBox(Vec4* t_vertices, u32 t_count); + explicit BBox(const BBox& t_bbox, const M4x4& t_matrix); + explicit BBox(const BBox& t_bbox); explicit BBox(Vec4* t_vertices); const float& getHeight() { return _height; } const float& getDepth() { return _depth; } @@ -52,6 +54,9 @@ class BBox : public CoreBBox { * */ void getMinMax(Vec4* res_min, Vec4* res_max); + /** Get new transformed BBox by model matrix */ + BBox getTransformed(const M4x4& t_matrix); + protected: float _height, _depth, _width; Vec4 _centerVector; diff --git a/engine/inc/renderer/3d/pipeline/minecraft/minecraft_pipeline.hpp b/engine/inc/renderer/3d/pipeline/minecraft/minecraft_pipeline.hpp index 0d195c7..7a270e8 100644 --- a/engine/inc/renderer/3d/pipeline/minecraft/minecraft_pipeline.hpp +++ b/engine/inc/renderer/3d/pipeline/minecraft/minecraft_pipeline.hpp @@ -34,6 +34,8 @@ class MinecraftPipeline : public Renderer3DPipeline { return manager.getTextureOffset(); } + const McpipBlockData& getBlockData() const { return manager.getBlockData(); } + private: BlockizerProgramsManager manager; RendererCore* rendererCore; diff --git a/engine/inc/renderer/core/3d/bbox/core_bbox.hpp b/engine/inc/renderer/core/3d/bbox/core_bbox.hpp index 29576fa..0d2f4a5 100644 --- a/engine/inc/renderer/core/3d/bbox/core_bbox.hpp +++ b/engine/inc/renderer/core/3d/bbox/core_bbox.hpp @@ -21,9 +21,11 @@ namespace Tyra { /** Bounding box */ class CoreBBox { public: + explicit CoreBBox(); explicit CoreBBox(Vec4* t_vertices, u32* faces, u32 t_count); explicit CoreBBox(Vec4* t_vertices, u32 t_count); explicit CoreBBox(Vec4* t_vertices); + explicit CoreBBox(const CoreBBox& t_bbox); explicit CoreBBox(CoreBBox** t_bboxes, const u32& count); explicit CoreBBox(const std::vector& t_bboxes, const u32& startIndex, const u32& stopIndex); diff --git a/engine/src/renderer/3d/bbox/bbox.cpp b/engine/src/renderer/3d/bbox/bbox.cpp index db8b4ad..4163987 100644 --- a/engine/src/renderer/3d/bbox/bbox.cpp +++ b/engine/src/renderer/3d/bbox/bbox.cpp @@ -25,8 +25,22 @@ BBox::BBox(Vec4* t_vertices, u32* faces, u32 count) setData(); } +BBox::BBox(const BBox& t_bbox) : CoreBBox(t_bbox) { setData(); } + +BBox::BBox(const BBox& t_bbox, const M4x4& t_matrix) { + for (u32 i = 0; i < 8; i++) { + _vertices[i] = t_matrix * _vertices[i]; + } + + setData(); +} + BBox::BBox(Vec4* t_vertices) : CoreBBox(t_vertices) { setData(); } +BBox BBox::getTransformed(const M4x4& t_matrix) { + return BBox(*this, t_matrix); +} + void BBox::setData() { // This might be shortened with Vec4 operator overloading, but current // implementation is more human readable. diff --git a/engine/src/renderer/core/3d/bbox/core_bbox.cpp b/engine/src/renderer/core/3d/bbox/core_bbox.cpp index 542f5de..919fcde 100644 --- a/engine/src/renderer/core/3d/bbox/core_bbox.cpp +++ b/engine/src/renderer/core/3d/bbox/core_bbox.cpp @@ -15,6 +15,12 @@ namespace Tyra { +CoreBBox::CoreBBox() { + for (u32 i = 0; i < 8; i++) { + _vertices[i] = Vec4(0.0F, 0.0F, 0.0F, 1.0F); + } +} + CoreBBox::CoreBBox(CoreBBox** t_bboxes, const u32& count) { float lowX = t_bboxes[0]->_vertices[0].x; float lowY = t_bboxes[0]->_vertices[0].y; @@ -132,6 +138,11 @@ CoreBBox::CoreBBox(Vec4* t_vertices, u32 count) { _vertices[7].set(hiX, hiY, hiZ); } +CoreBBox::CoreBBox(const CoreBBox& t_bbox) { + for (auto i = 0; i < 8; i++) + Vec4::copy(&_vertices[i], t_bbox._vertices[i].xyzw); +} + CoreBBox::CoreBBox(Vec4* t_vertices) { for (auto i = 0; i < 8; i++) Vec4::copy(&_vertices[i], t_vertices[i].xyzw); } @@ -168,8 +179,8 @@ std::string CoreBBox::getPrint(const char* name) const { } CoreBBoxFrustum CoreBBox::isInFrustum(const Plane* frustumPlanes, - const M4x4& model, - const float* margins) const { + const M4x4& model, + const float* margins) const { CoreBBoxFrustum result = IN_FRUSTUM; Vec4 boxCalcTemp; u8 boxIn = 0, boxOut = 0;