diff --git a/src/Physics/AxisAlignedBox.h b/src/Physics/AxisAlignedBox.h index 2f67eb456..c007c8ea6 100644 --- a/src/Physics/AxisAlignedBox.h +++ b/src/Physics/AxisAlignedBox.h @@ -34,6 +34,10 @@ template class PHYSICS_EXPORT AxisAlignedBox: public Ab /** @brief Constructor */ inline AxisAlignedBox(const typename DimensionTraits::VectorType& position, const typename DimensionTraits::VectorType& size): _position(position), _transformedPosition(position), _size(size), _transformedSize(size) {} + inline typename AbstractShape::Type type() const { + return AbstractShape::Type::AxisAlignedBox; + } + void applyTransformation(const typename DimensionTraits::MatrixType& transformation); /** @brief Position */ @@ -64,11 +68,6 @@ template class PHYSICS_EXPORT AxisAlignedBox: public Ab return _transformedSize; } - protected: - inline typename AbstractShape::Type type() const { - return AbstractShape::Type::AxisAlignedBox; - } - private: Math::Vector _position, _transformedPosition, _size, _transformedSize; diff --git a/src/Physics/Box.h b/src/Physics/Box.h index 25eed9345..896adaa67 100644 --- a/src/Physics/Box.h +++ b/src/Physics/Box.h @@ -35,6 +35,10 @@ template class PHYSICS_EXPORT Box: public AbstractShape /** @brief Constructor */ inline Box(const typename DimensionTraits::MatrixType& transformation): _transformation(transformation), _transformedTransformation(transformation) {} + inline typename AbstractShape::Type type() const { + return AbstractShape::Type::Box; + } + void applyTransformation(const typename DimensionTraits::MatrixType& transformation); /** @brief Transformation */ @@ -52,11 +56,6 @@ template class PHYSICS_EXPORT Box: public AbstractShape return _transformedTransformation; } - protected: - inline typename AbstractShape::Type type() const { - return AbstractShape::Type::Box; - } - private: Math::Matrix _transformation, _transformedTransformation; diff --git a/src/Physics/Capsule.h b/src/Physics/Capsule.h index 9ee660ef0..eb059b13e 100644 --- a/src/Physics/Capsule.h +++ b/src/Physics/Capsule.h @@ -39,6 +39,10 @@ template class PHYSICS_EXPORT Capsule: public AbstractS /** @brief Constructor */ inline Capsule(const typename DimensionTraits::VectorType& a, const typename DimensionTraits::VectorType& b, float radius): _a(a), _transformedA(a), _b(b), _transformedB(b), _radius(radius), _transformedRadius(radius) {} + inline typename AbstractShape::Type type() const { + return AbstractShape::Type::Capsule; + } + void applyTransformation(const typename DimensionTraits::MatrixType& transformation); bool collides(const AbstractShape* other) const; @@ -90,11 +94,6 @@ template class PHYSICS_EXPORT Capsule: public AbstractS /** @brief Collision with sphere */ bool operator%(const Sphere& other) const; - protected: - inline typename AbstractShape::Type type() const { - return AbstractShape::Type::Capsule; - } - private: Math::Vector _a, _transformedA, _b, _transformedB; diff --git a/src/Physics/Line.h b/src/Physics/Line.h index 880bc2ea6..21c0c31ae 100644 --- a/src/Physics/Line.h +++ b/src/Physics/Line.h @@ -35,6 +35,10 @@ template class PHYSICS_EXPORT Line: public AbstractShap /** @brief Constructor */ inline Line(const typename DimensionTraits::VectorType& a, const typename DimensionTraits::VectorType& b): _a(a), _transformedA(a), _b(b), _transformedB(b) {} + inline typename AbstractShape::Type type() const { + return AbstractShape::Type::Line; + } + void applyTransformation(const typename DimensionTraits::MatrixType& transformation); /** @brief First point */ @@ -67,11 +71,6 @@ template class PHYSICS_EXPORT Line: public AbstractShap return _transformedB; } - protected: - inline typename AbstractShape::Type type() const { - return AbstractShape::Type::Line; - } - private: Math::Vector _a, _transformedA, _b, _transformedB; diff --git a/src/Physics/LineSegment.h b/src/Physics/LineSegment.h index 2a5f1739c..82fe11861 100644 --- a/src/Physics/LineSegment.h +++ b/src/Physics/LineSegment.h @@ -33,8 +33,9 @@ template class LineSegment: public Line { /** @brief Constructor */ inline LineSegment(const typename DimensionTraits::VectorType& a, const typename DimensionTraits::VectorType& b): Line(a, b) {} - protected: - inline typename AbstractShape::Type type() const { return AbstractShape::Type::LineSegment; } + inline typename AbstractShape::Type type() const { + return AbstractShape::Type::LineSegment; + } }; /** @brief Two-dimensional line segment */ diff --git a/src/Physics/Plane.h b/src/Physics/Plane.h index 6afea764b..3895b6f6d 100644 --- a/src/Physics/Plane.h +++ b/src/Physics/Plane.h @@ -35,6 +35,8 @@ class PHYSICS_EXPORT Plane: public AbstractShape<3> { /** @brief Constructor */ inline Plane(const Vector3& position, const Vector3& normal): _position(position), _transformedPosition(position), _normal(normal), _transformedNormal(normal) {} + inline Type type() const { return Type::Plane; } + #ifndef DOXYGEN_GENERATING_OUTPUT void applyTransformation(const Matrix4& transformation); bool collides(const AbstractShape<3>* other) const; @@ -75,9 +77,6 @@ class PHYSICS_EXPORT Plane: public AbstractShape<3> { /** @brief Collision with line segment */ bool operator%(const LineSegment3D& other) const; - protected: - inline Type type() const { return Type::Plane; } - private: Vector3 _position, _transformedPosition, _normal, _transformedNormal; diff --git a/src/Physics/Point.h b/src/Physics/Point.h index 60557b6b8..0644c85d9 100644 --- a/src/Physics/Point.h +++ b/src/Physics/Point.h @@ -34,6 +34,10 @@ template class PHYSICS_EXPORT Point: public AbstractSha /** @brief Constructor */ inline Point(const typename DimensionTraits::VectorType& position): _position(position), _transformedPosition(position) {} + inline typename AbstractShape::Type type() const { + return AbstractShape::Type::Point; + } + void applyTransformation(const typename DimensionTraits::MatrixType& transformation); /** @brief Position */ @@ -51,9 +55,6 @@ template class PHYSICS_EXPORT Point: public AbstractSha return _transformedPosition; } - protected: - inline typename AbstractShape::Type type() const { return AbstractShape::Type::Point; } - private: Math::Vector _position, _transformedPosition; }; diff --git a/src/Physics/ShapeGroup.h b/src/Physics/ShapeGroup.h index 1f5900148..768731bd6 100644 --- a/src/Physics/ShapeGroup.h +++ b/src/Physics/ShapeGroup.h @@ -99,13 +99,14 @@ template class PHYSICS_EXPORT ShapeGroup: public Abstra /** @brief Move assignment */ ShapeGroup& operator=(ShapeGroup&& other); + inline typename AbstractShape::Type type() const { + return AbstractShape::Type::ShapeGroup; + } + void applyTransformation(const typename DimensionTraits::MatrixType& transformation); bool collides(const AbstractShape* other) const; - protected: - virtual typename AbstractShape::Type type() const { return AbstractShape::Type::ShapeGroup; } - private: inline ShapeGroup(int operation, AbstractShape* a, AbstractShape* b): operation(operation), a(a), b(b) {} diff --git a/src/Physics/Sphere.h b/src/Physics/Sphere.h index 9c92db521..36992346e 100644 --- a/src/Physics/Sphere.h +++ b/src/Physics/Sphere.h @@ -40,6 +40,10 @@ template class PHYSICS_EXPORT Sphere: public AbstractSh /** @brief Constructor */ inline Sphere(const typename DimensionTraits::VectorType& position, float radius): _position(position), _transformedPosition(position), _radius(radius), _transformedRadius(radius) {} + inline typename AbstractShape::Type type() const { + return AbstractShape::Type::Sphere; + } + void applyTransformation(const typename DimensionTraits::MatrixType& transformation); bool collides(const AbstractShape* other) const; @@ -82,11 +86,6 @@ template class PHYSICS_EXPORT Sphere: public AbstractSh /** @brief Collision with sphere */ bool operator%(const Sphere& other) const; - protected: - inline typename AbstractShape::Type type() const { - return AbstractShape::Type::Sphere; - } - private: Math::Vector _position, _transformedPosition;