MCPcopy Create free account
hub / github.com/axmolengine/axmol / removeAllShapes

Method removeAllShapes

core/physics/PhysicsBody.cpp:729–755  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

727}
728
729void PhysicsBody::removeAllShapes(bool reduceMassAndMoment /* = true*/)
730{
731 for (auto&& child : _shapes)
732 {
733 PhysicsShape* shape = dynamic_cast<PhysicsShape*>(child);
734
735 // deduce the area, mass and moment
736 // area must update before mass, because the density changes depend on it.
737 if (reduceMassAndMoment)
738 {
739 _area -= shape->getArea();
740 addMass(-shape->getMass());
741 addMoment(-shape->getMoment());
742 }
743
744 if (_world)
745 {
746 _world->removeShape(shape);
747 }
748
749 // set shape->_body = nullptr make the shape->setBody will not trigger the _body->removeShape function call.
750 shape->_body = nullptr;
751 shape->setBody(nullptr);
752 }
753
754 _shapes.clear();
755}
756
757void PhysicsBody::removeFromWorld()
758{

Calls 5

getAreaMethod · 0.45
getMassMethod · 0.45
removeShapeMethod · 0.45
setBodyMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected