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

Method beforeSimulation

core/physics/PhysicsBody.cpp:920–954  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

918}
919
920void PhysicsBody::beforeSimulation(const Mat4& parentToWorldTransform,
921 const Mat4& nodeToWorldTransform,
922 float scaleX,
923 float scaleY,
924 float rotation)
925{
926 if (_recordScaleX != scaleX || _recordScaleY != scaleY)
927 {
928 _recordScaleX = scaleX;
929 _recordScaleY = scaleY;
930 setScale(scaleX, scaleY);
931 }
932
933 // set rotation
934 if (_recordedRotation != rotation)
935 {
936 setRotation(rotation);
937 }
938
939 // set position
940 auto worldPosition = _ownerCenterOffset;
941 nodeToWorldTransform.transformVector(worldPosition.x, worldPosition.y, worldPosition.z, 1.f, &worldPosition);
942 setPosition(worldPosition.x, worldPosition.y);
943
944 _recordPosX = worldPosition.x;
945 _recordPosY = worldPosition.y;
946
947 if (_owner->getAnchorPoint() != Vec2::ANCHOR_MIDDLE)
948 {
949 parentToWorldTransform.getInversed().transformVector(worldPosition.x, worldPosition.y, worldPosition.z, 1.f,
950 &worldPosition);
951 _offset.x = worldPosition.x - _owner->getPositionX();
952 _offset.y = worldPosition.y - _owner->getPositionY();
953 }
954}
955
956void PhysicsBody::afterSimulation(const Mat4& parentToWorldTransform, float parentRotation)
957{

Callers

nothing calls this directly

Calls 8

transformVectorMethod · 0.80
getAnchorPointMethod · 0.80
setScaleFunction · 0.50
setRotationFunction · 0.50
setPositionFunction · 0.50
getInversedMethod · 0.45
getPositionXMethod · 0.45
getPositionYMethod · 0.45

Tested by

no test coverage detected