mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-07 03:51:50 +00:00
fix: extended blocks raycast fix
This commit is contained in:
parent
c89d31ca20
commit
b3ae8484a2
4 changed files with 104 additions and 83 deletions
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
// Axis Aligned Bounding Box
|
||||
/// @brief Axis Aligned Bounding Box
|
||||
struct AABB {
|
||||
glm::vec3 a {0.0f};
|
||||
glm::vec3 b {1.0f};
|
||||
|
|
@ -13,17 +13,17 @@ struct AABB {
|
|||
AABB(glm::vec3 size) : a(0.0f), b(size) {
|
||||
}
|
||||
|
||||
/* Get AABB point with minimal x,y,z */
|
||||
/// @brief Get AABB point with minimal x,y,z
|
||||
inline glm::vec3 min() const {
|
||||
return glm::min(a, b);
|
||||
}
|
||||
|
||||
/* Get AABB point with minimal x,y,z */
|
||||
/// @brief Get AABB point with minimal x,y,z
|
||||
inline glm::vec3 max() const {
|
||||
return glm::max(a, b);
|
||||
}
|
||||
|
||||
/* Get AABB dimensions: width, height, depth */
|
||||
/// @brief Get AABB dimensions: width, height, depth
|
||||
inline glm::vec3 size() const {
|
||||
return glm::vec3(
|
||||
fabs(b.x - a.x),
|
||||
|
|
@ -36,14 +36,14 @@ struct AABB {
|
|||
return (a + b) * 0.5f;
|
||||
}
|
||||
|
||||
/* Multiply AABB size from center */
|
||||
/// @brief Multiply AABB size from center
|
||||
inline void scale(const glm::vec3 mul) {
|
||||
glm::vec3 center = (a + b) * 0.5f;
|
||||
a = (a - center) * mul + center;
|
||||
b = (b - center) * mul + center;
|
||||
}
|
||||
|
||||
/* Multiply AABB size from given origin */
|
||||
/// @brief Multiply AABB size from given origin
|
||||
inline void scale(const glm::vec3 mul, const glm::vec3 orig) {
|
||||
glm::vec3 beg = min();
|
||||
glm::vec3 end = max();
|
||||
|
|
@ -52,7 +52,7 @@ struct AABB {
|
|||
b = (b - center) * mul + center;
|
||||
}
|
||||
|
||||
/* Check if given point is inside */
|
||||
/// @brief Check if given point is inside
|
||||
inline bool contains(const glm::vec3 pos) const {
|
||||
const glm::vec3 p = min();
|
||||
const glm::vec3 s = size();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue