[Opal-commits] opal/src PostStepEventHandler.h,NONE,1.1 Joint.cpp,1.26,1.27 Joint.h,1.64,1.65 SConsc
Status: Inactive
Brought to you by:
tylerstreeter
|
From: tylerstreeter <tyl...@us...> - 2005-03-21 04:29:15
|
Update of /cvsroot/opal/opal/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15060/src Modified Files: Joint.cpp Joint.h SConscript Simulator.cpp Simulator.h Solid.cpp Solid.h opal.h Added Files: PostStepEventHandler.h Log Message: added a PostStepEventHandler that gets notified at the end of every simulation step Index: Joint.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/Joint.cpp,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** Joint.cpp 8 Mar 2005 22:05:03 -0000 1.26 --- Joint.cpp 21 Mar 2005 04:29:05 -0000 1.27 *************** *** 34,38 **** { // "mData" is initialized in its own constructor. ! mJointBreakEventHandler = NULL; setUserData(NULL); mInitCalled = false; --- 34,38 ---- { // "mData" is initialized in its own constructor. ! setJointBreakEventHandler(NULL); setUserData(NULL); mInitCalled = false; *************** *** 101,109 **** //} ! void Joint::setEventHandler(JointBreakEventHandler* eventHandler) { mJointBreakEventHandler = eventHandler; } void Joint::setLimitsEnabled(int axisNum, bool e) { --- 101,115 ---- //} ! void Joint::setJointBreakEventHandler( ! JointBreakEventHandler* eventHandler) { mJointBreakEventHandler = eventHandler; } + JointBreakEventHandler* Joint::getJointBreakEventHandler()const + { + return mJointBreakEventHandler; + } + void Joint::setLimitsEnabled(int axisNum, bool e) { Index: Solid.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/Solid.cpp,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** Solid.cpp 14 Mar 2005 01:20:53 -0000 1.27 --- Solid.cpp 21 Mar 2005 04:29:05 -0000 1.28 *************** *** 33,37 **** { // "mData" is initialized in its own constructor. ! setEventHandler(NULL); setUserData(NULL); } --- 33,37 ---- { // "mData" is initialized in its own constructor. ! setCollisionEventHandler(NULL); setUserData(NULL); } *************** *** 346,355 **** } ! void Solid::setEventHandler(CollisionEventHandler* eventHandler) { mCollisionEventHandler = eventHandler; } ! CollisionEventHandler* Solid::getEventHandler()const { return mCollisionEventHandler; --- 346,355 ---- } ! void Solid::setCollisionEventHandler(CollisionEventHandler* eventHandler) { mCollisionEventHandler = eventHandler; } ! CollisionEventHandler* Solid::getCollisionEventHandler()const { return mCollisionEventHandler; Index: opal.h =================================================================== RCS file: /cvsroot/opal/opal/src/opal.h,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** opal.h 14 Mar 2005 05:18:27 -0000 1.23 --- opal.h 21 Mar 2005 04:29:05 -0000 1.24 *************** *** 65,68 **** --- 65,69 ---- #include "JointBreakEventHandler.h" #include "CollisionEventHandler.h" + #include "PostStepEventHandler.h" #include "Blueprint.h" #include "BlueprintInstance.h" Index: Solid.h =================================================================== RCS file: /cvsroot/opal/opal/src/Solid.h,v retrieving revision 1.83 retrieving revision 1.84 diff -C2 -d -r1.83 -r1.84 *** Solid.h 14 Mar 2005 01:20:53 -0000 1.83 --- Solid.h 21 Mar 2005 04:29:05 -0000 1.84 *************** *** 179,188 **** virtual void OPAL_CALL translateMass(const Vec3r& offset) = 0; ! /// Sets the Solid's event handler. ! virtual void OPAL_CALL setEventHandler( CollisionEventHandler* eventHandler); ! /// Returns the Solid's event handler. ! virtual CollisionEventHandler* OPAL_CALL getEventHandler()const; //// Quickly spinning solids should be set as fast rotating solids to --- 179,190 ---- virtual void OPAL_CALL translateMass(const Vec3r& offset) = 0; ! /// Sets the Solid's collision event handler. ! virtual void OPAL_CALL setCollisionEventHandler( CollisionEventHandler* eventHandler); ! /// Returns the Solid's collision event handler. If this returns ! /// NULL, the Solid is not using one. ! virtual CollisionEventHandler* OPAL_CALL ! getCollisionEventHandler()const; //// Quickly spinning solids should be set as fast rotating solids to *************** *** 223,227 **** SolidData mData; ! /// Pointer to this Solid's event handler. CollisionEventHandler* mCollisionEventHandler; --- 225,229 ---- SolidData mData; ! /// Pointer to this Solid's collision event handler. CollisionEventHandler* mCollisionEventHandler; --- NEW FILE: PostStepEventHandler.h --- /************************************************************************* * * * 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. * * * *************************************************************************/ #ifndef OPAL_POST_STEP_EVENT_HANDLER_H #define OPAL_POST_STEP_EVENT_HANDLER_H #include "Defines.h" #include "EventHandler.h" namespace opal { /// A listener that gets notified when a simulation step has finished. class PostStepEventHandler : public EventHandler { public: PostStepEventHandler(); virtual ~PostStepEventHandler(); /// Called once for each pending CollisionEvent. This is always /// called at the end of a time step, so CollisionEvents always /// get handled right away. virtual void OPAL_CALL handlePostStepEvent() = 0; protected: private: }; } #endif Index: Joint.h =================================================================== RCS file: /cvsroot/opal/opal/src/Joint.h,v retrieving revision 1.64 retrieving revision 1.65 diff -C2 -d -r1.64 -r1.65 *** Joint.h 8 Mar 2005 22:05:03 -0000 1.64 --- Joint.h 21 Mar 2005 04:29:05 -0000 1.65 *************** *** 94,101 **** virtual void OPAL_CALL repairAccumDamage(); ! /// Sets the Joint's event handler. ! virtual void OPAL_CALL setEventHandler( JointBreakEventHandler* eventHandler); /// Enables or disables the given Joint axis' limits. virtual void OPAL_CALL setLimitsEnabled(int axisNum, bool e); --- 94,106 ---- virtual void OPAL_CALL repairAccumDamage(); ! /// Sets the Joint's break event handler. ! virtual void OPAL_CALL setJointBreakEventHandler( JointBreakEventHandler* eventHandler); + /// Returns the Joint's break event handler. If this returns + /// NULL, the Joint is not using one. + virtual JointBreakEventHandler* OPAL_CALL + getJointBreakEventHandler()const; + /// Enables or disables the given Joint axis' limits. virtual void OPAL_CALL setLimitsEnabled(int axisNum, bool e); *************** *** 243,247 **** JointData mData; ! /// A pointer to the Joint's event handler. JointBreakEventHandler* mJointBreakEventHandler; --- 248,252 ---- JointData mData; ! /// A pointer to the Joint's break event handler. JointBreakEventHandler* mJointBreakEventHandler; Index: Simulator.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/Simulator.cpp,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -d -r1.47 -r1.48 *** Simulator.cpp 14 Mar 2005 05:18:27 -0000 1.47 --- Simulator.cpp 21 Mar 2005 04:29:05 -0000 1.48 *************** *** 41,44 **** --- 41,45 ---- #include "AccelerationSensor.h" #include "VolumeSensor.h" + #include "PostStepEventHandler.h" namespace opal *************** *** 51,54 **** --- 52,56 ---- setMaxAngularVel(defaults::maxAngularVel); setUserData(NULL); + setPostStepEventHandler(NULL); int i=0; *************** *** 116,122 **** while (mTimeBuffer >= mStepSize) { - // TODO: Call some user-defined function here; maybe have - // a BeginStepEventHandler - // Update Sensors. std::vector<Sensor*>::iterator sensorIter; --- 118,121 ---- *************** *** 217,225 **** // Update the Solid's CollisionEventHandler if applicable. ! if (solid->getEventHandler()) { ! solid->getEventHandler()-> internal_handlePendingCollisionEvents(); } } --- 216,230 ---- // Update the Solid's CollisionEventHandler if applicable. ! if (solid->getCollisionEventHandler()) { ! solid->getCollisionEventHandler()-> internal_handlePendingCollisionEvents(); } + + // Fire an event to the PostStepEventHandler, if one exists. + if (mPostStepEventHandler) + { + mPostStepEventHandler->handlePostStepEvent(); + } } *************** *** 240,243 **** --- 245,264 ---- } + real Simulator::getStepSize() + { + return mStepSize; + } + + void Simulator::setPostStepEventHandler( + PostStepEventHandler* eventHandler) + { + mPostStepEventHandler = eventHandler; + } + + PostStepEventHandler* Simulator::getPostStepEventHandler()const + { + return mPostStepEventHandler; + } + void Simulator::instantiateBlueprint( BlueprintInstance& instance, const Blueprint& bp, Index: SConscript =================================================================== RCS file: /cvsroot/opal/opal/src/SConscript,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** SConscript 14 Mar 2005 22:36:31 -0000 1.16 --- SConscript 21 Mar 2005 04:29:05 -0000 1.17 *************** *** 31,34 **** --- 31,35 ---- Point3r.h Portability.h + PostStepEventHandler.h Quaternion.h RaycastSensor.h Index: Simulator.h =================================================================== RCS file: /cvsroot/opal/opal/src/Simulator.h,v retrieving revision 1.87 retrieving revision 1.88 diff -C2 -d -r1.87 -r1.88 *** Simulator.h 14 Mar 2005 01:20:53 -0000 1.87 --- Simulator.h 21 Mar 2005 04:29:05 -0000 1.88 *************** *** 47,50 **** --- 47,51 ---- class VolumeSensor; class BlueprintInstance; + class PostStepEventHandler; struct RaycastResult; struct VolumeQueryResult; *************** *** 75,78 **** --- 76,91 ---- virtual void OPAL_CALL setStepSize(real stepSize); + /// Returns the constant step size used in the simulation. + virtual real OPAL_CALL getStepSize(); + + /// Sets the Simulator's post-step event handler. + virtual void OPAL_CALL setPostStepEventHandler( + PostStepEventHandler* eventHandler); + + /// Returns the Simulator's post-step event handler. If this + /// returns NULL, the Simulator is not using one. + virtual PostStepEventHandler* OPAL_CALL + getPostStepEventHandler()const; + /// Creates instances of all objects in a Blueprint and fills the /// given BlueprintInstance with pointers of the named objects. The *************** *** 325,328 **** --- 338,344 ---- unsigned long int mContactGroupFlags[32]; + /// Pointer to the Simulator's post-step event handler. + PostStepEventHandler* mPostStepEventHandler; + private: }; |