[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [14424] trunk/blender/source/gameengine: fix BGE bug #8309: After Parent Object added to the visual layer, Child Camera won't follow.
Benoit Bolsee
benoit.bolsee at online.be
Mon Apr 14 22:54:32 CEST 2008
Revision: 14424
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=14424
Author: ben2610
Date: 2008-04-14 22:54:20 +0200 (Mon, 14 Apr 2008)
Log Message:
-----------
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.
Modified Paths:
--------------
trunk/blender/source/gameengine/Converter/KX_ConvertActuators.cpp
trunk/blender/source/gameengine/Ketsji/KX_Camera.cpp
trunk/blender/source/gameengine/Ketsji/KX_Camera.h
trunk/blender/source/gameengine/Ketsji/KX_SceneActuator.cpp
Modified: trunk/blender/source/gameengine/Converter/KX_ConvertActuators.cpp
===================================================================
--- trunk/blender/source/gameengine/Converter/KX_ConvertActuators.cpp 2008-04-14 20:50:40 UTC (rev 14423)
+++ trunk/blender/source/gameengine/Converter/KX_ConvertActuators.cpp 2008-04-14 20:54:20 UTC (rev 14424)
@@ -684,15 +684,11 @@
break;
}
case ACT_SCENE_CAMERA:
+ mode = KX_SceneActuator::KX_SCENE_SET_CAMERA;
if (sceneact->camera)
{
- mode = KX_SceneActuator::KX_SCENE_SET_CAMERA;
cam = (KX_Camera*) converter->FindGameObject(sceneact->camera);
}
- else
- {
- // TODO:warn user
- }
break;
case ACT_SCENE_RESTART:
{
Modified: trunk/blender/source/gameengine/Ketsji/KX_Camera.cpp
===================================================================
--- trunk/blender/source/gameengine/Ketsji/KX_Camera.cpp 2008-04-14 20:50:40 UTC (rev 14423)
+++ trunk/blender/source/gameengine/Ketsji/KX_Camera.cpp 2008-04-14 20:54:20 UTC (rev 14424)
@@ -69,7 +69,22 @@
}
+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;
Modified: trunk/blender/source/gameengine/Ketsji/KX_Camera.h
===================================================================
--- trunk/blender/source/gameengine/Ketsji/KX_Camera.h 2008-04-14 20:50:40 UTC (rev 14423)
+++ trunk/blender/source/gameengine/Ketsji/KX_Camera.h 2008-04-14 20:54:20 UTC (rev 14424)
@@ -134,6 +134,24 @@
KX_Camera(void* sgReplicationInfo,SG_Callbacks callbacks,const RAS_CameraData& camdata, bool frustum_culling = true, PyTypeObject *T = &Type);
virtual ~KX_Camera();
+ /**
+ * Inherited from CValue -- return a new copy of this
+ * instance allocated on the heap. Ownership of the new
+ * object belongs with the caller.
+ */
+ virtual CValue*
+ GetReplica(
+ );
+
+ /**
+ * Inherited from CValue -- Makes sure any internal
+ * data owned by this class is deep copied. Called internally
+ */
+ virtual void
+ ProcessReplica(
+ KX_Camera* replica
+ );
+
MT_Transform GetWorldToCamera() const;
MT_Transform GetCameraToWorld() const;
Modified: trunk/blender/source/gameengine/Ketsji/KX_SceneActuator.cpp
===================================================================
--- trunk/blender/source/gameengine/Ketsji/KX_SceneActuator.cpp 2008-04-14 20:50:40 UTC (rev 14423)
+++ trunk/blender/source/gameengine/Ketsji/KX_SceneActuator.cpp 2008-04-14 20:54:20 UTC (rev 14424)
@@ -105,6 +105,15 @@
{
m_scene->SetActiveCamera(m_camera);
}
+ else
+ {
+ // if no camera is set and the parent object is a camera, use it as the camera
+ SCA_IObject* parent = GetParent();
+ if (parent->isA(&KX_Camera::Type))
+ {
+ m_scene->SetActiveCamera((KX_Camera*)parent);
+ }
+ }
break;
default:
break;
More information about the Bf-blender-cvs
mailing list