Revision: 8967
          http://playerstage.svn.sourceforge.net/playerstage/?rev=8967&view=rev
Author:   hsujohnhsu
Date:     2010-11-13 13:38:43 +0000 (Sat, 13 Nov 2010)

Log Message:
-----------
fix for nested model bug:

https://code.ros.org/trac/ros-pkg/ticket/4368

need to do the same in trunk, updating ticket for Nate.

Modified Paths:
--------------
    code/gazebo/branches/wg/server/Model.cc

Modified: code/gazebo/branches/wg/server/Model.cc
===================================================================
--- code/gazebo/branches/wg/server/Model.cc     2010-11-12 04:44:03 UTC (rev 
8966)
+++ code/gazebo/branches/wg/server/Model.cc     2010-11-13 13:38:43 UTC (rev 
8967)
@@ -297,8 +297,7 @@
 {
   std::string p = prefix + "  ";
   std::string typeName;
-  //std::map<std::string, Body* >::iterator bodyIter;
-  std::vector<Entity* >::iterator bodyIter;
+  std::vector<Entity* >::iterator entityIter;
   std::map<std::string, Controller* >::iterator contIter;
   JointContainer::iterator jointIter;
 
@@ -322,13 +321,12 @@
   {
     stream << prefix << "  " << *(this->staticP) << "\n";
 
-    for (bodyIter=this->children.begin(); bodyIter!=this->children.end(); 
bodyIter++)
+    for (entityIter=this->children.begin(); entityIter!=this->children.end(); 
entityIter++)
     {
       stream << "\n";
-      Entity *entity = *bodyIter;
-      if (entity && entity->GetType() == Entity::BODY)
+      if ((*entityIter) && (*entityIter)->GetType() == Entity::BODY)
       {
-        Body *body = (Body*)(entity);
+        Body *body = (Body*)(*entityIter);
         body->Save(p, stream);
       }
     }
@@ -420,7 +418,7 @@
 
   //DiagnosticTimer timer("Model[" + this->GetName() + "] Update ");
 
-  std::vector<Entity*>::iterator bodyIter;
+  std::vector<Entity*>::iterator entityIter;
   std::map<std::string, Controller* >::iterator contIter;
   JointContainer::iterator jointIter;
 
@@ -429,18 +427,30 @@
   {
     //DiagnosticTimer timer("Model[" + this->GetName() + "] Bodies Update ");
 
-    for (bodyIter=this->children.begin(); 
-         bodyIter!=this->children.end(); bodyIter++)
+    for (entityIter=this->children.begin(); 
+         entityIter!=this->children.end(); entityIter++)
     {
-      if (*bodyIter && (*bodyIter)->GetType() == Entity::BODY)
+      if (*entityIter)
       {
-        Body *body = (Body*)(*bodyIter);
+        if ((*entityIter)->GetType() == Entity::BODY)
+        {
+          Body *body = (Body*)(*entityIter);
 #ifdef USE_THREADPOOL
-        World::Instance()->threadPool->schedule(
-            boost::bind(&Body::Update,body));
+          
World::Instance()->threadPool->schedule(boost::bind(&Body::Update,body));
 #else
-        body->Update();
+          body->Update();
 #endif
+        }
+        else if ((*entityIter)->GetType() == Entity::MODEL)
+        {
+          // for nested Models
+          Model *model = (Model*)(*entityIter);
+#ifdef USE_THREADPOOL
+          
World::Instance()->threadPool->schedule(boost::bind(&Model::Update,model));
+#else
+          model->Update();
+#endif
+        }
       }
     }
   }


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

------------------------------------------------------------------------------
Centralized Desktop Delivery: Dell and VMware Reference Architecture
Simplifying enterprise desktop deployment and management using
Dell EqualLogic storage and VMware View: A highly scalable, end-to-end
client virtualization framework. Read more!
http://p.sf.net/sfu/dell-eql-dev2dev
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit

Reply via email to