[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [28024] trunk/blender: Object API changes so these functions now require a scene as first argument :

Brecht Van Lommel brecht at blender.org
Tue Apr 6 03:28:43 CEST 2010


Revision: 28024
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=28024
Author:   blendix
Date:     2010-04-06 03:28:39 +0200 (Tue, 06 Apr 2010)

Log Message:
-----------
Object API changes so these functions now require a scene as first argument:
create_mesh, create_dupli_list, make_display_list and is_visible.

This is done in order to make these context independent as the RNA API should
be as much as possible, and to fix #21297 and #21719, where there was an
assumption from these functions that there is a scene in the context, which
does not work for external render engines exporting in a separate thread.

Also avoided using context in a number of other functions, ideally only UI/WM
type functions should use context.

I've updated the scripts in trunk, but the addons and external ones in
development will need updates too.

Modified Paths:
--------------
    trunk/blender/release/scripts/io/engine_render_pov.py
    trunk/blender/release/scripts/io/export_3ds.py
    trunk/blender/release/scripts/io/export_fbx.py
    trunk/blender/release/scripts/io/export_mdd.py
    trunk/blender/release/scripts/io/export_obj.py
    trunk/blender/release/scripts/io/export_ply.py
    trunk/blender/release/scripts/io/export_x3d.py
    trunk/blender/source/blender/makesrna/intern/rna_curve.c
    trunk/blender/source/blender/makesrna/intern/rna_fcurve.c
    trunk/blender/source/blender/makesrna/intern/rna_object.c
    trunk/blender/source/blender/makesrna/intern/rna_object_api.c
    trunk/blender/source/blender/makesrna/intern/rna_pose.c
    trunk/blender/source/blender/makesrna/intern/rna_scene.c
    trunk/blender/source/blender/makesrna/intern/rna_scene_api.c

Modified: trunk/blender/release/scripts/io/engine_render_pov.py
===================================================================
--- trunk/blender/release/scripts/io/engine_render_pov.py	2010-04-06 01:20:45 UTC (rev 28023)
+++ trunk/blender/release/scripts/io/engine_render_pov.py	2010-04-06 01:28:39 UTC (rev 28024)
@@ -267,7 +267,7 @@
 
             file.write('}\n')
 
-    def exportMeshs(sel):
+    def exportMeshs(scene, sel):
 
         ob_num = 0
 
@@ -280,7 +280,7 @@
             me = ob.data
             me_materials = me.materials
 
-            me = ob.create_mesh(True, 'RENDER')
+            me = ob.create_mesh(scene, True, 'RENDER')
 
             if not me:
                 continue
@@ -593,7 +593,7 @@
     sel = scene.objects
     exportLamps([l for l in sel if l.type == 'LAMP'])
     exportMeta([l for l in sel if l.type == 'META'])
-    exportMeshs(sel)
+    exportMeshs(scene, sel)
     exportWorld(scene.world)
     exportGlobalSettings(scene)
 

Modified: trunk/blender/release/scripts/io/export_3ds.py
===================================================================
--- trunk/blender/release/scripts/io/export_3ds.py	2010-04-06 01:20:45 UTC (rev 28023)
+++ trunk/blender/release/scripts/io/export_3ds.py	2010-04-06 01:28:39 UTC (rev 28024)
@@ -74,12 +74,12 @@
 
 # also used by X3D exporter
 # return a tuple (free, object list), free is True if memory should be freed later with free_derived_objects()
-def create_derived_objects(ob):
+def create_derived_objects(scene, ob):
     if ob.parent and ob.parent.dupli_type != 'NONE':
         return False, None
 
     if ob.dupli_type != 'NONE':
-        ob.create_dupli_list()
+        ob.create_dupli_list(scene)
         return True, [(dob.object, dob.matrix) for dob in ob.dupli_list]
     else:
         return False, [(ob, ob.matrix)]
@@ -968,11 +968,12 @@
     # each material is added once):
     materialDict = {}
     mesh_objects = []
-    for ob in [ob for ob in context.scene.objects if ob.is_visible()]:
+    scene = context.scene
+    for ob in [ob for ob in scene.objects if ob.is_visible(scene)]:
 # 	for ob in sce.objects.context:
 
         # get derived objects
-        free, derived = create_derived_objects(ob)
+        free, derived = create_derived_objects(scene, ob)
 
         if derived == None: continue
 
@@ -982,7 +983,7 @@
             if ob.type not in ('MESH', 'CURVE', 'SURFACE', 'TEXT', 'META'):
                 continue
 
-            data = ob_derived.create_mesh(True, 'PREVIEW')
+            data = ob_derived.create_mesh(scene, True, 'PREVIEW')
 # 			data = getMeshFromObject(ob_derived, None, True, False, sce)
             if data:
                 data.transform(mat)

Modified: trunk/blender/release/scripts/io/export_fbx.py
===================================================================
--- trunk/blender/release/scripts/io/export_fbx.py	2010-04-06 01:20:45 UTC (rev 28023)
+++ trunk/blender/release/scripts/io/export_fbx.py	2010-04-06 01:28:39 UTC (rev 28024)
@@ -2038,7 +2038,7 @@
         if ob_arms_orig_rest:
             for ob_base in bpy.data.objects:
                 #if ob_base.type == 'Armature':
-                ob_base.make_display_list()
+                ob_base.make_display_list(scene)
 # 				ob_base.makeDisplayList()
 
             # This causes the makeDisplayList command to effect the mesh
@@ -2054,7 +2054,7 @@
 
         obs = [(ob_base, ob_base.matrix)]
         if ob_base.dupli_type != 'NONE':
-            ob_base.create_dupli_list()
+            ob_base.create_dupli_list(scene)
             obs = [(dob.object, dob.matrix) for dob in ob_base.dupli_list]
 
         for ob, mtx in obs:
@@ -2083,7 +2083,7 @@
                 if tmp_ob_type != 'MESH':
 # 				if tmp_ob_type != 'Mesh':
 # 					me = bpy.data.meshes.new()
-                    try:	me = ob.create_mesh(True, 'PREVIEW')
+                    try:	me = ob.create_mesh(scene, True, 'PREVIEW')
 # 					try:	me.getFromObject(ob)
                     except:	me = None
                     if me:
@@ -2094,7 +2094,7 @@
                     # Mesh Type!
                     if EXP_MESH_APPLY_MOD:
 # 						me = bpy.data.meshes.new()
-                        me = ob.create_mesh(True, 'PREVIEW')
+                        me = ob.create_mesh(scene, True, 'PREVIEW')
 # 						me.getFromObject(ob)
 
                         # so we keep the vert groups
@@ -2214,7 +2214,7 @@
             for ob_base in bpy.data.objects:
                 if ob_base.type == 'ARMATURE':
 # 				if ob_base.type == 'Armature':
-                    ob_base.make_display_list()
+                    ob_base.make_display_list(scene)
 # 					ob_base.makeDisplayList()
             # This causes the makeDisplayList command to effect the mesh
             scene.set_frame(scene.frame_current)

Modified: trunk/blender/release/scripts/io/export_mdd.py
===================================================================
--- trunk/blender/release/scripts/io/export_mdd.py	2010-04-06 01:20:45 UTC (rev 28023)
+++ trunk/blender/release/scripts/io/export_mdd.py	2010-04-06 01:28:39 UTC (rev 28024)
@@ -84,7 +84,7 @@
 
     orig_frame = sce.frame_current
     sce.set_frame(PREF_STARTFRAME)
-    me = ob.create_mesh(True, 'PREVIEW')
+    me = ob.create_mesh(sce, True, 'PREVIEW')
 
     #Flip y and z
     mat_flip = Mathutils.Matrix(\
@@ -123,7 +123,7 @@
         """
 
         sce.set_frame(frame)
-        me = ob.create_mesh(True, 'PREVIEW')
+        me = ob.create_mesh(sce, True, 'PREVIEW')
         check_vertcount(me, numverts)
         me.transform(mat_flip * ob.matrix)
 

Modified: trunk/blender/release/scripts/io/export_obj.py
===================================================================
--- trunk/blender/release/scripts/io/export_obj.py	2010-04-06 01:20:45 UTC (rev 28023)
+++ trunk/blender/release/scripts/io/export_obj.py	2010-04-06 01:28:39 UTC (rev 28024)
@@ -396,7 +396,7 @@
         if ob_main.dupli_type != 'NONE':
             # XXX
             print('creating dupli_list on', ob_main.name)
-            ob_main.create_dupli_list()
+            ob_main.create_dupli_list(scene)
 
             obs = [(dob.object, dob.matrix) for dob in ob_main.dupli_list]
 
@@ -421,7 +421,7 @@
             if ob.type != 'MESH':
                 continue
 
-            me = ob.create_mesh(EXPORT_APPLY_MODIFIERS, 'PREVIEW')
+            me = ob.create_mesh(scene, EXPORT_APPLY_MODIFIERS, 'PREVIEW')
 
             if EXPORT_ROTX90:
                 me.transform(mat_xrot90 * ob_mat)

Modified: trunk/blender/release/scripts/io/export_ply.py
===================================================================
--- trunk/blender/release/scripts/io/export_ply.py	2010-04-06 01:20:45 UTC (rev 28023)
+++ trunk/blender/release/scripts/io/export_ply.py	2010-04-06 01:28:39 UTC (rev 28024)
@@ -103,7 +103,7 @@
 
     #mesh = BPyMesh.getMeshFromObject(ob, None, EXPORT_APPLY_MODIFIERS, False, scn) # XXX
     if EXPORT_APPLY_MODIFIERS:
-        mesh = ob.create_mesh(True, 'PREVIEW')
+        mesh = ob.create_mesh(scene, True, 'PREVIEW')
     else:
         mesh = ob.data
 

Modified: trunk/blender/release/scripts/io/export_x3d.py
===================================================================
--- trunk/blender/release/scripts/io/export_x3d.py	2010-04-06 01:20:45 UTC (rev 28023)
+++ trunk/blender/release/scripts/io/export_x3d.py	2010-04-06 01:28:39 UTC (rev 28024)
@@ -852,10 +852,10 @@
         # --------------------------
 
 
-        for ob_main in [o for o in scene.objects if o.is_visible()]:
+        for ob_main in [o for o in scene.objects if o.is_visible(scene)]:
         # for ob_main in scene.objects.context:
 
-            free, derived = create_derived_objects(ob_main)
+            free, derived = create_derived_objects(scene, ob_main)
 
             if derived == None: continue
 
@@ -871,7 +871,7 @@
                 # elif objType in ("Mesh", "Curve", "Surf", "Text") :
                     if EXPORT_APPLY_MODIFIERS or objType != 'MESH':
                     # if  EXPORT_APPLY_MODIFIERS or objType != 'Mesh':
-                        me = ob.create_mesh(EXPORT_APPLY_MODIFIERS, 'PREVIEW')
+                        me = ob.create_mesh(scene, EXPORT_APPLY_MODIFIERS, 'PREVIEW')
                         # me= BPyMesh.getMeshFromObject(ob, containerMesh, EXPORT_APPLY_MODIFIERS, False, scene)
                     else:
                         me = ob.data

Modified: trunk/blender/source/blender/makesrna/intern/rna_curve.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_curve.c	2010-04-06 01:20:45 UTC (rev 28023)
+++ trunk/blender/source/blender/makesrna/intern/rna_curve.c	2010-04-06 01:28:39 UTC (rev 28024)
@@ -364,7 +364,7 @@
 	rna_Curve_update_data(bmain, scene, ptr);
 }
 
-static void rna_Curve_spline_points_add(ID *id, Nurb *nu, bContext *C, ReportList *reports, int number)
+static void rna_Curve_spline_points_add(ID *id, Nurb *nu, ReportList *reports, int number)
 {
 	if(nu->type == CU_BEZIER) {
 		BKE_report(reports, RPT_ERROR, "Bezier spline can't have points added");
@@ -378,11 +378,11 @@
 		/* update */
 		makeknots(nu, 1);
 
-		rna_Curve_update_data_id(CTX_data_main(C), CTX_data_scene(C), id);
+		rna_Curve_update_data_id(NULL, NULL, id);
 	}
 }
 
-static void rna_Curve_spline_bezpoints_add(ID *id, Nurb *nu, bContext *C, ReportList *reports, int number)
+static void rna_Curve_spline_bezpoints_add(ID *id, Nurb *nu, ReportList *reports, int number)
 {
 	if(nu->type != CU_BEZIER) {
 		BKE_report(reports, RPT_ERROR, "Only bezier splines can be added");
@@ -395,7 +395,7 @@
 		/* update */
 		makeknots(nu, 1);
 
-		rna_Curve_update_data_id(CTX_data_main(C), CTX_data_scene(C), id);
+		rna_Curve_update_data_id(NULL, NULL, id);
 	}
 }
 
@@ -903,7 +903,7 @@
 
 	func= RNA_def_function(srna, "add", "rna_Curve_spline_points_add");
 	RNA_def_function_ui_description(func, "Add a number of points to this spline.");
-	RNA_def_function_flag(func, FUNC_USE_CONTEXT|FUNC_USE_SELF_ID|FUNC_USE_REPORTS);
+	RNA_def_function_flag(func, FUNC_USE_SELF_ID|FUNC_USE_REPORTS);
 	parm= RNA_def_int(func, "number", 1, INT_MIN, INT_MAX, "Number", "Number of points to add to the spline", 0, INT_MAX);
 
 	/*
@@ -930,7 +930,7 @@
 
 	func= RNA_def_function(srna, "add", "rna_Curve_spline_bezpoints_add");
 	RNA_def_function_ui_description(func, "Add a number of points to this spline.");
-	RNA_def_function_flag(func, FUNC_USE_CONTEXT|FUNC_USE_SELF_ID|FUNC_USE_REPORTS);

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list