use mvc for the testbed, update almost all tests, bugfixes, improvements, cleanup
Since I started altering the testbed for better maintainability, I prefered to drop this (tested) large change with a single commit. Some changes below: Put some globals in their correct place, Now Testbed uses the MVC pattern (Model-View Controller). This way it becomes better to maintain than using no pattern in my opinion. Fixed some bugs in the debug draw interface. Of course, updated almost all tests because of the differences. Update script.
This commit is contained in:
@ -77,7 +77,7 @@ public:
|
||||
void FindNewPairs(T* callback);
|
||||
|
||||
// Draw the proxy AABBs.
|
||||
void Draw(b3Draw* draw) const;
|
||||
void Draw() const;
|
||||
private :
|
||||
friend class b3DynamicTree;
|
||||
|
||||
@ -189,9 +189,9 @@ inline void b3BroadPhase::FindNewPairs(T* callback)
|
||||
}
|
||||
}
|
||||
|
||||
inline void b3BroadPhase::Draw(b3Draw* draw) const
|
||||
inline void b3BroadPhase::Draw() const
|
||||
{
|
||||
m_tree.Draw(draw);
|
||||
m_tree.Draw();
|
||||
}
|
||||
|
||||
#endif
|
@ -21,20 +21,20 @@
|
||||
|
||||
#include <bounce/collision/sat/sat.h>
|
||||
|
||||
struct b3Segment;
|
||||
struct b3Capsule;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
float32 b3ProjectEdge(const b3Segment* hull, const b3Plane& plane);
|
||||
float32 b3ProjectEdge(const b3Capsule* hull, const b3Plane& plane);
|
||||
|
||||
b3FaceQuery b3QueryFaceSeparation(const b3Transform& xf1, const b3Segment* hull1,
|
||||
b3FaceQuery b3QueryFaceSeparation(const b3Transform& xf1, const b3Capsule* hull1,
|
||||
const b3Transform& xf2, const b3Hull* hull2);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
float32 b3ProjectEdge(const b3Vec3& P1, const b3Vec3& E1, const b3Vec3& P2, const b3Vec3& E2, const b3Vec3& C2);
|
||||
|
||||
b3EdgeQuery b3QueryEdgeSeparation(const b3Transform& xf1, const b3Segment* hull1,
|
||||
b3EdgeQuery b3QueryEdgeSeparation(const b3Transform& xf1, const b3Capsule* hull1,
|
||||
const b3Transform& xf2, const b3Hull* hull2);
|
||||
|
||||
#endif
|
@ -21,11 +21,13 @@
|
||||
|
||||
#include <bounce/collision/sat/sat.h>
|
||||
|
||||
struct b3Sphere;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
float32 b3ProjectVertex(const b3Vec3& hull, const b3Plane& plane);
|
||||
float32 b3ProjectVertex(const b3Sphere* hull, const b3Plane& plane);
|
||||
|
||||
b3FaceQuery b3QueryFaceSeparation(const b3Transform& xf1, const b3Vec3& hull1,
|
||||
b3FaceQuery b3QueryFaceSeparation(const b3Transform& xf1, const b3Sphere* hull1,
|
||||
const b3Transform& xf2, const b3Hull* hull2);
|
||||
|
||||
#endif
|
||||
|
@ -31,6 +31,12 @@ struct b3BoxHull : public b3Hull
|
||||
// Does nothing for performance.
|
||||
b3BoxHull() { }
|
||||
|
||||
// Construct this box from three extents and centered at the origin.
|
||||
b3BoxHull(float32 ex, float32 ey, float32 ez)
|
||||
{
|
||||
Set(ex, ey, ez);
|
||||
}
|
||||
|
||||
// Set this box to the unit box centered at the origin.
|
||||
void SetIdentity()
|
||||
{
|
||||
@ -174,4 +180,6 @@ struct b3BoxHull : public b3Hull
|
||||
}
|
||||
};
|
||||
|
||||
extern const b3BoxHull b3BoxHull_identity;
|
||||
|
||||
#endif
|
@ -21,20 +21,38 @@
|
||||
|
||||
#include <bounce/common/math/vec3.h>
|
||||
|
||||
struct b3Segment
|
||||
struct b3Capsule
|
||||
{
|
||||
//
|
||||
b3Capsule() { }
|
||||
|
||||
//
|
||||
b3Capsule(const b3Vec3& v1, const b3Vec3& v2, float32 r)
|
||||
{
|
||||
vertices[0] = v1;
|
||||
vertices[1] = v2;
|
||||
radius = r;
|
||||
}
|
||||
|
||||
//
|
||||
~b3Capsule() { }
|
||||
|
||||
b3Vec3 vertices[2];
|
||||
|
||||
float32 radius;
|
||||
|
||||
const b3Vec3& GetVertex(u32 index) const;
|
||||
u32 GetSupportVertex(const b3Vec3& direction) const;
|
||||
};
|
||||
|
||||
inline const b3Vec3& b3Segment::GetVertex(u32 index) const
|
||||
// Unit capsule centered at the origin
|
||||
extern const b3Capsule b3Capsule_identity;
|
||||
|
||||
inline const b3Vec3& b3Capsule::GetVertex(u32 index) const
|
||||
{
|
||||
return vertices[index];
|
||||
}
|
||||
|
||||
inline u32 b3Segment::GetSupportVertex(const b3Vec3& d) const
|
||||
inline u32 b3Capsule::GetSupportVertex(const b3Vec3& d) const
|
||||
{
|
||||
if (b3Dot(d, vertices[0]) > b3Dot(d, vertices[1]))
|
||||
{
|
||||
|
@ -57,6 +57,9 @@ struct b3Hull
|
||||
b3Plane GetEdgeSidePlane(u32 index) const;
|
||||
|
||||
u32 GetSize() const;
|
||||
|
||||
b3Vec3 GetCentroid() const;
|
||||
|
||||
void Validate() const;
|
||||
void Validate(const b3Face* face) const;
|
||||
void Validate(const b3HalfEdge* edge) const;
|
||||
|
@ -23,6 +23,19 @@
|
||||
|
||||
struct b3Sphere
|
||||
{
|
||||
//
|
||||
b3Sphere() { }
|
||||
|
||||
//
|
||||
b3Sphere(const b3Vec3& v, float32 r)
|
||||
{
|
||||
vertex = v;
|
||||
radius = r;
|
||||
}
|
||||
|
||||
//
|
||||
~b3Sphere() { }
|
||||
|
||||
b3Vec3 vertex;
|
||||
float32 radius;
|
||||
|
||||
@ -30,6 +43,9 @@ struct b3Sphere
|
||||
u32 GetSupportVertex(const b3Vec3& direction) const;
|
||||
};
|
||||
|
||||
// Unit sphere centered at origin
|
||||
extern const b3Sphere b3Sphere_identity;
|
||||
|
||||
inline const b3Vec3& b3Sphere::GetVertex(u32 index) const
|
||||
{
|
||||
B3_NOT_USED(index);
|
||||
|
@ -19,7 +19,6 @@
|
||||
#ifndef B3_DYNAMIC_TREE_H
|
||||
#define B3_DYNAMIC_TREE_H
|
||||
|
||||
#include <bounce/common/draw.h>
|
||||
#include <bounce/common/template/stack.h>
|
||||
#include <bounce/collision/shapes/aabb3.h>
|
||||
#include <bounce/collision/collision.h>
|
||||
@ -67,7 +66,7 @@ public :
|
||||
void Validate(i32 node) const;
|
||||
|
||||
// Draw this tree.
|
||||
void Draw(b3Draw* draw) const;
|
||||
void Draw() const;
|
||||
private :
|
||||
struct b3Node
|
||||
{
|
||||
|
@ -19,7 +19,6 @@
|
||||
#ifndef B3_STATIC_TREE_H
|
||||
#define B3_STATIC_TREE_H
|
||||
|
||||
#include <bounce/common/draw.h>
|
||||
#include <bounce/common/template/stack.h>
|
||||
#include <bounce/collision/shapes/aabb3.h>
|
||||
#include <bounce/collision/collision.h>
|
||||
@ -55,7 +54,7 @@ public:
|
||||
void RayCast(T* callback, const b3RayCastInput& input) const;
|
||||
|
||||
// Draw this tree.
|
||||
void Draw(b3Draw* draw) const;
|
||||
void Draw() const;
|
||||
|
||||
u32 GetSize() const;
|
||||
private :
|
||||
|
Reference in New Issue
Block a user