[216] | 1 | /************************************************************************* |
---|
| 2 | * * |
---|
| 3 | * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * |
---|
| 4 | * All rights reserved. Email: russ@q12.org Web: www.q12.org * |
---|
| 5 | * * |
---|
| 6 | * This library is free software; you can redistribute it and/or * |
---|
| 7 | * modify it under the terms of EITHER: * |
---|
| 8 | * (1) The GNU Lesser General Public License as published by the Free * |
---|
| 9 | * Software Foundation; either version 2.1 of the License, or (at * |
---|
| 10 | * your option) any later version. The text of the GNU Lesser * |
---|
| 11 | * General Public License is included with this library in the * |
---|
| 12 | * file LICENSE.TXT. * |
---|
| 13 | * (2) The BSD-style license that is included with this library in * |
---|
| 14 | * the file LICENSE-BSD.TXT. * |
---|
| 15 | * * |
---|
| 16 | * This library is distributed in the hope that it will be useful, * |
---|
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
---|
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * |
---|
| 19 | * LICENSE.TXT and LICENSE-BSD.TXT for more details. * |
---|
| 20 | * * |
---|
| 21 | *************************************************************************/ |
---|
| 22 | |
---|
| 23 | // object, body, and world structs. |
---|
| 24 | |
---|
| 25 | |
---|
| 26 | #ifndef _ODE_OBJECT_H_ |
---|
| 27 | #define _ODE_OBJECT_H_ |
---|
| 28 | |
---|
| 29 | #include <ode/common.h> |
---|
| 30 | #include <ode/memory.h> |
---|
| 31 | #include <ode/mass.h> |
---|
| 32 | #include "array.h" |
---|
| 33 | |
---|
| 34 | |
---|
| 35 | // some body flags |
---|
| 36 | |
---|
| 37 | enum { |
---|
| 38 | dxBodyFlagFiniteRotation = 1, // use finite rotations |
---|
| 39 | dxBodyFlagFiniteRotationAxis = 2, // use finite rotations only along axis |
---|
| 40 | dxBodyDisabled = 4, // body is disabled |
---|
| 41 | dxBodyNoGravity = 8, // body is not influenced by gravity |
---|
| 42 | dxBodyAutoDisable = 16 // enable auto-disable on body |
---|
| 43 | }; |
---|
| 44 | |
---|
| 45 | |
---|
| 46 | // base class that does correct object allocation / deallocation |
---|
| 47 | |
---|
| 48 | struct dBase { |
---|
| 49 | void *operator new (size_t size) { return dAlloc (size); } |
---|
| 50 | void operator delete (void *ptr, size_t size) { dFree (ptr,size); } |
---|
| 51 | void *operator new[] (size_t size) { return dAlloc (size); } |
---|
| 52 | void operator delete[] (void *ptr, size_t size) { dFree (ptr,size); } |
---|
| 53 | }; |
---|
| 54 | |
---|
| 55 | |
---|
| 56 | // base class for bodies and joints |
---|
| 57 | |
---|
| 58 | struct dObject : public dBase { |
---|
| 59 | dxWorld *world; // world this object is in |
---|
| 60 | dObject *next; // next object of this type in list |
---|
| 61 | dObject **tome; // pointer to previous object's next ptr |
---|
| 62 | void *userdata; // user settable data |
---|
| 63 | int tag; // used by dynamics algorithms |
---|
| 64 | }; |
---|
| 65 | |
---|
| 66 | |
---|
| 67 | // auto disable parameters |
---|
| 68 | struct dxAutoDisable { |
---|
| 69 | dReal idle_time; // time the body needs to be idle to auto-disable it |
---|
| 70 | int idle_steps; // steps the body needs to be idle to auto-disable it |
---|
| 71 | dReal linear_average_threshold; // linear (squared) average velocity threshold |
---|
| 72 | dReal angular_average_threshold; // angular (squared) average velocity threshold |
---|
| 73 | unsigned int average_samples; // size of the average_lvel and average_avel buffers |
---|
| 74 | }; |
---|
| 75 | |
---|
| 76 | |
---|
| 77 | // quick-step parameters |
---|
| 78 | struct dxQuickStepParameters { |
---|
| 79 | int num_iterations; // number of SOR iterations to perform |
---|
| 80 | dReal w; // the SOR over-relaxation parameter |
---|
| 81 | }; |
---|
| 82 | |
---|
| 83 | |
---|
| 84 | // contact generation parameters |
---|
| 85 | struct dxContactParameters { |
---|
| 86 | dReal max_vel; // maximum correcting velocity |
---|
| 87 | dReal min_depth; // thickness of 'surface layer' |
---|
| 88 | }; |
---|
| 89 | |
---|
| 90 | |
---|
| 91 | |
---|
| 92 | // position vector and rotation matrix for geometry objects that are not |
---|
| 93 | // connected to bodies. |
---|
| 94 | |
---|
| 95 | struct dxPosR { |
---|
| 96 | dVector3 pos; |
---|
| 97 | dMatrix3 R; |
---|
| 98 | }; |
---|
| 99 | |
---|
| 100 | struct dxBody : public dObject { |
---|
| 101 | dxJointNode *firstjoint; // list of attached joints |
---|
| 102 | int flags; // some dxBodyFlagXXX flags |
---|
| 103 | dGeomID geom; // first collision geom associated with body |
---|
| 104 | dMass mass; // mass parameters about POR |
---|
| 105 | dMatrix3 invI; // inverse of mass.I |
---|
| 106 | dReal invMass; // 1 / mass.mass |
---|
| 107 | dxPosR posr; // position and orientation of point of reference |
---|
| 108 | dQuaternion q; // orientation quaternion |
---|
| 109 | dVector3 lvel,avel; // linear and angular velocity of POR |
---|
| 110 | dVector3 facc,tacc; // force and torque accumulators |
---|
| 111 | dVector3 finite_rot_axis; // finite rotation axis, unit length or 0=none |
---|
| 112 | |
---|
| 113 | // auto-disable information |
---|
| 114 | dxAutoDisable adis; // auto-disable parameters |
---|
| 115 | dReal adis_timeleft; // time left to be idle |
---|
| 116 | int adis_stepsleft; // steps left to be idle |
---|
| 117 | dVector3* average_lvel_buffer; // buffer for the linear average velocity calculation |
---|
| 118 | dVector3* average_avel_buffer; // buffer for the angular average velocity calculation |
---|
| 119 | unsigned int average_counter; // counter/index to fill the average-buffers |
---|
| 120 | int average_ready; // indicates ( with = 1 ), if the Body's buffers are ready for average-calculations |
---|
| 121 | }; |
---|
| 122 | |
---|
| 123 | |
---|
| 124 | struct dxWorld : public dBase { |
---|
| 125 | dxBody *firstbody; // body linked list |
---|
| 126 | dxJoint *firstjoint; // joint linked list |
---|
| 127 | int nb,nj; // number of bodies and joints in lists |
---|
| 128 | dVector3 gravity; // gravity vector (m/s/s) |
---|
| 129 | dReal global_erp; // global error reduction parameter |
---|
| 130 | dReal global_cfm; // global costraint force mixing parameter |
---|
| 131 | dxAutoDisable adis; // auto-disable parameters |
---|
| 132 | int adis_flag; // auto-disable flag for new bodies |
---|
| 133 | dxQuickStepParameters qs; |
---|
| 134 | dxContactParameters contactp; |
---|
| 135 | }; |
---|
| 136 | |
---|
| 137 | |
---|
| 138 | #endif |
---|