[Orxonox-commit 5373] r10036 - in code/branches/modularships/src/orxonox: . collisionshapes worldentities/pawns

noep at orxonox.net noep at orxonox.net
Thu Apr 17 15:41:17 CEST 2014


Author: noep
Date: 2014-04-17 15:41:17 +0200 (Thu, 17 Apr 2014)
New Revision: 10036

Modified:
   code/branches/modularships/src/orxonox/Scene.cc
   code/branches/modularships/src/orxonox/collisionshapes/CompoundCollisionShape.cc
   code/branches/modularships/src/orxonox/worldentities/pawns/ModularSpaceShip.cc
   code/branches/modularships/src/orxonox/worldentities/pawns/ModularSpaceShip.h
Log:
Tried to prevent the StaticEntities & Collisionshapes from getting deleted by creating vectors of SmartPointers to them. didn't work.

Modified: code/branches/modularships/src/orxonox/Scene.cc
===================================================================
--- code/branches/modularships/src/orxonox/Scene.cc	2014-04-17 12:27:35 UTC (rev 10035)
+++ code/branches/modularships/src/orxonox/Scene.cc	2014-04-17 13:41:17 UTC (rev 10036)
@@ -344,6 +344,8 @@
     /*static*/ bool Scene::collisionCallback(btManifoldPoint& cp, const btCollisionObject* colObj0, int partId0,
                                              int index0, const btCollisionObject* colObj1, int partId1, int index1)
     {
+        orxout() << "collisionCb()" << endl;
+
         // get the WorldEntity pointers
         SmartPtr<WorldEntity> object0 = static_cast<WorldEntity*>(colObj0->getUserPointer());
         SmartPtr<WorldEntity> object1 = static_cast<WorldEntity*>(colObj1->getUserPointer());
@@ -359,6 +361,8 @@
         if (object1->isCollisionCallbackActive())
             modified |= object1->collidesAgainst(object0, cs0, cp);
 
+        orxout() << "collisionCb() completed." << endl;
+
         return modified;
     }
 }

Modified: code/branches/modularships/src/orxonox/collisionshapes/CompoundCollisionShape.cc
===================================================================
--- code/branches/modularships/src/orxonox/collisionshapes/CompoundCollisionShape.cc	2014-04-17 12:27:35 UTC (rev 10035)
+++ code/branches/modularships/src/orxonox/collisionshapes/CompoundCollisionShape.cc	2014-04-17 13:41:17 UTC (rev 10036)
@@ -137,15 +137,12 @@
         // If the input CollisionShape is actually attached.
         if (this->attachedShapes_.find(shape) != this->attachedShapes_.end())
         {
-            orxout() << "Still going..." << endl;
             this->attachedShapes_.erase(shape);
             if (shape->getCollisionShape())
                 this->compoundShape_->removeChildShape(shape->getCollisionShape()); // TODO: Apparently this is broken?
             shape->notifyDetached();
-            orxout() << "Still going...." << endl;
 
             this->updatePublicShape();
-            orxout() << "Still going....." << endl;
         }
         else
             orxout(internal_warning) << "Cannot detach non child collision shape" << endl;

Modified: code/branches/modularships/src/orxonox/worldentities/pawns/ModularSpaceShip.cc
===================================================================
--- code/branches/modularships/src/orxonox/worldentities/pawns/ModularSpaceShip.cc	2014-04-17 12:27:35 UTC (rev 10035)
+++ code/branches/modularships/src/orxonox/worldentities/pawns/ModularSpaceShip.cc	2014-04-17 13:41:17 UTC (rev 10036)
@@ -41,6 +41,7 @@
 #include "worldentities/StaticEntity.h"
 #include "collisionshapes/WorldEntityCollisionShape.h"
 #include <BulletCollision/CollisionShapes/btCollisionShape.h>
+#include <BulletCollision/CollisionShapes/btCompoundShape.h>
 
 
 
@@ -125,9 +126,36 @@
                 }
 
         this->partMap_[entity] = part;
+
+        //This adds a list of SmartPointers for all StaticEntities which have a ShipPart, preventing them from getting deleted. Hopefully.
+        SmartPtr<StaticEntity> newSmartPtr = entity;
+        SmartPtr<StaticEntity>* one = &newSmartPtr;
+        this->entityPtrList_.push_back(one);
+
+        this->createCSPtrList(this->getWorldEntityCollisionShape());
+
         orxout() << "New entity-part assignment created!" << endl;
     }
 
+    // This should add smartPointers to all (Orxonox)Collisionshapes of this SpaceShip, preventing them fromg etting deleted. Might not work due to weird acting getAttachedShape
+    void ModularSpaceShip::createCSPtrList(CompoundCollisionShape* cs)
+    {
+        for (int i=0; i < cs->getNumChildShapes(); i++)
+        {
+
+            if (!orxonox_cast<CompoundCollisionShape*>(cs->getAttachedShape(i)))
+            {
+                SmartPtr<CollisionShape> newSmartPtr = cs->getAttachedShape(i);
+                SmartPtr<CollisionShape>* one = &newSmartPtr;
+                this->csPtrList_.push_back(one);
+            }
+
+            if (orxonox_cast<CompoundCollisionShape*>(cs->getAttachedShape(i)))
+                createCSPtrList((CompoundCollisionShape*)(cs->getAttachedShape(i)));
+
+        }
+    }
+
     /**
     @brief
         Get the ShipPart an attached entity belongs to.

Modified: code/branches/modularships/src/orxonox/worldentities/pawns/ModularSpaceShip.h
===================================================================
--- code/branches/modularships/src/orxonox/worldentities/pawns/ModularSpaceShip.h	2014-04-17 12:27:35 UTC (rev 10035)
+++ code/branches/modularships/src/orxonox/worldentities/pawns/ModularSpaceShip.h	2014-04-17 13:41:17 UTC (rev 10036)
@@ -121,12 +121,16 @@
 
             virtual void updatePartAssignment();
 
+            void createCSPtrList(CompoundCollisionShape* cs);
+
         protected:
 
 
         private:
             void registerVariables();
             std::vector<ShipPart*> partList_;  // The list of all Parts mounted on this ModularSpaceShip.
+            std::vector<SmartPtr<StaticEntity>*> entityPtrList_;
+            std::vector<SmartPtr<CollisionShape>*> csPtrList_;
             std::map<StaticEntity*, ShipPart*> partMap_;
         
     };




More information about the Orxonox-commit mailing list