bbox fixes
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -34,6 +34,8 @@ class MinecraftPipeline : public Renderer3DPipeline {
|
||||
return manager.getTextureOffset();
|
||||
}
|
||||
|
||||
const McpipBlockData& getBlockData() const { return manager.getBlockData(); }
|
||||
|
||||
private:
|
||||
BlockizerProgramsManager manager;
|
||||
RendererCore* rendererCore;
|
||||
|
||||
@@ -20,9 +20,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<CoreBBox>& t_bboxes,
|
||||
const u32& startIndex, const u32& stopIndex);
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -14,6 +14,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;
|
||||
@@ -131,6 +137,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);
|
||||
}
|
||||
@@ -167,8 +178,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;
|
||||
|
||||
Reference in New Issue
Block a user