Changeset 11071 for code/trunk/src/orxonox/collisionshapes
- Timestamp:
- Jan 17, 2016, 10:29:21 PM (9 years ago)
- Location:
- code/trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/orxonox/collisionshapes/CollisionShape.cc
r10624 r11071 57 57 RegisterObject(CollisionShape); 58 58 59 this->parent_ = 0;59 this->parent_ = nullptr; 60 60 this->parentID_ = OBJECTID_UNKNOWN; 61 this->collisionShape_ = 0;61 this->collisionShape_ = nullptr; 62 62 this->position_ = Vector3::ZERO; 63 63 this->orientation_ = Quaternion::IDENTITY; … … 154 154 void CollisionShape::notifyDetached() 155 155 { 156 this->parent_ = 0;156 this->parent_ = nullptr; 157 157 this->parentID_ = OBJECTID_UNKNOWN; 158 158 } -
code/trunk/src/orxonox/collisionshapes/CollisionShape.h
r9667 r11071 61 61 virtual ~CollisionShape(); 62 62 63 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) ;63 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; 64 64 65 65 /** … … 181 181 182 182 btCollisionShape* collisionShape_; //!< The bullet collision shape of this CollisionShape. 183 CompoundCollisionShape* parent_; //!< The CompoundCollisionShape this CollisionShape belongs to, NULLif it doesn't belong to one.183 CompoundCollisionShape* parent_; //!< The CompoundCollisionShape this CollisionShape belongs to, nullptr if it doesn't belong to one. 184 184 unsigned int parentID_; //!< The objectID of the parent of this CollisionShape, which can either be a CompoundCollisionShape or a WorldEntity. 185 185 -
code/trunk/src/orxonox/collisionshapes/CompoundCollisionShape.cc
r10624 r11071 65 65 { 66 66 // Delete all children 67 for (std::map<CollisionShape*, btCollisionShape*>::iterator it = this->attachedShapes_.begin(); 68 it != this->attachedShapes_.end(); ++it) 67 for (const auto& mapEntry : this->attachedShapes_) 69 68 { 70 69 // make sure that the child doesn't want to detach itself --> speedup because of the missing update 71 it->first->notifyDetached();72 it->first->destroy();73 if (this->collisionShape_ == it->second)74 this->collisionShape_ = NULL; // don't destroy it twice70 mapEntry.first->notifyDetached(); 71 mapEntry.first->destroy(); 72 if (this->collisionShape_ == mapEntry.second) 73 this->collisionShape_ = nullptr; // don't destroy it twice 75 74 } 76 75 77 76 delete this->compoundShape_; 78 77 if (this->collisionShape_ == this->compoundShape_) 79 this->collisionShape_ = NULL; // don't destroy it twice78 this->collisionShape_ = nullptr; // don't destroy it twice 80 79 } 81 80 } … … 96 95 void CompoundCollisionShape::attach(CollisionShape* shape) 97 96 { 98 // If either the input shape is NULLor we try to attach the CollisionShape to itself.97 // If either the input shape is nullptr or we try to attach the CollisionShape to itself. 99 98 if (!shape || static_cast<CollisionShape*>(this) == shape) 100 99 return; … … 197 196 void CompoundCollisionShape::updatePublicShape() 198 197 { 199 btCollisionShape* primitive = 0; // The primitive shape, if there is one.198 btCollisionShape* primitive = nullptr; // The primitive shape, if there is one. 200 199 bool bPrimitive = true; // Whether the CompoundCollisionShape has just one non-empty CollisionShape. And that shape also has no transformation. 201 200 bool bEmpty = true; // Whether the CompoundCollisionShape is empty. 202 201 // Iterate over all CollisionShapes that belong to this CompoundCollisionShape. 203 for ( std::map<CollisionShape*, btCollisionShape*>::const_iterator it = this->attachedShapes_.begin(); it != this->attachedShapes_.end(); ++it)202 for (const auto& mapEntry : this->attachedShapes_) 204 203 { 205 204 // TODO: Make sure this is correct. 206 if ( it->second)205 if (mapEntry.second) 207 206 { 208 207 bEmpty = false; 209 if (! it->first->hasTransform() && bPrimitive)210 primitive = it->second;208 if (!mapEntry.first->hasTransform() && bPrimitive) 209 primitive = mapEntry.second; 211 210 else 212 211 { … … 221 220 { 222 221 // If there was none all along, nothing needs to be changed. 223 if (this->collisionShape_ == 0)222 if (this->collisionShape_ == nullptr) 224 223 return; 225 this->collisionShape_ = 0;224 this->collisionShape_ = nullptr; 226 225 } 227 226 // If the CompoundCollisionShape is just a primitive. … … 247 246 { 248 247 unsigned int i = 0; 249 for ( std::map<CollisionShape*, btCollisionShape*>::const_iterator it = this->attachedShapes_.begin(); it != this->attachedShapes_.end(); ++it)248 for (const auto& mapEntry : this->attachedShapes_) 250 249 { 251 250 if (i == index) 252 return it->first;251 return mapEntry.first; 253 252 ++i; 254 253 } 255 return 0;254 return nullptr; 256 255 } 257 256 … … 267 266 std::vector<CollisionShape*> shapes; 268 267 // Iterate through all attached CollisionShapes and add them to the list of shapes. 269 for( std::map<CollisionShape*, btCollisionShape*>::iterator it = this->attachedShapes_.begin(); it != this->attachedShapes_.end(); it++)270 shapes.push_back( it->first);268 for(const auto& mapEntry : this->attachedShapes_) 269 shapes.push_back(mapEntry.first); 271 270 272 271 // Delete the compound shape and create a new one. … … 275 274 276 275 // Re-attach all CollisionShapes. 277 for(std::vector<CollisionShape*>::iterator it = shapes.begin(); it != shapes.end(); it++) 278 { 279 CollisionShape* shape = *it; 276 for(CollisionShape* shape : shapes) 277 { 280 278 shape->setScale3D(this->getScale3D()); 281 279 // Only actually attach if we didn't pick a CompoundCollisionShape with no content. -
code/trunk/src/orxonox/collisionshapes/CompoundCollisionShape.h
r9667 r11071 61 61 virtual ~CompoundCollisionShape(); 62 62 63 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) ;63 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; 64 64 65 65 void attach(CollisionShape* shape); … … 70 70 void updateAttachedShape(CollisionShape* shape); 71 71 72 virtual void changedScale() ;72 virtual void changedScale() override; 73 73 74 74 private: 75 75 void updatePublicShape(); 76 inline virtual btCollisionShape* createNewShape() const77 { assert(false); return 0; }76 virtual inline btCollisionShape* createNewShape() const override 77 { assert(false); return nullptr; } 78 78 79 79 btCompoundShape* compoundShape_; -
code/trunk/src/orxonox/collisionshapes/WorldEntityCollisionShape.cc
r10624 r11071 43 43 RegisterObject(WorldEntityCollisionShape); 44 44 45 this->worldEntityOwner_ = NULL;45 this->worldEntityOwner_ = nullptr; 46 46 // suppress synchronisation 47 47 this->setSyncMode(ObjectDirection::None); … … 54 54 CollisionShape::updateParent(); 55 55 56 assert(this->worldEntityOwner_ != 0);56 assert(this->worldEntityOwner_ != nullptr); 57 57 this->worldEntityOwner_->notifyCollisionShapeChanged(); 58 58 } -
code/trunk/src/orxonox/collisionshapes/WorldEntityCollisionShape.h
r10624 r11071 46 46 47 47 protected: 48 virtual void updateParent() ;48 virtual void updateParent() override; 49 49 50 50 private: 51 v oid parentChanged();51 virtual void parentChanged() override; 52 52 53 53 WorldEntity* worldEntityOwner_;
Note: See TracChangeset
for help on using the changeset viewer.