Tizen 2.1 base
[platform/upstream/libbullet.git] / src / BulletMultiThreaded / TrbDynBody.h
1 /*\r
2    Copyright (C) 2009 Sony Computer Entertainment Inc.\r
3    All rights reserved.\r
4 \r
5 This software is provided 'as-is', without any express or implied warranty.\r
6 In no event will the authors be held liable for any damages arising from the use of this software.\r
7 Permission is granted to anyone to use this software for any purpose, \r
8 including commercial applications, and to alter it and redistribute it freely, \r
9 subject to the following restrictions:\r
10 \r
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.\r
12 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.\r
13 3. This notice may not be removed or altered from any source distribution.\r
14 \r
15 */\r
16 \r
17 #ifndef BT_RB_DYN_BODY_H__\r
18 #define BT_RB_DYN_BODY_H__\r
19 \r
20 #include "vectormath/vmInclude.h"\r
21 using namespace Vectormath::Aos;\r
22 \r
23 #include "TrbStateVec.h"\r
24 \r
25 class CollObject;\r
26 \r
27 class TrbDynBody\r
28 {\r
29 public:\r
30         TrbDynBody()\r
31         {\r
32                 fMass   = 0.0f;\r
33                 fCollObject = NULL;\r
34                 fElasticity = 0.2f;\r
35                 fFriction = 0.8f;\r
36         }\r
37 \r
38         // Get methods\r
39         float          getMass() const {return fMass;};\r
40         float          getElasticity() const {return fElasticity;}\r
41         float          getFriction() const {return fFriction;}\r
42         CollObject*    getCollObject() const {return fCollObject;}\r
43         const Matrix3 &getBodyInertia() const {return fIBody;}\r
44         const Matrix3 &getBodyInertiaInv() const {return fIBodyInv;}\r
45         float          getMassInv() const {return fMassInv;}\r
46 \r
47         // Set methods\r
48         void           setMass(float mass) {fMass=mass;fMassInv=mass>0.0f?1.0f/mass:0.0f;}\r
49         void           setBodyInertia(const Matrix3 bodyInertia) {fIBody = bodyInertia;fIBodyInv = inverse(bodyInertia);}\r
50         void           setElasticity(float elasticity) {fElasticity = elasticity;}\r
51         void           setFriction(float friction) {fFriction = friction;}\r
52         void           setCollObject(CollObject *collObj) {fCollObject = collObj;}\r
53         \r
54         void           setBodyInertiaInv(const Matrix3 bodyInertiaInv) \r
55         {\r
56                 fIBody = inverse(bodyInertiaInv);\r
57                 fIBodyInv = bodyInertiaInv;\r
58         }\r
59         void           setMassInv(float invMass) {\r
60                 fMass= invMass>0.0f ? 1.0f/invMass :0.0f;\r
61                 fMassInv=invMass;\r
62         }\r
63 \r
64 \r
65 private:\r
66         // Rigid Body constants\r
67         float          fMass;        // Rigid Body mass\r
68         float          fMassInv;     // Inverse of mass\r
69         Matrix3        fIBody;       // Inertia matrix in body's coords\r
70         Matrix3        fIBodyInv;    // Inertia matrix inverse in body's coords\r
71         float          fElasticity;  // Coefficient of restitution\r
72         float          fFriction;    // Coefficient of friction\r
73 \r
74 public:\r
75         CollObject*    fCollObject;  // Collision object corresponding the RB\r
76 } __attribute__ ((aligned(16)));\r
77 \r
78 #endif //BT_RB_DYN_BODY_H__\r
79 \r