2018-10-06 20:39:40 -07:00
|
|
|
#pragma once
|
2015-08-28 21:49:19 -07:00
|
|
|
|
2016-03-04 15:03:26 -08:00
|
|
|
#include "zeus/CVector3f.hpp"
|
2015-08-28 21:49:19 -07:00
|
|
|
|
2018-12-07 17:16:50 -08:00
|
|
|
namespace zeus {
|
|
|
|
class CSphere {
|
2015-08-28 21:49:19 -07:00
|
|
|
public:
|
2019-02-23 23:15:32 -08:00
|
|
|
constexpr CSphere(const CVector3f& position, float radius) : position(position), radius(radius) {}
|
2015-08-28 21:49:19 -07:00
|
|
|
|
2020-02-29 01:33:29 -08:00
|
|
|
[[nodiscard]] CVector3f getSurfaceNormal(const CVector3f& coord) const { return (coord - position).normalized(); }
|
2015-08-28 21:49:19 -07:00
|
|
|
|
2020-02-29 01:33:29 -08:00
|
|
|
[[nodiscard]] bool intersects(const CSphere& other) const {
|
|
|
|
const float dist = (position - other.position).magnitude();
|
2018-12-07 17:16:50 -08:00
|
|
|
return dist < (radius + other.radius);
|
|
|
|
}
|
2015-11-02 10:44:46 -08:00
|
|
|
|
2018-12-07 17:16:50 -08:00
|
|
|
CVector3f position;
|
|
|
|
float radius;
|
2015-08-28 21:49:19 -07:00
|
|
|
};
|
2018-12-07 21:23:50 -08:00
|
|
|
} // namespace zeus
|