Explorar el Código

- Refactoring
- Adding the class for CollisionShape tranformation

Panagiotis Christopoulos Charitos hace 14 años
padre
commit
e9c00c95cf

+ 20 - 0
anki/collision/CollisionShapeTransform.h

@@ -0,0 +1,20 @@
+#ifndef ANKI_COLLISION_COLLISION_SHAPE_TRANSFORM_H
+#define ANKI_COLLISION_COLLISION_SHAPE_TRANSFORM_H
+
+#include "anki/collision/Forward.h"
+
+
+namespace anki {
+
+
+class CollisionShapeTransform
+{
+	public:
+
+};
+
+
+} // end namespace
+
+
+#endif

+ 0 - 2
anki/collision/LineSegment.cpp

@@ -6,8 +6,6 @@
 namespace anki {
 namespace anki {
 
 
 
 
-//==============================================================================
-// getTransformed                                                              =
 //==============================================================================
 //==============================================================================
 LineSegment LineSegment::getTransformed(const Transform& transform) const
 LineSegment LineSegment::getTransformed(const Transform& transform) const
 {
 {

+ 0 - 6
anki/collision/Plane.cpp

@@ -21,8 +21,6 @@ Plane::Plane(const Vec3& normal_, float offset_)
 {}
 {}
 
 
 
 
-//==============================================================================
-// setFrom3Points                                                              =
 //==============================================================================
 //==============================================================================
 void Plane::setFrom3Points(const Vec3& p0, const Vec3& p1, const Vec3& p2)
 void Plane::setFrom3Points(const Vec3& p0, const Vec3& p1, const Vec3& p2)
 {
 {
@@ -40,8 +38,6 @@ void Plane::setFrom3Points(const Vec3& p0, const Vec3& p1, const Vec3& p2)
 }
 }
 
 
 
 
-//==============================================================================
-// setFromPlaneEquation                                                        =
 //==============================================================================
 //==============================================================================
 void Plane::setFromPlaneEquation(float a, float b, float c, float d)
 void Plane::setFromPlaneEquation(float a, float b, float c, float d)
 {
 {
@@ -65,8 +61,6 @@ void Plane::setFromPlaneEquation(float a, float b, float c, float d)
 }
 }
 
 
 
 
-//==============================================================================
-// getTransformed                                                              =
 //==============================================================================
 //==============================================================================
 Plane Plane::getTransformed(const Transform& trf) const
 Plane Plane::getTransformed(const Transform& trf) const
 {
 {

+ 8 - 2
anki/collision/Plane.h

@@ -90,10 +90,16 @@ class Plane: public CollisionShape
 		/// It gives the distance between a point and a plane. if returns >0
 		/// It gives the distance between a point and a plane. if returns >0
 		/// then the point lies in front of the plane, if <0 then it is behind
 		/// then the point lies in front of the plane, if <0 then it is behind
 		/// and if =0 then it is co-planar
 		/// and if =0 then it is co-planar
-		float test(const Vec3& point) const {return normal.dot(point) - offset;}
+		float test(const Vec3& point) const
+		{
+			return normal.dot(point) - offset;
+		}
 
 
 		/// Get the distance from a point to this plane
 		/// Get the distance from a point to this plane
-		float getDistance(const Vec3& point) const {return fabs(test(point));}
+		float getDistance(const Vec3& point) const
+		{
+			return fabs(test(point));
+		}
 
 
 		/// Returns the perpedicular point of a given point in this plane.
 		/// Returns the perpedicular point of a given point in this plane.
 		/// Plane's normal and returned-point are perpedicular
 		/// Plane's normal and returned-point are perpedicular

+ 0 - 2
anki/collision/Ray.cpp

@@ -5,8 +5,6 @@
 namespace anki {
 namespace anki {
 
 
 
 
-//==============================================================================
-// getTransformed                                                              =
 //==============================================================================
 //==============================================================================
 Ray Ray::getTransformed(const Transform& transform) const
 Ray Ray::getTransformed(const Transform& transform) const
 {
 {

+ 0 - 4
anki/collision/Sphere.cpp

@@ -5,8 +5,6 @@
 namespace anki {
 namespace anki {
 
 
 
 
-//==============================================================================
-// getTransformed                                                              =
 //==============================================================================
 //==============================================================================
 Sphere Sphere::getTransformed(const Transform& transform) const
 Sphere Sphere::getTransformed(const Transform& transform) const
 {
 {
@@ -18,8 +16,6 @@ Sphere Sphere::getTransformed(const Transform& transform) const
 }
 }
 
 
 
 
-//==============================================================================
-// getCompoundShape                                                            =
 //==============================================================================
 //==============================================================================
 Sphere Sphere::getCompoundShape(const Sphere& b) const
 Sphere Sphere::getCompoundShape(const Sphere& b) const
 {
 {

+ 19 - 0
anki/math/Vec3.inl.h

@@ -308,6 +308,7 @@ inline float Vec3::dot(const Vec3& b) const
 	return x() * b.x() + y() * b.y() + z() * b.z();
 	return x() * b.x() + y() * b.y() + z() * b.z();
 }
 }
 
 
+
 // cross prod
 // cross prod
 inline Vec3 Vec3::cross(const Vec3& b) const
 inline Vec3 Vec3::cross(const Vec3& b) const
 {
 {
@@ -316,42 +317,49 @@ inline Vec3 Vec3::cross(const Vec3& b) const
 		x() * b.y() - y() * b.x());
 		x() * b.y() - y() * b.x());
 }
 }
 
 
+
 // getLength
 // getLength
 inline float Vec3::getLength() const
 inline float Vec3::getLength() const
 {
 {
 	return Math::sqrt(getLengthSquared());
 	return Math::sqrt(getLengthSquared());
 }
 }
 
 
+
 // getLengthSquared
 // getLengthSquared
 inline float Vec3::getLengthSquared() const
 inline float Vec3::getLengthSquared() const
 {
 {
 	return x() * x() + y() * y() + z() * z();
 	return x() * x() + y() * y() + z() * z();
 }
 }
 
 
+
 // getDistanceSquared
 // getDistanceSquared
 inline float Vec3::getDistanceSquared(const Vec3& b) const
 inline float Vec3::getDistanceSquared(const Vec3& b) const
 {
 {
 	return ((*this) - b).getLengthSquared();
 	return ((*this) - b).getLengthSquared();
 }
 }
 
 
+
 // normalize
 // normalize
 inline void Vec3::normalize()
 inline void Vec3::normalize()
 {
 {
 	(*this) /= getLength();
 	(*this) /= getLength();
 }
 }
 
 
+
 // getNormalized
 // getNormalized
 inline Vec3 Vec3::getNormalized() const
 inline Vec3 Vec3::getNormalized() const
 {
 {
 	return (*this) / getLength();
 	return (*this) / getLength();
 }
 }
 
 
+
 // getProjection
 // getProjection
 inline Vec3 Vec3::getProjection(const Vec3& toThis) const
 inline Vec3 Vec3::getProjection(const Vec3& toThis) const
 {
 {
 	return toThis * ((*this).dot(toThis) / (toThis.dot(toThis)));
 	return toThis * ((*this).dot(toThis) / (toThis.dot(toThis)));
 }
 }
 
 
+
 // getRotated
 // getRotated
 inline Vec3 Vec3::getRotated(const Quat& q) const
 inline Vec3 Vec3::getRotated(const Quat& q) const
 {
 {
@@ -368,12 +376,14 @@ inline Vec3 Vec3::getRotated(const Quat& q) const
 	return (*this) + qXyz.cross(qXyz.cross((*this)) + (*this) * q.w()) * 2.0;
 	return (*this) + qXyz.cross(qXyz.cross((*this)) + (*this) * q.w()) * 2.0;
 }
 }
 
 
+
 // rotate
 // rotate
 inline void Vec3::rotate(const Quat& q)
 inline void Vec3::rotate(const Quat& q)
 {
 {
 	(*this) = getRotated(q);
 	(*this) = getRotated(q);
 }
 }
 
 
+
 // lerp
 // lerp
 inline Vec3 Vec3::lerp(const Vec3& v1, float t) const
 inline Vec3 Vec3::lerp(const Vec3& v1, float t) const
 {
 {
@@ -392,6 +402,7 @@ inline Vec3 Vec3::getTransformed(const Vec3& translate, const Mat3& rotate,
 	return (rotate * ((*this) * scale)) + translate;
 	return (rotate * ((*this) * scale)) + translate;
 }
 }
 
 
+
 // Mat3
 // Mat3
 inline void Vec3::transform(const Vec3& translate, const Mat3& rotate,
 inline void Vec3::transform(const Vec3& translate, const Mat3& rotate,
 	float scale)
 	float scale)
@@ -399,6 +410,7 @@ inline void Vec3::transform(const Vec3& translate, const Mat3& rotate,
 	(*this) = getTransformed(translate, rotate, scale);
 	(*this) = getTransformed(translate, rotate, scale);
 }
 }
 
 
+
 // Mat3 no scale
 // Mat3 no scale
 inline Vec3 Vec3::getTransformed(const Vec3& translate,
 inline Vec3 Vec3::getTransformed(const Vec3& translate,
 	const Mat3& rotate) const
 	const Mat3& rotate) const
@@ -406,12 +418,14 @@ inline Vec3 Vec3::getTransformed(const Vec3& translate,
 	return (rotate * (*this)) + translate;
 	return (rotate * (*this)) + translate;
 }
 }
 
 
+
 // Mat3 no scale
 // Mat3 no scale
 inline void Vec3::transform(const Vec3& translate, const Mat3& rotate)
 inline void Vec3::transform(const Vec3& translate, const Mat3& rotate)
 {
 {
 	(*this) = getTransformed(translate, rotate);
 	(*this) = getTransformed(translate, rotate);
 }
 }
 
 
+
 // Quat
 // Quat
 inline Vec3 Vec3::getTransformed(const Vec3& translate, const Quat& rotate,
 inline Vec3 Vec3::getTransformed(const Vec3& translate, const Quat& rotate,
 	float scale) const
 	float scale) const
@@ -419,6 +433,7 @@ inline Vec3 Vec3::getTransformed(const Vec3& translate, const Quat& rotate,
 	return ((*this) * scale).getRotated(rotate) + translate;
 	return ((*this) * scale).getRotated(rotate) + translate;
 }
 }
 
 
+
 // Quat
 // Quat
 inline void Vec3::transform(const Vec3& translate, const Quat& rotate,
 inline void Vec3::transform(const Vec3& translate, const Quat& rotate,
 	float scale)
 	float scale)
@@ -426,6 +441,7 @@ inline void Vec3::transform(const Vec3& translate, const Quat& rotate,
 	(*this) = getTransformed(translate, rotate, scale);
 	(*this) = getTransformed(translate, rotate, scale);
 }
 }
 
 
+
 // Mat4
 // Mat4
 inline Vec3 Vec3::getTransformed(const Mat4& transform) const
 inline Vec3 Vec3::getTransformed(const Mat4& transform) const
 {
 {
@@ -448,12 +464,14 @@ inline Vec3 Vec3::getTransformed(const Mat4& transform) const
 #endif
 #endif
 }
 }
 
 
+
 // Mat4
 // Mat4
 inline void Vec3::transform(const Mat4& transform)
 inline void Vec3::transform(const Mat4& transform)
 {
 {
 	(*this) = getTransformed(transform);
 	(*this) = getTransformed(transform);
 }
 }
 
 
+
 // Transform
 // Transform
 inline Vec3 Vec3::getTransformed(const Transform& transform) const
 inline Vec3 Vec3::getTransformed(const Transform& transform) const
 {
 {
@@ -461,6 +479,7 @@ inline Vec3 Vec3::getTransformed(const Transform& transform) const
 		transform.getOrigin();
 		transform.getOrigin();
 }
 }
 
 
+
 // Transform
 // Transform
 inline void Vec3::transform(const Transform& transform)
 inline void Vec3::transform(const Transform& transform)
 {
 {