Revision: 8439
          http://playerstage.svn.sourceforge.net/playerstage/?rev=8439&view=rev
Author:   natepak
Date:     2009-11-23 19:41:41 +0000 (Mon, 23 Nov 2009)

Log Message:
-----------
Not longer called model->Update if the model is static

Modified Paths:
--------------
    code/gazebo/trunk/server/Entity.cc
    code/gazebo/trunk/server/Entity.hh
    code/gazebo/trunk/server/Model.cc
    code/gazebo/trunk/server/World.cc
    code/gazebo/trunk/server/World.hh
    code/gazebo/trunk/server/physics/Geom.cc
    code/gazebo/trunk/server/physics/MapShape.cc
    code/gazebo/trunk/server/rendering/Light.cc
    code/gazebo/trunk/server/rendering/OgreVisual.cc

Modified: code/gazebo/trunk/server/Entity.cc
===================================================================
--- code/gazebo/trunk/server/Entity.cc  2009-11-23 16:17:24 UTC (rev 8438)
+++ code/gazebo/trunk/server/Entity.cc  2009-11-23 19:41:41 UTC (rev 8439)
@@ -151,6 +151,9 @@
 
   for (iter = this->children.begin(); iter != this->children.end(); iter++)
   {
+    if ( (*iter)->IsStatic())
+      continue;
+
     (*iter)->SetStatic(s);
     body = dynamic_cast<Body*>(*iter);
     if (body)
@@ -321,10 +324,11 @@
 // Handle a change of pose
 void Entity::PoseChange(bool notify)
 {
-  if (Simulator::Instance()->GetState() == Simulator::RUN)// || 
this->IsStatic())
+/*  if (Simulator::Instance()->GetState() == Simulator::RUN)
     this->visualNode->SetDirty(true, this->relativePose);
   else
-    this->visualNode->SetPose(this->relativePose);
+  */
+  this->visualNode->SetPose(this->relativePose);
 
   if (notify)
   {
@@ -335,3 +339,15 @@
       (*iter)->OnPoseChange();
   }
 }
+
+////////////////////////////////////////////////////////////////////////////////
+/// Get the parent model, if one exists
+Model *Entity::GetParentModel() const
+{
+  Entity *p = this->parent;
+
+  while (p && !p->IsModel())
+    p = p->GetParent();
+
+  return (Model*)p;
+}

Modified: code/gazebo/trunk/server/Entity.hh
===================================================================
--- code/gazebo/trunk/server/Entity.hh  2009-11-23 16:17:24 UTC (rev 8438)
+++ code/gazebo/trunk/server/Entity.hh  2009-11-23 19:41:41 UTC (rev 8439)
@@ -139,6 +139,10 @@
     /// \brief Return true if the entity is a model
     public: bool IsModel() const;
 
+    /// \brief Get the parent model, if one exists
+    /// \return Pointer to a model, or NULL if no parent model exists
+    public: Model *GetParentModel() const;
+
     /// \brief Return the name of this entity with the model scope
     ///        model1::...::modelN::entityName
     public: std::string GetScopedName();

Modified: code/gazebo/trunk/server/Model.cc
===================================================================
--- code/gazebo/trunk/server/Model.cc   2009-11-23 16:17:24 UTC (rev 8438)
+++ code/gazebo/trunk/server/Model.cc   2009-11-23 19:41:41 UTC (rev 8439)
@@ -538,7 +538,6 @@
 // Reset the model
 void Model::Reset()
 {
-  std::cout << "Model[" << this->GetName() << "] Reset\n";
   JointContainer::iterator jiter;
   std::map< std::string, Body* >::iterator biter;
   std::map<std::string, Controller* >::iterator citer;

Modified: code/gazebo/trunk/server/World.cc
===================================================================
--- code/gazebo/trunk/server/World.cc   2009-11-23 16:17:24 UTC (rev 8438)
+++ code/gazebo/trunk/server/World.cc   2009-11-23 19:41:41 UTC (rev 8439)
@@ -309,7 +309,7 @@
   std::vector< Model* >::iterator miter;
   for (miter=this->models.begin(); miter!=this->models.end(); miter++)
   {
-    if (*miter)
+    if (!(*miter)->IsStatic())
     {
 #ifdef USE_THREADPOOL
       this->threadPool->schedule(boost::bind(&Model::Update,(*miter)));
@@ -333,7 +333,6 @@
        Simulator::Instance()->GetPhysicsEnabled())
   {
     this->physicsEngine->UpdatePhysics();
-
     this->SaveState();
   }
 

Modified: code/gazebo/trunk/server/World.hh
===================================================================
--- code/gazebo/trunk/server/World.hh   2009-11-23 16:17:24 UTC (rev 8438)
+++ code/gazebo/trunk/server/World.hh   2009-11-23 19:41:41 UTC (rev 8439)
@@ -235,7 +235,7 @@
           {
             addEntitySignal.connect(subscriber);
           }
- 
+
   /// \brif Get the names of interfaces defined in the tree of a model
   private: void GetInterfaceNames(Entity* m, std::vector<std::string>& list);
 

Modified: code/gazebo/trunk/server/physics/Geom.cc
===================================================================
--- code/gazebo/trunk/server/physics/Geom.cc    2009-11-23 16:17:24 UTC (rev 
8438)
+++ code/gazebo/trunk/server/physics/Geom.cc    2009-11-23 19:41:41 UTC (rev 
8439)
@@ -140,11 +140,14 @@
 
     if (this->IsStatic())
       visual->MakeStatic();
+      
 
     childNode = childNode->GetNext("visual");
   }
 
 
+
+
   if (this->GetType() != Shape::PLANE && this->GetType() != Shape::HEIGHTMAP)
   {
     World::Instance()->RegisterGeom(this);

Modified: code/gazebo/trunk/server/physics/MapShape.cc
===================================================================
--- code/gazebo/trunk/server/physics/MapShape.cc        2009-11-23 16:17:24 UTC 
(rev 8438)
+++ code/gazebo/trunk/server/physics/MapShape.cc        2009-11-23 19:41:41 UTC 
(rev 8439)
@@ -174,15 +174,15 @@
     stream << "  <visual>";
     stream << "    <mesh>unit_box</mesh>";
     stream << "    <material>" << this->materialP->GetValue() << "</material>";
-    stream << "  <size>" << xSize << " " << ySize << " " << zSize << "</size>";
+    stream << "    <size>" << xSize << " "<< ySize << " " << zSize << 
"</size>";
     stream << "  </visual>";
     stream << "</geom:box>";
     stream << "</gazebo:world>";
 
     boxConfig->LoadString( stream.str() );
 
+    geom->SetStatic(true);
     geom->Load( boxConfig->GetRootNode()->GetChild() );
-    geom->SetStatic(true);
 
     delete boxConfig;
   }

Modified: code/gazebo/trunk/server/rendering/Light.cc
===================================================================
--- code/gazebo/trunk/server/rendering/Light.cc 2009-11-23 16:17:24 UTC (rev 
8438)
+++ code/gazebo/trunk/server/rendering/Light.cc 2009-11-23 19:41:41 UTC (rev 
8439)
@@ -1,5 +1,6 @@
 #include <Ogre.h>
 
+#include "Model.hh"
 #include "OgreDynamicLines.hh"
 #include "OgreVisual.hh"
 #include "OgreCreator.hh"
@@ -62,6 +63,7 @@
   else if (lightType == "directional")
   {
     this->light->setType(Ogre::Light::LT_DIRECTIONAL);
+    this->parent->GetParentModel()->SetStatic(true);
   }
   else if (lightType == "spot")
   {

Modified: code/gazebo/trunk/server/rendering/OgreVisual.cc
===================================================================
--- code/gazebo/trunk/server/rendering/OgreVisual.cc    2009-11-23 16:17:24 UTC 
(rev 8438)
+++ code/gazebo/trunk/server/rendering/OgreVisual.cc    2009-11-23 19:41:41 UTC 
(rev 8439)
@@ -126,11 +126,12 @@
 
   this->isStatic = isStatic;
 
-/*  if (this->isStatic)
+  if (this->isStatic)
+  {
     this->staticGeom = this->sceneNode->getCreator()->createStaticGeometry(
         this->GetName() + "_staticgeom");
+  }
   else
-  */
     this->staticGeom = NULL;
 }
 
@@ -354,22 +355,14 @@
   if (!this->staticGeom)
     this->staticGeom = 
OgreAdaptor::Instance()->sceneMgr->createStaticGeometry(this->sceneNode->getName()
 + "_Static");
 
-  //this->staticGeom->setRegionDimensions(Ogre::Vector3(1,1,1));
-  //this->staticGeom->setOrigin(Ogre::Vector3(2,2,1));
-
-  //this->sceneNode->setVisible(true);
-
   // Add the scene node to the static geometry
   this->staticGeom->addSceneNode(this->sceneNode);
 
   // Build the static geometry
   this->staticGeom->build();
 
-  // Detach the scene node from the parent. Prevents double rendering
+  // Prevent double rendering
   this->sceneNode->setVisible(false);
-  /*if (this->sceneNode->getParent())
-    this->sceneNode->getParent()->removeChild(this->sceneNode);
-    */
 }
 
 
////////////////////////////////////////////////////////////////////////////////
@@ -647,9 +640,8 @@
     obj->setCastShadows(shadows);
   }
 
-  /*if (this->IsStatic())
+  if (this->IsStatic())
     this->staticGeom->setCastShadows(shadows);
-    */
 }
 
 
////////////////////////////////////////////////////////////////////////////////
@@ -683,9 +675,10 @@
 
   if (this->IsStatic())
   {
-    //this->sceneNode->setParent( this->owner->GetVisu
+    //this->sceneNode->setParent(this->owner->GetVisualNode()->GetSceneNode() 
);
     //this->staticGeom->reset();
     //this->MakeStatic();
+    //this->staticGeom->setOrigin( Ogre::Vector3(pos.x, pos.y, pos.z) );
   }
   else
   {


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

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Playerstage-commit mailing list
Playerstage-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/playerstage-commit

Reply via email to