My Project: dynamics.mod/NewtonDynamics/source/physics/dgDeformableBody.h Source File

My Project

dgDeformableBody.h
Go to the documentation of this file.
1 /* Copyright (c) <2003-2011> <Julio Jerez, Newton Game Dynamics>
2 *
3 * This software is provided 'as-is', without any express or implied
4 * warranty. In no event will the authors be held liable for any damages
5 * arising from the use of this software.
6 *
7 * Permission is granted to anyone to use this software for any purpose,
8 * including commercial applications, and to alter it and redistribute it
9 * freely, subject to the following restrictions:
10 *
11 * 1. The origin of this software must not be misrepresented; you must not
12 * claim that you wrote the original software. If you use this software
13 * in a product, an acknowledgment in the product documentation would be
14 * appreciated but is not required.
15 *
16 * 2. Altered source versions must be plainly marked as such, and must not be
17 * misrepresented as being the original software.
18 *
19 * 3. This notice may not be removed or altered from any source distribution.
20 */
21
22 #ifndef _DG_DEFORMABLE_BODY_H_
23 #define _DG_DEFORMABLE_BODY_H_
24
25 #include "dgPhysicsStdafx.h"
26
27 #include "dgBody.h"
28
29 DG_MSC_VECTOR_ALIGMENT
30 class dgDeformableBody: public dgBody
31 {
32 public:
33 dgDeformableBody();
34 dgDeformableBody(dgWorld* const world, const dgTree<const dgCollision*, dgInt32>* const collisionNode, dgDeserialize serializeCallback, void* const userData);
35 virtual ~dgDeformableBody();
36
37 virtual void Serialize (const dgTree<dgInt32, const dgCollision*>* const collisionNode, dgSerialize serializeCallback, void* const userData);
38
39 protected:
40 virtual bool IsDeformable() const;
41 virtual bool IsInEquilibrium () const;
42
43 virtual void SetMatrix(const dgMatrix& matrix);
44 virtual void ApplyExtenalForces (dgFloat32 timestep, dgInt32 threadIndex);
45 virtual void SetVelocity (const dgVector& velocity);
46
47 virtual void SetMassMatrix (dgFloat32 mass, dgFloat32 Ix, dgFloat32 Iy, dgFloat32 Iz);
48 virtual void SetMassProperties (dgFloat32 mass, const dgCollisionInstance* const collision);
49
50 virtual const dgVector& GetForce() const;
51 virtual const dgVector& GetTorque() const {return m_dummy;}
52 virtual void AddDampingAcceleration() {}
53
54 virtual void AddForce (const dgVector& force);
55 virtual void SetForce (const dgVector& force);
56 virtual void SetTorque (const dgVector& torque) {}
57 virtual void AddTorque (const dgVector& torque) {}
58
59 virtual dgFloat32 GetLinearDamping () const {return dgFloat32 (0.0f);}
60 virtual dgVector GetAngularDamping () const {return m_dummy;}
61 virtual void SetLinearDamping (dgFloat32 linearDamp) {}
62 virtual void SetAngularDamping (const dgVector& angularDamp) {}
63
64 virtual const dgMatrix& GetInertiaMatrix () const {return dgGetZeroMatrix();}
65 virtual dgMatrix CalculateInertiaMatrix () const {return dgGetZeroMatrix();}
66 virtual dgMatrix CalculateInvInertiaMatrix () const {return dgGetZeroMatrix();}
67
68 virtual void AttachCollision (dgCollisionInstance* const collision);
69
70 virtual dgVector PredictLinearVelocity(dgFloat32 timestep) const {return m_veloc;}
71 virtual dgVector PredictAngularVelocity(dgFloat32 timestep) const {return m_omega;}
72
73 virtual void SetCollidable (bool state) {m_collidable = state;}
74 virtual void AddImpulse (const dgVector& pointVeloc, const dgVector& pointPosit) {dgAssert(0);}
75 virtual void ApplyImpulsePair (const dgVector& linearImpulse, const dgVector& angularImpulse) {dgAssert(0);}
76 virtual void ApplyImpulsesAtPoint (dgInt32 count, dgInt32 strideInBytes, const dgFloat32* const impulseArray, const dgFloat32* const pointArray) {dgAssert(0);}
77
78 virtual void SetExtForceAndTorqueCallback (OnApplyExtForceAndTorque callback);
79 virtual OnApplyExtForceAndTorque GetExtForceAndTorqueCallback () const;
80
81 dgVector m_force;
82 dgVector m_torque;
83 OnApplyExtForceAndTorque m_applyExtForces;
84 static dgVector m_dummy;
85
86 } DG_GCC_VECTOR_ALIGMENT;
87
88
89 inline bool dgDeformableBody::IsDeformable() const
90 {
91 return true;
92 }
93
94
95 #endif
96
dgDeformableBody::SetExtForceAndTorqueCallback
virtual void SetExtForceAndTorqueCallback(OnApplyExtForceAndTorque callback)
Definition: dgDeformableBody.cpp:105
dgDeformableBody::GetTorque
virtual const dgVector & GetTorque() const
Definition: dgDeformableBody.h:51
dgDeformableBody::Serialize
virtual void Serialize(const dgTree< dgInt32, const dgCollision *> *const collisionNode, dgSerialize serializeCallback, void *const userData)
Definition: dgDeformableBody.cpp:59
dgDeformableBody::GetExtForceAndTorqueCallback
virtual OnApplyExtForceAndTorque GetExtForceAndTorqueCallback() const
Definition: dgDeformableBody.cpp:83
dgDeformableBody::GetLinearDamping
virtual dgFloat32 GetLinearDamping() const
Definition: dgDeformableBody.h:59
dgDeformableBody::SetMassProperties
virtual void SetMassProperties(dgFloat32 mass, const dgCollisionInstance *const collision)
Definition: dgDeformableBody.cpp:67
dgDeformableBody::IsInEquilibrium
virtual bool IsInEquilibrium() const
Definition: dgDeformableBody.cpp:134
dgGetZeroMatrix
const dgMatrix & dgGetZeroMatrix()
Definition: dgMatrix.cpp:52
dgDeformableBody::AddTorque
virtual void AddTorque(const dgVector &torque)
Definition: dgDeformableBody.h:57
dgBody
Definition: dgBody.h:44
dgDeformableBody::CalculateInertiaMatrix
virtual dgMatrix CalculateInertiaMatrix() const
Definition: dgDeformableBody.h:65
userData
void *const userData
Definition: dgBroadPhase.h:35
dgAssert
#define dgAssert(x)
Definition: dgTypes.h:158
dgFloat32
float dgFloat32
Definition: dgTypes.h:233
dgInt32
int dgInt32
Definition: dgTypes.h:218
dgBody.h
dgDeformableBody::PredictAngularVelocity
virtual dgVector PredictAngularVelocity(dgFloat32 timestep) const
Definition: dgDeformableBody.h:71
dgVector
Definition: dgVector.h:639
dgBody::m_omega
dgVector m_omega
Definition: dgBody.h:209
dgDeformableBody
Definition: dgDeformableBody.h:30
dgDeformableBody::GetAngularDamping
virtual dgVector GetAngularDamping() const
Definition: dgDeformableBody.h:60
dgDeformableBody::AddDampingAcceleration
virtual void AddDampingAcceleration()
Definition: dgDeformableBody.h:52
dgDeformableBody::m_torque
dgVector m_torque
Definition: dgDeformableBody.h:82
dgDeformableBody::dgDeformableBody
dgDeformableBody()
Definition: dgDeformableBody.cpp:32
dgDeformableBody::ApplyExtenalForces
virtual void ApplyExtenalForces(dgFloat32 timestep, dgInt32 threadIndex)
Definition: dgDeformableBody.cpp:111
dgSerialize
void(dgApi * dgSerialize)(void *const userData, const void *const buffer, size_t size)
Definition: dgTypes.h:280
dgTree
Definition: dgTree.h:88
DG_MSC_VECTOR_ALIGMENT
#define DG_MSC_VECTOR_ALIGMENT
Definition: dgTypes.h:194
dgDeformableBody::SetVelocity
virtual void SetVelocity(const dgVector &velocity)
Definition: dgDeformableBody.cpp:121
dgDeformableBody::m_applyExtForces
OnApplyExtForceAndTorque m_applyExtForces
Definition: dgDeformableBody.h:83
dgDeformableBody::SetLinearDamping
virtual void SetLinearDamping(dgFloat32 linearDamp)
Definition: dgDeformableBody.h:61
dgDeformableBody::ApplyImpulsePair
virtual void ApplyImpulsePair(const dgVector &linearImpulse, const dgVector &angularImpulse)
Definition: dgDeformableBody.h:75
dgDeserialize
void(dgApi * dgDeserialize)(void *const userData, void *buffer, size_t size)
Definition: dgTypes.h:279
dgDeformableBody::GetInertiaMatrix
virtual const dgMatrix & GetInertiaMatrix() const
Definition: dgDeformableBody.h:64
dgDeformableBody::IsDeformable
virtual bool IsDeformable() const
Definition: dgDeformableBody.h:89
dgBody::m_collidable
dgUnsigned32 m_collidable
Definition: dgBody.h:238
dgCollisionInstance
Definition: dgCollisionInstance.h:30
dgDeformableBody::m_force
dgVector m_force
Definition: dgDeformableBody.h:81
dgDeformableBody::AddImpulse
virtual void AddImpulse(const dgVector &pointVeloc, const dgVector &pointPosit)
Definition: dgDeformableBody.h:74
dgDeformableBody::AttachCollision
virtual void AttachCollision(dgCollisionInstance *const collision)
Definition: dgDeformableBody.cpp:141
dgDeformableBody::SetCollidable
virtual void SetCollidable(bool state)
Definition: dgDeformableBody.h:73
DG_GCC_VECTOR_ALIGMENT
dgDeformableBody DG_GCC_VECTOR_ALIGMENT
dgBody::m_veloc
dgVector m_veloc
Definition: dgBody.h:208
threadIndex
dgFloat32 dgInt32 threadIndex
Definition: dgConstraint.h:44
dgDeformableBody::AddForce
virtual void AddForce(const dgVector &force)
Definition: dgDeformableBody.cpp:93
timestep
dgFloat32 timestep
Definition: dgBallConstraint.h:34
dgDeformableBody::~dgDeformableBody
virtual ~dgDeformableBody()
Definition: dgDeformableBody.cpp:53
dgDeformableBody::PredictLinearVelocity
virtual dgVector PredictLinearVelocity(dgFloat32 timestep) const
Definition: dgDeformableBody.h:70
dgMatrix
Definition: dgMatrix.h:40
dgDeformableBody::SetTorque
virtual void SetTorque(const dgVector &torque)
Definition: dgDeformableBody.h:56
dgPhysicsStdafx.h
dgDeformableBody::GetForce
virtual const dgVector & GetForce() const
Definition: dgDeformableBody.cpp:88
dgDeformableBody::CalculateInvInertiaMatrix
virtual dgMatrix CalculateInvInertiaMatrix() const
Definition: dgDeformableBody.h:66
dgDeformableBody::ApplyImpulsesAtPoint
virtual void ApplyImpulsesAtPoint(dgInt32 count, dgInt32 strideInBytes, const dgFloat32 *const impulseArray, const dgFloat32 *const pointArray)
Definition: dgDeformableBody.h:76
dgDeformableBody::SetMatrix
virtual void SetMatrix(const dgMatrix &matrix)
Definition: dgDeformableBody.cpp:157
dgWorld
Definition: dgWorld.h:129
dgDeformableBody::SetAngularDamping
virtual void SetAngularDamping(const dgVector &angularDamp)
Definition: dgDeformableBody.h:62
dgBody::OnApplyExtForceAndTorque
void(dgApi * OnApplyExtForceAndTorque)(dgBody &me, dgFloat32 timestep, dgInt32 threadIndex)
Definition: dgBody.h:48
dgDeformableBody::SetForce
virtual void SetForce(const dgVector &force)
Definition: dgDeformableBody.cpp:98
dgDeformableBody::m_dummy
static dgVector m_dummy
Definition: dgDeformableBody.h:84
dgDeformableBody::SetMassMatrix
virtual void SetMassMatrix(dgFloat32 mass, dgFloat32 Ix, dgFloat32 Iy, dgFloat32 Iz)
Definition: dgDeformableBody.cpp:72