From 566053319a47119bf718154f800659f9f0b86472 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Mon, 14 Apr 2008 20:54:20 +0000 Subject: fix BGE bug #8309: After Parent Object added to the visual layer, Child Camera won't follow. This bug fix is made of two parts: 1) It's now possible to dynamically add a camera. 2) Empty camera name on a SetCamera actuator now points to the actuator's parent object if this object is a camera. This trick is useful to make current a dynamically created camera: just add a SetCamera actuator on the camera itself and leave the name empty. Later, when the camera is added in the scene with an AddObject actuator, either directly or via a parent object, you just need to activate the actuator to make the newly created camera current. If you set a name on a SetCamera actuator, it will always point to the original camera, even after replication. --- source/gameengine/Ketsji/KX_Camera.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'source/gameengine/Ketsji/KX_Camera.cpp') diff --git a/source/gameengine/Ketsji/KX_Camera.cpp b/source/gameengine/Ketsji/KX_Camera.cpp index b75662f01c9..aa15199b816 100644 --- a/source/gameengine/Ketsji/KX_Camera.cpp +++ b/source/gameengine/Ketsji/KX_Camera.cpp @@ -69,7 +69,22 @@ KX_Camera::~KX_Camera() } +CValue* KX_Camera::GetReplica() +{ + KX_Camera* replica = new KX_Camera(*this); + + // this will copy properties and so on... + CValue::AddDataToReplica(replica); + ProcessReplica(replica); + + return replica; +} +void KX_Camera::ProcessReplica(KX_Camera* replica) +{ + KX_GameObject::ProcessReplica(replica); +} + MT_Transform KX_Camera::GetWorldToCamera() const { MT_Transform camtrans; -- cgit v1.2.3