KX_BulletPhysicsController::~KX_BulletPhysicsController () { // The game object has a direct link to if (m_pObject) { // If we cheat in SetObject, we must also cheat here otherwise the // object will still things it has a physical controller // Note that it requires that m_pObject is reset in case the object is deleted // before the controller (usual case, see KX_Scene::RemoveNodeDestructObjec) // The non usual case is when the object is not deleted because its reference is hanging // in a AddObject actuator but the node is deleted. This case is covered here. KX_GameObject* gameobj = (KX_GameObject*) m_pObject->GetSGClientObject(); gameobj->SetPhysicsController(NULL,false); } }
void KX_BulletPhysicsController::SetObject (SG_IObject* object) { SG_Controller::SetObject(object); // cheating here... //should not be necessary, is it for duplicates ? KX_GameObject* gameobj = (KX_GameObject*) object->GetSGClientObject(); gameobj->SetPhysicsController(this,gameobj->IsDynamic()); CcdPhysicsController::setNewClientInfo(gameobj->getClientInfo()); if (m_bSensor) { // use a different callback function for sensor object, // bullet will not synchronize, we must do it explicitly SG_Callbacks& callbacks = gameobj->GetSGNode()->GetCallBackFunctions(); callbacks.m_updatefunc = KX_GameObject::SynchronizeTransformFunc; } }