[Opal-commits] opal/src Matrix44r.h,1.28,1.29 RaycastSensor.cpp,1.5,1.6 Sensor.h,1.8,1.9 Simulator.h
Status: Inactive
Brought to you by:
tylerstreeter
|
From: tylerstreeter <tyl...@us...> - 2005-03-14 01:21:16
|
Update of /cvsroot/opal/opal/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27784/src Modified Files: Matrix44r.h RaycastSensor.cpp Sensor.h Simulator.h Solid.cpp Solid.h VolumeSensor.cpp VolumeSensor.h Log Message: finished implementing RaycastSensor and VolumeSensor Index: Sensor.h =================================================================== RCS file: /cvsroot/opal/opal/src/Sensor.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Sensor.h 9 Mar 2005 02:09:49 -0000 1.8 --- Sensor.h 14 Mar 2005 01:20:53 -0000 1.9 *************** *** 34,42 **** namespace opal { ! /// A device that records data from a simulation. Some Sensors can be ! /// attached to Solids, some can simply be positioned somewhere within ! /// an environment, and some can work either way. All Sensors start out ! /// disabled and must be initialized via init) before they can be ! /// enabled. class Sensor { --- 34,44 ---- namespace opal { ! /// A device that records data from a simulation. Sensors can either be ! /// attached to Solids or just positioned somewhere within an ! /// environment. Each Sensor maintains a transform matrix; depending ! /// on whether the Sensor is attached to a Solid, the transform is ! /// relative to the attached Solid or the global origin. All Sensors ! /// start out disabled and must be initialized (via init) before they ! /// can be enabled. class Sensor { *************** *** 65,69 **** /// Sets the Sensor's transform. ! virtual void OPAL_CALL setTransform(const Matrix44r& name) = 0; /// Returns the Sensor's transform. --- 67,71 ---- /// Sets the Sensor's transform. ! virtual void OPAL_CALL setTransform(const Matrix44r& t) = 0; /// Returns the Sensor's transform. Index: Solid.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/Solid.cpp,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** Solid.cpp 8 Mar 2005 16:10:23 -0000 1.26 --- Solid.cpp 14 Mar 2005 01:20:53 -0000 1.27 *************** *** 137,143 **** } ! void Solid::setTransform(const Matrix44r& transform) { ! mData.transform = transform; internal_updateEngineTransform(); } --- 137,143 ---- } ! void Solid::setTransform(const Matrix44r& t) { ! mData.transform = t; internal_updateEngineTransform(); } Index: RaycastSensor.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/RaycastSensor.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** RaycastSensor.cpp 13 Mar 2005 23:07:10 -0000 1.5 --- RaycastSensor.cpp 14 Mar 2005 01:20:53 -0000 1.6 *************** *** 59,70 **** const RaycastResult& RaycastSensor::fireRay(real length) { ! // TODO: if mData.solid is valid, update this Sensor's ray ! // relative to the Solid; otherwise, update it relative to ! // global origin. ! // TODO: if this is attached to a Solid, keep the ray from ! // colliding with that Solid. ! return mSim->internal_fireRay(mData.ray, length); } --- 59,79 ---- const RaycastResult& RaycastSensor::fireRay(real length) { ! Rayr ray = mData.ray; ! // If the Sensor is attached to a Solid, we need to transform ! // the ray relative to that Solid's transform. ! if (mData.solid) ! { ! ray = mData.solid->getTransform() * ray; ! } ! // Use the Sensor's transform on the ray. ! ray = mData.transform * ray; ! ! // If this is attached to a Solid, the Simulator raycast function ! // will automatically ignore intersections between the ray and ! // that Solid. ! ! return mSim->internal_fireRay(ray, length, mData.solid); } Index: Solid.h =================================================================== RCS file: /cvsroot/opal/opal/src/Solid.h,v retrieving revision 1.82 retrieving revision 1.83 diff -C2 -d -r1.82 -r1.83 *** Solid.h 10 Mar 2005 21:10:36 -0000 1.82 --- Solid.h 14 Mar 2005 01:20:53 -0000 1.83 *************** *** 120,124 **** /// Sets this Solid's transform matrix. ! virtual void OPAL_CALL setTransform(const Matrix44r& transform); /// Returns a constant reference to this Solid's transform. --- 120,124 ---- /// Sets this Solid's transform matrix. ! virtual void OPAL_CALL setTransform(const Matrix44r& t); /// Returns a constant reference to this Solid's transform. Index: VolumeSensor.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/VolumeSensor.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** VolumeSensor.cpp 13 Mar 2005 23:07:11 -0000 1.2 --- VolumeSensor.cpp 14 Mar 2005 01:20:53 -0000 1.3 *************** *** 52,65 **** } ! const VolumeQueryResult& VolumeSensor::queryVolume(const Solid* volume) { ! // TODO: if mData.solid is valid, update this Sensor's transform ! // relative to the Solid; otherwise, update it relative to ! // global origin. ! // TODO: if this is attached to a Solid, don't add the volume Solid ! // to the results. ! return mSim->internal_queryVolume(volume); } --- 52,90 ---- } ! const VolumeQueryResult& VolumeSensor::queryVolume(Solid* volume) { ! // The volume Solid's transform will be totally ignored. ! // Store the volume Solid's transform. ! Matrix44r originalVolumeTransform = volume->getTransform(); ! Matrix44r newVolumeTransform; ! ! // If the Sensor is attached to a Solid, we need to transform ! // the volume relative to that Solid's transform. ! if (mData.solid) ! { ! newVolumeTransform = ! mData.solid->getTransform() * newVolumeTransform; ! } ! ! // Use the Sensor's transform on the volume. ! newVolumeTransform = mData.transform * newVolumeTransform; ! ! // Set the volume's new transform we just setup. ! volume->setTransform(newVolumeTransform); ! ! // If this is attached to a Solid, the Simulator volume query ! // function will automatically ignore intersections between the ! // volume and that Solid. ! ! // Query the volume for colliding Solids. ! const VolumeQueryResult& result = ! mSim->internal_queryVolume(volume, mData.solid); ! ! // Restore the volume Solid's original transform. ! volume->setTransform(originalVolumeTransform); ! ! return result; } Index: VolumeSensor.h =================================================================== RCS file: /cvsroot/opal/opal/src/VolumeSensor.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** VolumeSensor.h 12 Mar 2005 01:21:17 -0000 1.1 --- VolumeSensor.h 14 Mar 2005 01:20:53 -0000 1.2 *************** *** 131,136 **** /// Queries the Sensor's environment with the given Solid's volume, /// returning a list of the Solids that collide with that Solid. virtual const VolumeQueryResult& OPAL_CALL queryVolume( ! const Solid* volume); virtual void OPAL_CALL setEnabled(bool e); --- 131,139 ---- /// Queries the Sensor's environment with the given Solid's volume, /// returning a list of the Solids that collide with that Solid. + /// The given Solid's transform will be totally ignored; use the + /// Sensor's transform instead. If this Sensor is attached to + /// a Solid, that Solid will not be added to the results. virtual const VolumeQueryResult& OPAL_CALL queryVolume( ! Solid* volume); virtual void OPAL_CALL setEnabled(bool e); Index: Matrix44r.h =================================================================== RCS file: /cvsroot/opal/opal/src/Matrix44r.h,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** Matrix44r.h 2 Mar 2005 05:30:32 -0000 1.28 --- Matrix44r.h 14 Mar 2005 01:20:52 -0000 1.29 *************** *** 45,49 **** inline Matrix44r operator-(const Matrix44r & lhs, const Matrix44r & rhs); inline Point3r operator*(const Matrix44r & m, const Point3r &p); ! inline Rayr operator*(const Matrix44r & m, const Rayr &p); inline bool inverse(Matrix44r & dest, const Matrix44r & src); inline void fastInverse(Matrix44r & dest, const Matrix44r & src); --- 45,49 ---- inline Matrix44r operator-(const Matrix44r & lhs, const Matrix44r & rhs); inline Point3r operator*(const Matrix44r & m, const Point3r &p); ! inline Rayr operator*(const Matrix44r & m, const Rayr &r); inline bool inverse(Matrix44r & dest, const Matrix44r & src); inline void fastInverse(Matrix44r & dest, const Matrix44r & src); *************** *** 543,547 **** result(2, 2)).lengthSquared(); ! //TODO: write opal::abs if(fabs(l0) > eps) l0 = 1.0f / l0; if(fabs(l1) > eps) l1 = 1.0f / l1; --- 543,547 ---- result(2, 2)).lengthSquared(); ! // TODO: write opal::abs. if(fabs(l0) > eps) l0 = 1.0f / l0; if(fabs(l1) > eps) l1 = 1.0f / l1; *************** *** 648,658 **** } ! inline Rayr operator*(const Matrix44r & m, const Rayr & p) { ! Rayr r(m * p.getOrigin(), m * p.getDir()); ! return r; } } - #endif --- 648,657 ---- } ! inline Rayr operator*(const Matrix44r & m, const Rayr & r) { ! Rayr ray(m * r.getOrigin(), m * r.getDir()); ! return ray; } } #endif Index: Simulator.h =================================================================== RCS file: /cvsroot/opal/opal/src/Simulator.h,v retrieving revision 1.86 retrieving revision 1.87 diff -C2 -d -r1.86 -r1.87 *** Simulator.h 13 Mar 2005 23:07:11 -0000 1.86 --- Simulator.h 14 Mar 2005 01:20:53 -0000 1.87 *************** *** 226,234 **** /// into the scene and returns intersections results. virtual const RaycastResult& OPAL_CALL internal_fireRay( ! const Rayr& r, real length) = 0; /// Helper function used for volume queries. virtual const VolumeQueryResult& OPAL_CALL internal_queryVolume( ! const Solid* volume) = 0; /// Returns the Simulator's contact group flags. --- 226,234 ---- /// into the scene and returns intersections results. virtual const RaycastResult& OPAL_CALL internal_fireRay( ! const Rayr& r, real length, const Solid* attachedSolid) = 0; /// Helper function used for volume queries. virtual const VolumeQueryResult& OPAL_CALL internal_queryVolume( ! const Solid* volume, const Solid* attachedSolid) = 0; /// Returns the Simulator's contact group flags. |