Bullet Collision Detection & Physics Library
TrbDynBody.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2009 Sony Computer Entertainment Inc.
3  All rights reserved.
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 */
16 
17 #ifndef BT_RB_DYN_BODY_H__
18 #define BT_RB_DYN_BODY_H__
19 
20 #include "vectormath/vmInclude.h"
21 using namespace Vectormath::Aos;
22 
23 #include "TrbStateVec.h"
24 
25 class CollObject;
26 
28 {
29 public:
31  {
32  fMass = 0.0f;
33  fCollObject = NULL;
34  fElasticity = 0.2f;
35  fFriction = 0.8f;
36  }
37 
38  // Get methods
39  float getMass() const {return fMass;};
40  float getElasticity() const {return fElasticity;}
41  float getFriction() const {return fFriction;}
42  CollObject* getCollObject() const {return fCollObject;}
43  const Matrix3 &getBodyInertia() const {return fIBody;}
44  const Matrix3 &getBodyInertiaInv() const {return fIBodyInv;}
45  float getMassInv() const {return fMassInv;}
46 
47  // Set methods
48  void setMass(float mass) {fMass=mass;fMassInv=mass>0.0f?1.0f/mass:0.0f;}
49  void setBodyInertia(const Matrix3 bodyInertia) {fIBody = bodyInertia;fIBodyInv = inverse(bodyInertia);}
50  void setElasticity(float elasticity) {fElasticity = elasticity;}
51  void setFriction(float friction) {fFriction = friction;}
52  void setCollObject(CollObject *collObj) {fCollObject = collObj;}
53 
54  void setBodyInertiaInv(const Matrix3 bodyInertiaInv)
55  {
56  fIBody = inverse(bodyInertiaInv);
57  fIBodyInv = bodyInertiaInv;
58  }
59  void setMassInv(float invMass) {
60  fMass= invMass>0.0f ? 1.0f/invMass :0.0f;
61  fMassInv=invMass;
62  }
63 
64 
65 private:
66  // Rigid Body constants
67  float fMass; // Rigid Body mass
68  float fMassInv; // Inverse of mass
69  Matrix3 fIBody; // Inertia matrix in body's coords
70  Matrix3 fIBodyInv; // Inertia matrix inverse in body's coords
71  float fElasticity; // Coefficient of restitution
72  float fFriction; // Coefficient of friction
73 
74 public:
75  CollObject* fCollObject; // Collision object corresponding the RB
76 } __attribute__ ((aligned(16)));
77 
78 #endif //BT_RB_DYN_BODY_H__
79 
float fFriction
Definition: TrbDynBody.h:185
void setMassInv(float invMass)
Definition: TrbDynBody.h:59
CollObject * fCollObject
Definition: TrbDynBody.h:75
Matrix3 fIBodyInv
Definition: TrbDynBody.h:183
const Matrix3 inverse(const Matrix3 &mat)
Definition: neon/mat_aos.h:174
CollObject * getCollObject() const
Definition: TrbDynBody.h:42
Matrix3 fIBody
Definition: TrbDynBody.h:69
float getMass() const
Definition: TrbDynBody.h:39
float fMassInv
Definition: TrbDynBody.h:68
float fFriction
Definition: TrbDynBody.h:72
float fElasticity
Definition: TrbDynBody.h:184
void setFriction(float friction)
Definition: TrbDynBody.h:51
Matrix3 fIBody
Definition: TrbDynBody.h:182
float fElasticity
Definition: TrbDynBody.h:71
const Matrix3 & getBodyInertia() const
Definition: TrbDynBody.h:43
CollObject * fCollObject
Definition: TrbDynBody.h:188
void setMass(float mass)
Definition: TrbDynBody.h:48
float fMass
Definition: TrbDynBody.h:67
Matrix3 fIBodyInv
Definition: TrbDynBody.h:70
void setBodyInertiaInv(const Matrix3 bodyInertiaInv)
Definition: TrbDynBody.h:54
class TrbDynBody __attribute__((aligned(16)))
float fMass
Definition: TrbDynBody.h:180
float getMassInv() const
Definition: TrbDynBody.h:45
void setBodyInertia(const Matrix3 bodyInertia)
Definition: TrbDynBody.h:49
void setElasticity(float elasticity)
Definition: TrbDynBody.h:50
float getFriction() const
Definition: TrbDynBody.h:41
float getElasticity() const
Definition: TrbDynBody.h:40
float fMassInv
Definition: TrbDynBody.h:181
void setCollObject(CollObject *collObj)
Definition: TrbDynBody.h:52
const Matrix3 & getBodyInertiaInv() const
Definition: TrbDynBody.h:44