Thread: [Opal-commits] opal/src testFixedJoint.cpp,NONE,1.1 testJoint.cpp,NONE,1.1 Joint.cpp,1.32,1.33 Joint
Status: Inactive
Brought to you by:
tylerstreeter
Update of /cvsroot/opal/opal/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3972/src Modified Files: Joint.cpp Joint.h JointData.h Makefile.am Makefile.in Quaternion.h testsolid.cpp Added Files: testFixedJoint.cpp testJoint.cpp Log Message: Implemented features to track Joint damage. --- NEW FILE: testFixedJoint.cpp --- /************************************************************************* * * * Open Physics Abstraction Layer * * Copyright (C) 2004-2005 * * Alan Fischer ala...@gm... * * Andres Reinot an...@re... * * Tyler Streeter tyl...@gm... * * Oleksandr Lozitskiy mr....@gm... * * All rights reserved. * * Web: opal.sourceforge.net * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of EITHER: * * (1) The GNU Lesser General Public License as published by the Free * * Software Foundation; either version 2.1 of the License, or (at * * your option) any later version. The text of the GNU Lesser * * General Public License is included with this library in the * * file license-LGPL.txt. * * (2) The BSD-style license that is included with this library in * * the file license-BSD.txt. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * * license-LGPL.txt and license-BSD.txt for more details. * * * *************************************************************************/ // system headers #include <quicktest.h> // project headers #include "opal.h" using namespace opal; namespace testFixedJoint { class Fixture { public: Fixture() { sim = createSimulator(); sim->setGravity( Vec3r( 0, 0, 0 ) ); s1 = sim->createSolid(); s2 = sim->createSolid(); s1->setPosition( Point3r( 0, 0, 0 ) ); s2->setPosition( Point3r( 0, 10, 0 ) ); j = sim->createJoint(); } ~Fixture() { sim->destroy(); } Simulator * sim; Solid * s1; Solid * s2; Joint * j; }; QT_TEST( no_shapes ) { Fixture f; JointData jdata; jdata.setType( FIXED_JOINT ); jdata.solid0 = f.s1; jdata.solid1 = f.s2; f.j->init( jdata ); f.sim->simulate( 1 ); QT_CHECK_CLOSE( f.s1->getPosition().x, 0 ); QT_CHECK_CLOSE( f.s1->getPosition().y, 0 ); QT_CHECK_CLOSE( f.s1->getPosition().z, 0 ); QT_CHECK_CLOSE( f.s2->getPosition().x, 0 ); QT_CHECK_CLOSE( f.s2->getPosition().y, 10 ); QT_CHECK_CLOSE( f.s2->getPosition().z, 0 ); } QT_TEST( with_shapes ) { Fixture f; SphereShapeData data; data.radius = 1; f.s1->addShape( data ); f.s2->addShape( data ); JointData jdata; jdata.setType( FIXED_JOINT ); jdata.solid0 = f.s1; jdata.solid1 = f.s2; f.j->init( jdata ); f.sim->simulate( 1 ); QT_CHECK_CLOSE( f.s1->getPosition().x, 0 ); QT_CHECK_CLOSE( f.s1->getPosition().y, 0 ); QT_CHECK_CLOSE( f.s1->getPosition().z, 0 ); QT_CHECK_CLOSE( f.s2->getPosition().x, 0 ); QT_CHECK_CLOSE( f.s2->getPosition().y, 10 ); QT_CHECK_CLOSE( f.s2->getPosition().z, 0 ); } } Index: Makefile.in =================================================================== RCS file: /cvsroot/opal/opal/src/Makefile.in,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Makefile.in 10 Dec 2005 05:18:35 -0000 1.10 --- Makefile.in 10 Dec 2005 22:41:06 -0000 1.11 *************** *** 73,77 **** testPoint3r.$(OBJEXT) testQuaternion.$(OBJEXT) \ testMatrix44r.$(OBJEXT) testBlueprint.$(OBJEXT) \ ! testMath.$(OBJEXT) testVelocityMotor.$(OBJEXT) test_opal_OBJECTS = $(am_test_opal_OBJECTS) test_opal_DEPENDENCIES = \ --- 73,78 ---- testPoint3r.$(OBJEXT) testQuaternion.$(OBJEXT) \ testMatrix44r.$(OBJEXT) testBlueprint.$(OBJEXT) \ ! testMath.$(OBJEXT) testVelocityMotor.$(OBJEXT) \ ! testFixedJoint.$(OBJEXT) testJoint.$(OBJEXT) test_opal_OBJECTS = $(am_test_opal_OBJECTS) test_opal_DEPENDENCIES = \ *************** *** 215,220 **** test_opal_SOURCES = testopal.cpp testsolid.cpp testAccelerationSensor.cpp \ ! testRaycastSensor.cpp testSimulator.cpp testVec3r.cpp testPoint3r.cpp testQuaternion.cpp \ ! testMatrix44r.cpp testBlueprint.cpp testMath.cpp testVelocityMotor.cpp test_opal_LDADD = $(top_builddir)/src/external/tinyxml/libtinyxml.a \ --- 216,222 ---- test_opal_SOURCES = testopal.cpp testsolid.cpp testAccelerationSensor.cpp \ ! testRaycastSensor.cpp testSimulator.cpp testVec3r.cpp testPoint3r.cpp testQuaternion.cpp \ ! testMatrix44r.cpp testBlueprint.cpp testMath.cpp testVelocityMotor.cpp testFixedJoint.cpp \ ! testJoint.cpp test_opal_LDADD = $(top_builddir)/src/external/tinyxml/libtinyxml.a \ *************** *** 326,329 **** --- 328,333 ---- @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testAccelerationSensor.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testBlueprint.Po@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testFixedJoint.Po@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testJoint.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testMath.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testMatrix44r.Po@am__quote@ --- NEW FILE: testJoint.cpp --- /************************************************************************* * * * Open Physics Abstraction Layer * * Copyright (C) 2004-2005 * * Alan Fischer ala...@gm... * * Andres Reinot an...@re... * * Tyler Streeter tyl...@gm... * * Oleksandr Lozitskiy mr....@gm... * * All rights reserved. * * Web: opal.sourceforge.net * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of EITHER: * * (1) The GNU Lesser General Public License as published by the Free * * Software Foundation; either version 2.1 of the License, or (at * * your option) any later version. The text of the GNU Lesser * * General Public License is included with this library in the * * file license-LGPL.txt. * * (2) The BSD-style license that is included with this library in * * the file license-BSD.txt. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * * license-LGPL.txt and license-BSD.txt for more details. * * * *************************************************************************/ // system headers #include <quicktest.h> // project headers #include "opal.h" using namespace opal; //! Testing generic Joint stuff namespace testJoint { QT_TEST( break_settings ) { Simulator * sim = createSimulator(); Joint * j = sim->createJoint(); JointData data; j->init( data ); QT_CHECK_EQUAL( j->getBreakingMode(), UNBREAKABLE_MODE ); sim->destroy(); } QT_TEST( breaking_threshhold ) { Simulator * sim = createSimulator(); Solid * s0 = sim->createSolid(); s0->setPosition( 0, 0, 0 ); Solid * s1 = sim->createSolid(); s1->setPosition( 0, 0, 10 ); { SphereShapeData data; data.radius = 1; s0->addShape( data ); s1->addShape( data ); } Joint * j = sim->createJoint(); { JointData data; data.setType( FIXED_JOINT ); data.breakMode = THRESHOLD_MODE; data.breakThresh = 100; data.solid0 = s0; data.solid1 = s1; j->init( data ); } sim->simulate( 1 ); QT_CHECK_EQUAL( j->isBroken(), false ); // apply a force that breaks the joint { Force f; f.type = GLOBAL_FORCE; f.duration = 1; f.singleStep = false; f.pos = Point3r( 0, 0, 0 ); f.vec = Vec3r( 0, 0, 100 ); s1->addForce( f ); } sim->simulate( 1 ); QT_CHECK_EQUAL( j->isBroken(), true ); sim->destroy(); } } Index: testsolid.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/testsolid.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** testsolid.cpp 1 Dec 2005 23:55:21 -0000 1.7 --- testsolid.cpp 10 Dec 2005 22:41:06 -0000 1.8 *************** *** 231,241 **** QT_CHECK_EQUAL( q, f.s->getQuaternion() ); ! q.set( 1, 0, 0, 0 ); ! f.s->setQuaternion( q ); ! QT_CHECK_EQUAL( q, f.s->getQuaternion() ); ! q.set( 0, 0, 0, 1 ); ! f.s->setQuaternion( q ); ! QT_CHECK_EQUAL( q, f.s->getQuaternion() ); } } --- 231,252 ---- QT_CHECK_EQUAL( q, f.s->getQuaternion() ); ! q.set( 1, 0, 0, 0 ); ! f.s->setQuaternion( q ); ! QT_CHECK_EQUAL( q, f.s->getQuaternion() ); ! q.set( 0, 0, 0, 1 ); ! f.s->setQuaternion( q ); ! QT_CHECK_EQUAL( q, f.s->getQuaternion() ); ! } ! ! QT_TEST( capsule_ODE_crash ) ! { ! SolidFixture f; ! CapsuleShapeData data; ! data.length = 70; ! data.radius = 10; ! f.s->addShape( data ); ! ! f.sim->simulate( 1 ); } } Index: Makefile.am =================================================================== RCS file: /cvsroot/opal/opal/src/Makefile.am,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Makefile.am 10 Dec 2005 05:18:35 -0000 1.10 --- Makefile.am 10 Dec 2005 22:41:06 -0000 1.11 *************** *** 15,20 **** bin_PROGRAMS = test_opal test_opal_SOURCES = testopal.cpp testsolid.cpp testAccelerationSensor.cpp \ ! testRaycastSensor.cpp testSimulator.cpp testVec3r.cpp testPoint3r.cpp testQuaternion.cpp \ ! testMatrix44r.cpp testBlueprint.cpp testMath.cpp testVelocityMotor.cpp test_opal_LDADD = $(top_builddir)/src/external/tinyxml/libtinyxml.a \ $(top_builddir)/src/ODE/libodeimpl.a $(top_builddir)/src/libopalode.a -lode --- 15,21 ---- bin_PROGRAMS = test_opal test_opal_SOURCES = testopal.cpp testsolid.cpp testAccelerationSensor.cpp \ ! testRaycastSensor.cpp testSimulator.cpp testVec3r.cpp testPoint3r.cpp testQuaternion.cpp \ ! testMatrix44r.cpp testBlueprint.cpp testMath.cpp testVelocityMotor.cpp testFixedJoint.cpp \ ! testJoint.cpp test_opal_LDADD = $(top_builddir)/src/external/tinyxml/libtinyxml.a \ $(top_builddir)/src/ODE/libodeimpl.a $(top_builddir)/src/libopalode.a -lode Index: Joint.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/Joint.cpp,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** Joint.cpp 4 May 2005 21:04:00 -0000 1.32 --- Joint.cpp 10 Dec 2005 22:41:06 -0000 1.33 *************** *** 1,28 **** /************************************************************************* ! * * ! * Open Physics Abstraction Layer * ! * Copyright (C) 2004-2005 * ! * Alan Fischer ala...@gm... * ! * Andres Reinot an...@re... * ! * Tyler Streeter tyl...@gm... * ! * All rights reserved. * ! * Web: opal.sourceforge.net * ! * * ! * This library is free software; you can redistribute it and/or * ! * modify it under the terms of EITHER: * ! * (1) The GNU Lesser General Public License as published by the Free * ! * Software Foundation; either version 2.1 of the License, or (at * ! * your option) any later version. The text of the GNU Lesser * ! * General Public License is included with this library in the * ! * file license-LGPL.txt. * ! * (2) The BSD-style license that is included with this library in * ! * the file license-BSD.txt. * ! * * ! * This library is distributed in the hope that it will be useful, * ! * but WITHOUT ANY WARRANTY; without even the implied warranty of * ! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * ! * license-LGPL.txt and license-BSD.txt for more details. * ! * * ! *************************************************************************/ #include "Joint.h" --- 1,28 ---- /************************************************************************* ! * * ! * Open Physics Abstraction Layer * ! * Copyright (C) 2004-2005 * ! * Alan Fischer ala...@gm... * ! * Andres Reinot an...@re... * ! * Tyler Streeter tyl...@gm... * ! * All rights reserved. * ! * Web: opal.sourceforge.net * ! * * ! * This library is free software; you can redistribute it and/or * ! * modify it under the terms of EITHER: * ! * (1) The GNU Lesser General Public License as published by the Free * ! * Software Foundation; either version 2.1 of the License, or (at * ! * your option) any later version. The text of the GNU Lesser * ! * General Public License is included with this library in the * ! * file license-LGPL.txt. * ! * (2) The BSD-style license that is included with this library in * ! * the file license-BSD.txt. * ! * * ! * This library is distributed in the hope that it will be useful, * ! * but WITHOUT ANY WARRANTY; without even the implied warranty of * ! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * ! * license-LGPL.txt and license-BSD.txt for more details. * ! * * ! *************************************************************************/ #include "Joint.h" *************** *** 31,393 **** namespace opal { ! Joint::Joint() ! { ! // "mData" is initialized in its own constructor. ! setJointBreakEventHandler(NULL); ! setUserData(NULL); ! mInitCalled = false; ! mNumAxes = 0; ! mAxisRotational[0] = false; ! mAxisRotational[1] = false; ! mAxisRotational[2] = false; ! } ! Joint::~Joint() ! { ! } ! void Joint::internal_destroy() ! { ! delete this; ! } ! void Joint::init(const JointData& data) ! { ! mData = data; ! } ! const JointData& Joint::getData() ! { ! // Update parameters that don't get updated automatically. ! for (int i=0; i<mNumAxes; ++i) ! { ! mData.axis[i] = getAxis(i); ! } ! mData.anchor = getAnchor(); ! return mData; ! } ! void Joint::setName(const std::string& name) ! { ! mData.name = name; ! } ! const std::string& Joint::getName()const ! { ! return mData.name; ! } ! void Joint::setContactsEnabled(bool e) ! { ! mData.contactsEnabled = e; ! } ! bool Joint::areContactsEnabled()const ! { ! return mData.contactsEnabled; ! } ! JointType Joint::getType()const ! { ! return mData.getType(); ! } ! void Joint::setBreakParams(JointBreakMode mode, real breakThresh, ! real accumThresh) ! { ! mData.breakMode = mode; ! mData.breakThresh = breakThresh; ! mData.accumThresh = accumThresh; ! } ! void Joint::repairAccumDamage() ! { ! mData.accumDamage = 0; ! //mIsBroken = false; ! } ! //bool Joint::internal_isBroken() ! //{ ! // return mIsBroken; ! //} ! void Joint::setJointBreakEventHandler( ! JointBreakEventHandler* eventHandler) ! { ! mJointBreakEventHandler = eventHandler; ! } ! JointBreakEventHandler* Joint::getJointBreakEventHandler()const ! { ! return mJointBreakEventHandler; ! } ! void Joint::setLimitsEnabled(int axisNum, bool e) ! { ! assert(axisNum >= 0 && axisNum < mNumAxes); ! mData.axis[axisNum].limitsEnabled = e; ! } ! bool Joint::areLimitsEnabled(int axisNum) ! { ! assert(axisNum >= 0 && axisNum < mNumAxes); ! return mData.axis[axisNum].limitsEnabled; ! } ! //void Joint::setLimits(int axisNum, JointLimits l) ! //{ ! // assert(axisNum >= 0 && axisNum < mNumAxes); ! // assert(l.bounciness >= 0 && l.bounciness <= 1); ! // assert(l.hardness >= 0 && l.hardness <= 1); ! // mData.axis[axisNum].limits = l; ! //} ! //const Joint::JointLimits& getLimits(int axisNum)const ! //{ ! // assert(axisNum >= 0 && axisNum < mNumAxes); ! // return mData.axis[axisNum].limits; ! //} ! void Joint::setLimitRange(int axisNum, real low, real high) ! { ! assert(high >= low); ! assert(axisNum >= 0 && axisNum < mNumAxes); ! mData.axis[axisNum].limits.low = low; ! mData.axis[axisNum].limits.high = high; ! } ! real Joint::getLowLimit(int axisNum)const ! { ! assert(axisNum >= 0 && axisNum < mNumAxes); ! return mData.axis[axisNum].limits.low; ! } ! real Joint::getHighLimit(int axisNum)const ! { ! assert(axisNum >= 0 && axisNum < mNumAxes); ! return mData.axis[axisNum].limits.high; ! } ! void Joint::setLimitHardness(int axisNum, real h) ! { ! assert(h >= 0 && h <= 1); ! assert(axisNum >= 0 && axisNum < mNumAxes); ! mData.axis[axisNum].limits.hardness = h; ! } ! real Joint::getLimitHardness(int axisNum)const ! { ! assert(axisNum >= 0 && axisNum < mNumAxes); ! return mData.axis[axisNum].limits.hardness; ! } ! void Joint::setLimitBounciness(int axisNum, real b) ! { ! assert(b >= 0 && b <= 1); ! assert(axisNum >= 0 && axisNum < mNumAxes); ! mData.axis[axisNum].limits.bounciness = b; ! } ! real Joint::getLimitBounciness(int axisNum)const ! { ! assert(axisNum >= 0 && axisNum < mNumAxes); ! return mData.axis[axisNum].limits.bounciness; ! } ! void Joint::addForce(int axisNum, real magnitude, real duration, ! bool singleStep) ! { ! assert(axisNum >= 0 && axisNum < mNumAxes); ! if (mData.enabled) ! { ! Force f; ! f.singleStep = singleStep; ! // We only care about the duration if this is not a single-step ! // force. ! if (!f.singleStep) ! { ! f.duration = duration; ! } ! f.type = LOCAL_FORCE; ! Vec3r direction = mData.axis[axisNum].direction; ! f.vec = magnitude * direction; ! if (mData.solid0) ! { ! mData.solid0->addForce(f); ! } ! f.vec *= (real)-1.0; ! if (mData.solid1) ! { ! mData.solid1->addForce(f); ! } ! } ! } ! void Joint::addTorque(int axisNum, real magnitude, real duration, ! bool singleStep) ! { ! assert(axisNum >= 0 && axisNum < mNumAxes); ! if (mData.enabled) ! { ! Force f; ! f.singleStep = singleStep; ! // We only care about the duration if this is not a single-step ! // force. ! if (!f.singleStep) ! { ! f.duration = duration; ! } ! f.type = LOCAL_TORQUE; ! Vec3r axis = mData.axis[axisNum].direction; ! f.vec = magnitude * axis; ! if (mData.solid0) ! { ! mData.solid0->addForce(f); ! } ! f.vec *= (real)-1.0; ! if (mData.solid1) ! { ! mData.solid1->addForce(f); ! } ! } ! } ! void Joint::wakeSolids() ! { ! mData.solid0->setSleeping(false); ! mData.solid1->setSleeping(false); ! } ! void Joint::setSolids(Solid* s0, Solid* s1) ! { ! mData.solid0 = s0; ! mData.solid1 = s1; ! } ! Solid* Joint::getSolid0()const ! { ! return mData.solid0; ! } ! Solid* Joint::getSolid1()const ! { ! return mData.solid1; ! } ! void Joint::setAxis(int axisNum, const JointAxis& axis) ! { ! assert(axisNum >= 0 && axisNum < mNumAxes); ! mData.axis[axisNum] = axis; ! } ! int Joint::getNumAxes()const ! { ! return mNumAxes; ! } ! void Joint::setAnchor(const Point3r& anchor) ! { ! mData.anchor = anchor; ! } ! bool Joint::isEnabled()const ! { ! return mData.enabled; ! } ! void Joint::setEnabled(bool e) ! { ! if (!mInitCalled) ! { ! return; ! } ! mData.enabled = e; ! } ! bool Joint::isRotational(int axisNum)const ! { ! assert(axisNum >= 0 && axisNum < mNumAxes); ! return mAxisRotational[axisNum]; ! } ! void Joint::setUserData(void* data) ! { ! mUserData = data; ! } ! void* Joint::getUserData() ! { ! return mUserData; ! } ! bool Joint::internal_dependsOnSolid(Solid* s) ! { ! if (s == mData.solid0 || s == mData.solid1) ! { ! return true; ! } ! else ! { ! return false; ! } ! } ! void Joint::updateDamage(real currentStress) ! { ! bool isBroken = false; ! switch(mData.breakMode) ! { ! case UNBREAKABLE_MODE: ! //nothing to do ! break; ! case THRESHOLD_MODE: ! { ! if (currentStress >= mData.breakThresh) ! { ! isBroken = true; ! } ! break; ! } ! case ACCUMULATED_MODE: ! { ! if (currentStress >= mData.accumThresh) ! { ! mData.accumDamage += currentStress; ! } ! if (mData.accumDamage >= mData.breakThresh) ! { ! isBroken = true; ! } ! break; ! } ! default: ! assert(false); ! } ! if (isBroken) ! { ! setEnabled(false); ! if (mJointBreakEventHandler) ! { ! mJointBreakEventHandler->handleJointBreakEvent(this); ! } ! } ! } } --- 31,415 ---- namespace opal { ! Joint::Joint() ! { ! // "mData" is initialized in its own constructor. ! setJointBreakEventHandler( NULL ); ! setUserData( NULL ); ! mInitCalled = false; ! mNumAxes = 0; ! mAxisRotational[ 0 ] = false; ! mAxisRotational[ 1 ] = false; ! mAxisRotational[ 2 ] = false; ! } ! Joint::~Joint() ! {} ! void Joint::internal_destroy() ! { ! delete this; ! } ! void Joint::init( const JointData& data ) ! { ! mData = data; ! } ! const JointData& Joint::getData() ! { ! // Update parameters that don't get updated automatically. ! for ( int i = 0; i < mNumAxes; ++i ) ! { ! mData.axis[ i ] = getAxis( i ); ! } ! mData.anchor = getAnchor(); ! return mData; ! } ! void Joint::setName( const std::string& name ) ! { ! mData.name = name; ! } ! const std::string& Joint::getName() const ! { ! return mData.name; ! } ! void Joint::setContactsEnabled( bool e ) ! { ! mData.contactsEnabled = e; ! } ! bool Joint::areContactsEnabled() const ! { ! return mData.contactsEnabled; ! } ! JointType Joint::getType() const ! { ! return mData.getType(); ! } ! void Joint::setBreakParams( JointBreakMode mode, real breakThresh, ! real accumThresh ) ! { ! mData.breakMode = mode; ! mData.breakThresh = breakThresh; ! mData.accumThresh = accumThresh; ! } ! bool Joint::isBroken() const ! { ! return mData.isBroken; ! } ! JointBreakMode Joint::getBreakingMode() const ! { ! return mData.breakMode; ! } ! real Joint::getBreakThresh() const ! { ! return mData.breakThresh; ! } ! real Joint::getAccumulatedDamage() const ! { ! return mData.accumDamage; ! } ! real Joint::getAccumulatedThresh() const ! { ! return mData.accumThresh; ! } ! void Joint::repairAccumDamage() ! { ! mData.accumDamage = 0; ! //mIsBroken = false; ! } ! //bool Joint::internal_isBroken() ! //{ ! // return mIsBroken; ! //} ! void Joint::setJointBreakEventHandler( ! JointBreakEventHandler* eventHandler ) ! { ! mJointBreakEventHandler = eventHandler; ! } ! JointBreakEventHandler* Joint::getJointBreakEventHandler() const ! { ! return mJointBreakEventHandler; ! } ! void Joint::setLimitsEnabled( int axisNum, bool e ) ! { ! assert( axisNum >= 0 && axisNum < mNumAxes ); ! mData.axis[ axisNum ].limitsEnabled = e; ! } ! bool Joint::areLimitsEnabled( int axisNum ) ! { ! assert( axisNum >= 0 && axisNum < mNumAxes ); ! return mData.axis[ axisNum ].limitsEnabled; ! } ! //void Joint::setLimits(int axisNum, JointLimits l) ! //{ ! // assert(axisNum >= 0 && axisNum < mNumAxes); ! // assert(l.bounciness >= 0 && l.bounciness <= 1); ! // assert(l.hardness >= 0 && l.hardness <= 1); ! // mData.axis[axisNum].limits = l; ! //} ! //const Joint::JointLimits& getLimits(int axisNum)const ! //{ ! // assert(axisNum >= 0 && axisNum < mNumAxes); ! // return mData.axis[axisNum].limits; ! //} ! void Joint::setLimitRange( int axisNum, real low, real high ) ! { ! assert( high >= low ); ! assert( axisNum >= 0 && axisNum < mNumAxes ); ! mData.axis[ axisNum ].limits.low = low; ! mData.axis[ axisNum ].limits.high = high; ! } ! real Joint::getLowLimit( int axisNum ) const ! { ! assert( axisNum >= 0 && axisNum < mNumAxes ); ! return mData.axis[ axisNum ].limits.low; ! } ! real Joint::getHighLimit( int axisNum ) const ! { ! assert( axisNum >= 0 && axisNum < mNumAxes ); ! return mData.axis[ axisNum ].limits.high; ! } ! void Joint::setLimitHardness( int axisNum, real h ) ! { ! assert( h >= 0 && h <= 1 ); ! assert( axisNum >= 0 && axisNum < mNumAxes ); ! mData.axis[ axisNum ].limits.hardness = h; ! } ! real Joint::getLimitHardness( int axisNum ) const ! { ! assert( axisNum >= 0 && axisNum < mNumAxes ); ! return mData.axis[ axisNum ].limits.hardness; ! } ! void Joint::setLimitBounciness( int axisNum, real b ) ! { ! assert( b >= 0 && b <= 1 ); ! assert( axisNum >= 0 && axisNum < mNumAxes ); ! mData.axis[ axisNum ].limits.bounciness = b; ! } ! real Joint::getLimitBounciness( int axisNum ) const ! { ! assert( axisNum >= 0 && axisNum < mNumAxes ); ! return mData.axis[ axisNum ].limits.bounciness; ! } ! void Joint::addForce( int axisNum, real magnitude, real duration, ! bool singleStep ) ! { ! assert( axisNum >= 0 && axisNum < mNumAxes ); ! if ( mData.enabled ) ! { ! Force f; ! f.singleStep = singleStep; ! // We only care about the duration if this is not a single-step ! // force. ! if ( !f.singleStep ) ! { ! f.duration = duration; ! } ! f.type = LOCAL_FORCE; ! Vec3r direction = mData.axis[ axisNum ].direction; ! f.vec = magnitude * direction; ! if ( mData.solid0 ) ! { ! mData.solid0->addForce( f ); ! } ! f.vec *= ( real ) - 1.0; ! if ( mData.solid1 ) ! { ! mData.solid1->addForce( f ); ! } ! } ! } ! void Joint::addTorque( int axisNum, real magnitude, real duration, ! bool singleStep ) ! { ! assert( axisNum >= 0 && axisNum < mNumAxes ); ! if ( mData.enabled ) ! { ! Force f; ! f.... [truncated message content] |