| odecpp.h | | odecpp.h | |
| /************************************************************************* | | /************************************************************************* | |
| * * | | * * | |
|
| * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * | | * Open Dynamics Engine, Copyright (C) 2001, 2002 Russell L. Smith. * | |
| * All rights reserved. Email: russ@q12.org Web: www.q12.org * | | * All rights reserved. Email: russ@q12.org Web: www.q12.org * | |
| * * | | * * | |
| * This library is free software; you can redistribute it and/or * | | * This library is free software; you can redistribute it and/or * | |
| * modify it under the terms of EITHER: * | | * modify it under the terms of EITHER: * | |
| * (1) The GNU Lesser General Public License as published by the Free * | | * (1) The GNU Lesser General Public License as published by the Free * | |
| * Software Foundation; either version 2.1 of the License, or (at * | | * Software Foundation; either version 2.1 of the License, or (at * | |
| * your option) any later version. The text of the GNU Lesser * | | * your option) any later version. The text of the GNU Lesser * | |
| * General Public License is included with this library in the * | | * General Public License is included with this library in the * | |
| * file LICENSE.TXT. * | | * file LICENSE.TXT. * | |
| * (2) The BSD-style license that is included with this library in * | | * (2) The BSD-style license that is included with this library in * | |
| * the file LICENSE-BSD.TXT. * | | * the file LICENSE-BSD.TXT. * | |
| * * | | * * | |
|
| * This library is distributed in the hope that it will be useful, * | | * This library is distributed in the hope that it will be useful, * | |
| * but WITHOUT ANY WARRANTY; without even the implied warranty of * | | * but WITHOUT ANY WARRANTY; without even the implied warranty of * | |
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * | |
| * LICENSE.TXT and LICENSE-BSD.TXT for more details. * | | * LICENSE.TXT and LICENSE-BSD.TXT for more details. * | |
| * * | | * * | |
| *************************************************************************/ | | *************************************************************************/ | |
| | | | |
| /* C++ interface for non-collision stuff */ | | /* C++ interface for non-collision stuff */ | |
| | | | |
| #ifndef _ODE_ODECPP_H_ | | #ifndef _ODE_ODECPP_H_ | |
| #define _ODE_ODECPP_H_ | | #define _ODE_ODECPP_H_ | |
| #ifdef __cplusplus | | #ifdef __cplusplus | |
| | | | |
| //namespace ode { | | //namespace ode { | |
| | | | |
|
| class dWorld { | | class dWorldSimpleIDContainer { | |
| dWorldID _id; | | protected: | |
| | | dWorldID _id; | |
| | | | |
| | | dWorldSimpleIDContainer(): _id(0) {} | |
| | | ~dWorldSimpleIDContainer() { destroy(); } | |
| | | | |
| | | void destroy() { | |
| | | if (_id) { | |
| | | dWorldDestroy(_id); | |
| | | _id = 0; | |
| | | } | |
| | | } | |
| | | }; | |
| | | | |
|
| | | class dWorldDynamicIDContainer: public dWorldSimpleIDContainer { | |
| | | protected: | |
| | | virtual ~dWorldDynamicIDContainer() {} | |
| | | }; | |
| | | | |
| | | template <class dWorldTemplateBase> | |
| | | class dWorldTemplate: public dWorldTemplateBase { | |
| // intentionally undefined, don't use these | | // intentionally undefined, don't use these | |
|
| dWorld (const dWorld &); | | dWorldTemplate (const dWorldTemplate<dWorldTemplateBase> &); | |
| void operator= (const dWorld &); | | void operator= (const dWorldTemplate<dWorldTemplateBase> &); | |
| | | | |
| | | protected: | |
| | | dWorldID get_id() const { return dWorldTemplateBase::_id; } | |
| | | void set_id(dWorldID value) { dWorldTemplateBase::_id = value; } | |
| | | | |
| public: | | public: | |
|
| dWorld() | | dWorldTemplate() | |
| { _id = dWorldCreate(); } | | { set_id(dWorldCreate()); } | |
| ~dWorld() | | | |
| { dWorldDestroy (_id); } | | | |
| | | | |
| dWorldID id() const | | dWorldID id() const | |
|
| { return _id; } | | { return get_id(); } | |
| operator dWorldID() const | | operator dWorldID() const | |
|
| { return _id; } | | { return get_id(); } | |
| | | | |
| void setGravity (dReal x, dReal y, dReal z) | | void setGravity (dReal x, dReal y, dReal z) | |
|
| { dWorldSetGravity (_id,x,y,z); } | | { dWorldSetGravity (get_id(), x, y, z); } | |
| void setGravity (const dVector3 g) | | void setGravity (const dVector3 g) | |
| { setGravity (g[0], g[1], g[2]); } | | { setGravity (g[0], g[1], g[2]); } | |
| void getGravity (dVector3 g) const | | void getGravity (dVector3 g) const | |
|
| { dWorldGetGravity (_id,g); } | | { dWorldGetGravity (get_id(), g); } | |
| | | | |
| void setERP (dReal erp) | | void setERP (dReal erp) | |
|
| { dWorldSetERP(_id, erp); } | | { dWorldSetERP(get_id(), erp); } | |
| dReal getERP() const | | dReal getERP() const | |
|
| { return dWorldGetERP(_id); } | | { return dWorldGetERP(get_id()); } | |
| | | | |
| void setCFM (dReal cfm) | | void setCFM (dReal cfm) | |
|
| { dWorldSetCFM(_id, cfm); } | | { dWorldSetCFM(get_id(), cfm); } | |
| dReal getCFM() const | | dReal getCFM() const | |
|
| { return dWorldGetCFM(_id); } | | { return dWorldGetCFM(get_id()); } | |
| | | | |
| void step (dReal stepsize) | | void step (dReal stepsize) | |
|
| { dWorldStep (_id,stepsize); } | | { dWorldStep (get_id(), stepsize); } | |
| | | | |
| void stepFast1 (dReal stepsize, int maxiterations) | | | |
| { dWorldStepFast1 (_id,stepsize,maxiterations); } | | | |
| void setAutoEnableDepthSF1(int depth) | | | |
| { dWorldSetAutoEnableDepthSF1 (_id, depth); } | | | |
| int getAutoEnableDepthSF1() const | | | |
| { return dWorldGetAutoEnableDepthSF1 (_id); } | | | |
| | | | |
| void quickStep(dReal stepsize) | | void quickStep(dReal stepsize) | |
|
| { dWorldQuickStep (_id, stepsize); } | | { dWorldQuickStep (get_id(), stepsize); } | |
| void setQuickStepNumIterations(int num) | | void setQuickStepNumIterations(int num) | |
|
| { dWorldSetQuickStepNumIterations (_id, num); } | | { dWorldSetQuickStepNumIterations (get_id(), num); } | |
| int getQuickStepNumIterations() const | | int getQuickStepNumIterations() const | |
|
| { return dWorldGetQuickStepNumIterations (_id); } | | { return dWorldGetQuickStepNumIterations (get_id()); } | |
| void setQuickStepW(dReal over_relaxation) | | void setQuickStepW(dReal over_relaxation) | |
|
| { dWorldSetQuickStepW (_id, over_relaxation); } | | { dWorldSetQuickStepW (get_id(), over_relaxation); } | |
| dReal getQuickStepW() const | | dReal getQuickStepW() const | |
|
| { return dWorldGetQuickStepW (_id); } | | { return dWorldGetQuickStepW (get_id()); } | |
| | | | |
| void setAutoDisableLinearThreshold (dReal threshold) | | void setAutoDisableLinearThreshold (dReal threshold) | |
|
| { dWorldSetAutoDisableLinearThreshold (_id,threshold); } | | { dWorldSetAutoDisableLinearThreshold (get_id(), threshold); } | |
| dReal getAutoDisableLinearThreshold() const | | dReal getAutoDisableLinearThreshold() const | |
|
| { return dWorldGetAutoDisableLinearThreshold (_id); } | | { return dWorldGetAutoDisableLinearThreshold (get_id()); } | |
| void setAutoDisableAngularThreshold (dReal threshold) | | void setAutoDisableAngularThreshold (dReal threshold) | |
|
| { dWorldSetAutoDisableAngularThreshold (_id,threshold); } | | { dWorldSetAutoDisableAngularThreshold (get_id(), threshold); } | |
| dReal getAutoDisableAngularThreshold() const | | dReal getAutoDisableAngularThreshold() const | |
|
| { return dWorldGetAutoDisableAngularThreshold (_id); } | | { return dWorldGetAutoDisableAngularThreshold (get_id()); } | |
| void setAutoDisableSteps (int steps) | | void setAutoDisableSteps (int steps) | |
|
| { dWorldSetAutoDisableSteps (_id,steps); } | | { dWorldSetAutoDisableSteps (get_id(), steps); } | |
| int getAutoDisableSteps() const | | int getAutoDisableSteps() const | |
|
| { return dWorldGetAutoDisableSteps (_id); } | | { return dWorldGetAutoDisableSteps (get_id()); } | |
| void setAutoDisableTime (dReal time) | | void setAutoDisableTime (dReal time) | |
|
| { dWorldSetAutoDisableTime (_id,time); } | | { dWorldSetAutoDisableTime (get_id(), time); } | |
| dReal getAutoDisableTime() const | | dReal getAutoDisableTime() const | |
|
| { return dWorldGetAutoDisableTime (_id); } | | { return dWorldGetAutoDisableTime (get_id()); } | |
| void setAutoDisableFlag (int do_auto_disable) | | void setAutoDisableFlag (int do_auto_disable) | |
|
| { dWorldSetAutoDisableFlag (_id,do_auto_disable); } | | { dWorldSetAutoDisableFlag (get_id(), do_auto_disable); } | |
| int getAutoDisableFlag() const | | int getAutoDisableFlag() const | |
|
| { return dWorldGetAutoDisableFlag (_id); } | | { return dWorldGetAutoDisableFlag (get_id()); } | |
| | | | |
| dReal getLinearDampingThreshold() const | | dReal getLinearDampingThreshold() const | |
|
| { return dWorldGetLinearDampingThreshold(_id); } | | { return dWorldGetLinearDampingThreshold(get_id()); } | |
| void setLinearDampingThreshold(dReal threshold) | | void setLinearDampingThreshold(dReal threshold) | |
|
| { dWorldSetLinearDampingThreshold(_id, threshold); } | | { dWorldSetLinearDampingThreshold(get_id(), threshold); } | |
| dReal getAngularDampingThreshold() const | | dReal getAngularDampingThreshold() const | |
|
| { return dWorldGetAngularDampingThreshold(_id); } | | { return dWorldGetAngularDampingThreshold(get_id()); } | |
| void setAngularDampingThreshold(dReal threshold) | | void setAngularDampingThreshold(dReal threshold) | |
|
| { dWorldSetAngularDampingThreshold(_id, threshold); } | | { dWorldSetAngularDampingThreshold(get_id(), threshold); } | |
| dReal getLinearDamping() const | | dReal getLinearDamping() const | |
|
| { return dWorldGetLinearDamping(_id); } | | { return dWorldGetLinearDamping(get_id()); } | |
| void setLinearDamping(dReal scale) | | void setLinearDamping(dReal scale) | |
|
| { dWorldSetLinearDamping(_id, scale); } | | { dWorldSetLinearDamping(get_id(), scale); } | |
| dReal getAngularDamping() const | | dReal getAngularDamping() const | |
|
| { return dWorldGetAngularDamping(_id); } | | { return dWorldGetAngularDamping(get_id()); } | |
| void setAngularDamping(dReal scale) | | void setAngularDamping(dReal scale) | |
|
| { dWorldSetAngularDamping(_id, scale); } | | { dWorldSetAngularDamping(get_id(), scale); } | |
| void setDamping(dReal linear_scale, dReal angular_scale) | | void setDamping(dReal linear_scale, dReal angular_scale) | |
|
| { dWorldSetDamping(_id, linear_scale, angular_scale); } | | { dWorldSetDamping(get_id(), linear_scale, angular_scale); } | |
| | | | |
| dReal getMaxAngularSpeed() const | | dReal getMaxAngularSpeed() const | |
|
| { return dWorldGetMaxAngularSpeed(_id); } | | { return dWorldGetMaxAngularSpeed(get_id()); } | |
| void setMaxAngularSpeed(dReal max_speed) | | void setMaxAngularSpeed(dReal max_speed) | |
|
| { dWorldSetMaxAngularSpeed(_id, max_speed); } | | { dWorldSetMaxAngularSpeed(get_id(), max_speed); } | |
| | | | |
| void setContactSurfaceLayer(dReal depth) | | void setContactSurfaceLayer(dReal depth) | |
|
| { dWorldSetContactSurfaceLayer (_id, depth); } | | { dWorldSetContactSurfaceLayer (get_id(), depth); } | |
| dReal getContactSurfaceLayer() const | | dReal getContactSurfaceLayer() const | |
|
| { return dWorldGetContactSurfaceLayer (_id); } | | { return dWorldGetContactSurfaceLayer (get_id()); } | |
| | | | |
| void impulseToForce (dReal stepsize, dReal ix, dReal iy, dReal iz, | | void impulseToForce (dReal stepsize, dReal ix, dReal iy, dReal iz, | |
| dVector3 force) | | dVector3 force) | |
|
| { dWorldImpulseToForce (_id,stepsize,ix,iy,iz,force); } | | { dWorldImpulseToForce (get_id(), stepsize, ix, iy, iz, force); } | |
| | | }; | |
| | | | |
| | | class dBodySimpleIDContainer { | |
| | | protected: | |
| | | dBodyID _id; | |
| | | | |
| | | dBodySimpleIDContainer(): _id(0) {} | |
| | | ~dBodySimpleIDContainer() { destroy(); } | |
| | | | |
| | | void destroy() { | |
| | | if (_id) { | |
| | | dBodyDestroy(_id); | |
| | | _id = 0; | |
| | | } | |
| | | } | |
| }; | | }; | |
| | | | |
|
| class dBody { | | class dBodyDynamicIDContainer: public dBodySimpleIDContainer { | |
| dBodyID _id; | | protected: | |
| | | virtual ~dBodyDynamicIDContainer() {} | |
| | | }; | |
| | | | |
| | | template <class dBodyTemplateBase, class dWorldTemplateBase> | |
| | | class dBodyTemplate: public dBodyTemplateBase { | |
| // intentionally undefined, don't use these | | // intentionally undefined, don't use these | |
|
| dBody (const dBody &); | | dBodyTemplate (const dBodyTemplate<dBodyTemplateBase, dWorldTemplateBase> | |
| void operator= (const dBody &); | | &); | |
| | | void operator= (const dBodyTemplate<dBodyTemplateBase, dWorldTemplateBase | |
| | | > &); | |
| | | | |
| | | protected: | |
| | | dBodyID get_id() const { return dBodyTemplateBase::_id; } | |
| | | void set_id(dBodyID value) { dBodyTemplateBase::_id = value; } | |
| | | | |
| | | void destroy() { dBodyTemplateBase::destroy(); } | |
| | | | |
| public: | | public: | |
|
| dBody() | | dBodyTemplate() | |
| { _id = 0; } | | { } | |
| dBody (dWorldID world) | | dBodyTemplate (dWorldID world) | |
| { _id = dBodyCreate (world); } | | { set_id(dBodyCreate(world)); } | |
| dBody (dWorld& world) | | dBodyTemplate (dWorldTemplate<dWorldTemplateBase>& world) | |
| { _id = dBodyCreate (world.id()); } | | { set_id(dBodyCreate(world.id())); } | |
| ~dBody() | | | |
| { if (_id) dBodyDestroy (_id); } | | | |
| | | | |
| void create (dWorldID world) { | | void create (dWorldID world) { | |
|
| if (_id) dBodyDestroy (_id); | | destroy(); | |
| _id = dBodyCreate (world); | | set_id(dBodyCreate(world)); | |
| } | | } | |
|
| void create (dWorld& world) { | | void create (dWorldTemplate<dWorldTemplateBase>& world) { | |
| create(world.id()); | | create(world.id()); | |
| } | | } | |
| | | | |
| dBodyID id() const | | dBodyID id() const | |
|
| { return _id; } | | { return get_id(); } | |
| operator dBodyID() const | | operator dBodyID() const | |
|
| { return _id; } | | { return get_id(); } | |
| | | | |
| void setData (void *data) | | void setData (void *data) | |
|
| { dBodySetData (_id,data); } | | { dBodySetData (get_id(), data); } | |
| void *getData() const | | void *getData() const | |
|
| { return dBodyGetData (_id); } | | { return dBodyGetData (get_id()); } | |
| | | | |
| void setPosition (dReal x, dReal y, dReal z) | | void setPosition (dReal x, dReal y, dReal z) | |
|
| { dBodySetPosition (_id,x,y,z); } | | { dBodySetPosition (get_id(), x, y, z); } | |
| void setPosition (const dVector3 p) | | void setPosition (const dVector3 p) | |
| { setPosition(p[0], p[1], p[2]); } | | { setPosition(p[0], p[1], p[2]); } | |
| | | | |
| void setRotation (const dMatrix3 R) | | void setRotation (const dMatrix3 R) | |
|
| { dBodySetRotation (_id,R); } | | { dBodySetRotation (get_id(), R); } | |
| void setQuaternion (const dQuaternion q) | | void setQuaternion (const dQuaternion q) | |
|
| { dBodySetQuaternion (_id,q); } | | { dBodySetQuaternion (get_id(), q); } | |
| void setLinearVel (dReal x, dReal y, dReal z) | | void setLinearVel (dReal x, dReal y, dReal z) | |
|
| { dBodySetLinearVel (_id,x,y,z); } | | { dBodySetLinearVel (get_id(), x, y, z); } | |
| void setLinearVel (const dVector3 v) | | void setLinearVel (const dVector3 v) | |
| { setLinearVel(v[0], v[1], v[2]); } | | { setLinearVel(v[0], v[1], v[2]); } | |
| void setAngularVel (dReal x, dReal y, dReal z) | | void setAngularVel (dReal x, dReal y, dReal z) | |
|
| { dBodySetAngularVel (_id,x,y,z); } | | { dBodySetAngularVel (get_id(), x, y, z); } | |
| void setAngularVel (const dVector3 v) | | void setAngularVel (const dVector3 v) | |
| { setAngularVel (v[0], v[1], v[2]); } | | { setAngularVel (v[0], v[1], v[2]); } | |
| | | | |
| const dReal * getPosition() const | | const dReal * getPosition() const | |
|
| { return dBodyGetPosition (_id); } | | { return dBodyGetPosition (get_id()); } | |
| const dReal * getRotation() const | | const dReal * getRotation() const | |
|
| { return dBodyGetRotation (_id); } | | { return dBodyGetRotation (get_id()); } | |
| const dReal * getQuaternion() const | | const dReal * getQuaternion() const | |
|
| { return dBodyGetQuaternion (_id); } | | { return dBodyGetQuaternion (get_id()); } | |
| const dReal * getLinearVel() const | | const dReal * getLinearVel() const | |
|
| { return dBodyGetLinearVel (_id); } | | { return dBodyGetLinearVel (get_id()); } | |
| const dReal * getAngularVel() const | | const dReal * getAngularVel() const | |
|
| { return dBodyGetAngularVel (_id); } | | { return dBodyGetAngularVel (get_id()); } | |
| | | | |
| void setMass (const dMass *mass) | | void setMass (const dMass *mass) | |
|
| { dBodySetMass (_id,mass); } | | { dBodySetMass (get_id(), mass); } | |
| void setMass (const dMass &mass) | | void setMass (const dMass &mass) | |
| { setMass (&mass); } | | { setMass (&mass); } | |
| dMass getMass () const | | dMass getMass () const | |
|
| { dMass mass; dBodyGetMass (_id,&mass); return mass; } | | { dMass mass; dBodyGetMass (get_id(), &mass); return mass; } | |
| | | | |
| void addForce (dReal fx, dReal fy, dReal fz) | | void addForce (dReal fx, dReal fy, dReal fz) | |
|
| { dBodyAddForce (_id, fx, fy, fz); } | | { dBodyAddForce (get_id(), fx, fy, fz); } | |
| void addForce (const dVector3 f) | | void addForce (const dVector3 f) | |
| { addForce (f[0], f[1], f[2]); } | | { addForce (f[0], f[1], f[2]); } | |
| void addTorque (dReal fx, dReal fy, dReal fz) | | void addTorque (dReal fx, dReal fy, dReal fz) | |
|
| { dBodyAddTorque (_id, fx, fy, fz); } | | { dBodyAddTorque (get_id(), fx, fy, fz); } | |
| void addTorque (const dVector3 t) | | void addTorque (const dVector3 t) | |
| { addTorque(t[0], t[1], t[2]); } | | { addTorque(t[0], t[1], t[2]); } | |
| | | | |
| void addRelForce (dReal fx, dReal fy, dReal fz) | | void addRelForce (dReal fx, dReal fy, dReal fz) | |
|
| { dBodyAddRelForce (_id, fx, fy, fz); } | | { dBodyAddRelForce (get_id(), fx, fy, fz); } | |
| void addRelForce (const dVector3 f) | | void addRelForce (const dVector3 f) | |
| { addRelForce (f[0], f[1], f[2]); } | | { addRelForce (f[0], f[1], f[2]); } | |
| void addRelTorque (dReal fx, dReal fy, dReal fz) | | void addRelTorque (dReal fx, dReal fy, dReal fz) | |
|
| { dBodyAddRelTorque (_id, fx, fy, fz); } | | { dBodyAddRelTorque (get_id(), fx, fy, fz); } | |
| void addRelTorque (const dVector3 t) | | void addRelTorque (const dVector3 t) | |
| { addRelTorque (t[0], t[1], t[2]); } | | { addRelTorque (t[0], t[1], t[2]); } | |
| | | | |
| void addForceAtPos (dReal fx, dReal fy, dReal fz, | | void addForceAtPos (dReal fx, dReal fy, dReal fz, | |
| dReal px, dReal py, dReal pz) | | dReal px, dReal py, dReal pz) | |
|
| { dBodyAddForceAtPos (_id, fx, fy, fz, px, py, pz); } | | { dBodyAddForceAtPos (get_id(), fx, fy, fz, px, py, pz); } | |
| void addForceAtPos (const dVector3 f, const dVector3 p) | | void addForceAtPos (const dVector3 f, const dVector3 p) | |
| { addForceAtPos (f[0], f[1], f[2], p[0], p[1], p[2]); } | | { addForceAtPos (f[0], f[1], f[2], p[0], p[1], p[2]); } | |
| | | | |
| void addForceAtRelPos (dReal fx, dReal fy, dReal fz, | | void addForceAtRelPos (dReal fx, dReal fy, dReal fz, | |
| dReal px, dReal py, dReal pz) | | dReal px, dReal py, dReal pz) | |
|
| { dBodyAddForceAtRelPos (_id, fx, fy, fz, px, py, pz); } | | { dBodyAddForceAtRelPos (get_id(), fx, fy, fz, px, py, pz); } | |
| void addForceAtRelPos (const dVector3 f, const dVector3 p) | | void addForceAtRelPos (const dVector3 f, const dVector3 p) | |
| { addForceAtRelPos (f[0], f[1], f[2], p[0], p[1], p[2]); } | | { addForceAtRelPos (f[0], f[1], f[2], p[0], p[1], p[2]); } | |
| | | | |
| void addRelForceAtPos (dReal fx, dReal fy, dReal fz, | | void addRelForceAtPos (dReal fx, dReal fy, dReal fz, | |
| dReal px, dReal py, dReal pz) | | dReal px, dReal py, dReal pz) | |
|
| { dBodyAddRelForceAtPos (_id, fx, fy, fz, px, py, pz); } | | { dBodyAddRelForceAtPos (get_id(), fx, fy, fz, px, py, pz); } | |
| void addRelForceAtPos (const dVector3 f, const dVector3 p) | | void addRelForceAtPos (const dVector3 f, const dVector3 p) | |
| { addRelForceAtPos (f[0], f[1], f[2], p[0], p[1], p[2]); } | | { addRelForceAtPos (f[0], f[1], f[2], p[0], p[1], p[2]); } | |
| | | | |
| void addRelForceAtRelPos (dReal fx, dReal fy, dReal fz, | | void addRelForceAtRelPos (dReal fx, dReal fy, dReal fz, | |
| dReal px, dReal py, dReal pz) | | dReal px, dReal py, dReal pz) | |
|
| { dBodyAddRelForceAtRelPos (_id, fx, fy, fz, px, py, pz); } | | { dBodyAddRelForceAtRelPos (get_id(), fx, fy, fz, px, py, pz); } | |
| void addRelForceAtRelPos (const dVector3 f, const dVector3 p) | | void addRelForceAtRelPos (const dVector3 f, const dVector3 p) | |
| { addRelForceAtRelPos (f[0], f[1], f[2], p[0], p[1], p[2]); } | | { addRelForceAtRelPos (f[0], f[1], f[2], p[0], p[1], p[2]); } | |
| | | | |
| const dReal * getForce() const | | const dReal * getForce() const | |
|
| { return dBodyGetForce(_id); } | | { return dBodyGetForce(get_id()); } | |
| const dReal * getTorque() const | | const dReal * getTorque() const | |
|
| { return dBodyGetTorque(_id); } | | { return dBodyGetTorque(get_id()); } | |
| void setForce (dReal x, dReal y, dReal z) | | void setForce (dReal x, dReal y, dReal z) | |
|
| { dBodySetForce (_id,x,y,z); } | | { dBodySetForce (get_id(), x, y, z); } | |
| void setForce (const dVector3 f) | | void setForce (const dVector3 f) | |
| { setForce (f[0], f[1], f[2]); } | | { setForce (f[0], f[1], f[2]); } | |
| void setTorque (dReal x, dReal y, dReal z) | | void setTorque (dReal x, dReal y, dReal z) | |
|
| { dBodySetTorque (_id,x,y,z); } | | { dBodySetTorque (get_id(), x, y, z); } | |
| void setTorque (const dVector3 t) | | void setTorque (const dVector3 t) | |
| { setTorque (t[0], t[1], t[2]); } | | { setTorque (t[0], t[1], t[2]); } | |
| | | | |
| void setDynamic() | | void setDynamic() | |
|
| { dBodySetDynamic (_id); } | | { dBodySetDynamic (get_id()); } | |
| void setKinematic() | | void setKinematic() | |
|
| { dBodySetKinematic (_id); } | | { dBodySetKinematic (get_id()); } | |
| bool isKinematic() const | | bool isKinematic() const | |
|
| { return dBodyIsKinematic (_id) != 0; } | | { return dBodyIsKinematic (get_id()) != 0; } | |
| | | | |
| void enable() | | void enable() | |
|
| { dBodyEnable (_id); } | | { dBodyEnable (get_id()); } | |
| void disable() | | void disable() | |
|
| { dBodyDisable (_id); } | | { dBodyDisable (get_id()); } | |
| bool isEnabled() const | | bool isEnabled() const | |
|
| { return dBodyIsEnabled (_id) != 0; } | | { return dBodyIsEnabled (get_id()) != 0; } | |
| | | | |
| void getRelPointPos (dReal px, dReal py, dReal pz, dVector3 result) const | | void getRelPointPos (dReal px, dReal py, dReal pz, dVector3 result) const | |
|
| { dBodyGetRelPointPos (_id, px, py, pz, result); } | | { dBodyGetRelPointPos (get_id(), px, py, pz, result); } | |
| void getRelPointPos (const dVector3 p, dVector3 result) const | | void getRelPointPos (const dVector3 p, dVector3 result) const | |
| { getRelPointPos (p[0], p[1], p[2], result); } | | { getRelPointPos (p[0], p[1], p[2], result); } | |
| | | | |
| void getRelPointVel (dReal px, dReal py, dReal pz, dVector3 result) const | | void getRelPointVel (dReal px, dReal py, dReal pz, dVector3 result) const | |
|
| { dBodyGetRelPointVel (_id, px, py, pz, result); } | | { dBodyGetRelPointVel (get_id(), px, py, pz, result); } | |
| void getRelPointVel (const dVector3 p, dVector3 result) const | | void getRelPointVel (const dVector3 p, dVector3 result) const | |
| { getRelPointVel (p[0], p[1], p[2], result); } | | { getRelPointVel (p[0], p[1], p[2], result); } | |
| | | | |
| void getPointVel (dReal px, dReal py, dReal pz, dVector3 result) const | | void getPointVel (dReal px, dReal py, dReal pz, dVector3 result) const | |
|
| { dBodyGetPointVel (_id, px, py, pz, result); } | | { dBodyGetPointVel (get_id(), px, py, pz, result); } | |
| void getPointVel (const dVector3 p, dVector3 result) const | | void getPointVel (const dVector3 p, dVector3 result) const | |
| { getPointVel (p[0], p[1], p[2], result); } | | { getPointVel (p[0], p[1], p[2], result); } | |
| | | | |
| void getPosRelPoint (dReal px, dReal py, dReal pz, dVector3 result) const | | void getPosRelPoint (dReal px, dReal py, dReal pz, dVector3 result) const | |
|
| { dBodyGetPosRelPoint (_id, px, py, pz, result); } | | { dBodyGetPosRelPoint (get_id(), px, py, pz, result); } | |
| void getPosRelPoint (const dVector3 p, dVector3 result) const | | void getPosRelPoint (const dVector3 p, dVector3 result) const | |
| { getPosRelPoint (p[0], p[1], p[2], result); } | | { getPosRelPoint (p[0], p[1], p[2], result); } | |
| | | | |
| void vectorToWorld (dReal px, dReal py, dReal pz, dVector3 result) const | | void vectorToWorld (dReal px, dReal py, dReal pz, dVector3 result) const | |
|
| { dBodyVectorToWorld (_id, px, py, pz, result); } | | { dBodyVectorToWorld (get_id(), px, py, pz, result); } | |
| void vectorToWorld (const dVector3 p, dVector3 result) const | | void vectorToWorld (const dVector3 p, dVector3 result) const | |
| { vectorToWorld (p[0], p[1], p[2], result); } | | { vectorToWorld (p[0], p[1], p[2], result); } | |
| | | | |
| void vectorFromWorld (dReal px, dReal py, dReal pz, dVector3 result) cons
t | | void vectorFromWorld (dReal px, dReal py, dReal pz, dVector3 result) cons
t | |
|
| { dBodyVectorFromWorld (_id,px,py,pz,result); } | | { dBodyVectorFromWorld (get_id(), px, py, pz, result); } | |
| void vectorFromWorld (const dVector3 p, dVector3 result) const | | void vectorFromWorld (const dVector3 p, dVector3 result) const | |
| { vectorFromWorld (p[0], p[1], p[2], result); } | | { vectorFromWorld (p[0], p[1], p[2], result); } | |
| | | | |
| void setFiniteRotationMode (bool mode) | | void setFiniteRotationMode (bool mode) | |
|
| { dBodySetFiniteRotationMode (_id, mode); } | | { dBodySetFiniteRotationMode (get_id(), mode); } | |
| | | | |
| void setFiniteRotationAxis (dReal x, dReal y, dReal z) | | void setFiniteRotationAxis (dReal x, dReal y, dReal z) | |
|
| { dBodySetFiniteRotationAxis (_id, x, y, z); } | | { dBodySetFiniteRotationAxis (get_id(), x, y, z); } | |
| void setFiniteRotationAxis (const dVector3 a) | | void setFiniteRotationAxis (const dVector3 a) | |
| { setFiniteRotationAxis (a[0], a[1], a[2]); } | | { setFiniteRotationAxis (a[0], a[1], a[2]); } | |
| | | | |
| bool getFiniteRotationMode() const | | bool getFiniteRotationMode() const | |
|
| { return dBodyGetFiniteRotationMode (_id) != 0; } | | { return dBodyGetFiniteRotationMode (get_id()) != 0; } | |
| void getFiniteRotationAxis (dVector3 result) const | | void getFiniteRotationAxis (dVector3 result) const | |
|
| { dBodyGetFiniteRotationAxis (_id, result); } | | { dBodyGetFiniteRotationAxis (get_id(), result); } | |
| | | | |
| int getNumJoints() const | | int getNumJoints() const | |
|
| { return dBodyGetNumJoints (_id); } | | { return dBodyGetNumJoints (get_id()); } | |
| dJointID getJoint (int index) const | | dJointID getJoint (int index) const | |
|
| { return dBodyGetJoint (_id, index); } | | { return dBodyGetJoint (get_id(), index); } | |
| | | | |
| void setGravityMode (bool mode) | | void setGravityMode (bool mode) | |
|
| { dBodySetGravityMode (_id,mode); } | | { dBodySetGravityMode (get_id(), mode); } | |
| bool getGravityMode() const | | bool getGravityMode() const | |
|
| { return dBodyGetGravityMode (_id) != 0; } | | { return dBodyGetGravityMode (get_id()) != 0; } | |
| | | | |
| bool isConnectedTo (dBodyID body) const | | bool isConnectedTo (dBodyID body) const | |
|
| { return dAreConnected (_id, body) != 0; } | | { return dAreConnected (get_id(), body) != 0; } | |
| | | | |
| void setAutoDisableLinearThreshold (dReal threshold) | | void setAutoDisableLinearThreshold (dReal threshold) | |
|
| { dBodySetAutoDisableLinearThreshold (_id,threshold); } | | { dBodySetAutoDisableLinearThreshold (get_id(), threshold); } | |
| dReal getAutoDisableLinearThreshold() const | | dReal getAutoDisableLinearThreshold() const | |
|
| { return dBodyGetAutoDisableLinearThreshold (_id); } | | { return dBodyGetAutoDisableLinearThreshold (get_id()); } | |
| void setAutoDisableAngularThreshold (dReal threshold) | | void setAutoDisableAngularThreshold (dReal threshold) | |
|
| { dBodySetAutoDisableAngularThreshold (_id,threshold); } | | { dBodySetAutoDisableAngularThreshold (get_id(), threshold); } | |
| dReal getAutoDisableAngularThreshold() const | | dReal getAutoDisableAngularThreshold() const | |
|
| { return dBodyGetAutoDisableAngularThreshold (_id); } | | { return dBodyGetAutoDisableAngularThreshold (get_id()); } | |
| void setAutoDisableSteps (int steps) | | void setAutoDisableSteps (int steps) | |
|
| { dBodySetAutoDisableSteps (_id,steps); } | | { dBodySetAutoDisableSteps (get_id(), steps); } | |
| int getAutoDisableSteps() const | | int getAutoDisableSteps() const | |
|
| { return dBodyGetAutoDisableSteps (_id); } | | { return dBodyGetAutoDisableSteps (get_id()); } | |
| void setAutoDisableTime (dReal time) | | void setAutoDisableTime (dReal time) | |
|
| { dBodySetAutoDisableTime (_id,time); } | | { dBodySetAutoDisableTime (get_id(), time); } | |
| dReal getAutoDisableTime() const | | dReal getAutoDisableTime() const | |
|
| { return dBodyGetAutoDisableTime (_id); } | | { return dBodyGetAutoDisableTime (get_id()); } | |
| void setAutoDisableFlag (bool do_auto_disable) | | void setAutoDisableFlag (bool do_auto_disable) | |
|
| { dBodySetAutoDisableFlag (_id,do_auto_disable); } | | { dBodySetAutoDisableFlag (get_id(), do_auto_disable); } | |
| bool getAutoDisableFlag() const | | bool getAutoDisableFlag() const | |
|
| { return dBodyGetAutoDisableFlag (_id) != 0; } | | { return dBodyGetAutoDisableFlag (get_id()) != 0; } | |
| | | | |
| dReal getLinearDamping() const | | dReal getLinearDamping() const | |
|
| { return dBodyGetLinearDamping(_id); } | | { return dBodyGetLinearDamping(get_id()); } | |
| void setLinearDamping(dReal scale) | | void setLinearDamping(dReal scale) | |
|
| { dBodySetLinearDamping(_id, scale); } | | { dBodySetLinearDamping(get_id(), scale); } | |
| dReal getAngularDamping() const | | dReal getAngularDamping() const | |
|
| { return dBodyGetAngularDamping(_id); } | | { return dBodyGetAngularDamping(get_id()); } | |
| void setAngularDamping(dReal scale) | | void setAngularDamping(dReal scale) | |
|
| { dBodySetAngularDamping(_id, scale); } | | { dBodySetAngularDamping(get_id(), scale); } | |
| void setDamping(dReal linear_scale, dReal angular_scale) | | void setDamping(dReal linear_scale, dReal angular_scale) | |
|
| { dBodySetDamping(_id, linear_scale, angular_scale); } | | { dBodySetDamping(get_id(), linear_scale, angular_scale); } | |
| dReal getLinearDampingThreshold() const | | dReal getLinearDampingThreshold() const | |
|
| { return dBodyGetLinearDampingThreshold(_id); } | | { return dBodyGetLinearDampingThreshold(get_id()); } | |
| void setLinearDampingThreshold(dReal threshold) const | | void setLinearDampingThreshold(dReal threshold) const | |
|
| { dBodySetLinearDampingThreshold(_id, threshold); } | | { dBodySetLinearDampingThreshold(get_id(), threshold); } | |
| dReal getAngularDampingThreshold() const | | dReal getAngularDampingThreshold() const | |
|
| { return dBodyGetAngularDampingThreshold(_id); } | | { return dBodyGetAngularDampingThreshold(get_id()); } | |
| void setAngularDampingThreshold(dReal threshold) | | void setAngularDampingThreshold(dReal threshold) | |
|
| { dBodySetAngularDampingThreshold(_id, threshold); } | | { dBodySetAngularDampingThreshold(get_id(), threshold); } | |
| void setDampingDefaults() | | void setDampingDefaults() | |
|
| { dBodySetDampingDefaults(_id); } | | { dBodySetDampingDefaults(get_id()); } | |
| | | | |
| dReal getMaxAngularSpeed() const | | dReal getMaxAngularSpeed() const | |
|
| { return dBodyGetMaxAngularSpeed(_id); } | | { return dBodyGetMaxAngularSpeed(get_id()); } | |
| void setMaxAngularSpeed(dReal max_speed) | | void setMaxAngularSpeed(dReal max_speed) | |
|
| { dBodySetMaxAngularSpeed(_id, max_speed); } | | { dBodySetMaxAngularSpeed(get_id(), max_speed); } | |
| | | | |
| bool getGyroscopicMode() const | | bool getGyroscopicMode() const | |
|
| { return dBodyGetGyroscopicMode(_id) != 0; } | | { return dBodyGetGyroscopicMode(get_id()) != 0; } | |
| void setGyroscopicMode(bool mode) | | void setGyroscopicMode(bool mode) | |
|
| { dBodySetGyroscopicMode(_id, mode); } | | { dBodySetGyroscopicMode(get_id(), mode); } | |
| | | | |
| }; | | }; | |
| | | | |
|
| class dJointGroup { | | class dJointGroupSimpleIDContainer { | |
| dJointGroupID _id; | | protected: | |
| | | dJointGroupID _id; | |
| | | | |
| | | dJointGroupSimpleIDContainer(): _id(0) {} | |
| | | ~dJointGroupSimpleIDContainer() { destroy(); } | |
| | | | |
|
| | | void destroy() { | |
| | | if (_id) { | |
| | | dJointGroupDestroy(_id); | |
| | | _id = 0; | |
| | | } | |
| | | } | |
| | | }; | |
| | | | |
| | | class dJointGroupDynamicIDContainer: public dJointGroupSimpleIDContainer { | |
| | | protected: | |
| | | virtual ~dJointGroupDynamicIDContainer() {} | |
| | | }; | |
| | | | |
| | | template <class dJointGroupTemplateBase> | |
| | | class dJointGroupTemplate: public dJointGroupTemplateBase { | |
| // intentionally undefined, don't use these | | // intentionally undefined, don't use these | |
|
| dJointGroup (const dJointGroup &); | | dJointGroupTemplate (const dJointGroupTemplate<dJointGroupTemplateBase> & | |
| void operator= (const dJointGroup &); | | ); | |
| | | void operator= (const dJointGroupTemplate<dJointGroupTemplateBase> &); | |
| | | | |
| | | protected: | |
| | | dJointGroupID get_id() const { return dJointGroupTemplateBase::_id; } | |
| | | void set_id(dJointGroupID value) { dJointGroupTemplateBase::_id = value; | |
| | | } | |
| | | | |
| | | void destroy() { dJointGroupTemplateBase::destroy(); } | |
| | | | |
| public: | | public: | |
|
| dJointGroup () | | dJointGroupTemplate () | |
| { _id = dJointGroupCreate (0); } | | { set_id(dJointGroupCreate(0)); } | |
| ~dJointGroup() | | | |
| { dJointGroupDestroy (_id); } | | | |
| void create () { | | void create () { | |
|
| if (_id) dJointGroupDestroy (_id); | | destroy(); | |
| _id = dJointGroupCreate (0); | | set_id(dJointGroupCreate(0)); | |
| } | | } | |
| | | | |
| dJointGroupID id() const | | dJointGroupID id() const | |
|
| { return _id; } | | { return get_id(); } | |
| operator dJointGroupID() const | | operator dJointGroupID() const | |
|
| { return _id; } | | { return get_id(); } | |
| | | | |
| void empty() | | void empty() | |
|
| { dJointGroupEmpty (_id); } | | { dJointGroupEmpty (get_id()); } | |
| void clear() | | void clear() | |
| { empty(); } | | { empty(); } | |
| }; | | }; | |
| | | | |
|
| class dJoint { | | class dJointSimpleIDContainer { | |
| | | protected: | |
| | | dJointID _id; | |
| | | | |
| | | dJointSimpleIDContainer(): _id(0) {} | |
| | | ~dJointSimpleIDContainer() { destroy(); } | |
| | | | |
| | | void destroy() { | |
| | | if (_id) { | |
| | | dJointDestroy (_id); | |
| | | _id = 0; | |
| | | } | |
| | | } | |
| | | }; | |
| | | | |
| | | class dJointDynamicIDContainer: public dJointSimpleIDContainer { | |
| | | protected: | |
| | | virtual ~dJointDynamicIDContainer() {} | |
| | | }; | |
| | | | |
| | | template <class dJointTemplateBase, class dWorldTemplateBase, class dBodyTe | |
| | | mplateBase> | |
| | | class dJointTemplate: public dJointTemplateBase { | |
| private: | | private: | |
| // intentionally undefined, don't use these | | // intentionally undefined, don't use these | |
|
| dJoint (const dJoint &) ; | | dJointTemplate (const dJointTemplate<dJointTemplateBase, dWorldTemplateBa | |
| void operator= (const dJoint &); | | se, dBodyTemplateBase> &) ; | |
| | | void operator= (const dJointTemplate<dJointTemplateBase, dWorldTemplateBa | |
| | | se, dBodyTemplateBase> &); | |
| | | | |
| protected: | | protected: | |
|
| dJointID _id; | | dJointID get_id() const { return dJointTemplateBase::_id; } | |
| | | void set_id(dJointID value) { dJointTemplateBase::_id = value; } | |
| | | | |
|
| dJoint() // don't let user construct pure dJoint objects | | void destroy() { dJointTemplateBase::destroy(); } | |
| { _id = 0; } | | | |
| | | | |
|
| public: | | protected: | |
| virtual ~dJoint() // :( Destructor must be virtual to suppress compiler w | | dJointTemplate() // don't let user construct pure dJointTemplate objects | |
| arning "class XXX has virtual functions but non-virtual destructor" | | { } | |
| { if (_id) dJointDestroy (_id); } | | | |
| | | | |
|
| | | public: | |
| dJointID id() const | | dJointID id() const | |
|
| { return _id; } | | { return get_id(); } | |
| operator dJointID() const | | operator dJointID() const | |
|
| { return _id; } | | { return get_id(); } | |
| | | | |
| int getNumBodies() const | | int getNumBodies() const | |
|
| { return dJointGetNumBodies(_id); } | | { return dJointGetNumBodies(get_id()); } | |
| | | | |
| void attach (dBodyID body1, dBodyID body2) | | void attach (dBodyID body1, dBodyID body2) | |
|
| { dJointAttach (_id, body1, body2); } | | { dJointAttach (get_id(), body1, body2); } | |
| void attach (dBody& body1, dBody& body2) | | void attach (dBodyTemplate<dBodyTemplateBase, dWorldTemplateBase>& body1, | |
| | | dBodyTemplate<dBodyTemplateBase, dWorldTemplateBase>& body2) | |
| { attach(body1.id(), body2.id()); } | | { attach(body1.id(), body2.id()); } | |
| | | | |
| void enable() | | void enable() | |
|
| { dJointEnable (_id); } | | { dJointEnable (get_id()); } | |
| void disable() | | void disable() | |
|
| { dJointDisable (_id); } | | { dJointDisable (get_id()); } | |
| bool isEnabled() const | | bool isEnabled() const | |
|
| { return dJointIsEnabled (_id) != 0; } | | { return dJointIsEnabled (get_id()) != 0; } | |
| | | | |
| void setData (void *data) | | void setData (void *data) | |
|
| { dJointSetData (_id, data); } | | { dJointSetData (get_id(), data); } | |
| void *getData() const | | void *getData() const | |
|
| { return dJointGetData (_id); } | | { return dJointGetData (get_id()); } | |
| | | | |
| dJointType getType() const | | dJointType getType() const | |
|
| { return dJointGetType (_id); } | | { return dJointGetType (get_id()); } | |
| | | | |
| dBodyID getBody (int index) const | | dBodyID getBody (int index) const | |
|
| { return dJointGetBody (_id, index); } | | { return dJointGetBody (get_id(), index); } | |
| | | | |
| void setFeedback(dJointFeedback *fb) | | void setFeedback(dJointFeedback *fb) | |
|
| { dJointSetFeedback(_id, fb); } | | { dJointSetFeedback(get_id(), fb); } | |
| dJointFeedback *getFeedback() const | | dJointFeedback *getFeedback() const | |
|
| { return dJointGetFeedback(_id); } | | { return dJointGetFeedback(get_id()); } | |
| | | | |
| // If not implemented it will do nothing as describe in the doc | | // If not implemented it will do nothing as describe in the doc | |
| virtual void setParam (int, dReal) {}; | | virtual void setParam (int, dReal) {}; | |
| virtual dReal getParam (int) const { return 0; } | | virtual dReal getParam (int) const { return 0; } | |
| }; | | }; | |
| | | | |
|
| class dBallJoint : public dJoint { | | template <class dJointTemplateBase, class dWorldTemplateBase, class dBodyTe | |
| | | mplateBase> | |
| | | class dBallJointTemplate : public dJointTemplate<dJointTemplateBase, dWorld | |
| | | TemplateBase, dBodyTemplateBase> { | |
| private: | | private: | |
| // intentionally undefined, don't use these | | // intentionally undefined, don't use these | |
|
| dBallJoint (const dBallJoint &); | | dBallJointTemplate (const dBallJointTemplate<dJointTemplateBase, dWorldTe | |
| void operator= (const dBallJoint &); | | mplateBase, dBodyTemplateBase> &); | |
| | | void operator= (const dBallJointTemplate<dJointTemplateBase, dWorldTempla | |
| | | teBase, dBodyTemplateBase> &); | |
| | | | |
| | | protected: | |
| | | typedef dJointTemplate<dJointTemplateBase, dWorldTemplateBase, dBodyTempl | |
| | | ateBase> dBaseTemplate; | |
| | | | |
| | | dJointID get_id() const { return dBaseTemplate::get_id(); } | |
| | | void set_id(dJointID value) { dBaseTemplate::set_id(value); } | |
| | | | |
| | | void destroy() { dBaseTemplate::destroy(); } | |
| | | | |
| public: | | public: | |
|
| dBallJoint() { } | | dBallJointTemplate() { } | |
| dBallJoint (dWorldID world, dJointGroupID group=0) | | dBallJointTemplate (dWorldID world, dJointGroupID group=0) | |
| { _id = dJointCreateBall (world, group); } | | { set_id(dJointCreateBall(world, group)); } | |
| dBallJoint (dWorld& world, dJointGroupID group=0) | | dBallJointTemplate (dWorldTemplate<dWorldTemplateBase>& world, dJointGrou | |
| { _id = dJointCreateBall (world.id(), group); } | | pID group=0) | |
| | | { set_id(dJointCreateBall(world.id(), group)); } | |
| | | | |
| void create (dWorldID world, dJointGroupID group=0) { | | void create (dWorldID world, dJointGroupID group=0) { | |
|
| if (_id) dJointDestroy (_id); | | destroy(); | |
| _id = dJointCreateBall (world, group); | | set_id(dJointCreateBall(world, group)); | |
| } | | } | |
|
| void create (dWorld& world, dJointGroupID group=0) | | void create (dWorldTemplate<dWorldTemplateBase>& world, dJointGroupID gro
up=0) | |
| { create(world.id(), group); } | | { create(world.id(), group); } | |
| | | | |
| void setAnchor (dReal x, dReal y, dReal z) | | void setAnchor (dReal x, dReal y, dReal z) | |
|
| { dJointSetBallAnchor (_id, x, y, z); } | | { dJointSetBallAnchor (get_id(), x, y, z); } | |
| void setAnchor (const dVector3 a) | | void setAnchor (const dVector3 a) | |
| { setAnchor (a[0], a[1], a[2]); } | | { setAnchor (a[0], a[1], a[2]); } | |
| void getAnchor (dVector3 result) const | | void getAnchor (dVector3 result) const | |
|
| { dJointGetBallAnchor (_id, result); } | | { dJointGetBallAnchor (get_id(), result); } | |
| void getAnchor2 (dVector3 result) const | | void getAnchor2 (dVector3 result) const | |
|
| { dJointGetBallAnchor2 (_id, result); } | | { dJointGetBallAnchor2 (get_id(), result); } | |
| virtual void setParam (int parameter, dReal value) | | virtual void setParam (int parameter, dReal value) | |
|
| { dJointSetBallParam (_id, parameter, value); } | | { dJointSetBallParam (get_id(), parameter, value); } | |
| virtual dReal getParam (int parameter) const | | virtual dReal getParam (int parameter) const | |
|
| { return dJointGetBallParam (_id, parameter); } | | { return dJointGetBallParam (get_id(), parameter); } | |
| // TODO: expose params through methods | | // TODO: expose params through methods | |
| } ; | | } ; | |
| | | | |
|
| class dHingeJoint : public dJoint { | | template <class dJointTemplateBase, class dWorldTemplateBase, class dBodyTe | |
| | | mplateBase> | |
| | | class dHingeJointTemplate : public dJointTemplate<dJointTemplateBase, dWorl | |
| | | dTemplateBase, dBodyTemplateBase> { | |
| | | private: | |
| // intentionally undefined, don't use these | | // intentionally undefined, don't use these | |
|
| dHingeJoint (const dHingeJoint &); | | dHingeJointTemplate (const dHingeJointTemplate<dJointTemplateBase, dWorld | |
| void operator = (const dHingeJoint &); | | TemplateBase, dBodyTemplateBase> &); | |
| | | void operator = (const dHingeJointTemplate<dJointTemplateBase, dWorldTemp | |
| | | lateBase, dBodyTemplateBase> &); | |
| | | | |
| | | protected: | |
| | | typedef dJointTemplate<dJointTemplateBase, dWorldTemplateBase, dBodyTempl | |
| | | ateBase> dBaseTemplate; | |
| | | | |
| | | dJointID get_id() const { return dBaseTemplate::get_id(); } | |
| | | void set_id(dJointID value) { dBaseTemplate::set_id(value); } | |
| | | | |
| | | void destroy() { dBaseTemplate::destroy(); } | |
| | | | |
| public: | | public: | |
|
| dHingeJoint() { } | | dHingeJointTemplate() { } | |
| dHingeJoint (dWorldID world, dJointGroupID group=0) | | dHingeJointTemplate (dWorldID world, dJointGroupID group=0) | |
| { _id = dJointCreateHinge (world, group); } | | { set_id(dJointCreateHinge(world, group)); } | |
| dHingeJoint (dWorld& world, dJointGroupID group=0) | | dHingeJointTemplate (dWorldTemplate<dWorldTemplateBase>& world, dJointGro | |
| { _id = dJointCreateHinge (world.id(), group); } | | upID group=0) | |
| | | { set_id(dJointCreateHinge(world.id(), group)); } | |
| | | | |
| void create (dWorldID world, dJointGroupID group=0) { | | void create (dWorldID world, dJointGroupID group=0) { | |
|
| if (_id) dJointDestroy (_id); | | destroy(); | |
| _id = dJointCreateHinge (world, group); | | set_id(dJointCreateHinge (world, group)); | |
| } | | } | |
|
| void create (dWorld& world, dJointGroupID group=0) | | void create (dWorldTemplate<dWorldTemplateBase>& world, dJointGroupID gro
up=0) | |
| { create(world.id(), group); } | | { create(world.id(), group); } | |
| | | | |
| void setAnchor (dReal x, dReal y, dReal z) | | void setAnchor (dReal x, dReal y, dReal z) | |
|
| { dJointSetHingeAnchor (_id, x, y, z); } | | { dJointSetHingeAnchor (get_id(), x, y, z); } | |
| void setAnchor (const dVector3 a) | | void setAnchor (const dVector3 a) | |
| { setAnchor (a[0], a[1], a[2]); } | | { setAnchor (a[0], a[1], a[2]); } | |
| void getAnchor (dVector3 result) const | | void getAnchor (dVector3 result) const | |
|
| { dJointGetHingeAnchor (_id, result); } | | { dJointGetHingeAnchor (get_id(), result); } | |
| void getAnchor2 (dVector3 result) const | | void getAnchor2 (dVector3 result) const | |
|
| { dJointGetHingeAnchor2 (_id, result); } | | { dJointGetHingeAnchor2 (get_id(), result); } | |
| | | | |
| void setAxis (dReal x, dReal y, dReal z) | | void setAxis (dReal x, dReal y, dReal z) | |
|
| { dJointSetHingeAxis (_id, x, y, z); } | | { dJointSetHingeAxis (get_id(), x, y, z); } | |
| void setAxis (const dVector3 a) | | void setAxis (const dVector3 a) | |
| { setAxis(a[0], a[1], a[2]); } | | { setAxis(a[0], a[1], a[2]); } | |
| void getAxis (dVector3 result) const | | void getAxis (dVector3 result) const | |
|
| { dJointGetHingeAxis (_id, result); } | | { dJointGetHingeAxis (get_id(), result); } | |
| | | | |
| dReal getAngle() const | | dReal getAngle() const | |
|
| { return dJointGetHingeAngle (_id); } | | { return dJointGetHingeAngle (get_id()); } | |
| dReal getAngleRate() const | | dReal getAngleRate() const | |
|
| { return dJointGetHingeAngleRate (_id); } | | { return dJointGetHingeAngleRate (get_id()); } | |
| | | | |
| virtual void setParam (int parameter, dReal value) | | virtual void setParam (int parameter, dReal value) | |
|
| { dJointSetHingeParam (_id, parameter, value); } | | { dJointSetHingeParam (get_id(), parameter, value); } | |
| virtual dReal getParam (int parameter) const | | virtual dReal getParam (int parameter) const | |
|
| { return dJointGetHingeParam (_id, parameter); } | | { return dJointGetHingeParam (get_id(), parameter); } | |
| // TODO: expose params through methods | | // TODO: expose params through methods | |
| | | | |
| void addTorque (dReal torque) | | void addTorque (dReal torque) | |
|
| { dJointAddHingeTorque(_id, torque); } | | { dJointAddHingeTorque(get_id(), torque); } | |
| }; | | }; | |
| | | | |
|
| class dSliderJoint : public dJoint { | | template <class dJointTemplateBase, class dWorldTemplateBase, class dBodyTe | |
| | | mplateBase> | |
| | | class dSliderJointTemplate : public dJointTemplate<dJointTemplateBase, dWor | |
| | | ldTemplateBase, dBodyTemplateBase> { | |
| | | private: | |
| // intentionally undefined, don't use these | | // intentionally undefined, don't use these | |
|
| dSliderJoint (const dSliderJoint &); | | dSliderJointTemplate (const dSliderJointTemplate<dJointTemplateBase, dWor | |
| void operator = (const dSliderJoint &); | | ldTemplateBase, dBodyTemplateBase> &); | |
| | | void operator = (const dSliderJointTemplate<dJointTemplateBase, dWorldTem | |
| | | plateBase, dBodyTemplateBase> &); | |
| | | | |
| | | protected: | |
| | | typedef dJointTemplate<dJointTemplateBase, dWorldTemplateBase, dBodyTempl | |
| | | ateBase> dBaseTemplate; | |
| | | | |
| | | dJointID get_id() const { return dBaseTemplate::get_id(); } | |
| | | void set_id(dJointID value) { dBaseTemplate::set_id(value); } | |
| | | | |
| | | void destroy() { dBaseTemplate::destroy(); } | |
| | | | |
| public: | | public: | |
|
| dSliderJoint() { } | | dSliderJointTemplate() { } | |
| dSliderJoint (dWorldID world, dJointGroupID group=0) | | dSliderJointTemplate (dWorldID world, dJointGroupID group=0) | |
| { _id = dJointCreateSlider (world, group); } | | { set_id(dJointCreateSlider(world, group)); } | |
| dSliderJoint (dWorld& world, dJointGroupID group=0) | | dSliderJointTemplate (dWorldTemplate<dWorldTemplateBase>& world, dJointGr | |
| { _id = dJointCreateSlider (world.id(), group); } | | oupID group=0) | |
| | | { set_id(dJointCreateSlider(world.id(), group)); } | |
| | | | |
| void create (dWorldID world, dJointGroupID group=0) { | | void create (dWorldID world, dJointGroupID group=0) { | |
|
| if (_id) dJointDestroy (_id); | | destroy(); | |
| _id = dJointCreateSlider (world, group); | | set_id(dJointCreateSlider(world, group)); | |
| } | | } | |
|
| void create (dWorld& world, dJointGroupID group=0) | | void create (dWorldTemplate<dWorldTemplateBase>& world, dJointGroupID gro
up=0) | |
| { create(world.id(), group); } | | { create(world.id(), group); } | |
| | | | |
| void setAxis (dReal x, dReal y, dReal z) | | void setAxis (dReal x, dReal y, dReal z) | |
|
| { dJointSetSliderAxis (_id, x, y, z); } | | { dJointSetSliderAxis (get_id(), x, y, z); } | |
| void setAxis (const dVector3 a) | | void setAxis (const dVector3 a) | |
| { setAxis (a[0], a[1], a[2]); } | | { setAxis (a[0], a[1], a[2]); } | |
| void getAxis (dVector3 result) const | | void getAxis (dVector3 result) const | |
|
| { dJointGetSliderAxis (_id, result); } | | { dJointGetSliderAxis (get_id(), result); } | |
| | | | |
| dReal getPosition() const | | dReal getPosition() const | |
|
| { return dJointGetSliderPosition (_id); } | | { return dJointGetSliderPosition (get_id()); } | |
| dReal getPositionRate() const | | dReal getPositionRate() const | |
|
| { return dJointGetSliderPositionRate (_id); } | | { return dJointGetSliderPositionRate (get_id()); } | |
| | | | |
| virtual void setParam (int parameter, dReal value) | | virtual void setParam (int parameter, dReal value) | |
|
| { dJointSetSliderParam (_id, parameter, value); } | | { dJointSetSliderParam (get_id(), parameter, value); } | |
| virtual dReal getParam (int parameter) const | | virtual dReal getParam (int parameter) const | |
|
| { return dJointGetSliderParam (_id, parameter); } | | { return dJointGetSliderParam (get_id(), parameter); } | |
| // TODO: expose params through methods | | // TODO: expose params through methods | |
| | | | |
| void addForce (dReal force) | | void addForce (dReal force) | |
|
| { dJointAddSliderForce(_id, force); } | | { dJointAddSliderForce(get_id(), force); } | |
| }; | | }; | |
| | | | |
|
| class dUniversalJoint : public dJoint { | | template <class dJointTemplateBase, class dWorldTemplateBase, class dBodyTe | |
| | | mplateBase> | |
| | | class dUniversalJointTemplate : public dJointTemplate<dJointTemplateBase, d | |
| | | WorldTemplateBase, dBodyTemplateBase> { | |
| | | private: | |
| // intentionally undefined, don't use these | | // intentionally undefined, don't use these | |
|
| dUniversalJoint (const dUniversalJoint &); | | dUniversalJointTemplate (const dUniversalJointTemplate<dJointTemplateBase | |
| void operator = (const dUniversalJoint &); | | , dWorldTemplateBase, dBodyTemplateBase> &); | |
| | | void operator = (const dUniversalJointTemplate<dJointTemplateBase, dWorld | |
| | | TemplateBase, dBodyTemplateBase> &); | |
| | | | |
| | | protected: | |
| | | typedef dJointTemplate<dJointTemplateBase, dWorldTemplateBase, dBodyTempl | |
| | | ateBase> dBaseTemplate; | |
| | | | |
| | | dJointID get_id() const { return dBaseTemplate::get_id(); } | |
| | | void set_id(dJointID value) { dBaseTemplate::set_id(value); } | |
| | | | |
| | | void destroy() { dBaseTemplate::destroy(); } | |
| | | | |
| public: | | public: | |
|
| dUniversalJoint() { } | | dUniversalJointTemplate() { } | |
| dUniversalJoint (dWorldID world, dJointGroupID group=0) | | dUniversalJointTemplate (dWorldID world, dJointGroupID group=0) | |
| { _id = dJointCreateUniversal (world, group); } | | { set_id(dJointCreateUniversal(world, group)); } | |
| dUniversalJoint (dWorld& world, dJointGroupID group=0) | | dUniversalJointTemplate (dWorldTemplate<dWorldTemplateBase>& world, dJoin | |
| { _id = dJointCreateUniversal (world.id(), group); } | | tGroupID group=0) | |
| | | { set_id(dJointCreateUniversal(world.id(), group)); } | |
| | | | |
| void create (dWorldID world, dJointGroupID group=0) { | | void create (dWorldID world, dJointGroupID group=0) { | |
|
| if (_id) dJointDestroy (_id); | | destroy(); | |
| _id = dJointCreateUniversal (world, group); | | set_id(dJointCreateUniversal(world, group)); | |
| } | | } | |
|
| void create (dWorld& world, dJointGroupID group=0) | | void create (dWorldTemplate<dWorldTemplateBase>& world, dJointGroupID gro
up=0) | |
| { create(world.id(), group); } | | { create(world.id(), group); } | |
| | | | |
| void setAnchor (dReal x, dReal y, dReal z) | | void setAnchor (dReal x, dReal y, dReal z) | |
|
| { dJointSetUniversalAnchor (_id, x, y, z); } | | { dJointSetUniversalAnchor (get_id(), x, y, z); } | |
| void setAnchor (const dVector3 a) | | void setAnchor (const dVector3 a) | |
| { setAnchor(a[0], a[1], a[2]); } | | { setAnchor(a[0], a[1], a[2]); } | |
| void setAxis1 (dReal x, dReal y, dReal z) | | void setAxis1 (dReal x, dReal y, dReal z) | |
|
| { dJointSetUniversalAxis1 (_id, x, y, z); } | | { dJointSetUniversalAxis1 (get_id(), x, y, z); } | |
| void setAxis1 (const dVector3 a) | | void setAxis1 (const dVector3 a) | |
| { setAxis1 (a[0], a[1], a[2]); } | | { setAxis1 (a[0], a[1], a[2]); } | |
| void setAxis2 (dReal x, dReal y, dReal z) | | void setAxis2 (dReal x, dReal y, dReal z) | |
|
| { dJointSetUniversalAxis2 (_id, x, y, z); } | | { dJointSetUniversalAxis2 (get_id(), x, y, z); } | |
| void setAxis2 (const dVector3 a) | | void setAxis2 (const dVector3 a) | |
| { setAxis2 (a[0], a[1], a[2]); } | | { setAxis2 (a[0], a[1], a[2]); } | |
| | | | |
| void getAnchor (dVector3 result) const | | void getAnchor (dVector3 result) const | |
|
| { dJointGetUniversalAnchor (_id, result); } | | { dJointGetUniversalAnchor (get_id(), result); } | |
| void getAnchor2 (dVector3 result) const | | void getAnchor2 (dVector3 result) const | |
|
| { dJointGetUniversalAnchor2 (_id, result); } | | { dJointGetUniversalAnchor2 (get_id(), result); } | |
| void getAxis1 (dVector3 result) const | | void getAxis1 (dVector3 result) const | |
|
| { dJointGetUniversalAxis1 (_id, result); } | | { dJointGetUniversalAxis1 (get_id(), result); } | |
| void getAxis2 (dVector3 result) const | | void getAxis2 (dVector3 result) const | |
|
| { dJointGetUniversalAxis2 (_id, result); } | | { dJointGetUniversalAxis2 (get_id(), result); } | |
| | | | |
| virtual void setParam (int parameter, dReal value) | | virtual void setParam (int parameter, dReal value) | |
|
| { dJointSetUniversalParam (_id, parameter, value); } | | { dJointSetUniversalParam (get_id(), parameter, value); } | |
| virtual dReal getParam (int parameter) const | | virtual dReal getParam (int parameter) const | |
|
| { return dJointGetUniversalParam (_id, parameter); } | | { return dJointGetUniversalParam (get_id(), parameter); } | |
| // TODO: expose params through methods | | // TODO: expose params through methods | |
| | | | |
| void getAngles(dReal *angle1, dReal *angle2) const | | void getAngles(dReal *angle1, dReal *angle2) const | |
|
| { dJointGetUniversalAngles (_id, angle1, angle2); } | | { dJointGetUniversalAngles (get_id(), angle1, angle2); } | |
| | | | |
| dReal getAngle1() const | | dReal getAngle1() const | |
|
| { return dJointGetUniversalAngle1 (_id); } | | { return dJointGetUniversalAngle1 (get_id()); } | |
| dReal getAngle1Rate() const | | dReal getAngle1Rate() const | |
|
| { return dJointGetUniversalAngle1Rate (_id); } | | { return dJointGetUniversalAngle1Rate (get_id()); } | |
| dReal getAngle2() const | | dReal getAngle2() const | |
|
| { return dJointGetUniversalAngle2 (_id); } | | { return dJointGetUniversalAngle2 (get_id()); } | |
| dReal getAngle2Rate() const | | dReal getAngle2Rate() const | |
|
| { return dJointGetUniversalAngle2Rate (_id); } | | { return dJointGetUniversalAngle2Rate (get_id()); } | |
| | | | |
| void addTorques (dReal torque1, dReal torque2) | | void addTorques (dReal torque1, dReal torque2) | |
|
| { dJointAddUniversalTorques(_id, torque1, torque2); } | | { dJointAddUniversalTorques(get_id(), torque1, torque2); } | |
| }; | | }; | |
| | | | |
|
| class dHinge2Joint : public dJoint { | | template <class dJointTemplateBase, class dWorldTemplateBase, class dBodyTe | |
| | | mplateBase> | |
| | | class dHinge2JointTemplate : public dJointTemplate<dJointTemplateBase, dWor | |
| | | ldTemplateBase, dBodyTemplateBase> { | |
| | | private: | |
| // intentionally undefined, don't use these | | // intentionally undefined, don't use these | |
|
| dHinge2Joint (const dHinge2Joint &); | | dHinge2JointTemplate (const dHinge2JointTemplate<dJointTemplateBase, dWor | |
| void operator = (const dHinge2Joint &); | | ldTemplateBase, dBodyTemplateBase> &); | |
| | | void operator = (const dHinge2JointTemplate<dJointTemplateBase, dWorldTem | |
| | | plateBase, dBodyTemplateBase> &); | |
| | | | |
| | | protected: | |
| | | typedef dJointTemplate<dJointTemplateBase, dWorldTemplateBase, dBodyTempl | |
| | | ateBase> dBaseTemplate; | |
| | | | |
| | | dJointID get_id() const { return dBaseTemplate::get_id(); } | |
| | | void set_id(dJointID value) { dBaseTemplate::set_id(value); } | |
| | | | |
| | | void destroy() { dBaseTemplate::destroy(); } | |
| | | | |
| public: | | public: | |
|
| dHinge2Joint() { } | | dHinge2JointTemplate() { } | |
| dHinge2Joint (dWorldID world, dJointGroupID group=0) | | dHinge2JointTemplate (dWorldID world, dJointGroupID group=0) | |
| { _id = dJointCreateHinge2 (world, group); } | | { set_id(dJointCreateHinge2(world, group)); } | |
| dHinge2Joint (dWorld& world, dJointGroupID group=0) | | dHinge2JointTemplate (dWorldTemplate<dWorldTemplateBase>& world, dJointGr | |
| { _id = dJointCreateHinge2 (world.id(), group); } | | oupID group=0) | |
| | | { set_id(dJointCreateHinge2(world.id(), group)); } | |
| | | | |
| void create (dWorldID world, dJointGroupID group=0) { | | void create (dWorldID world, dJointGroupID group=0) { | |
|
| if (_id) dJointDestroy (_id); | | destroy(); | |
| _id = dJointCreateHinge2 (world, group); | | set_id(dJointCreateHinge2(world, group)); | |
| } | | } | |
|
| void create (dWorld& world, dJointGroupID group=0) | | void create (dWorldTemplate<dWorldTemplateBase>& world, dJointGroupID gro
up=0) | |
| { create(world.id(), group); } | | { create(world.id(), group); } | |
| | | | |
| void setAnchor (dReal x, dReal y, dReal z) | | void setAnchor (dReal x, dReal y, dReal z) | |
|
| { dJointSetHinge2Anchor (_id, x, y, z); } | | { dJointSetHinge2Anchor (get_id(), x, y, z); } | |
| void setAnchor (const dVector3 a) | | void setAnchor (const dVector3 a) | |
| { setAnchor(a[0], a[1], a[2]); } | | { setAnchor(a[0], a[1], a[2]); } | |
| void setAxis1 (dReal x, dReal y, dReal z) | | void setAxis1 (dReal x, dReal y, dReal z) | |
|
| { dJointSetHinge2Axis1 (_id, x, y, z); } | | { dJointSetHinge2Axis1 (get_id(), x, y, z); } | |
| void setAxis1 (const dVector3 a) | | void setAxis1 (const dVector3 a) | |
| { setAxis1 (a[0], a[1], a[2]); } | | { setAxis1 (a[0], a[1], a[2]); } | |
| void setAxis2 (dReal x, dReal y, dReal z) | | void setAxis2 (dReal x, dReal y, dReal z) | |
|
| { dJointSetHinge2Axis2 (_id, x, y, z); } | | { dJointSetHinge2Axis2 (get_id(), x, y, z); } | |
| void setAxis2 (const dVector3 a) | | void setAxis2 (const dVector3 a) | |
| { setAxis2 (a[0], a[1], a[2]); } | | { setAxis2 (a[0], a[1], a[2]); } | |
| | | | |
| void getAnchor (dVector3 result) const | | void getAnchor (dVector3 result) const | |
|
| { dJointGetHinge2Anchor (_id, result); } | | { dJointGetHinge2Anchor (get_id(), result); } | |
| void getAnchor2 (dVector3 result) const | | void getAnchor2 (dVector3 result) const | |
|
| { dJointGetHinge2Anchor2 (_id, result); } | | { dJointGetHinge2Anchor2 (get_id(), result); } | |
| void getAxis1 (dVector3 result) const | | void getAxis1 (dVector3 result) const | |
|
| { dJointGetHinge2Axis1 (_id, result); } | | { dJointGetHinge2Axis1 (get_id(), result); } | |
| void getAxis2 (dVector3 result) const | | void getAxis2 (dVector3 result) const | |
|
| { dJointGetHinge2Axis2 (_id, result); } | | { dJointGetHinge2Axis2 (get_id(), result); } | |
| | | | |
| dReal getAngle1() const | | dReal getAngle1() const | |
|
| { return dJointGetHinge2Angle1 (_id); } | | { return dJointGetHinge2Angle1 (get_id()); } | |
| dReal getAngle1Rate() const | | dReal getAngle1Rate() const | |
|
| { return dJointGetHinge2Angle1Rate (_id); } | | { return dJointGetHinge2Angle1Rate (get_id()); } | |
| dReal getAngle2Rate() const | | dReal getAngle2Rate() const | |
|
| { return dJointGetHinge2Angle2Rate (_id); } | | { return dJointGetHinge2Angle2Rate (get_id()); } | |
| | | | |
| virtual void setParam (int parameter, dReal value) | | virtual void setParam (int parameter, dReal value) | |
|
| { dJointSetHinge2Param (_id, parameter, value); } | | { dJointSetHinge2Param (get_id(), parameter, value); } | |
| virtual dReal getParam (int parameter) const | | virtual dReal getParam (int parameter) const | |
|
| { return dJointGetHinge2Param (_id, parameter); } | | { return dJointGetHinge2Param (get_id(), parameter); } | |
| // TODO: expose params through methods | | // TODO: expose params through methods | |
| | | | |
| void addTorques(dReal torque1, dReal torque2) | | void addTorques(dReal torque1, dReal torque2) | |
|
| { dJointAddHinge2Torques(_id, torque1, torque2); } | | { dJointAddHinge2Torques(get_id(), torque1, torque2); } | |
| }; | | }; | |
| | | | |
|
| class dPRJoint : public dJoint { | | template <class dJointTemplateBase, class dWorldTemplateBase, class dBodyTe | |
| dPRJoint (const dPRJoint &); | | mplateBase> | |
| void operator = (const dPRJoint &); | | class dPRJointTemplate : public dJointTemplate<dJointTemplateBase, dWorldTe | |
| | | mplateBase, dBodyTemplateBase> { | |
| | | private: | |
| | | // intentionally undefined, don't use these | |
| | | dPRJointTemplate (const dPRJointTemplate<dJointTemplateBase, dWorldTempla | |
| | | teBase, dBodyTemplateBase> &); | |
| | | void operator = (const dPRJointTemplate<dJointTemplateBase, dWorldTemplat | |
| | | eBase, dBodyTemplateBase> &); | |
| | | | |
| | | protected: | |
| | | typedef dJointTemplate<dJointTemplateBase, dWorldTemplateBase, dBodyTempl | |
| | | ateBase> dBaseTemplate; | |
| | | | |
| | | dJointID get_id() const { return dBaseTemplate::get_id(); } | |
| | | void set_id(dJointID value) { dBaseTemplate::set_id(value); } | |
| | | | |
| | | void destroy() { dBaseTemplate::destroy(); } | |
| | | | |
| public: | | public: | |
|
| dPRJoint() { } | | dPRJointTemplate() { } | |
| dPRJoint (dWorldID world, dJointGroupID group=0) | | dPRJointTemplate (dWorldID world, dJointGroupID group=0) | |
| { _id = dJointCreatePR (world, group); } | | { set_id(dJointCreatePR(world, group)); } | |
| dPRJoint (dWorld& world, dJointGroupID group=0) | | dPRJointTemplate (dWorldTemplate<dWorldTemplateBase>& world, dJointGroupI | |
| { _id = dJointCreatePR (world.id(), group); } | | D group=0) | |
| | | { set_id(dJointCreatePR(world.id(), group)); } | |
| | | | |
| void create (dWorldID world, dJointGroupID group=0) { | | void create (dWorldID world, dJointGroupID group=0) { | |
|
| if (_id) dJointDestroy (_id); | | destroy(); | |
| _id = dJointCreatePR (world, group); | | set_id(dJointCreatePR(world, group)); | |
| } | | } | |
|
| void create (dWorld& world, dJointGroupID group=0) | | void create (dWorldTemplate<dWorldTemplateBase>& world, dJointGroupID gro
up=0) | |
| { create(world.id(), group); } | | { create(world.id(), group); } | |
| | | | |
| void setAnchor (dReal x, dReal y, dReal z) | | void setAnchor (dReal x, dReal y, dReal z) | |
|
| { dJointSetPRAnchor (_id, x, y, z); } | | { dJointSetPRAnchor (get_id(), x, y, z); } | |
| void setAnchor (const dVector3 a) | | void setAnchor (const dVector3 a) | |
| { setAnchor (a[0], a[1], a[2]); } | | { setAnchor (a[0], a[1], a[2]); } | |
| void setAxis1 (dReal x, dReal y, dReal z) | | void setAxis1 (dReal x, dReal y, dReal z) | |
|
| { dJointSetPRAxis1 (_id, x, y, z); } | | { dJointSetPRAxis1 (get_id(), x, y, z); } | |
| void setAxis1 (const dVector3 a) | | void setAxis1 (const dVector3 a) | |
| { setAxis1(a[0], a[1], a[2]); } | | { setAxis1(a[0], a[1], a[2]); } | |
| void setAxis2 (dReal x, dReal y, dReal z) | | void setAxis2 (dReal x, dReal y, dReal z) | |
|
| { dJointSetPRAxis2 (_id, x, y, z); } | | { dJointSetPRAxis2 (get_id(), x, y, z); } | |
| void setAxis2 (const dVector3 a) | | void setAxis2 (const dVector3 a) | |
| { setAxis2(a[0], a[1], a[2]); } | | { setAxis2(a[0], a[1], a[2]); } | |
| | | | |
| void getAnchor (dVector3 result) const | | void getAnchor (dVector3 result) const | |
|
| { dJointGetPRAnchor (_id, result); } | | { dJointGetPRAnchor (get_id(), result); } | |
| void getAxis1 (dVector3 result) const | | void getAxis1 (dVector3 result) const | |
|
| { dJointGetPRAxis1 (_id, result); } | | { dJointGetPRAxis1 (get_id(), result); } | |
| void getAxis2 (dVector3 result) const | | void getAxis2 (dVector3 result) const | |
|
| { dJointGetPRAxis2 (_id, result); } | | { dJointGetPRAxis2 (get_id(), result); } | |
| | | | |
| dReal getPosition() const | | dReal getPosition() const | |
|
| { return dJointGetPRPosition (_id); } | | { return dJointGetPRPosition (get_id()); } | |
| dReal getPositionRate() const | | dReal getPositionRate() const | |
|
| { return dJointGetPRPositionRate (_id); } | | { return dJointGetPRPositionRate (get_id()); } | |
| | | | |
| dReal getAngle() const | | dReal getAngle() const | |
|
| { return dJointGetPRAngle (_id); } | | { return dJointGetPRAngle (get_id()); } | |
| dReal getAngleRate() const | | dReal getAngleRate() const | |
|
| { return dJointGetPRAngleRate (_id); } | | { return dJointGetPRAngleRate (get_id()); } | |
| | | | |
| virtual void setParam (int parameter, dReal value) | | virtual void setParam (int parameter, dReal value) | |
|
| { dJointSetPRParam (_id, parameter, value); } | | { dJointSetPRParam (get_id(), parameter, value); } | |
| virtual dReal getParam (int parameter) const | | virtual dReal getParam (int parameter) const | |
|
| { return dJointGetPRParam (_id, parameter); } | | { return dJointGetPRParam (get_id(), parameter); } | |
| }; | | }; | |
| | | | |
|
| class dPUJoint : public dJoint | | template <class dJointTemplateBase, class dWorldTemplateBase, class dBodyTe | |
| | | mplateBase> | |
| | | class dPUJointTemplate : public dJointTemplate<dJointTemplateBase, dWorldTe | |
| | | mplateBase, dBodyTemplateBase> | |
| { | | { | |
|
| dPUJoint (const dPUJoint &); | | private: | |
| void operator = (const dPUJoint &); | | // intentionally undefined, don't use these | |
| | | dPUJointTemplate (const dPUJointTemplate<dJointTemplateBase, dWorldTempla | |
| | | teBase, dBodyTemplateBase> &); | |
| | | void operator = (const dPUJointTemplate<dJointTemplateBase, dWorldTemplat | |
| | | eBase, dBodyTemplateBase> &); | |
| | | | |
| | | protected: | |
| | | typedef dJointTemplate<dJointTemplateBase, dWorldTemplateBase, dBodyTempl | |
| | | ateBase> dBaseTemplate; | |
| | | | |
| | | dJointID get_id() const { return dBaseTemplate::get_id(); } | |
| | | void set_id(dJointID value) { dBaseTemplate::set_id(value); } | |
| | | | |
| | | void destroy() { dBaseTemplate::destroy(); } | |
| | | | |
| public: | | public: | |
|
| dPUJoint() { } | | dPUJointTemplate() { } | |
| dPUJoint (dWorldID world, dJointGroupID group=0) | | dPUJointTemplate (dWorldID world, dJointGroupID group=0) | |
| { _id = dJointCreatePU (world, group); } | | { set_id(dJointCreatePU(world, group)); } | |
| dPUJoint (dWorld& world, dJointGroupID group=0) | | dPUJointTemplate (dWorldTemplate<dWorldTemplateBase>& world, dJointGroupI | |
| { _id = dJointCreatePU (world.id(), group); } | | D group=0) | |
| | | { set_id(dJointCreatePU(world.id(), group)); } | |
| | | | |
| void create (dWorldID world, dJointGroupID group=0) | | void create (dWorldID world, dJointGroupID group=0) | |
| { | | { | |
|
| if (_id) dJointDestroy (_id); | | destroy(); | |
| _id = dJointCreatePU (world, group); | | set_id(dJointCreatePU(world, group)); | |
| } | | } | |
|
| void create (dWorld& world, dJointGroupID group=0) | | void create (dWorldTemplate<dWorldTemplateBase>& world, dJointGroupID gro
up=0) | |
| { create(world.id(), group); } | | { create(world.id(), group); } | |
| | | | |
| void setAnchor (dReal x, dReal y, dReal z) | | void setAnchor (dReal x, dReal y, dReal z) | |
|
| { dJointSetPUAnchor (_id, x, y, z); } | | { dJointSetPUAnchor (get_id(), x, y, z); } | |
| void setAnchor (const dVector3 a) | | void setAnchor (const dVector3 a) | |
| { setAnchor (a[0], a[1], a[2]); } | | { setAnchor (a[0], a[1], a[2]); } | |
| void setAxis1 (dReal x, dReal y, dReal z) | | void setAxis1 (dReal x, dReal y, dReal z) | |
|
| { dJointSetPUAxis1 (_id, x, y, z); } | | { dJointSetPUAxis1 (get_id(), x, y, z); } | |
| void setAxis1 (const dVector3 a) | | void setAxis1 (const dVector3 a) | |
| { setAxis1(a[0], a[1], a[2]); } | | { setAxis1(a[0], a[1], a[2]); } | |
| void setAxis2 (dReal x, dReal y, dReal z) | | void setAxis2 (dReal x, dReal y, dReal z) | |
|
| { dJointSetPUAxis2 (_id, x, y, z); } | | { dJointSetPUAxis2 (get_id(), x, y, z); } | |
| void setAxis3 (dReal x, dReal y, dReal z) | | void setAxis3 (dReal x, dReal y, dReal z) | |
|
| { dJointSetPUAxis3 (_id, x, y, z); } | | { dJointSetPUAxis3 (get_id(), x, y, z); } | |
| void setAxis3 (const dVector3 a) | | void setAxis3 (const dVector3 a) | |
| { setAxis3(a[0], a[1], a[2]); } | | { setAxis3(a[0], a[1], a[2]); } | |
| void setAxisP (dReal x, dReal y, dReal z) | | void setAxisP (dReal x, dReal y, dReal z) | |
|
| { dJointSetPUAxis3 (_id, x, y, z); } | | { dJointSetPUAxis3 (get_id(), x, y, z); } | |
| void setAxisP (const dVector3 a) | | void setAxisP (const dVector3 a) | |
| { setAxisP(a[0], a[1], a[2]); } | | { setAxisP(a[0], a[1], a[2]); } | |
| | | | |
| virtual void getAnchor (dVector3 result) const | | virtual void getAnchor (dVector3 result) const | |
|
| { dJointGetPUAnchor (_id, result); } | | { dJointGetPUAnchor (get_id(), result); } | |
| void getAxis1 (dVector3 result) const | | void getAxis1 (dVector3 result) const | |
|
| { dJointGetPUAxis1 (_id, result); } | | { dJointGetPUAxis1 (get_id(), result); } | |
| void getAxis2 (dVector3 result) const | | void getAxis2 (dVector3 result) const | |
|
| { dJointGetPUAxis2 (_id, result); } | | { dJointGetPUAxis2 (get_id(), result); } | |
| void getAxis3 (dVector3 result) const | | void getAxis3 (dVector3 result) const | |
|
| { dJointGetPUAxis3 (_id, result); } | | { dJointGetPUAxis3 (get_id(), result); } | |
| void getAxisP (dVector3 result) const | | void getAxisP (dVector3 result) const | |
|
| { dJointGetPUAxis3 (_id, result); } | | { dJointGetPUAxis3 (get_id(), result); } | |
| | | | |
| dReal getAngle1() const | | dReal getAngle1() const | |
|
| { return dJointGetPUAngle1 (_id); } | | { return dJointGetPUAngle1 (get_id()); } | |
| dReal getAngle1Rate() const | | dReal getAngle1Rate() const | |
|
| { return dJointGetPUAngle1Rate (_id); } | | { return dJointGetPUAngle1Rate (get_id()); } | |
| dReal getAngle2() const | | dReal getAngle2() const | |
|
| { return dJointGetPUAngle2 (_id); } | | { return dJointGetPUAngle2 (get_id()); } | |
| dReal getAngle2Rate() const | | dReal getAngle2Rate() const | |
|
| { return dJointGetPUAngle2Rate (_id); } | | { return dJointGetPUAngle2Rate (get_id()); } | |
| | | | |
| dReal getPosition() const | | dReal getPosition() const | |
|
| { return dJointGetPUPosition (_id); } | | { return dJointGetPUPosition (get_id()); } | |
| dReal getPositionRate() const | | dReal getPositionRate() const | |
|
| { return dJointGetPUPositionRate (_id); } | | { return dJointGetPUPositionRate (get_id()); } | |
| | | | |
| virtual void setParam (int parameter, dReal value) | | virtual void setParam (int parameter, dReal value) | |
|
| { dJointSetPUParam (_id, parameter, value); } | | { dJointSetPUParam (get_id(), parameter, value); } | |
| virtual dReal getParam (int parameter) const | | virtual dReal getParam (int parameter) const | |
|
| { return dJointGetPUParam (_id, parameter); } | | { return dJointGetPUParam (get_id(), parameter); } | |
| // TODO: expose params through methods | | // TODO: expose params through methods | |
| }; | | }; | |
| | | | |
|
| class dPistonJoint : public dJoint | | template <class dJointTemplateBase, class dWorldTemplateBase, class dBodyTe | |
| | | mplateBase> | |
| | | class dPistonJointTemplate : public dJointTemplate<dJointTemplateBase, dWor | |
| | | ldTemplateBase, dBodyTemplateBase> | |
| { | | { | |
|
| | | private: | |
| // intentionally undefined, don't use these | | // intentionally undefined, don't use these | |
|
| dPistonJoint (const dPistonJoint &); | | dPistonJointTemplate (const dPistonJointTemplate<dJointTemplateBase, dWor | |
| void operator = (const dPistonJoint &); | | ldTemplateBase, dBodyTemplateBase> &); | |
| | | void operator = (const dPistonJointTemplate<dJointTemplateBase, dWorldTem | |
| | | plateBase, dBodyTemplateBase> &); | |
| | | | |
| | | protected: | |
| | | typedef dJointTemplate<dJointTemplateBase, dWorldTemplateBase, dBodyTempl | |
| | | ateBase> dBaseTemplate; | |
| | | | |
| | | dJointID get_id() const { return dBaseTemplate::get_id(); } | |
| | | void set_id(dJointID value) { dBaseTemplate::set_id(value); } | |
| | | | |
| | | void destroy() { dBaseTemplate::destroy(); } | |
| | | | |
| public: | | public: | |
|
| dPistonJoint() { } | | dPistonJointTemplate() { } | |
| dPistonJoint (dWorldID world, dJointGroupID group=0) | | dPistonJointTemplate (dWorldID world, dJointGroupID group=0) | |
| { _id = dJointCreatePiston (world, group); } | | { set_id(dJointCreatePiston(world, group)); } | |
| dPistonJoint (dWorld& world, dJointGroupID group=0) | | dPistonJointTemplate (dWorldTemplate<dWorldTemplateBase>& world, dJointGr | |
| { _id = dJointCreatePiston (world, group); } | | oupID group=0) | |
| | | { set_id(dJointCreatePiston(world, group)); } | |
| | | | |
| void create (dWorldID world, dJointGroupID group=0) | | void create (dWorldID world, dJointGroupID group=0) | |
| { | | { | |
|
| if (_id) dJointDestroy (_id); | | destroy(); | |
| _id = dJointCreatePiston (world, group); | | set_id(dJointCreatePiston(world, group)); | |
| } | | } | |
|
| void create (dWorld& world, dJointGroupID group=0) | | void create (dWorldTemplate<dWorldTemplateBase>& world, dJointGroupID gro
up=0) | |
| { create(world.id(), group); } | | { create(world.id(), group); } | |
| | | | |
| void setAnchor (dReal x, dReal y, dReal z) | | void setAnchor (dReal x, dReal y, dReal z) | |
|
| { dJointSetPistonAnchor (_id, x, y, z); } | | { dJointSetPistonAnchor (get_id(), x, y, z); } | |
| void setAnchor (const dVector3 a) | | void setAnchor (const dVector3 a) | |
| { setAnchor (a[0], a[1], a[2]); } | | { setAnchor (a[0], a[1], a[2]); } | |
| void getAnchor (dVector3 result) const | | void getAnchor (dVector3 result) const | |
|
| { dJointGetPistonAnchor (_id, result); } | | { dJointGetPistonAnchor (get_id(), result); } | |
| void getAnchor2 (dVector3 result) const | | void getAnchor2 (dVector3 result) const | |
|
| { dJointGetPistonAnchor2 (_id, result); } | | { dJointGetPistonAnchor2 (get_id(), result); } | |
| | | | |
| void setAxis (dReal x, dReal y, dReal z) | | void setAxis (dReal x, dReal y, dReal z) | |
|
| { dJointSetPistonAxis (_id, x, y, z); } | | { dJointSetPistonAxis (get_id(), x, y, z); } | |
| void setAxis (const dVector3 a) | | void setAxis (const dVector3 a) | |
| { setAxis(a[0], a[1], a[2]); } | | { setAxis(a[0], a[1], a[2]); } | |
| void getAxis (dVector3 result) const | | void getAxis (dVector3 result) const | |
|
| { dJointGetPistonAxis (_id, result); } | | { dJointGetPistonAxis (get_id(), result); } | |
| | | | |
| dReal getPosition() const | | dReal getPosition() const | |
|
| { return dJointGetPistonPosition (_id); } | | { return dJointGetPistonPosition (get_id()); } | |
| dReal getPositionRate() const | | dReal getPositionRate() const | |
|
| { return dJointGetPistonPositionRate (_id); } | | { return dJointGetPistonPositionRate (get_id()); } | |
| | | | |
| virtual void setParam (int parameter, dReal value) | | virtual void setParam (int parameter, dReal value) | |
|
| { dJointSetPistonParam (_id, parameter, value); } | | { dJointSetPistonParam (get_id(), parameter, value); } | |
| virtual dReal getParam (int parameter) const | | virtual dReal getParam (int parameter) const | |
|
| { return dJointGetPistonParam (_id, parameter); } | | { return dJointGetPistonParam (get_id(), parameter); } | |
| // TODO: expose params through methods | | // TODO: expose params through methods | |
| | | | |
| void addForce (dReal force) | | void addForce (dReal force) | |
|
| { dJointAddPistonForce (_id, force); } | | { dJointAddPistonForce (get_id(), force); } | |
| }; | | }; | |
| | | | |
|
| class dFixedJoint : public dJoint | | template <class dJointTemplateBase, class dWorldTemplateBase, class dBodyTe | |
| | | mplateBase> | |
| | | class dFixedJointTemplate : public dJointTemplate<dJointTemplateBase, dWorl | |
| | | dTemplateBase, dBodyTemplateBase> | |
| { | | { | |
|
| | | private: | |
| // intentionally undefined, don't use these | | // intentionally undefined, don't use these | |
|
| dFixedJoint (const dFixedJoint &); | | dFixedJointTemplate (const dFixedJointTemplate<dJointTemplateBase, dWorld | |
| void operator = (const dFixedJoint &); | | TemplateBase, dBodyTemplateBase> &); | |
| | | void operator = (const dFixedJointTemplate<dJointTemplateBase, dWorldTemp | |
| | | lateBase, dBodyTemplateBase> &); | |
| | | | |
| | | protected: | |
| | | typedef dJointTemplate<dJointTemplateBase, dWorldTemplateBase, dBodyTempl | |
| | | ateBase> dBaseTemplate; | |
| | | | |
| | | dJointID get_id() const { return dBaseTemplate::get_id(); } | |
| | | void set_id(dJointID value) { dBaseTemplate::set_id(value); } | |
| | | | |
| | | void destroy() { dBaseTemplate::destroy(); } | |
| | | | |
| public: | | public: | |
|
| dFixedJoint() { } | | dFixedJointTemplate() { } | |
| dFixedJoint (dWorldID world, dJointGroupID group=0) | | dFixedJointTemplate (dWorldID world, dJointGroupID group=0) | |
| { _id = dJointCreateFixed (world, group); } | | { set_id(dJointCreateFixed(world, group)); } | |
| dFixedJoint (dWorld& world, dJointGroupID group=0) | | dFixedJointTemplate (dWorldTemplate<dWorldTemplateBase>& world, dJointGro | |
| { _id = dJointCreateFixed (world, group); } | | upID group=0) | |
| | | { set_id(dJointCreateFixed(world, group)); } | |
| | | | |
| void create (dWorldID world, dJointGroupID group=0) { | | void create (dWorldID world, dJointGroupID group=0) { | |
|
| if (_id) dJointDestroy (_id); | | destroy(); | |
| _id = dJointCreateFixed (world, group); | | set_id(dJointCreateFixed(world, group)); | |
| } | | } | |
|
| void create (dWorld& world, dJointGroupID group=0) | | void create (dWorldTemplate<dWorldTemplateBase>& world, dJointGroupID gro
up=0) | |
| { create(world.id(), group); } | | { create(world.id(), group); } | |
| | | | |
| void set() | | void set() | |
|
| { dJointSetFixed (_id); } | | { dJointSetFixed (get_id()); } | |
| | | | |
| virtual void setParam (int parameter, dReal value) | | virtual void setParam (int parameter, dReal value) | |
|
| { dJointSetFixedParam (_id, parameter, value); } | | { dJointSetFixedParam (get_id(), parameter, value); } | |
| | | | |
| virtual dReal getParam (int parameter) const | | virtual dReal getParam (int parameter) const | |
|
| { return dJointGetFixedParam (_id, parameter); } | | { return dJointGetFixedParam (get_id(), parameter); } | |
| // TODO: expose params through methods | | // TODO: expose params through methods | |
| }; | | }; | |
| | | | |
|
| class dContactJoint : public dJoint { | | template <class dJointTemplateBase, class dWorldTemplateBase, class dBodyTe | |
| | | mplateBase> | |
| | | class dContactJointTemplate : public dJointTemplate<dJointTemplateBase, dWo | |
| | | rldTemplateBase, dBodyTemplateBase> { | |
| | | private: | |
| // intentionally undefined, don't use these | | // intentionally undefined, don't use these | |
|
| dContactJoint (const dContactJoint &); | | dContactJointTemplate (const dContactJointTemplate<dJointTemplateBase, dW | |
| void operator = (const dContactJoint &); | | orldTemplateBase, dBodyTemplateBase> &); | |
| | | void operator = (const dContactJointTemplate<dJointTemplateBase, dWorldTe | |
| | | mplateBase, dBodyTemplateBase> &); | |
| | | | |
| | | protected: | |
| | | typedef dJointTemplate<dJointTemplateBase, dWorldTemplateBase, dBodyTempl | |
| | | ateBase> dBaseTemplate; | |
| | | | |
| | | dJointID get_id() const { return dBaseTemplate::get_id(); } | |
| | | void set_id(dJointID value) { dBaseTemplate::set_id(value); } | |
| | | | |
| | | void destroy() { dBaseTemplate::destroy(); } | |
| | | | |
| public: | | public: | |
|
| dContactJoint() { } | | dContactJointTemplate() { } | |
| dContactJoint (dWorldID world, dJointGroupID group, dContact *contact) | | dContactJointTemplate (dWorldID world, dJointGroupID group, dContact *con | |
| { _id = dJointCreateContact (world, group, contact); } | | tact) | |
| dContactJoint (dWorld& world, dJointGroupID group, dContact *contact) | | { set_id(dJointCreateContact(world, group, contact)); } | |
| { _id = dJointCreateContact (world.id(), group, contact); } | | dContactJointTemplate (dWorldTemplate<dWorldTemplateBase>& world, dJointG | |
| | | roupID group, dContact *contact) | |
| | | { set_id(dJointCreateContact(world.id(), group, contact)); } | |
| | | | |
| void create (dWorldID world, dJointGroupID group, dContact *contact) { | | void create (dWorldID world, dJointGroupID group, dContact *contact) { | |
|
| if (_id) dJointDestroy (_id); | | destroy(); | |
| _id = dJointCreateContact (world, group, contact); | | set_id(dJointCreateContact(world, group, contact)); | |
| } | | } | |
| | | | |
|
| void create (dWorld& world, dJointGroupID group, dContact *contact) | | void create (dWorldTemplate<dWorldTemplateBase>& world, dJointGroupID gro
up, dContact *contact) | |
| { create(world.id(), group, contact); } | | { create(world.id(), group, contact); } | |
| }; | | }; | |
| | | | |
|
| class dNullJoint : public dJoint { | | template <class dJointTemplateBase, class dWorldTemplateBase, class dBodyTe | |
| | | mplateBase> | |
| | | class dNullJointTemplate : public dJointTemplate<dJointTemplateBase, dWorld | |
| | | TemplateBase, dBodyTemplateBase> { | |
| | | private: | |
| // intentionally undefined, don't use these | | // intentionally undefined, don't use these | |
|
| dNullJoint (const dNullJoint &); | | dNullJointTemplate (const dNullJointTemplate<dJointTemplateBase, dWorldTe | |
| void operator = (const dNullJoint &); | | mplateBase, dBodyTemplateBase> &); | |
| | | void operator = (const dNullJointTemplate<dJointTemplateBase, dWorldTempl | |
| | | ateBase, dBodyTemplateBase> &); | |
| | | | |
| | | protected: | |
| | | typedef dJointTemplate<dJointTemplateBase, dWorldTemplateBase, dBodyTempl | |
| | | ateBase> dBaseTemplate; | |
| | | | |
| | | dJointID get_id() const { return dBaseTemplate::get_id(); } | |
| | | void set_id(dJointID value) { dBaseTemplate::set_id(value); } | |
| | | | |
| | | void destroy() { dBaseTemplate::destroy(); } | |
| | | | |
| public: | | public: | |
|
| dNullJoint() { } | | dNullJointTemplate() { } | |
| dNullJoint (dWorldID world, dJointGroupID group=0) | | dNullJointTemplate (dWorldID world, dJointGroupID group=0) | |
| { _id = dJointCreateNull (world, group); } | | { set_id(dJointCreateNull(world, group)); } | |
| dNullJoint (dWorld& world, dJointGroupID group=0) | | dNullJointTemplate (dWorldTemplate<dWorldTemplateBase>& world, dJointGrou | |
| { _id = dJointCreateNull (world.id(), group); } | | pID group=0) | |
| | | { set_id(dJointCreateNull (world.id(), group)); } | |
| | | | |
| void create (dWorldID world, dJointGroupID group=0) { | | void create (dWorldID world, dJointGroupID group=0) { | |
|
| if (_id) dJointDestroy (_id); | | destroy(); | |
| _id = dJointCreateNull (world, group); | | set_id(dJointCreateNull(world, group)); | |
| } | | } | |
|
| void create (dWorld& world, dJointGroupID group=0) | | void create (dWorldTemplate<dWorldTemplateBase>& world, dJointGroupID gro
up=0) | |
| { create(world.id(), group); } | | { create(world.id(), group); } | |
| }; | | }; | |
| | | | |
|
| class dAMotorJoint : public dJoint { | | template <class dJointTemplateBase, class dWorldTemplateBase, class dBodyTe | |
| | | mplateBase> | |
| | | class dAMotorJointTemplate : public dJointTemplate<dJointTemplateBase, dWor | |
| | | ldTemplateBase, dBodyTemplateBase> { | |
| | | private: | |
| // intentionally undefined, don't use these | | // intentionally undefined, don't use these | |
|
| dAMotorJoint (const dAMotorJoint &); | | dAMotorJointTemplate (const dAMotorJointTemplate<dJointTemplateBase, dWor | |
| void operator = (const dAMotorJoint &); | | ldTemplateBase, dBodyTemplateBase> &); | |
| | | void operator = (const dAMotorJointTemplate<dJointTemplateBase, dWorldTem | |
| | | plateBase, dBodyTemplateBase> &); | |
| | | | |
| | | protected: | |
| | | typedef dJointTemplate<dJointTemplateBase, dWorldTemplateBase, dBodyTempl | |
| | | ateBase> dBaseTemplate; | |
| | | | |
| | | dJointID get_id() const { return dBaseTemplate::get_id(); } | |
| | | void set_id(dJointID value) { dBaseTemplate::set_id(value); } | |
| | | | |
| | | void destroy() { dBaseTemplate::destroy(); } | |
| | | | |
| public: | | public: | |
|
| dAMotorJoint() { } | | dAMotorJointTemplate() { } | |
| dAMotorJoint (dWorldID world, dJointGroupID group=0) | | dAMotorJointTemplate (dWorldID world, dJointGroupID group=0) | |
| { _id = dJointCreateAMotor (world, group); } | | { set_id(dJointCreateAMotor(world, group)); } | |
| dAMotorJoint (dWorld& world, dJointGroupID group=0) | | dAMotorJointTemplate (dWorldTemplate<dWorldTemplateBase>& world, dJointGr | |
| { _id = dJointCreateAMotor (world.id(), group); } | | oupID group=0) | |
| | | { set_id(dJointCreateAMotor(world.id(), group)); } | |
| | | | |
| void create (dWorldID world, dJointGroupID group=0) { | | void create (dWorldID world, dJointGroupID group=0) { | |
|
| if (_id) dJointDestroy (_id); | | destroy(); | |
| _id = dJointCreateAMotor (world, group); | | set_id(dJointCreateAMotor(world, group)); | |
| } | | } | |
|
| void create (dWorld& world, dJointGroupID group=0) | | void create (dWorldTemplate<dWorldTemplateBase>& world, dJointGroupID gro
up=0) | |
| { create(world.id(), group); } | | { create(world.id(), group); } | |
| | | | |
| void setMode (int mode) | | void setMode (int mode) | |
|
| { dJointSetAMotorMode (_id, mode); } | | { dJointSetAMotorMode (get_id(), mode); } | |
| int getMode() const | | int getMode() const | |
|
| { return dJointGetAMotorMode (_id); } | | { return dJointGetAMotorMode (get_id()); } | |
| | | | |
| void setNumAxes (int num) | | void setNumAxes (int num) | |
|
| { dJointSetAMotorNumAxes (_id, num); } | | { dJointSetAMotorNumAxes (get_id(), num); } | |
| int getNumAxes() const | | int getNumAxes() const | |
|
| { return dJointGetAMotorNumAxes (_id); } | | { return dJointGetAMotorNumAxes (get_id()); } | |
| | | | |
| void setAxis (int anum, int rel, dReal x, dReal y, dReal z) | | void setAxis (int anum, int rel, dReal x, dReal y, dReal z) | |
|
| { dJointSetAMotorAxis (_id, anum, rel, x, y, z); } | | { dJointSetAMotorAxis (get_id(), anum, rel, x, y, z); } | |
| void setAxis (int anum, int rel, const dVector3 a) | | void setAxis (int anum, int rel, const dVector3 a) | |
| { setAxis(anum, rel, a[0], a[1], a[2]); } | | { setAxis(anum, rel, a[0], a[1], a[2]); } | |
| void getAxis (int anum, dVector3 result) const | | void getAxis (int anum, dVector3 result) const | |
|
| { dJointGetAMotorAxis (_id, anum, result); } | | { dJointGetAMotorAxis (get_id(), anum, result); } | |
| int getAxisRel (int anum) const | | int getAxisRel (int anum) const | |
|
| { return dJointGetAMotorAxisRel (_id, anum); } | | { return dJointGetAMotorAxisRel (get_id(), anum); } | |
| | | | |
| void setAngle (int anum, dReal angle) | | void setAngle (int anum, dReal angle) | |
|
| { dJointSetAMotorAngle (_id, anum, angle); } | | { dJointSetAMotorAngle (get_id(), anum, angle); } | |
| dReal getAngle (int anum) const | | dReal getAngle (int anum) const | |
|
| { return dJointGetAMotorAngle (_id, anum); } | | { return dJointGetAMotorAngle (get_id(), anum); } | |
| dReal getAngleRate (int anum) | | dReal getAngleRate (int anum) | |
|
| { return dJointGetAMotorAngleRate (_id,anum); } | | { return dJointGetAMotorAngleRate (get_id(), anum); } | |
| | | | |
| void setParam (int parameter, dReal value) | | void setParam (int parameter, dReal value) | |
|
| { dJointSetAMotorParam (_id, parameter, value); } | | { dJointSetAMotorParam (get_id(), parameter, value); } | |
| dReal getParam (int parameter) const | | dReal getParam (int parameter) const | |
|
| { return dJointGetAMotorParam (_id, parameter); } | | { return dJointGetAMotorParam (get_id(), parameter); } | |
| // TODO: expose params through methods | | // TODO: expose params through methods | |
| | | | |
| void addTorques(dReal torque1, dReal torque2, dReal torque3) | | void addTorques(dReal torque1, dReal torque2, dReal torque3) | |
|
| { dJointAddAMotorTorques(_id, torque1, torque2, torque3); } | | { dJointAddAMotorTorques(get_id(), torque1, torque2, torque3); } | |
| }; | | }; | |
| | | | |
|
| class dLMotorJoint : public dJoint { | | template <class dJointTemplateBase, class dWorldTemplateBase, class dBodyTe | |
| | | mplateBase> | |
| | | class dLMotorJointTemplate : public dJointTemplate<dJointTemplateBase, dWor | |
| | | ldTemplateBase, dBodyTemplateBase> { | |
| | | private: | |
| // intentionally undefined, don't use these | | // intentionally undefined, don't use these | |
|
| dLMotorJoint (const dLMotorJoint &); | | dLMotorJointTemplate (const dLMotorJointTemplate<dJointTemplateBase, dWor | |
| void operator = (const dLMotorJoint &); | | ldTemplateBase, dBodyTemplateBase> &); | |
| | | void operator = (const dLMotorJointTemplate<dJointTemplateBase, dWorldTem | |
| | | plateBase, dBodyTemplateBase> &); | |
| | | | |
| | | protected: | |
| | | typedef dJointTemplate<dJointTemplateBase, dWorldTemplateBase, dBodyTempl | |
| | | ateBase> dBaseTemplate; | |
| | | | |
| | | dJointID get_id() const { return dBaseTemplate::get_id(); } | |
| | | void set_id(dJointID value) { dBaseTemplate::set_id(value); } | |
| | | | |
| | | void destroy() { dBaseTemplate::destroy(); } | |
| | | | |
| public: | | public: | |
|
| dLMotorJoint() { } | | dLMotorJointTemplate() { } | |
| dLMotorJoint (dWorldID world, dJointGroupID group=0) | | dLMotorJointTemplate (dWorldID world, dJointGroupID group=0) | |
| { _id = dJointCreateLMotor (world, group); } | | { set_id(dJointCreateLMotor(world, group)); } | |
| dLMotorJoint (dWorld& world, dJointGroupID group=0) | | dLMotorJointTemplate (dWorldTemplate<dWorldTemplateBase>& world, dJointGr | |
| { _id = dJointCreateLMotor (world.id(), group); } | | oupID group=0) | |
| | | { set_id(dJointCreateLMotor(world.id(), group)); } | |
| | | | |
| void create (dWorldID world, dJointGroupID group=0) { | | void create (dWorldID world, dJointGroupID group=0) { | |
|
| if (_id) dJointDestroy (_id); | | destroy(); | |
| _id = dJointCreateLMotor (world, group); | | set_id(dJointCreateLMotor(world, group)); | |
| } | | } | |
|
| void create (dWorld& world, dJointGroupID group=0) | | void create (dWorldTemplate<dWorldTemplateBase>& world, dJointGroupID gro
up=0) | |
| { create(world.id(), group); } | | { create(world.id(), group); } | |
| | | | |
| void setNumAxes (int num) | | void setNumAxes (int num) | |
|
| { dJointSetLMotorNumAxes (_id, num); } | | { dJointSetLMotorNumAxes (get_id(), num); } | |
| int getNumAxes() const | | int getNumAxes() const | |
|
| { return dJointGetLMotorNumAxes (_id); } | | { return dJointGetLMotorNumAxes (get_id()); } | |
| | | | |
| void setAxis (int anum, int rel, dReal x, dReal y, dReal z) | | void setAxis (int anum, int rel, dReal x, dReal y, dReal z) | |
|
| { dJointSetLMotorAxis (_id, anum, rel, x, y, z); } | | { dJointSetLMotorAxis (get_id(), anum, rel, x, y, z); } | |
| void setAxis (int anum, int rel, const dVector3 a) | | void setAxis (int anum, int rel, const dVector3 a) | |
| { setAxis(anum, rel, a[0], a[1], a[2]); } | | { setAxis(anum, rel, a[0], a[1], a[2]); } | |
| void getAxis (int anum, dVector3 result) const | | void getAxis (int anum, dVector3 result) const | |
|
| { dJointGetLMotorAxis (_id, anum, result); } | | { dJointGetLMotorAxis (get_id(), anum, result); } | |
| | | | |
| void setParam (int parameter, dReal value) | | void setParam (int parameter, dReal value) | |
|
| { dJointSetLMotorParam (_id, parameter, value); } | | { dJointSetLMotorParam (get_id(), parameter, value); } | |
| dReal getParam (int parameter) const | | dReal getParam (int parameter) const | |
|
| { return dJointGetLMotorParam (_id, parameter); } | | { return dJointGetLMotorParam (get_id(), parameter); } | |
| // TODO: expose params through methods | | // TODO: expose params through methods | |
| }; | | }; | |
| | | | |
| //} | | //} | |
| | | | |
|
| | | #if !defined(dODECPP_WORLD_TEMPLATE_BASE) | |
| | | | |
| | | #if defined(dODECPP_BODY_TEMPLATE_BASE) || defined(dODECPP_JOINTGROUP_TEMPL | |
| | | ATE_BASE) || defined(dODECPP_JOINT_TEMPLATE_BASE) | |
| | | #error All the odecpp template bases must be defined or not defined togethe | |
| | | r | |
| | | #endif | |
| | | | |
| | | #define dODECPP_WORLD_TEMPLATE_BASE dWorldDynamicIDContainer | |
| | | #define dODECPP_BODY_TEMPLATE_BASE dBodyDynamicIDContainer | |
| | | #define dODECPP_JOINTGROUP_TEMPLATE_BASE dJointGroupDynamicIDContainer | |
| | | #define dODECPP_JOINT_TEMPLATE_BASE dJointDynamicIDContainer | |
| | | | |
| | | #else // #if defined(dODECPP_WORLD_TEMPLATE_BASE) | |
| | | | |
| | | #if !defined(dODECPP_BODY_TEMPLATE_BASE) || !defined(dODECPP_JOINTGROUP_TEM | |
| | | PLATE_BASE) || !defined(dODECPP_JOINT_TEMPLATE_BASE) | |
| | | #error All the odecpp template bases must be defined or not defined togethe | |
| | | r | |
| | | #endif | |
| | | | |
| | | #endif // #if defined(dODECPP_WORLD_TEMPLATE_BASE) | |
| | | | |
| | | typedef dWorldTemplate<dODECPP_WORLD_TEMPLATE_BASE> dWorld; | |
| | | typedef dBodyTemplate<dODECPP_BODY_TEMPLATE_BASE, dODECPP_WORLD_TEMPLATE_BA | |
| | | SE> dBody; | |
| | | typedef dJointGroupTemplate<dODECPP_JOINTGROUP_TEMPLATE_BASE> dJointGroup; | |
| | | typedef dJointTemplate<dODECPP_JOINT_TEMPLATE_BASE, dODECPP_WORLD_TEMPLATE_ | |
| | | BASE, dODECPP_BODY_TEMPLATE_BASE> dJoint; | |
| | | typedef dBallJointTemplate<dODECPP_JOINT_TEMPLATE_BASE, dODECPP_WORLD_TEMPL | |
| | | ATE_BASE, dODECPP_BODY_TEMPLATE_BASE> dBallJoint; | |
| | | typedef dHingeJointTemplate<dODECPP_JOINT_TEMPLATE_BASE, dODECPP_WORLD_TEMP | |
| | | LATE_BASE, dODECPP_BODY_TEMPLATE_BASE> dHingeJoint; | |
| | | typedef dSliderJointTemplate<dODECPP_JOINT_TEMPLATE_BASE, dODECPP_WORLD_TEM | |
| | | PLATE_BASE, dODECPP_BODY_TEMPLATE_BASE> dSliderJoint; | |
| | | typedef dUniversalJointTemplate<dODECPP_JOINT_TEMPLATE_BASE, dODECPP_WORLD_ | |
| | | TEMPLATE_BASE, dODECPP_BODY_TEMPLATE_BASE> dUniversalJoint; | |
| | | typedef dHinge2JointTemplate<dODECPP_JOINT_TEMPLATE_BASE, dODECPP_WORLD_TEM | |
| | | PLATE_BASE, dODECPP_BODY_TEMPLATE_BASE> dHinge2Joint; | |
| | | typedef dPRJointTemplate<dODECPP_JOINT_TEMPLATE_BASE, dODECPP_WORLD_TEMPLAT | |
| | | E_BASE, dODECPP_BODY_TEMPLATE_BASE> dPRJoint; | |
| | | typedef dPUJointTemplate<dODECPP_JOINT_TEMPLATE_BASE, dODECPP_WORLD_TEMPLAT | |
| | | E_BASE, dODECPP_BODY_TEMPLATE_BASE> dPUJoint; | |
| | | typedef dPistonJointTemplate<dODECPP_JOINT_TEMPLATE_BASE, dODECPP_WORLD_TEM | |
| | | PLATE_BASE, dODECPP_BODY_TEMPLATE_BASE> dPistonJoint; | |
| | | typedef dFixedJointTemplate<dODECPP_JOINT_TEMPLATE_BASE, dODECPP_WORLD_TEMP | |
| | | LATE_BASE, dODECPP_BODY_TEMPLATE_BASE> dFixedJoint; | |
| | | typedef dContactJointTemplate<dODECPP_JOINT_TEMPLATE_BASE, dODECPP_WORLD_TE | |
| | | MPLATE_BASE, dODECPP_BODY_TEMPLATE_BASE> dContactJoint; | |
| | | typedef dNullJointTemplate<dODECPP_JOINT_TEMPLATE_BASE, dODECPP_WORLD_TEMPL | |
| | | ATE_BASE, dODECPP_BODY_TEMPLATE_BASE> dNullJoint; | |
| | | typedef dAMotorJointTemplate<dODECPP_JOINT_TEMPLATE_BASE, dODECPP_WORLD_TEM | |
| | | PLATE_BASE, dODECPP_BODY_TEMPLATE_BASE> dAMotorJoint; | |
| | | typedef dLMotorJointTemplate<dODECPP_JOINT_TEMPLATE_BASE, dODECPP_WORLD_TEM | |
| | | PLATE_BASE, dODECPP_BODY_TEMPLATE_BASE> dLMotorJoint; | |
| | | | |
| #endif | | #endif | |
| #endif | | #endif | |
| | | | |
| // Local variables: | | // Local variables: | |
| // mode:c++ | | // mode:c++ | |
| // c-basic-offset:2 | | // c-basic-offset:2 | |
| // End: | | // End: | |
| | | | |
End of changes. 328 change blocks. |
| 435 lines changed or deleted | | 792 lines changed or added | |
|
| odemath.h | | odemath.h | |
| | | | |
| skipping to change at line 28 | | skipping to change at line 28 | |
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * | |
| * LICENSE.TXT and LICENSE-BSD.TXT for more details. * | | * LICENSE.TXT and LICENSE-BSD.TXT for more details. * | |
| * * | | * * | |
| *************************************************************************/ | | *************************************************************************/ | |
| | | | |
| #ifndef _ODE_ODEMATH_H_ | | #ifndef _ODE_ODEMATH_H_ | |
| #define _ODE_ODEMATH_H_ | | #define _ODE_ODEMATH_H_ | |
| | | | |
| #include <ode/common.h> | | #include <ode/common.h> | |
| | | | |
|
| #ifdef __GNUC__ | | | |
| #define PURE_INLINE extern inline | | | |
| #else | | | |
| #define PURE_INLINE inline | | | |
| #endif | | | |
| | | | |
| /* | | /* | |
| * macro to access elements i,j in an NxM matrix A, independent of the | | * macro to access elements i,j in an NxM matrix A, independent of the | |
| * matrix storage convention. | | * matrix storage convention. | |
| */ | | */ | |
| #define dACCESS33(A,i,j) ((A)[(i)*4+(j)]) | | #define dACCESS33(A,i,j) ((A)[(i)*4+(j)]) | |
| | | | |
| /* | | /* | |
| * Macro to test for valid floating point values | | * Macro to test for valid floating point values | |
| */ | | */ | |
| #define dVALIDVEC3(v) (!(dIsNan(v[0]) || dIsNan(v[1]) || dIsNan(v[2]))) | | #define dVALIDVEC3(v) (!(dIsNan(v[0]) || dIsNan(v[1]) || dIsNan(v[2]))) | |
| #define dVALIDVEC4(v) (!(dIsNan(v[0]) || dIsNan(v[1]) || dIsNan(v[2]) || dI
sNan(v[3]))) | | #define dVALIDVEC4(v) (!(dIsNan(v[0]) || dIsNan(v[1]) || dIsNan(v[2]) || dI
sNan(v[3]))) | |
| #define dVALIDMAT3(m) (!(dIsNan(m[0]) || dIsNan(m[1]) || dIsNan(m[2]) || dI
sNan(m[3]) || dIsNan(m[4]) || dIsNan(m[5]) || dIsNan(m[6]) || dIsNan(m[7])
|| dIsNan(m[8]) || dIsNan(m[9]) || dIsNan(m[10]) || dIsNan(m[11]))) | | #define dVALIDMAT3(m) (!(dIsNan(m[0]) || dIsNan(m[1]) || dIsNan(m[2]) || dI
sNan(m[3]) || dIsNan(m[4]) || dIsNan(m[5]) || dIsNan(m[6]) || dIsNan(m[7])
|| dIsNan(m[8]) || dIsNan(m[9]) || dIsNan(m[10]) || dIsNan(m[11]))) | |
| #define dVALIDMAT4(m) (!(dIsNan(m[0]) || dIsNan(m[1]) || dIsNan(m[2]) || dI
sNan(m[3]) || dIsNan(m[4]) || dIsNan(m[5]) || dIsNan(m[6]) || dIsNan(m[7])
|| dIsNan(m[8]) || dIsNan(m[9]) || dIsNan(m[10]) || dIsNan(m[11]) || dIsNan
(m[12]) || dIsNan(m[13]) || dIsNan(m[14]) || dIsNan(m[15]) )) | | #define dVALIDMAT4(m) (!(dIsNan(m[0]) || dIsNan(m[1]) || dIsNan(m[2]) || dI
sNan(m[3]) || dIsNan(m[4]) || dIsNan(m[5]) || dIsNan(m[6]) || dIsNan(m[7])
|| dIsNan(m[8]) || dIsNan(m[9]) || dIsNan(m[10]) || dIsNan(m[11]) || dIsNan
(m[12]) || dIsNan(m[13]) || dIsNan(m[14]) || dIsNan(m[15]) )) | |
| | | | |
|
| /* | | // Some vector math | |
| * General purpose vector operations with other vectors or constants. | | PURE_INLINE void dAddVectors3(dReal *res, const dReal *a, const dReal *b) | |
| */ | | { | |
| | | dReal res_0, res_1, res_2; | |
| | | res_0 = a[0] + b[0]; | |
| | | res_1 = a[1] + b[1]; | |
| | | res_2 = a[2] + b[2]; | |
| | | // Only assign after all the calculations are over to avoid incurring mem | |
| | | ory aliasing | |
| | | res[0] = res_0; res[1] = res_1; res[2] = res_2; | |
| | | } | |
| | | | |
|
| #define dOP(a,op,b,c) do { \ | | PURE_INLINE void dSubtractVectors3(dReal *res, const dReal *a, const dReal | |
| (a)[0] = ((b)[0]) op ((c)[0]); \ | | *b) | |
| (a)[1] = ((b)[1]) op ((c)[1]); \ | | { | |
| (a)[2] = ((b)[2]) op ((c)[2]); \ | | dReal res_0, res_1, res_2; | |
| } while (0) | | res_0 = a[0] - b[0]; | |
| #define dOPC(a,op,b,c) do { \ | | res_1 = a[1] - b[1]; | |
| (a)[0] = ((b)[0]) op (c); \ | | res_2 = a[2] - b[2]; | |
| (a)[1] = ((b)[1]) op (c); \ | | // Only assign after all the calculations are over to avoid incurring mem | |
| (a)[2] = ((b)[2]) op (c); \ | | ory aliasing | |
| } while (0) | | res[0] = res_0; res[1] = res_1; res[2] = res_2; | |
| #define dOPE(a,op,b) do {\ | | } | |
| (a)[0] op ((b)[0]); \ | | | |
| (a)[1] op ((b)[1]); \ | | | |
| (a)[2] op ((b)[2]); \ | | | |
| } while (0) | | | |
| #define dOPEC(a,op,c) do { \ | | | |
| (a)[0] op (c); \ | | | |
| (a)[1] op (c); \ | | | |
| (a)[2] op (c); \ | | | |
| } while (0) | | | |
| | | | |
| /// Define an equation with operatos | | | |
| /// For example this function can be used to replace | | | |
| /// <PRE> | | | |
| /// for (int i=0; i<3; ++i) | | | |
| /// a[i] += b[i] + c[i]; | | | |
| /// </PRE> | | | |
| #define dOPE2(a,op1,b,op2,c) do { \ | | | |
| (a)[0] op1 ((b)[0]) op2 ((c)[0]); \ | | | |
| (a)[1] op1 ((b)[1]) op2 ((c)[1]); \ | | | |
| (a)[2] op1 ((b)[2]) op2 ((c)[2]); \ | | | |
| } while (0) | | | |
| | | | |
|
| /* | | PURE_INLINE void dAddScaledVectors3(dReal *res, const dReal *a, const dReal | |
| * Length, and squared length helpers. dLENGTH returns the length of a dVec | | *b, dReal a_scale, dReal b_scale) | |
| tor3. | | { | |
| * dLENGTHSQUARED return the squared length of a dVector3. | | dReal res_0, res_1, res_2; | |
| */ | | res_0 = a_scale * a[0] + b_scale * b[0]; | |
| | | res_1 = a_scale * a[1] + b_scale * b[1]; | |
| | | res_2 = a_scale * a[2] + b_scale * b[2]; | |
| | | // Only assign after all the calculations are over to avoid incurring mem | |
| | | ory aliasing | |
| | | res[0] = res_0; res[1] = res_1; res[2] = res_2; | |
| | | } | |
| | | | |
|
| #define dLENGTHSQUARED(a) (((a)[0])*((a)[0]) + ((a)[1])*((a)[1]) + ((a)[2]) | | PURE_INLINE void dScaleVector3(dReal *res, dReal nScale) | |
| *((a)[2])) | | { | |
| | | res[0] *= nScale ; | |
| | | res[1] *= nScale ; | |
| | | res[2] *= nScale ; | |
| | | } | |
| | | | |
|
| #ifdef __cplusplus | | PURE_INLINE void dNegateVector3(dReal *res) | |
| | | { | |
| | | res[0] = -res[0]; | |
| | | res[1] = -res[1]; | |
| | | res[2] = -res[2]; | |
| | | } | |
| | | | |
|
| PURE_INLINE dReal dLENGTH (const dReal *a) { return dSqrt(dLENGTHSQUARED(a) | | PURE_INLINE void dCopyVector3(dReal *res, const dReal *a) | |
| ); } | | { | |
| | | dReal res_0, res_1, res_2; | |
| | | res_0 = a[0]; | |
| | | res_1 = a[1]; | |
| | | res_2 = a[2]; | |
| | | // Only assign after all the calculations are over to avoid incurring mem | |
| | | ory aliasing | |
| | | res[0] = res_0; res[1] = res_1; res[2] = res_2; | |
| | | } | |
| | | | |
|
| #else | | PURE_INLINE void dCopyScaledVector3(dReal *res, const dReal *a, dReal nScal | |
| | | e) | |
| | | { | |
| | | dReal res_0, res_1, res_2; | |
| | | res_0 = a[0] * nScale; | |
| | | res_1 = a[1] * nScale; | |
| | | res_2 = a[2] * nScale; | |
| | | // Only assign after all the calculations are over to avoid incurring mem | |
| | | ory aliasing | |
| | | res[0] = res_0; res[1] = res_1; res[2] = res_2; | |
| | | } | |
| | | | |
|
| #define dLENGTH(a) ( dSqrt( ((a)[0])*((a)[0]) + ((a)[1])*((a)[1]) + ((a)[2] | | PURE_INLINE void dCopyNegatedVector3(dReal *res, const dReal *a) | |
| )*((a)[2]) ) ) | | { | |
| | | dReal res_0, res_1, res_2; | |
| | | res_0 = -a[0]; | |
| | | res_1 = -a[1]; | |
| | | res_2 = -a[2]; | |
| | | // Only assign after all the calculations are over to avoid incurring mem | |
| | | ory aliasing | |
| | | res[0] = res_0; res[1] = res_1; res[2] = res_2; | |
| | | } | |
| | | | |
|
| #endif /* __cplusplus */ | | PURE_INLINE void dCopyVector4(dReal *res, const dReal *a) | |
| | | { | |
| | | dReal res_0, res_1, res_2, res_3; | |
| | | res_0 = a[0]; | |
| | | res_1 = a[1]; | |
| | | res_2 = a[2]; | |
| | | res_3 = a[3]; | |
| | | // Only assign after all the calculations are over to avoid incurring mem | |
| | | ory aliasing | |
| | | res[0] = res_0; res[1] = res_1; res[2] = res_2; res[3] = res_3; | |
| | | } | |
| | | | |
|
| /* | | PURE_INLINE void dCopyMatrix4x4(dReal *res, const dReal *a) | |
| * 3-way dot product. dDOTpq means that elements of `a' and `b' are spaced | | { | |
| * p and q indexes apart respectively. dDOT() means dDOT11. | | dCopyVector4(res + 0, a + 0); | |
| * in C++ we could use function templates to get all the versions of these | | dCopyVector4(res + 4, a + 4); | |
| * functions - but on some compilers this will result in sub-optimal code. | | dCopyVector4(res + 8, a + 8); | |
| */ | | } | |
| | | | |
|
| #define dDOTpq(a,b,p,q) ((a)[0]*(b)[0] + (a)[p]*(b)[q] + (a)[2*(p)]*(b)[2*( | | PURE_INLINE void dCopyMatrix4x3(dReal *res, const dReal *a) | |
| q)]) | | { | |
| | | dCopyVector3(res + 0, a + 0); | |
| | | dCopyVector3(res + 4, a + 4); | |
| | | dCopyVector3(res + 8, a + 8); | |
| | | } | |
| | | | |
|
| #ifdef __cplusplus | | PURE_INLINE void dGetMatrixColumn3(dReal *res, const dReal *a, unsigned n) | |
| | | { | |
| | | dReal res_0, res_1, res_2; | |
| | | res_0 = a[n + 0]; | |
| | | res_1 = a[n + 4]; | |
| | | res_2 = a[n + 8]; | |
| | | // Only assign after all the calculations are over to avoid incurring mem | |
| | | ory aliasing | |
| | | res[0] = res_0; res[1] = res_1; res[2] = res_2; | |
| | | } | |
| | | | |
| | | PURE_INLINE dReal dCalcVectorLength3(const dReal *a) | |
| | | { | |
| | | return dSqrt(a[0] * a[0] + a[1] * a[1] + a[2] * a[2]); | |
| | | } | |
| | | | |
| | | PURE_INLINE dReal dCalcVectorLengthSquare3(const dReal *a) | |
| | | { | |
| | | return (a[0] * a[0] + a[1] * a[1] + a[2] * a[2]); | |
| | | } | |
| | | | |
|
| PURE_INLINE dReal dDOT (const dReal *a, const dReal *b) { return dDOTpq(a | | PURE_INLINE dReal dCalcPointDepth3(const dReal *test_p, const dReal *plane_ | |
| ,b,1,1); } | | p, const dReal *plane_n) | |
| PURE_INLINE dReal dDOT13 (const dReal *a, const dReal *b) { return dDOTpq(a | | { | |
| ,b,1,3); } | | return (plane_p[0] - test_p[0]) * plane_n[0] + (plane_p[1] - test_p[1]) * | |
| PURE_INLINE dReal dDOT31 (const dReal *a, const dReal *b) { return dDOTpq(a | | plane_n[1] + (plane_p[2] - test_p[2]) * plane_n[2]; | |
| ,b,3,1); } | | } | |
| PURE_INLINE dReal dDOT33 (const dReal *a, const dReal *b) { return dDOTpq(a | | | |
| ,b,3,3); } | | /* | |
| PURE_INLINE dReal dDOT14 (const dReal *a, const dReal *b) { return dDOTpq(a | | * 3-way dot product. _dCalcVectorDot3 means that elements of `a' and `b' ar | |
| ,b,1,4); } | | e spaced | |
| PURE_INLINE dReal dDOT41 (const dReal *a, const dReal *b) { return dDOTpq(a | | * step_a and step_b indexes apart respectively. dCalcVectorDot3() means dDo | |
| ,b,4,1); } | | t311. | |
| PURE_INLINE dReal dDOT44 (const dReal *a, const dReal *b) { return dDOTpq(a | | */ | |
| ,b,4,4); } | | | |
| | | PURE_INLINE dReal _dCalcVectorDot3(const dReal *a, const dReal *b, unsigned | |
| #else | | step_a, unsigned step_b) | |
| | | { | |
| #define dDOT(a,b) dDOTpq(a,b,1,1) | | return a[0] * b[0] + a[step_a] * b[step_b] + a[2 * step_a] * b[2 * step_b | |
| #define dDOT13(a,b) dDOTpq(a,b,1,3) | | ]; | |
| #define dDOT31(a,b) dDOTpq(a,b,3,1) | | } | |
| #define dDOT33(a,b) dDOTpq(a,b,3,3) | | | |
| #define dDOT14(a,b) dDOTpq(a,b,1,4) | | | |
| #define dDOT41(a,b) dDOTpq(a,b,4,1) | | | |
| #define dDOT44(a,b) dDOTpq(a,b,4,4) | | | |
| | | | |
|
| #endif /* __cplusplus */ | | PURE_INLINE dReal dCalcVectorDot3 (const dReal *a, const dReal *b) { ret | |
| | | urn _dCalcVectorDot3(a,b,1,1); } | |
| | | PURE_INLINE dReal dCalcVectorDot3_13 (const dReal *a, const dReal *b) { ret | |
| | | urn _dCalcVectorDot3(a,b,1,3); } | |
| | | PURE_INLINE dReal dCalcVectorDot3_31 (const dReal *a, const dReal *b) { ret | |
| | | urn _dCalcVectorDot3(a,b,3,1); } | |
| | | PURE_INLINE dReal dCalcVectorDot3_33 (const dReal *a, const dReal *b) { ret | |
| | | urn _dCalcVectorDot3(a,b,3,3); } | |
| | | PURE_INLINE dReal dCalcVectorDot3_14 (const dReal *a, const dReal *b) { ret | |
| | | urn _dCalcVectorDot3(a,b,1,4); } | |
| | | PURE_INLINE dReal dCalcVectorDot3_41 (const dReal *a, const dReal *b) { ret | |
| | | urn _dCalcVectorDot3(a,b,4,1); } | |
| | | PURE_INLINE dReal dCalcVectorDot3_44 (const dReal *a, const dReal *b) { ret | |
| | | urn _dCalcVectorDot3(a,b,4,4); } | |
| | | | |
| /* | | /* | |
|
| * cross product, set a = b x c. dCROSSpqr means that elements of `a', `b' | | * cross product, set res = a x b. _dCalcVectorCross3 means that elements o | |
| * and `c' are spaced p, q and r indexes apart respectively. | | f `res', `a' | |
| * dCROSS() means dCROSS111. `op' is normally `=', but you can set it to | | * and `b' are spaced step_res, step_a and step_b indexes apart respectivel | |
| * +=, -= etc to get other effects. | | y. | |
| | | * dCalcVectorCross3() means dCross3111. | |
| */ | | */ | |
| | | | |
|
| #define dCROSS(a,op,b,c) \ | | PURE_INLINE void _dCalcVectorCross3(dReal *res, const dReal *a, const dReal | |
| do { \ | | *b, unsigned step_res, unsigned step_a, unsigned step_b) | |
| (a)[0] op ((b)[1]*(c)[2] - (b)[2]*(c)[1]); \ | | { | |
| (a)[1] op ((b)[2]*(c)[0] - (b)[0]*(c)[2]); \ | | dReal res_0, res_1, res_2; | |
| (a)[2] op ((b)[0]*(c)[1] - (b)[1]*(c)[0]); \ | | res_0 = a[ step_a]*b[2*step_b] - a[2*step_a]*b[ step_b]; | |
| } while(0) | | res_1 = a[2*step_a]*b[ 0] - a[ 0]*b[2*step_b]; | |
| #define dCROSSpqr(a,op,b,c,p,q,r) \ | | res_2 = a[ 0]*b[ step_b] - a[ step_a]*b[ 0]; | |
| do { \ | | // Only assign after all the calculations are over to avoid incurring mem | |
| (a)[ 0] op ((b)[ q]*(c)[2*r] - (b)[2*q]*(c)[ r]); \ | | ory aliasing | |
| (a)[ p] op ((b)[2*q]*(c)[ 0] - (b)[ 0]*(c)[2*r]); \ | | res[ 0] = res_0; | |
| (a)[2*p] op ((b)[ 0]*(c)[ r] - (b)[ q]*(c)[ 0]); \ | | res[ step_res] = res_1; | |
| } while(0) | | res[2*step_res] = res_2; | |
| #define dCROSS114(a,op,b,c) dCROSSpqr(a,op,b,c,1,1,4) | | } | |
| #define dCROSS141(a,op,b,c) dCROSSpqr(a,op,b,c,1,4,1) | | | |
| #define dCROSS144(a,op,b,c) dCROSSpqr(a,op,b,c,1,4,4) | | PURE_INLINE void dCalcVectorCross3 (dReal *res, const dReal *a, const dR | |
| #define dCROSS411(a,op,b,c) dCROSSpqr(a,op,b,c,4,1,1) | | eal *b) { _dCalcVectorCross3(res, a, b, 1, 1, 1); } | |
| #define dCROSS414(a,op,b,c) dCROSSpqr(a,op,b,c,4,1,4) | | PURE_INLINE void dCalcVectorCross3_114(dReal *res, const dReal *a, const dR | |
| #define dCROSS441(a,op,b,c) dCROSSpqr(a,op,b,c,4,4,1) | | eal *b) { _dCalcVectorCross3(res, a, b, 1, 1, 4); } | |
| #define dCROSS444(a,op,b,c) dCROSSpqr(a,op,b,c,4,4,4) | | PURE_INLINE void dCalcVectorCross3_141(dReal *res, const dReal *a, const dR | |
| | | eal *b) { _dCalcVectorCross3(res, a, b, 1, 4, 1); } | |
| | | PURE_INLINE void dCalcVectorCross3_144(dReal *res, const dReal *a, const dR | |
| | | eal *b) { _dCalcVectorCross3(res, a, b, 1, 4, 4); } | |
| | | PURE_INLINE void dCalcVectorCross3_411(dReal *res, const dReal *a, const dR | |
| | | eal *b) { _dCalcVectorCross3(res, a, b, 4, 1, 1); } | |
| | | PURE_INLINE void dCalcVectorCross3_414(dReal *res, const dReal *a, const dR | |
| | | eal *b) { _dCalcVectorCross3(res, a, b, 4, 1, 4); } | |
| | | PURE_INLINE void dCalcVectorCross3_441(dReal *res, const dReal *a, const dR | |
| | | eal *b) { _dCalcVectorCross3(res, a, b, 4, 4, 1); } | |
| | | PURE_INLINE void dCalcVectorCross3_444(dReal *res, const dReal *a, const dR | |
| | | eal *b) { _dCalcVectorCross3(res, a, b, 4, 4, 4); } | |
| | | | |
| | | PURE_INLINE void dAddVectorCross3(dReal *res, const dReal *a, const dReal * | |
| | | b) | |
| | | { | |
| | | dReal tmp[3]; | |
| | | dCalcVectorCross3(tmp, a, b); | |
| | | dAddVectors3(res, res, tmp); | |
| | | } | |
| | | | |
| | | PURE_INLINE void dSubtractVectorCross3(dReal *res, const dReal *a, const dR | |
| | | eal *b) | |
| | | { | |
| | | dReal tmp[3]; | |
| | | dCalcVectorCross3(tmp, a, b); | |
| | | dSubtractVectors3(res, res, tmp); | |
| | | } | |
| | | | |
| /* | | /* | |
| * set a 3x3 submatrix of A to a matrix such that submatrix(A)*b = a x b. | | * set a 3x3 submatrix of A to a matrix such that submatrix(A)*b = a x b. | |
| * A is stored by rows, and has `skip' elements per row. the matrix is | | * A is stored by rows, and has `skip' elements per row. the matrix is | |
| * assumed to be already zero, so this does not write zero elements! | | * assumed to be already zero, so this does not write zero elements! | |
| * if (plus,minus) is (+,-) then a positive version will be written. | | * if (plus,minus) is (+,-) then a positive version will be written. | |
| * if (plus,minus) is (-,+) then a negative version will be written. | | * if (plus,minus) is (-,+) then a negative version will be written. | |
| */ | | */ | |
| | | | |
|
| #define dCROSSMAT(A,a,skip,plus,minus) \ | | PURE_INLINE void dSetCrossMatrixPlus(dReal *res, const dReal *a, unsigned s | |
| do { \ | | kip) | |
| (A)[1] = minus (a)[2]; \ | | { | |
| (A)[2] = plus (a)[1]; \ | | const dReal a_0 = a[0], a_1 = a[1], a_2 = a[2]; | |
| (A)[(skip)+0] = plus (a)[2]; \ | | res[1] = -a_2; | |
| (A)[(skip)+2] = minus (a)[0]; \ | | res[2] = +a_1; | |
| (A)[2*(skip)+0] = minus (a)[1]; \ | | res[skip+0] = +a_2; | |
| (A)[2*(skip)+1] = plus (a)[0]; \ | | res[skip+2] = -a_0; | |
| } while(0) | | res[2*skip+0] = -a_1; | |
| | | res[2*skip+1] = +a_0; | |
| | | } | |
| | | | |
| | | PURE_INLINE void dSetCrossMatrixMinus(dReal *res, const dReal *a, unsigned | |
| | | skip) | |
| | | { | |
| | | const dReal a_0 = a[0], a_1 = a[1], a_2 = a[2]; | |
| | | res[1] = +a_2; | |
| | | res[2] = -a_1; | |
| | | res[skip+0] = -a_2; | |
| | | res[skip+2] = +a_0; | |
| | | res[2*skip+0] = +a_1; | |
| | | res[2*skip+1] = -a_0; | |
| | | } | |
| | | | |
| /* | | /* | |
| * compute the distance between two 3D-vectors | | * compute the distance between two 3D-vectors | |
| */ | | */ | |
| | | | |
|
| #ifdef __cplusplus | | PURE_INLINE dReal dCalcPointsDistance3(const dReal *a, const dReal *b) | |
| PURE_INLINE dReal dDISTANCE (const dVector3 a, const dVector3 b) | | { | |
| { return dSqrt( (a[0]-b[0])*(a[0]-b[0]) + (a[1]-b[1])*(a[1]-b[1]) + | | dReal res; | |
| (a[2]-b[2])*(a[2]-b[2]) ); } | | dReal tmp[3]; | |
| #else | | dSubtractVectors3(tmp, a, b); | |
| #define dDISTANCE(a,b) \ | | res = dCalcVectorLength3(tmp); | |
| (dSqrt( ((a)[0]-(b)[0])*((a)[0]-(b)[0]) + ((a)[1]-(b)[1])*((a)[1]-(b | | return res; | |
| )[1]) + ((a)[2]-(b)[2])*((a)[2]-(b)[2]) )) | | } | |
| #endif | | | |
| | | | |
| /* | | /* | |
|
| * special case matrix multipication, with operator selection | | * special case matrix multiplication, with operator selection | |
| */ | | */ | |
| | | | |
|
| #define dMULTIPLYOP0_331(A,op,B,C) \ | | PURE_INLINE void dMultiplyHelper0_331(dReal *res, const dReal *a, const dRe | |
| do { \ | | al *b) | |
| (A)[0] op dDOT((B),(C)); \ | | { | |
| (A)[1] op dDOT((B+4),(C)); \ | | dReal res_0, res_1, res_2; | |
| (A)[2] op dDOT((B+8),(C)); \ | | res_0 = dCalcVectorDot3(a, b); | |
| } while(0) | | res_1 = dCalcVectorDot3(a + 4, b); | |
| #define dMULTIPLYOP1_331(A,op,B,C) \ | | res_2 = dCalcVectorDot3(a + 8, b); | |
| do { \ | | // Only assign after all the calculations are over to avoid incurring mem | |
| (A)[0] op dDOT41((B),(C)); \ | | ory aliasing | |
| (A)[1] op dDOT41((B+1),(C)); \ | | res[0] = res_0; res[1] = res_1; res[2] = res_2; | |
| (A)[2] op dDOT41((B+2),(C)); \ | | } | |
| } while(0) | | | |
| #define dMULTIPLYOP0_133(A,op,B,C) \ | | PURE_INLINE void dMultiplyHelper1_331(dReal *res, const dReal *a, const dRe | |
| do { \ | | al *b) | |
| (A)[0] op dDOT14((B),(C)); \ | | { | |
| (A)[1] op dDOT14((B),(C+1)); \ | | dReal res_0, res_1, res_2; | |
| (A)[2] op dDOT14((B),(C+2)); \ | | res_0 = dCalcVectorDot3_41(a, b); | |
| } while(0) | | res_1 = dCalcVectorDot3_41(a + 1, b); | |
| #define dMULTIPLYOP0_333(A,op,B,C) \ | | res_2 = dCalcVectorDot3_41(a + 2, b); | |
| do { \ | | // Only assign after all the calculations are over to avoid incurring mem | |
| (A)[0] op dDOT14((B),(C)); \ | | ory aliasing | |
| (A)[1] op dDOT14((B),(C+1)); \ | | res[0] = res_0; res[1] = res_1; res[2] = res_2; | |
| (A)[2] op dDOT14((B),(C+2)); \ | | } | |
| (A)[4] op dDOT14((B+4),(C)); \ | | | |
| (A)[5] op dDOT14((B+4),(C+1)); \ | | | |
| (A)[6] op dDOT14((B+4),(C+2)); \ | | | |
| (A)[8] op dDOT14((B+8),(C)); \ | | | |
| (A)[9] op dDOT14((B+8),(C+1)); \ | | | |
| (A)[10] op dDOT14((B+8),(C+2)); \ | | | |
| } while(0) | | | |
| #define dMULTIPLYOP1_333(A,op,B,C) \ | | | |
| do { \ | | | |
| (A)[0] op dDOT44((B),(C)); \ | | | |
| (A)[1] op dDOT44((B),(C+1)); \ | | | |
| (A)[2] op dDOT44((B),(C+2)); \ | | | |
| (A)[4] op dDOT44((B+1),(C)); \ | | | |
| (A)[5] op dDOT44((B+1),(C+1)); \ | | | |
| (A)[6] op dDOT44((B+1),(C+2)); \ | | | |
| (A)[8] op dDOT44((B+2),(C)); \ | | | |
| (A)[9] op dDOT44((B+2),(C+1)); \ | | | |
| (A)[10] op dDOT44((B+2),(C+2)); \ | | | |
| } while(0) | | | |
| #define dMULTIPLYOP2_333(A,op,B,C) \ | | | |
| do { \ | | | |
| (A)[0] op dDOT((B),(C)); \ | | | |
| (A)[1] op dDOT((B),(C+4)); \ | | | |
| (A)[2] op dDOT((B),(C+8)); \ | | | |
| (A)[4] op dDOT((B+4),(C)); \ | | | |
| (A)[5] op dDOT((B+4),(C+4)); \ | | | |
| (A)[6] op dDOT((B+4),(C+8)); \ | | | |
| (A)[8] op dDOT((B+8),(C)); \ | | | |
| (A)[9] op dDOT((B+8),(C+4)); \ | | | |
| (A)[10] op dDOT((B+8),(C+8)); \ | | | |
| } while(0) | | | |
| | | | |
|
| #ifdef __cplusplus | | PURE_INLINE void dMultiplyHelper0_133(dReal *res, const dReal *a, const dRe | |
| | | al *b) | |
| | | { | |
| | | dMultiplyHelper1_331(res, b, a); | |
| | | } | |
| | | | |
|
| #define DECL template <class TA, class TB, class TC> PURE_INLINE void | | PURE_INLINE void dMultiplyHelper1_133(dReal *res, const dReal *a, const dRe | |
| | | al *b) | |
| | | { | |
| | | dReal res_0, res_1, res_2; | |
| | | res_0 = dCalcVectorDot3_44(a, b); | |
| | | res_1 = dCalcVectorDot3_44(a + 1, b); | |
| | | res_2 = dCalcVectorDot3_44(a + 2, b); | |
| | | // Only assign after all the calculations are over to avoid incurring mem | |
| | | ory aliasing | |
| | | res[0] = res_0; res[1] = res_1; res[2] = res_2; | |
| | | } | |
| | | | |
| /* | | /* | |
| Note: NEVER call any of these functions/macros with the same variable for A
and C, | | Note: NEVER call any of these functions/macros with the same variable for A
and C, | |
| it is not equivalent to A*=B. | | it is not equivalent to A*=B. | |
| */ | | */ | |
| | | | |
|
| DECL dMULTIPLY0_331(TA *A, const TB *B, const TC *C) { dMULTIPLYOP0_331(A,= | | PURE_INLINE void dMultiply0_331(dReal *res, const dReal *a, const dReal *b) | |
| ,B,C); } | | { | |
| DECL dMULTIPLY1_331(TA *A, const TB *B, const TC *C) { dMULTIPLYOP1_331(A,= | | dMultiplyHelper0_331(res, a, b); | |
| ,B,C); } | | } | |
| DECL dMULTIPLY0_133(TA *A, const TB *B, const TC *C) { dMULTIPLYOP0_133(A,= | | | |
| ,B,C); } | | | |
| DECL dMULTIPLY0_333(TA *A, const TB *B, const TC *C) { dMULTIPLYOP0_333(A,= | | | |
| ,B,C); } | | | |
| DECL dMULTIPLY1_333(TA *A, const TB *B, const TC *C) { dMULTIPLYOP1_333(A,= | | | |
| ,B,C); } | | | |
| DECL dMULTIPLY2_333(TA *A, const TB *B, const TC *C) { dMULTIPLYOP2_333(A,= | | | |
| ,B,C); } | | | |
| | | | |
| DECL dMULTIPLYADD0_331(TA *A, const TB *B, const TC *C) { dMULTIPLYOP0_331( | | | |
| A,+=,B,C); } | | | |
| DECL dMULTIPLYADD1_331(TA *A, const TB *B, const TC *C) { dMULTIPLYOP1_331( | | | |
| A,+=,B,C); } | | | |
| DECL dMULTIPLYADD0_133(TA *A, const TB *B, const TC *C) { dMULTIPLYOP0_133( | | | |
| A,+=,B,C); } | | | |
| DECL dMULTIPLYADD0_333(TA *A, const TB *B, const TC *C) { dMULTIPLYOP0_333( | | | |
| A,+=,B,C); } | | | |
| DECL dMULTIPLYADD1_333(TA *A, const TB *B, const TC *C) { dMULTIPLYOP1_333( | | | |
| A,+=,B,C); } | | | |
| DECL dMULTIPLYADD2_333(TA *A, const TB *B, const TC *C) { dMULTIPLYOP2_333( | | | |
| A,+=,B,C); } | | | |
| | | | |
| #undef DECL | | | |
| | | | |
| #else | | | |
| | | | |
| #define dMULTIPLY0_331(A,B,C) dMULTIPLYOP0_331(A,=,B,C) | | | |
| #define dMULTIPLY1_331(A,B,C) dMULTIPLYOP1_331(A,=,B,C) | | | |
| #define dMULTIPLY0_133(A,B,C) dMULTIPLYOP0_133(A,=,B,C) | | | |
| #define dMULTIPLY0_333(A,B,C) dMULTIPLYOP0_333(A,=,B,C) | | | |
| #define dMULTIPLY1_333(A,B,C) dMULTIPLYOP1_333(A,=,B,C) | | | |
| #define dMULTIPLY2_333(A,B,C) dMULTIPLYOP2_333(A,=,B,C) | | | |
| | | | |
| #define dMULTIPLYADD0_331(A,B,C) dMULTIPLYOP0_331(A,+=,B,C) | | | |
| #define dMULTIPLYADD1_331(A,B,C) dMULTIPLYOP1_331(A,+=,B,C) | | | |
| #define dMULTIPLYADD0_133(A,B,C) dMULTIPLYOP0_133(A,+=,B,C) | | | |
| #define dMULTIPLYADD0_333(A,B,C) dMULTIPLYOP0_333(A,+=,B,C) | | | |
| #define dMULTIPLYADD1_333(A,B,C) dMULTIPLYOP1_333(A,+=,B,C) | | | |
| #define dMULTIPLYADD2_333(A,B,C) dMULTIPLYOP2_333(A,+=,B,C) | | | |
| | | | |
|
| #endif | | PURE_INLINE void dMultiply1_331(dReal *res, const dReal *a, const dReal *b) | |
| | | { | |
| | | dMultiplyHelper1_331(res, a, b); | |
| | | } | |
| | | | |
|
| #ifdef __cplusplus | | PURE_INLINE void dMultiply0_133(dReal *res, const dReal *a, const dReal *b) | |
| extern "C" { | | { | |
| #endif | | dMultiplyHelper0_133(res, a, b); | |
| | | } | |
| | | | |
|
| /* | | PURE_INLINE void dMultiply0_333(dReal *res, const dReal *a, const dReal *b) | |
| * normalize 3x1 and 4x1 vectors (i.e. scale them to unit length) | | { | |
| */ | | dMultiplyHelper0_133(res + 0, a + 0, b); | |
| | | dMultiplyHelper0_133(res + 4, a + 4, b); | |
| | | dMultiplyHelper0_133(res + 8, a + 8, b); | |
| | | } | |
| | | | |
|
| #if defined(__ODE__) | | PURE_INLINE void dMultiply1_333(dReal *res, const dReal *a, const dReal *b) | |
| | | { | |
| | | dMultiplyHelper1_133(res + 0, b, a + 0); | |
| | | dMultiplyHelper1_133(res + 4, b, a + 1); | |
| | | dMultiplyHelper1_133(res + 8, b, a + 2); | |
| | | } | |
| | | | |
|
| int _dSafeNormalize3 (dVector3 a); | | PURE_INLINE void dMultiply2_333(dReal *res, const dReal *a, const dReal *b) | |
| int _dSafeNormalize4 (dVector4 a); | | { | |
| | | dMultiplyHelper0_331(res + 0, b, a + 0); | |
| | | dMultiplyHelper0_331(res + 4, b, a + 4); | |
| | | dMultiplyHelper0_331(res + 8, b, a + 8); | |
| | | } | |
| | | | |
|
| static __inline void _dNormalize3(dVector3 a) | | PURE_INLINE void dMultiplyAdd0_331(dReal *res, const dReal *a, const dReal
*b) | |
| { | | { | |
|
| int bNormalizationResult = _dSafeNormalize3(a); | | dReal tmp[3]; | |
| dIASSERT(bNormalizationResult); | | dMultiplyHelper0_331(tmp, a, b); | |
| dVARIABLEUSED(bNormalizationResult); | | dAddVectors3(res, res, tmp); | |
| } | | } | |
| | | | |
|
| static __inline void _dNormalize4(dVector4 a) | | PURE_INLINE void dMultiplyAdd1_331(dReal *res, const dReal *a, const dReal
*b) | |
| { | | { | |
|
| int bNormalizationResult = _dSafeNormalize4(a); | | dReal tmp[3]; | |
| dIASSERT(bNormalizationResult); | | dMultiplyHelper1_331(tmp, a, b); | |
| dVARIABLEUSED(bNormalizationResult); | | dAddVectors3(res, res, tmp); | |
| } | | } | |
| | | | |
|
| #endif // defined(__ODE__) | | PURE_INLINE void dMultiplyAdd0_133(dReal *res, const dReal *a, const dReal | |
| | | *b) | |
| | | { | |
| | | dReal tmp[3]; | |
| | | dMultiplyHelper0_133(tmp, a, b); | |
| | | dAddVectors3(res, res, tmp); | |
| | | } | |
| | | | |
| | | PURE_INLINE void dMultiplyAdd0_333(dReal *res, const dReal *a, const dReal | |
| | | *b) | |
| | | { | |
| | | dReal tmp[3]; | |
| | | dMultiplyHelper0_133(tmp, a + 0, b); | |
| | | dAddVectors3(res+ 0, res + 0, tmp); | |
| | | dMultiplyHelper0_133(tmp, a + 4, b); | |
| | | dAddVectors3(res + 4, res + 4, tmp); | |
| | | dMultiplyHelper0_133(tmp, a + 8, b); | |
| | | dAddVectors3(res + 8, res + 8, tmp); | |
| | | } | |
| | | | |
| | | PURE_INLINE void dMultiplyAdd1_333(dReal *res, const dReal *a, const dReal | |
| | | *b) | |
| | | { | |
| | | dReal tmp[3]; | |
| | | dMultiplyHelper1_133(tmp, b, a + 0); | |
| | | dAddVectors3(res + 0, res + 0, tmp); | |
| | | dMultiplyHelper1_133(tmp, b, a + 1); | |
| | | dAddVectors3(res + 4, res + 4, tmp); | |
| | | dMultiplyHelper1_133(tmp, b, a + 2); | |
| | | dAddVectors3(res + 8, res + 8, tmp); | |
| | | } | |
| | | | |
| | | PURE_INLINE void dMultiplyAdd2_333(dReal *res, const dReal *a, const dReal | |
| | | *b) | |
| | | { | |
| | | dReal tmp[3]; | |
| | | dMultiplyHelper0_331(tmp, b, a + 0); | |
| | | dAddVectors3(res + 0, res + 0, tmp); | |
| | | dMultiplyHelper0_331(tmp, b, a + 4); | |
| | | dAddVectors3(res + 4, res + 4, tmp); | |
| | | dMultiplyHelper0_331(tmp, b, a + 8); | |
| | | dAddVectors3(res + 8, res + 8, tmp); | |
| | | } | |
| | | | |
| | | // Include legacy macros here | |
| | | #include <ode/odemath_legacy.h> | |
| | | | |
| | | #ifdef __cplusplus | |
| | | extern "C" { | |
| | | #endif | |
| | | | |
| | | /* | |
| | | * normalize 3x1 and 4x1 vectors (i.e. scale them to unit length) | |
| | | */ | |
| | | | |
| // For DLL export | | // For DLL export | |
| ODE_API int dSafeNormalize3 (dVector3 a); | | ODE_API int dSafeNormalize3 (dVector3 a); | |
| ODE_API int dSafeNormalize4 (dVector4 a); | | ODE_API int dSafeNormalize4 (dVector4 a); | |
| ODE_API void dNormalize3 (dVector3 a); // Potentially asserts on zero vec | | ODE_API void dNormalize3 (dVector3 a); // Potentially asserts on zero vec | |
| ODE_API void dNormalize4 (dVector4 a); // Potentially asserts on zero vec | | ODE_API void dNormalize4 (dVector4 a); // Potentially asserts on zero vec | |
| | | | |
| #if defined(__ODE__) | | #if defined(__ODE__) | |
| | | | |
|
| | | int _dSafeNormalize3 (dVector3 a); | |
| | | int _dSafeNormalize4 (dVector4 a); | |
| | | | |
| | | PURE_INLINE void _dNormalize3(dVector3 a) | |
| | | { | |
| | | int bNormalizationResult = _dSafeNormalize3(a); | |
| | | dIVERIFY(bNormalizationResult); | |
| | | } | |
| | | | |
| | | PURE_INLINE void _dNormalize4(dVector4 a) | |
| | | { | |
| | | int bNormalizationResult = _dSafeNormalize4(a); | |
| | | dIVERIFY(bNormalizationResult); | |
| | | } | |
| | | | |
| // For internal use | | // For internal use | |
| #define dSafeNormalize3(a) _dSafeNormalize3(a) | | #define dSafeNormalize3(a) _dSafeNormalize3(a) | |
| #define dSafeNormalize4(a) _dSafeNormalize4(a) | | #define dSafeNormalize4(a) _dSafeNormalize4(a) | |
| #define dNormalize3(a) _dNormalize3(a) | | #define dNormalize3(a) _dNormalize3(a) | |
| #define dNormalize4(a) _dNormalize4(a) | | #define dNormalize4(a) _dNormalize4(a) | |
| | | | |
| #endif // defined(__ODE__) | | #endif // defined(__ODE__) | |
| | | | |
| /* | | /* | |
| * given a unit length "normal" vector n, generate vectors p and q vectors | | * given a unit length "normal" vector n, generate vectors p and q vectors | |
| | | | |
End of changes. 35 change blocks. |
| 249 lines changed or deleted | | 382 lines changed or added | |
|