|
@@ -159,20 +159,36 @@ PhysicsVehicle *PhysicsScene::addVehicleChild(SceneEntity *newEntity, Number mas
|
|
|
void PhysicsScene::removePhysicsChild(SceneEntity *entity) {
|
|
void PhysicsScene::removePhysicsChild(SceneEntity *entity) {
|
|
|
PhysicsSceneEntity *ent = getPhysicsEntityBySceneEntity(entity);
|
|
PhysicsSceneEntity *ent = getPhysicsEntityBySceneEntity(entity);
|
|
|
if(ent) {
|
|
if(ent) {
|
|
|
- physicsWorld->removeRigidBody(ent->rigidBody);
|
|
|
|
|
- physicsWorld->removeCollisionObject(ent->collisionObject);
|
|
|
|
|
- for(int i=0; i < physicsChildren.size(); i++) {
|
|
|
|
|
- if(physicsChildren[i] == ent) {
|
|
|
|
|
- physicsChildren.erase(physicsChildren.begin()+i);
|
|
|
|
|
|
|
+ if(ent->getType() == PhysicsSceneEntity::CHARACTER_CONTROLLER) {
|
|
|
|
|
+ removeCharacterChild((PhysicsCharacter *)ent);
|
|
|
|
|
+ } else {
|
|
|
|
|
+
|
|
|
|
|
+ if(ent->rigidBody)
|
|
|
|
|
+ physicsWorld->removeRigidBody(ent->rigidBody);
|
|
|
|
|
+ physicsWorld->removeCollisionObject(ent->collisionObject);
|
|
|
|
|
+ for(int i=0; i < physicsChildren.size(); i++) {
|
|
|
|
|
+ if(physicsChildren[i] == ent) {
|
|
|
|
|
+ physicsChildren.erase(physicsChildren.begin()+i);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
- for(int i=0; i < collisionChildren.size(); i++) {
|
|
|
|
|
- if(collisionChildren[i] == ent) {
|
|
|
|
|
- collisionChildren.erase(collisionChildren.begin()+i);
|
|
|
|
|
|
|
+ for(int i=0; i < collisionChildren.size(); i++) {
|
|
|
|
|
+ if(collisionChildren[i] == ent) {
|
|
|
|
|
+ collisionChildren.erase(collisionChildren.begin()+i);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
delete ent;
|
|
delete ent;
|
|
|
|
|
+ CollisionScene::removeEntity(entity);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+void PhysicsScene::removeEntity(SceneEntity *entity) {
|
|
|
|
|
+ PhysicsSceneEntity *ent = getPhysicsEntityBySceneEntity(entity);
|
|
|
|
|
+ if(ent) {
|
|
|
|
|
+ removePhysicsChild(entity);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ CollisionScene::removeEntity(entity);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
PhysicsSceneEntity *PhysicsScene::getPhysicsEntityBySceneEntity(SceneEntity *entity) {
|
|
PhysicsSceneEntity *PhysicsScene::getPhysicsEntityBySceneEntity(SceneEntity *entity) {
|