- Timestamp:
- Apr 16, 2014, 8:59:17 PM (11 years ago)
- Location:
- code/branches/modularships/src/orxonox/worldentities/pawns
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/modularships/src/orxonox/worldentities/pawns/ModularSpaceShip.cc
r10029 r10033 40 40 #include "items/ShipPart.h" 41 41 #include "worldentities/StaticEntity.h" 42 #include "collisionshapes/WorldEntityCollisionShape.h" 42 43 #include <BulletCollision/CollisionShapes/btCollisionShape.h> 43 44 … … 78 79 { 79 80 // iterate through all attached objects 80 for (unsigned int i=0; i < this->getNumAttachedObj(); i++)81 for (unsigned int i=0; i < (unsigned int)(this->getNumAttachedObj()); i++) 81 82 { 82 83 if (this->getAttachedObject(i) == NULL) … … 179 180 //orxout() << "ShipPart of Entity " << cs->getUserPointer() << ": " << this->getPartOfEntity((StaticEntity*)(cs->getUserPointer())) << endl; 180 181 182 orxout() << "CP before handleHit" << endl; 183 181 184 if (this->getPartOfEntity((StaticEntity*)(cs->getUserPointer())) != NULL) 182 185 this->getPartOfEntity((StaticEntity*)(cs->getUserPointer()))->handleHit(damage, healthdamage, shielddamage, originator); … … 276 279 if (itt->second == part) 277 280 { 278 //this->detach(itt->first);281 this->detach(itt->first); 279 282 //itt->first->destroy(); 280 itt->first->setActive(false); 281 itt->first->setVisible(false); 282 itt->first->setCollisionResponse(false); 283 //itt->first->setActive(false); 284 //itt->first->setVisible(false); 285 //itt->first->setCollisionResponse(false); 286 //itt->first->setCollisionType(None); 287 //itt->first->deactivatePhysics(); 283 288 this->partMap_.erase(itt); 284 289 } … … 286 291 } 287 292 293 /** 294 @brief 295 Detaches a child WorldEntity from this instance. 296 */ 297 void ModularSpaceShip::detach(WorldEntity* object) 298 { 299 std::set<WorldEntity*>::iterator it = this->children_.find(object); 300 if (it == this->children_.end()) 301 { 302 orxout(internal_warning) << "Cannot detach an object that is not a child." << endl; 303 return; 304 } 305 306 // collision shapes 307 orxout() << "MSS: detach()" << endl; 308 309 this->printBtChildShapes((btCompoundShape*)(this->getWorldEntityCollisionShape()->getCollisionShape()), 2, 0); 310 this->detachCollisionShape(object->collisionShape_); // after succeeding, causes a crash in the collision handling 311 this->printBtChildShapes((btCompoundShape*)(this->getWorldEntityCollisionShape()->getCollisionShape()), 2, 0); 312 313 // mass 314 if (object->getMass() > 0.0f) 315 { 316 this->childrenMass_ -= object->getMass(); 317 recalculateMassProps(); 318 } 319 320 this->detachNode(object->node_); 321 this->children_.erase(it); // this causes a crash when unloading the level. Or not? 322 323 object->notifyDetached(); 324 orxout() << "MSS: detach() completed." << endl; 325 } 288 326 } -
code/branches/modularships/src/orxonox/worldentities/pawns/ModularSpaceShip.h
r10023 r10033 118 118 void removeShipPart(ShipPart* part); 119 119 120 void detach(WorldEntity* object); 121 120 122 virtual void updatePartAssignment(); 121 123
Note: See TracChangeset
for help on using the changeset viewer.