~ubuntu-branches/ubuntu/gutsy/blender/gutsy-security

« back to all changes in this revision

Viewing changes to extern/bullet/Extras/PhysicsInterface/CcdPhysics/CcdPhysicsController.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Lukas Fittl
  • Date: 2006-09-20 01:57:27 UTC
  • mfrom: (1.2.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20060920015727-gmoqlxwstx9wwqs3
Tags: 2.42a-1ubuntu1
* Merge from Debian unstable (Closes: Malone #55903). Remaining changes:
  - debian/genpot: Add python scripts from Lee June <blender@eyou.com> to
    generate a reasonable PO template from the sources. Since gettext is used
    in a highly nonstandard way, xgettext does not work for this job.
  - debian/rules: Call the scripts, generate po/blender.pot, and clean it up
    in the clean target.
  - Add a proper header to the generated PO template.
* debian/control: Build depend on libavformat-dev >= 3:0.cvs20060823-3.1,
  otherwise this package will FTBFS

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
 
1
16
#include "CcdPhysicsController.h"
2
17
 
3
18
#include "Dynamics/RigidBody.h"
4
19
#include "PHY_IMotionState.h"
5
20
#include "BroadphaseCollision/BroadphaseProxy.h"
 
21
#include "BroadphaseCollision/BroadphaseInterface.h"
6
22
#include "CollisionShapes/ConvexShape.h"
 
23
#include "CcdPhysicsEnvironment.h"
 
24
#include "SimdTransformUtil.h"
 
25
 
 
26
#include "CollisionShapes/SphereShape.h"
 
27
#include "CollisionShapes/ConeShape.h"
7
28
 
8
29
class BP_Proxy;
9
30
 
13
34
float   gDeactivationTime = 2.f;
14
35
bool    gDisableDeactivation = false;
15
36
 
16
 
float gLinearSleepingTreshold = 0.8f;
 
37
float gLinearSleepingTreshold = 0.4f;
17
38
float gAngularSleepingTreshold = 1.0f;
18
39
 
19
40
#include "Dynamics/MassProps.h"
20
41
 
21
42
SimdVector3 startVel(0,0,0);//-10000);
22
43
CcdPhysicsController::CcdPhysicsController (const CcdConstructionInfo& ci)
 
44
:m_cci(ci)
23
45
{
24
46
        m_collisionDelay = 0;
25
47
        m_newClientInfo = 0;
26
48
        
27
49
        m_MotionState = ci.m_MotionState;
28
50
 
29
 
 
 
51
        
 
52
        
 
53
        CreateRigidbody();
 
54
        
 
55
 
 
56
        
 
57
        #ifdef WIN32
 
58
        if (m_body->getInvMass())
 
59
                m_body->setLinearVelocity(startVel);
 
60
        #endif
 
61
 
 
62
}
 
63
 
 
64
SimdTransform   CcdPhysicsController::GetTransformFromMotionState(PHY_IMotionState* motionState)
 
65
{
30
66
        SimdTransform trans;
31
67
        float tmp[3];
32
 
        m_MotionState->getWorldPosition(tmp[0],tmp[1],tmp[2]);
 
68
        motionState->getWorldPosition(tmp[0],tmp[1],tmp[2]);
33
69
        trans.setOrigin(SimdVector3(tmp[0],tmp[1],tmp[2]));
34
70
 
35
71
        SimdQuaternion orn;
36
 
        m_MotionState->getWorldOrientation(orn[0],orn[1],orn[2],orn[3]);
 
72
        motionState->getWorldOrientation(orn[0],orn[1],orn[2],orn[3]);
37
73
        trans.setRotation(orn);
38
 
 
39
 
        MassProps mp(ci.m_mass, ci.m_localInertiaTensor);
40
 
 
41
 
        m_body = new RigidBody(mp,0,0,ci.m_friction,ci.m_restitution);
42
 
 
43
 
        m_body->SetCollisionShape( ci.m_collisionShape);
44
 
 
 
74
        return trans;
 
75
 
 
76
}
 
77
 
 
78
void CcdPhysicsController::CreateRigidbody()
 
79
{
 
80
 
 
81
        SimdTransform trans = GetTransformFromMotionState(m_cci.m_MotionState);
 
82
 
 
83
        MassProps mp(m_cci.m_mass, m_cci.m_localInertiaTensor);
 
84
 
 
85
        m_body = new RigidBody(mp,0,0,m_cci.m_friction,m_cci.m_restitution);
 
86
        m_body->m_collisionShape = m_cci.m_collisionShape;
45
87
        
46
 
        m_broadphaseHandle = ci.m_broadphaseHandle;
47
 
 
48
88
 
49
89
        //
50
90
        // init the rigidbody properly
51
91
        //
52
92
        
53
 
        m_body->setMassProps(ci.m_mass, ci.m_localInertiaTensor);
54
 
        m_body->setGravity( ci.m_gravity);
55
 
 
 
93
        m_body->setMassProps(m_cci.m_mass, m_cci.m_localInertiaTensor * m_cci.m_inertiaFactor);
 
94
        //setMassProps this also sets collisionFlags
 
95
        m_body->m_collisionFlags = m_cci.m_collisionFlags;
56
96
        
57
 
        m_body->setDamping(ci.m_linearDamping, ci.m_angularDamping);
58
 
 
59
 
 
 
97
        m_body->setGravity( m_cci.m_gravity);
 
98
        m_body->setDamping(m_cci.m_linearDamping, m_cci.m_angularDamping);
60
99
        m_body->setCenterOfMassTransform( trans );
61
100
 
62
 
        #ifdef WIN32
63
 
        if (m_body->getInvMass())
64
 
                m_body->setLinearVelocity(startVel);
65
 
        #endif
66
101
 
67
102
}
68
103
 
69
104
CcdPhysicsController::~CcdPhysicsController()
70
105
{
71
106
        //will be reference counted, due to sharing
 
107
        m_cci.m_physicsEnv->removeCcdPhysicsController(this);
72
108
        delete m_MotionState;
73
109
        delete m_body;
74
110
}
78
114
                */
79
115
bool            CcdPhysicsController::SynchronizeMotionStates(float time)
80
116
{
81
 
        const SimdVector3& worldPos = m_body->getCenterOfMassPosition();
82
 
        m_MotionState->setWorldPosition(worldPos[0],worldPos[1],worldPos[2]);
83
 
        
84
 
        const SimdQuaternion& worldquat = m_body->getOrientation();
85
 
        m_MotionState->setWorldOrientation(worldquat[0],worldquat[1],worldquat[2],worldquat[3]);
86
 
 
87
 
        m_MotionState->calculateWorldTransformations();
88
 
 
89
 
        float scale[3];
90
 
        m_MotionState->getWorldScaling(scale[0],scale[1],scale[2]);
91
 
        
92
 
        SimdVector3 scaling(scale[0],scale[1],scale[2]);
93
 
        m_body->GetCollisionShape()->setLocalScaling(scaling);
94
 
 
 
117
        //sync non-static to motionstate, and static from motionstate (todo: add kinematic etc.)
 
118
 
 
119
        if (!m_body->IsStatic())
 
120
        {
 
121
                const SimdVector3& worldPos = m_body->getCenterOfMassPosition();
 
122
                m_MotionState->setWorldPosition(worldPos[0],worldPos[1],worldPos[2]);
 
123
                
 
124
                const SimdQuaternion& worldquat = m_body->getOrientation();
 
125
                m_MotionState->setWorldOrientation(worldquat[0],worldquat[1],worldquat[2],worldquat[3]);
 
126
 
 
127
                m_MotionState->calculateWorldTransformations();
 
128
 
 
129
                float scale[3];
 
130
                m_MotionState->getWorldScaling(scale[0],scale[1],scale[2]);
 
131
                SimdVector3 scaling(scale[0],scale[1],scale[2]);
 
132
                GetCollisionShape()->setLocalScaling(scaling);
 
133
        } else
 
134
        {
 
135
                SimdVector3 worldPos;
 
136
                SimdQuaternion worldquat;
 
137
 
 
138
                m_MotionState->getWorldPosition(worldPos[0],worldPos[1],worldPos[2]);
 
139
                m_MotionState->getWorldOrientation(worldquat[0],worldquat[1],worldquat[2],worldquat[3]);
 
140
                SimdTransform oldTrans = m_body->getCenterOfMassTransform();
 
141
                SimdTransform newTrans(worldquat,worldPos);
 
142
                                
 
143
                m_body->setCenterOfMassTransform(newTrans);
 
144
                //need to keep track of previous position for friction effects...
 
145
                
 
146
                m_MotionState->calculateWorldTransformations();
 
147
 
 
148
                float scale[3];
 
149
                m_MotionState->getWorldScaling(scale[0],scale[1],scale[2]);
 
150
                SimdVector3 scaling(scale[0],scale[1],scale[2]);
 
151
                GetCollisionShape()->setLocalScaling(scaling);
 
152
        }
95
153
        return true;
96
 
}
97
 
 
98
 
CollisionShape* CcdPhysicsController::GetCollisionShape() 
99
 
100
 
        return m_body->GetCollisionShape();
101
 
}
102
 
 
103
 
 
 
154
 
 
155
}
104
156
 
105
157
                /**
106
158
                        WriteMotionStateToDynamics synchronizes dynas, kinematic and deformable entities (and do 'late binding')
116
168
                // controller replication
117
169
void            CcdPhysicsController::PostProcessReplica(class PHY_IMotionState* motionstate,class PHY_IPhysicsController* parentctrl)
118
170
{
119
 
}
 
171
        m_MotionState = motionstate;
 
172
 
 
173
        
 
174
 
 
175
        m_body = 0;
 
176
        CreateRigidbody();
 
177
        
 
178
        m_cci.m_physicsEnv->addCcdPhysicsController(this);
 
179
 
 
180
 
 
181
/*      SM_Object* dynaparent=0;
 
182
        SumoPhysicsController* sumoparentctrl = (SumoPhysicsController* )parentctrl;
 
183
        
 
184
        if (sumoparentctrl)
 
185
        {
 
186
                dynaparent = sumoparentctrl->GetSumoObject();
 
187
        }
 
188
        
 
189
        SM_Object* orgsumoobject = m_sumoObj;
 
190
        
 
191
        
 
192
        m_sumoObj       =       new SM_Object(
 
193
                orgsumoobject->getShapeHandle(), 
 
194
                orgsumoobject->getMaterialProps(),                      
 
195
                orgsumoobject->getShapeProps(),
 
196
                dynaparent);
 
197
        
 
198
        m_sumoObj->setRigidBody(orgsumoobject->isRigidBody());
 
199
        
 
200
        m_sumoObj->setMargin(orgsumoobject->getMargin());
 
201
        m_sumoObj->setPosition(orgsumoobject->getPosition());
 
202
        m_sumoObj->setOrientation(orgsumoobject->getOrientation());
 
203
        //if it is a dyna, register for a callback
 
204
        m_sumoObj->registerCallback(*this);
 
205
        
 
206
        m_sumoScene->add(* (m_sumoObj));
 
207
        */
 
208
 
 
209
 
 
210
 
 
211
}
 
212
 
 
213
void CcdPhysicsController::SetMargin(float margin)
 
214
{
 
215
        if (m_body && m_body->GetCollisionShape())
 
216
        {
 
217
                m_body->GetCollisionShape()->SetMargin(margin);
 
218
        }
 
219
 
 
220
 
 
221
}
 
222
 
 
223
float CcdPhysicsController::GetMargin() const
 
224
{
 
225
        if (m_body && m_body->GetCollisionShape())
 
226
        {
 
227
                return m_body->GetCollisionShape()->GetMargin();
 
228
        }
 
229
 
 
230
        return 0.f;
 
231
 
 
232
}
 
233
 
120
234
 
121
235
                // kinematic methods
122
236
void            CcdPhysicsController::RelativeTranslate(float dlocX,float dlocY,float dlocZ,bool local)
123
237
{
124
 
        SimdTransform xform = m_body->getCenterOfMassTransform();
125
 
        xform.setOrigin(xform.getOrigin() + SimdVector3(dlocX,dlocY,dlocZ));
126
 
        this->m_body->setCenterOfMassTransform(xform);
 
238
        if (m_body)
 
239
        {
 
240
                m_body->activate();
 
241
 
 
242
                SimdVector3 dloc(dlocX,dlocY,dlocZ);
 
243
                SimdTransform xform = m_body->getCenterOfMassTransform();
 
244
 
 
245
                if (local)
 
246
                {
 
247
                        dloc = xform.getBasis()*dloc;
 
248
                }
 
249
 
 
250
                xform.setOrigin(xform.getOrigin() + dloc);
 
251
                m_body->setCenterOfMassTransform(xform);
 
252
        }
127
253
 
128
254
}
129
255
 
131
257
{
132
258
        if (m_body )
133
259
        {
 
260
                m_body->activate();
 
261
 
134
262
                SimdMatrix3x3 drotmat(  rotval[0],rotval[1],rotval[2],
135
263
                                                                rotval[4],rotval[5],rotval[6],
136
264
                                                                rotval[8],rotval[9],rotval[10]);
159
287
 
160
288
void            CcdPhysicsController::getOrientation(float &quatImag0,float &quatImag1,float &quatImag2,float &quatReal)
161
289
{
162
 
 
 
290
        SimdQuaternion q = m_body->getCenterOfMassTransform().getRotation();
 
291
        quatImag0 = q[0];
 
292
        quatImag1 = q[1];
 
293
        quatImag2 = q[2];
 
294
        quatReal = q[3];
163
295
}
164
296
void            CcdPhysicsController::setOrientation(float quatImag0,float quatImag1,float quatImag2,float quatReal)
165
297
{
186
318
 
187
319
void            CcdPhysicsController::getPosition(PHY__Vector3& pos) const
188
320
{
189
 
        assert(0);
 
321
        const SimdTransform& xform = m_body->getCenterOfMassTransform();
 
322
        pos[0] = xform.getOrigin().x();
 
323
        pos[1] = xform.getOrigin().y();
 
324
        pos[2] = xform.getOrigin().z();
190
325
}
191
326
 
192
327
void            CcdPhysicsController::setScaling(float scaleX,float scaleY,float scaleZ)
193
328
{
 
329
        if (!SimdFuzzyZero(m_cci.m_scaling.x()-scaleX) ||
 
330
                !SimdFuzzyZero(m_cci.m_scaling.y()-scaleY) ||
 
331
                !SimdFuzzyZero(m_cci.m_scaling.z()-scaleZ))
 
332
        {
 
333
                m_cci.m_scaling = SimdVector3(scaleX,scaleY,scaleZ);
 
334
 
 
335
                if (m_body && m_body->GetCollisionShape())
 
336
                {
 
337
                        m_body->GetCollisionShape()->setLocalScaling(m_cci.m_scaling);
 
338
                        m_body->GetCollisionShape()->CalculateLocalInertia(m_cci.m_mass, m_cci.m_localInertiaTensor);
 
339
                        m_body->setMassProps(m_cci.m_mass, m_cci.m_localInertiaTensor * m_cci.m_inertiaFactor);
 
340
                }
 
341
        }
194
342
}
195
343
                
196
344
                // physics methods
197
345
void            CcdPhysicsController::ApplyTorque(float torqueX,float torqueY,float torqueZ,bool local)
198
346
{
 
347
        SimdVector3 torque(torqueX,torqueY,torqueZ);
 
348
        SimdTransform xform = m_body->getCenterOfMassTransform();
 
349
        if (local)
 
350
        {
 
351
                torque  = xform.getBasis()*torque;
 
352
        }
 
353
        m_body->applyTorque(torque);
199
354
}
 
355
 
200
356
void            CcdPhysicsController::ApplyForce(float forceX,float forceY,float forceZ,bool local)
201
357
{
 
358
        SimdVector3 force(forceX,forceY,forceZ);
 
359
        SimdTransform xform = m_body->getCenterOfMassTransform();
 
360
        if (local)
 
361
        {
 
362
                force   = xform.getBasis()*force;
 
363
        }
 
364
        m_body->applyCentralForce(force);
202
365
}
203
366
void            CcdPhysicsController::SetAngularVelocity(float ang_velX,float ang_velY,float ang_velZ,bool local)
204
367
{
205
368
        SimdVector3 angvel(ang_velX,ang_velY,ang_velZ);
206
 
 
207
 
        m_body->setAngularVelocity(angvel);
 
369
        if (angvel.length2() > (SIMD_EPSILON*SIMD_EPSILON))
 
370
        {
 
371
                m_body->activate();
 
372
        }
 
373
 
 
374
        {
 
375
                SimdTransform xform = m_body->getCenterOfMassTransform();
 
376
                if (local)
 
377
                {
 
378
                        angvel  = xform.getBasis()*angvel;
 
379
                }
 
380
 
 
381
                m_body->setAngularVelocity(angvel);
 
382
        }
208
383
 
209
384
}
210
385
void            CcdPhysicsController::SetLinearVelocity(float lin_velX,float lin_velY,float lin_velZ,bool local)
211
386
{
212
387
 
213
388
        SimdVector3 linVel(lin_velX,lin_velY,lin_velZ);
214
 
        m_body->setLinearVelocity(linVel);
 
389
        if (linVel.length2() > (SIMD_EPSILON*SIMD_EPSILON))
 
390
        {
 
391
                m_body->activate();
 
392
        }
 
393
        
 
394
        {
 
395
                SimdTransform xform = m_body->getCenterOfMassTransform();
 
396
                if (local)
 
397
                {
 
398
                        linVel  = xform.getBasis()*linVel;
 
399
                }
 
400
                m_body->setLinearVelocity(linVel);
 
401
        }
215
402
}
216
403
void            CcdPhysicsController::applyImpulse(float attachX,float attachY,float attachZ, float impulseX,float impulseY,float impulseZ)
217
404
{
218
 
        
219
405
        SimdVector3 impulse(impulseX,impulseY,impulseZ);
220
 
        SimdVector3 pos(attachX,attachY,attachZ);
221
 
 
222
 
        m_body->activate();
223
 
 
224
 
        m_body->applyImpulse(impulse,pos);
 
406
 
 
407
        if (impulse.length2() > (SIMD_EPSILON*SIMD_EPSILON))
 
408
        {
 
409
                m_body->activate();
 
410
                
 
411
                SimdVector3 pos(attachX,attachY,attachZ);
 
412
 
 
413
                m_body->activate();
 
414
 
 
415
                m_body->applyImpulse(impulse,pos);
 
416
        }
225
417
 
226
418
}
227
419
void            CcdPhysicsController::SetActive(bool active)
230
422
                // reading out information from physics
231
423
void            CcdPhysicsController::GetLinearVelocity(float& linvX,float& linvY,float& linvZ)
232
424
{
233
 
}
 
425
        const SimdVector3& linvel = this->m_body->getLinearVelocity();
 
426
        linvX = linvel.x();
 
427
        linvY = linvel.y();
 
428
        linvZ = linvel.z();
 
429
 
 
430
}
 
431
 
 
432
void            CcdPhysicsController::GetAngularVelocity(float& angVelX,float& angVelY,float& angVelZ)
 
433
{
 
434
        const SimdVector3& angvel= m_body->getAngularVelocity();
 
435
        angVelX = angvel.x();
 
436
        angVelY = angvel.y();
 
437
        angVelZ = angvel.z();
 
438
}
 
439
 
234
440
void            CcdPhysicsController::GetVelocity(const float posX,const float posY,const float posZ,float& linvX,float& linvY,float& linvZ)
235
441
{
 
442
        SimdVector3 pos(posX,posY,posZ);
 
443
        SimdVector3 rel_pos = pos-m_body->getCenterOfMassPosition();
 
444
        SimdVector3 linvel = m_body->getVelocityInLocalPoint(rel_pos);
 
445
        linvX = linvel.x();
 
446
        linvY = linvel.y();
 
447
        linvZ = linvel.z();
236
448
}
237
449
void            CcdPhysicsController::getReactionForce(float& forceX,float& forceY,float& forceZ)
238
450
{
241
453
                // dyna's that are rigidbody are free in orientation, dyna's with non-rigidbody are restricted 
242
454
void            CcdPhysicsController::setRigidBody(bool rigid)
243
455
{
 
456
        if (!rigid)
 
457
        {
 
458
                //fake it for now
 
459
                SimdVector3 inertia = m_body->getInvInertiaDiagLocal();
 
460
                inertia[1] = 0.f;
 
461
                m_body->setInvInertiaDiagLocal(inertia);
 
462
                m_body->updateInertiaTensor();
 
463
        }
244
464
}
245
465
 
246
466
                // clientinfo for raycasts for example
256
476
 
257
477
void    CcdPhysicsController::UpdateDeactivation(float timeStep)
258
478
{
259
 
        if ( (m_body->GetActivationState() == 2))
 
479
        if ( (m_body->GetActivationState() == ISLAND_SLEEPING) || (m_body->GetActivationState() == DISABLE_DEACTIVATION))
260
480
                return;
261
 
        
262
481
 
263
482
        if ((m_body->getLinearVelocity().length2() < gLinearSleepingTreshold*gLinearSleepingTreshold) &&
264
483
                (m_body->getAngularVelocity().length2() < gAngularSleepingTreshold*gAngularSleepingTreshold))
275
494
bool CcdPhysicsController::wantsSleeping()
276
495
{
277
496
 
 
497
        if (m_body->GetActivationState() == DISABLE_DEACTIVATION)
 
498
                return false;
 
499
 
278
500
        //disable deactivation
279
501
        if (gDisableDeactivation || (gDeactivationTime == 0.f))
280
502
                return false;
281
 
        //2 == ISLAND_SLEEPING, 3 == WANTS_DEACTIVATION
282
 
        if ( (m_body->GetActivationState() == 2) || (m_body->GetActivationState() == 3))
 
503
 
 
504
        if ( (m_body->GetActivationState() == ISLAND_SLEEPING) || (m_body->GetActivationState() == WANTS_DEACTIVATION))
283
505
                return true;
284
506
 
285
507
        if (m_body->m_deactivationTime> gDeactivationTime)
289
511
        return false;
290
512
}
291
513
 
 
514
PHY_IPhysicsController* CcdPhysicsController::GetReplica()
 
515
{
 
516
        //very experimental, shape sharing is not implemented yet.
 
517
        //just support SphereShape/ConeShape for now
 
518
 
 
519
        CcdConstructionInfo cinfo = m_cci;
 
520
        if (cinfo.m_collisionShape)
 
521
        {
 
522
                switch (cinfo.m_collisionShape->GetShapeType())
 
523
                {
 
524
                case SPHERE_SHAPE_PROXYTYPE:
 
525
                        {
 
526
                                SphereShape* orgShape = (SphereShape*)cinfo.m_collisionShape;
 
527
                                cinfo.m_collisionShape = new SphereShape(*orgShape);
 
528
                                break;
 
529
                        }
 
530
 
 
531
                        case CONE_SHAPE_PROXYTYPE:
 
532
                        {
 
533
                                ConeShape* orgShape = (ConeShape*)cinfo.m_collisionShape;
 
534
                                cinfo.m_collisionShape = new ConeShape(*orgShape);
 
535
                                break;
 
536
                        }
 
537
 
 
538
 
 
539
                default:
 
540
                        {
 
541
                                return 0;
 
542
                        }
 
543
                }
 
544
        }
 
545
 
 
546
        cinfo.m_MotionState = new DefaultMotionState();
 
547
 
 
548
        CcdPhysicsController* replica = new CcdPhysicsController(cinfo);
 
549
        return replica;
 
550
}
 
551
 
 
552
///////////////////////////////////////////////////////////
 
553
///A small utility class, DefaultMotionState
 
554
///
 
555
///////////////////////////////////////////////////////////
 
556
 
 
557
DefaultMotionState::DefaultMotionState()
 
558
{
 
559
        m_worldTransform.setIdentity();
 
560
}
 
561
 
 
562
 
 
563
DefaultMotionState::~DefaultMotionState()
 
564
{
 
565
 
 
566
}
 
567
 
 
568
void    DefaultMotionState::getWorldPosition(float& posX,float& posY,float& posZ)
 
569
{
 
570
        posX = m_worldTransform.getOrigin().x();
 
571
        posY = m_worldTransform.getOrigin().y();
 
572
        posZ = m_worldTransform.getOrigin().z();
 
573
}
 
574
 
 
575
void    DefaultMotionState::getWorldScaling(float& scaleX,float& scaleY,float& scaleZ)
 
576
{
 
577
        scaleX = 1.;
 
578
        scaleY = 1.;
 
579
        scaleZ = 1.;
 
580
}
 
581
 
 
582
void    DefaultMotionState::getWorldOrientation(float& quatIma0,float& quatIma1,float& quatIma2,float& quatReal)
 
583
{
 
584
        quatIma0 = m_worldTransform.getRotation().x();
 
585
        quatIma1 = m_worldTransform.getRotation().y();
 
586
        quatIma2 = m_worldTransform.getRotation().z();
 
587
        quatReal = m_worldTransform.getRotation()[3];
 
588
}
 
589
                
 
590
void    DefaultMotionState::setWorldPosition(float posX,float posY,float posZ)
 
591
{
 
592
        SimdPoint3 pos(posX,posY,posZ);
 
593
        m_worldTransform.setOrigin( pos );
 
594
}
 
595
 
 
596
void    DefaultMotionState::setWorldOrientation(float quatIma0,float quatIma1,float quatIma2,float quatReal)
 
597
{
 
598
        SimdQuaternion orn(quatIma0,quatIma1,quatIma2,quatReal);
 
599
        m_worldTransform.setRotation( orn );
 
600
}
 
601
                
 
602
void    DefaultMotionState::calculateWorldTransformations()
 
603
{
 
604
 
 
605
}
 
606