~ubuntu-branches/ubuntu/vivid/emscripten/vivid

« back to all changes in this revision

Viewing changes to tests/bullet/Demos/Benchmarks/BenchmarkDemo.h

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2013-05-02 13:11:51 UTC
  • Revision ID: package-import@ubuntu.com-20130502131151-q8dvteqr1ef2x7xz
Tags: upstream-1.4.1~20130504~adb56cb
ImportĀ upstreamĀ versionĀ 1.4.1~20130504~adb56cb

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
Bullet Continuous Collision Detection and Physics Library
 
3
Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
 
4
 
 
5
This software is provided 'as-is', without any express or implied warranty.
 
6
In no event will the authors be held liable for any damages arising from the use of this software.
 
7
Permission is granted to anyone to use this software for any purpose, 
 
8
including commercial applications, and to alter it and redistribute it freely, 
 
9
subject to the following restrictions:
 
10
 
 
11
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
 
12
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
 
13
3. This notice may not be removed or altered from any source distribution.
 
14
*/
 
15
#ifndef BENCHMARK_DEMO_H
 
16
#define BENCHMARK_DEMO_H
 
17
 
 
18
 
 
19
#include "LinearMath/btAlignedObjectArray.h"
 
20
#include "LinearMath/btTransform.h"
 
21
 
 
22
class btDynamicsWorld;
 
23
 
 
24
#define NUMRAYS 500
 
25
 
 
26
class btRigidBody;
 
27
class btBroadphaseInterface;
 
28
class btCollisionShape;
 
29
class btOverlappingPairCache;
 
30
class btCollisionDispatcher;
 
31
class btConstraintSolver;
 
32
struct btCollisionAlgorithmCreateFunc;
 
33
class btDefaultCollisionConfiguration;
 
34
 
 
35
 
 
36
#ifndef USE_GRAPHICAL_BENCHMARK
 
37
///empty placeholder
 
38
class DemoApplication
 
39
{
 
40
protected:
 
41
 
 
42
        btDynamicsWorld* m_dynamicsWorld;
 
43
        btScalar        m_defaultContactProcessingThreshold;
 
44
 
 
45
public:
 
46
        DemoApplication()
 
47
        :m_defaultContactProcessingThreshold(BT_LARGE_FLOAT)
 
48
        {
 
49
        }
 
50
        virtual void myinit() {}
 
51
        virtual btDynamicsWorld* getDynamicsWorld()
 
52
        {
 
53
                return m_dynamicsWorld;
 
54
        }
 
55
 
 
56
        btScalar        getDeltaTimeMicroseconds()
 
57
        {
 
58
                return 1.f;
 
59
        }
 
60
 
 
61
        void    renderme() {}
 
62
        void    setCameraDistance(btScalar dist){}
 
63
        void    clientResetScene(){}
 
64
        btRigidBody*    localCreateRigidBody(float mass, const btTransform& startTransform,btCollisionShape* shape);
 
65
 
 
66
};
 
67
///BenchmarkDemo is provides several performance tests
 
68
#define PlatformDemoApplication DemoApplication
 
69
#else //USE_GRAPHICAL_BENCHMARK
 
70
 
 
71
#ifdef _WINDOWS
 
72
#include "Win32DemoApplication.h"
 
73
#define PlatformDemoApplication Win32DemoApplication
 
74
#else
 
75
#include "GlutDemoApplication.h"
 
76
#define PlatformDemoApplication GlutDemoApplication
 
77
#endif
 
78
 
 
79
#endif //USE_GRAPHICAL_BENCHMARK
 
80
 
 
81
 
 
82
class BenchmarkDemo : public PlatformDemoApplication
 
83
{
 
84
 
 
85
        //keep the collision shapes, for deletion/cleanup
 
86
        btAlignedObjectArray<btCollisionShape*> m_collisionShapes;
 
87
 
 
88
        btAlignedObjectArray<class RagDoll*>    m_ragdolls;
 
89
 
 
90
        btBroadphaseInterface*  m_overlappingPairCache;
 
91
 
 
92
        btCollisionDispatcher*  m_dispatcher;
 
93
 
 
94
        btConstraintSolver*     m_solver;
 
95
 
 
96
        btDefaultCollisionConfiguration* m_collisionConfiguration;
 
97
        
 
98
        int     m_benchmark;
 
99
 
 
100
        void    createTest1();
 
101
        void    createTest2();
 
102
        void    createTest3();
 
103
        void    createTest4();
 
104
        void    createTest5();
 
105
        void    createTest6();
 
106
        void    createTest7();
 
107
 
 
108
        void createWall(const btVector3& offsetPosition,int stackSize,const btVector3& boxSize);
 
109
        void createPyramid(const btVector3& offsetPosition,int stackSize,const btVector3& boxSize);
 
110
        void createTowerCircle(const btVector3& offsetPosition,int stackSize,int rotSize,const btVector3& boxSize);
 
111
        void createLargeMeshBody();
 
112
 
 
113
 
 
114
        class SpuBatchRaycaster* m_batchRaycaster;
 
115
        class btThreadSupportInterface* m_batchRaycasterThreadSupport;
 
116
 
 
117
        void castRays();
 
118
        void initRays();
 
119
 
 
120
        public:
 
121
 
 
122
        BenchmarkDemo(int benchmark)
 
123
        :m_benchmark(benchmark)
 
124
        {
 
125
        }
 
126
        virtual ~BenchmarkDemo()
 
127
        {
 
128
                exitPhysics();
 
129
        }
 
130
        void    initPhysics();
 
131
 
 
132
        void    exitPhysics();
 
133
 
 
134
        virtual void clientMoveAndDisplay();
 
135
 
 
136
        virtual void displayCallback();
 
137
        
 
138
 
 
139
 
 
140
        
 
141
};
 
142
 
 
143
class BenchmarkDemo1 : public BenchmarkDemo
 
144
{
 
145
public:
 
146
        BenchmarkDemo1()
 
147
                :BenchmarkDemo(1)
 
148
        {
 
149
        }
 
150
 
 
151
        static DemoApplication* Create()
 
152
        {
 
153
                BenchmarkDemo1* demo = new BenchmarkDemo1;
 
154
                demo->myinit();
 
155
                demo->initPhysics();
 
156
                return demo;
 
157
        }
 
158
};
 
159
 
 
160
class BenchmarkDemo2 : public BenchmarkDemo
 
161
{
 
162
public:
 
163
        BenchmarkDemo2()
 
164
                :BenchmarkDemo(2)
 
165
        {
 
166
        }
 
167
 
 
168
        static DemoApplication* Create()
 
169
        {
 
170
                BenchmarkDemo2* demo = new BenchmarkDemo2;
 
171
                demo->myinit();
 
172
                demo->initPhysics();
 
173
                return demo;
 
174
        }
 
175
};
 
176
 
 
177
class BenchmarkDemo3 : public BenchmarkDemo
 
178
{
 
179
public:
 
180
        BenchmarkDemo3()
 
181
                :BenchmarkDemo(3)
 
182
        {
 
183
        }
 
184
 
 
185
        static DemoApplication* Create()
 
186
        {
 
187
                BenchmarkDemo3* demo = new BenchmarkDemo3;
 
188
                demo->myinit();
 
189
                demo->initPhysics();
 
190
                return demo;
 
191
        }
 
192
};
 
193
 
 
194
class BenchmarkDemo4 : public BenchmarkDemo
 
195
{
 
196
public:
 
197
        BenchmarkDemo4()
 
198
                :BenchmarkDemo(4)
 
199
        {
 
200
        }
 
201
 
 
202
        static DemoApplication* Create()
 
203
        {
 
204
                BenchmarkDemo4* demo = new BenchmarkDemo4;
 
205
                demo->myinit();
 
206
                demo->initPhysics();
 
207
                return demo;
 
208
        }
 
209
};
 
210
 
 
211
 
 
212
class BenchmarkDemo5 : public BenchmarkDemo
 
213
{
 
214
public:
 
215
        BenchmarkDemo5()
 
216
                :BenchmarkDemo(5)
 
217
        {
 
218
        }
 
219
 
 
220
        static DemoApplication* Create()
 
221
        {
 
222
                BenchmarkDemo5* demo = new BenchmarkDemo5;
 
223
                demo->myinit();
 
224
                demo->initPhysics();
 
225
                return demo;
 
226
        }
 
227
};
 
228
 
 
229
 
 
230
class BenchmarkDemo6 : public BenchmarkDemo
 
231
{
 
232
public:
 
233
        BenchmarkDemo6()
 
234
                :BenchmarkDemo(6)
 
235
        {
 
236
        }
 
237
 
 
238
        static DemoApplication* Create()
 
239
        {
 
240
                BenchmarkDemo6* demo = new BenchmarkDemo6;
 
241
                demo->myinit();
 
242
                demo->initPhysics();
 
243
                return demo;
 
244
        }
 
245
};
 
246
 
 
247
class BenchmarkDemo7 : public BenchmarkDemo
 
248
{
 
249
public:
 
250
        BenchmarkDemo7()
 
251
                :BenchmarkDemo(7)
 
252
        {
 
253
        }
 
254
 
 
255
        static DemoApplication* Create()
 
256
        {
 
257
                BenchmarkDemo7* demo = new BenchmarkDemo7;
 
258
                demo->myinit();
 
259
                demo->initPhysics();
 
260
                return demo;
 
261
        }
 
262
};
 
263
 
 
264
#endif //BENCHMARK_DEMO_H
 
265