My Project: dynamics.mod/NewtonDynamics/source/newton/NewtonClass.h Source File

My Project

NewtonClass.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 __NewotnClass_3HL6356GYL459020__
23 #define __NewotnClass_3HL6356GYL459020__
24
25 #include "NewtonStdAfx.h"
26 #include "Newton.h"
27
28
29
30 #define DG_TIMESTEP (1.0f / 60.0f)
31 #define DG_MAX_TIMESTEP (1.0f / 30.0f)
32 #define DG_MIN_TIMESTEP (1.0f / 1000.0f)
33
34 class Newton;
35
36
37 class NewtonDeadBodies: public dgTree<dgBody*, void* >
38 {
39 public:
40 NewtonDeadBodies(dgMemoryAllocator* const allocator);
41 void DestroyBodies(Newton& world);
42 };
43
44
45 class NewtonDeadJoints: public dgTree<dgConstraint*, void* >
46 {
47 public:
48 NewtonDeadJoints(dgMemoryAllocator* const allocator);
49 void DestroyJoints(Newton& world);
50 };
51
52
53 class Newton:
54 public dgWorld,
55 public NewtonDeadBodies,
56 public NewtonDeadJoints
57 {
58 public:
59 DG_CLASS_ALLOCATOR(allocator)
60
61 Newton (dgFloat32 scale, dgMemoryAllocator* const allocator);
62 ~Newton ();
63
64 void DestroyBody(dgBody* const body);
65 void DestroyJoint(dgConstraint* const joint);
66
67 void UpdatePhysics (dgFloat32 timestep);
68 void UpdatePhysicsAsync (dgFloat32 timestep);
69 static void* DefaultAllocMemory (dgInt32 size);
70 static void DefaultFreeMemory (void* const ptr, dgInt32 size);
71
72 dgFloat32 m_maxTimeStep;
73
74
75 NewtonWorldDestructorCallback m_destructor;
76 };
77
78
79
80 class NewtonUserJoint: public dgUserConstraint
81 {
82 public:
83 NewtonUserJoint (dgWorld* const world, dgInt32 maxDof, NewtonUserBilateralCallback callback, NewtonUserBilateralGetInfoCallback getInfo, dgBody* const dyn0, dgBody* const dyn1);
84 ~NewtonUserJoint ();
85
86 dgUnsigned32 JacobianDerivative (dgContraintDescritor& params);
87
88 void AddAngularRowJacobian (const dgVector& dir, dgFloat32 relAngle);
89 void AddGeneralRowJacobian (const dgFloat32* const jacobian0, const dgFloat32* const jacobian1);
90 void AddLinearRowJacobian (const dgVector& pivot0, const dgVector& pivot1, const dgVector& dir);
91
92 dgFloat32 GetRowForce (dgInt32 row) const;
93 void SetHighFriction (dgFloat32 friction);
94 void SetLowerFriction (dgFloat32 friction);
95 void SetRowStiffness (dgFloat32 stiffness);
96 void SetAcceleration (dgFloat32 acceleration);
97 void SetSpringDamperAcceleration (dgFloat32 springK, dgFloat32 springD);
98 void GetInfo (dgConstraintInfo* const info) const;
99
100 void SetUpdateFeedbackFunction (NewtonUserBilateralCallback getFeedback);
101
102 void SetMaxContactsForExactSolver (bool mode, dgInt32 MaxCount);
103
104 private:
105 NewtonUserBilateralCallback m_jacobianFnt;
106 NewtonUserBilateralGetInfoCallback m_getInfoCallback;
107
108 dgInt32 m_rows;
109 dgForceImpactPair* m_forceArray;
110 dgContraintDescritor* m_param;
111
112 dgFloat32 m_lastJointAngle;
113 dgVector m_lastPosit0;
114 dgVector m_lastPosit1;
115 };
116
117
118
119 #endif
NewtonDeadJoints
Definition: NewtonClass.h:45
NewtonUserBilateralGetInfoCallback
void(* NewtonUserBilateralGetInfoCallback)(const NewtonJoint *const userJoint, NewtonJointRecord *const info)
Definition: Newton.h:413
dgForceImpactPair
Definition: dgConstraint.h:73
NewtonDeadBodies::DestroyBodies
void DestroyBodies(Newton &world)
Definition: NewtonClass.cpp:35
dgBody
Definition: dgBody.h:44
Newton
Definition: NewtonClass.h:53
dgFloat32
float dgFloat32
Definition: dgTypes.h:233
dgInt32
int dgInt32
Definition: dgTypes.h:218
NewtonWorldDestructorCallback
void(* NewtonWorldDestructorCallback)(const NewtonWorld *const world)
Definition: Newton.h:345
dgVector
Definition: dgVector.h:639
NewtonDeadBodies
Definition: NewtonClass.h:37
DG_CLASS_ALLOCATOR
#define DG_CLASS_ALLOCATOR(allocator)
Definition: dgMemory.h:60
dgContraintDescritor
Definition: dgConstraint.h:118
dgConstraintInfo
Definition: dgConstraint.h:46
dgUserConstraint
Definition: dgUserConstraint.h:30
Newton::m_maxTimeStep
dgFloat32 m_maxTimeStep
Definition: NewtonClass.h:72
dgTree
Definition: dgTree.h:88
Newton::m_destructor
NewtonWorldDestructorCallback m_destructor
Definition: NewtonClass.h:75
NewtonUserJoint
Definition: NewtonClass.h:80
dgUnsigned32
unsigned dgUnsigned32
Definition: dgTypes.h:219
NewtonStdAfx.h
timestep
dgFloat32 timestep
Definition: dgBallConstraint.h:34
Newton.h
NewtonUserBilateralCallback
void(* NewtonUserBilateralCallback)(const NewtonJoint *const userJoint, dFloat timestep, int threadIndex)
Definition: Newton.h:412
dgMemoryAllocator
Definition: dgMemory.h:73
NewtonDeadBodies::NewtonDeadBodies
NewtonDeadBodies(dgMemoryAllocator *const allocator)
Definition: NewtonClass.cpp:29
dgConstraint
Definition: dgConstraint.h:140
dgWorld
Definition: dgWorld.h:129