diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2010-04-06 05:28:39 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2010-04-06 05:28:39 +0400 |
commit | 9498121463cd6837620b33d7c367f446cf34049a (patch) | |
tree | 95f7a88e74131aa4583e1b81aa456931cb4ecbde /release | |
parent | b1e556890d80c7e899e386ee470dec4fbf4ffe95 (diff) |
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.
Diffstat (limited to 'release')
-rw-r--r-- | release/scripts/io/engine_render_pov.py | 6 | ||||
-rw-r--r-- | release/scripts/io/export_3ds.py | 11 | ||||
-rw-r--r-- | release/scripts/io/export_fbx.py | 10 | ||||
-rw-r--r-- | release/scripts/io/export_mdd.py | 4 | ||||
-rw-r--r-- | release/scripts/io/export_obj.py | 4 | ||||
-rw-r--r-- | release/scripts/io/export_ply.py | 2 | ||||
-rw-r--r-- | release/scripts/io/export_x3d.py | 6 |
7 files changed, 22 insertions, 21 deletions
diff --git a/release/scripts/io/engine_render_pov.py b/release/scripts/io/engine_render_pov.py index e64e3bf05fb..146708bd69c 100644 --- a/release/scripts/io/engine_render_pov.py +++ b/release/scripts/io/engine_render_pov.py @@ -267,7 +267,7 @@ def write_pov(filename, scene=None, info_callback=None): file.write('}\n') - def exportMeshs(sel): + def exportMeshs(scene, sel): ob_num = 0 @@ -280,7 +280,7 @@ def write_pov(filename, scene=None, info_callback=None): 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 @@ def write_pov(filename, scene=None, info_callback=None): 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) diff --git a/release/scripts/io/export_3ds.py b/release/scripts/io/export_3ds.py index d46cc712e9a..5833dd01f3c 100644 --- a/release/scripts/io/export_3ds.py +++ b/release/scripts/io/export_3ds.py @@ -74,12 +74,12 @@ import bpy # 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 @@ def save_3ds(filename, context): # 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 @@ def save_3ds(filename, context): 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) diff --git a/release/scripts/io/export_fbx.py b/release/scripts/io/export_fbx.py index 9dd3a68f4da..08d142d80e8 100644 --- a/release/scripts/io/export_fbx.py +++ b/release/scripts/io/export_fbx.py @@ -2038,7 +2038,7 @@ def write(filename, batch_objects = None, \ 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 @@ def write(filename, batch_objects = None, \ 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 @@ def write(filename, batch_objects = None, \ 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 @@ def write(filename, batch_objects = None, \ # 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 @@ def write(filename, batch_objects = None, \ 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) diff --git a/release/scripts/io/export_mdd.py b/release/scripts/io/export_mdd.py index be3ddbc73bd..6523ce8b466 100644 --- a/release/scripts/io/export_mdd.py +++ b/release/scripts/io/export_mdd.py @@ -84,7 +84,7 @@ def write(filename, sce, ob, PREF_STARTFRAME, PREF_ENDFRAME, PREF_FPS): 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 @@ def write(filename, sce, ob, PREF_STARTFRAME, PREF_ENDFRAME, PREF_FPS): """ 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) diff --git a/release/scripts/io/export_obj.py b/release/scripts/io/export_obj.py index c10a698c9d3..c87a2af67c6 100644 --- a/release/scripts/io/export_obj.py +++ b/release/scripts/io/export_obj.py @@ -396,7 +396,7 @@ def write(filename, objects, scene, 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 @@ def write(filename, objects, scene, 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) diff --git a/release/scripts/io/export_ply.py b/release/scripts/io/export_ply.py index 23a3eb8b9ee..8249ce553bb 100644 --- a/release/scripts/io/export_ply.py +++ b/release/scripts/io/export_ply.py @@ -103,7 +103,7 @@ def write(filename, scene, ob, \ #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 diff --git a/release/scripts/io/export_x3d.py b/release/scripts/io/export_x3d.py index dccc5808bc5..e5c3213ee94 100644 --- a/release/scripts/io/export_x3d.py +++ b/release/scripts/io/export_x3d.py @@ -852,10 +852,10 @@ class x3d_class: # -------------------------- - 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 @@ class x3d_class: # 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 |