void Physics3DComponent::onEnter() { Component::onEnter(); if (_physics3DObj->getPhysicsWorld() == nullptr && _owner) { auto scene = _owner->getScene(); if (scene) addToPhysicsWorld(scene->getPhysics3DWorld()); } }
void PhysicsBody::onAdd() { _owner->_physicsBody = this; auto contentSize = _owner->getContentSize(); _ownerCenterOffset.x = 0.5f * contentSize.width; _ownerCenterOffset.y = 0.5f * contentSize.height; setRotationOffset(_owner->getRotation()); // component may be added after onEnter() has been invoked, so we should add // this line to make sure physics body is added to physics world addToPhysicsWorld(); }
void PhysicsBody::onEnter() { addToPhysicsWorld(); }