[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [49309] branches: Getting components back into a branch.

Mitchell Stokes mogurijin at gmail.com
Fri Jul 27 23:59:47 CEST 2012


Revision: 49309
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=49309
Author:   moguri
Date:     2012-07-27 21:59:47 +0000 (Fri, 27 Jul 2012)
Log Message:
-----------
Getting components back into a branch.

Modified Paths:
--------------
    branches/ge_components/release/scripts/bge_components/camera.py
    branches/ge_components/release/scripts/bge_components/vehicle.py
    branches/ge_components/release/scripts/modules/bpy/utils.py
    branches/ge_components/release/scripts/startup/bl_ui/space_logic.py
    branches/ge_components/source/blender/blenkernel/CMakeLists.txt
    branches/ge_components/source/blender/blenkernel/SConscript
    branches/ge_components/source/blender/blenkernel/intern/object.c
    branches/ge_components/source/blender/blenloader/intern/readfile.c
    branches/ge_components/source/blender/blenloader/intern/writefile.c
    branches/ge_components/source/blender/editors/space_logic/logic_ops.c
    branches/ge_components/source/blender/makesdna/DNA_object_types.h
    branches/ge_components/source/blender/makesdna/DNA_space_types.h
    branches/ge_components/source/blender/makesdna/intern/makesdna.c
    branches/ge_components/source/blender/makesrna/RNA_access.h
    branches/ge_components/source/blender/makesrna/intern/CMakeLists.txt
    branches/ge_components/source/blender/makesrna/intern/makesrna.c
    branches/ge_components/source/blender/makesrna/intern/rna_internal.h
    branches/ge_components/source/blender/makesrna/intern/rna_object.c
    branches/ge_components/source/blender/makesrna/intern/rna_space.c
    branches/ge_components/source/blender/python/intern/bpy.c
    branches/ge_components/source/gameengine/Converter/BL_BlenderDataConversion.cpp
    branches/ge_components/source/gameengine/Ketsji/CMakeLists.txt
    branches/ge_components/source/gameengine/Ketsji/KX_GameObject.cpp
    branches/ge_components/source/gameengine/Ketsji/KX_GameObject.h
    branches/ge_components/source/gameengine/Ketsji/KX_PythonInitTypes.cpp
    branches/ge_components/source/gameengine/Ketsji/KX_PythonInitTypes.h
    branches/ge_components/source/gameengine/Ketsji/KX_PythonSeq.cpp
    branches/ge_components/source/gameengine/Ketsji/KX_PythonSeq.h
    branches/ge_components/source/gameengine/Ketsji/KX_Scene.cpp

Added Paths:
-----------
    branches/ge_components/
    branches/ge_components/release/scripts/bge_components/
    branches/ge_components/source/blender/blenkernel/BKE_pycomponent.h
    branches/ge_components/source/blender/blenkernel/intern/python_component.c
    branches/ge_components/source/blender/makesdna/DNA_component_types.h
    branches/ge_components/source/blender/makesrna/intern/rna_pycomponent.c
    branches/ge_components/source/gameengine/Ketsji/KX_PythonComponent.cpp
    branches/ge_components/source/gameengine/Ketsji/KX_PythonComponent.h


Property changes on: branches/ge_components
___________________________________________________________________
Added: svn:ignore
   + *.pdb
.*
TAGS
cscope.out
sgc.bat
sgd.bat
smc.bat
ssenv.bat
tags
user-config.py
CMakeFiles
CMakeCache.txt
blender.bin
blender.kdev4
.kdev4

Added: svn:externals
   + 

Added: svn:mergeinfo
   + /branches/bge_components:36315-36316,36318,36331,36389,36540
/branches/ge_harmony:42255,42279-42282,42286,42302,42338,42349,42616,42620,42698-42699,42739,42753,42773-42774,42832,44568,44597-44598,44793-44794
/branches/soc-2011-cucumber:37517,38166-38167,38177,38179-38180,38187,38242,38384,38387,38403-38404,38407,38968,38970,38973,39045,40845,42997-42998,43439
/branches/soc-2011-tomato:42376,42378-42379,42383,42385,42395,42397-42400,42407,42411,42418,42443-42444,42446,42467,42472,42486,42650-42652,42654-42655,42709-42710,42733-42734,42801,43872,44130,44141,44147-44149,44151-44152,44229-44230,45623-45625,46037,48089,48092,48551-48552,48679,48790,48792-48793,49076,49087,49292,49294

Modified: branches/ge_components/release/scripts/bge_components/camera.py
===================================================================
--- branches/bge_components/release/scripts/bge_components/camera.py	2011-04-24 23:44:40 UTC (rev 36316)
+++ branches/ge_components/release/scripts/bge_components/camera.py	2012-07-27 21:59:47 UTC (rev 49309)
@@ -5,12 +5,11 @@
 	"""A component for a third person camera"""
 	
 	args = OrderedDict([
-		("pPivot Name", "pivot"),
+		("Pivot Name", "pivot"),
 		("Time Offset", 35),
 		("Lens", 30),
 		("Scale Max", 4.0),
 		("Scale Min", 0.6),
-		("Option", {"One", "Two"})
 		])
 		
 	def start(self, args):
@@ -18,7 +17,6 @@
 		if not isinstance(self.object, bge.types.KX_Camera):
 			raise TypeError("This component must be attached to a camera")
 		
-		print(args['Option'])
 		# Apply settings
 		self.object.parent.timeOffset = args['Time Offset']
 		self.object.lens = args['Lens']

Modified: branches/ge_components/release/scripts/bge_components/vehicle.py
===================================================================
--- branches/bge_components/release/scripts/bge_components/vehicle.py	2011-04-24 23:44:40 UTC (rev 36316)
+++ branches/ge_components/release/scripts/bge_components/vehicle.py	2012-07-27 21:59:47 UTC (rev 49309)
@@ -19,8 +19,7 @@
 		("Brake Power", 10.0),
 		("Turn Power", 0.3),
 		
-		("Front Wheel Drive", True),
-		("Rear Wheel Drive", False),
+		("Drive Type", {"Front Wheel", "Rear Wheel"}),
 		("Tire Prefix", "tire_"),
 		("Front Tire Radius", 0.3),
 		("Rear Tire Radius", 0.3),
@@ -41,8 +40,8 @@
 		self.turn = args['Turn Power']
 		
 		# Save steering settings
-		self.fwd = args['Front Wheel Drive']
-		self.rwd = args['Rear Wheel Drive']
+		self.fwd = args['Drive Type'] == "Front Wheel"
+		self.rwd = args['Drive Type'] == "Rear Wheel"
 		
 		# Create the vehicle constraint
 		constraint = bge.constraints.createConstraint(self.object.getPhysicsId(), 0, 11)
@@ -89,7 +88,7 @@
 					args['Front Tire Radius'] if i in (0, 1) else args['Rear Tire Radius'],
 					
 					# Steerability
-					args['Front Wheel Drive'] if i in (2, 3) else args['Rear Wheel Drive'])
+					self.fwd if i in (2, 3) else self.rwd)
 					
 			# Advanced settings
 			vid.setTyreFriction(args['Tire Friction'], i)

Modified: branches/ge_components/release/scripts/modules/bpy/utils.py
===================================================================
--- trunk/blender/release/scripts/modules/bpy/utils.py	2012-07-27 18:18:13 UTC (rev 49305)
+++ branches/ge_components/release/scripts/modules/bpy/utils.py	2012-07-27 21:59:47 UTC (rev 49309)
@@ -53,7 +53,7 @@
 
 import addon_utils as _addon_utils
 
-_script_module_dirs = "startup", "modules"
+_script_module_dirs = "startup", "modules", "bge_components"
 
 
 def _test_import(module_name, loaded_modules):
@@ -220,8 +220,8 @@
             if _os.path.isdir(path):
                 _sys_path_ensure(path)
 
-                # only add this to sys.modules, don't run
-                if path_subdir == "modules":
+                # only add these to sys.modules, dont run
+                if path_subdir in ("modules", "bge_components"):
                     continue
 
                 for mod in modules_from_path(path, loaded_modules):

Modified: branches/ge_components/release/scripts/startup/bl_ui/space_logic.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/space_logic.py	2012-07-27 18:18:13 UTC (rev 49305)
+++ branches/ge_components/release/scripts/startup/bl_ui/space_logic.py	2012-07-27 21:59:47 UTC (rev 49309)
@@ -20,7 +20,41 @@
 import bpy
 from bpy.types import Header, Menu, Panel
 
+class LOGIC_PT_components(Panel):
+	bl_space_type = 'LOGIC_EDITOR'
+	bl_region_type = 'UI'
+	bl_label = 'Components'
+	
+	@classmethod
+	def poll(cls, context):
+		ob = context.active_object
+		return ob and ob.name
+		
+	def draw(self, context):
+		layout = self.layout
+		
+		ob = context.active_object
+		game = ob.game
+		
+		st = context.space_data
 
+		row = layout.row()
+		row.prop(st, "import_string", text="")
+		row.operator("logic.component_add", text="Add Component")
+		
+		for i, c in enumerate(game.components):
+			box = layout.box()
+			row = box.row()
+			row.prop(c, "name", text="")
+			row.operator("logic.component_reload", text="", icon='RECOVER_LAST').index = i
+			row.operator("logic.component_remove", text="", icon='X').index = i
+			
+			for prop in c.properties:
+				row = box.row()
+				row.label(text=prop.name)
+				row.prop(prop, "value", text="")
+			
+
 class LOGIC_PT_properties(Panel):
     bl_space_type = 'LOGIC_EDITOR'
     bl_region_type = 'UI'

Copied: branches/ge_components/source/blender/blenkernel/BKE_pycomponent.h (from rev 36316, branches/bge_components/source/blender/blenkernel/BKE_pycomponent.h)
===================================================================
--- branches/ge_components/source/blender/blenkernel/BKE_pycomponent.h	                        (rev 0)
+++ branches/ge_components/source/blender/blenkernel/BKE_pycomponent.h	2012-07-27 21:59:47 UTC (rev 49309)
@@ -0,0 +1,15 @@
+#ifndef BKE_PYCOMPONENT_H
+#define BKE_PYCOMPONENT_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct PythonComponent *new_component_from_import(char *import);
+void free_component(struct PythonComponent *pc);
+void free_components(struct ListBase *base);
+#ifdef __cplusplus
+}
+#endif
+
+#endif /*BKE_PYCOMPONENT_H*/
\ No newline at end of file

Modified: branches/ge_components/source/blender/blenkernel/CMakeLists.txt
===================================================================
--- trunk/blender/source/blender/blenkernel/CMakeLists.txt	2012-07-27 18:18:13 UTC (rev 49305)
+++ branches/ge_components/source/blender/blenkernel/CMakeLists.txt	2012-07-27 21:59:47 UTC (rev 49309)
@@ -121,6 +121,7 @@
 	intern/particle_system.c
 	intern/pointcache.c
 	intern/property.c
+	intern/python_component.c
 	intern/report.c
 	intern/sca.c
 	intern/scene.c

Modified: branches/ge_components/source/blender/blenkernel/SConscript
===================================================================
--- trunk/blender/source/blender/blenkernel/SConscript	2012-07-27 18:18:13 UTC (rev 49305)
+++ branches/ge_components/source/blender/blenkernel/SConscript	2012-07-27 21:59:47 UTC (rev 49309)
@@ -32,6 +32,7 @@
 
 if env['WITH_BF_PYTHON']:
     incs += ' ../python'
+    incs += ' ' + env['BF_PYTHON_INC']
     defs.append('WITH_PYTHON')
     if env['BF_DEBUG']:
         defs.append('DEBUG')

Modified: branches/ge_components/source/blender/blenkernel/intern/object.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/object.c	2012-07-27 18:18:13 UTC (rev 49305)
+++ branches/ge_components/source/blender/blenkernel/intern/object.c	2012-07-27 21:59:47 UTC (rev 49309)
@@ -76,6 +76,7 @@
 #include "BKE_DerivedMesh.h"
 #include "BKE_animsys.h"
 #include "BKE_anim.h"
+#include "BKE_pycomponent.h"
 #include "BKE_constraint.h"
 #include "BKE_curve.h"
 #include "BKE_displist.h"
@@ -336,6 +337,7 @@
 	free_sensors(&ob->sensors);
 	free_controllers(&ob->controllers);
 	free_actuators(&ob->actuators);
+	free_components(&ob->components);
 	
 	free_constraints(&ob->constraints);
 	
@@ -1142,6 +1144,7 @@
 	copy_sensors(&obn->sensors, &ob->sensors);
 	copy_controllers(&obn->controllers, &ob->controllers);
 	copy_actuators(&obn->actuators, &ob->actuators);
+	// XXX todo copy_components(&obn->components, &ob->components);
 	
 	if (ob->pose) {
 		copy_object_pose(obn, ob);

Copied: branches/ge_components/source/blender/blenkernel/intern/python_component.c (from rev 36316, branches/bge_components/source/blender/blenkernel/intern/python_component.c)
===================================================================
--- branches/ge_components/source/blender/blenkernel/intern/python_component.c	                        (rev 0)
+++ branches/ge_components/source/blender/blenkernel/intern/python_component.c	2012-07-27 21:59:47 UTC (rev 49309)
@@ -0,0 +1,365 @@
+#include <stdlib.h>
+
+#include "DNA_component_types.h"
+#include "DNA_property_types.h" /* For MAX_PROPSTRING */
+#include "DNA_listBase.h"
+#include "BKE_global.h"
+#include "BKE_main.h"
+#include "BKE_pycomponent.h"
+#include "BLI_fileops.h"
+#include "BLI_listbase.h"
+#include "BLI_path_util.h"
+#include "BLI_string.h"
+#include "MEM_guardedalloc.h"
+
+#include "RNA_types.h"
+
+#ifdef WITH_PYTHON
+	#include "Python.h"
+#endif
+
+#ifndef WITH_PYTHON
+	struct PyObject;
+#endif
+
+int verify_class(PyObject *cls)
+{
+#ifdef WITH_PYTHON
+	PyObject *list, *item;
+	char *name;
+	int i;
+	int comp;
+
+	list = PyObject_GetAttrString(cls, "__bases__");
+
+	for (i=0; i<PyTuple_Size(list); ++i)
+	{
+		item = PyObject_GetAttrString(PyTuple_GetItem(list, i), "__name__");
+		name = _PyUnicode_AsString(item);
+
+
+		// We don't want to decref until after the comprison
+		comp = strcmp("KX_PythonComponent", name);
+		Py_DECREF(item);
+
+		if (comp == 0)
+		{
+			Py_DECREF(list);
+			return 1;
+		}
+	}
+
+	Py_DECREF(list);
+#endif
+	return 0;
+}
+
+
+ComponentProperty *create_property(char *name, short type, int data, void *poin)
+{
+	ComponentProperty *cprop;
+
+	cprop = MEM_mallocN(sizeof(ComponentProperty), "ComponentProperty");
+
+	if (cprop)
+	{
+		BLI_strncpy(cprop->name, name, sizeof(cprop->name));
+		cprop->type = type;
+
+		cprop->data = 0;
+		cprop->poin = NULL;
+
+		if (type == CPROP_TYPE_INT)
+			cprop->data = data;
+		else if (type == CPROP_TYPE_FLOAT)

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list