svn merge -r 30913:30953 https://svn.blender.org/svnroot/bf-blender/trunk/blender
authorJoerg Mueller <nexyon@gmail.com>
Sun, 1 Aug 2010 23:19:30 +0000 (23:19 +0000)
committerJoerg Mueller <nexyon@gmail.com>
Sun, 1 Aug 2010 23:19:30 +0000 (23:19 +0000)
112 files changed:
intern/ghost/intern/GHOST_SystemCocoa.mm
release/scripts/io/netrender/__init__.py
release/scripts/io/netrender/repath.py [changed mode: 0755->0644]
release/scripts/io/netrender/ui.py
release/scripts/op/object.py
release/scripts/ui/properties_data_armature_rigify.py
release/scripts/ui/space_view3d.py
source/blender/blenkernel/BKE_curve.h
source/blender/blenkernel/BKE_depsgraph.h
source/blender/blenkernel/BKE_library.h
source/blender/blenkernel/BKE_material.h
source/blender/blenkernel/BKE_mesh.h
source/blender/blenkernel/BKE_pointcache.h
source/blender/blenkernel/BKE_scene.h
source/blender/blenkernel/intern/anim.c
source/blender/blenkernel/intern/blender.c
source/blender/blenkernel/intern/curve.c
source/blender/blenkernel/intern/deform.c
source/blender/blenkernel/intern/depsgraph.c
source/blender/blenkernel/intern/font.c
source/blender/blenkernel/intern/library.c
source/blender/blenkernel/intern/material.c
source/blender/blenkernel/intern/mesh.c
source/blender/blenkernel/intern/particle.c
source/blender/blenkernel/intern/pointcache.c
source/blender/blenkernel/intern/scene.c
source/blender/blenkernel/intern/sequencer.c
source/blender/blenkernel/intern/smoke.c
source/blender/blenloader/intern/readfile.c
source/blender/collada/DocumentImporter.cpp
source/blender/editors/animation/drivers.c
source/blender/editors/animation/keyframing.c
source/blender/editors/animation/keyingsets.c
source/blender/editors/armature/editarmature.c
source/blender/editors/curve/curve_ops.c
source/blender/editors/curve/editcurve.c
source/blender/editors/include/ED_armature.h
source/blender/editors/include/ED_object.h
source/blender/editors/interface/interface.c
source/blender/editors/interface/interface_layout.c
source/blender/editors/interface/interface_templates.c
source/blender/editors/interface/resources.c
source/blender/editors/mesh/editmesh.c
source/blender/editors/mesh/mesh_ops.c
source/blender/editors/mesh/meshtools.c
source/blender/editors/object/object_add.c
source/blender/editors/object/object_bake.c
source/blender/editors/object/object_constraint.c
source/blender/editors/object/object_edit.c
source/blender/editors/object/object_group.c
source/blender/editors/object/object_hook.c
source/blender/editors/object/object_modifier.c
source/blender/editors/object/object_ops.c
source/blender/editors/object/object_relations.c
source/blender/editors/object/object_transform.c
source/blender/editors/physics/particle_boids.c
source/blender/editors/physics/particle_object.c
source/blender/editors/physics/physics_ops.c
source/blender/editors/render/render_internal.c
source/blender/editors/render/render_opengl.c
source/blender/editors/render/render_preview.c
source/blender/editors/screen/screen_edit.c
source/blender/editors/screen/screen_ops.c
source/blender/editors/space_graph/graph_buttons.c
source/blender/editors/space_logic/logic_window.c
source/blender/editors/space_node/drawnode.c
source/blender/editors/space_node/node_edit.c
source/blender/editors/space_outliner/outliner.c
source/blender/editors/space_text/text_ops.c
source/blender/editors/space_view3d/drawobject.c
source/blender/editors/space_view3d/view3d_buttons.c
source/blender/editors/space_view3d/view3d_header.c
source/blender/editors/space_view3d/view3d_snap.c
source/blender/editors/space_view3d/view3d_view.c
source/blender/editors/transform/transform.c
source/blender/editors/transform/transform_conversions.c
source/blender/editors/transform/transform_generics.c
source/blender/editors/util/ed_util.c
source/blender/editors/uvedit/uvedit_ops.c
source/blender/makesdna/DNA_node_types.h
source/blender/makesdna/DNA_scene_types.h
source/blender/makesrna/intern/rna_boid.c
source/blender/makesrna/intern/rna_constraint.c
source/blender/makesrna/intern/rna_curve.c
source/blender/makesrna/intern/rna_fcurve.c
source/blender/makesrna/intern/rna_image_api.c
source/blender/makesrna/intern/rna_modifier.c
source/blender/makesrna/intern/rna_object.c
source/blender/makesrna/intern/rna_object_force.c
source/blender/makesrna/intern/rna_particle.c
source/blender/makesrna/intern/rna_pose.c
source/blender/makesrna/intern/rna_scene.c
source/blender/makesrna/intern/rna_scene_api.c
source/blender/makesrna/intern/rna_smoke.c
source/blender/modifiers/intern/MOD_meshdeform.c
source/blender/nodes/intern/CMP_nodes/CMP_colorbalance.c
source/blender/python/intern/bpy_interface.c
source/blender/python/intern/bpy_rna.c
source/blender/render/extern/include/RE_pipeline.h
source/blender/render/intern/include/render_types.h
source/blender/render/intern/include/texture.h
source/blender/render/intern/source/convertblender.c
source/blender/render/intern/source/envmap.c
source/blender/render/intern/source/pipeline.c
source/blender/render/intern/source/pointdensity.c
source/blender/render/intern/source/sss.c
source/blender/render/intern/source/texture.c
source/blender/render/intern/source/voxeldata.c
source/blender/windowmanager/intern/wm_event_system.c
source/blender/windowmanager/intern/wm_files.c
source/blender/windowmanager/intern/wm_operators.c
source/creator/creator.c

index bec243fc977ab5a1f9e9d54620e2965a1045e437..b7038a30e0086bdb83f327b8685063c043f6c10a 100644 (file)
@@ -1299,6 +1299,11 @@ GHOST_TUns8 GHOST_SystemCocoa::handleQuitRequest()
                        NSArray *windowsList = [NSApp orderedWindows];
                        if ([windowsList count]) {
                                [[windowsList objectAtIndex:0] makeKeyAndOrderFront:nil];
+                               //Handle the modifiers keyes changed state issue
+                               //as recovering from the quit dialog is like application
+                               //gaining focus back.
+                               //Main issue fixed is Cmd modifier not being cleared
+                               handleApplicationBecomeActiveEvent();
                        }
                }
 
index 43f3094e628e227b25d1ddcdb76fc90348969e42..5a705e95aa82393030a3c00a3b6af3a1339f01d2 100644 (file)
 
 # This directory is a Python package.
 
-from netrender import model
-from netrender import operators
-from netrender import client
-from netrender import slave
-from netrender import master
-from netrender import master_html
-from netrender import utils
-from netrender import balancing
-from netrender import ui
-from netrender import repath
+# To support reload properly, try to access a package var, if it's there, reload everything
+try:
+    init_data
+
+    reload(model)
+    reload(operators)
+    reload(client)
+    reload(slave)
+    reload(master)
+    reload(master_html)
+    reload(utils)
+    reload(balancing)
+    reload(ui)
+    reload(repath)
+except:
+    from netrender import model
+    from netrender import operators
+    from netrender import client
+    from netrender import slave
+    from netrender import master
+    from netrender import master_html
+    from netrender import utils
+    from netrender import balancing
+    from netrender import ui
+    from netrender import repath
 
 jobs = []
 slaves = []
@@ -38,14 +53,10 @@ init_data = True
 init_address = True
 
 def register():
-    pass # TODO
+    ui.addProperties()
+    
 
 def unregister():
     import bpy
-
     bpy.types.Scene.RemoveProperty("network_render")
 
-    bpy.types.unregister(ui.NetRenderJob)
-    bpy.types.unregister(ui.NetRenderSettings)
-    bpy.types.unregister(ui.NetRenderSlave)
-
old mode 100755 (executable)
new mode 100644 (file)
index c60b10c484a27dd985aba8673ca3975ab76f85aa..c82a031100b28c16389e942add95118a694d61b0 100644 (file)
@@ -337,138 +337,139 @@ class NetRenderSlave(bpy.types.IDPropertyGroup):
 class NetRenderJob(bpy.types.IDPropertyGroup):
     pass
 
-bpy.types.Scene.PointerProperty(attr="network_render", type=NetRenderSettings, name="Network Render", description="Network Render Settings")
-
-NetRenderSettings.StringProperty( attr="server_address",
-                name="Server address",
-                description="IP or name of the master render server",
-                maxlen = 128,
-                default = "[default]")
-
-NetRenderSettings.IntProperty( attr="server_port",
-                name="Server port",
-                description="port of the master render server",
-                default = 8000,
-                min=1,
-                max=65535)
-
-NetRenderSettings.BoolProperty( attr="master_broadcast",
-                name="Broadcast",
-                description="broadcast master server address on local network",
-                default = True)
-
-NetRenderSettings.BoolProperty( attr="slave_clear",
-                name="Clear on exit",
-                description="delete downloaded files on exit",
-                default = True)
-
-NetRenderSettings.BoolProperty( attr="slave_thumb",
-                name="Generate thumbnails",
-                description="Generate thumbnails on slaves instead of master",
-                default = False)
-
-NetRenderSettings.BoolProperty( attr="slave_outputlog",
-                name="Output render log on console",
-                description="Output render text log to console as well as sending it to the master",
-                default = True)
-
-NetRenderSettings.BoolProperty( attr="master_clear",
-                name="Clear on exit",
-                description="delete saved files on exit",
-                default = False)
-
-default_path = os.environ.get("TEMP")
-
-if not default_path:
-    if os.name == 'nt':
-        default_path = "c:/tmp/"
-    else:
-        default_path = "/tmp/"
-elif not default_path.endswith(os.sep):
-    default_path += os.sep
-
-NetRenderSettings.StringProperty( attr="path",
-                name="Path",
-                description="Path for temporary files",
-                maxlen = 128,
-                default = default_path,
-                subtype='FILE_PATH')
-
-NetRenderSettings.StringProperty( attr="job_name",
-                name="Job name",
-                description="Name of the job",
-                maxlen = 128,
-                default = "[default]")
-
-NetRenderSettings.StringProperty( attr="job_category",
-                name="Job category",
-                description="Category of the job",
-                maxlen = 128,
-                default = "")
-
-NetRenderSettings.IntProperty( attr="chunks",
-                name="Chunks",
-                description="Number of frame to dispatch to each slave in one chunk",
-                default = 5,
-                min=1,
-                max=65535)
-
-NetRenderSettings.IntProperty( attr="priority",
-                name="Priority",
-                description="Priority of the job",
-                default = 1,
-                min=1,
-                max=10)
-
-NetRenderSettings.StringProperty( attr="job_id",
-                name="Network job id",
-                description="id of the last sent render job",
-                maxlen = 64,
-                default = "")
-
-NetRenderSettings.IntProperty( attr="active_slave_index",
-                name="Index of the active slave",
-                description="",
-                default = -1,
-                min= -1,
-                max=65535)
-
-NetRenderSettings.IntProperty( attr="active_blacklisted_slave_index",
-                name="Index of the active slave",
-                description="",
-                default = -1,
-                min= -1,
-                max=65535)
-
-NetRenderSettings.IntProperty( attr="active_job_index",
-                name="Index of the active job",
-                description="",
-                default = -1,
-                min= -1,
-                max=65535)
-
-NetRenderSettings.EnumProperty(attr="mode",
-                        items=(
-                                        ("RENDER_CLIENT", "Client", "Act as render client"),
-                                        ("RENDER_MASTER", "Master", "Act as render master"),
-                                        ("RENDER_SLAVE", "Slave", "Act as render slave"),
-                                    ),
-                        name="Network mode",
-                        description="Mode of operation of this instance",
-                        default="RENDER_CLIENT")
-
-NetRenderSettings.CollectionProperty(attr="slaves", type=NetRenderSlave, name="Slaves", description="")
-NetRenderSettings.CollectionProperty(attr="slaves_blacklist", type=NetRenderSlave, name="Slaves Blacklist", description="")
-NetRenderSettings.CollectionProperty(attr="jobs", type=NetRenderJob, name="Job List", description="")
-
-NetRenderSlave.StringProperty( attr="name",
-                name="Name of the slave",
-                description="",
-                maxlen = 64,
-                default = "")
-
-NetRenderJob.StringProperty( attr="name",
-                name="Name of the job",
-                description="",
-                maxlen = 128,
-                default = "")
+def addProperties():
+    bpy.types.Scene.PointerProperty(attr="network_render", type=NetRenderSettings, name="Network Render", description="Network Render Settings")
+    
+    NetRenderSettings.StringProperty( attr="server_address",
+                    name="Server address",
+                    description="IP or name of the master render server",
+                    maxlen = 128,
+                    default = "[default]")
+    
+    NetRenderSettings.IntProperty( attr="server_port",
+                    name="Server port",
+                    description="port of the master render server",
+                    default = 8000,
+                    min=1,
+                    max=65535)
+    
+    NetRenderSettings.BoolProperty( attr="master_broadcast",
+                    name="Broadcast",
+                    description="broadcast master server address on local network",
+                    default = True)
+    
+    NetRenderSettings.BoolProperty( attr="slave_clear",
+                    name="Clear on exit",
+                    description="delete downloaded files on exit",
+                    default = True)
+    
+    NetRenderSettings.BoolProperty( attr="slave_thumb",
+                    name="Generate thumbnails",
+                    description="Generate thumbnails on slaves instead of master",
+                    default = False)
+    
+    NetRenderSettings.BoolProperty( attr="slave_outputlog",
+                    name="Output render log on console",
+                    description="Output render text log to console as well as sending it to the master",
+                    default = True)
+    
+    NetRenderSettings.BoolProperty( attr="master_clear",
+                    name="Clear on exit",
+                    description="delete saved files on exit",
+                    default = False)
+    
+    default_path = os.environ.get("TEMP")
+    
+    if not default_path:
+        if os.name == 'nt':
+            default_path = "c:/tmp/"
+        else:
+            default_path = "/tmp/"
+    elif not default_path.endswith(os.sep):
+        default_path += os.sep
+    
+    NetRenderSettings.StringProperty( attr="path",
+                    name="Path",
+                    description="Path for temporary files",
+                    maxlen = 128,
+                    default = default_path,
+                    subtype='FILE_PATH')
+    
+    NetRenderSettings.StringProperty( attr="job_name",
+                    name="Job name",
+                    description="Name of the job",
+                    maxlen = 128,
+                    default = "[default]")
+    
+    NetRenderSettings.StringProperty( attr="job_category",
+                    name="Job category",
+                    description="Category of the job",
+                    maxlen = 128,
+                    default = "")
+    
+    NetRenderSettings.IntProperty( attr="chunks",
+                    name="Chunks",
+                    description="Number of frame to dispatch to each slave in one chunk",
+                    default = 5,
+                    min=1,
+                    max=65535)
+    
+    NetRenderSettings.IntProperty( attr="priority",
+                    name="Priority",
+                    description="Priority of the job",
+                    default = 1,
+                    min=1,
+                    max=10)
+    
+    NetRenderSettings.StringProperty( attr="job_id",
+                    name="Network job id",
+                    description="id of the last sent render job",
+                    maxlen = 64,
+                    default = "")
+    
+    NetRenderSettings.IntProperty( attr="active_slave_index",
+                    name="Index of the active slave",
+                    description="",
+                    default = -1,
+                    min= -1,
+                    max=65535)
+    
+    NetRenderSettings.IntProperty( attr="active_blacklisted_slave_index",
+                    name="Index of the active slave",
+                    description="",
+                    default = -1,
+                    min= -1,
+                    max=65535)
+    
+    NetRenderSettings.IntProperty( attr="active_job_index",
+                    name="Index of the active job",
+                    description="",
+                    default = -1,
+                    min= -1,
+                    max=65535)
+    
+    NetRenderSettings.EnumProperty(attr="mode",
+                            items=(
+                                            ("RENDER_CLIENT", "Client", "Act as render client"),
+                                            ("RENDER_MASTER", "Master", "Act as render master"),
+                                            ("RENDER_SLAVE", "Slave", "Act as render slave"),
+                                        ),
+                            name="Network mode",
+                            description="Mode of operation of this instance",
+                            default="RENDER_CLIENT")
+    
+    NetRenderSettings.CollectionProperty(attr="slaves", type=NetRenderSlave, name="Slaves", description="")
+    NetRenderSettings.CollectionProperty(attr="slaves_blacklist", type=NetRenderSlave, name="Slaves Blacklist", description="")
+    NetRenderSettings.CollectionProperty(attr="jobs", type=NetRenderJob, name="Job List", description="")
+    
+    NetRenderSlave.StringProperty( attr="name",
+                    name="Name of the slave",
+                    description="",
+                    maxlen = 64,
+                    default = "")
+    
+    NetRenderJob.StringProperty( attr="name",
+                    name="Name of the job",
+                    description="",
+                    maxlen = 128,
+                    default = "")
index 0b052195541919bdb003f6737245434ee2a87b7f..403491bfa28fde860565017da4ad93d7cf52371e 100644 (file)
@@ -528,9 +528,9 @@ class MakeDupliFace(bpy.types.Operator):
 
 
 class IsolateTypeRender(bpy.types.Operator):
-    '''Select object matching a naming pattern'''
+    '''Hide unselected render objects of same type as active by setting the hide render flag'''
     bl_idname = "object.isolate_type_render"
-    bl_label = "Isolate Render Selection"
+    bl_label = "Restrict Render Unselected"
     bl_options = {'REGISTER', 'UNDO'}
 
     def execute(self, context):
@@ -545,6 +545,17 @@ class IsolateTypeRender(bpy.types.Operator):
                     obj.hide_render = True
 
         return {'FINISHED'}
+        
+class ClearAllRestrictRender(bpy.types.Operator):
+    '''Reveal all render objects by setting the hide render flag'''
+    bl_idname = "object.hide_render_clear_all"
+    bl_label = "Clear All Restrict Render"
+    bl_options = {'REGISTER', 'UNDO'}
+
+    def execute(self, context):
+        for obj in context.scene.objects:
+               obj.hide_render = False
+        return {'FINISHED'}
 
 
 classes = [
@@ -555,7 +566,8 @@ classes = [
     ShapeTransfer,
     JoinUVs,
     IsolateTypeRender,
-    MakeDupliFace]
+    MakeDupliFace,
+    ClearAllRestrictRender]
 
 
 def register():
@@ -570,4 +582,4 @@ def unregister():
         unregister(cls)
 
 if __name__ == "__main__":
-    register()
+    register()
\ No newline at end of file
index 193ff390b1e29a33fccf12866a7a595734eb85b4..5af676d5aa8bea47e845d1b07718d04989d3af3d 100644 (file)
@@ -365,7 +365,7 @@ def unregister():
     for cls in classes:
         unregister(cls)
 
-    bpy.types.INFO_MT_armature_add.remove(menu_func)
+    space_info.INFO_MT_armature_add.remove(menu_func)
 
 if __name__ == "__main__":
     register()
index 5d22c3b41bb7d07272e97ad0b1ee9b2ff4e55123..7b59b00dc566a0a6afde5dff88969b45055dd15b 100644 (file)
@@ -791,7 +791,7 @@ class VIEW3D_MT_object_specials(bpy.types.Menu):
         layout.separator()
 
         props = layout.operator("object.isolate_type_render")
-
+        props = layout.operator("object.hide_render_clear_all")
 
 class VIEW3D_MT_object_apply(bpy.types.Menu):
     bl_label = "Apply"
@@ -2388,4 +2388,4 @@ def unregister():
         unregister(cls)
 
 if __name__ == "__main__":
-    register()
+    register()
\ No newline at end of file
index e83ea4b809c15230ccbf5179979f5bacf052b25b..bcc92b477a71b98d62f71182211403a7ad759c84 100644 (file)
@@ -107,5 +107,9 @@ int clamp_nurb_order_v( struct Nurb *nu);
 
 ListBase *BKE_curve_nurbs(struct Curve *cu);
 
+int curve_bounds(struct Curve *cu, float min[3], float max[3]);
+int curve_center_median(struct Curve *cu, float cent[3]);
+int curve_center_bounds(struct Curve *cu, float cent[3]);
+void curve_translate(struct Curve *cu, float offset[3], int do_keys);
 #endif
 
index 6a44051806e1ba2aaebf294fdcc1cab32ed329e2..0b78a1206fe0e1fa3ac7e730ec45d47554f40b79 100644 (file)
@@ -70,7 +70,7 @@ int           queue_count(struct DagNodeQueue *queue);
 void   queue_delete(struct DagNodeQueue *queue);
 
 // queries
-struct DagForest       *build_dag(struct Scene *sce, short mask);
+struct DagForest       *build_dag(struct Main *bmain, struct Scene *sce, short mask);
 void                           free_forest(struct DagForest *Dag);
 
 // note :
@@ -97,14 +97,14 @@ void        draw_all_deps(void);
 /* Note that the DAG never executes changes in Objects, only sets flags in Objects */
 
                /* (re)-create dependency graph for scene */
-void   DAG_scene_sort(struct Scene *sce);
+void   DAG_scene_sort(struct Main *bmain, struct Scene *sce);
 
                /* flag all objects that need recalc because they're animated */
-void   DAG_scene_update_flags(struct Scene *sce, unsigned int lay);
+void   DAG_scene_update_flags(struct Main *bmain, struct Scene *sce, unsigned int lay);
                /* flushes all recalc flags in objects down the dependency tree */
-void   DAG_scene_flush_update(struct Scene *sce, unsigned int lay, int time);
+void   DAG_scene_flush_update(struct Main *bmain, struct Scene *sce, unsigned int lay, int time);
                /* tag objects for update on file load */
-void   DAG_on_load_update(void);
+void   DAG_on_load_update(struct Main *bmain);
 
                /* flag all IDs that need recalc because they're animated, influencing
                   this ID only. only for objects currently */
@@ -113,7 +113,7 @@ void        DAG_id_update_flags(struct ID *id);
                   but note the DAG only supports objects and object data currently */
 void   DAG_id_flush_update(struct ID *id, short flag);
                /* when setting manual RECALC flags, call this afterwards */
-void   DAG_ids_flush_update(int time);
+void   DAG_ids_flush_update(struct Main *bmain, int time);
 
                /* (re)-create dependency graph for armature pose */
 void   DAG_pose_sort(struct Object *ob);
index fcf7ae857380e5b93248ae717dc30815b58877ae..debccaa02f99bf6b4031b20a777a20151336cffe 100644 (file)
@@ -65,6 +65,7 @@ void tag_main(struct Main *mainvar, int tag);
 
 int splitIDname(char *name, char *left, int *nr);
 void rename_id(struct ID *id, char *name);
+void name_uiprefix_id(char *name, struct ID *id);
 void test_idbutton(char *name);
 void text_idbutton(struct ID *id, char *text);
 void all_local(struct Library *lib, int untagged_only);
index 07ca5a1c0ee837a81f42a266011c47ff296ae0be..a220153523ee7f4f90d489608a8d7d25f260627b 100644 (file)
@@ -35,6 +35,7 @@
 extern "C" {
 #endif
 
+struct Main;
 struct Material;
 struct ID;
 struct Object;
@@ -69,9 +70,9 @@ int object_remove_material_slot(struct Object *ob);
 /* rendering */
 
 void init_render_material(struct Material *, int, float *);
-void init_render_materials(int, float *);
+void init_render_materials(struct Main *, int, float *);
 void end_render_material(struct Material *);
-void end_render_materials(void);
+void end_render_materials(struct Main *);
 
 int material_in_material(struct Material *parmat, struct Material *mat);
 
index 3b6cf8803d8b4ef16049b5756d22ace3cc58bbdb..8c5979222f057b985f9bc8a1849d2fab55f31a59 100644 (file)
@@ -140,7 +140,12 @@ int mesh_layers_menu_charlen(struct CustomData *data, int type); /* use this to
 void mesh_layers_menu_concat(struct CustomData *data, int type, char *str);
 int mesh_layers_menu(struct CustomData *data, int type);
 
+/* vertex level transformations & checks (no derived mesh) */
 
+int mesh_bounds(struct Mesh *me, float min[3], float max[3]);
+int mesh_center_median(struct Mesh *me, float cent[3]);
+int mesh_center_bounds(struct Mesh *me, float cent[3]);
+void mesh_translate(struct Mesh *me, float offset[3], int do_keys);
 
 #ifdef __cplusplus
 }
index 03a86b6566a3feb1b546f9764a1cb7040a41d8e7..63f36a5f1036329940156bc28725b975989b50f2 100644 (file)
 #define PTCACHE_READ_OLD                               3
 
 /* Structs */
+struct ClothModifierData;
+struct ListBase;
+struct Main;
 struct Object;
-struct Scene;
-struct SoftBody;
-struct ParticleSystem;
 struct ParticleKey;
-struct ClothModifierData;
-struct SmokeModifierData;
+struct ParticleSystem;
 struct PointCache;
-struct ListBase;
+struct Scene;
+struct SmokeModifierData;
+struct SoftBody;
 
 /* temp structure for read/write */
 typedef struct PTCacheData {
@@ -143,6 +144,7 @@ typedef struct PTCacheID {
 } PTCacheID;
 
 typedef struct PTCacheBaker {
+       struct Main *main;
        struct Scene *scene;
        int bake;
        int render;
@@ -286,7 +288,7 @@ struct PointCache *BKE_ptcache_copy_list(struct ListBase *ptcaches_new, struct L
 /********************** Baking *********************/
 
 /* Bakes cache with cache_step sized jumps in time, not accurate but very fast. */
-void BKE_ptcache_quick_cache_all(struct Scene *scene);
+void BKE_ptcache_quick_cache_all(struct Main *bmain, struct Scene *scene);
 
 /* Bake cache or simulate to current frame with settings defined in the baker. */
 void BKE_ptcache_make_cache(struct PTCacheBaker* baker);
index f0fb2a656738ea7b17a4538a0ab2c47849de1608..96ef8d44cf46d1b24df947af7ee70d4cfabda425 100644 (file)
 #ifndef BKE_SCENE_H
 #define BKE_SCENE_H
 
+struct AviCodecData;
+struct Base;
 struct bglMats;
-struct Scene;
+struct Main;
 struct Object;
-struct Base;
-struct Text;
-struct AviCodecData;
 struct QuicktimeCodecData;
 struct RenderData;
+struct Scene;
+struct Text;
 struct Text;
-struct Main;
 
 #define SCE_COPY_EMPTY         0
 #define SCE_COPY_LINK_OB       1
@@ -57,8 +57,8 @@ void free_scene(struct Scene *sce);
 struct Scene *add_scene(char *name);
 struct Base *object_in_scene(struct Object *ob, struct Scene *sce);
 
-void set_scene_bg(struct Scene *sce);
-struct Scene *set_scene_name(char *name);
+void set_scene_bg(struct Main *bmain, struct Scene *sce);
+struct Scene *set_scene_name(struct Main *bmain, char *name);
 
 struct Scene *copy_scene(struct Main *bmain, struct Scene *sce, int type);
 void unlink_scene(struct Main *bmain, struct Scene *sce, struct Scene *newsce);
@@ -78,12 +78,12 @@ void scene_deselect_all(struct Scene *sce);
 void scene_select_base(struct Scene *sce, struct Base *selbase);
 
 /* checks for cycle, returns 1 if it's all OK */
-int scene_check_setscene(struct Scene *sce);
+int scene_check_setscene(struct Main *bmain, struct Scene *sce);
 
 float BKE_curframe(struct Scene *scene);
 
-void scene_update_tagged(struct Scene *sce);
-void scene_update_for_newframe(struct Scene *sce, unsigned int lay);
+void scene_update_tagged(struct Main *bmain, struct Scene *sce);
+void scene_update_for_newframe(struct Main *bmain, struct Scene *sce, unsigned int lay);
 
 void scene_add_render_layer(struct Scene *sce);
 
index 412084f7cd125e8785a592ee5a3f986b3de2df53..c24ec78dc1c97da40ba7d7f206932c65b33bdaa5 100644 (file)
@@ -289,7 +289,7 @@ static void motionpaths_calc_optimise_depsgraph(Scene *scene, ListBase *targets)
        }
        
        /* "brew me a list that's sorted a bit faster now depsy" */
-       DAG_scene_sort(scene);
+       DAG_scene_sort(G.main, scene);
 }
 
 /* update scene for current frame */
@@ -299,7 +299,7 @@ static void motionpaths_calc_update_scene(Scene *scene)
        Base *base, *last=NULL;
        
        /* only stuff that moves or needs display still */
-       DAG_scene_update_flags(scene, scene->lay);
+       DAG_scene_update_flags(G.main, scene, scene->lay);
        
        /* find the last object with the tag 
         *      - all those afterwards are assumed to not be relevant for our calculations
@@ -327,7 +327,7 @@ static void motionpaths_calc_update_scene(Scene *scene)
         *        that doesn't force complete update, but for now, this is the
         *        most accurate way!
         */
-       scene_update_for_newframe(scene, scene->lay); // XXX this is the best way we can get anything moving
+       scene_update_for_newframe(G.main, scene, scene->lay); // XXX this is the best way we can get anything moving
 #endif
 }
 
index 9a624017a164826cd1f43ebf42129287885a463e..1a1f3a724ca32815f38276eeafbe348848d938f7 100644 (file)
@@ -313,7 +313,7 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, char *filename)
        BLI_strncpy(G.main->name, filename, FILE_MAX); /* is guaranteed current file */
 
        /* baseflags, groups, make depsgraph, etc */
-       set_scene_bg(CTX_data_scene(C));
+       set_scene_bg(G.main, CTX_data_scene(C));
        
        MEM_freeN(bfd);
 }
@@ -478,7 +478,7 @@ static int read_undosave(bContext *C, UndoElem *uel)
        G.fileflags= fileflags;
 
        if(success)
-               DAG_on_load_update();
+               DAG_on_load_update(G.main);
 
        return success;
 }
index 4142ad7128fe03abaa7e17c3272ad37d73e62920..1a30e85c5c45efd23a3538d20ee333a958ea3978 100644 (file)
@@ -276,7 +276,7 @@ void tex_space_curve(Curve *cu)
 {
        DispList *dl;
        BoundBox *bb;
-       float *fp, min[3], max[3], loc[3], size[3];
+       float *fp, min[3], max[3];
        int tot, doit= 0;
        
        if(cu->bb==NULL) cu->bb= MEM_callocN(sizeof(BoundBox), "boundbox");
@@ -303,20 +303,15 @@ void tex_space_curve(Curve *cu)
                min[0] = min[1] = min[2] = -1.0f;
                max[0] = max[1] = max[2] = 1.0f;
        }
-       
-       loc[0]= (min[0]+max[0])/2.0f;
-       loc[1]= (min[1]+max[1])/2.0f;
-       loc[2]= (min[2]+max[2])/2.0f;
-       
-       size[0]= (max[0]-min[0])/2.0f;
-       size[1]= (max[1]-min[1])/2.0f;
-       size[2]= (max[2]-min[2])/2.0f;
 
        boundbox_set_from_min_max(bb, min, max);
 
        if(cu->texflag & CU_AUTOSPACE) {
-               VECCOPY(cu->loc, loc);
-               VECCOPY(cu->size, size);
+               mid_v3_v3v3(cu->loc, min, max);
+               cu->size[0]= (max[0]-min[0])/2.0f;
+               cu->size[1]= (max[1]-min[1])/2.0f;
+               cu->size[2]= (max[2]-min[2])/2.0f;
+
                cu->rot[0]= cu->rot[1]= cu->rot[2]= 0.0;
 
                if(cu->size[0]==0.0) cu->size[0]= 1.0;
@@ -3107,3 +3102,103 @@ ListBase *BKE_curve_nurbs(Curve *cu)
 
        return &cu->nurb;
 }
+
+
+/* basic vertex data functions */
+int curve_bounds(Curve *cu, float min[3], float max[3])
+{
+       ListBase *nurb_lb= BKE_curve_nurbs(cu);
+       Nurb *nu;
+
+       INIT_MINMAX(min, max);
+
+       for(nu= nurb_lb->first; nu; nu= nu->next)
+               minmaxNurb(nu, min, max);
+
+       return (nurb_lb->first != NULL);
+}
+
+int curve_center_median(Curve *cu, float cent[3])
+{
+       ListBase *nurb_lb= BKE_curve_nurbs(cu);
+       Nurb *nu;
+       int total= 0;
+
+       zero_v3(cent);
+
+       for(nu= nurb_lb->first; nu; nu= nu->next) {
+               int i;
+
+               if(nu->type == CU_BEZIER) {
+                       BezTriple *bezt;
+                       i= nu->pntsu;
+                       total += i * 3;
+                       for(bezt= nu->bezt; i--; bezt++) {
+                               add_v3_v3(cent, bezt->vec[0]);
+                               add_v3_v3(cent, bezt->vec[1]);
+                               add_v3_v3(cent, bezt->vec[2]);
+                       }
+               }
+               else {
+                       BPoint *bp;
+                       i= nu->pntsu*nu->pntsv;
+                       total += i;
+                       for(bp= nu->bp; i--; bp++) {
+                               add_v3_v3(cent, bp->vec);
+                       }
+               }
+       }
+
+       mul_v3_fl(cent, 1.0f/(float)total);
+
+       return (total != 0);
+}
+
+int curve_center_bounds(Curve *cu, float cent[3])
+{
+       float min[3], max[3];
+
+       if(curve_bounds(cu, min, max)) {
+               mid_v3_v3v3(cent, min, max);
+               return 1;
+       }
+
+       return 0;
+}
+
+void curve_translate(Curve *cu, float offset[3], int do_keys)
+{
+       ListBase *nurb_lb= BKE_curve_nurbs(cu);
+       Nurb *nu;
+       int i;
+
+       for(nu= nurb_lb->first; nu; nu= nu->next) {
+               BezTriple *bezt;
+               BPoint *bp;
+
+               if(nu->type == CU_BEZIER) {
+                       i= nu->pntsu;
+                       for(bezt= nu->bezt; i--; bezt++) {
+                               add_v3_v3(bezt->vec[0], offset);
+                               add_v3_v3(bezt->vec[1], offset);
+                               add_v3_v3(bezt->vec[2], offset);
+                       }
+               }
+               else {
+                       i= nu->pntsu*nu->pntsv;
+                       for(bp= nu->bp; i--; bp++) {
+                               add_v3_v3(bp->vec, offset);
+                       }
+               }
+       }
+
+       if (do_keys && cu->key) {
+               KeyBlock *kb;
+               for (kb=cu->key->block.first; kb; kb=kb->next) {
+                       float *fp= kb->data;
+                       for (i= kb->totelem; i--; fp+=3) {
+                               add_v3_v3(fp, offset);
+                       }
+               }
+       }
+}
index 5f262c526c3f199ebd4146e6a7baf99ce0366076..ccb6ebe1f1eb22c9b1e954be0bab731092edb149 100644 (file)
@@ -471,7 +471,6 @@ void flip_side_name (char *name, const char *from_name, int strip_number)
 #undef IS_SEPARATOR
 
        sprintf (name, "%s%s%s%s", prefix, replace, suffix, number);
-       printf("'%s' --> '%s'\n", from_name, name);
 }
 
 float defvert_find_weight(const struct MDeformVert *dvert, int group_num)
index 142f80a350e8a4fd20928465cc289b153fc32368..1f8360324d51433c465efbbf1a563e91bae163b8 100644 (file)
@@ -658,7 +658,7 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O
                dag_add_relation(dag,scenenode,node,DAG_RL_SCENE, "Scene Relation");
 }
 
-struct DagForest *build_dag(struct Scene *sce, short mask) 
+struct DagForest *build_dag(Main *bmain, Scene *sce, short mask) 
 {
        Base *base;
        Object *ob;
@@ -695,7 +695,7 @@ struct DagForest *build_dag(struct Scene *sce, short mask)
        }
        
        /* add groups used in current scene objects */
-       for(group= G.main->group.first; group; group= group->id.next) {
+       for(group= bmain->group.first; group; group= group->id.next) {
                if(group->id.flag & LIB_DOIT) {
                        for(go= group->gobject.first; go; go= go->next) {
                                build_dag_object(dag, scenenode, sce, go->ob, mask);
@@ -1605,7 +1605,7 @@ static void dag_editors_update(Main *bmain, ID *id)
 }
 
 /* groups with objects in this scene need to be put in the right order as well */
-static void scene_sort_groups(Scene *sce)
+static void scene_sort_groups(Main *bmain, Scene *sce)
 {
        Base *base;
        Group *group;
@@ -1613,14 +1613,14 @@ static void scene_sort_groups(Scene *sce)
        Object *ob;
        
        /* test; are group objects all in this scene? */
-       for(ob= G.main->object.first; ob; ob= ob->id.next) {
+       for(ob= bmain->object.first; ob; ob= ob->id.next) {
                ob->id.flag &= ~LIB_DOIT;
                ob->id.newid= NULL;     /* newid abuse for GroupObject */
        }
        for(base = sce->base.first; base; base= base->next)
                base->object->id.flag |= LIB_DOIT;
        
-       for(group= G.main->group.first; group; group= group->id.next) {
+       for(group= bmain->group.first; group; group= group->id.next) {
                for(go= group->gobject.first; go; go= go->next) {
                        if((go->ob->id.flag & LIB_DOIT)==0)
                                break;
@@ -1649,7 +1649,7 @@ static void scene_sort_groups(Scene *sce)
 }
 
 /* sort the base list on dependency order */
-void DAG_scene_sort(struct Scene *sce)
+void DAG_scene_sort(Main *bmain, Scene *sce)
 {
        DagNode *node;
        DagNodeQueue *nqueue;
@@ -1661,7 +1661,7 @@ void DAG_scene_sort(struct Scene *sce)
        
        tempbase.first= tempbase.last= NULL;
        
-       build_dag(sce, DAG_RL_ALL_BUT_DATA);
+       build_dag(bmain, sce, DAG_RL_ALL_BUT_DATA);
        
        dag_check_cycle(sce->theDag);
 
@@ -1731,7 +1731,7 @@ void DAG_scene_sort(struct Scene *sce)
        queue_delete(nqueue);
        
        /* all groups with objects in this scene gets resorted too */
-       scene_sort_groups(sce);
+       scene_sort_groups(bmain, sce);
        
        if(G.f & G_DEBUG) {
                printf("\nordered\n");
@@ -1926,7 +1926,7 @@ static void dag_scene_flush_layers(Scene *sce, int lay)
 }
 
 /* flushes all recalc flags in objects down the dependency tree */
-void DAG_scene_flush_update(Scene *sce, unsigned int lay, int time)
+void DAG_scene_flush_update(Main *bmain, Scene *sce, unsigned int lay, int time)
 {
        DagNode *firstnode;
        DagAdjList *itA;
@@ -1935,7 +1935,7 @@ void DAG_scene_flush_update(Scene *sce, unsigned int lay, int time)
        
        if(sce->theDag==NULL) {
                printf("DAG zero... not allowed to happen!\n");
-               DAG_scene_sort(sce);
+               DAG_scene_sort(bmain, sce);
        }
        
        firstnode= sce->theDag->DagNode.first;  // always scene node
@@ -2135,7 +2135,7 @@ static void dag_object_time_update_flags(Object *ob)
        }               
 }
 /* flag all objects that need recalc, for changes in time for example */
-void DAG_scene_update_flags(Scene *scene, unsigned int lay)
+void DAG_scene_update_flags(Main *bmain, Scene *scene, unsigned int lay)
 {
        Base *base;
        Object *ob;
@@ -2157,7 +2157,7 @@ void DAG_scene_update_flags(Scene *scene, unsigned int lay)
        }       
        
        /* we do groups each once */
-       for(group= G.main->group.first; group; group= group->id.next) {
+       for(group= bmain->group.first; group; group= group->id.next) {
                if(group->id.flag & LIB_DOIT) {
                        for(go= group->gobject.first; go; go= go->next) {
                                dag_object_time_update_flags(go->ob);
@@ -2166,7 +2166,7 @@ void DAG_scene_update_flags(Scene *scene, unsigned int lay)
        }
        
        for(sce= scene; sce; sce= sce->set)
-               DAG_scene_flush_update(sce, lay, 1);
+               DAG_scene_flush_update(bmain, sce, lay, 1);
        
        /* test: set time flag, to disable baked systems to update */
        for(SETLOOPER(scene, base)) {
@@ -2223,21 +2223,19 @@ static void dag_current_scene_layers(Main *bmain, Scene **sce, unsigned int *lay
        }
 }
 
-void DAG_ids_flush_update(int time)
+void DAG_ids_flush_update(Main *bmain, int time)
 {
-       Main *bmain= G.main;
        Scene *sce;
        unsigned int lay;
 
        dag_current_scene_layers(bmain, &sce, &lay);
 
        if(sce)
-               DAG_scene_flush_update(sce, lay, time);
+               DAG_scene_flush_update(bmain, sce, lay, time);
 }
 
-void DAG_on_load_update(void)
+void DAG_on_load_update(Main *bmain)
 {
-       Main *bmain= G.main;
        Scene *scene, *sce;
        Base *base;
        Object *ob;
@@ -2268,7 +2266,7 @@ void DAG_on_load_update(void)
                        }
                }
 
-               for(group= G.main->group.first; group; group= group->id.next) {
+               for(group= bmain->group.first; group; group= group->id.next) {
                        if(group->id.flag & LIB_DOIT) {
                                for(go= group->gobject.first; go; go= go->next) {
                                        if(ELEM5(go->ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL))
@@ -2282,7 +2280,7 @@ void DAG_on_load_update(void)
                }
 
                /* now tag update flags, to ensure deformers get calculated on redraw */
-               DAG_scene_update_flags(scene, lay);
+               DAG_scene_update_flags(bmain, scene, lay);
        }
 }
 
@@ -2394,7 +2392,7 @@ void DAG_id_flush_update(ID *id, short flag)
        }
 
        /* flush to other objects that depend on this one */
-       DAG_scene_flush_update(sce, lay, 0);
+       DAG_scene_flush_update(bmain, sce, lay, 0);
 }
 
 /* recursively descends tree, each node only checked once */
@@ -2477,7 +2475,7 @@ void DAG_id_update_flags(ID *id)
                }
                
                /* set recalcs and flushes */
-               DAG_scene_update_flags(sce, lay);
+               DAG_scene_update_flags(bmain, sce, lay);
                
                /* now we clear recalcs, unless color is set */
                for(node = sce->theDag->DagNode.first; node; node= node->next) {
index 7ebd0c3f4578eb184ce2587612487dee2edf9044..46f67adeb4bb4c004698759342ea05cb7222a2d7 100644 (file)
@@ -814,7 +814,7 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode)
                twidth = char_width(cu, che, info);
 
                // Calculate positions
-               if((tb->w != 0.0) && (ct->dobreak==0) && ((xof-(tb->x/cu->fsize)+twidth)*cu->fsize) > tb->w) {
+               if((tb->w != 0.0) && (ct->dobreak==0) && ((xof-(tb->x/cu->fsize)+twidth)*cu->fsize) > tb->w + cu->xof*cu->fsize) {
        //              fprintf(stderr, "linewidth exceeded: %c%c%c...\n", mem[i], mem[i+1], mem[i+2]);
                        for (j=i; j && (mem[j] != '\n') && (mem[j] != '\r') && (chartransdata[j].dobreak==0); j--) {
                                if (mem[j]==' ' || mem[j]=='-') {
@@ -855,7 +855,7 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode)
                        linedata4[lnr]= wsnr;
                        
                        if ( (tb->h != 0.0) &&
-                                ((-(yof-(tb->y/cu->fsize))) > ((tb->h/cu->fsize)-(linedist*cu->fsize))) &&
+                                ((-(yof-(tb->y/cu->fsize))) > ((tb->h/cu->fsize)-(linedist*cu->fsize)) - cu->yof) &&
                                 (cu->totbox > (curbox+1)) ) {
                                maxlen= 0;
                                tb++;
index 716a0b7d41b3aff78007ad36e974420233ff79ce..6852a487afafe406de09ed1bd320415cb3bd6ca6 100644 (file)
@@ -1394,3 +1394,12 @@ void rename_id(ID *id, char *name)
        
        new_id(lb, id, name);                           
 }
+
+void name_uiprefix_id(char *name, ID *id)
+{
+       name[0] = id->lib ? 'L':' ';
+       name[1] = id->flag & LIB_FAKEUSER ? 'F':' ';
+       name[2] = ' ';
+
+       strcpy(name+3, id->name+2);
+}
index 11c96e9a3470cb5a57ffe54de66e15710c231a2d..6b79a7b4d62420cdb406d395d0ee6e6fbc133242 100644 (file)
@@ -783,14 +783,14 @@ void init_render_material(Material *mat, int r_mode, float *amb)
        }
 }
 
-void init_render_materials(int r_mode, float *amb)
+void init_render_materials(Main *bmain, int r_mode, float *amb)
 {
        Material *ma;
        
        /* clear these flags before going over materials, to make sure they
         * are cleared only once, otherwise node materials contained in other
         * node materials can go wrong */
-       for(ma= G.main->mat.first; ma; ma= ma->id.next) {
+       for(ma= bmain->mat.first; ma; ma= ma->id.next) {
                if(ma->id.us) {
                        ma->texco= 0;
                        ma->mapto= 0;
@@ -798,7 +798,7 @@ void init_render_materials(int r_mode, float *amb)
        }
 
        /* two steps, first initialize, then or the flags for layers */
-       for(ma= G.main->mat.first; ma; ma= ma->id.next) {
+       for(ma= bmain->mat.first; ma; ma= ma->id.next) {
                /* is_used flag comes back in convertblender.c */
                ma->flag &= ~MA_IS_USED;
                if(ma->id.us) 
@@ -815,10 +815,10 @@ void end_render_material(Material *mat)
                ntreeEndExecTree(mat->nodetree); /* has internal flag to detect it only does it once */
 }
 
-void end_render_materials(void)
+void end_render_materials(Main *bmain)
 {
        Material *ma;
-       for(ma= G.main->mat.first; ma; ma= ma->id.next)
+       for(ma= bmain->mat.first; ma; ma= ma->id.next)
                if(ma->id.us) 
                        end_render_material(ma);
 }
index 66e8c10206c5024c955dc16353d234ebfe2dc7f0..ab7b0694836ac6f952f5bb16b4a0d0cc2fbe4a3f 100644 (file)
@@ -320,33 +320,22 @@ void make_local_mesh(Mesh *me)
 
 void boundbox_mesh(Mesh *me, float *loc, float *size)
 {
-       MVert *mvert;
        BoundBox *bb;
        float min[3], max[3];
        float mloc[3], msize[3];
-       int a;
        
        if(me->bb==0) me->bb= MEM_callocN(sizeof(BoundBox), "boundbox");
        bb= me->bb;
-       
-       INIT_MINMAX(min, max);
 
        if (!loc) loc= mloc;
        if (!size) size= msize;
        
-       mvert= me->mvert;
-       for(a=0; a<me->totvert; a++, mvert++) {
-               DO_MINMAX(mvert->co, min, max);
-       }
-
-       if(!me->totvert) {
+       if(!mesh_bounds(me, min, max)) {
                min[0] = min[1] = min[2] = -1.0f;
                max[0] = max[1] = max[2] = 1.0f;
        }
 
-       loc[0]= (min[0]+max[0])/2.0f;
-       loc[1]= (min[1]+max[1])/2.0f;
-       loc[2]= (min[2]+max[2])/2.0f;
+       mid_v3_v3v3(loc, min, max);
                
        size[0]= (max[0]-min[0])/2.0f;
        size[1]= (max[1]-min[1])/2.0f;
@@ -369,9 +358,9 @@ void tex_space_mesh(Mesh *me)
                        else if(size[a]<0.0 && size[a]> -0.00001) size[a]= -0.00001;
                }
 
-               VECCOPY(me->loc, loc);
-               VECCOPY(me->size, size);
-               me->rot[0]= me->rot[1]= me->rot[2]= 0.0;
+               copy_v3_v3(me->loc, loc);
+               copy_v3_v3(me->size, size);
+               zero_v3(me->rot);
        }
 }
 
@@ -413,9 +402,7 @@ float *get_mesh_orco_verts(Object *ob)
        totvert = MIN2(tme->totvert, me->totvert);
 
        for(a=0; a<totvert; a++, mvert++) {
-               vcos[a][0]= mvert->co[0];
-               vcos[a][1]= mvert->co[1];
-               vcos[a][2]= mvert->co[2];
+               copy_v3_v3(vcos[a], mvert->co);
        }
 
        return (float*)vcos;
@@ -431,9 +418,7 @@ void transform_mesh_orco_verts(Mesh *me, float (*orco)[3], int totvert, int inve
        if(invert) {
                for(a=0; a<totvert; a++) {
                        float *co = orco[a];
-                       co[0] = co[0]*size[0] + loc[0];
-                       co[1] = co[1]*size[1] + loc[1];
-                       co[2] = co[2]*size[2] + loc[2];
+                       madd_v3_v3v3v3(co, loc, co, size);
                }
        }
        else {
@@ -1497,3 +1482,60 @@ void mesh_pmv_off(Object *ob, Mesh *me)
                me->pv= NULL;
        }
 }
+
+/* basic vertex data functions */
+int mesh_bounds(Mesh *me, float min[3], float max[3])
+{
+       int i= me->totvert;
+       MVert *mvert;
+       INIT_MINMAX(min, max);
+       for(mvert= me->mvert; i--; mvert++) {
+               DO_MINMAX(mvert->co, min, max);
+       }
+       
+       return (me->totvert != 0);
+}
+
+int mesh_center_median(Mesh *me, float cent[3])
+{
+       int i= me->totvert;
+       MVert *mvert;
+       zero_v3(cent);
+       for(mvert= me->mvert; i--; mvert++) {
+               add_v3_v3(cent, mvert->co);
+       }
+       mul_v3_fl(cent, 1.0f/(float)me->totvert);
+
+       return (me->totvert != 0);
+}
+
+int mesh_center_bounds(Mesh *me, float cent[3])
+{
+       float min[3], max[3];
+
+       if(mesh_bounds(me, min, max)) {
+               mid_v3_v3v3(cent, min, max);
+               return 1;
+       }
+
+       return 0;
+}
+
+void mesh_translate(Mesh *me, float offset[3], int do_keys)
+{
+       int i= me->totvert;
+       MVert *mvert;
+       for(mvert= me->mvert; i--; mvert++) {
+               add_v3_v3(mvert->co, offset);
+       }
+       
+       if (do_keys && me->key) {
+               KeyBlock *kb;
+               for (kb=me->key->block.first; kb; kb=kb->next) {
+                       float *fp= kb->data;
+                       for (i= kb->totelem; i--; fp+=3) {
+                               add_v3_v3(fp, offset);
+                       }
+               }
+       }
+}
index ed63f011342049ec4c155f579971de95a5c9fa18..52ee0180f43d9b82263b140e49404cbbf1ed4f14 100644 (file)
@@ -3395,7 +3395,7 @@ ModifierData *object_add_particle_system(Scene *scene, Object *ob, char *name)
        psys->flag = PSYS_ENABLED|PSYS_CURRENT;
        psys->cfra=bsystem_time(scene,ob,scene->r.cfra+1,0.0);
 
-       DAG_scene_sort(scene);
+       DAG_scene_sort(G.main, scene);
        DAG_id_flush_update(&ob->id, OB_RECALC_DATA);
 
        return md;
@@ -3432,7 +3432,7 @@ void object_remove_particle_system(Scene *scene, Object *ob)
        else
                ob->mode &= ~OB_MODE_PARTICLE_EDIT;
 
-       DAG_scene_sort(scene);
+       DAG_scene_sort(G.main, scene);
        DAG_id_flush_update(&ob->id, OB_RECALC_DATA);
 }
 static void default_particle_settings(ParticleSettings *part)
index ced5d116ad003ec0cfb1fde371aaa90e765cf92b..d44221d2cd39f464dd6d7888850a3163ec76b621 100644 (file)
@@ -2335,7 +2335,7 @@ PointCache *BKE_ptcache_copy_list(ListBase *ptcaches_new, ListBase *ptcaches_old
 
 
 /* Baking */
-void BKE_ptcache_quick_cache_all(Scene *scene)
+void BKE_ptcache_quick_cache_all(Main *bmain, Scene *scene)
 {
        PTCacheBaker baker;
 
@@ -2348,6 +2348,7 @@ void BKE_ptcache_quick_cache_all(Scene *scene)
        baker.progresscontext=NULL;
        baker.render=0;
        baker.anim_init = 0;
+       baker.main=bmain;
        baker.scene=scene;
        baker.quick_step=scene->physics_settings.quick_cache_step;
 
@@ -2362,6 +2363,7 @@ typedef struct {
        int endframe;
        int step;
        int *cfra_ptr;
+       Main *main;
        Scene *scene;
 } ptcache_make_cache_data;
 
@@ -2369,7 +2371,7 @@ static void *ptcache_make_cache_thread(void *ptr) {
        ptcache_make_cache_data *data = (ptcache_make_cache_data*)ptr;
 
        for(; (*data->cfra_ptr <= data->endframe) && !data->break_operation; *data->cfra_ptr+=data->step) {
-               scene_update_for_newframe(data->scene, data->scene->lay);
+               scene_update_for_newframe(data->main, data->scene, data->scene->lay);
                if(G.background) {
                        printf("bake: frame %d :: %d\n", (int)*data->cfra_ptr, data->endframe);
                }
@@ -2382,6 +2384,7 @@ static void *ptcache_make_cache_thread(void *ptr) {
 /* if bake is not given run simulations to current frame */
 void BKE_ptcache_make_cache(PTCacheBaker* baker)
 {
+       Main *bmain = baker->main;
        Scene *scene = baker->scene;
        Scene *sce; /* SETLOOPER macro only */
        Base *base;
@@ -2401,6 +2404,7 @@ void BKE_ptcache_make_cache(PTCacheBaker* baker)
        thread_data.step = baker->quick_step;
        thread_data.cfra_ptr = &CFRA;
        thread_data.scene = baker->scene;
+       thread_data.main = baker->main;
 
        G.afbreek = 0;
 
@@ -2570,7 +2574,7 @@ void BKE_ptcache_make_cache(PTCacheBaker* baker)
        CFRA = cfrao;
        
        if(bake) /* already on cfra unless baking */
-               scene_update_for_newframe(scene, scene->lay);
+               scene_update_for_newframe(bmain, scene, scene->lay);
 
        if (thread_data.break_operation)
                WM_cursor_wait(0);
index 3c7f6e13445e5cf3f2c70345fa77eed3e2306c85..48cef7e1bdebae376e752a90c3715203178953c2 100644 (file)
@@ -501,7 +501,7 @@ Base *object_in_scene(Object *ob, Scene *sce)
        return NULL;
 }
 
-void set_scene_bg(Scene *scene)
+void set_scene_bg(Main *bmain, Scene *scene)
 {
        Scene *sce;
        Base *base;
@@ -511,18 +511,18 @@ void set_scene_bg(Scene *scene)
        int flag;
        
        /* check for cyclic sets, for reading old files but also for definite security (py?) */
-       scene_check_setscene(scene);
+       scene_check_setscene(bmain, scene);
        
        /* can happen when switching modes in other scenes */
        if(scene->obedit && !(scene->obedit->mode & OB_MODE_EDIT))
                scene->obedit= NULL;
 
        /* deselect objects (for dataselect) */
-       for(ob= G.main->object.first; ob; ob= ob->id.next)
+       for(ob= bmain->object.first; ob; ob= ob->id.next)
                ob->flag &= ~(SELECT|OB_FROMGROUP);
 
        /* group flags again */
-       for(group= G.main->group.first; group; group= group->id.next) {
+       for(group= bmain->group.first; group; group= group->id.next) {
                go= group->gobject.first;
                while(go) {
                        if(go->ob) go->ob->flag |= OB_FROMGROUP;
@@ -531,12 +531,12 @@ void set_scene_bg(Scene *scene)
        }
 
        /* sort baselist */
-       DAG_scene_sort(scene);
+       DAG_scene_sort(bmain, scene);
        
        /* ensure dags are built for sets */
        for(sce= scene->set; sce; sce= sce->set)
                if(sce->theDag==NULL)
-                       DAG_scene_sort(sce);
+                       DAG_scene_sort(bmain, sce);
 
        /* copy layers and flags from bases to objects */
        for(base= scene->base.first; base; base= base->next) {
@@ -558,11 +558,11 @@ void set_scene_bg(Scene *scene)
 }
 
 /* called from creator.c */
-Scene *set_scene_name(char *name)
+Scene *set_scene_name(Main *bmain, char *name)
 {
        Scene *sce= (Scene *)find_id("SC", name);
        if(sce) {
-               set_scene_bg(sce);
+               set_scene_bg(bmain, sce);
                printf("Scene switch: '%s' in file: '%s'\n", name, G.sce);
                return sce;
        }
@@ -871,7 +871,7 @@ void scene_select_base(Scene *sce, Base *selbase)
 }
 
 /* checks for cycle, returns 1 if it's all OK */
-int scene_check_setscene(Scene *sce)
+int scene_check_setscene(Main *bmain, Scene *sce)
 {
        Scene *scene;
        int a, totscene;
@@ -879,7 +879,7 @@ int scene_check_setscene(Scene *sce)
        if(sce->set==NULL) return 1;
        
        totscene= 0;
-       for(scene= G.main->scene.first; scene; scene= scene->id.next)
+       for(scene= bmain->scene.first; scene; scene= scene->id.next)
                totscene++;
        
        for(a=0, scene=sce; scene->set; scene=scene->set, a++) {
@@ -907,14 +907,14 @@ float BKE_curframe(Scene *scene)
        return ctime;
 }
 
-static void scene_update_tagged_recursive(Scene *scene, Scene *scene_parent)
+static void scene_update_tagged_recursive(Main *bmain, Scene *scene, Scene *scene_parent)
 {
        Base *base;
 
        /* sets first, we allow per definition current scene to have
           dependencies on sets, but not the other way around. */
        if(scene->set)
-               scene_update_tagged_recursive(scene->set, scene_parent);
+               scene_update_tagged_recursive(bmain, scene->set, scene_parent);
 
        for(base= scene->base.first; base; base= base->next) {
                Object *ob= base->object;
@@ -930,14 +930,14 @@ static void scene_update_tagged_recursive(Scene *scene, Scene *scene_parent)
 }
 
 /* this is called in main loop, doing tagged updates before redraw */
-void scene_update_tagged(Scene *scene)
+void scene_update_tagged(Main *bmain, Scene *scene)
 {
        scene->physics_settings.quick_cache_step= 0;
 
        /* update all objects: drivers, matrices, displists, etc. flags set
           by depgraph or manual, no layer check here, gets correct flushed */
 
-       scene_update_tagged_recursive(scene, scene);
+       scene_update_tagged_recursive(bmain, scene, scene);
 
        /* recalc scene animation data here (for sequencer) */
        {
@@ -949,14 +949,14 @@ void scene_update_tagged(Scene *scene)
        }
 
        if(scene->physics_settings.quick_cache_step)
-               BKE_ptcache_quick_cache_all(scene);
+               BKE_ptcache_quick_cache_all(bmain, scene);
 
        /* in the future this should handle updates for all datablocks, not
           only objects and scenes. - brecht */
 }
 
 /* applies changes right away, does all sets too */
-void scene_update_for_newframe(Scene *sce, unsigned int lay)
+void scene_update_for_newframe(Main *bmain, Scene *sce, unsigned int lay)
 {
        float ctime = BKE_curframe(sce);
        Scene *sce_iter;
@@ -966,13 +966,13 @@ void scene_update_for_newframe(Scene *sce, unsigned int lay)
 
        for(sce_iter= sce; sce_iter; sce_iter= sce_iter->set) {
                if(sce_iter->theDag==NULL)
-                       DAG_scene_sort(sce_iter);
+                       DAG_scene_sort(bmain, sce_iter);
        }
 
 
        /* Following 2 functions are recursive
         * so dont call within 'scene_update_tagged_recursive' */
-       DAG_scene_update_flags(sce, lay);   // only stuff that moves or needs display still
+       DAG_scene_update_flags(bmain, sce, lay);   // only stuff that moves or needs display still
 
        /* All 'standard' (i.e. without any dependencies) animation is handled here,
         * with an 'local' to 'macro' order of evaluation. This should ensure that
@@ -980,11 +980,11 @@ void scene_update_for_newframe(Scene *sce, unsigned int lay)
         * can be overridden by settings from Scene, which owns the Texture through a hierarchy
         * such as Scene->World->MTex/Texture) can still get correctly overridden.
         */
-       BKE_animsys_evaluate_all_animation(G.main, ctime);
+       BKE_animsys_evaluate_all_animation(bmain, ctime);
        /*...done with recusrive funcs */
 
        /* object_handle_update() on all objects, groups and sets */
-       scene_update_tagged_recursive(sce, sce);
+       scene_update_tagged_recursive(bmain, sce, sce);
 }
 
 /* return default layer, also used to patch old files */
index 4f3ad50e294a4c5592923bef94193b2e324a13f8..aab4e1226b24f945db8d7d7b65490c76913057f4 100644 (file)
@@ -1852,7 +1852,7 @@ static ImBuf * seq_render_scene_strip_impl(
        
        if(sequencer_view3d_cb && BLI_thread_is_main() && doseq_gl && (seq->scene == scene || have_seq==0) && seq->scene->camera) {
                /* opengl offscreen render */
-               scene_update_for_newframe(seq->scene, seq->scene->lay);
+               scene_update_for_newframe(G.main, seq->scene, seq->scene->lay);
                ibuf= sequencer_view3d_cb(seq->scene, seqrectx, seqrecty, 
                                          scene->r.seq_prev_type);
        }
@@ -1865,7 +1865,7 @@ static ImBuf * seq_render_scene_strip_impl(
                else
                        re= RE_NewRender(sce->id.name);
                
-               RE_BlenderFrame(re, sce, NULL, sce->lay, frame);
+               RE_BlenderFrame(re, G.main, sce, NULL, sce->lay, frame);
                
                RE_AcquireResultImage(re, &rres);
                
@@ -1876,12 +1876,6 @@ static ImBuf * seq_render_scene_strip_impl(
                                addzbuffloatImBuf(ibuf);
                                memcpy(ibuf->zbuf_float, rres.rectz, sizeof(float)*rres.rectx*rres.recty);
                        }
-                       
-                       /* {
-                          ImBuf *imb= IMB_allocImBuf(rres.rectx, rres.recty, 32, IB_rectfloat, 0);
-                          IMB_saveiff(imb, "/tmp/foo.image", IB_rect | IB_metadata);
-                          IMB_freeImBuf(imb);
-                          } */
 
                        /* float buffers in the sequencer are not linear */
                        ibuf->profile= IB_PROFILE_LINEAR_RGB;
index 2664a20bd184308fb5f396b9d4af25fcea5aa274..97eb3aa866c66f015779d50b6946f4617008254d 100644 (file)
@@ -296,7 +296,7 @@ int smokeModifier_init (SmokeModifierData *smd, Object *ob, Scene *scene, Derive
                return 1;
        }
 
-       return 1;
+       return 2;
 }
 
 static void fill_scs_points(Object *ob, DerivedMesh *dm, SmokeCollSettings *scs)
@@ -935,7 +935,6 @@ static void smoke_calc_domain(Scene *scene, Object *ob, SmokeModifierData *smd)
                                                                // Add emitter density to temp emission map
                                                                temp_emission_map[index] = sfs->density;
 
-
                                                                // Uses particle velocity as initial velocity for smoke
                                                                if(sfs->flags & MOD_SMOKE_FLOW_INITVELOCITY && (psys->part->phystype != PART_PHYS_NO))
                                                                {
@@ -943,8 +942,6 @@ static void smoke_calc_domain(Scene *scene, Object *ob, SmokeModifierData *smd)
                                                                        velocity_y[index] = pa->state.vel[1]*sfs->vel_multi;
                                                                        velocity_z[index] = pa->state.vel[2]*sfs->vel_multi;
                                                                }                                                                               
-                                                       
-
                                                        }                                                                       
                                                        else if(sfs->type & MOD_SMOKE_FLOW_TYPE_OUTFLOW) // outflow                                                                     
                                                        {                                                                               
@@ -1328,6 +1325,7 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM
                int startframe, endframe, framenr;
                float timescale;
                int cache_result = 0, cache_result_wt = 0;
+               int did_init = 0;
 
                framenr = scene->r.cfra;
 
@@ -1357,7 +1355,7 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM
 
                // printf("startframe: %d, framenr: %d\n", startframe, framenr);
 
-               if(!smokeModifier_init(smd, ob, scene, dm))
+               if(!(did_init = smokeModifier_init(smd, ob, scene, dm)))
                {
                        printf("bad smokeModifier_init\n");
                        return;
@@ -1414,8 +1412,18 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM
                                smoke_dissolve(sds->fluid, sds->diss_speed, sds->flags & MOD_SMOKE_DISSOLVE_LOG);
                        smoke_step(sds->fluid, smd->time, scene->r.frs_sec / scene->r.frs_sec_base);
                }
+               else
+               {
+                       /* Smoke did not load cache and was not reset but we're on startframe */
+                       /* So now reinit the smoke since it was not done yet */
+                       if(did_init == 2)
+                       {
+                               smokeModifier_reset(smd);
+                               smokeModifier_init(smd, ob, scene, dm);
+                       }
+               }
 
-               // create shadows before writing cache so we get nice shadows for sstartframe, too
+               // create shadows before writing cache so we get nice shadows for startframe, too
                if(get_lamp(scene, light))
                        smoke_calc_transparency(sds->shadow, smoke_get_density(sds->fluid), sds->p0, sds->p1, sds->res, sds->dx, light, calc_voxel_transp, -7.0*sds->dx);
        
index c050f25256adf3a3a8d01f3831e3252428ff388d..1fab3d894fd807aa05b46f5de5a3b73cc073e8b8 100644 (file)
@@ -12406,9 +12406,7 @@ static void append_do_cursor(Scene *scene, Library *curlib, short flag)
                return;
        
        /* move from the center of the appended objects to cursor */
-       centerloc[0]= (min[0]+max[0])/2;
-       centerloc[1]= (min[1]+max[1])/2;
-       centerloc[2]= (min[2]+max[2])/2;
+       mid_v3_v3v3(centerloc, min, max);
        curs = scene->cursor;
        VECSUB(centerloc,curs,centerloc);
        
@@ -12511,7 +12509,7 @@ void BLO_script_library_append(BlendHandle **bh, char *dir, char *name,
 
        /* do we need to do this? */
        if(scene)
-               DAG_scene_sort(scene);
+               DAG_scene_sort(bmain, scene);
 
        *bh= (BlendHandle*)fd;
 }
index a415b90ff08eabffcdb92747210a9e91a98a75fb..b9052d23511fd4e73181f8032697f0881220e15b 100644 (file)
@@ -216,6 +216,7 @@ static int set_parent(Object *ob, Object *par, bContext *C, bool is_parent_space
                return false;
 
        Object workob;
+       Main *bmain = CTX_data_main(C);
        Scene *sce = CTX_data_scene(C);
 
        ob->parent = par;
@@ -243,8 +244,8 @@ static int set_parent(Object *ob, Object *par, bContext *C, bool is_parent_space
        ob->recalc |= OB_RECALC_OB | OB_RECALC_DATA;
        par->recalc |= OB_RECALC_OB;
 
-       DAG_scene_sort(sce);
-       DAG_ids_flush_update(0);
+       DAG_scene_sort(bmain, sce);
+       DAG_ids_flush_update(bmain, 0);
        WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL);
 
        return true;
@@ -611,9 +612,10 @@ private:
                void link_armature(bContext *C, Object *ob, std::map<COLLADAFW::UniqueId, COLLADAFW::Node*>& joint_by_uid,
                                                   TransformReader *tm)
                {
+                       Main *bmain = CTX_data_main(C);
                        Scene *scene = CTX_data_scene(C);
 
-                       ModifierData *md = ED_object_modifier_add(NULL, scene, ob, NULL, eModifierType_Armature);
+                       ModifierData *md = ED_object_modifier_add(NULL, bmain, scene, ob, NULL, eModifierType_Armature);
                        ((ArmatureModifierData *)md)->object = ob_arm;
 
                        copy_m4_m4(ob->obmat, bind_shape_matrix);
@@ -630,8 +632,8 @@ private:
 
                        ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA;
 
-                       DAG_scene_sort(scene);
-                       DAG_ids_flush_update(0);
+                       DAG_scene_sort(bmain, scene);
+                       DAG_ids_flush_update(bmain, 0);
                        WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL);
 #endif
 
@@ -3132,7 +3134,7 @@ public:
                        where_is_object(scene, job);
 
                        // after parenting and layer change
-                       DAG_scene_sort(scene);
+                       DAG_scene_sort(CTX_data_main(C), scene);
 
                        joint_objects[node->getUniqueId()] = job;
                }
index 3fc228e1c1597a66e0b5bec8e5e286f6a38115d7..9edcf637cdc69b47a3724377cdb78b4495e86e6e 100644 (file)
@@ -389,7 +389,7 @@ static int add_driver_button_exec (bContext *C, wmOperator *op)
        
        if (success) {
                /* send updates */
-               DAG_ids_flush_update(0);
+               DAG_ids_flush_update(CTX_data_main(C), 0);
                
                WM_event_add_notifier(C, NC_ANIMATION|ND_FCURVES_ORDER, NULL); // XXX
        }
@@ -440,7 +440,7 @@ static int remove_driver_button_exec (bContext *C, wmOperator *op)
        
        if (success) {
                /* send updates */
-               DAG_ids_flush_update(0);
+               DAG_ids_flush_update(CTX_data_main(C), 0);
                
                WM_event_add_notifier(C, NC_ANIMATION|ND_FCURVES_ORDER, NULL);  // XXX
        }
index f60181d7f6c0eda2741314b1e42b316d2f42e497..ea20a5c2c885df9f6d15b9a26dcd0b225223c0e2 100644 (file)
@@ -51,6 +51,7 @@
 #include "BKE_constraint.h"
 #include "BKE_depsgraph.h"
 #include "BKE_fcurve.h"
+#include "BKE_main.h"
 #include "BKE_nla.h"
 #include "BKE_global.h"
 #include "BKE_utildefines.h"
@@ -1060,6 +1061,7 @@ static int modify_key_op_poll(bContext *C)
 
 static int insert_key_exec (bContext *C, wmOperator *op)
 {
+       Main *bmain= CTX_data_main(C);
        Scene *scene= CTX_data_scene(C);
        KeyingSet *ks= NULL;
        int type= RNA_int_get(op->ptr, "type");
@@ -1106,7 +1108,7 @@ static int insert_key_exec (bContext *C, wmOperator *op)
                BKE_report(op->reports, RPT_WARNING, "Keying Set failed to insert any keyframes");
        
        /* send updates */
-       DAG_ids_flush_update(0);
+       DAG_ids_flush_update(bmain, 0);
        
        return OPERATOR_FINISHED;
 }
@@ -1202,6 +1204,7 @@ void ANIM_OT_keyframe_insert_menu (wmOperatorType *ot)
 
 static int delete_key_exec (bContext *C, wmOperator *op)
 {
+       Main *bmain= CTX_data_main(C);
        Scene *scene= CTX_data_scene(C);
        KeyingSet *ks= NULL;    
        int type= RNA_int_get(op->ptr, "type");
@@ -1248,7 +1251,7 @@ static int delete_key_exec (bContext *C, wmOperator *op)
                BKE_report(op->reports, RPT_WARNING, "Keying Set failed to remove any keyframes");
        
        /* send updates */
-       DAG_ids_flush_update(0);
+       DAG_ids_flush_update(bmain, 0);
        
        return OPERATOR_FINISHED;
 }
@@ -1287,6 +1290,7 @@ void ANIM_OT_keyframe_delete (wmOperatorType *ot)
  
 static int delete_key_v3d_exec (bContext *C, wmOperator *op)
 {
+       Main *bmain= CTX_data_main(C);
        Scene *scene= CTX_data_scene(C);
        float cfra= (float)CFRA; // XXX for now, don't bother about all the yucky offset crap
        
@@ -1315,7 +1319,7 @@ static int delete_key_v3d_exec (bContext *C, wmOperator *op)
        CTX_DATA_END;
        
        /* send updates */
-       DAG_ids_flush_update(0);
+       DAG_ids_flush_update(bmain, 0);
        
        WM_event_add_notifier(C, NC_OBJECT|ND_KEYS, NULL);
        
@@ -1343,6 +1347,7 @@ void ANIM_OT_keyframe_delete_v3d (wmOperatorType *ot)
 
 static int insert_key_button_exec (bContext *C, wmOperator *op)
 {
+       Main *bmain= CTX_data_main(C);
        Scene *scene= CTX_data_scene(C);
        PointerRNA ptr;
        PropertyRNA *prop= NULL;
@@ -1400,7 +1405,7 @@ static int insert_key_button_exec (bContext *C, wmOperator *op)
        
        if (success) {
                /* send updates */
-               DAG_ids_flush_update(0);
+               DAG_ids_flush_update(bmain, 0);
                
                /* send notifiers that keyframes have been changed */
                WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
@@ -1430,6 +1435,7 @@ void ANIM_OT_keyframe_insert_button (wmOperatorType *ot)
 
 static int delete_key_button_exec (bContext *C, wmOperator *op)
 {
+       Main *bmain= CTX_data_main(C);
        Scene *scene= CTX_data_scene(C);
        PointerRNA ptr;
        PropertyRNA *prop= NULL;
@@ -1470,7 +1476,7 @@ static int delete_key_button_exec (bContext *C, wmOperator *op)
        
        if (success) {
                /* send updates */
-               DAG_ids_flush_update(0);
+               DAG_ids_flush_update(bmain, 0);
                
                /* send notifiers that keyframes have been changed */
                WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
index 301111d22fd913191c1103c0035d36fb6a3ac8df..033c4713e014372b8a051689ea42f16bd0c815b1 100644 (file)
@@ -289,6 +289,7 @@ void ANIM_OT_keying_set_path_remove (wmOperatorType *ot)
 
 static int add_keyingset_button_exec (bContext *C, wmOperator *op)
 {
+       Main *bmain= CTX_data_main(C);
        Scene *scene= CTX_data_scene(C);
        KeyingSet *ks = NULL;
        PropertyRNA *prop= NULL;
@@ -359,7 +360,7 @@ static int add_keyingset_button_exec (bContext *C, wmOperator *op)
        
        if (success) {
                /* send updates */
-               DAG_ids_flush_update(0);
+               DAG_ids_flush_update(bmain, 0);
                
                /* for now, only send ND_KEYS for KeyingSets */
                WM_event_add_notifier(C, NC_SCENE|ND_KEYINGSET, NULL);
@@ -389,6 +390,7 @@ void ANIM_OT_keyingset_button_add (wmOperatorType *ot)
 
 static int remove_keyingset_button_exec (bContext *C, wmOperator *op)
 {
+       Main *bmain= CTX_data_main(C);
        Scene *scene= CTX_data_scene(C);
        KeyingSet *ks = NULL;
        PropertyRNA *prop= NULL;
@@ -441,7 +443,7 @@ static int remove_keyingset_button_exec (bContext *C, wmOperator *op)
        
        if (success) {
                /* send updates */
-               DAG_ids_flush_update(0);
+               DAG_ids_flush_update(bmain, 0);
                
                /* for now, only send ND_KEYS for KeyingSets */
                WM_event_add_notifier(C, NC_SCENE|ND_KEYINGSET, NULL);
index 7db20fea6eb81f3032295375fa3537f3608cadc5..3b5c07a80017474c2cbd8a7d38037cca2e37ad8b 100644 (file)
@@ -421,37 +421,45 @@ void ED_armature_apply_transform(Object *ob, float mat[4][4])
 
 /* exported for use in editors/object/ */
 /* 0 == do center, 1 == center new, 2 == center cursor */
-void docenter_armature (Scene *scene, View3D *v3d, Object *ob, int centermode)
+void docenter_armature (Scene *scene, Object *ob, float cursor[3], int centermode, int around)
 {
        Object *obedit= scene->obedit; // XXX get from context
        EditBone *ebone;
        bArmature *arm= ob->data;
-       float cent[3] = {0.0f, 0.0f, 0.0f};
-       float min[3], max[3];
-       float omat[3][3];
+       float cent[3];
 
        /* Put the armature into editmode */
-       if(ob!=obedit)
+       if(ob != obedit) {
                ED_armature_to_edit(ob);
+               obedit= NULL; /* we cant use this so behave as if there is no obedit */
+       }
 
        /* Find the centerpoint */
        if (centermode == 2) {
-               float *fp= give_cursor(scene, v3d);
-               VECCOPY(cent, fp);
+               copy_v3_v3(cent, cursor);
                invert_m4_m4(ob->imat, ob->obmat);
                mul_m4_v3(ob->imat, cent);
        }
        else {
-               INIT_MINMAX(min, max);
-               
-               for (ebone= arm->edbo->first; ebone; ebone=ebone->next) {
-                       DO_MINMAX(ebone->head, min, max);
-                       DO_MINMAX(ebone->tail, min, max);
+               if(around==V3D_CENTROID) {
+                       int total= 0;
+                       zero_v3(cent);
+                       for (ebone= arm->edbo->first; ebone; ebone=ebone->next) {
+                               total+=2;
+                               add_v3_v3(cent, ebone->head);
+                               add_v3_v3(cent, ebone->tail);
+                       }
+                       mul_v3_fl(cent, 1.0f/(float)total);
+               }
+               else {
+                       float min[3], max[3];
+                       INIT_MINMAX(min, max);
+                       for (ebone= arm->edbo->first; ebone; ebone=ebone->next) {
+                               DO_MINMAX(ebone->head, min, max);
+                               DO_MINMAX(ebone->tail, min, max);
+                       }
+                       mid_v3_v3v3(cent, min, max);
                }
-               
-               cent[0]= (min[0] + max[0]) / 2.0f;
-               cent[1]= (min[1] + max[1]) / 2.0f;
-               cent[2]= (min[2] + max[2]) / 2.0f;
        }
        
        /* Do the adjustments */
@@ -461,17 +469,16 @@ void docenter_armature (Scene *scene, View3D *v3d, Object *ob, int centermode)
        }
        
        /* Turn the list into an armature */
-       ED_armature_from_edit(ob);
-       
+       if(obedit==NULL) {
+               ED_armature_from_edit(ob);
+               ED_armature_edit_free(ob);
+       }
+
        /* Adjust object location for new centerpoint */
        if(centermode && obedit==NULL) {
-               copy_m3_m4(omat, ob->obmat);
-               
-               mul_m3_v3(omat, cent);
+               mul_mat3_m4_v3(ob->obmat, cent); /* ommit translation part */
                add_v3_v3(ob->loc, cent);
        }
-       else 
-               ED_armature_edit_free(ob);
 }
 
 /* ---------------------- */
@@ -802,6 +809,7 @@ static void joined_armature_fix_links(Object *tarArm, Object *srcArm, bPoseChann
 /* join armature exec is exported for use in object->join objects operator... */
 int join_armature_exec(bContext *C, wmOperator *op)
 {
+       Main *bmain= CTX_data_main(C);
        Scene *scene= CTX_data_scene(C);
        Object  *ob= CTX_data_active_object(C);
        bArmature *arm= (ob)? ob->data: NULL;
@@ -894,12 +902,12 @@ int join_armature_exec(bContext *C, wmOperator *op)
                                free_pose_channels_hash(pose);
                        }
                        
-                       ED_base_object_free_and_unlink(scene, base);
+                       ED_base_object_free_and_unlink(bmain, scene, base);
                }
        }
        CTX_DATA_END;
        
-       DAG_scene_sort(scene);  // because we removed object(s)
+       DAG_scene_sort(bmain, scene);   // because we removed object(s)
 
        ED_armature_from_edit(ob);
        ED_armature_edit_free(ob);
@@ -1111,6 +1119,7 @@ static void separate_armature_bones (Scene *scene, Object *ob, short sel)
 /* separate selected bones into their armature */
 static int separate_armature_exec (bContext *C, wmOperator *op)
 {
+       Main *bmain= CTX_data_main(C);
        Scene *scene= CTX_data_scene(C);
        Object *obedit= CTX_data_edit_object(C);
        Object *oldob, *newob;
@@ -1151,7 +1160,7 @@ static int separate_armature_exec (bContext *C, wmOperator *op)
        ED_armature_edit_free(obedit);
        
        /* 2) duplicate base */
-       newbase= ED_object_add_duplicate(scene, oldbase, USER_DUP_ARM); /* only duplicate linked armature */
+       newbase= ED_object_add_duplicate(bmain, scene, oldbase, USER_DUP_ARM); /* only duplicate linked armature */
        newob= newbase->object;         
        newbase->flag &= ~SELECT;
        
@@ -2022,7 +2031,6 @@ void ED_armature_edit_free(struct Object *ob)
 
                        BLI_freelistN(arm->edbo);
                }
-
                MEM_freeN(arm->edbo);
                arm->edbo= NULL;
        }
index d650cecdc3eee486f08d0b0b353e54cd74b96230..47b1fee3cf68c6bc3838003c29e825ec9e59d429 100644 (file)
@@ -233,6 +233,6 @@ void ED_keymap_curve(wmKeyConfig *keyconf)
        /* menus */
        WM_keymap_add_menu(keymap, "VIEW3D_MT_hook", HKEY, KM_PRESS, KM_CTRL, 0);
 
-       ED_object_generic_keymap(keyconf, keymap, 2);
+       ED_object_generic_keymap(keyconf, keymap, 3);
 }
 
index d38c91da5c5c363de21c9bdbe91c0b5a74a827bb..16204e9f1993ca88972c5cec8fd188d1943a4013 100644 (file)
@@ -1119,6 +1119,7 @@ void CU_select_swap(Object *obedit)
 
 static int separate_exec(bContext *C, wmOperator *op)
 {
+       Main *bmain= CTX_data_main(C);
        Scene *scene= CTX_data_scene(C);
        Nurb *nu, *nu1;
        Object *oldob, *newob;
@@ -1139,7 +1140,7 @@ static int separate_exec(bContext *C, wmOperator *op)
        WM_cursor_wait(1);
        
        /* 1. duplicate the object and data */
-       newbase= ED_object_add_duplicate(scene, oldbase, 0);    /* 0 = fully linked */
+       newbase= ED_object_add_duplicate(bmain, scene, oldbase, 0);     /* 0 = fully linked */
        ED_base_object_select(newbase, BA_DESELECT);
        newob= newbase->object;
 
@@ -5543,6 +5544,7 @@ void CURVE_OT_shade_flat(wmOperatorType *ot)
 
 int join_curve_exec(bContext *C, wmOperator *op)
 {
+       Main *bmain= CTX_data_main(C);
        Scene *scene= CTX_data_scene(C);
        Object *ob= CTX_data_active_object(C);
        Curve *cu;
@@ -5594,7 +5596,7 @@ int join_curve_exec(bContext *C, wmOperator *op)
                                        }
                                }
                        
-                               ED_base_object_free_and_unlink(scene, base);
+                               ED_base_object_free_and_unlink(bmain, scene, base);
                        }
                }
        }
@@ -5603,7 +5605,7 @@ int join_curve_exec(bContext *C, wmOperator *op)
        cu= ob->data;
        addlisttolist(&cu->nurb, &tempbase);
        
-       DAG_scene_sort(scene);  // because we removed object(s), call before editmode!
+       DAG_scene_sort(bmain, scene);   // because we removed object(s), call before editmode!
        
        ED_object_enter_editmode(C, EM_WAITCURSOR);
        ED_object_exit_editmode(C, EM_FREEDATA|EM_WAITCURSOR|EM_DO_UNDO);
index d2d1e2a1d6907edaf221c88baaf525dcd8161ddb..52db36e188db5f3504e076a1bd56df53b00cf0c7 100644 (file)
@@ -120,7 +120,7 @@ void ED_armature_edit_bone_remove(struct bArmature *arm, EditBone *exBone);
 
 void transform_armature_mirror_update(struct Object *obedit);
 void clear_armature(struct Scene *scene, struct Object *ob, char mode);
-void docenter_armature (struct Scene *scene, struct View3D *v3d, struct Object *ob, int centermode);
+void docenter_armature (struct Scene *scene, struct Object *ob, float cursor[3], int centermode, int around);
 
 void ED_armature_apply_transform(struct Object *ob, float mat[4][4]);
 
index a03cd135f1ca5baa9b49591f649efcf32a7c07ac..f243b4cc497534f72c119f7c83fd41d9b8377953 100644 (file)
 #ifndef ED_OBJECT_H
 #define ED_OBJECT_H
 
-struct wmKeyConfig;
-struct wmKeyMap;
-struct Scene;
-struct Object;
-struct bContext;
 struct Base;
-struct View3D;
 struct bConstraint;
+struct bContext;
 struct bPoseChannel;
+struct Curve;
 struct KeyBlock;
 struct Lattice;
+struct Main;
 struct Mesh;
-struct Curve;
-struct ReportList;
 struct ModifierData;
-struct wmOperatorType;
-struct wmOperator;
+struct Object;
+struct ReportList;
+struct Scene;
+struct View3D;
 struct wmEvent;
+struct wmKeyConfig;
+struct wmKeyMap;
+struct wmOperator;
+struct wmOperatorType;
 
 /* object_edit.c */
 struct Object *ED_object_active_context(struct bContext *C);
@@ -55,7 +56,13 @@ void ED_operatortypes_object(void);
 void ED_operatormacros_object(void);
 void ED_keymap_object(struct wmKeyConfig *keyconf);
 
-/* generic editmode keys like pet */
+/* generic editmode keys like pet
+ * do_pet
+ *     0: No
+ *     1: Object
+ *     2: Edit
+ *     3: Edit with connected
+ * */
 void ED_object_generic_keymap(struct wmKeyConfig *keyconf, struct wmKeyMap *keymap, int do_pet);
 
        /* send your own notifier for select! */
@@ -63,10 +70,10 @@ void ED_base_object_select(struct Base *base, short mode);
        /* includes notifier */
 void ED_base_object_activate(struct bContext *C, struct Base *base);
 
-void ED_base_object_free_and_unlink(struct Scene *scene, struct Base *base);
+void ED_base_object_free_and_unlink(struct Main *bmain, struct Scene *scene, struct Base *base);
 
        /* single object duplicate, if dupflag==0, fully linked, else it uses the flags given */
-struct Base *ED_object_add_duplicate(struct Scene *scene, struct Base *base, int dupflag);
+struct Base *ED_object_add_duplicate(struct Main *bmain, struct Scene *scene, struct Base *base, int dupflag);
 
 void ED_object_parent(struct Object *ob, struct Object *parent, int type, const char *substr);
 
@@ -91,7 +98,7 @@ int ED_object_add_generic_invoke(struct bContext *C, struct wmOperator *op, stru
 int ED_object_add_generic_get_opts(struct bContext *C, struct wmOperator *op, float *loc, float *rot, int *enter_editmode, unsigned int *layer);
 struct Object *ED_object_add_type(struct bContext *C, int type, float *loc, float *rot, int enter_editmode, unsigned int layer);
 
-void ED_object_single_users(struct Scene *scene, int full);
+void ED_object_single_users(struct Main *bmain, struct Scene *scene, int full);
 
 /* cleanup */
 int object_is_libdata(struct Object *ob);
@@ -110,7 +117,7 @@ void object_test_constraints(struct Object *ob);
 
 void ED_object_constraint_set_active(struct Object *ob, struct bConstraint *con);
 void ED_object_constraint_update(struct Object *ob);
-void ED_object_constraint_dependency_update(struct Scene *scene, struct Object *ob);
+void ED_object_constraint_dependency_update(struct Main *bmain, struct Scene *scene, struct Object *ob);
 
 /* object_lattice.c */
 int  mouse_lattice(struct bContext *C, short mval[2], int extend);
@@ -126,11 +133,11 @@ enum {
        MODIFIER_APPLY_SHAPE,
 } eModifier_Apply_Mode;
 
-struct ModifierData *ED_object_modifier_add(struct ReportList *reports, struct Scene *scene, struct Object *ob, char *name, int type);
-int ED_object_modifier_remove(struct ReportList *reports, struct Scene *scene, struct Object *ob, struct ModifierData *md);
+struct ModifierData *ED_object_modifier_add(struct ReportList *reports, struct Main *bmain, struct Scene *scene, struct Object *ob, char *name, int type);
+int ED_object_modifier_remove(struct ReportList *reports, struct Main *bmain, struct Scene *scene, struct Object *ob, struct ModifierData *md);
 int ED_object_modifier_move_down(struct ReportList *reports, struct Object *ob, struct ModifierData *md);
 int ED_object_modifier_move_up(struct ReportList *reports, struct Object *ob, struct ModifierData *md);
-int ED_object_modifier_convert(struct ReportList *reports, struct Scene *scene, struct Object *ob, struct ModifierData *md);
+int ED_object_modifier_convert(struct ReportList *reports, struct Main *bmain, struct Scene *scene, struct Object *ob, struct ModifierData *md);
 int ED_object_modifier_apply(struct ReportList *reports, struct Scene *scene, struct Object *ob, struct ModifierData *md, int mode);
 int ED_object_modifier_copy(struct ReportList *reports, struct Object *ob, struct ModifierData *md);
 
index 7b67a458ae2d97774f7e91cb2a768224ed57e931..38c11e507cc3d1d35d5f99fedc9815b5a24639a1 100644 (file)
@@ -1644,7 +1644,7 @@ int ui_set_but_string(bContext *C, uiBut *but, const char *str)
                value= atof(str);
 #endif
 
-               if(!ui_is_but_float(but)) value= (int)value;
+               if(!ui_is_but_float(but)) value= (int)floor(value + 0.5);
                if(but->type==NUMABS) value= fabs(value);
 
                /* not that we use hard limits here */
index c2bcc673c1e2cc1540e21c91d621d8fb098c0c8e..c56b3c31222b47d9a6e6b2de0981fdef3ab48939 100644 (file)
@@ -1111,13 +1111,23 @@ static void rna_search_cb(const struct bContext *C, void *arg_but, char *str, ui
                        if(itemptr.data == but->rnapoin.id.data)
                                continue;
 
-               if(itemptr.type && RNA_struct_is_ID(itemptr.type))
-                       iconid= ui_id_icon_get((bContext*)C, itemptr.data, 1);
-        else
+               if(itemptr.type && RNA_struct_is_ID(itemptr.type)) {
+                       ID *id= itemptr.data;
+                       char name_ui[32];
+
+#if 0          /* this name is used for a string comparison and can't be modified, TODO */
+                       name_uiprefix_id(name_ui, id);
+#else
+                       strcpy(name_ui, id->name+2);
+#endif
+                       name= BLI_strdup(name_ui);
+                       iconid= ui_id_icon_get((bContext*)C, id, 1);
+        }
+               else {
+                       name= RNA_struct_name_get_alloc(&itemptr, NULL, 0);
             iconid = 0;
-               
-               name= RNA_struct_name_get_alloc(&itemptr, NULL, 0);
-               
+               }
+
                if(name) {
                        if(BLI_strcasestr(name, str)) {
                                cis = MEM_callocN(sizeof(CollItemSearch), "CollectionItemSearch");
@@ -1126,9 +1136,9 @@ static void rna_search_cb(const struct bContext *C, void *arg_but, char *str, ui
                                cis->iconid = iconid;
                                BLI_addtail(items_list, cis);
                        }
-               MEM_freeN(name);
-               }
-               
+                       MEM_freeN(name);
+               }                       
+
                i++;
        }
        RNA_PROP_END;
index 488258d2a06518b04995238e918ad6715c2daf53..3d32030326f1b6547f35c2337166bd072044c303 100644 (file)
@@ -218,9 +218,12 @@ static void id_search_cb(const bContext *C, void *arg_template, char *str, uiSea
                                        continue;
 
                        if(BLI_strcasestr(id->name+2, str)) {
+                               char name_ui[32];
+                               name_uiprefix_id(name_ui, id);
+
                                iconid= ui_id_icon_get((bContext*)C, id, 1);
 
-                               if(!uiSearchItemAdd(items, id->name+2, id, iconid))
+                               if(!uiSearchItemAdd(items, name_ui, id, iconid))
                                        break;
                        }
                }
@@ -958,6 +961,7 @@ uiLayout *uiTemplateModifier(uiLayout *layout, bContext *C, PointerRNA *ptr, int
 
 void do_constraint_panels(bContext *C, void *arg, int event)
 {
+       Main *bmain= CTX_data_main(C);
        Scene *scene= CTX_data_scene(C);
        Object *ob= CTX_data_active_object(C);
        
@@ -969,7 +973,7 @@ void do_constraint_panels(bContext *C, void *arg, int event)
                break;  // no handling
        case B_CONSTRAINT_CHANGETARGET:
                if (ob->pose) ob->pose->flag |= POSE_RECALC;    // checks & sorts pose channels
-               DAG_scene_sort(scene);
+               DAG_scene_sort(bmain, scene);
                break;
        default:
                break;
index 3f943f7b1b0e0ae0a7ee8d4c3a5b653febf7acbe..4b02e4b1e65f7bfdb9a3af8726736f79ad66d5b5 100644 (file)
@@ -979,6 +979,7 @@ void UI_make_axis_color(char *src_col, char *dst_col, char axis)
 /* patching UserDef struct and Themes */
 void init_userdef_do_versions(void)
 {
+       Main *bmain= G.main;
 //     countall();
        
        /* the UserDef struct is not corrected with do_versions() .... ugh! */
@@ -1013,18 +1014,18 @@ void init_userdef_do_versions(void)
        if(U.flag & USER_CUSTOM_RANGE) 
                vDM_ColorBand_store(&U.coba_weight); /* signal for derivedmesh to use colorband */
        
-       if (G.main->versionfile <= 191) {
+       if (bmain->versionfile <= 191) {
                strcpy(U.plugtexdir, U.textudir);
                strcpy(U.sounddir, "/");
        }
        
        /* patch to set Dupli Armature */
-       if (G.main->versionfile < 220) {
+       if (bmain->versionfile < 220) {
                U.dupflag |= USER_DUP_ARM;
        }
        
        /* added seam, normal color, undo */
-       if (G.main->versionfile <= 234) {
+       if (bmain->versionfile <= 234) {
                bTheme *btheme;
                
                U.uiflag |= USER_GLOBALUNDO;
@@ -1047,12 +1048,12 @@ void init_userdef_do_versions(void)
                        }
                }
        }
-       if (G.main->versionfile <= 235) {
+       if (bmain->versionfile <= 235) {
                /* illegal combo... */
                if (U.flag & USER_LMOUSESELECT) 
                        U.flag &= ~USER_TWOBUTTONMOUSE;
        }
-       if (G.main->versionfile <= 236) {
+       if (bmain->versionfile <= 236) {
                bTheme *btheme;
                /* new space type */
                for(btheme= U.themes.first; btheme; btheme= btheme->next) {
@@ -1069,7 +1070,7 @@ void init_userdef_do_versions(void)
                        }
                }
        }
-       if (G.main->versionfile <= 237) {
+       if (bmain->versionfile <= 237) {
                bTheme *btheme;
                /* bone colors */
                for(btheme= U.themes.first; btheme; btheme= btheme->next) {
@@ -1080,7 +1081,7 @@ void init_userdef_do_versions(void)
                        }
                }
        }
-       if (G.main->versionfile <= 238) {
+       if (bmain->versionfile <= 238) {
                bTheme *btheme;
                /* bone colors */
                for(btheme= U.themes.first; btheme; btheme= btheme->next) {
@@ -1091,7 +1092,7 @@ void init_userdef_do_versions(void)
                        }
                }
        }
-       if (G.main->versionfile <= 239) {
+       if (bmain->versionfile <= 239) {
                bTheme *btheme;
                
                for(btheme= U.themes.first; btheme; btheme= btheme->next) {
@@ -1105,7 +1106,7 @@ void init_userdef_do_versions(void)
                }
                if(U.obcenter_dia==0) U.obcenter_dia= 6;
        }
-       if (G.main->versionfile <= 241) {
+       if (bmain->versionfile <= 241) {
                bTheme *btheme;
                for(btheme= U.themes.first; btheme; btheme= btheme->next) {
                        /* Node editor theme, check for alpha==0 is safe, then color was never set */
@@ -1146,7 +1147,7 @@ void init_userdef_do_versions(void)
                }
                
        }
-       if (G.main->versionfile <= 242) {
+       if (bmain->versionfile <= 242) {
                bTheme *btheme;
                
                for(btheme= U.themes.first; btheme; btheme= btheme->next) {
@@ -1164,11 +1165,11 @@ void init_userdef_do_versions(void)
                        }
                }
        }
-       if (G.main->versionfile <= 243) {
+       if (bmain->versionfile <= 243) {
                /* set default number of recently-used files (if not set) */
                if (U.recent_files == 0) U.recent_files = 10;
        }
-       if (G.main->versionfile < 245 || (G.main->versionfile == 245 && G.main->subversionfile < 3)) {
+       if (bmain->versionfile < 245 || (bmain->versionfile == 245 && bmain->subversionfile < 3)) {
                bTheme *btheme;
                for(btheme= U.themes.first; btheme; btheme= btheme->next) {
                        SETCOL(btheme->tv3d.editmesh_active, 255, 255, 255, 128);
@@ -1176,7 +1177,7 @@ void init_userdef_do_versions(void)
                if(U.coba_weight.tot==0)
                        init_colorband(&U.coba_weight, 1);
        }
-       if ((G.main->versionfile < 245) || (G.main->versionfile == 245 && G.main->subversionfile < 11)) {
+       if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 11)) {
                bTheme *btheme;
                for (btheme= U.themes.first; btheme; btheme= btheme->next) {
                        /* these should all use the same colour */
@@ -1189,7 +1190,7 @@ void init_userdef_do_versions(void)
                        SETCOL(btheme->ttime.cframe, 0x60, 0xc0, 0x40, 255);
                }
        }
-       if ((G.main->versionfile < 245) || (G.main->versionfile == 245 && G.main->subversionfile < 13)) {
+       if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 13)) {
                bTheme *btheme;
                for (btheme= U.themes.first; btheme; btheme= btheme->next) {
                        /* action channel groups (recolor anyway) */
@@ -1262,10 +1263,10 @@ void init_userdef_do_versions(void)
                        }
                }
        }
-       if ((G.main->versionfile < 245) || (G.main->versionfile == 245 && G.main->subversionfile < 16)) {
+       if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 16)) {
                U.flag |= USER_ADD_VIEWALIGNED|USER_ADD_EDITMODE;
        }
-       if ((G.main->versionfile < 247) || (G.main->versionfile == 247 && G.main->subversionfile <= 2)) {
+       if ((bmain->versionfile < 247) || (bmain->versionfile == 247 && bmain->subversionfile <= 2)) {
                bTheme *btheme;
                
                /* adjust themes */
@@ -1287,7 +1288,7 @@ void init_userdef_do_versions(void)
                        SETCOL(btheme->tseq.vertex_select, col[0], col[1], col[2], 255);
                }
        }
-       if (G.main->versionfile < 250) {
+       if (bmain->versionfile < 250) {
                bTheme *btheme;
                
                for(btheme= U.themes.first; btheme; btheme= btheme->next) {
@@ -1328,7 +1329,7 @@ void init_userdef_do_versions(void)
                U.ipo_new= BEZT_IPO_BEZ;
        }
        
-       if (G.main->versionfile < 250 || (G.main->versionfile == 250 && G.main->subversionfile < 1)) {
+       if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 1)) {
                bTheme *btheme;
 
                for(btheme= U.themes.first; btheme; btheme= btheme->next) {
@@ -1351,7 +1352,7 @@ void init_userdef_do_versions(void)
                }
        }
 
-       if (G.main->versionfile < 250 || (G.main->versionfile == 250 && G.main->subversionfile < 3)) {
+       if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 3)) {
                /* new audio system */
                if(U.audiochannels == 0)
                        U.audiochannels = 2;
@@ -1369,10 +1370,10 @@ void init_userdef_do_versions(void)
                        U.audiorate = 44100;
        }
 
-       if (G.main->versionfile < 250 || (G.main->versionfile == 250 && G.main->subversionfile < 5))
+       if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 5))
                U.gameflags |= USER_DISABLE_VBO;
        
-       if (G.main->versionfile < 250 || (G.main->versionfile == 250 && G.main->subversionfile < 8)) {
+       if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 8)) {
                wmKeyMap *km;
                
                for(km=U.keymaps.first; km; km=km->next) {
@@ -1412,16 +1413,16 @@ void init_userdef_do_versions(void)
                                strcpy(km->idname, "Property Editor");
                }
        }
-       if (G.main->versionfile < 250 || (G.main->versionfile == 250 && G.main->subversionfile < 16)) {
+       if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 16)) {
                if(U.wmdrawmethod == USER_DRAW_TRIPLE)
                        U.wmdrawmethod = USER_DRAW_AUTOMATIC;
        }
        
-       if (G.main->versionfile < 252 || (G.main->versionfile == 252 && G.main->subversionfile < 3)) {
+       if (bmain->versionfile < 252 || (bmain->versionfile == 252 && bmain->subversionfile < 3)) {
                if (U.flag & USER_LMOUSESELECT) 
                        U.flag &= ~USER_TWOBUTTONMOUSE;
        }
-       if (G.main->versionfile < 252 || (G.main->versionfile == 252 && G.main->subversionfile < 4)) {
+       if (bmain->versionfile < 252 || (bmain->versionfile == 252 && bmain->subversionfile < 4)) {
                bTheme *btheme;
                
                /* default new handle type is auto handles */
@@ -1454,7 +1455,7 @@ void init_userdef_do_versions(void)
                        SETCOLF(btheme->tv3d.edge_crease, 0.8, 0, 0.6, 1.0);
                }
        }
-       if (G.main->versionfile <= 252) {
+       if (bmain->versionfile <= 252) {
                bTheme *btheme;
 
                /* init new curve colors */
@@ -1463,7 +1464,7 @@ void init_userdef_do_versions(void)
                                SETCOL(btheme->tv3d.lastsel_point, 0xff, 0xff, 0xff, 255);
                }
        }
-       if (G.main->versionfile < 252 || (G.main->versionfile == 252 && G.main->subversionfile < 5)) {
+       if (bmain->versionfile < 252 || (bmain->versionfile == 252 && bmain->subversionfile < 5)) {
                bTheme *btheme;
                
                /* interface_widgets.c */
index cdcbb5cb4611b583f353ecbe3b643cad566c821a..a63f4995acc8c28848aee4f3bc263aa142986d79 100644 (file)
@@ -1330,7 +1330,7 @@ static EnumPropertyItem prop_separate_types[] = {
 };
 
 /* return 1: success */
-static int mesh_separate_selected(Scene *scene, Base *editbase)
+static int mesh_separate_selected(Main *bmain, Scene *scene, Base *editbase)
 {
        EditMesh *em, *emnew;
        EditVert *eve, *v1;
@@ -1372,7 +1372,7 @@ static int mesh_separate_selected(Scene *scene, Base *editbase)
         */
        
        /* 1 */
-       basenew= ED_object_add_duplicate(scene, editbase, 0);   /* 0 = fully linked */
+       basenew= ED_object_add_duplicate(bmain, scene, editbase, 0);    /* 0 = fully linked */
        ED_base_object_select(basenew, BA_DESELECT);
        
        /* 2 */
@@ -1441,7 +1441,7 @@ static int mesh_separate_selected(Scene *scene, Base *editbase)
 }
 
 /* return 1: success */
-static int mesh_separate_material(Scene *scene, Base *editbase)
+static int mesh_separate_material(Main *bmain, Scene *scene, Base *editbase)
 {
        Mesh *me= editbase->object->data;
        EditMesh *em= BKE_mesh_get_editmesh(me);
@@ -1453,7 +1453,7 @@ static int mesh_separate_material(Scene *scene, Base *editbase)
                /* select the material */
                EM_select_by_material(em, curr_mat);
                /* and now separate */
-               if(0==mesh_separate_selected(scene, editbase)) {
+               if(0==mesh_separate_selected(bmain, scene, editbase)) {
                        BKE_mesh_end_editmesh(me, em);
                        return 0;
                }
@@ -1464,7 +1464,7 @@ static int mesh_separate_material(Scene *scene, Base *editbase)
 }
 
 /* return 1: success */
-static int mesh_separate_loose(Scene *scene, Base *editbase)
+static int mesh_separate_loose(Main *bmain, Scene *scene, Base *editbase)
 {
        Mesh *me;
        EditMesh *em;
@@ -1504,7 +1504,7 @@ static int mesh_separate_loose(Scene *scene, Base *editbase)
                tot= BLI_countlist(&em->verts);
 
                /* and now separate */
-               doit= mesh_separate_selected(scene, editbase);
+               doit= mesh_separate_selected(bmain, scene, editbase);
 
                /* with hidden verts this can happen */
                if(tot == BLI_countlist(&em->verts))
@@ -1518,16 +1518,17 @@ static int mesh_separate_loose(Scene *scene, Base *editbase)
 
 static int mesh_separate_exec(bContext *C, wmOperator *op)
 {
+       Main *bmain= CTX_data_main(C);
        Scene *scene= CTX_data_scene(C);
        Base *base= CTX_data_active_base(C);
        int retval= 0, type= RNA_enum_get(op->ptr, "type");
        
        if(type == 0)
-               retval= mesh_separate_selected(scene, base);
+               retval= mesh_separate_selected(bmain, scene, base);
        else if(type == 1)
-               retval= mesh_separate_material (scene, base);
+               retval= mesh_separate_material(bmain, scene, base);
        else if(type == 2)
-               retval= mesh_separate_loose(scene, base);
+               retval= mesh_separate_loose(bmain, scene, base);
           
        if(retval) {
                WM_event_add_notifier(C, NC_GEOM|ND_DATA, base->object->data);
index e143e4859f56a7880921bfbee4c3904a667c2a9b..9eac347c8938b3cf3f8c5b4c0e872b5669366fa3 100644 (file)
@@ -314,6 +314,6 @@ void ED_keymap_mesh(wmKeyConfig *keyconf)
        WM_keymap_add_menu(keymap, "VIEW3D_MT_uv_map", UKEY, KM_PRESS, 0, 0);
        WM_keymap_add_menu(keymap, "VIEW3D_MT_vertex_group", GKEY, KM_PRESS, KM_CTRL, 0);
        
-       ED_object_generic_keymap(keyconf, keymap, 2);
+       ED_object_generic_keymap(keyconf, keymap, 3);
 }
 
index 87b5c886b4a7d72f19cc79feadbdc6f3fc7e6ab1..47b7b89ff7a90d88ea695f29c5b11a38d60a0ce1 100644 (file)
@@ -92,6 +92,7 @@ return 0 if no join is made (error) and 1 of the join is done */
 
 int join_mesh_exec(bContext *C, wmOperator *op)
 {
+       Main *bmain= CTX_data_main(C);
        Scene *scene= CTX_data_scene(C);
        Object *ob= CTX_data_active_object(C);
        Material **matar, *ma;
@@ -443,7 +444,7 @@ int join_mesh_exec(bContext *C, wmOperator *op)
                        
                        /* free base, now that data is merged */
                        if(base->object != ob)
-                               ED_base_object_free_and_unlink(scene, base);
+                               ED_base_object_free_and_unlink(bmain, scene, base);
                }
        }
        CTX_DATA_END;
@@ -503,17 +504,17 @@ int join_mesh_exec(bContext *C, wmOperator *op)
                /* free it's ipo too - both are not actually freed from memory yet as ID-blocks */
                if(nkey->ipo) {
                        free_ipo(nkey->ipo);
-                       BLI_remlink(&G.main->ipo, nkey->ipo);
+                       BLI_remlink(&bmain->ipo, nkey->ipo);
                        MEM_freeN(nkey->ipo);
                }
 #endif
                
                free_key(nkey);
-               BLI_remlink(&G.main->key, nkey);
+               BLI_remlink(&bmain->key, nkey);
                MEM_freeN(nkey);
        }
        
-       DAG_scene_sort(scene);  // removed objects, need to rebuild dag before editmode call
+       DAG_scene_sort(bmain, scene);   // removed objects, need to rebuild dag before editmode call
        
        ED_object_enter_editmode(C, EM_WAITCURSOR);
        ED_object_exit_editmode(C, EM_FREEDATA|EM_WAITCURSOR|EM_DO_UNDO);
index e08661b1795ee914d22830f57d9785233003cacb..67cae8d4155d9dd050c3ea9af1f5195fffb34529 100644 (file)
@@ -241,7 +241,7 @@ int ED_object_add_generic_get_opts(bContext *C, wmOperator *op, float *loc, floa
 
        if(RNA_property_is_set(op->ptr, "layer")) {
                RNA_boolean_get_array(op->ptr, "layer", layer_values);
-
+               *layer= 0;
                for(a=0; a<20; a++) {
                        if(layer_values[a])
                                *layer |= (1 << a);
@@ -284,6 +284,7 @@ int ED_object_add_generic_get_opts(bContext *C, wmOperator *op, float *loc, floa
 /* for object add primitive operators */
 Object *ED_object_add_type(bContext *C, int type, float *loc, float *rot, int enter_editmode, unsigned int layer)
 {
+       Main *bmain= CTX_data_main(C);
        Scene *scene= CTX_data_scene(C);
        Object *ob;
        
@@ -300,8 +301,8 @@ Object *ED_object_add_type(bContext *C, int type, float *loc, float *rot, int en
        /* more editor stuff */
        ED_object_base_init_transform(C, BASACT, loc, rot);
 
-       DAG_scene_sort(scene);
-       ED_render_id_flush_update(G.main, ob->data);
+       DAG_scene_sort(bmain, scene);
+       ED_render_id_flush_update(bmain, ob->data);
 
        if(enter_editmode)
                ED_object_enter_editmode(C, EM_IGNORE_LAYER);
@@ -750,6 +751,8 @@ static int group_instance_add_exec(bContext *C, wmOperator *op)
                return OPERATOR_CANCELLED;
 
        if(group) {
+               Main *bmain= CTX_data_main(C);
+               Scene *scene= CTX_data_scene(C);
                Object *ob= ED_object_add_type(C, OB_EMPTY, loc, rot, FALSE, layer);
                rename_id(&ob->id, group->id.name+2);
                ob->dup_group= group;
@@ -757,7 +760,7 @@ static int group_instance_add_exec(bContext *C, wmOperator *op)
                id_lib_extern(&group->id);
 
                /* works without this except if you try render right after, see: 22027 */
-               DAG_scene_sort(CTX_data_scene(C));
+               DAG_scene_sort(bmain, scene);
 
                WM_event_add_notifier(C, NC_SCENE|ND_OB_ACTIVE, CTX_data_scene(C));
 
@@ -797,16 +800,17 @@ void OBJECT_OT_group_instance_add(wmOperatorType *ot)
 
 /* remove base from a specific scene */
 /* note: now unlinks constraints as well */
-void ED_base_object_free_and_unlink(Scene *scene, Base *base)
+void ED_base_object_free_and_unlink(Main *bmain, Scene *scene, Base *base)
 {
        BLI_remlink(&scene->base, base);
-       free_libblock_us(&G.main->object, base->object);
+       free_libblock_us(&bmain->object, base->object);
        if(scene->basact==base) scene->basact= NULL;
        MEM_freeN(base);
 }
 
 static int object_delete_exec(bContext *C, wmOperator *op)
 {
+       Main *bmain= CTX_data_main(C);
        Scene *scene= CTX_data_scene(C);
        int islamp= 0;
        
@@ -817,14 +821,14 @@ static int object_delete_exec(bContext *C, wmOperator *op)
 
                if(base->object->type==OB_LAMP) islamp= 1;
                /* remove from current scene only */
-               ED_base_object_free_and_unlink(scene, base);
+               ED_base_object_free_and_unlink(bmain, scene, base);
        }
        CTX_DATA_END;
 
        if(islamp) reshadeall_displist(scene);  /* only frees displist */
 
-       DAG_scene_sort(scene);
-       DAG_ids_flush_update(0);
+       DAG_scene_sort(bmain, scene);
+       DAG_ids_flush_update(bmain, 0);
        
        WM_event_add_notifier(C, NC_SCENE|ND_OB_ACTIVE, CTX_data_scene(C));
        
@@ -859,6 +863,7 @@ static void copy_object__forwardModifierLinks(void *userData, Object *ob,
 /* after copying objects, copied data should get new pointers */
 static void copy_object_set_idnew(bContext *C, int dupflag)
 {
+       Main *bmain= CTX_data_main(C);
        Material *ma, *mao;
        ID *id;
        int a;
@@ -881,7 +886,7 @@ static void copy_object_set_idnew(bContext *C, int dupflag)
        
        /* materials */
        if( dupflag & USER_DUP_MAT) {
-               mao= G.main->mat.first;
+               mao= bmain->mat.first;
                while(mao) {
                        if(mao->id.newid) {
                                
@@ -915,7 +920,7 @@ static void copy_object_set_idnew(bContext *C, int dupflag)
 #if 0 // XXX old animation system
        /* lamps */
        if( dupflag & USER_DUP_IPO) {
-               Lamp *la= G.main->lamp.first;
+               Lamp *la= bmain->lamp.first;
                while(la) {
                        if(la->id.newid) {
                                Lamp *lan= (Lamp *)la->id.newid;
@@ -931,7 +936,7 @@ static void copy_object_set_idnew(bContext *C, int dupflag)
        }
        
        /* ipos */
-       ipo= G.main->ipo.first;
+       ipo= bmain->ipo.first;
        while(ipo) {
                if(ipo->id.lib==NULL && ipo->id.newid) {
                        Ipo *ipon= (Ipo *)ipo->id.newid;
@@ -1000,6 +1005,7 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base)
 
 static int object_duplicates_make_real_exec(bContext *C, wmOperator *op)
 {
+       Main *bmain= CTX_data_main(C);
        Scene *scene= CTX_data_scene(C);
        
        clear_id_newpoins();
@@ -1009,8 +1015,8 @@ static int object_duplicates_make_real_exec(bContext *C, wmOperator *op)
        }
        CTX_DATA_END;
 
-       DAG_scene_sort(scene);
-       DAG_ids_flush_update(0);
+       DAG_scene_sort(bmain, scene);
+       DAG_ids_flush_update(bmain, 0);
        WM_event_add_notifier(C, NC_SCENE, scene);
        WM_main_add_notifier(NC_OBJECT|ND_DRAW, NULL);
        
@@ -1089,6 +1095,7 @@ static Base *duplibase_for_convert(Scene *scene, Base *base, Object *ob)
 
 static int convert_exec(bContext *C, wmOperator *op)
 {
+       Main *bmain= CTX_data_main(C);
        Scene *scene= CTX_data_scene(C);
        Base *basen=NULL, *basact=NULL, *basedel=NULL;
        Object *ob, *ob1, *newob, *obact= CTX_data_active_object(C);
@@ -1214,7 +1221,7 @@ static int convert_exec(bContext *C, wmOperator *op)
                        if (!keep_original) {
                                /* other users */
                                if(cu->id.us>1) {
-                                       for(ob1= G.main->object.first; ob1; ob1=ob1->id.next) {
+                                       for(ob1= bmain->object.first; ob1; ob1=ob1->id.next) {
                                                if(ob1->data==ob->data) {
                                                        ob1->type= OB_CURVE;
                                                        ob1->recalc |= OB_RECALC_ALL;
@@ -1321,7 +1328,7 @@ static int convert_exec(bContext *C, wmOperator *op)
                /* delete original if needed */
                if(basedel) {
                        if(!keep_original)
-                               ED_base_object_free_and_unlink(scene, basedel); 
+                               ED_base_object_free_and_unlink(bmain, scene, basedel);  
 
                        basedel = NULL;
                }
@@ -1337,13 +1344,13 @@ static int convert_exec(bContext *C, wmOperator *op)
                                base= base->next;
 
                                if (ob->type == OB_MBALL) {
-                                       ED_base_object_free_and_unlink(scene, tmpbase);
+                                       ED_base_object_free_and_unlink(bmain, scene, tmpbase);
                                }
                        }
                }
 
                /* delete object should renew depsgraph */
-               DAG_scene_sort(scene);
+               DAG_scene_sort(bmain, scene);
        }
 
 // XXX ED_object_enter_editmode(C, 0);
@@ -1357,7 +1364,7 @@ static int convert_exec(bContext *C, wmOperator *op)
                WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER|ND_DATA, BASACT->object);
        }
 
-       DAG_scene_sort(scene);
+       DAG_scene_sort(bmain, scene);
        WM_event_add_notifier(C, NC_SCENE|NC_OBJECT|ND_DRAW, scene); /* is NC_SCENE needed ? */
 
        return OPERATOR_FINISHED;
@@ -1394,7 +1401,7 @@ void OBJECT_OT_convert(wmOperatorType *ot)
 
 /* used below, assumes id.new is correct */
 /* leaves selection of base/object unaltered */
-static Base *object_add_duplicate_internal(Scene *scene, Base *base, int dupflag)
+static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base, int dupflag)
 {
        Base *basen= NULL;
        Material ***matarar;
@@ -1417,7 +1424,7 @@ static Base *object_add_duplicate_internal(Scene *scene, Base *base, int dupflag
                
                if(basen->flag & OB_FROMGROUP) {
                        Group *group;
-                       for(group= G.main->group.first; group; group= group->id.next) {
+                       for(group= bmain->group.first; group; group= group->id.next) {
                                if(object_in_group(ob, group))
                                        add_to_group(group, obn, scene, basen);
                        }
@@ -1596,7 +1603,7 @@ static Base *object_add_duplicate_internal(Scene *scene, Base *base, int dupflag
 
 /* single object duplicate, if dupflag==0, fully linked, else it uses the flags given */
 /* leaves selection of base/object unaltered */
-Base *ED_object_add_duplicate(Scene *scene, Base *base, int dupflag)
+Base *ED_object_add_duplicate(Main *bmain, Scene *scene, Base *base, int dupflag)
 {
        Base *basen;
        Object *ob;
@@ -1604,15 +1611,15 @@ Base *ED_object_add_duplicate(Scene *scene, Base *base, int dupflag)
        clear_id_newpoins();
        clear_sca_new_poins();  /* sensor/contr/act */
 
-       basen= object_add_duplicate_internal(scene, base, dupflag);
+       basen= object_add_duplicate_internal(bmain, scene, base, dupflag);
        if (basen == NULL) {
                return NULL;
        }
 
        ob= basen->object;
 
-       DAG_scene_sort(scene);
-       ED_render_id_flush_update(G.main, ob->data);
+       DAG_scene_sort(bmain, scene);
+       ED_render_id_flush_update(bmain, ob->data);
 
        return basen;
 }
@@ -1620,6 +1627,7 @@ Base *ED_object_add_duplicate(Scene *scene, Base *base, int dupflag)
 /* contextual operator dupli */
 static int duplicate_exec(bContext *C, wmOperator *op)
 {
+       Main *bmain= CTX_data_main(C);
        Scene *scene= CTX_data_scene(C);
        int linked= RNA_boolean_get(op->ptr, "linked");
        int dupflag= (linked)? 0: U.dupflag;
@@ -1628,7 +1636,7 @@ static int duplicate_exec(bContext *C, wmOperator *op)
        clear_sca_new_poins();  /* sensor/contr/act */
        
        CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) {
-               Base *basen= object_add_duplicate_internal(scene, base, dupflag);
+               Base *basen= object_add_duplicate_internal(bmain, scene, base, dupflag);
                
                /* note that this is safe to do with this context iterator,
                   the list is made in advance */
@@ -1642,14 +1650,14 @@ static int duplicate_exec(bContext *C, wmOperator *op)
                if(BASACT==base)
                        ED_base_object_activate(C, basen);
                
-               ED_render_id_flush_update(G.main, basen->object->data);
+               ED_render_id_flush_update(bmain, basen->object->data);
        }
        CTX_DATA_END;
 
        copy_object_set_idnew(C, dupflag);
 
-       DAG_scene_sort(scene);
-       DAG_ids_flush_update(0);
+       DAG_scene_sort(bmain, scene);
+       DAG_ids_flush_update(bmain, 0);
 
        WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene);
 
@@ -1697,6 +1705,7 @@ static int add_named_poll(bContext *C)
 
 static int add_named_exec(bContext *C, wmOperator *op)
 {
+       Main *bmain= CTX_data_main(C);
        Scene *scene= CTX_data_scene(C);
        Base *basen, *base;
        Object *ob;
@@ -1718,7 +1727,7 @@ static int add_named_exec(bContext *C, wmOperator *op)
        clear_id_newpoins();
        clear_sca_new_poins();  /* sensor/contr/act */
 
-       basen= object_add_duplicate_internal(scene, base, dupflag);
+       basen= object_add_duplicate_internal(bmain, scene, base, dupflag);
 
        if (basen == NULL) {
                MEM_freeN(base);
@@ -1732,8 +1741,8 @@ static int add_named_exec(bContext *C, wmOperator *op)
 
        copy_object_set_idnew(C, dupflag);
 
-       DAG_scene_sort(scene);
-       DAG_ids_flush_update(0);
+       DAG_scene_sort(bmain, scene);
+       DAG_ids_flush_update(bmain, 0);
 
        MEM_freeN(base);
 
index 9f9d41147b6179fb27ccf347f9747e3f3778a429..6261c33a6f7db8e53297135a1c3b359eb1bb0995 100644 (file)
@@ -94,6 +94,7 @@ static ScrArea *biggest_image_area(bScreen *screen)
 
 typedef struct BakeRender {
        Render *re;
+       Main *main;
        Scene *scene;
        struct Object *actob;
        int tot, ready;
@@ -139,6 +140,7 @@ static void init_bake_internal(BakeRender *bkr, bContext *C)
        Scene *scene= CTX_data_scene(C);
 
        bkr->sa= biggest_image_area(CTX_wm_screen(C)); /* can be NULL */
+       bkr->main= CTX_data_main(C);
        bkr->scene= scene;
        bkr->actob= (scene->r.bake_flag & R_BAKE_TO_ACTIVE) ? OBACT : NULL;
        bkr->re= RE_NewRender("_Bake View_");
@@ -196,6 +198,7 @@ static void bake_startjob(void *bkv, short *stop, short *do_update, float *progr
 {
        BakeRender *bkr= bkv;
        Scene *scene= bkr->scene;
+       Main *bmain= bkr->main;
 
        bkr->stop= stop;
        bkr->do_update= do_update;
@@ -204,7 +207,7 @@ static void bake_startjob(void *bkv, short *stop, short *do_update, float *progr
        RE_test_break_cb(bkr->re, NULL, thread_break);
        G.afbreek= 0;   /* blender_test_break uses this global */
 
-       RE_Database_Baking(bkr->re, scene, scene->lay, scene->r.bake_mode, bkr->actob);
+       RE_Database_Baking(bkr->re, bmain, scene, scene->lay, scene->r.bake_mode, bkr->actob);
 
        /* baking itself is threaded, cannot use test_break in threads. we also update optional imagewindow */
        bkr->tot= RE_bake_shade_all_selected(bkr->re, scene->r.bake_mode, bkr->actob, bkr->do_update, bkr->progress);
@@ -284,6 +287,7 @@ static int objects_bake_render_invoke(bContext *C, wmOperator *op, wmEvent *_eve
 
 static int bake_image_exec(bContext *C, wmOperator *op)
 {
+       Main *bmain= CTX_data_main(C);
        Scene *scene= CTX_data_scene(C);
 
 
@@ -302,7 +306,7 @@ static int bake_image_exec(bContext *C, wmOperator *op)
                RE_test_break_cb(bkr.re, NULL, thread_break);
                G.afbreek= 0;   /* blender_test_break uses this global */
 
-               RE_Database_Baking(bkr.re, scene, scene->lay, scene->r.bake_mode, (scene->r.bake_flag & R_BAKE_TO_ACTIVE)? OBACT: NULL);
+               RE_Database_Baking(bkr.re, bmain, scene, scene->lay, scene->r.bake_mode, (scene->r.bake_flag & R_BAKE_TO_ACTIVE)? OBACT: NULL);
 
                /* baking itself is threaded, cannot use test_break in threads  */
                BLI_init_threads(&threads, do_bake_render, 1);
index b1dc41531ef7eb8b67ce998d4569073d904971fd..8f83a412c961d112d0dd34ca6c850c24d5f9727f 100644 (file)
@@ -779,12 +779,12 @@ void ED_object_constraint_update(Object *ob)
        else DAG_id_flush_update(&ob->id, OB_RECALC_OB);
 }
 
-void ED_object_constraint_dependency_update(Scene *scene, Object *ob)
+void ED_object_constraint_dependency_update(Main *bmain, Scene *scene, Object *ob)
 {
        ED_object_constraint_update(ob);
 
        if(ob->pose) ob->pose->flag |= POSE_RECALC;     // checks & sorts pose channels
-       DAG_scene_sort(scene);
+       DAG_scene_sort(bmain, scene);
 }
 
 static int constraint_poll(bContext *C)
@@ -931,8 +931,9 @@ void CONSTRAINT_OT_move_up (wmOperatorType *ot)
 
 static int pose_constraints_clear_exec(bContext *C, wmOperator *op)
 {
-       Object *ob= CTX_data_active_object(C);
+       Main *bmain= CTX_data_main(C);
        Scene *scene= CTX_data_scene(C);
+       Object *ob= CTX_data_active_object(C);
        
        /* free constraints for all selected bones */
        CTX_DATA_BEGIN(C, bPoseChannel*, pchan, selected_pose_bones)
@@ -943,7 +944,7 @@ static int pose_constraints_clear_exec(bContext *C, wmOperator *op)
        CTX_DATA_END;
        
        /* force depsgraph to get recalculated since relationships removed */
-       DAG_scene_sort(scene);          /* sort order of objects */     
+       DAG_scene_sort(bmain, scene);           /* sort order of objects */     
        
        /* do updates */
        DAG_id_flush_update(&ob->id, OB_RECALC_DATA);
@@ -967,6 +968,7 @@ void POSE_OT_constraints_clear(wmOperatorType *ot)
 
 static int object_constraints_clear_exec(bContext *C, wmOperator *op)
 {
+       Main *bmain= CTX_data_main(C);
        Scene *scene= CTX_data_scene(C);
        
        /* do freeing */
@@ -978,7 +980,7 @@ static int object_constraints_clear_exec(bContext *C, wmOperator *op)
        CTX_DATA_END;
        
        /* force depsgraph to get recalculated since relationships removed */
-       DAG_scene_sort(scene);          /* sort order of objects */     
+       DAG_scene_sort(bmain, scene);           /* sort order of objects */     
        
        /* do updates */
        WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT, NULL);
@@ -1002,8 +1004,9 @@ void OBJECT_OT_constraints_clear(wmOperatorType *ot)
 
 static int pose_constraint_copy_exec(bContext *C, wmOperator *op)
 {
-       bPoseChannel *pchan = CTX_data_active_pose_bone(C);
+       Main *bmain= CTX_data_main(C);
        Scene *scene = CTX_data_scene(C);
+       bPoseChannel *pchan = CTX_data_active_pose_bone(C);
        
        /* don't do anything if bone doesn't exist or doesn't have any constraints */
        if (ELEM(NULL, pchan, pchan->constraints.first)) {
@@ -1021,7 +1024,7 @@ static int pose_constraint_copy_exec(bContext *C, wmOperator *op)
        CTX_DATA_END;
        
        /* force depsgraph to get recalculated since new relationships added */
-       DAG_scene_sort(scene);          /* sort order of objects/bones */
+       DAG_scene_sort(bmain, scene);           /* sort order of objects/bones */
 
        return OPERATOR_FINISHED;
 }
@@ -1043,8 +1046,9 @@ void POSE_OT_constraints_copy(wmOperatorType *ot)
 
 static int object_constraint_copy_exec(bContext *C, wmOperator *op)
 {
-       Object *obact = ED_object_active_context(C);
+       Main *bmain= CTX_data_main(C);
        Scene *scene = CTX_data_scene(C);
+       Object *obact = ED_object_active_context(C);
        
        /* copy all constraints from active object to all selected objects */
        CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) 
@@ -1056,7 +1060,7 @@ static int object_constraint_copy_exec(bContext *C, wmOperator *op)
        CTX_DATA_END;
        
        /* force depsgraph to get recalculated since new relationships added */
-       DAG_scene_sort(scene);          /* sort order of objects */
+       DAG_scene_sort(bmain, scene);           /* sort order of objects */
 
        return OPERATOR_FINISHED;
 }
@@ -1219,6 +1223,7 @@ static short get_new_constraint_target(bContext *C, int con_type, Object **tar_o
 /* used by add constraint operators to add the constraint required */
 static int constraint_add_exec(bContext *C, wmOperator *op, Object *ob, ListBase *list, int type, short setTarget)
 {
+       Main *bmain= CTX_data_main(C);
        Scene *scene= CTX_data_scene(C);
        bPoseChannel *pchan;
        bConstraint *con;
@@ -1316,7 +1321,7 @@ static int constraint_add_exec(bContext *C, wmOperator *op, Object *ob, ListBase
        
        
        /* force depsgraph to get recalculated since new relationships added */
-       DAG_scene_sort(scene);          /* sort order of objects */
+       DAG_scene_sort(bmain, scene);           /* sort order of objects */
        
        if ((ob->type==OB_ARMATURE) && (pchan)) {
                ob->pose->flag |= POSE_RECALC;  /* sort pose channels */
index 0d3ebc7f6693acadec743c2983c23808dc8d06e1..18da264336e08e9a5ece2c4189763e08f738293a 100644 (file)
@@ -137,6 +137,7 @@ Object *ED_object_active_context(bContext *C)
 /* ********* clear/set restrict view *********/
 static int object_hide_view_clear_exec(bContext *C, wmOperator *op)
 {
+       Main *bmain= CTX_data_main(C);
        ScrArea *sa= CTX_wm_area(C);
        View3D *v3d= sa->spacedata.first;
        Scene *scene= CTX_data_scene(C);
@@ -153,7 +154,7 @@ static int object_hide_view_clear_exec(bContext *C, wmOperator *op)
                }
        }
        if (changed) {
-               DAG_scene_sort(scene);
+               DAG_scene_sort(bmain, scene);
                WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene);
        }
 
@@ -178,6 +179,7 @@ void OBJECT_OT_hide_view_clear(wmOperatorType *ot)
 
 static int object_hide_view_set_exec(bContext *C, wmOperator *op)
 {
+       Main *bmain= CTX_data_main(C);
        Scene *scene= CTX_data_scene(C);
        short changed = 0;
        int unselected= RNA_boolean_get(op->ptr, "unselected");
@@ -204,7 +206,7 @@ static int object_hide_view_set_exec(bContext *C, wmOperator *op)
        CTX_DATA_END;
 
        if (changed) {
-               DAG_scene_sort(scene);
+               DAG_scene_sort(bmain, scene);
                
                WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, CTX_data_scene(C));
                
@@ -965,144 +967,6 @@ void special_editmenu(Scene *scene, View3D *v3d)
 
 }
 
-/* Change subdivision or particle properties of mesh object ob, if level==-1
- * then toggle subsurf, else set to level set allows to toggle multiple
- * selections */
-
-static void object_has_subdivision_particles(Object *ob, int *havesubdiv, int *havepart, int depth)
-{
-       if(ob->type==OB_MESH) {
-               if(modifiers_findByType(ob, eModifierType_Subsurf))
-                       *havesubdiv= 1;
-               if(modifiers_findByType(ob, eModifierType_ParticleSystem))
-                       *havepart= 1;
-       }
-
-       if(ob->dup_group && depth <= 4) {
-               GroupObject *go;
-
-               for(go= ob->dup_group->gobject.first; go; go= go->next)
-                       object_has_subdivision_particles(go->ob, havesubdiv, havepart, depth+1);
-       }
-}
-
-static void object_flip_subdivison_particles(Scene *scene, Object *ob, int *set, int level, int mode, int particles, int depth)
-{
-       ModifierData *md;
-
-       if(ob->type==OB_MESH) {
-               if(particles) {
-                       for(md=ob->modifiers.first; md; md=md->next) {
-                               if(md->type == eModifierType_ParticleSystem) {
-                                       ParticleSystemModifierData *psmd = (ParticleSystemModifierData*)md;
-
-                                       if(*set == -1)
-                                               *set= psmd->modifier.mode&(mode);
-
-                                       if (*set)
-                                               psmd->modifier.mode &= ~(mode);
-                                       else
-                                               psmd->modifier.mode |= (mode);
-                               }
-                       }
-               }
-               else {
-                       md = modifiers_findByType(ob, eModifierType_Subsurf);
-
-                       if (md) {
-                               SubsurfModifierData *smd = (SubsurfModifierData*) md;
-
-                               if (level == -1) {
-                                       if(*set == -1) 
-                                               *set= smd->modifier.mode&(mode);
-
-                                       if (*set)
-                                               smd->modifier.mode &= ~(mode);
-                                       else
-                                               smd->modifier.mode |= (mode);
-                               } else {
-                                       smd->levels = level;
-                               }
-                       } 
-                       else if(depth == 0 && *set != 0) {
-                               SubsurfModifierData *smd = (SubsurfModifierData*) modifier_new(eModifierType_Subsurf);
-                               
-                               BLI_addtail(&ob->modifiers, smd);
-                               modifier_unique_name(&ob->modifiers, (ModifierData*)smd);
-                               
-                               if (level!=-1) {
-                                       smd->levels = level;
-                               }
-                               
-                               if(*set == -1)
-                                       *set= 1;
-                       }
-               }
-
-               DAG_id_flush_update(&ob->id, OB_RECALC_DATA);
-       }
-
-       if(ob->dup_group && depth<=4) {
-               GroupObject *go;
-
-               for(go= ob->dup_group->gobject.first; go; go= go->next)
-                       object_flip_subdivison_particles(scene, go->ob, set, level, mode, particles, depth+1);
-       }
-}
-
-/* Change subdivision properties of mesh object ob, if
-* level==-1 then toggle subsurf, else set to level.
-*/
-
-void flip_subdivison(Scene *scene, View3D *v3d, int level)
-{
-       Base *base;
-       int set= -1;
-       int mode, pupmode, particles= 0, havesubdiv= 0, havepart= 0;
-       int alt= 0; // XXX
-       
-       if(alt)
-               mode= eModifierMode_Realtime;
-       else
-               mode= eModifierMode_Render|eModifierMode_Realtime;
-       
-       if(level == -1) {
-               if (scene->obedit) { // XXX get from context
-                       object_has_subdivision_particles(scene->obedit, &havesubdiv, &havepart, 0);                     
-               } else {
-                       for(base= scene->base.first; base; base= base->next) {
-                               if(((level==-1) && (TESTBASE(v3d, base))) || (TESTBASELIB(v3d, base))) {
-                                       object_has_subdivision_particles(base->object, &havesubdiv, &havepart, 0);
-                               }
-                       }
-               }
-       }
-       else
-               havesubdiv= 1;
-       
-       if(havesubdiv && havepart) {
-               pupmode= pupmenu("Switch%t|Subsurf %x1|Particle Systems %x2");
-               if(pupmode <= 0)
-                       return;
-               else if(pupmode == 2)
-                       particles= 1;
-       }
-       else if(havepart)
-               particles= 1;
-
-       if (scene->obedit) {     // XXX get from context
-               object_flip_subdivison_particles(scene, scene->obedit, &set, level, mode, particles, 0);
-       } else {
-               for(base= scene->base.first; base; base= base->next) {
-                       if(((level==-1) && (TESTBASE(v3d, base))) || (TESTBASELIB(v3d, base))) {
-                               object_flip_subdivison_particles(scene, base->object, &set, level, mode, particles, 0);
-                       }
-               }
-       }
-       
-       DAG_ids_flush_update(0);
-}
 static void copymenu_properties(Scene *scene, View3D *v3d, Object *ob)
 {      
 //XXX no longer used - to be removed - replaced by game_properties_copy_exec
@@ -1197,7 +1061,7 @@ static void copymenu_logicbricks(Scene *scene, View3D *v3d, Object *ob)
        }
 }
 
-static void copymenu_modifiers(Scene *scene, View3D *v3d, Object *ob)
+static void copymenu_modifiers(Main *bmain, Scene *scene, View3D *v3d, Object *ob)
 {
        Base *base;
        int i, event;
@@ -1296,7 +1160,7 @@ static void copymenu_modifiers(Scene *scene, View3D *v3d, Object *ob)
        
 //     if(errorstr) notice(errorstr);
        
-       DAG_scene_sort(scene);
+       DAG_scene_sort(bmain, scene);
        
 }
 
@@ -1344,7 +1208,7 @@ static void copy_texture_space(Object *to, Object *ob)
        
 }
 
-void copy_attr(Scene *scene, View3D *v3d, short event)
+void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event)
 {
        Object *ob;
        Base *base;
@@ -1369,7 +1233,7 @@ void copy_attr(Scene *scene, View3D *v3d, short event)
                return;
        }
        else if(event==24) {
-               copymenu_modifiers(scene, v3d, ob);
+               copymenu_modifiers(bmain, scene, v3d, ob);
                return;
        }
 
@@ -1587,12 +1451,12 @@ void copy_attr(Scene *scene, View3D *v3d, short event)
        }
        
        if(do_scene_sort)
-               DAG_scene_sort(scene);
+               DAG_scene_sort(bmain, scene);
 
-       DAG_ids_flush_update(0);
+       DAG_ids_flush_update(bmain, 0);
 }
 
-void copy_attr_menu(Scene *scene, View3D *v3d)
+void copy_attr_menu(Main *bmain, Scene *scene, View3D *v3d)
 {
        Object *ob;
        short event;
@@ -1643,7 +1507,7 @@ void copy_attr_menu(Scene *scene, View3D *v3d)
        event= pupmenu(str);
        if(event<= 0) return;
        
-       copy_attr(scene, v3d, event);
+       copy_attr(bmain, scene, v3d, event);
 }
 
 /* ********************************************** */
index ba609bd9bb3bcfc456cb576df16006756b45698b..b0a6c6471a2628da125401347c2017407527b48c 100644 (file)
@@ -60,6 +60,7 @@
 
 static int objects_add_active_exec(bContext *C, wmOperator *op)
 {
+       Main *bmain= CTX_data_main(C);
        Scene *scene= CTX_data_scene(C);
        Object *ob= OBACT;
        Group *group;
@@ -70,7 +71,7 @@ static int objects_add_active_exec(bContext *C, wmOperator *op)
        /* linking to same group requires its own loop so we can avoid
           looking up the active objects groups each time */
 
-       for(group= G.main->group.first; group; group=group->id.next) {
+       for(group= bmain->group.first; group; group=group->id.next) {
                if(object_in_group(ob, group)) {
                        /* Assign groups to selected objects */
                        CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) {
@@ -83,7 +84,7 @@ static int objects_add_active_exec(bContext *C, wmOperator *op)
        
        if(!ok) BKE_report(op->reports, RPT_ERROR, "Active Object contains no groups");
        
-       DAG_scene_sort(scene);
+       DAG_scene_sort(bmain, scene);
        WM_event_add_notifier(C, NC_GROUP|NA_EDITED, NULL);
        
        return OPERATOR_FINISHED;
@@ -106,6 +107,7 @@ void GROUP_OT_objects_add_active(wmOperatorType *ot)
 
 static int objects_remove_active_exec(bContext *C, wmOperator *op)
 {
+       Main *bmain= CTX_data_main(C);
        Scene *scene= CTX_data_scene(C);
        Object *ob= OBACT;
        Group *group;
@@ -116,7 +118,7 @@ static int objects_remove_active_exec(bContext *C, wmOperator *op)
        /* linking to same group requires its own loop so we can avoid
           looking up the active objects groups each time */
 
-       for(group= G.main->group.first; group; group=group->id.next) {
+       for(group= bmain->group.first; group; group=group->id.next) {
                if(object_in_group(ob, group)) {
                        /* Assign groups to selected objects */
                        CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) {
@@ -129,7 +131,7 @@ static int objects_remove_active_exec(bContext *C, wmOperator *op)
        
        if(!ok) BKE_report(op->reports, RPT_ERROR, "Active Object contains no groups");
        
-       DAG_scene_sort(scene);
+       DAG_scene_sort(bmain, scene);
        WM_event_add_notifier(C, NC_GROUP|NA_EDITED, NULL);
        
        return OPERATOR_FINISHED;
@@ -152,6 +154,7 @@ void GROUP_OT_objects_remove_active(wmOperatorType *ot)
 
 static int group_objects_remove_exec(bContext *C, wmOperator *op)
 {
+       Main *bmain= CTX_data_main(C);
        Scene *scene= CTX_data_scene(C);
        Group *group= NULL;
 
@@ -162,7 +165,7 @@ static int group_objects_remove_exec(bContext *C, wmOperator *op)
        }
        CTX_DATA_END;
 
-       DAG_scene_sort(scene);
+       DAG_scene_sort(bmain, scene);
        WM_event_add_notifier(C, NC_GROUP|NA_EDITED, NULL);
        
        return OPERATOR_FINISHED;
@@ -185,6 +188,7 @@ void GROUP_OT_objects_remove(wmOperatorType *ot)
 
 static int group_create_exec(bContext *C, wmOperator *op)
 {
+       Main *bmain= CTX_data_main(C);
        Scene *scene= CTX_data_scene(C);
        Group *group= NULL;
        char name[32]; /* id name */
@@ -198,7 +202,7 @@ static int group_create_exec(bContext *C, wmOperator *op)
        }
        CTX_DATA_END;
 
-       DAG_scene_sort(scene);
+       DAG_scene_sort(bmain, scene);
        WM_event_add_notifier(C, NC_GROUP|NA_EDITED, NULL);
        
        return OPERATOR_FINISHED;
index 88e463039a18b9033ade48967f64597237de9869..fefefae586c84d0d71fb1a559c6927b4b2989127 100644 (file)
@@ -45,6 +45,7 @@
 #include "BKE_context.h"
 #include "BKE_customdata.h"
 #include "BKE_depsgraph.h"
+#include "BKE_main.h"
 #include "BKE_mesh.h"
 #include "BKE_modifier.h"
 #include "BKE_object.h"
@@ -413,7 +414,7 @@ static Object *add_hook_object_new(Scene *scene, Object *obedit)
        return ob;
 }
 
-static void add_hook_object(Scene *scene, Object *obedit, Object *ob, int mode)
+static void add_hook_object(Main *bmain, Scene *scene, Object *obedit, Object *ob, int mode)
 {
        ModifierData *md=NULL;
        HookModifierData *hmd = NULL;
@@ -459,11 +460,12 @@ static void add_hook_object(Scene *scene, Object *obedit, Object *ob, int mode)
        mul_serie_m4(hmd->parentinv, ob->imat, obedit->obmat, NULL, 
                                 NULL, NULL, NULL, NULL, NULL);
        
-       DAG_scene_sort(scene);
+       DAG_scene_sort(bmain, scene);
 }
 
 static int object_add_hook_selob_exec(bContext *C, wmOperator *op)
 {
+       Main *bmain= CTX_data_main(C);
        Scene *scene= CTX_data_scene(C);
        Object *obedit = CTX_data_edit_object(C);
        Object *obsel=NULL;
@@ -482,7 +484,7 @@ static int object_add_hook_selob_exec(bContext *C, wmOperator *op)
                return OPERATOR_CANCELLED;
        }
        
-       add_hook_object(scene, obedit, obsel, OBJECT_ADDHOOK_SELOB);
+       add_hook_object(bmain, scene, obedit, obsel, OBJECT_ADDHOOK_SELOB);
        
        WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, obedit);
        return OPERATOR_FINISHED;
@@ -505,10 +507,11 @@ void OBJECT_OT_hook_add_selobj(wmOperatorType *ot)
 
 static int object_add_hook_newob_exec(bContext *C, wmOperator *op)
 {
+       Main *bmain= CTX_data_main(C);
        Scene *scene= CTX_data_scene(C);
        Object *obedit = CTX_data_edit_object(C);
 
-       add_hook_object(scene, obedit, NULL, OBJECT_ADDHOOK_NEWOB);
+       add_hook_object(bmain, scene, obedit, NULL, OBJECT_ADDHOOK_NEWOB);
        
        WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene);
        WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, obedit);
index 0661b675668d6e259846b69f20d867208d2207c1..a54ed9bd239d459da8e155463d93c14645dfeaec 100644 (file)
@@ -53,6 +53,7 @@
 #include "BKE_global.h"
 #include "BKE_key.h"
 #include "BKE_lattice.h"
+#include "BKE_main.h"
 #include "BKE_mesh.h"
 #include "BKE_modifier.h"
 #include "BKE_multires.h"
@@ -77,7 +78,7 @@
 
 /******************************** API ****************************/
 
-ModifierData *ED_object_modifier_add(ReportList *reports, Scene *scene, Object *ob, char *name, int type)
+ModifierData *ED_object_modifier_add(ReportList *reports, Main *bmain, Scene *scene, Object *ob, char *name, int type)
 {
        ModifierData *md=NULL, *new_md=NULL;
        ModifierTypeInfo *mti = modifierType_getInfo(type);
@@ -129,10 +130,10 @@ ModifierData *ED_object_modifier_add(ReportList *reports, Scene *scene, Object *
                                ob->pd= object_add_collision_fields(0);
                        
                        ob->pd->deflect= 1;
-                       DAG_scene_sort(scene);
+                       DAG_scene_sort(bmain, scene);
                }
                else if(type == eModifierType_Surface)
-                       DAG_scene_sort(scene);
+                       DAG_scene_sort(bmain, scene);
        }
 
        DAG_id_flush_update(&ob->id, OB_RECALC_DATA);
@@ -140,7 +141,7 @@ ModifierData *ED_object_modifier_add(ReportList *reports, Scene *scene, Object *
        return new_md;
 }
 
-int ED_object_modifier_remove(ReportList *reports, Scene *scene, Object *ob, ModifierData *md)
+int ED_object_modifier_remove(ReportList *reports, Main *bmain, Scene *scene, Object *ob, ModifierData *md)
 {
        ModifierData *obmd;
 
@@ -175,13 +176,13 @@ int ED_object_modifier_remove(ReportList *reports, Scene *scene, Object *ob, Mod
                if(ob->pd)
                        ob->pd->deflect= 0;
 
-               DAG_scene_sort(scene);
+               DAG_scene_sort(bmain, scene);
        }
        else if(md->type == eModifierType_Surface) {
                if(ob->pd && ob->pd->shape == PFIELD_SHAPE_SURFACE)
                        ob->pd->shape = PFIELD_SHAPE_PLANE;
 
-               DAG_scene_sort(scene);
+               DAG_scene_sort(bmain, scene);
        }
        else if(md->type == eModifierType_Smoke) {
                ob->dt = OB_TEXTURE;
@@ -243,7 +244,7 @@ int ED_object_modifier_move_down(ReportList *reports, Object *ob, ModifierData *
        return 1;
 }
 
-int ED_object_modifier_convert(ReportList *reports, Scene *scene, Object *ob, ModifierData *md)
+int ED_object_modifier_convert(ReportList *reports, Main *bmain, Scene *scene, Object *ob, ModifierData *md)
 {
        Object *obn;
        ParticleSystem *psys;
@@ -341,7 +342,7 @@ int ED_object_modifier_convert(ReportList *reports, Scene *scene, Object *ob, Mo
                }
        }
 
-       DAG_scene_sort(scene);
+       DAG_scene_sort(bmain, scene);
 
        return 1;
 }
@@ -500,11 +501,12 @@ int ED_object_modifier_copy(ReportList *reports, Object *ob, ModifierData *md)
 
 static int modifier_add_exec(bContext *C, wmOperator *op)
 {
+       Main *bmain= CTX_data_main(C);
        Scene *scene= CTX_data_scene(C);
        Object *ob = ED_object_active_context(C);
        int type= RNA_enum_get(op->ptr, "type");
 
-       if(!ED_object_modifier_add(op->reports, scene, ob, NULL, type))
+       if(!ED_object_modifier_add(op->reports, bmain, scene, ob, NULL, type))
                return OPERATOR_CANCELLED;
 
        WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
@@ -626,11 +628,12 @@ static ModifierData *edit_modifier_property_get(bContext *C, wmOperator *op, Obj
 
 static int modifier_remove_exec(bContext *C, wmOperator *op)
 {
+       Main *bmain= CTX_data_main(C);
        Scene *scene= CTX_data_scene(C);
        Object *ob = ED_object_active_context(C);
        ModifierData *md = edit_modifier_property_get(C, op, ob, 0);
        
-       if(!ob || !md || !ED_object_modifier_remove(op->reports, scene, ob, md))
+       if(!ob || !md || !ED_object_modifier_remove(op->reports, bmain, scene, ob, md))
                return OPERATOR_CANCELLED;
 
        WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
@@ -792,11 +795,12 @@ void OBJECT_OT_modifier_apply(wmOperatorType *ot)
 
 static int modifier_convert_exec(bContext *C, wmOperator *op)
 {
+       Main *bmain= CTX_data_main(C);
        Scene *scene= CTX_data_scene(C);
        Object *ob = ED_object_active_context(C);
        ModifierData *md = edit_modifier_property_get(C, op, ob, 0);
        
-       if(!ob || !md || !ED_object_modifier_convert(op->reports, scene, ob, md))
+       if(!ob || !md || !ED_object_modifier_convert(op->reports, bmain, scene, ob, md))
                return OPERATOR_CANCELLED;
 
        DAG_id_flush_update(&ob->id, OB_RECALC_DATA);
index e1ea7924916490f3e788b98070c77f986991fa16..610a82d964c997f3eed27978e181c7662b2f5046 100644 (file)
@@ -364,7 +364,10 @@ void ED_keymap_object(wmKeyConfig *keyconf)
                RNA_int_set(kmi->ptr, "level", i);
        }
 
-       /* Lattice -------------------------------------------------------------------- */
+       /* ############################################################################ */
+       /* ################################ LATTICE ################################### */
+       /* ############################################################################ */
+
        keymap= WM_keymap_find(keyconf, "Lattice", 0, 0);
        keymap->poll= ED_operator_editlattice;
 
@@ -375,7 +378,7 @@ void ED_keymap_object(wmKeyConfig *keyconf)
                /* menus */
        WM_keymap_add_menu(keymap, "VIEW3D_MT_hook", HKEY, KM_PRESS, KM_CTRL, 0);
 
-       ED_object_generic_keymap(keyconf, keymap, 1);
+       ED_object_generic_keymap(keyconf, keymap, 2);
 }
 
 void ED_object_generic_keymap(struct wmKeyConfig *keyconf, struct wmKeyMap *keymap, int do_pet)
@@ -383,22 +386,31 @@ void ED_object_generic_keymap(struct wmKeyConfig *keyconf, struct wmKeyMap *keym
        wmKeyMapItem *kmi;
 
        /* used by mesh, curve & lattice only */
-       if(do_pet > 0) {
+       if(do_pet) {
                /* context ops */
                kmi = WM_keymap_add_item(keymap, "WM_OT_context_cycle_enum", OKEY, KM_PRESS, KM_SHIFT, 0);
                RNA_string_set(kmi->ptr, "data_path", "tool_settings.proportional_editing_falloff");
 
-               kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle_enum", OKEY, KM_PRESS, 0, 0);
-               RNA_string_set(kmi->ptr, "data_path", "tool_settings.proportional_editing");
-               RNA_string_set(kmi->ptr, "value_1", "DISABLED");
-               RNA_string_set(kmi->ptr, "value_2", "ENABLED");
+               // Object mode
+               if (do_pet == 1) {
+
+                       kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", OKEY, KM_PRESS, 0, 0);
+                       RNA_string_set(kmi->ptr, "data_path", "tool_settings.proportional_editing_objects");
+
+               } else { // Edit mode
 
-               /* for modes/object types that allow 'conencted' mode, add the Alt O key */
-               if (do_pet > 1) {
-                       kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle_enum", OKEY, KM_PRESS, KM_ALT, 0);
+                       kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle_enum", OKEY, KM_PRESS, 0, 0);
                        RNA_string_set(kmi->ptr, "data_path", "tool_settings.proportional_editing");
                        RNA_string_set(kmi->ptr, "value_1", "DISABLED");
-                       RNA_string_set(kmi->ptr, "value_2", "CONNECTED");
+                       RNA_string_set(kmi->ptr, "value_2", "ENABLED");
+
+                       /* for modes/object types that allow 'connected' mode, add the Alt O key */
+                       if (do_pet == 3) {
+                               kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle_enum", OKEY, KM_PRESS, KM_ALT, 0);
+                               RNA_string_set(kmi->ptr, "data_path", "tool_settings.proportional_editing");
+                               RNA_string_set(kmi->ptr, "value_1", "DISABLED");
+                               RNA_string_set(kmi->ptr, "value_2", "CONNECTED");
+                       }
                }
        }
 }
index 8d488eeabacc40b6c936e5e175757ff6afee3823..463db871f551f4bdd34f28e86e5d1d7a25f21054 100644 (file)
@@ -97,6 +97,7 @@ static int vertex_parent_set_poll(bContext *C)
 
 static int vertex_parent_set_exec(bContext *C, wmOperator *op)
 {
+       Main *bmain= CTX_data_main(C);
        Scene *scene= CTX_data_scene(C);
        Object *obedit= CTX_data_edit_object(C);
        EditVert *eve;
@@ -230,7 +231,7 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op)
        }
        CTX_DATA_END;
        
-       DAG_scene_sort(scene);
+       DAG_scene_sort(bmain, scene);
 
        WM_event_add_notifier(C, NC_OBJECT, NULL);
 
@@ -295,6 +296,7 @@ static int make_proxy_invoke (bContext *C, wmOperator *op, wmEvent *evt)
 
 static int make_proxy_exec (bContext *C, wmOperator *op)
 {
+       Main *bmain= CTX_data_main(C);
        Object *ob, *gob= CTX_data_active_object(C);
        GroupObject *go;
        Scene *scene= CTX_data_scene(C);
@@ -338,7 +340,7 @@ static int make_proxy_exec (bContext *C, wmOperator *op)
                object_make_proxy(newob, ob, gob);
                
                /* depsgraph flushes are needed for the new data */
-               DAG_scene_sort(scene);
+               DAG_scene_sort(bmain, scene);
                DAG_id_flush_update(&newob->id, OB_RECALC_ALL);
                WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, newob);
        }
@@ -413,6 +415,8 @@ static EnumPropertyItem prop_clear_parent_types[] = {
 /* note, poll should check for editable scene */
 static int parent_clear_exec(bContext *C, wmOperator *op)
 {
+       Main *bmain= CTX_data_main(C);
+       Scene *scene= CTX_data_scene(C);
        int type= RNA_enum_get(op->ptr, "type");
        
        CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) {
@@ -431,8 +435,8 @@ static int parent_clear_exec(bContext *C, wmOperator *op)
        }
        CTX_DATA_END;
        
-       DAG_scene_sort(CTX_data_scene(C));
-       DAG_ids_flush_update(0);
+       DAG_scene_sort(bmain, scene);
+       DAG_ids_flush_update(bmain, 0);
        WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL);
 
        return OPERATOR_FINISHED;
@@ -517,6 +521,7 @@ void ED_object_parent(Object *ob, Object *par, int type, const char *substr)
 
 static int parent_set_exec(bContext *C, wmOperator *op)
 {
+       Main *bmain= CTX_data_main(C);
        Scene *scene= CTX_data_scene(C);
        Object *par= CTX_data_active_object(C);
        bPoseChannel *pchan= NULL;
@@ -594,15 +599,15 @@ static int parent_set_exec(bContext *C, wmOperator *op)
 
                                                switch (partype) {
                                                case PAR_CURVE: /* curve deform */
-                                                       md= ED_object_modifier_add(op->reports, scene, ob, NULL, eModifierType_Curve);
+                                                       md= ED_object_modifier_add(op->reports, bmain, scene, ob, NULL, eModifierType_Curve);
                                                        ((CurveModifierData *)md)->object= par;
                                                        break;
                                                case PAR_LATTICE: /* lattice deform */
-                                                       md= ED_object_modifier_add(op->reports, scene, ob, NULL, eModifierType_Lattice);
+                                                       md= ED_object_modifier_add(op->reports, bmain, scene, ob, NULL, eModifierType_Lattice);
                                                        ((LatticeModifierData *)md)->object= par;
                                                        break;
                                                default: /* armature deform */
-                                                       md= ED_object_modifier_add(op->reports, scene, ob, NULL, eModifierType_Armature);
+                                                       md= ED_object_modifier_add(op->reports, bmain, scene, ob, NULL, eModifierType_Armature);
                                                        ((ArmatureModifierData *)md)->object= par;
                                                        break;
                                                }
@@ -657,8 +662,8 @@ static int parent_set_exec(bContext *C, wmOperator *op)
        }
        CTX_DATA_END;
        
-       DAG_scene_sort(scene);
-       DAG_ids_flush_update(0);
+       DAG_scene_sort(bmain, scene);
+       DAG_ids_flush_update(bmain, 0);
        WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL);
        
        return OPERATOR_FINISHED;
@@ -719,6 +724,7 @@ void OBJECT_OT_parent_set(wmOperatorType *ot)
 
 static int parent_noinv_set_exec(bContext *C, wmOperator *op)
 {
+       Main *bmain= CTX_data_main(C);
        Object *par= CTX_data_active_object(C);
        
        par->recalc |= OB_RECALC_OB;
@@ -745,8 +751,8 @@ static int parent_noinv_set_exec(bContext *C, wmOperator *op)
        }
        CTX_DATA_END;
        
-       DAG_scene_sort(CTX_data_scene(C));
-       DAG_ids_flush_update(0);
+       DAG_scene_sort(bmain, CTX_data_scene(C));
+       DAG_ids_flush_update(bmain, 0);
        WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL);
        
        return OPERATOR_FINISHED;
@@ -772,6 +778,7 @@ void OBJECT_OT_parent_no_inverse_set(wmOperatorType *ot)
 
 static int object_slow_parent_clear_exec(bContext *C, wmOperator *op)
 {
+       Main *bmain= CTX_data_main(C);
        Scene *scene= CTX_data_scene(C);
 
        CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) {
@@ -786,7 +793,7 @@ static int object_slow_parent_clear_exec(bContext *C, wmOperator *op)
        }
        CTX_DATA_END;
 
-       DAG_ids_flush_update(0);
+       DAG_ids_flush_update(bmain, 0);
        WM_event_add_notifier(C, NC_SCENE, scene);
        
        return OPERATOR_FINISHED;
@@ -813,6 +820,7 @@ void OBJECT_OT_slow_parent_clear(wmOperatorType *ot)
 
 static int object_slow_parent_set_exec(bContext *C, wmOperator *op)
 {
+       Main *bmain= CTX_data_main(C);
        Scene *scene= CTX_data_scene(C);
 
        CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) {
@@ -824,7 +832,7 @@ static int object_slow_parent_set_exec(bContext *C, wmOperator *op)
        }
        CTX_DATA_END;
 
-       DAG_ids_flush_update(0);
+       DAG_ids_flush_update(bmain, 0);
        WM_event_add_notifier(C, NC_SCENE, scene);
        
        return OPERATOR_FINISHED;
@@ -858,6 +866,8 @@ static EnumPropertyItem prop_clear_track_types[] = {
 /* note, poll should check for editable scene */
 static int object_track_clear_exec(bContext *C, wmOperator *op)
 {
+       Main *bmain= CTX_data_main(C);
+       Scene *scene= CTX_data_scene(C);
        int type= RNA_enum_get(op->ptr, "type");
 
        if(CTX_data_edit_object(C)) {
@@ -883,8 +893,8 @@ static int object_track_clear_exec(bContext *C, wmOperator *op)
        }
        CTX_DATA_END;
 
-       DAG_ids_flush_update(0);
-       DAG_scene_sort(CTX_data_scene(C));
+       DAG_ids_flush_update(bmain, 0);
+       DAG_scene_sort(bmain, scene);
        WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL);
 
        return OPERATOR_FINISHED;
@@ -920,6 +930,7 @@ static EnumPropertyItem prop_make_track_types[] = {
 
 static int track_set_exec(bContext *C, wmOperator *op)
 {
+       Main *bmain= CTX_data_main(C);
        Scene *scene= CTX_data_scene(C);
        Object *obact= CTX_data_active_object(C); 
        
@@ -987,8 +998,8 @@ static int track_set_exec(bContext *C, wmOperator *op)
                CTX_DATA_END;
        }
        
-       DAG_scene_sort(scene);
-       DAG_ids_flush_update(0);
+       DAG_scene_sort(bmain, scene);
+       DAG_ids_flush_update(bmain, 0);
        WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL);
        
        return OPERATOR_FINISHED;
@@ -1057,6 +1068,7 @@ static int move_to_layer_invoke(bContext *C, wmOperator *op, wmEvent *event)
 
 static int move_to_layer_exec(bContext *C, wmOperator *op)
 {
+       Main *bmain= CTX_data_main(C);
        Scene *scene= CTX_data_scene(C);
        View3D *v3d= CTX_wm_view3d(C);
        unsigned int lay, local;
@@ -1097,7 +1109,7 @@ static int move_to_layer_exec(bContext *C, wmOperator *op)
        /* warning, active object may be hidden now */
        
        WM_event_add_notifier(C, NC_SCENE|NC_OBJECT|ND_DRAW, scene); /* is NC_SCENE needed ? */
-       DAG_scene_sort(scene);
+       DAG_scene_sort(bmain, scene);
 
        return OPERATOR_FINISHED;
 }
@@ -1123,10 +1135,10 @@ void OBJECT_OT_move_to_layer(wmOperatorType *ot)
 
 /************************** Link to Scene Operator *****************************/
 
-void link_to_scene(unsigned short nr)
+void link_to_scene(Main *bmain, unsigned short nr)
 {
 #if 0
-       Scene *sce= (Scene*) BLI_findlink(&G.main->scene, G.curscreen->scenenr-1);
+       Scene *sce= (Scene*) BLI_findlink(&bmain->scene, G.curscreen->scenenr-1);
        Base *base, *nbase;
        
        if(sce==0) return;
@@ -1146,6 +1158,7 @@ void link_to_scene(unsigned short nr)
 
 static int make_links_scene_exec(bContext *C, wmOperator *op)
 {
+       Main *bmain= CTX_data_main(C);
        Scene *scene_to= BLI_findlink(&CTX_data_main(C)->scene, RNA_enum_get(op->ptr, "scene"));
 
        if(scene_to==NULL) {
@@ -1174,7 +1187,7 @@ static int make_links_scene_exec(bContext *C, wmOperator *op)
        }
        CTX_DATA_END;
 
-       DAG_ids_flush_update(0);
+       DAG_ids_flush_update(bmain, 0);
 
        /* one day multiple scenes will be visible, then we should have some update function for them */
        return OPERATOR_FINISHED;
@@ -1214,6 +1227,7 @@ static int allow_make_links_data(int ev, Object *ob, Object *obt)
 
 static int make_links_data_exec(bContext *C, wmOperator *op)
 {
+       Main *bmain= CTX_data_main(C);
        int event = RNA_int_get(op->ptr, "type");
        Object *ob;
        ID *id;
@@ -1266,7 +1280,7 @@ static int make_links_data_exec(bContext *C, wmOperator *op)
        }
        CTX_DATA_END;
 
-       DAG_ids_flush_update(0);
+       DAG_ids_flush_update(bmain, 0);
        WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, CTX_wm_view3d(C));
        return OPERATOR_FINISHED;
 }
@@ -1396,7 +1410,7 @@ void new_id_matar(Material **matar, int totcol)
        }
 }
 
-void single_obdata_users(Scene *scene, int flag)
+void single_obdata_users(Main *bmain, Scene *scene, int flag)
 {
        Object *ob;
        Lamp *la;
@@ -1512,7 +1526,7 @@ void single_obdata_users(Scene *scene, int flag)
                }
        }
        
-       me= G.main->mesh.first;
+       me= bmain->mesh.first;
        while(me) {
                ID_NEW(me->texcomesh);
                me= me->id.next;
@@ -1610,10 +1624,9 @@ void do_single_tex_user(Tex **from)
        }
 }
 
-void single_tex_users_expand()
+void single_tex_users_expand(Main *bmain)
 {
        /* only when 'parent' blocks are LIB_NEW */
-       Main *bmain= G.main;
        Material *ma;
        Lamp *la;
        World *wo;
@@ -1650,10 +1663,9 @@ void single_tex_users_expand()
        }
 }
 
-static void single_mat_users_expand(void)
+static void single_mat_users_expand(Main *bmain)
 {
        /* only when 'parent' blocks are LIB_NEW */
-       Main *bmain= G.main;
        Object *ob;
        Mesh *me;
        Curve *cu;
@@ -1686,14 +1698,14 @@ static void single_mat_users_expand(void)
 }
 
 /* used for copying scenes */
-void ED_object_single_users(Scene *scene, int full)
+void ED_object_single_users(Main *bmain, Scene *scene, int full)
 {
        single_object_users(scene, NULL, 0);
 
        if(full) {
-               single_obdata_users(scene, 0);
-               single_mat_users_expand();
-               single_tex_users_expand();
+               single_obdata_users(bmain, scene, 0);
+               single_mat_users_expand(bmain);
+               single_tex_users_expand(bmain);
        }
 
        clear_id_newpoins();
@@ -1828,6 +1840,7 @@ void OBJECT_OT_make_local(wmOperatorType *ot)
 
 static int make_single_user_exec(bContext *C, wmOperator *op)
 {
+       Main *bmain= CTX_data_main(C);
        Scene *scene= CTX_data_scene(C);
        View3D *v3d= CTX_wm_view3d(C); /* ok if this is NULL */
        int flag= RNA_enum_get(op->ptr, "type"); /* 0==ALL, SELECTED==selected objecs */
@@ -1836,7 +1849,7 @@ static int make_single_user_exec(bContext *C, wmOperator *op)
                single_object_users(scene, v3d, flag);
 
        if(RNA_boolean_get(op->ptr, "obdata"))
-               single_obdata_users(scene, flag);
+               single_obdata_users(bmain, scene, flag);
 
        if(RNA_boolean_get(op->ptr, "material"))
                single_mat_users(scene, flag, FALSE);
@@ -1885,6 +1898,7 @@ void OBJECT_OT_make_single_user(wmOperatorType *ot)
 
 static int drop_named_material_invoke(bContext *C, wmOperator *op, wmEvent *event)
 {
+       Main *bmain= CTX_data_main(C);
        Base *base= ED_view3d_give_base_under_cursor(C, event->mval);
        Material *ma;
        char name[32];
@@ -1896,7 +1910,7 @@ static int drop_named_material_invoke(bContext *C, wmOperator *op, wmEvent *even
        
        assign_material(base->object, ma, 1);
        
-       DAG_ids_flush_update(0);
+       DAG_ids_flush_update(bmain, 0);
        WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, CTX_wm_view3d(C));
        
        return OPERATOR_FINISHED;
index cd66b9ab2ba1b085184672efeae94d2803fdd03c..d7961a8cd2bb8c22d180c0a239843f2bdd0f64df 100644 (file)
@@ -68,6 +68,7 @@
 
 static int object_location_clear_exec(bContext *C, wmOperator *op)
 {
+       Main *bmain = CTX_data_main(C);
        Scene *scene = CTX_data_scene(C);
        KeyingSet *ks= ANIM_builtin_keyingset_get_named(NULL, "Location");
        
@@ -102,7 +103,7 @@ static int object_location_clear_exec(bContext *C, wmOperator *op)
        CTX_DATA_END;
        
        /* this is needed so children are also updated */
-       DAG_ids_flush_update(0);
+       DAG_ids_flush_update(bmain, 0);
 
        WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL);
 
@@ -126,6 +127,7 @@ void OBJECT_OT_location_clear(wmOperatorType *ot)
 
 static int object_rotation_clear_exec(bContext *C, wmOperator *op)
 {
+       Main *bmain= CTX_data_main(C);
        Scene *scene= CTX_data_scene(C);
        KeyingSet *ks= ANIM_builtin_keyingset_get_named(NULL, "Rotation");
        
@@ -182,7 +184,7 @@ static int object_rotation_clear_exec(bContext *C, wmOperator *op)
                                                axis_angle_to_eulO( oldeul, EULER_ORDER_DEFAULT,ob->rotAxis, ob->rotAngle);
                                        }
                                        else {
-                                               VECCOPY(oldeul, ob->rot);
+                                               copy_v3_v3(oldeul, ob->rot);
                                        }
                                        
                                        eul[0]= eul[1]= eul[2]= 0.0f;
@@ -244,7 +246,7 @@ static int object_rotation_clear_exec(bContext *C, wmOperator *op)
        CTX_DATA_END;
        
        /* this is needed so children are also updated */
-       DAG_ids_flush_update(0);
+       DAG_ids_flush_update(bmain, 0);
 
        WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL);
        
@@ -268,6 +270,7 @@ void OBJECT_OT_rotation_clear(wmOperatorType *ot)
 
 static int object_scale_clear_exec(bContext *C, wmOperator *op)
 {
+       Main *bmain= CTX_data_main(C);
        Scene *scene= CTX_data_scene(C);
        KeyingSet *ks= ANIM_builtin_keyingset_get_named(NULL, "Scaling");
        
@@ -307,7 +310,7 @@ static int object_scale_clear_exec(bContext *C, wmOperator *op)
        CTX_DATA_END;
        
        /* this is needed so children are also updated */
-       DAG_ids_flush_update(0);
+       DAG_ids_flush_update(bmain, 0);
 
        WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL);
        
@@ -331,6 +334,7 @@ void OBJECT_OT_scale_clear(wmOperatorType *ot)
 
 static int object_origin_clear_exec(bContext *C, wmOperator *op)
 {
+       Main *bmain= CTX_data_main(C);
        float *v1, *v3, mat[3][3];
        int armature_clear= 0;
 
@@ -348,7 +352,7 @@ static int object_origin_clear_exec(bContext *C, wmOperator *op)
        CTX_DATA_END;
 
        if(armature_clear==0) /* in this case flush was done */
-               DAG_ids_flush_update(0);
+               DAG_ids_flush_update(bmain, 0);
        
        WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL);
        
@@ -694,294 +698,170 @@ void texspace_edit(Scene *scene, View3D *v3d)
 
 /********************* Set Object Center ************************/
 
-static EnumPropertyItem prop_set_center_types[] = {
-       {0, "GEOMETRY_ORIGIN", 0, "Geometry to Origin", "Move object geometry to object origin"},
-       {1, "ORIGIN_GEOMETRY", 0, "Origin to Geometry", "Move object origin to center of object geometry"},
-       {2, "ORIGIN_CURSOR", 0, "Origin to 3D Cursor", "Move object origin to position of the 3d cursor"},
-       {0, NULL, 0, NULL, NULL}
+enum {
+       GEOMETRY_TO_ORIGIN=0,
+       ORIGIN_TO_GEOMETRY,
+       ORIGIN_TO_CURSOR
 };
 
-/* 0 == do center, 1 == center new, 2 == center cursor */
 static int object_origin_set_exec(bContext *C, wmOperator *op)
 {
        Main *bmain= CTX_data_main(C);
        Scene *scene= CTX_data_scene(C);
-       ScrArea *sa= CTX_wm_area(C);
-       View3D *v3d= sa->spacedata.first;
        Object *obedit= CTX_data_edit_object(C);
        Object *tob;
-       Mesh *me, *tme;
-       Curve *cu;
-/*     BezTriple *bezt;
-       BPoint *bp; */
-       Nurb *nu, *nu1;
-       EditVert *eve;
-       float cent[3], centn[3], min[3], max[3], omat[3][3];
-       int a, total= 0;
+       float cursor[3], cent[3], cent_neg[3], centn[3], min[3], max[3];
        int centermode = RNA_enum_get(op->ptr, "type");
-       
+       int around = RNA_enum_get(op->ptr, "center"); /* initialized from v3d->around */
+
        /* keep track of what is changed */
        int tot_change=0, tot_lib_error=0, tot_multiuser_arm_error=0;
-       MVert *mvert;
 
-       if(scene->id.lib || v3d==NULL){
-               BKE_report(op->reports, RPT_ERROR, "Operation cannot be performed on Lib data");
-                return OPERATOR_CANCELLED;
-       }
-       if (obedit && centermode > 0) {
+       if (obedit && centermode != GEOMETRY_TO_ORIGIN) {
                BKE_report(op->reports, RPT_ERROR, "Operation cannot be performed in EditMode");
                return OPERATOR_CANCELLED;
-       }       
-       cent[0]= cent[1]= cent[2]= 0.0; 
-       
-       if(obedit) {
+       }
+       else {
+               /* get the view settings if 'around' isnt set and the view is available */
+               View3D *v3d= CTX_wm_view3d(C);
+               copy_v3_v3(cursor, give_cursor(scene, v3d));
+               if(v3d && !RNA_property_is_set(op->ptr, "around"))
+                       around= v3d->around;
+       }
+
+       zero_v3(cent);
 
+       if(obedit) {
                INIT_MINMAX(min, max);
-       
+
                if(obedit->type==OB_MESH) {
                        Mesh *me= obedit->data;
                        EditMesh *em = BKE_mesh_get_editmesh(me);
+                       EditVert *eve;
 
-                       for(eve= em->verts.first; eve; eve= eve->next) {
-                               if(v3d->around==V3D_CENTROID) {
+                       if(around==V3D_CENTROID) {
+                               int total= 0;
+                               for(eve= em->verts.first; eve; eve= eve->next) {
                                        total++;
-                                       VECADD(cent, cent, eve->co);
+                                       add_v3_v3(cent, eve->co);
                                }
-                               else {
-                                       DO_MINMAX(eve->co, min, max);
-                               }
-                       }
-                       
-                       if(v3d->around==V3D_CENTROID) {
                                mul_v3_fl(cent, 1.0f/(float)total);
                        }
                        else {
-                               cent[0]= (min[0]+max[0])/2.0f;
-                               cent[1]= (min[1]+max[1])/2.0f;
-                               cent[2]= (min[2]+max[2])/2.0f;
+                               for(eve= em->verts.first; eve; eve= eve->next) {
+                                       DO_MINMAX(eve->co, min, max);
+                               }
+                               mid_v3_v3v3(cent, min, max);
                        }
-                       
+
                        for(eve= em->verts.first; eve; eve= eve->next) {
-                               sub_v3_v3(eve->co, cent);                       
+                               sub_v3_v3(eve->co, cent);
                        }
-                       
+
                        recalc_editnormals(em);
                        tot_change++;
                        DAG_id_flush_update(&obedit->id, OB_RECALC_DATA);
                        BKE_mesh_end_editmesh(me, em);
                }
        }
-       
+
        /* reset flags */
        CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) {
                        ob->flag &= ~OB_DONE;
        }
        CTX_DATA_END;
 
-       for (tob= G.main->object.first; tob; tob= tob->id.next) {
+       for (tob= bmain->object.first; tob; tob= tob->id.next) {
                if(tob->data)
                        ((ID *)tob->data)->flag &= ~LIB_DOIT;
        }
-       
+
        CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) {
                if((ob->flag & OB_DONE)==0) {
                        ob->flag |= OB_DONE;
-                               
-                       if(obedit==NULL && (me=get_mesh(ob)) ) {
-                               if (me->id.lib) {
-                                       tot_lib_error++;
-                               } else {
-                                       if(centermode==2) {
-                                               VECCOPY(cent, give_cursor(scene, v3d));
-                                               invert_m4_m4(ob->imat, ob->obmat);
-                                               mul_m4_v3(ob->imat, cent);
-                                       } else {
-                                               INIT_MINMAX(min, max);
-                                               mvert= me->mvert;
-                                               for(a=0; a<me->totvert; a++, mvert++) {
-                                                       DO_MINMAX(mvert->co, min, max);
-                                               }
-                                       
-                                               cent[0]= (min[0]+max[0])/2.0f;
-                                               cent[1]= (min[1]+max[1])/2.0f;
-                                               cent[2]= (min[2]+max[2])/2.0f;
-                                       }
 
-                                       mvert= me->mvert;
-                                       for(a=0; a<me->totvert; a++, mvert++) {
-                                               sub_v3_v3(mvert->co, cent);
-                                       }
-                                       
-                                       if (me->key) {
-                                               KeyBlock *kb;
-                                               for (kb=me->key->block.first; kb; kb=kb->next) {
-                                                       float *fp= kb->data;
-                                                       
-                                                       for (a=0; a<kb->totelem; a++, fp+=3) {
-                                                               sub_v3_v3(fp, cent);
-                                                       }
-                                               }
-                                       }
+                       if(ob->data == NULL) {
+                               /* pass */
+                       }
+                       else if (((ID *)ob->data)->lib) {
+                               tot_lib_error++;
+                       }
 
-                                       tot_change++;
-                                       me->id.flag |= LIB_DOIT;
-                                               
-                                       if(centermode) {
-                                               copy_m3_m4(omat, ob->obmat);
-                                               
-                                               copy_v3_v3(centn, cent);
-                                               mul_m3_v3(omat, centn);
-                                               ob->loc[0]+= centn[0];
-                                               ob->loc[1]+= centn[1];
-                                               ob->loc[2]+= centn[2];
-                                               
-                                               where_is_object(scene, ob);
-                                               ignore_parent_tx(bmain, scene, ob);
-                                               
-                                               /* other users? */
-                                               CTX_DATA_BEGIN(C, Object*, ob_other, selected_editable_objects) {
-                                                       if((ob_other->flag & OB_DONE)==0) {
-                                                               tme= get_mesh(ob_other);
-                                                               
-                                                               if(tme==me) {
-                                                                       
-                                                                       ob_other->flag |= OB_DONE;
-                                                                       ob_other->recalc= OB_RECALC_OB|OB_RECALC_DATA;
-
-                                                                       copy_m3_m4(omat, ob_other->obmat);
-                                                                       copy_v3_v3(centn, cent);
-                                                                       mul_m3_v3(omat, centn);
-                                                                       ob_other->loc[0]+= centn[0];
-                                                                       ob_other->loc[1]+= centn[1];
-                                                                       ob_other->loc[2]+= centn[2];
-                                                                       
-                                                                       where_is_object(scene, ob_other);
-                                                                       ignore_parent_tx(bmain, scene, ob_other);
-                                                                       
-                                                                       if(!(tme->id.flag & LIB_DOIT)) {
-                                                                               mvert= tme->mvert;
-                                                                               for(a=0; a<tme->totvert; a++, mvert++) {
-                                                                                       sub_v3_v3(mvert->co, cent);
-                                                                               }
-                                                                               
-                                                                               if (tme->key) {
-                                                                                       KeyBlock *kb;
-                                                                                       for (kb=tme->key->block.first; kb; kb=kb->next) {
-                                                                                               float *fp= kb->data;
-                                                                                               
-                                                                                               for (a=0; a<kb->totelem; a++, fp+=3) {
-                                                                                                       sub_v3_v3(fp, cent);
-                                                                                               }
-                                                                                       }
-                                                                               }
-
-                                                                               tot_change++;
-                                                                               tme->id.flag |= LIB_DOIT;
-                                                                       }
-                                                               }
-                                                       }
-                                               }
-                                               CTX_DATA_END;
-                                       }
+                       if(obedit==NULL && ob->type==OB_MESH) {
+                               Mesh *me= ob->data;
+
+                               if(centermode == ORIGIN_TO_CURSOR) {
+                                       copy_v3_v3(cent, cursor);
+                                       invert_m4_m4(ob->imat, ob->obmat);
+                                       mul_m4_v3(ob->imat, cent);
+                               } else  {
+                                       if(around==V3D_CENTROID)
+                                               mesh_center_median(me, cent);
+                                       else
+                                               mesh_center_bounds(me, cent);
                                }
+
+                               negate_v3_v3(cent_neg, cent);
+                               mesh_translate(me, cent_neg, 1);
+
+                               tot_change++;
+                               me->id.flag |= LIB_DOIT;
                        }
                        else if (ELEM(ob->type, OB_CURVE, OB_SURF)) {
-                               
-                               /* weak code here... (ton) */
-                               if(obedit==ob) {
-                                       ListBase *editnurb= curve_get_editcurve(obedit);
+                               Curve *cu= ob->data;
 
-                                       nu1= editnurb->first;
-                                       cu= obedit->data;
+                               if(centermode == ORIGIN_TO_CURSOR) {
+                                       copy_v3_v3(cent, cursor);
+                                       invert_m4_m4(ob->imat, ob->obmat);
+                                       mul_m4_v3(ob->imat, cent);
                                }
                                else {
-                                       cu= ob->data;
-                                       nu1= cu->nurb.first;
+                                       if(around==V3D_CENTROID)
+                                               curve_center_median(cu, cent);
+                                       else
+                                               curve_center_bounds(cu, cent);
                                }
-                               
-                               if (cu->id.lib) {
-                                       tot_lib_error++;
-                               } else {
-                                       if(centermode==2) {
-                                               copy_v3_v3(cent, give_cursor(scene, v3d));
-                                               invert_m4_m4(ob->imat, ob->obmat);
-                                               mul_m4_v3(ob->imat, cent);
 
-                                               /* don't allow Z change if curve is 2D */
-                                               if( !( cu->flag & CU_3D ) )
-                                                       cent[2] = 0.0;
-                                       } 
-                                       else {
-                                               INIT_MINMAX(min, max);
-                                               
-                                               nu= nu1;
-                                               while(nu) {
-                                                       minmaxNurb(nu, min, max);
-                                                       nu= nu->next;
-                                               }
-                                               
-                                               cent[0]= (min[0]+max[0])/2.0f;
-                                               cent[1]= (min[1]+max[1])/2.0f;
-                                               cent[2]= (min[2]+max[2])/2.0f;
-                                       }
-                                       
-                                       nu= nu1;
-                                       while(nu) {
-                                               if(nu->type == CU_BEZIER) {
-                                                       a= nu->pntsu;
-                                                       while (a--) {
-                                                               sub_v3_v3(nu->bezt[a].vec[0], cent);
-                                                               sub_v3_v3(nu->bezt[a].vec[1], cent);
-                                                               sub_v3_v3(nu->bezt[a].vec[2], cent);
-                                                       }
-                                               }
-                                               else {
-                                                       a= nu->pntsu*nu->pntsv;
-                                                       while (a--)
-                                                               sub_v3_v3(nu->bp[a].vec, cent);
-                                               }
-                                               nu= nu->next;
-                                       }
-                       
-                                       if(centermode && obedit==NULL) {
-                                               copy_m3_m4(omat, ob->obmat);
-                                               
-                                               mul_m3_v3(omat, cent);
-                                               ob->loc[0]+= cent[0];
-                                               ob->loc[1]+= cent[1];
-                                               ob->loc[2]+= cent[2];
-                                               
-                                               where_is_object(scene, ob);
-                                               ignore_parent_tx(bmain, scene, ob);
-                                       }
-                                       
-                                       tot_change++;
-                                       cu->id.flag |= LIB_DOIT;
+                               /* don't allow Z change if curve is 2D */
+                               if( !( cu->flag & CU_3D ) )
+                                       cent[2] = 0.0;
 
-                                       if(obedit) {
-                                               if (centermode==0) {
-                                                       DAG_id_flush_update(&obedit->id, OB_RECALC_DATA);
-                                               }
-                                               break;
+                               negate_v3_v3(cent_neg, cent);
+                               curve_translate(cu, cent_neg, 1);
+
+                               tot_change++;
+                               cu->id.flag |= LIB_DOIT;
+
+                               if(obedit) {
+                                       if (centermode == GEOMETRY_TO_ORIGIN) {
+                                               DAG_id_flush_update(&obedit->id, OB_RECALC_DATA);
                                        }
+                                       break;
                                }
                        }
                        else if(ob->type==OB_FONT) {
                                /* get from bb */
-                               
-                               cu= ob->data;
-                               
-                               if(cu->bb==NULL) {
+
+                               Curve *cu= ob->data;
+
+                               if(cu->bb==NULL && (centermode != ORIGIN_TO_CURSOR)) {
                                        /* do nothing*/
-                               } else if (cu->id.lib) {
-                                       tot_lib_error++;
-                               } else {
-                                       cu->xof= -0.5f*( cu->bb->vec[4][0] - cu->bb->vec[0][0]);
-                                       cu->yof= -0.5f -0.5f*( cu->bb->vec[0][1] - cu->bb->vec[2][1]);  /* extra 0.5 is the height o above line */
-                                       
-                                       /* not really ok, do this better once! */
-                                       cu->xof /= cu->fsize;
-                                       cu->yof /= cu->fsize;
+                               }
+                               else {
+                                       if(centermode == ORIGIN_TO_CURSOR) {
+                                               copy_v3_v3(cent, cursor);
+                                               invert_m4_m4(ob->imat, ob->obmat);
+                                               mul_m4_v3(ob->imat, cent);
+                                       }
+                                       else {
+                                               cent[0]= 0.5f * ( cu->bb->vec[4][0] + cu->bb->vec[0][0]);
+                                               cent[1]= 0.5f * ( cu->bb->vec[0][1] + cu->bb->vec[2][1]) - 0.5f;        /* extra 0.5 is the height o above line */
+                                       }
+
+                                       cent[2]= 0.0f;
+
+                                       cu->xof= cu->xof - (cent[0] / cu->fsize);
+                                       cu->yof= cu->yof - (cent[1] / cu->fsize);
 
                                        tot_change++;
                                        cu->id.flag |= LIB_DOIT;
@@ -989,58 +869,100 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
                        }
                        else if(ob->type==OB_ARMATURE) {
                                bArmature *arm = ob->data;
-                               
-                               if (arm->id.lib) {
-                                       tot_lib_error++;
-                               } else if(ID_REAL_USERS(arm) > 1) {
+
+                               if(ID_REAL_USERS(arm) > 1) {
                                        /*BKE_report(op->reports, RPT_ERROR, "Can't apply to a multi user armature");
                                        return;*/
                                        tot_multiuser_arm_error++;
-                               } else {
-                                       /* Function to recenter armatures in editarmature.c 
+                               }
+                               else {
+                                       /* Function to recenter armatures in editarmature.c
                                         * Bone + object locations are handled there.
                                         */
-                                       docenter_armature(scene, v3d, ob, centermode);
+                                       docenter_armature(scene, ob, cursor, centermode, around);
 
                                        tot_change++;
-                                       cu->id.flag |= LIB_DOIT;
-                                       
+                                       arm->id.flag |= LIB_DOIT;
+
                                        where_is_object(scene, ob);
                                        ignore_parent_tx(bmain, scene, ob);
-                                       
-                                       if(obedit) 
+
+                                       if(obedit)
                                                break;
                                }
                        }
+
+                       /* offset other selected objects */
+                       if(centermode != GEOMETRY_TO_ORIGIN) {
+                               /* was the object data modified
+                                * note: the functions above must set 'cent' */
+                               if(ob->data && (((ID *)ob->data)->flag && LIB_DOIT) && ob->type != OB_ARMATURE) {
+                                       copy_v3_v3(centn, cent);
+                                       mul_mat3_m4_v3(ob->obmat, centn); /* ommit translation part */
+                                       add_v3_v3(ob->loc, centn);
+
+                                       where_is_object(scene, ob);
+                                       ignore_parent_tx(bmain, scene, ob);
+
+                                       /* other users? */
+                                       CTX_DATA_BEGIN(C, Object*, ob_other, selected_editable_objects) {
+                                               if((ob_other->flag & OB_DONE)==0 && (ob_other->data == ob->data)) {
+                                                       ob_other->flag |= OB_DONE;
+                                                       ob_other->recalc= OB_RECALC_OB|OB_RECALC_DATA;
+
+                                                       copy_v3_v3(centn, cent);
+                                                       mul_mat3_m4_v3(ob_other->obmat, centn); /* ommit translation part */
+                                                       add_v3_v3(ob_other->loc, centn);
+
+                                                       where_is_object(scene, ob_other);
+                                                       ignore_parent_tx(bmain, scene, ob_other);
+                                               }
+                                       }
+                                       CTX_DATA_END;
+                               }
+                       }
                }
        }
        CTX_DATA_END;
 
-       for (tob= G.main->object.first; tob; tob= tob->id.next) {
+       for (tob= bmain->object.first; tob; tob= tob->id.next) {
                if(tob->data && (((ID *)tob->data)->flag & LIB_DOIT)) {
                        tob->recalc= OB_RECALC_OB|OB_RECALC_DATA;
                }
        }
-       
+
        if (tot_change) {
-               DAG_ids_flush_update(0);
+               DAG_ids_flush_update(bmain, 0);
                WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL);
        }
-       
+
        /* Warn if any errors occurred */
        if (tot_lib_error+tot_multiuser_arm_error) {
-               BKE_reportf(op->reports, RPT_WARNING, "%i Object(s) Not Centered, %i Changed:",tot_lib_error+tot_multiuser_arm_error, tot_change);              
+               BKE_reportf(op->reports, RPT_WARNING, "%i Object(s) Not Centered, %i Changed:",tot_lib_error+tot_multiuser_arm_error, tot_change);
                if (tot_lib_error)
                        BKE_reportf(op->reports, RPT_WARNING, "|%i linked library objects",tot_lib_error);
                if (tot_multiuser_arm_error)
                        BKE_reportf(op->reports, RPT_WARNING, "|%i multiuser armature object(s)",tot_multiuser_arm_error);
        }
-       
+
        return OPERATOR_FINISHED;
 }
 
 void OBJECT_OT_origin_set(wmOperatorType *ot)
 {
+       static EnumPropertyItem prop_set_center_types[] = {
+               {GEOMETRY_TO_ORIGIN, "GEOMETRY_ORIGIN", 0, "Geometry to Origin", "Move object geometry to object origin"},
+               {ORIGIN_TO_GEOMETRY, "ORIGIN_GEOMETRY", 0, "Origin to Geometry", "Move object origin to center of object geometry"},
+               {ORIGIN_TO_CURSOR, "ORIGIN_CURSOR", 0, "Origin to 3D Cursor", "Move object origin to position of the 3d cursor"},
+               {0, NULL, 0, NULL, NULL}
+       };
+       
+       static EnumPropertyItem prop_set_bounds_types[] = {
+               {V3D_CENTROID, "MEDIAN", 0, "Median Center", ""},
+               {V3D_CENTER, "BOUNDS", 0, "Bounds Center", ""},
+               {0, NULL, 0, NULL, NULL}
+       };
+       
        /* identifiers */
        ot->name= "Set Origin";
        ot->description = "Set the object's origin, by either moving the data, or set to center of data, or use 3d cursor";
@@ -1050,12 +972,12 @@ void OBJECT_OT_origin_set(wmOperatorType *ot)
        ot->invoke= WM_menu_invoke;
        ot->exec= object_origin_set_exec;
        
-       ot->poll= ED_operator_view3d_active;
+       ot->poll= ED_operator_scene_editable;
        
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
        
        ot->prop= RNA_def_enum(ot->srna, "type", prop_set_center_types, 0, "Type", "");
-
+       RNA_def_enum(ot->srna, "center", prop_set_bounds_types, V3D_CENTROID, "Center", "");
 }
 
index 37de0d8f873c5f77e288f5d1fec0b3dff784589a..a18890881a8ab8d251e29ec730f7d8a27e4eac54 100644 (file)
@@ -35,6 +35,7 @@
 #include "BKE_boids.h"
 #include "BKE_context.h"
 #include "BKE_depsgraph.h"
+#include "BKE_main.h"
 #include "BKE_particle.h"
 
 #include "BLI_listbase.h"
@@ -99,6 +100,7 @@ void BOID_OT_rule_add(wmOperatorType *ot)
 }
 static int rule_del_exec(bContext *C, wmOperator *op)
 {
+       Main *bmain = CTX_data_main(C);
        Scene *scene = CTX_data_scene(C);
        PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem);
        ParticleSystem *psys= ptr.data;
@@ -125,7 +127,7 @@ static int rule_del_exec(bContext *C, wmOperator *op)
        if(rule)
                rule->flag |= BOIDRULE_CURRENT;
 
-       DAG_scene_sort(scene);
+       DAG_scene_sort(bmain, scene);
        DAG_id_flush_update(&psys->part->id, OB_RECALC_DATA|PSYS_RECALC_RESET);
 
        WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
@@ -266,6 +268,7 @@ void BOID_OT_state_add(wmOperatorType *ot)
 }
 static int state_del_exec(bContext *C, wmOperator *op)
 {
+       Main *bmain = CTX_data_main(C);
        Scene *scene = CTX_data_scene(C);
        PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem);
        ParticleSystem *psys= ptr.data;
@@ -297,7 +300,7 @@ static int state_del_exec(bContext *C, wmOperator *op)
 
        state->flag |= BOIDSTATE_CURRENT;
 
-       DAG_scene_sort(scene);
+       DAG_scene_sort(bmain, scene);
        DAG_id_flush_update(&psys->part->id, OB_RECALC_DATA|PSYS_RECALC_RESET);
 
        WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
index 059805fdf2d1607a8b856d6ecc21e13fe2150a1e..ba5d1ee525020c4a487005c0b1285d09b871fc36 100644 (file)
@@ -166,7 +166,7 @@ static int new_particle_settings_exec(bContext *C, wmOperator *op)
 
        psys_check_boid_data(psys);
 
-       DAG_scene_sort(scene);
+       DAG_scene_sort(bmain, scene);
        DAG_id_flush_update(&ob->id, OB_RECALC_DATA);
 
        WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, ob);
@@ -193,6 +193,7 @@ void PARTICLE_OT_new(wmOperatorType *ot)
 
 static int new_particle_target_exec(bContext *C, wmOperator *op)
 {
+       Main *bmain = CTX_data_main(C);
        Scene *scene = CTX_data_scene(C);
        PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem);
        ParticleSystem *psys= ptr.data;
@@ -214,7 +215,7 @@ static int new_particle_target_exec(bContext *C, wmOperator *op)
 
        BLI_addtail(&psys->targets, pt);
 
-       DAG_scene_sort(scene);
+       DAG_scene_sort(bmain, scene);
        DAG_id_flush_update(&ob->id, OB_RECALC_DATA);
 
        WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, ob);
@@ -238,6 +239,7 @@ void PARTICLE_OT_new_target(wmOperatorType *ot)
 
 static int remove_particle_target_exec(bContext *C, wmOperator *op)
 {
+       Main *bmain = CTX_data_main(C);
        Scene *scene = CTX_data_scene(C);
        PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem);
        ParticleSystem *psys= ptr.data;
@@ -262,7 +264,7 @@ static int remove_particle_target_exec(bContext *C, wmOperator *op)
        if(pt)
                pt->flag |= PTARGET_CURRENT;
 
-       DAG_scene_sort(scene);
+       DAG_scene_sort(bmain, scene);
        DAG_id_flush_update(&ob->id, OB_RECALC_DATA);
 
        WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, ob);
index 5a51c36cd09d8002b6b00c3ad8c084ad09e15003..2b7f8e9d5a2548d2c8e25dd1dc5177c7b32016d8 100644 (file)
@@ -114,7 +114,7 @@ static void keymap_particle(wmKeyConfig *keyconf)
        
        WM_keymap_add_item(keymap, "PARTICLE_OT_weight_set", KKEY, KM_PRESS, KM_SHIFT, 0);
 
-       ED_object_generic_keymap(keyconf, keymap, 1);
+       ED_object_generic_keymap(keyconf, keymap, 2);
 }
 
 /******************************* boids *************************************/
index 7110c3aa7a7588e1d65f2fc8965d82688757273d..b5392f6dede3d1a042a8bb94d9f86668560ed0ed 100644 (file)
@@ -403,6 +403,7 @@ static int screen_render_exec(bContext *C, wmOperator *op)
        Render *re= RE_NewRender(scene->id.name);
        Image *ima;
        View3D *v3d= CTX_wm_view3d(C);
+       Main *mainp= G.main; //BKE_undo_get_main(&scene);
        int lay= (v3d)? v3d->lay: scene->lay;
 
        if(re==NULL) {
@@ -418,9 +419,11 @@ static int screen_render_exec(bContext *C, wmOperator *op)
        BKE_image_backup_render(scene, ima);
 
        if(RNA_boolean_get(op->ptr, "animation"))
-               RE_BlenderAnim(re, scene, lay, scene->r.sfra, scene->r.efra, scene->r.frame_step, op->reports);
+               RE_BlenderAnim(re, mainp, scene, lay, scene->r.sfra, scene->r.efra, scene->r.frame_step, op->reports);
        else
-               RE_BlenderFrame(re, scene, NULL, lay, scene->r.cfra);
+               RE_BlenderFrame(re, mainp, scene, NULL, lay, scene->r.cfra);
+
+       //free_main(mainp);
 
        // no redraw needed, we leave state as we entered it
        ED_update_for_newframe(C, 1);
@@ -555,19 +558,18 @@ static void image_rect_update(void *rjv, RenderResult *rr, volatile rcti *renrec
 static void render_startjob(void *rjv, short *stop, short *do_update, float *progress)
 {
        RenderJob *rj= rjv;
-//     Main *mainp= BKE_undo_get_main(&rj->scene);
+       Main *mainp= G.main; //BKE_undo_get_main(&rj->scene);
 
        rj->stop= stop;
        rj->do_update= do_update;
        rj->progress= progress;
 
        if(rj->anim)
-               RE_BlenderAnim(rj->re, rj->scene, rj->lay, rj->scene->r.sfra, rj->scene->r.efra, rj->scene->r.frame_step, rj->reports);
+               RE_BlenderAnim(rj->re, mainp, rj->scene, rj->lay, rj->scene->r.sfra, rj->scene->r.efra, rj->scene->r.frame_step, rj->reports);
        else
-               RE_BlenderFrame(rj->re, rj->scene, rj->srl, rj->lay, rj->scene->r.cfra);
+               RE_BlenderFrame(rj->re, mainp, rj->scene, rj->srl, rj->lay, rj->scene->r.cfra);
 
-//     if(mainp)
-//             free_main(mainp);
+       //free_main(mainp);
 }
 
 static void render_endjob(void *rjv)
index 5881d50c30942c0d1daf7a5772cafb6c9076d994..524e36b3fc9ebbc4784b6d7617cb68500b846a18 100644 (file)
@@ -241,6 +241,7 @@ static int screen_opengl_render_init(bContext *C, wmOperator *op)
 
 static void screen_opengl_render_end(bContext *C, OGLRender *oglrender)
 {
+       Main *bmain= CTX_data_main(C);
        Scene *scene= oglrender->scene;
 
        if(oglrender->mh) {
@@ -250,7 +251,7 @@ static void screen_opengl_render_end(bContext *C, OGLRender *oglrender)
 
        if(oglrender->timer) { /* exec will not have a timer */
                scene->r.cfra= oglrender->cfrao;
-               scene_update_for_newframe(scene, screen_opengl_layers(oglrender));
+               scene_update_for_newframe(bmain, scene, screen_opengl_layers(oglrender));
 
                WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), oglrender->timer);
        }
@@ -297,6 +298,7 @@ static int screen_opengl_render_anim_initialize(bContext *C, wmOperator *op)
 }
 static int screen_opengl_render_anim_step(bContext *C, wmOperator *op)
 {
+       Main *bmain= CTX_data_main(C);
        OGLRender *oglrender= op->customdata;
        Scene *scene= oglrender->scene;
        ImBuf *ibuf;
@@ -316,11 +318,11 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op)
                if(lay & 0xFF000000)
                        lay &= 0xFF000000;
 
-               scene_update_for_newframe(scene, lay);
+               scene_update_for_newframe(bmain, scene, lay);
                CFRA++;
        }
 
-       scene_update_for_newframe(scene, screen_opengl_layers(oglrender));
+       scene_update_for_newframe(bmain, scene, screen_opengl_layers(oglrender));
 
        if(view_context) {
                if(oglrender->rv3d->persp==RV3D_CAMOB && oglrender->v3d->camera && oglrender->v3d->scenelock) {
index 4bb1f630dad7ba9647084dd9160f53198093bc6c..49395f7fb56361173398a1147bd8fd3a6c454dfb 100644 (file)
@@ -704,7 +704,7 @@ void BIF_view3d_previewrender_clear(ScrArea *sa)
 }
 
 /* afterqueue call */
-void BIF_view3d_previewrender(Scene *scene, ScrArea *sa)
+void BIF_view3d_previewrender(Main *bmain, Scene *scene, ScrArea *sa)
 {
        View3D *v3d= sa->spacedata.first;
        RegionView3D *rv3d= NULL; // XXX
@@ -804,7 +804,7 @@ void BIF_view3d_previewrender(Scene *scene, ScrArea *sa)
                        
                        /* database can have created render-resol data... */
                        if(rstats->convertdone) 
-                               DAG_scene_flush_update(scene, scene->lay, 0);
+                               DAG_scene_flush_update(bmain, scene, scene->lay, 0);
                        
                        //printf("dbase update\n");
                }
@@ -975,7 +975,7 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs
                ((Camera *)sce->camera->data)->lens *= (float)sp->sizey/(float)sizex;
 
        /* entire cycle for render engine */
-       RE_PreviewRender(re, sce);
+       RE_PreviewRender(re, G.main, sce);
 
        ((Camera *)sce->camera->data)->lens= oldlens;
 
index 5082992aaba4a8bdb2bc4239ef8d202019d303e6..8cee4a24dcc35532a1efbd81eb64d37bcd2d2c51 100644 (file)
@@ -1426,7 +1426,7 @@ void ED_screen_set_scene(bContext *C, Scene *scene)
        }
        
        CTX_data_scene_set(C, scene);
-       set_scene_bg(scene);
+       set_scene_bg(CTX_data_main(C), scene);
        
        ED_update_for_newframe(C, 1);
        
@@ -1727,6 +1727,7 @@ void ED_screen_animation_timer_update(bScreen *screen, int redraws, int refresh)
 /* results in fully updated anim system */
 void ED_update_for_newframe(const bContext *C, int mute)
 {
+       Main *bmain= CTX_data_main(C);
        bScreen *screen= CTX_wm_screen(C);
        Scene *scene= CTX_data_scene(C);
        
@@ -1750,7 +1751,7 @@ void ED_update_for_newframe(const bContext *C, int mute)
 
        /* this function applies the changes too */
        /* XXX future: do all windows */
-       scene_update_for_newframe(scene, BKE_screen_visible_layers(screen, scene)); /* BKE_scene.h */
+       scene_update_for_newframe(bmain, scene, BKE_screen_visible_layers(screen, scene)); /* BKE_scene.h */
        
        //if ( (CFRA>1) && (!mute) && (scene->r.audio.flag & AUDIO_SCRUB)) 
        //      audiostream_scrub( CFRA );
index c8192996127297210afa1d1b6881400d90c1169c..b085c8178b0e86026e36cfb612645d9134ca294c 100644 (file)
@@ -2838,9 +2838,9 @@ static int scene_new_exec(bContext *C, wmOperator *op)
        
        /* these can't be handled in blenkernel curently, so do them here */
        if(type == SCE_COPY_LINK_DATA)
-               ED_object_single_users(newscene, 0);
+               ED_object_single_users(bmain, newscene, 0);
        else if(type == SCE_COPY_FULL)
-               ED_object_single_users(newscene, 1);
+               ED_object_single_users(bmain, newscene, 1);
        
        WM_event_add_notifier(C, NC_SCENE|ND_SCENEBROWSE, newscene);
        
index bf433923707696caf952fe3850e9022f1d89c576..a6c57126cfe5b2bd90c019e42eabd05562637045 100644 (file)
@@ -299,16 +299,17 @@ static void graph_panel_key_properties(const bContext *C, Panel *pa)
 
 static void do_graph_region_driver_buttons(bContext *C, void *arg, int event)
 {
+       Main *bmain= CTX_data_main(C);
        Scene *scene= CTX_data_scene(C);
        
        switch (event) {
                case B_IPO_DEPCHANGE:
                {
                        /* rebuild depsgraph for the new deps */
-                       DAG_scene_sort(scene);
+                       DAG_scene_sort(bmain, scene);
                        
                        /* force an update of depsgraph */
-                       DAG_ids_flush_update(0);
+                       DAG_ids_flush_update(bmain, 0);
                }
                        break;
        }
index 98422ec2d9f9afb867a70d2984e39229920df4e8..ae2cee64a23990e3d826b000100ac527656da1f3 100644 (file)
@@ -359,6 +359,7 @@ static void old_sca_move_actuator(bContext *C, void *datav, void *move_up)
 
 void do_logic_buts(bContext *C, void *arg, int event)
 {
+       Main *bmain= CTX_data_main(C);
        bSensor *sens;
        bController *cont;
        bActuator *act;
@@ -382,7 +383,7 @@ void do_logic_buts(bContext *C, void *arg, int event)
                break;
        
        case B_ADD_SENS:
-               for(ob=G.main->object.first; ob; ob=ob->id.next) {
+               for(ob=bmain->object.first; ob; ob=ob->id.next) {
                        if(ob->scaflag & OB_ADDSENS) {
                                ob->scaflag &= ~OB_ADDSENS;
                                sens= new_sensor(SENS_ALWAYS);
@@ -396,7 +397,7 @@ void do_logic_buts(bContext *C, void *arg, int event)
                break;
 
        case B_CHANGE_SENS:
-               for(ob=G.main->object.first; ob; ob=ob->id.next) {
+               for(ob=bmain->object.first; ob; ob=ob->id.next) {
                        sens= ob->sensors.first;
                        while(sens) {
                                if(sens->type != sens->otype) {
@@ -410,7 +411,7 @@ void do_logic_buts(bContext *C, void *arg, int event)
                break;
        
        case B_DEL_SENS:
-               for(ob=G.main->object.first; ob; ob=ob->id.next) {
+               for(ob=bmain->object.first; ob; ob=ob->id.next) {
                        sens= ob->sensors.first;
                        while(sens) {
                                if(sens->flag & SENS_DEL) {
@@ -425,7 +426,7 @@ void do_logic_buts(bContext *C, void *arg, int event)
                break;
        
        case B_ADD_CONT:
-               for(ob=G.main->object.first; ob; ob=ob->id.next) {
+               for(ob=bmain->object.first; ob; ob=ob->id.next) {
                        if(ob->scaflag & OB_ADDCONT) {
                                ob->scaflag &= ~OB_ADDCONT;
                                cont= new_controller(CONT_LOGIC_AND);
@@ -450,7 +451,7 @@ void do_logic_buts(bContext *C, void *arg, int event)
                break;
 
        case B_SET_STATE_BIT:
-               for(ob=G.main->object.first; ob; ob=ob->id.next) {
+               for(ob=bmain->object.first; ob; ob=ob->id.next) {
                        if(ob->scaflag & OB_ALLSTATE) {
                                ob->scaflag &= ~OB_ALLSTATE;
                                ob->state = 0x3FFFFFFF;
@@ -459,7 +460,7 @@ void do_logic_buts(bContext *C, void *arg, int event)
                break;
 
        case B_INIT_STATE_BIT:
-               for(ob=G.main->object.first; ob; ob=ob->id.next) {
+               for(ob=bmain->object.first; ob; ob=ob->id.next) {
                        if(ob->scaflag & OB_INITSTBIT) {
                                ob->scaflag &= ~OB_INITSTBIT;
                                ob->state = ob->init_state;
@@ -470,7 +471,7 @@ void do_logic_buts(bContext *C, void *arg, int event)
                break;
 
        case B_CHANGE_CONT:
-               for(ob=G.main->object.first; ob; ob=ob->id.next) {
+               for(ob=bmain->object.first; ob; ob=ob->id.next) {
                        cont= ob->controllers.first;
                        while(cont) {
                                if(cont->type != cont->otype) {
@@ -485,7 +486,7 @@ void do_logic_buts(bContext *C, void *arg, int event)
        
 
        case B_DEL_CONT:
-               for(ob=G.main->object.first; ob; ob=ob->id.next) {
+               for(ob=bmain->object.first; ob; ob=ob->id.next) {
                        cont= ob->controllers.first;
                        while(cont) {
                                if(cont->flag & CONT_DEL) {
@@ -501,7 +502,7 @@ void do_logic_buts(bContext *C, void *arg, int event)
                break;
 
        case B_ADD_ACT:
-               for(ob=G.main->object.first; ob; ob=ob->id.next) {
+               for(ob=bmain->object.first; ob; ob=ob->id.next) {
                        if(ob->scaflag & OB_ADDACT) {
                                ob->scaflag &= ~OB_ADDACT;
                                act= new_actuator(ACT_OBJECT);
@@ -514,7 +515,7 @@ void do_logic_buts(bContext *C, void *arg, int event)
                break;
 
        case B_CHANGE_ACT:
-               for(ob=G.main->object.first; ob; ob=ob->id.next) {
+               for(ob=bmain->object.first; ob; ob=ob->id.next) {
                        act= ob->actuators.first;
                        while(act) {
                                if(act->type != act->otype) {
@@ -528,7 +529,7 @@ void do_logic_buts(bContext *C, void *arg, int event)
                break;
 
        case B_DEL_ACT:
-               for(ob=G.main->object.first; ob; ob=ob->id.next) {
+               for(ob=bmain->object.first; ob; ob=ob->id.next) {
                        act= ob->actuators.first;
                        while(act) {
                                if(act->flag & ACT_DEL) {
@@ -546,7 +547,7 @@ void do_logic_buts(bContext *C, void *arg, int event)
        case B_SOUNDACT_BROWSE:
                /* since we don't know which... */
                didit= 0;
-               for(ob=G.main->object.first; ob; ob=ob->id.next) {
+               for(ob=bmain->object.first; ob; ob=ob->id.next) {
                        act= ob->actuators.first;
                        while(act)
                        {
@@ -555,11 +556,11 @@ void do_logic_buts(bContext *C, void *arg, int event)
                                        bSoundActuator *sa= act->data;
                                        if(sa->sndnr)
                                        {
-                                               bSound *sound= G.main->sound.first;
+                                               bSound *sound= bmain->sound.first;
                                                int nr= 1;
 
                                                if(sa->sndnr == -2) {
-// XXX                                                 activate_databrowse((ID *)G.main->sound.first, ID_SO, 0, B_SOUNDACT_BROWSE,
+// XXX                                                 activate_databrowse((ID *)bmain->sound.first, ID_SO, 0, B_SOUNDACT_BROWSE,
 //                                                                                     &sa->sndnr, do_logic_buts);
                                                        break;
                                                }
@@ -768,6 +769,7 @@ static void set_sca_ob(Object *ob)
 static ID **get_selected_and_linked_obs(bContext *C, short *count, short scavisflag)
 {
        Base *base;
+       Main *bmain= CTX_data_main(C);
        Scene *scene= CTX_data_scene(C);
        Object *ob, *obt, *obact= CTX_data_active_object(C);
        ID **idar;
@@ -784,7 +786,7 @@ static ID **get_selected_and_linked_obs(bContext *C, short *count, short scavisf
        
        if(scene==NULL) return NULL;
        
-       ob= G.main->object.first;
+       ob= bmain->object.first;
        while(ob) {
                ob->scavisflag= 0;
                set_sca_ob(ob);
@@ -818,7 +820,7 @@ static ID **get_selected_and_linked_obs(bContext *C, short *count, short scavisf
                while(doit) {
                        doit= 0;
                        
-                       ob= G.main->object.first;
+                       ob= bmain->object.first;
                        while(ob) {
                        
                                /* 1st case: select sensor when controller selected */
@@ -899,7 +901,7 @@ static ID **get_selected_and_linked_obs(bContext *C, short *count, short scavisf
        } 
        
        /* now we count */
-       ob= G.main->object.first;
+       ob= bmain->object.first;
        while(ob) {
                if( ob->scavisflag ) (*count)++;
                ob= ob->id.next;
@@ -910,7 +912,7 @@ static ID **get_selected_and_linked_obs(bContext *C, short *count, short scavisf
        
        idar= MEM_callocN( (*count)*sizeof(void *), "idar");
        
-       ob= G.main->object.first;
+       ob= bmain->object.first;
        nr= 0;
 
        /* make the active object always the first one of the list */
@@ -1817,7 +1819,7 @@ static void check_armature_actuator(bContext *C, void *arg1_but, void *arg2_act)
 }
 
 
-static short draw_actuatorbuttons(Object *ob, bActuator *act, uiBlock *block, short xco, short yco, short width)
+static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlock *block, short xco, short yco, short width)
 {
        bSoundActuator      *sa      = NULL;
        bObjectActuator     *oa      = NULL;
@@ -2142,8 +2144,8 @@ static short draw_actuatorbuttons(Object *ob, bActuator *act, uiBlock *block, sh
                        glRects(xco, yco-ysize, xco+width, yco);
                        uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1);
                        
-                       if(G.main->sound.first) {
-                               IDnames_to_pupstring(&str, "Sound files", NULL, &(G.main->sound), (ID *)sa->sound, &(sa->sndnr));
+                       if(bmain->sound.first) {
+                               IDnames_to_pupstring(&str, "Sound files", NULL, &(bmain->sound), (ID *)sa->sound, &(sa->sndnr));
                                /* reset this value, it is for handling the event */
                                sa->sndnr = 0;
                                uiDefButS(block, MENU, B_SOUNDACT_BROWSE, str, xco+10,yco-22,20,19, &(sa->sndnr), 0, 0, 0, 0, "");      
@@ -4709,6 +4711,7 @@ static void logic_buttons_new(bContext *C, ARegion *ar)
 
 void logic_buttons(bContext *C, ARegion *ar)
 {
+       Main *bmain= CTX_data_main(C);
        SpaceLogic *slogic= CTX_wm_space_logic(C);
        Object *ob= CTX_data_active_object(C);
        ID **idar;
@@ -5033,7 +5036,7 @@ void logic_buttons(bContext *C, ARegion *ar)
                                                uiButSetFunc(but, make_unique_prop_names_cb, act->name, (void*) 0);
 
                                                ycoo= yco;
-                                               yco= draw_actuatorbuttons(ob, act, block, xco, yco, width);
+                                               yco= draw_actuatorbuttons(bmain, ob, act, block, xco, yco, width);
                                                if(yco-6 < ycoo) ycoo= (yco+ycoo-20)/2;
                                        }
                                        else {
index 082f3f97dfde1e1e2f1be9cda599c9b5f8824092..01992d225c7d997f4ef94f7dd90d643d9037a7bb 100644 (file)
@@ -190,6 +190,7 @@ static void node_buts_normal(uiLayout *layout, bContext *C, PointerRNA *ptr)
 #if 0 // not used in 2.5x yet
 static void node_browse_tex_cb(bContext *C, void *ntree_v, void *node_v)
 {
+       Main *bmain= CTX_data_main(C);
        bNodeTree *ntree= ntree_v;
        bNode *node= node_v;
        Tex *tex;
@@ -200,7 +201,7 @@ static void node_browse_tex_cb(bContext *C, void *ntree_v, void *node_v)
                node->id->us--;
                node->id= NULL;
        }
-       tex= BLI_findlink(&G.main->tex, node->menunr-1);
+       tex= BLI_findlink(&bmain->tex, node->menunr-1);
 
        node->id= &tex->id;
        id_us_plus(node->id);
@@ -220,6 +221,7 @@ static void node_browse_tex_cb(bContext *C, void *ntree_v, void *node_v)
 #endif
 static void node_dynamic_update_cb(bContext *C, void *ntree_v, void *node_v)
 {
+       Main *bmain= CTX_data_main(C);
        Material *ma;
        bNode *node= (bNode *)node_v;
        ID *id= node->id;
@@ -229,7 +231,7 @@ static void node_dynamic_update_cb(bContext *C, void *ntree_v, void *node_v)
 
        /* Users only have to press the "update" button in one pynode
         * and we also update all others sharing the same script */
-       for (ma= G.main->mat.first; ma; ma= ma->id.next) {
+       for (ma= bmain->mat.first; ma; ma= ma->id.next) {
                if (ma->nodetree) {
                        bNode *nd;
                        for (nd= ma->nodetree->nodes.first; nd; nd= nd->next) {
@@ -277,6 +279,7 @@ static void node_buts_math(uiLayout *layout, bContext *C, PointerRNA *ptr)
 
 static void node_browse_text_cb(bContext *C, void *ntree_v, void *node_v)
 {
+       Main *bmain= CTX_data_main(C);
        bNodeTree *ntree= ntree_v;
        bNode *node= node_v;
        ID *oldid;
@@ -287,7 +290,7 @@ static void node_browse_text_cb(bContext *C, void *ntree_v, void *node_v)
                node->id->us--;
        }
        oldid= node->id;
-       node->id= BLI_findlink(&G.main->text, node->menunr-1);
+       node->id= BLI_findlink(&bmain->text, node->menunr-1);
        id_us_plus(node->id);
        BLI_strncpy(node->name, node->id->name+2, 21); /* huh? why 21? */
 
@@ -368,6 +371,7 @@ static void node_shader_buts_geometry(uiLayout *layout, bContext *C, PointerRNA
 
 static void node_shader_buts_dynamic(uiLayout *layout, bContext *C, PointerRNA *ptr)
 { 
+       Main *bmain= CTX_data_main(C);
        uiBlock *block= uiLayoutAbsoluteBlock(layout);
        bNode *node= ptr->data;
        bNodeTree *ntree= ptr->id.data;
@@ -380,7 +384,7 @@ static void node_shader_buts_dynamic(uiLayout *layout, bContext *C, PointerRNA *
        /* B_NODE_EXEC is handled in butspace.c do_node_buts */
        if(!node->id) {
                        char *strp;
-                       IDnames_to_pupstring(&strp, NULL, "", &(G.main->text), NULL, NULL);
+                       IDnames_to_pupstring(&strp, NULL, "", &(bmain->text), NULL, NULL);
                        node->menunr= 0;
                        bt= uiDefButS(block, MENU, B_NODE_EXEC/*+node->nr*/, strp, 
                                                        butr->xmin, dy, 19, 19, 
index cea88c33c5b98a887ef578051f785f020b4c0cdf..dcd87b89ea09a898dc19fa516daeec29f28bec7b 100644 (file)
@@ -1852,6 +1852,7 @@ void NODE_OT_links_cut(wmOperatorType *ot)
 /* goes over all scenes, reads render layers */
 static int node_read_renderlayers_exec(bContext *C, wmOperator *op)
 {
+       Main *bmain= CTX_data_main(C);
        SpaceNode *snode= CTX_wm_space_node(C);
        Scene *curscene= CTX_data_scene(C), *scene;
        bNode *node;
@@ -1859,7 +1860,7 @@ static int node_read_renderlayers_exec(bContext *C, wmOperator *op)
        ED_preview_kill_jobs(C);
 
        /* first tag scenes unread */
-       for(scene= G.main->scene.first; scene; scene= scene->id.next) 
+       for(scene= bmain->scene.first; scene; scene= scene->id.next) 
                scene->id.flag |= LIB_DOIT;
 
        for(node= snode->edittree->nodes.first; node; node= node->next) {
index 3cdc2437c45faf69cbf870303af394dd22fc0e09..ad04e28ee4a6e23ee754feb3a156106637487921 100644 (file)
@@ -3186,7 +3186,7 @@ static void object_delete_cb(bContext *C, Scene *scene, TreeElement *te, TreeSto
                if(scene->obedit==base->object) 
                        ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR|EM_DO_UNDO);
                
-               ED_base_object_free_and_unlink(scene, base);
+               ED_base_object_free_and_unlink(CTX_data_main(C), scene, base);
                te->directdata= NULL;
                tselem->id= NULL;
        }
@@ -3337,7 +3337,7 @@ void outliner_del(bContext *C, Scene *scene, ARegion *ar, SpaceOops *soops)
                ;//             del_seq();
        else {
                outliner_do_object_operation(C, scene, soops, &soops->tree, object_delete_cb);
-               DAG_scene_sort(scene);
+               DAG_scene_sort(CTX_data_main(C), scene);
                ED_undo_push(C, "Delete Objects");
        }
 }
@@ -3356,6 +3356,7 @@ static EnumPropertyItem prop_object_op_types[] = {
 
 static int outliner_object_operation_exec(bContext *C, wmOperator *op)
 {
+       Main *bmain= CTX_data_main(C);
        Scene *scene= CTX_data_scene(C);
        SpaceOops *soops= CTX_wm_space_outliner(C);
        int event;
@@ -3382,7 +3383,7 @@ static int outliner_object_operation_exec(bContext *C, wmOperator *op)
        }
        else if(event==4) {
                outliner_do_object_operation(C, scene, soops, &soops->tree, object_delete_cb);
-               DAG_scene_sort(scene);
+               DAG_scene_sort(bmain, scene);
                str= "Delete Objects";
        }
        else if(event==5) {     /* disabled, see above (ton) */
index 5638cb6daf5da8a5624abb4353b527249d1e8d8e..7a3f0ff80e5e7625dc30c604558e98fbed8e1a17 100644 (file)
@@ -2359,6 +2359,7 @@ void TEXT_OT_insert(wmOperatorType *ot)
 
 static int find_and_replace(bContext *C, wmOperator *op, short mode)
 {
+       Main *bmain= CTX_data_main(C);
        SpaceText *st= CTX_wm_space_text(C);
        Text *start= NULL, *text= st->text;
        int flags, first= 1;
@@ -2420,7 +2421,7 @@ static int find_and_replace(bContext *C, wmOperator *op, short mode)
                        if(text->id.next)
                                text= st->text= text->id.next;
                        else
-                               text= st->text= G.main->text.first;
+                               text= st->text= bmain->text.first;
                        txt_move_toline(text, 0, 0);
                        text_update_cursor_moved(C);
                        WM_event_add_notifier(C, NC_TEXT|ND_CURSOR, text);
index 5bb1ea2cc9f75ca72b6c440834d81895fb6ec27a..54775affe3f047a8b66dd0f70cf0266937a67362 100644 (file)
@@ -146,7 +146,7 @@ static void view3d_project_short_clip(ARegion *ar, float *vec, short *adr, int l
                        return;
        }
        
-       VECCOPY(vec4, vec);
+       copy_v3_v3(vec4, vec)