~ubuntu-branches/ubuntu/trusty/blender/trusty

« back to all changes in this revision

Viewing changes to source/gameengine/Physics/Bullet/CcdPhysicsController.h

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2013-03-06 12:08:47 UTC
  • mfrom: (1.5.1) (14.1.8 experimental)
  • Revision ID: package-import@ubuntu.com-20130306120847-frjfaryb2zrotwcg
Tags: 2.66a-1ubuntu1
* Resynchronize with Debian (LP: #1076930, #1089256, #1052743, #999024,
  #1122888, #1147084)
* debian/control:
  - Lower build-depends on libavcodec-dev since we're not
    doing the libav9 transition in Ubuntu yet

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
///     PHY_IPhysicsController is the abstract simplified Interface to a physical object.
30
30
///     It contains the IMotionState and IDeformableMesh Interfaces.
31
31
#include "btBulletDynamicsCommon.h"
 
32
#include "BulletDynamics/Character/btKinematicCharacterController.h"
32
33
#include "LinearMath/btTransform.h"
33
34
 
34
35
#include "PHY_IMotionState.h"
170
171
        btVector3                               m_halfExtend;
171
172
        btTransform                             m_childTrans;
172
173
        btVector3                               m_childScale;
173
 
        void*                                   m_userData;     
 
174
        void*                                   m_userData;
174
175
        btAlignedObjectArray<btScalar>  m_vertexArray;  // Contains both vertex array for polytope shape and
175
176
                                                                                        // triangle array for concave mesh shape. Each vertex is 3 consecutive values
176
177
                                                                                        // In this case a triangle is made of 3 consecutive points
202
203
 
203
204
 
204
205
#ifdef WITH_CXX_GUARDEDALLOC
205
 
public:
206
 
        void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:CcdShapeConstructionInfo"); }
207
 
        void operator delete( void *mem ) { MEM_freeN(mem); }
 
206
        MEM_CXX_CLASS_ALLOC_FUNCS("GE:CcdShapeConstructionInfo")
208
207
#endif
209
208
};
210
209
 
221
220
                KinematicFilter = 4,
222
221
                DebrisFilter = 8,
223
222
                SensorFilter = 16,
224
 
                AllFilter = DefaultFilter | StaticFilter | KinematicFilter | DebrisFilter | SensorFilter,
 
223
                CharacterFilter = 32,
 
224
                AllFilter = DefaultFilter | StaticFilter | KinematicFilter | DebrisFilter | SensorFilter | CharacterFilter,
225
225
        };
226
226
 
227
227
 
229
229
            :m_localInertiaTensor(1.f, 1.f, 1.f),
230
230
                m_gravity(0,0,0),
231
231
                m_scaling(1.f,1.f,1.f),
 
232
                m_linearFactor(0.f, 0.f, 0.f),
 
233
                m_angularFactor(0.f, 0.f, 0.f),
232
234
                m_mass(0.f),
233
235
                m_clamp_vel_min(-1.f),
234
236
                m_clamp_vel_max(-1.f),
267
269
                m_bRigid(false),
268
270
                m_bSoft(false),
269
271
                m_bSensor(false),
 
272
                m_bCharacter(false),
270
273
                m_bGimpact(false),
271
274
                m_collisionFilterGroup(DefaultFilter),
272
275
                m_collisionFilterMask(AllFilter),
291
294
        btVector3       m_localInertiaTensor;
292
295
        btVector3       m_gravity;
293
296
        btVector3       m_scaling;
 
297
        btVector3       m_linearFactor;
 
298
        btVector3       m_angularFactor;
294
299
        btScalar        m_mass;
295
300
        btScalar        m_clamp_vel_min;  
296
301
        btScalar        m_clamp_vel_max;  
301
306
        btScalar        m_margin;
302
307
 
303
308
        ////////////////////
 
309
        float   m_stepHeight;
 
310
        float   m_jumpSpeed;
 
311
        float   m_fallSpeed;
 
312
        
304
313
        int             m_gamesoftFlag;
305
314
        float   m_soft_linStiff;                        /* linear stiffness 0..1 */
306
315
        float   m_soft_angStiff;                /* angular stiffness 0..1 */
343
352
        bool            m_bRigid;
344
353
        bool            m_bSoft;
345
354
        bool            m_bSensor;
 
355
        bool            m_bCharacter;
346
356
        bool            m_bGimpact;                     // use Gimpact for mesh body
347
357
 
348
358
        ///optional use of collision group/mask:
381
391
 
382
392
};
383
393
 
384
 
 
385
394
class btRigidBody;
386
395
class btCollisionObject;
387
396
class btSoftBody;
 
397
class btPairCachingGhostObject;
 
398
 
 
399
class BlenderBulletCharacterController : public btKinematicCharacterController
 
400
{
 
401
private:
 
402
        btMotionState* m_motionState;
 
403
        int m_jumps;
 
404
        int m_maxJumps;
 
405
 
 
406
public:
 
407
        BlenderBulletCharacterController(btMotionState *motionState, btPairCachingGhostObject *ghost, btConvexShape* shape, float stepHeight);
 
408
 
 
409
        virtual void updateAction(btCollisionWorld *collisionWorld, btScalar dt);
 
410
 
 
411
        int getMaxJumps() const;
 
412
 
 
413
        void setMaxJumps(int maxJumps);
 
414
 
 
415
        int getJumpCount() const;
 
416
 
 
417
        virtual bool canJump() const;
 
418
 
 
419
        virtual void jump();
 
420
 
 
421
        const btVector3& getWalkDirection();
 
422
};
388
423
 
389
424
///CcdPhysicsController is a physics object that supports continuous collision detection and time of impact based physics resolution.
390
 
class CcdPhysicsController : public PHY_IPhysicsController      
 
425
class CcdPhysicsController : public PHY_IPhysicsController
391
426
{
392
427
protected:
393
428
        btCollisionObject* m_object;
 
429
        BlenderBulletCharacterController* m_characterController;
394
430
        
395
431
 
396
432
        class PHY_IMotionState*         m_MotionState;
417
453
 
418
454
        void CreateRigidbody();
419
455
        bool CreateSoftbody();
 
456
        bool CreateCharacterController();
420
457
 
421
458
        bool Register() { 
422
459
                return (m_registerCount++ == 0) ? true : false;
453
490
                btRigidBody* GetRigidBody();
454
491
                btCollisionObject*      GetCollisionObject();
455
492
                btSoftBody* GetSoftBody();
 
493
                btKinematicCharacterController* GetCharacterController();
456
494
 
457
495
                CcdShapeConstructionInfo* GetShapeInfo() { return m_shapeInfo; }
458
496
 
465
503
 
466
504
 
467
505
                /**
468
 
                        SynchronizeMotionStates ynchronizes dynas, kinematic and deformable entities (and do 'late binding')
469
 
                */
 
506
                 * SynchronizeMotionStates ynchronizes dynas, kinematic and deformable entities (and do 'late binding')
 
507
                 */
470
508
                virtual bool            SynchronizeMotionStates(float time);
471
509
                /**
472
 
                        WriteMotionStateToDynamics ynchronizes dynas, kinematic and deformable entities (and do 'late binding')
473
 
                */
 
510
                 * WriteMotionStateToDynamics ynchronizes dynas, kinematic and deformable entities (and do 'late binding')
 
511
                 */
474
512
                
475
513
                virtual void            WriteMotionStateToDynamics(bool nondynaonly);
476
514
                virtual void            WriteDynamicsToMotionState();
481
519
 
482
520
                // kinematic methods
483
521
                virtual void            RelativeTranslate(float dlocX,float dlocY,float dlocZ,bool local);
 
522
                virtual void            SetWalkDirection(float dirX,float dirY,float dirZ,bool local);
484
523
                virtual void            RelativeRotate(const float drot[9],bool local);
485
524
                virtual void            getOrientation(float &quatImag0,float &quatImag1,float &quatImag2,float &quatReal);
486
525
                virtual void            setOrientation(float quatImag0,float quatImag1,float quatImag2,float quatReal);
495
534
                virtual void            SetAngularVelocity(float ang_velX,float ang_velY,float ang_velZ,bool local);
496
535
                virtual void            SetLinearVelocity(float lin_velX,float lin_velY,float lin_velZ,bool local);
497
536
                virtual void            applyImpulse(float attachX,float attachY,float attachZ, float impulseX,float impulseY,float impulseZ);
 
537
                virtual void            Jump();
498
538
                virtual void            SetActive(bool active);
499
539
 
500
540
                // reading out information from physics
502
542
                virtual void            GetAngularVelocity(float& angVelX,float& angVelY,float& angVelZ);
503
543
                virtual void            GetVelocity(const float posX,const float posY,const float posZ,float& linvX,float& linvY,float& linvZ); 
504
544
                virtual void            getReactionForce(float& forceX,float& forceY,float& forceZ);
 
545
                virtual void            GetWalkDirection(float& dirX,float& dirY,float& dirZ);
505
546
 
506
547
                // dyna's that are rigidbody are free in orientation, dyna's with non-rigidbody are restricted 
507
548
                virtual void            setRigidBody(bool rigid);
615
656
                }
616
657
 
617
658
#ifdef WITH_CXX_GUARDEDALLOC
618
 
public:
619
 
        void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:CcdPhysicsController"); }
620
 
        void operator delete( void *mem ) { MEM_freeN(mem); }
 
659
        MEM_CXX_CLASS_ALLOC_FUNCS("GE:CcdPhysicsController")
621
660
#endif
622
661
};
623
662
 
649
688
        
650
689
        
651
690
#ifdef WITH_CXX_GUARDEDALLOC
652
 
public:
653
 
        void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:DefaultMotionState"); }
654
 
        void operator delete( void *mem ) { MEM_freeN(mem); }
 
691
        MEM_CXX_CLASS_ALLOC_FUNCS("GE:DefaultMotionState")
655
692
#endif
656
693
};
657
694
 
658
695
 
659
 
#endif //__CCDPHYSICSCONTROLLER_H__
 
696
#endif  /* __CCDPHYSICSCONTROLLER_H__ */