[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [51203] trunk/blender: patch [#31875] Patch to get scene access through a game object

Campbell Barton ideasman42 at gmail.com
Tue Oct 9 07:58:12 CEST 2012


Revision: 51203
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=51203
Author:   campbellbarton
Date:     2012-10-09 05:58:09 +0000 (Tue, 09 Oct 2012)
Log Message:
-----------
patch [#31875] Patch to get scene access through a game object
from Jay Parker (battery) 

Modified Paths:
--------------
    trunk/blender/doc/python_api/rst/bge.types.rst
    trunk/blender/source/gameengine/Ketsji/KX_GameObject.cpp
    trunk/blender/source/gameengine/Ketsji/KX_GameObject.h

Modified: trunk/blender/doc/python_api/rst/bge.types.rst
===================================================================
--- trunk/blender/doc/python_api/rst/bge.types.rst	2012-10-09 03:44:29 UTC (rev 51202)
+++ trunk/blender/doc/python_api/rst/bge.types.rst	2012-10-09 05:58:09 UTC (rev 51203)
@@ -333,7 +333,8 @@
 
    .. attribute:: useContinue
 
-      The actions continue option, True or False. When True, the action will always play from where last left off, otherwise negative events to this actuator will reset it to its start frame.
+      The actions continue option, True or False. When True, the action will always play from where last left off,
+      otherwise negative events to this actuator will reset it to its start frame.
 
       :type: boolean
 
@@ -879,7 +880,8 @@
 
    .. note::
       
-      Calling ANY method or attribute on an object that has been removed from a scene will raise a SystemError, if an object may have been removed since last accessing it use the :data:`invalid` attribute to check.
+      Calling ANY method or attribute on an object that has been removed from a scene will raise a SystemError,
+      if an object may have been removed since last accessing it use the :data:`invalid` attribute to check.
 
    KX_GameObject can be subclassed to extend functionality. For example:
 
@@ -999,6 +1001,12 @@
 
       :type: :class:`KX_GameObject` or None
 
+   .. attribute:: scene
+
+      The object's scene. (read-only).
+
+      :type: :class:`KX_Scene` or None
+
    .. attribute:: visible
 
       visibility flag.
@@ -4558,7 +4566,9 @@
    
    .. data:: KX_ACT_ARMATURE_RUN
 
-      Just make sure the armature will be updated on the next graphic frame. This is the only persistent mode of the actuator: it executes automatically once per frame until stopped by a controller
+      Just make sure the armature will be updated on the next graphic frame.
+      This is the only persistent mode of the actuator:
+      it executes automatically once per frame until stopped by a controller
       
       :value: 0
 

Modified: trunk/blender/source/gameengine/Ketsji/KX_GameObject.cpp
===================================================================
--- trunk/blender/source/gameengine/Ketsji/KX_GameObject.cpp	2012-10-09 03:44:29 UTC (rev 51202)
+++ trunk/blender/source/gameengine/Ketsji/KX_GameObject.cpp	2012-10-09 05:58:09 UTC (rev 51203)
@@ -1682,7 +1682,8 @@
 	KX_PYATTRIBUTE_RO_FUNCTION("name",		KX_GameObject, pyattr_get_name),
 	KX_PYATTRIBUTE_RO_FUNCTION("parent",	KX_GameObject, pyattr_get_parent),
 	KX_PYATTRIBUTE_RO_FUNCTION("members",	KX_GameObject, pyattr_get_instance_objects),
-	KX_PYATTRIBUTE_RO_FUNCTION("group",	KX_GameObject, pyattr_get_dupli_group_object),
+	KX_PYATTRIBUTE_RO_FUNCTION("group",		KX_GameObject, pyattr_get_dupli_group_object),
+	KX_PYATTRIBUTE_RO_FUNCTION("scene",		KX_GameObject, pyattr_get_scene),
 	KX_PYATTRIBUTE_RO_FUNCTION("life",		KX_GameObject, pyattr_get_life),
 	KX_PYATTRIBUTE_RW_FUNCTION("mass",		KX_GameObject, pyattr_get_mass,		pyattr_set_mass),
 	KX_PYATTRIBUTE_RW_FUNCTION("linVelocityMin",		KX_GameObject, pyattr_get_lin_vel_min, pyattr_set_lin_vel_min),
@@ -1988,6 +1989,17 @@
 	Py_RETURN_NONE;
 }
 
+PyObject* KX_GameObject::pyattr_get_scene(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
+{
+	KX_GameObject *self = static_cast<KX_GameObject*>(self_v);
+	SG_Node *node = self->GetSGNode();
+	KX_Scene *scene = static_cast<KX_Scene *>(node->GetSGClientInfo());
+	if (scene) {
+		return scene->GetProxy();
+	}
+	Py_RETURN_NONE;
+}
+
 PyObject *KX_GameObject::pyattr_get_dupli_group_object(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
 {
 	KX_GameObject* self= static_cast<KX_GameObject*>(self_v);

Modified: trunk/blender/source/gameengine/Ketsji/KX_GameObject.h
===================================================================
--- trunk/blender/source/gameengine/Ketsji/KX_GameObject.h	2012-10-09 03:44:29 UTC (rev 51202)
+++ trunk/blender/source/gameengine/Ketsji/KX_GameObject.h	2012-10-09 05:58:09 UTC (rev 51203)
@@ -980,6 +980,7 @@
 
 	static PyObject*	pyattr_get_dupli_group_object(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
 	static PyObject*	pyattr_get_instance_objects(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
+	static PyObject*	pyattr_get_scene(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
 
 	static PyObject*	pyattr_get_life(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
 	static PyObject*	pyattr_get_mass(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);




More information about the Bf-blender-cvs mailing list