Revision: 8082
          http://playerstage.svn.sourceforge.net/playerstage/?rev=8082&view=rev
Author:   natepak
Date:     2009-07-23 01:11:01 +0000 (Thu, 23 Jul 2009)

Log Message:
-----------
Added dInitODE2 and thread safety for ODE

Modified Paths:
--------------
    code/gazebo/trunk/server/Simulator.cc
    code/gazebo/trunk/server/physics/PhysicsEngine.hh
    code/gazebo/trunk/server/physics/ode/ODEPhysics.cc
    code/gazebo/trunk/server/physics/ode/ODEPhysics.hh

Modified: code/gazebo/trunk/server/Simulator.cc
===================================================================
--- code/gazebo/trunk/server/Simulator.cc       2009-07-22 22:37:08 UTC (rev 
8081)
+++ code/gazebo/trunk/server/Simulator.cc       2009-07-23 01:11:01 UTC (rev 
8082)
@@ -599,6 +599,8 @@
 {
   World *world = World::Instance();
 
+  world->GetPhysicsEngine()->InitForThread();
+
   double step = world->GetPhysicsEngine()->GetStepTime();
   double physicsUpdateRate = world->GetPhysicsEngine()->GetUpdateRate();
   double physicsUpdatePeriod = 1.0 / physicsUpdateRate;

Modified: code/gazebo/trunk/server/physics/PhysicsEngine.hh
===================================================================
--- code/gazebo/trunk/server/physics/PhysicsEngine.hh   2009-07-22 22:37:08 UTC 
(rev 8081)
+++ code/gazebo/trunk/server/physics/PhysicsEngine.hh   2009-07-23 01:11:01 UTC 
(rev 8082)
@@ -95,6 +95,9 @@
   
     /// \brief Initialize the physics engine
     public: virtual void Init() = 0;
+
+    /// \brief Initialize for separate thread
+    public: virtual void InitForThread() = 0;
   
     /// \brief Update the physics engine collision
     public: virtual void UpdateCollision() = 0;

Modified: code/gazebo/trunk/server/physics/ode/ODEPhysics.cc
===================================================================
--- code/gazebo/trunk/server/physics/ode/ODEPhysics.cc  2009-07-22 22:37:08 UTC 
(rev 8081)
+++ code/gazebo/trunk/server/physics/ode/ODEPhysics.cc  2009-07-23 01:11:01 UTC 
(rev 8082)
@@ -56,8 +56,10 @@
     : PhysicsEngine()
 {
   // Collision detection init
-  dInitODE();
+  dInitODE2(0);
 
+  dAllocateODEDataForThread(dAllocateMaskAll);
+
   this->worldId = dWorldCreate();
 
   //this->spaceId = dSimpleSpaceCreate(0);
@@ -80,6 +82,8 @@
 // Destructor
 ODEPhysics::~ODEPhysics()
 {
+  dCloseODE();
+
   if (this->spaceId)
     dSpaceDestroy(this->spaceId);
 
@@ -152,6 +156,13 @@
 }
 
 
////////////////////////////////////////////////////////////////////////////////
+// Initialize for separate thread
+void ODEPhysics::InitForThread()
+{
+  dAllocateODEDataForThread(dAllocateMaskAll);
+}
+
+////////////////////////////////////////////////////////////////////////////////
 // Update the ODE collisions, create joints
 void ODEPhysics::UpdateCollision()
 {

Modified: code/gazebo/trunk/server/physics/ode/ODEPhysics.hh
===================================================================
--- code/gazebo/trunk/server/physics/ode/ODEPhysics.hh  2009-07-22 22:37:08 UTC 
(rev 8081)
+++ code/gazebo/trunk/server/physics/ode/ODEPhysics.hh  2009-07-23 01:11:01 UTC 
(rev 8082)
@@ -101,6 +101,9 @@
   /// \brief Initialize the ODE engine
   public: virtual void Init();
 
+  /// \brief Initialize for separate thread
+  public: virtual void InitForThread();
+
   /// \brief Update the ODE collision
   public: virtual void UpdateCollision();
 


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit

Reply via email to