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

BroadphaseProxy.h « BroadphaseCollision « Bullet « bullet « extern - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 235e2f1e46512b6ae4ad13814b14b6beee5216d1 (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
124
125
126
/*
 * Copyright (c) 2005 Erwin Coumans http://continuousphysics.com/Bullet/
 *
 * Permission to use, copy, modify, distribute and sell this software
 * and its documentation for any purpose is hereby granted without fee,
 * provided that the above copyright notice appear in all copies.
 * Erwin Coumans makes no representations about the suitability 
 * of this software for any purpose.  
 * It is provided "as is" without express or implied warranty.
*/
#ifndef BROADPHASE_PROXY_H
#define BROADPHASE_PROXY_H



/// Dispatcher uses these types
/// IMPORTANT NOTE:The types are ordered polyhedral, implicit convex and concave
/// to facilitate type checking
enum BroadphaseNativeTypes
{
// polyhedral convex shapes
	BOX_SHAPE_PROXYTYPE,
	TRIANGLE_SHAPE_PROXYTYPE,
	TETRAHEDRAL_SHAPE_PROXYTYPE,
	CONVEX_HULL_SHAPE_PROXYTYPE,
//implicit convex shapes
IMPLICIT_CONVEX_SHAPES_START_HERE,
	SPHERE_SHAPE_PROXYTYPE,
	MULTI_SPHERE_SHAPE_PROXYTYPE,
	CONE_SHAPE_PROXYTYPE,
	CONVEX_SHAPE_PROXYTYPE,
	CYLINDER_SHAPE_PROXYTYPE,
	MINKOWSKI_SUM_SHAPE_PROXYTYPE,
	MINKOWSKI_DIFFERENCE_SHAPE_PROXYTYPE,
//concave shapes
CONCAVE_SHAPES_START_HERE,
	//keep all the convex shapetype below here, for the check IsConvexShape in broadphase proxy!
	TRIANGLE_MESH_SHAPE_PROXYTYPE,
	EMPTY_SHAPE_PROXYTYPE,

	MAX_BROADPHASE_COLLISION_TYPES
};


///BroadphaseProxy
struct BroadphaseProxy
{
	BroadphaseProxy() :m_clientObject(0),m_clientObjectType(-1){}
	BroadphaseProxy(void* object,int type)
		:m_clientObject(object),
		m_clientObjectType(type)
	{
	}

	void        *m_clientObject;

	int GetClientObjectType ( ) const { return m_clientObjectType;}

	
	void	SetClientObjectType( int type ) { 
		m_clientObjectType = type; 
	}

	bool IsConvexShape()
	{
		return (GetClientObjectType () < TRIANGLE_MESH_SHAPE_PROXYTYPE);
	}
	bool IsConcaveShape()
	{
		return (GetClientObjectType() > CONCAVE_SHAPES_START_HERE);
	}

protected:
	int			 m_clientObjectType;
};

class CollisionAlgorithm;

struct BroadphaseProxy;

#define SIMPLE_MAX_ALGORITHMS 2

/// contains a pair of aabb-overlapping objects
struct BroadphasePair
{
	BroadphasePair ()
		:
	m_pProxy0(0),
		m_pProxy1(0)
	{
		for (int i=0;i<SIMPLE_MAX_ALGORITHMS;i++)
		{
			m_algorithms[i] = 0;
		}
	}

	BroadphasePair(const BroadphasePair& other)
		:		m_pProxy0(other.m_pProxy0),
				m_pProxy1(other.m_pProxy1)
	{
		for (int i=0;i<SIMPLE_MAX_ALGORITHMS;i++)
		{
			m_algorithms[i] = other.m_algorithms[i];
		}
	}
	BroadphasePair(BroadphaseProxy& proxy0,BroadphaseProxy& proxy1)
		:
		m_pProxy0(&proxy0),
		m_pProxy1(&proxy1)
	{
		for (int i=0;i<SIMPLE_MAX_ALGORITHMS;i++)
	{
			m_algorithms[i] = 0;
		}

	}

	
	BroadphaseProxy* m_pProxy0;
	BroadphaseProxy* m_pProxy1;
	
	mutable CollisionAlgorithm* m_algorithms[SIMPLE_MAX_ALGORITHMS];
};

#endif //BROADPHASE_PROXY_H