Welcome to mirror list, hosted at ThFree Co, Russian Federation.

ToiContactDispatcher.h « CollisionDispatch « BulletDynamics « bullet « extern - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b1793f70979ce2dbe77f4c10f24fdb6daf9676b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#ifndef TOI_CONTACT_DISPATCHER_H
#define TOI_CONTACT_DISPATCHER_H

#include "BroadphaseCollision/CollisionDispatcher.h"
#include "NarrowPhaseCollision/PersistentManifold.h"
#include "CollisionDispatch/UnionFind.h"
#include "BroadphaseCollision/BroadphaseProxy.h"

class ConstraintSolver;
class IDebugDraw;

//island management
#define ACTIVE_TAG 1
#define ISLAND_SLEEPING 2
#define WANTS_DEACTIVATION 3


struct CollisionAlgorithmCreateFunc
{
	bool m_swapped;
	
	CollisionAlgorithmCreateFunc()
		:m_swapped(false)
	{
	}
	virtual	CollisionAlgorithm* CreateCollisionAlgorithm(BroadphaseProxy& proxy0,BroadphaseProxy& proxy1)
	{
		return 0;
	}
};
#include <vector>
///ToiContactDispatcher (Time of Impact) is the main collision dispatcher.
///Basic implementation supports algorithms that handle ConvexConvex and ConvexConcave collision pairs.
///Time of Impact, Closest Points and Penetration Depth.
class ToiContactDispatcher : public Dispatcher
{
	
	bool m_useIslands;

	
	std::vector<PersistentManifold*>	m_manifoldsPtr;


	UnionFind m_unionFind;
	ConstraintSolver*	m_solver;
	
	float	m_sor;
	float	m_tau;
	float	m_damping;
	
	CollisionAlgorithmCreateFunc* m_doubleDispatch[MAX_BROADPHASE_COLLISION_TYPES][MAX_BROADPHASE_COLLISION_TYPES];
	
public:
	
	UnionFind& GetUnionFind() { return m_unionFind;}

//	int	m_firstFreeManifold;
	
//	const PersistentManifold* GetManifoldByIndexInternal(int index)
//	{
//		return &m_manifolds[index];
//	}

	int	GetNumManifolds() { return m_manifoldsPtr.size();}

	 PersistentManifold* GetManifoldByIndexInternal(int index)
	{
	return m_manifoldsPtr[index];
	}


	void InitUnionFind()
	{
		if (m_useIslands)
			m_unionFind.reset();
	}
	
	void FindUnions();
	
	int m_count;
	
	ToiContactDispatcher (ConstraintSolver* solver);

	virtual PersistentManifold*	GetNewManifold(void* b0,void* b1);
	
	virtual void ReleaseManifold(PersistentManifold* manifold);

	//
	// todo: this is random access, it can be walked 'cache friendly'!
	//
	virtual void SolveConstraints(float timeStep, int numIterations,int numRigidBodies,IDebugDraw* debugDrawer);
	
	
	CollisionAlgorithm* FindAlgorithm(BroadphaseProxy& proxy0,BroadphaseProxy& proxy1)
	{
		CollisionAlgorithm* algo = InternalFindAlgorithm(proxy0,proxy1);
		return algo;
	}
	
	CollisionAlgorithm* InternalFindAlgorithm(BroadphaseProxy& proxy0,BroadphaseProxy& proxy1);
	
	virtual int GetUniqueId() { return RIGIDBODY_DISPATCHER;}
	
	void	SetSor(float sor)
	{
		m_sor = sor;
	}

	void	SetTau(float tau)
	{
		m_tau = tau;
	}
	
	void	SetDamping( float damping)
	{
		m_damping = damping;
	}
	

};

#endif //TOI_CONTACT_DISPATCHER_H