1
0
Fork 0
Univerxel/src/core/geometry/Shapes.hpp

29 lines
593 B
C++

#pragma once
#include "../flags.hpp"
#include "../data/math.hpp"
#include "IBox.hpp"
namespace geometry {
enum class Shape {
Cube,
Sphere
};
static _FORCE_INLINE_ bool InShape(Shape shape, glm::llvec3 center, int radius, glm::llvec3 pos, glm::vec3 size) {
switch (shape) {
case Shape::Cube:
return IBox::fromCenter(center, radius).contains(
IBox::fromMin(pos, size)) != IBox::ContainmentType::Disjoint;
case Shape::Sphere:
return glm::length2(center - pos) < glm::pow2(radius + (int)size.x);
default:
return false;
}
}
};