|
|
|
|
@ -35,10 +35,10 @@ applying transformation, the scale factor is averaged from all axes.
|
|
|
|
|
@see Sphere2D, Sphere3D |
|
|
|
|
@todo Assert for asymmetric scaling |
|
|
|
|
*/ |
|
|
|
|
template<std::uint8_t dimensions> class MAGNUM_PHYSICS_EXPORT Sphere: public AbstractShape<dimensions> { |
|
|
|
|
template<UnsignedInt dimensions> class MAGNUM_PHYSICS_EXPORT Sphere: public AbstractShape<dimensions> { |
|
|
|
|
public: |
|
|
|
|
/** @brief Constructor */ |
|
|
|
|
inline explicit Sphere(const typename DimensionTraits<dimensions>::VectorType& position, float radius): _position(position), _transformedPosition(position), _radius(radius), _transformedRadius(radius) {} |
|
|
|
|
inline explicit Sphere(const typename DimensionTraits<dimensions>::VectorType& position, Float radius): _position(position), _transformedPosition(position), _radius(radius), _transformedRadius(radius) {} |
|
|
|
|
|
|
|
|
|
inline typename AbstractShape<dimensions>::Type type() const override { |
|
|
|
|
return AbstractShape<dimensions>::Type::Sphere; |
|
|
|
|
@ -59,10 +59,10 @@ template<std::uint8_t dimensions> class MAGNUM_PHYSICS_EXPORT Sphere: public Abs
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** @brief Radius */ |
|
|
|
|
inline float radius() const { return _radius; } |
|
|
|
|
inline Float radius() const { return _radius; } |
|
|
|
|
|
|
|
|
|
/** @brief Set radius */ |
|
|
|
|
inline void setRadius(float radius) { _radius = radius; } |
|
|
|
|
inline void setRadius(Float radius) { _radius = radius; } |
|
|
|
|
|
|
|
|
|
/** @brief Transformed position */ |
|
|
|
|
inline typename DimensionTraits<dimensions>::VectorType transformedPosition() const { |
|
|
|
|
@ -70,7 +70,7 @@ template<std::uint8_t dimensions> class MAGNUM_PHYSICS_EXPORT Sphere: public Abs
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** @brief Transformed radius */ |
|
|
|
|
inline float transformedRadius() const { |
|
|
|
|
inline Float transformedRadius() const { |
|
|
|
|
return _transformedRadius; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -89,7 +89,7 @@ template<std::uint8_t dimensions> class MAGNUM_PHYSICS_EXPORT Sphere: public Abs
|
|
|
|
|
private: |
|
|
|
|
typename DimensionTraits<dimensions>::VectorType _position, |
|
|
|
|
_transformedPosition; |
|
|
|
|
float _radius, _transformedRadius; |
|
|
|
|
Float _radius, _transformedRadius; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
/** @brief Two-dimensional sphere */ |
|
|
|
|
@ -99,13 +99,13 @@ typedef Sphere<2> Sphere2D;
|
|
|
|
|
typedef Sphere<3> Sphere3D; |
|
|
|
|
|
|
|
|
|
/** @collisionoperator{Point,Sphere} */ |
|
|
|
|
template<std::uint8_t dimensions> inline bool operator%(const Point<dimensions>& a, const Sphere<dimensions>& b) { return b % a; } |
|
|
|
|
template<UnsignedInt dimensions> inline bool operator%(const Point<dimensions>& a, const Sphere<dimensions>& b) { return b % a; } |
|
|
|
|
|
|
|
|
|
/** @collisionoperator{Line,Sphere} */ |
|
|
|
|
template<std::uint8_t dimensions> inline bool operator%(const Line<dimensions>& a, const Sphere<dimensions>& b) { return b % a; } |
|
|
|
|
template<UnsignedInt dimensions> inline bool operator%(const Line<dimensions>& a, const Sphere<dimensions>& b) { return b % a; } |
|
|
|
|
|
|
|
|
|
/** @collisionoperator{LineSegment,Sphere} */ |
|
|
|
|
template<std::uint8_t dimensions> inline bool operator%(const LineSegment<dimensions>& a, const Sphere<dimensions>& b) { return b % a; } |
|
|
|
|
template<UnsignedInt dimensions> inline bool operator%(const LineSegment<dimensions>& a, const Sphere<dimensions>& b) { return b % a; } |
|
|
|
|
|
|
|
|
|
}} |
|
|
|
|
|
|
|
|
|
|