Browse Source

Physics: Shape type is public function.

vectorfields
Vladimír Vondruš 14 years ago
parent
commit
71d90580b0
  1. 9
      src/Physics/AxisAlignedBox.h
  2. 9
      src/Physics/Box.h
  3. 9
      src/Physics/Capsule.h
  4. 9
      src/Physics/Line.h
  5. 5
      src/Physics/LineSegment.h
  6. 5
      src/Physics/Plane.h
  7. 7
      src/Physics/Point.h
  8. 7
      src/Physics/ShapeGroup.h
  9. 9
      src/Physics/Sphere.h

9
src/Physics/AxisAlignedBox.h

@ -34,6 +34,10 @@ template<std::uint8_t dimensions> class PHYSICS_EXPORT AxisAlignedBox: public Ab
/** @brief Constructor */
inline AxisAlignedBox(const typename DimensionTraits<dimensions, GLfloat>::VectorType& position, const typename DimensionTraits<dimensions, GLfloat>::VectorType& size): _position(position), _transformedPosition(position), _size(size), _transformedSize(size) {}
inline typename AbstractShape<dimensions>::Type type() const {
return AbstractShape<dimensions>::Type::AxisAlignedBox;
}
void applyTransformation(const typename DimensionTraits<dimensions, GLfloat>::MatrixType& transformation);
/** @brief Position */
@ -64,11 +68,6 @@ template<std::uint8_t dimensions> class PHYSICS_EXPORT AxisAlignedBox: public Ab
return _transformedSize;
}
protected:
inline typename AbstractShape<dimensions>::Type type() const {
return AbstractShape<dimensions>::Type::AxisAlignedBox;
}
private:
Math::Vector<dimensions, GLfloat> _position, _transformedPosition,
_size, _transformedSize;

9
src/Physics/Box.h

@ -35,6 +35,10 @@ template<std::uint8_t dimensions> class PHYSICS_EXPORT Box: public AbstractShape
/** @brief Constructor */
inline Box(const typename DimensionTraits<dimensions, GLfloat>::MatrixType& transformation): _transformation(transformation), _transformedTransformation(transformation) {}
inline typename AbstractShape<dimensions>::Type type() const {
return AbstractShape<dimensions>::Type::Box;
}
void applyTransformation(const typename DimensionTraits<dimensions, GLfloat>::MatrixType& transformation);
/** @brief Transformation */
@ -52,11 +56,6 @@ template<std::uint8_t dimensions> class PHYSICS_EXPORT Box: public AbstractShape
return _transformedTransformation;
}
protected:
inline typename AbstractShape<dimensions>::Type type() const {
return AbstractShape<dimensions>::Type::Box;
}
private:
Math::Matrix<dimensions+1, GLfloat> _transformation,
_transformedTransformation;

9
src/Physics/Capsule.h

@ -39,6 +39,10 @@ template<std::uint8_t dimensions> class PHYSICS_EXPORT Capsule: public AbstractS
/** @brief Constructor */
inline Capsule(const typename DimensionTraits<dimensions, GLfloat>::VectorType& a, const typename DimensionTraits<dimensions, GLfloat>::VectorType& b, float radius): _a(a), _transformedA(a), _b(b), _transformedB(b), _radius(radius), _transformedRadius(radius) {}
inline typename AbstractShape<dimensions>::Type type() const {
return AbstractShape<dimensions>::Type::Capsule;
}
void applyTransformation(const typename DimensionTraits<dimensions, GLfloat>::MatrixType& transformation);
bool collides(const AbstractShape<dimensions>* other) const;
@ -90,11 +94,6 @@ template<std::uint8_t dimensions> class PHYSICS_EXPORT Capsule: public AbstractS
/** @brief Collision with sphere */
bool operator%(const Sphere<dimensions>& other) const;
protected:
inline typename AbstractShape<dimensions>::Type type() const {
return AbstractShape<dimensions>::Type::Capsule;
}
private:
Math::Vector<dimensions, GLfloat> _a, _transformedA,
_b, _transformedB;

9
src/Physics/Line.h

@ -35,6 +35,10 @@ template<std::uint8_t dimensions> class PHYSICS_EXPORT Line: public AbstractShap
/** @brief Constructor */
inline Line(const typename DimensionTraits<dimensions, GLfloat>::VectorType& a, const typename DimensionTraits<dimensions, GLfloat>::VectorType& b): _a(a), _transformedA(a), _b(b), _transformedB(b) {}
inline typename AbstractShape<dimensions>::Type type() const {
return AbstractShape<dimensions>::Type::Line;
}
void applyTransformation(const typename DimensionTraits<dimensions, GLfloat>::MatrixType& transformation);
/** @brief First point */
@ -67,11 +71,6 @@ template<std::uint8_t dimensions> class PHYSICS_EXPORT Line: public AbstractShap
return _transformedB;
}
protected:
inline typename AbstractShape<dimensions>::Type type() const {
return AbstractShape<dimensions>::Type::Line;
}
private:
Math::Vector<dimensions, GLfloat> _a, _transformedA,
_b, _transformedB;

5
src/Physics/LineSegment.h

@ -33,8 +33,9 @@ template<std::uint8_t dimensions> class LineSegment: public Line<dimensions> {
/** @brief Constructor */
inline LineSegment(const typename DimensionTraits<dimensions, GLfloat>::VectorType& a, const typename DimensionTraits<dimensions, GLfloat>::VectorType& b): Line<dimensions>(a, b) {}
protected:
inline typename AbstractShape<dimensions>::Type type() const { return AbstractShape<dimensions>::Type::LineSegment; }
inline typename AbstractShape<dimensions>::Type type() const {
return AbstractShape<dimensions>::Type::LineSegment;
}
};
/** @brief Two-dimensional line segment */

5
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;

7
src/Physics/Point.h

@ -34,6 +34,10 @@ template<std::uint8_t dimensions> class PHYSICS_EXPORT Point: public AbstractSha
/** @brief Constructor */
inline Point(const typename DimensionTraits<dimensions, GLfloat>::VectorType& position): _position(position), _transformedPosition(position) {}
inline typename AbstractShape<dimensions>::Type type() const {
return AbstractShape<dimensions>::Type::Point;
}
void applyTransformation(const typename DimensionTraits<dimensions, GLfloat>::MatrixType& transformation);
/** @brief Position */
@ -51,9 +55,6 @@ template<std::uint8_t dimensions> class PHYSICS_EXPORT Point: public AbstractSha
return _transformedPosition;
}
protected:
inline typename AbstractShape<dimensions>::Type type() const { return AbstractShape<dimensions>::Type::Point; }
private:
Math::Vector<dimensions, GLfloat> _position, _transformedPosition;
};

7
src/Physics/ShapeGroup.h

@ -99,13 +99,14 @@ template<std::uint8_t dimensions> class PHYSICS_EXPORT ShapeGroup: public Abstra
/** @brief Move assignment */
ShapeGroup& operator=(ShapeGroup&& other);
inline typename AbstractShape<dimensions>::Type type() const {
return AbstractShape<dimensions>::Type::ShapeGroup;
}
void applyTransformation(const typename DimensionTraits<dimensions, GLfloat>::MatrixType& transformation);
bool collides(const AbstractShape<dimensions>* other) const;
protected:
virtual typename AbstractShape<dimensions>::Type type() const { return AbstractShape<dimensions>::Type::ShapeGroup; }
private:
inline ShapeGroup(int operation, AbstractShape<dimensions>* a, AbstractShape<dimensions>* b): operation(operation), a(a), b(b) {}

9
src/Physics/Sphere.h

@ -40,6 +40,10 @@ template<std::uint8_t dimensions> class PHYSICS_EXPORT Sphere: public AbstractSh
/** @brief Constructor */
inline Sphere(const typename DimensionTraits<dimensions, GLfloat>::VectorType& position, float radius): _position(position), _transformedPosition(position), _radius(radius), _transformedRadius(radius) {}
inline typename AbstractShape<dimensions>::Type type() const {
return AbstractShape<dimensions>::Type::Sphere;
}
void applyTransformation(const typename DimensionTraits<dimensions, GLfloat>::MatrixType& transformation);
bool collides(const AbstractShape<dimensions>* other) const;
@ -82,11 +86,6 @@ template<std::uint8_t dimensions> class PHYSICS_EXPORT Sphere: public AbstractSh
/** @brief Collision with sphere */
bool operator%(const Sphere<dimensions>& other) const;
protected:
inline typename AbstractShape<dimensions>::Type type() const {
return AbstractShape<dimensions>::Type::Sphere;
}
private:
Math::Vector<dimensions, GLfloat> _position,
_transformedPosition;

Loading…
Cancel
Save