~ubuntu-branches/ubuntu/saucy/emscripten/saucy-proposed

« back to all changes in this revision

Viewing changes to tests/bullet/src/BulletMultiThreaded/TrbDynBody.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
   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
 
 
27
class TrbDynBody
 
28
{
 
29
public:
 
30
        TrbDynBody()
 
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