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

Method addShape

core/physics/PhysicsBody.cpp:427–455  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

425}
426
427PhysicsShape* PhysicsBody::addShape(PhysicsShape* shape, bool addMassAndMoment /* = true*/)
428{
429 if (shape == nullptr)
430 return nullptr;
431
432 // add shape to body
433 if (_shapes.getIndex(shape) == -1)
434 {
435 shape->setBody(this);
436
437 // calculate the area, mass, and density
438 // area must update before mass, because the density changes depend on it.
439 if (addMassAndMoment)
440 {
441 _area += shape->getArea();
442 addMass(shape->getMass());
443 addMoment(shape->getMoment());
444 }
445
446 if (_world && cpBodyGetSpace(_cpBody))
447 {
448 _world->addShape(shape);
449 }
450
451 _shapes.pushBack(shape);
452 }
453
454 return shape;
455}
456
457void PhysicsBody::applyForce(const Vec2& force, const Vec2& offset)
458{

Callers 9

createCircleMethod · 0.45
createBoxMethod · 0.45
createPolygonMethod · 0.45
createEdgeSegmentMethod · 0.45
createEdgeBoxMethod · 0.45
createEdgePolygonMethod · 0.45
createEdgeChainMethod · 0.45
onEnterMethod · 0.45

Calls 6

cpBodyGetSpaceFunction · 0.85
pushBackMethod · 0.80
getIndexMethod · 0.45
setBodyMethod · 0.45
getAreaMethod · 0.45
getMassMethod · 0.45

Tested by 1

onEnterMethod · 0.36