fix bbox const
This commit is contained in:
@@ -25,37 +25,46 @@ class BBox : public CoreBBox {
|
|||||||
explicit BBox(const BBox& t_bbox, const M4x4& t_matrix);
|
explicit BBox(const BBox& t_bbox, const M4x4& t_matrix);
|
||||||
explicit BBox(const BBox& t_bbox);
|
explicit BBox(const BBox& t_bbox);
|
||||||
explicit BBox(Vec4* t_vertices);
|
explicit BBox(Vec4* t_vertices);
|
||||||
const float& getHeight() { return _height; }
|
|
||||||
const float& getDepth() { return _depth; }
|
const float& getHeight() const { return _height; }
|
||||||
const float& getWidth() { return _width; }
|
const float& getDepth() const { return _depth; }
|
||||||
|
const float& getWidth() const { return _width; }
|
||||||
|
|
||||||
/** @returns the vector directly in middle of the bounding box. */
|
/** @returns the vector directly in middle of the bounding box. */
|
||||||
const Vec4& getCenter() { return _centerVector; }
|
const Vec4& getCenter() const { return _centerVector; }
|
||||||
|
|
||||||
/** @returns the front face (further on z-axis) */
|
/** @returns the front face (further on z-axis) */
|
||||||
const BBoxFace& getFrontFace() { return _frontFace; }
|
const BBoxFace& getFrontFace() const { return _frontFace; }
|
||||||
|
|
||||||
/** @returns the back face (nearer on z-axis) */
|
/** @returns the back face (nearer on z-axis) */
|
||||||
const BBoxFace& getBackFace() { return _backFace; }
|
const BBoxFace& getBackFace() const { return _backFace; }
|
||||||
|
|
||||||
/** @returns the left face (further on x-axis) */
|
/** @returns the left face (further on x-axis) */
|
||||||
const BBoxFace& getLeftFace() { return _leftFace; }
|
const BBoxFace& getLeftFace() const { return _leftFace; }
|
||||||
|
|
||||||
/** @returns the right face (nearer on x-axis) */
|
/** @returns the right face (nearer on x-axis) */
|
||||||
const BBoxFace& getRightFace() { return _rightFace; }
|
const BBoxFace& getRightFace() const { return _rightFace; }
|
||||||
|
|
||||||
/** @returns the top face (further on y-axis) */
|
/** @returns the top face (further on y-axis) */
|
||||||
const BBoxFace& getTopFace() { return _topFace; }
|
const BBoxFace& getTopFace() const { return _topFace; }
|
||||||
|
|
||||||
/** @returns the bottom face (nearer on y-axis) */
|
/** @returns the bottom face (nearer on y-axis) */
|
||||||
const BBoxFace& getBottomFace() { return _bottomFace; }
|
const BBoxFace& getBottomFace() const { return _bottomFace; }
|
||||||
|
|
||||||
/** @returns the lower (x, y, z) boundary of the box. */
|
/** @returns the lower (x, y, z) boundary of the box. */
|
||||||
Vec4 min();
|
Vec4 min() const;
|
||||||
/** @returns the upper (x, y, z) boundary of the box. */
|
/** @returns the upper (x, y, z) boundary of the box. */
|
||||||
Vec4 max();
|
Vec4 max() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param res_min Vec4 to store the min result
|
* @param res_min Vec4 to store the min result
|
||||||
* @param res_max Vec4 to store the min result
|
* @param res_max Vec4 to store the min result
|
||||||
* @brief Calc and stores the min and max points of box at a single loop
|
* @brief Calc and stores the min and max points of box at a single loop
|
||||||
* */
|
* */
|
||||||
void getMinMax(Vec4* res_min, Vec4* res_max);
|
void getMinMax(Vec4* res_min, Vec4* res_max) const;
|
||||||
|
|
||||||
/** Get new transformed BBox by model matrix */
|
/** Get new transformed BBox by model matrix */
|
||||||
BBox getTransformed(const M4x4& t_matrix);
|
BBox getTransformed(const M4x4& t_matrix) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
float _height, _depth, _width;
|
float _height, _depth, _width;
|
||||||
|
|||||||
@@ -32,15 +32,22 @@ class CoreBBox {
|
|||||||
|
|
||||||
Vec4 vertices[8];
|
Vec4 vertices[8];
|
||||||
|
|
||||||
const Vec4& operator[](const u8& i) { return vertices[i]; }
|
const Vec4& operator[](const u8& i) const { return vertices[i]; }
|
||||||
|
|
||||||
const u8 getVertexCount() { return 8; }
|
const u8 getVertexCount() const { return 8; }
|
||||||
|
|
||||||
void print() const;
|
void print() const;
|
||||||
void print(const char* name) const;
|
void print(const char* name) const;
|
||||||
void print(const std::string& name) const { print(name.c_str()); }
|
void print(const std::string& name) const { print(name.c_str()); }
|
||||||
std::string getPrint(const char* name = nullptr) const;
|
std::string getPrint(const char* name = nullptr) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Check if bbox is in view frustum
|
||||||
|
*
|
||||||
|
* @param frustumPlanes Available in engine.renderer.core.renderer3D.frustumPlanes
|
||||||
|
* @param model Model matrix
|
||||||
|
* @param margins Optional margins
|
||||||
|
*/
|
||||||
CoreBBoxFrustum isInFrustum(const Plane* frustumPlanes, const M4x4& model,
|
CoreBBoxFrustum isInFrustum(const Plane* frustumPlanes, const M4x4& model,
|
||||||
const float* margins = nullptr) const;
|
const float* margins = nullptr) const;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ BBox::BBox(const BBox& t_bbox, const M4x4& t_matrix) {
|
|||||||
|
|
||||||
BBox::BBox(Vec4* t_vertices) : CoreBBox(t_vertices) { setData(); }
|
BBox::BBox(Vec4* t_vertices) : CoreBBox(t_vertices) { setData(); }
|
||||||
|
|
||||||
BBox BBox::getTransformed(const M4x4& t_matrix) {
|
BBox BBox::getTransformed(const M4x4& t_matrix) const {
|
||||||
return BBox(*this, t_matrix);
|
return BBox(*this, t_matrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,7 +64,7 @@ void BBox::setData() {
|
|||||||
_bottomFace = BBoxFace(vertices[0], vertices[5], vertices[0].y);
|
_bottomFace = BBoxFace(vertices[0], vertices[5], vertices[0].y);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec4 BBox::min() {
|
Vec4 BBox::min() const {
|
||||||
Vec4 temp, _min;
|
Vec4 temp, _min;
|
||||||
u8 isInitialized = 0;
|
u8 isInitialized = 0;
|
||||||
|
|
||||||
@@ -83,7 +83,7 @@ Vec4 BBox::min() {
|
|||||||
return _min;
|
return _min;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec4 BBox::max() {
|
Vec4 BBox::max() const {
|
||||||
Vec4 temp, _max;
|
Vec4 temp, _max;
|
||||||
u8 isInitialized = 0;
|
u8 isInitialized = 0;
|
||||||
|
|
||||||
@@ -102,7 +102,7 @@ Vec4 BBox::max() {
|
|||||||
return _max;
|
return _max;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BBox::getMinMax(Vec4* res_min, Vec4* res_max) {
|
void BBox::getMinMax(Vec4* res_min, Vec4* res_max) const {
|
||||||
Vec4 temp = Vec4();
|
Vec4 temp = Vec4();
|
||||||
|
|
||||||
u8 isInitialized = 0;
|
u8 isInitialized = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user