svn merge ^/trunk/blender -r42261:42290
authorCampbell Barton <ideasman42@gmail.com>
Wed, 30 Nov 2011 09:31:11 +0000 (09:31 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 30 Nov 2011 09:31:11 +0000 (09:31 +0000)
62 files changed:
extern/libmv/libmv/tracking/esm_region_tracker.cc
extern/libmv/libmv/tracking/klt_region_tracker.cc
extern/libmv/libmv/tracking/lmicklt_region_tracker.cc
extern/libmv/libmv/tracking/trklt_region_tracker.cc
release/scripts/startup/bl_operators/clip.py
release/scripts/startup/bl_ui/space_info.py
release/scripts/startup/bl_ui/space_view3d.py
release/text/readme.html
source/blender/blenkernel/BKE_blender.h
source/blender/blenkernel/BKE_deform.h
source/blender/blenkernel/BKE_library.h
source/blender/blenkernel/intern/action.c
source/blender/blenkernel/intern/anim.c
source/blender/blenkernel/intern/armature.c
source/blender/blenkernel/intern/brush.c
source/blender/blenkernel/intern/camera.c
source/blender/blenkernel/intern/curve.c
source/blender/blenkernel/intern/deform.c
source/blender/blenkernel/intern/image.c
source/blender/blenkernel/intern/lamp.c
source/blender/blenkernel/intern/lattice.c
source/blender/blenkernel/intern/library.c
source/blender/blenkernel/intern/material.c
source/blender/blenkernel/intern/mball.c
source/blender/blenkernel/intern/mesh.c
source/blender/blenkernel/intern/object.c
source/blender/blenkernel/intern/particle.c
source/blender/blenkernel/intern/speaker.c
source/blender/blenkernel/intern/texture.c
source/blender/blenkernel/intern/world.c
source/blender/blenloader/intern/readfile.c
source/blender/editors/include/ED_screen.h
source/blender/editors/interface/interface_panel.c
source/blender/editors/object/object_constraint.c
source/blender/editors/object/object_transform.c
source/blender/editors/object/object_vgroup.c
source/blender/editors/render/render_opengl.c
source/blender/editors/screen/area.c
source/blender/editors/space_clip/clip_draw.c
source/blender/editors/space_image/image_draw.c
source/blender/editors/space_node/drawnode.c
source/blender/editors/space_outliner/outliner_tools.c
source/blender/editors/space_view3d/view3d_draw.c
source/blender/makesdna/DNA_view3d_types.h
source/blender/makesrna/intern/rna_space.c
source/blender/modifiers/intern/MOD_weightvg_util.c
source/blender/python/intern/bpy_library.c
source/blender/python/intern/bpy_props.c
source/blender/python/mathutils/mathutils.c
source/blender/python/mathutils/mathutils.h
source/blender/python/mathutils/mathutils_Color.h
source/blender/python/mathutils/mathutils_Euler.c
source/blender/python/mathutils/mathutils_Euler.h
source/blender/python/mathutils/mathutils_Matrix.c
source/blender/python/mathutils/mathutils_Matrix.h
source/blender/python/mathutils/mathutils_Quaternion.c
source/blender/python/mathutils/mathutils_Quaternion.h
source/blender/python/mathutils/mathutils_Vector.c
source/blender/python/mathutils/mathutils_Vector.h
source/blender/render/intern/source/convertblender.c
source/blender/windowmanager/intern/wm_operators.c
source/gameengine/Converter/KX_BlenderSceneConverter.cpp

index 01edee3bbb524e4f9acc155d9d540c750535e2ac..844b5ff3cb9853e52110f341db4eb3845551675e 100644 (file)
@@ -31,7 +31,7 @@
 namespace libmv {
 
 // TODO(keir): Reduce duplication between here and the other region trackers.
-bool RegionIsInBounds(const FloatImage &image1,
+static bool RegionIsInBounds(const FloatImage &image1,
                       double x, double y,
                       int half_window_size) {
   // Check the minimum coordinates.
@@ -56,7 +56,7 @@ bool RegionIsInBounds(const FloatImage &image1,
 
 // Sample a region centered at x,y in image with size extending by half_width
 // from x,y. Channels specifies the number of channels to sample from.
-void SamplePattern(const FloatImage &image,
+static void SamplePattern(const FloatImage &image,
                    double x, double y,
                    int half_width,
                    int channels,
@@ -74,7 +74,7 @@ void SamplePattern(const FloatImage &image,
 
 // Estimate "reasonable" error by computing autocorrelation for a small shift.
 // TODO(keir): Add a facility for 
-double EstimateReasonableError(const FloatImage &image,
+static double EstimateReasonableError(const FloatImage &image,
                                double x, double y,
                                int half_width) {
   double error = 0.0;
index 78ce0be603c3f84f705b180d568093ac86987d37..c8e605de572a54e2285e8b31fbd403ada769a345 100644 (file)
@@ -63,7 +63,7 @@ static void ComputeTrackingEquation(const Array3Df &image_and_gradient1,
   }
 }
 
-bool RegionIsInBounds(const FloatImage &image1,
+static bool RegionIsInBounds(const FloatImage &image1,
                       double x, double y,
                       int half_window_size) {
   // Check the minimum coordinates.
index 5ac96e661759d8ae31f34a7205b699aa6a6c35e0..c06a1d3302c528a62c5d4f785cb54c84e4aad68e 100644 (file)
@@ -29,7 +29,7 @@
 namespace libmv {
 
 // TODO(keir): Reduce duplication between here and the other region trackers.
-bool RegionIsInBounds(const FloatImage &image1,
+static bool RegionIsInBounds(const FloatImage &image1,
                       double x, double y,
                       int half_window_size) {
   // Check the minimum coordinates.
@@ -54,7 +54,7 @@ bool RegionIsInBounds(const FloatImage &image1,
 
 // Sample a region centered at x,y in image with size extending by half_width
 // from x,y. Channels specifies the number of channels to sample from.
-void SamplePattern(const FloatImage &image,
+static void SamplePattern(const FloatImage &image,
                    double x, double y,
                    int half_width,
                    int channels,
@@ -71,7 +71,7 @@ void SamplePattern(const FloatImage &image,
 }
 
 // Estimate "reasonable" error by computing autocorrelation for a small shift.
-double EstimateReasonableError(const FloatImage &image,
+static double EstimateReasonableError(const FloatImage &image,
                                double x, double y,
                                int half_width) {
   double error = 0.0;
index 7e51787ebacca00d8c562737d6859661e5285686..f19315b6b11f157ec235cf77693ffef918dcac37 100644 (file)
@@ -81,7 +81,7 @@ static void ComputeTrackingEquation(const Array3Df &image_and_gradient1,
   *e = (A + lambda*Mat2f::Identity())*Di*(V - W) + 0.5*(S - R);
 }
 
-bool RegionIsInBounds(const FloatImage &image1,
+static bool RegionIsInBounds(const FloatImage &image1,
                       double x, double y,
                       int half_window_size) {
   // Check the minimum coordinates.
index 6ab480b4e23af18ca6b5c0d010a56fc13ec8a8a8..11d545849ef2855adbecf5daf3ea5ad33466f388 100644 (file)
@@ -40,14 +40,14 @@ def CLIP_set_viewport_background(context, all_screens, clip, clip_user):
         bgpic = None
 
         for x in space_v3d.background_images:
-            if x.source == 'MOVIE':
+            if x.source == 'MOVIE_CLIP':
                 bgpic = x
                 break
 
         if not bgpic:
             bgpic = space_v3d.background_images.new()
 
-        bgpic.source = 'MOVIE'
+        bgpic.source = 'MOVIE_CLIP'
         bgpic.clip = clip
         bgpic.clip_user.proxy_render_size = user.proxy_render_size
         bgpic.clip_user.use_render_undistorted = True
@@ -531,7 +531,6 @@ class CLIP_OT_setup_tracking_scene(Operator):
         vector_blur = tree.nodes.new(type='VECBLUR')
         alphaover = tree.nodes.new(type='ALPHAOVER')
         viewer = tree.nodes.new(type='VIEWER')
-        zcomb = tree.nodes.new(type='ZCOMBINE')
 
         # setup nodes
         movieclip.clip = clip
@@ -561,8 +560,6 @@ class CLIP_OT_setup_tracking_scene(Operator):
 
         vector_blur.factor = 0.75
 
-        zcomb.use_alpha = True
-
         # create links
         tree.links.new(movieclip.outputs['Image'], distortion.inputs['Image'])
 
@@ -591,14 +588,8 @@ class CLIP_OT_setup_tracking_scene(Operator):
         tree.links.new(rlayer_fg.outputs['Z'], vector_blur.inputs['Z'])
         tree.links.new(rlayer_fg.outputs['Speed'], vector_blur.inputs['Speed'])
 
-        tree.links.new(vector_blur.outputs['Image'], zcomb.inputs[0])
-        tree.links.new(rlayer_fg.outputs['Z'], zcomb.inputs[1])
-
-        tree.links.new(mul_image.outputs['Image'], zcomb.inputs[2])
-        tree.links.new(rlayer_bg.outputs['Z'], zcomb.inputs[3])
-
         tree.links.new(mul_image.outputs['Image'], alphaover.inputs[1])
-        tree.links.new(zcomb.outputs['Image'], alphaover.inputs[2])
+        tree.links.new(vector_blur.outputs['Image'], alphaover.inputs[2])
 
         tree.links.new(alphaover.outputs['Image'], composite.inputs['Image'])
         tree.links.new(alphaover.outputs['Image'], viewer.inputs['Image'])
@@ -641,17 +632,13 @@ class CLIP_OT_setup_tracking_scene(Operator):
         rlayer_fg.location = rlayer_bg.location
         rlayer_fg.location -= Vector((0.0, 500.0))
 
-        vector_blur.location[0] = mul_image.location[0] - 200
+        vector_blur.location[0] = mul_image.location[0]
         vector_blur.location[1] = rlayer_fg.location[1]
 
-        alphaover.location[0] = vector_blur.location[0] + 700
+        alphaover.location[0] = vector_blur.location[0] + 350
         alphaover.location[1] = \
             (vector_blur.location[1] + mul_image.location[1]) / 2
 
-        zcomb.location[0] = vector_blur.location[0] + 450
-        zcomb.location[1] = \
-            (vector_blur.location[1] + mul_image.location[1]) / 3 * 2
-
         composite.location = alphaover.location
         composite.location += Vector((200.0, -100.0))
 
index ab8975d60e84c540d21bbd5886b0e1aecec152bc..a44bdbd58b38c0ad953b57cf9467852ffa0ec3d4 100644 (file)
@@ -362,7 +362,7 @@ class INFO_MT_help(Menu):
         layout = self.layout
 
         layout.operator("wm.url_open", text="Manual", icon='HELP').url = 'http://wiki.blender.org/index.php/Doc:2.6/Manual'
-        layout.operator("wm.url_open", text="Release Log", icon='URL').url = 'http://www.blender.org/development/release-logs/blender-260/'
+        layout.operator("wm.url_open", text="Release Log", icon='URL').url = 'http://www.blender.org/development/release-logs/blender-261/'
 
         layout.separator()
 
index f6aab54f397b53bc51c861e9edcfdf41f89925e1..bfc8962168a91f67c5f23763c7e4c9cf093c2d9d 100644 (file)
@@ -2301,10 +2301,16 @@ class VIEW3D_PT_background_image(Panel):
             row.prop(bg, "show_expanded", text="", emboss=False)
             if bg.source == 'IMAGE' and bg.image:
                 row.prop(bg.image, "name", text="", emboss=False)
-            elif bg.source == 'MOVIE' and bg.clip:
+            elif bg.source == 'MOVIE_CLIP' and bg.clip:
                 row.prop(bg.clip, "name", text="", emboss=False)
             else:
                 row.label(text="Not Set")
+
+            if bg.show_background_image:
+                row.prop(bg, "show_background_image", text="", emboss=False, icon='RESTRICT_VIEW_OFF')
+            else:
+                row.prop(bg, "show_background_image", text="", emboss=False, icon='RESTRICT_VIEW_ON')
+
             row.operator("view3d.background_image_remove", text="", emboss=False, icon='X').index = i
 
             box.prop(bg, "view_axis", text="Axis")
@@ -2321,7 +2327,7 @@ class VIEW3D_PT_background_image(Panel):
                         box.template_image(bg, "image", bg.image_user, compact=True)
                         has_bg = True
 
-                elif bg.source == 'MOVIE':
+                elif bg.source == 'MOVIE_CLIP':
                     box.prop(bg, 'use_camera_clip')
 
                     column = box.column()
index 8c5ead490360379146d0f7ea67c9648e38c5c403..0627624d2e70e01a2afd8cc04aea595fb0fe0629 100644 (file)
   </style>
 </head>
 <body>
-<p class="title"><b>Blender 2.60</b></p>
+<p class="title"><b>Blender 2.61</b></p>
 <p><br></p>
 <p class="header"><b>About</b></p>
 <p class="body">Welcome to Blender, the free, open source 3D application for modeling, animation, rendering, compositing, video editing and game creation. Blender is available for Linux, Mac OS X, Windows, Solaris and FreeBSD and has a large world-wide community.</p>
 <p class="body">Blender can be used freely for any purpose, including commercial use and distribution. It's free and open-source software, released under the GNU GPL licence. The entire source code is available on our website.</p>
 <p class="body">For more information, visit <a href="http://www.blender.org">blender.org</a>.</p>
 <p><br></p>
-<p class="header"><b>2.60</b></p>
-<p class="body">The Blender Foundation and online developer community is proud to present Blender 2.60. This release is the first official stable release of the Blender 2.6 series, in which we will refine the 2.5 series and add exciting new features again.<a href="http://www.blender.org/development/release-logs/blender-260/">More information about this release</a>.</p>
+<p class="header"><b>2.61</b></p>
+<p class="body">The Blender Foundation and online developer community is proud to present Blender 2.61. This release is the second official stable release of the Blender 2.6 series, in which we will refine the 2.5 series and add exciting new features again.<a href="http://www.blender.org/development/release-logs/blender-261/">More information about this release</a>.</p>
 <p><br></p>
 <p class="header"><b>Bugs</b></p>
-<p class="body">Although Blender 2.60 is considered a stable release, you may encounter a bug. If you do, please help us by posting it in the bug tracker or using Help → Report a Bug from inside Blender. If it wasn’t reported yet, please log in (or register) and fill in detailed information about the error. Please post detailed instructions on how to reproduce it or post a .blend file showcasing the bug.</p>
+<p class="body">Although Blender 2.61 is considered a stable release, you may encounter a bug. If you do, please help us by posting it in the bug tracker or using Help → Report a Bug from inside Blender. If it wasn’t reported yet, please log in (or register) and fill in detailed information about the error. Please post detailed instructions on how to reproduce it or post a .blend file showcasing the bug.</p>
 <p><br></p>
 <p class="header"><b>Package Contents</b></p>
 <p class="body">The downloaded Blender package includes:</p>
@@ -47,7 +47,7 @@
 <p class="header"><b>Links</b></p>
 <p class="body">Users:</p>
 <p class="body">       General information             <a href="http://www.blender.org">www.blender.org</a> <br>
-       Full release log                        <a href="http://www.blender.org/development/release-logs/blender-260/">www.blender.org/development/release-logs/blender-260/</a><br>
+       Full release log                        <a href="http://www.blender.org/development/release-logs/blender-261/">www.blender.org/development/release-logs/blender-261/</a><br>
        Tutorials                       <a href="http://www.blender.org/education-help/">www.blender.org/education-help/</a>    <br>
        Manual                  <a href="http://wiki.blender.org/index.php/Doc:Manual">wiki.blender.org/index.php/Doc:Manual</a><br>
        User Forum                      <a href="http://www.blenderartists.org">www.blenderartists.org</a><br>
index a64ebe56c9c8bd85da4d9f7c925bf1e131172acf..50a1331d7ab1dc22f063e1587e6e103982c3383a 100644 (file)
@@ -42,7 +42,7 @@ extern "C" {
  * and keep comment above the defines.
  * Use STRINGIFY() rather than defining with quotes */
 #define BLENDER_VERSION                        260
-#define BLENDER_SUBVERSION             5
+#define BLENDER_SUBVERSION             6
 
 #define BLENDER_MINVERSION             250
 #define BLENDER_MINSUBVERSION  0
index 3e643fe961cac5caa79858a778765b87491aeabd..ed8ea6911346a28ae0b3a98967ccbb7ab2829358 100644 (file)
@@ -52,13 +52,16 @@ void                                 defgroup_unique_name(struct bDeformGroup *dg, struct Object *ob);
 
 struct MDeformWeight   *defvert_find_index(const struct MDeformVert *dv, const int defgroup);
 struct MDeformWeight   *defvert_verify_index(struct MDeformVert *dv, const int defgroup);
+void                     defvert_remove_index(struct MDeformVert *dvert, int defgroup, struct MDeformWeight *dw);
 
-float  defvert_find_weight(const struct MDeformVert *dvert, const int group_num);
-float  defvert_array_find_weight_safe(const struct MDeformVert *dvert, int index, int group_num);
+float  defvert_find_weight(const struct MDeformVert *dvert, const int defgroup);
+float  defvert_array_find_weight_safe(const struct MDeformVert *dvert, const int index, const int defgroup);
 
-void defvert_copy(struct MDeformVert *dvert_r, const struct MDeformVert *dvert);
-void defvert_sync(struct MDeformVert *dvert_r, const struct MDeformVert *dvert, int use_verify);
-void defvert_sync_mapped(struct MDeformVert *dvert_r, const struct MDeformVert *dvert, const int *flip_map, const int flip_map_len, const int use_verify);
+void defvert_copy(struct MDeformVert *dvert_dst, const struct MDeformVert *dvert_src);
+void defvert_copy_index(struct MDeformVert *dvert_dst, const struct MDeformVert *dvert_src, const int defgroup);
+void defvert_sync(struct MDeformVert *dvert_dst, const struct MDeformVert *dvert_src, int use_verify);
+void defvert_sync_mapped(struct MDeformVert *dvert_dst, const struct MDeformVert *dvert_src,
+                         const int *flip_map, const int flip_map_len, const int use_verify);
 void defvert_remap (struct MDeformVert *dvert, int *map);
 void defvert_flip(struct MDeformVert *dvert, const int *flip_map, const int flip_map_len);
 void defvert_normalize(struct MDeformVert *dvert);
index ade055ac457b8e6ae2442e6bfd7d182aadd5c6be..e8d6c85664be1623697e173c5ed24f69594740f7 100644 (file)
@@ -49,7 +49,7 @@ void *alloc_libblock(struct ListBase *lb, short type, const char *name);
 void *copy_libblock(struct ID *id);
 void copy_libblock_data(struct ID *id, const struct ID *id_from, const short do_action);
 
-void BKE_id_lib_local_paths(struct Main *bmain, struct ID *id);
+void BKE_id_lib_local_paths(struct Main *bmain, struct Library *lib, struct ID *id);
 void id_lib_extern(struct ID *id);
 void BKE_library_filepath_set(struct Library *lib, const char *filepath);
 void id_us_plus(struct ID *id);
index 5fb03b7bbd00dd5199269a88ce1fc9b36ab3375a..767401a55ef70e1a1059f0e6f383ed20be2b045c 100644 (file)
@@ -92,8 +92,8 @@ bAction *add_empty_action(const char name[])
 
 /* temp data for make_local_action */
 typedef struct tMakeLocalActionContext {
-       bAction *act;    /* original action */
-       bAction *actn;   /* new action */
+       bAction *act;       /* original action */
+       bAction *act_new;   /* new action */
        
        int is_lib;         /* some action users were libraries */
        int is_local;       /* some action users were not libraries */
@@ -117,9 +117,9 @@ static void make_localact_apply_cb(ID *id, AnimData *adt, void *mlac_ptr)
        
        if (adt->action == mlac->act) {
                if (id->lib == NULL) {
-                       adt->action = mlac->actn;
+                       adt->action = mlac->act_new;
                        
-                       id_us_plus(&mlac->actn->id);
+                       id_us_plus(&mlac->act_new->id);
                        id_us_min(&mlac->act->id);
                }
        }
@@ -146,10 +146,10 @@ void make_local_action(bAction *act)
                id_clear_lib_data(bmain, &act->id);
        }
        else if (mlac.is_local && mlac.is_lib) {
-               mlac.actn= copy_action(act);
-               mlac.actn->id.us= 0;
+               mlac.act_new= copy_action(act);
+               mlac.act_new->id.us= 0;
 
-               BKE_id_lib_local_paths(bmain, &mlac.actn->id);
+               BKE_id_lib_local_paths(bmain, act->id.lib, &mlac.act_new->id);
 
                BKE_animdata_main_cb(bmain, make_localact_apply_cb, &mlac);
        }
index 67bd1ec18aaf300730bcde81fede885548a6c82e..0d63c161ccc53ead0f5dbcd419fd90b56b58096c 100644 (file)
@@ -758,7 +758,7 @@ static void group_duplilist(ListBase *lb, Scene *scene, Object *ob, int level, i
 static void frames_duplilist(ListBase *lb, Scene *scene, Object *ob, int level, int animated)
 {
        extern int enable_cu_speed;     /* object.c */
-       Object copyob = {{NULL}};
+       Object copyob;
        int cfrao = scene->r.cfra;
        int dupend = ob->dupend;
        
index a9c29728650902c162f0df47ee8e90970d8d0f34..2157bd5999bb29f9b482084c8c4f378e3cd8840a 100644 (file)
@@ -158,17 +158,17 @@ void make_local_armature(bArmature *arm)
                id_clear_lib_data(bmain, &arm->id);
        }
        else if(is_local && is_lib) {
-               bArmature *armn= copy_armature(arm);
-               armn->id.us= 0;
+               bArmature *arm_new= copy_armature(arm);
+               arm_new->id.us= 0;
 
                /* Remap paths of new ID using old library as base. */
-               BKE_id_lib_local_paths(bmain, &armn->id);
+               BKE_id_lib_local_paths(bmain, arm->id.lib, &arm_new->id);
 
                for(ob= bmain->object.first; ob; ob= ob->id.next) {
                        if(ob->data == arm) {
                                if(ob->id.lib==NULL) {
-                                       ob->data= armn;
-                                       armn->id.us++;
+                                       ob->data= arm_new;
+                                       arm_new->id.us++;
                                        arm->id.us--;
                                }
                        }
index 5303baddbca2453fed3a43d0d58bb116f184a742..7fac273ef77e4ccd666262b4045ecefdaf8035a7 100644 (file)
@@ -224,17 +224,17 @@ void make_local_brush(Brush *brush)
                }
        }
        else if(is_local && is_lib) {
-               Brush *brushn= copy_brush(brush);
-               brushn->id.us= 1; /* only keep fake user */
-               brushn->id.flag |= LIB_FAKEUSER;
+               Brush *brush_new= copy_brush(brush);
+               brush_new->id.us= 1; /* only keep fake user */
+               brush_new->id.flag |= LIB_FAKEUSER;
 
                /* Remap paths of new ID using old library as base. */
-               BKE_id_lib_local_paths(bmain, &brush->id);
+               BKE_id_lib_local_paths(bmain, brush->id.lib, &brush_new->id);
                
                for(scene= bmain->scene.first; scene; scene=scene->id.next) {
                        if(paint_brush(&scene->toolsettings->imapaint.paint)==brush) {
                                if(scene->id.lib==NULL) {
-                                       paint_brush_set(&scene->toolsettings->imapaint.paint, brushn);
+                                       paint_brush_set(&scene->toolsettings->imapaint.paint, brush_new);
                                }
                        }
                }
index 08e8a80750e6865611cf5255c4a4249ae2f894e8..2bd973d779968f4a18e99d68a7dc2580cd64341f 100644 (file)
@@ -108,18 +108,18 @@ void make_local_camera(Camera *cam)
                id_clear_lib_data(bmain, &cam->id);
        }
        else if(is_local && is_lib) {
-               Camera *camn= copy_camera(cam);
+               Camera *cam_new= copy_camera(cam);
 
-               camn->id.us= 0;
+               cam_new->id.us= 0;
 
                /* Remap paths of new ID using old library as base. */
-               BKE_id_lib_local_paths(bmain, &camn->id);
+               BKE_id_lib_local_paths(bmain, cam->id.lib, &cam_new->id);
 
                for(ob= bmain->object.first; ob; ob= ob->id.next) {
                        if(ob->data == cam) {
                                if(ob->id.lib==NULL) {
-                                       ob->data= camn;
-                                       camn->id.us++;
+                                       ob->data= cam_new;
+                                       cam_new->id.us++;
                                        cam->id.us--;
                                }
                        }
index ccafb65312af2055567195f1c3cd77f4aa4c6ac4..1bee8eaa0231f040c465c93b399b88d6700c6dc7 100644 (file)
@@ -275,16 +275,16 @@ void make_local_curve(Curve *cu)
                extern_local_curve(cu);
        }
        else if(is_local && is_lib) {
-               Curve *cun= copy_curve(cu);
-               cun->id.us= 0;
+               Curve *cu_new= copy_curve(cu);
+               cu_new->id.us= 0;
 
-               BKE_id_lib_local_paths(bmain, &cun->id);
+               BKE_id_lib_local_paths(bmain, cu->id.lib, &cu_new->id);
 
                for(ob= bmain->object.first; ob; ob= ob->id.next) {
                        if(ob->data==cu) {
                                if(ob->id.lib==NULL) {
-                                       ob->data= cun;
-                                       cun->id.us++;
+                                       ob->data= cu_new;
+                                       cu_new->id.us++;
                                        cu->id.us--;
                                }
                        }
index 9539e6a4bfadea7f05fbdbb770a22d951fa138bb..6947bf05890e558b74d713890282b6b72e00b72e 100644 (file)
@@ -48,7 +48,7 @@
 #include "BLI_cellalloc.h"
 
 
-void defgroup_copy_list (ListBase *outbase, ListBase *inbase)
+void defgroup_copy_list(ListBase *outbase, ListBase *inbase)
 {
        bDeformGroup *defgroup, *defgroupn;
 
@@ -60,7 +60,7 @@ void defgroup_copy_list (ListBase *outbase, ListBase *inbase)
        }
 }
 
-bDeformGroup *defgroup_duplicate (bDeformGroup *ingroup)
+bDeformGroup *defgroup_duplicate(bDeformGroup *ingroup)
 {
        bDeformGroup *outgroup;
 
@@ -68,7 +68,7 @@ bDeformGroup *defgroup_duplicate (bDeformGroup *ingroup)
                return NULL;
 
        outgroup=MEM_callocN(sizeof(bDeformGroup), "copy deformGroup");
-       
+
        /* For now, just copy everything over. */
        memcpy (outgroup, ingroup, sizeof(bDeformGroup));
 
@@ -78,59 +78,85 @@ bDeformGroup *defgroup_duplicate (bDeformGroup *ingroup)
 }
 
 /* copy & overwrite weights */
-void defvert_copy (MDeformVert *dvert_r, const MDeformVert *dvert)
+void defvert_copy(MDeformVert *dvert_dst, const MDeformVert *dvert_src)
 {
-       if(dvert_r->totweight == dvert->totweight) {
-               if(dvert->totweight)
-                       memcpy(dvert_r->dw, dvert->dw, dvert->totweight * sizeof(MDeformWeight));
+       if (dvert_dst->totweight == dvert_src->totweight) {
+               if (dvert_src->totweight)
+                       memcpy(dvert_dst->dw, dvert_src->dw, dvert_src->totweight * sizeof(MDeformWeight));
        }
        else {
-               if(dvert_r->dw)
-                       BLI_cellalloc_free(dvert_r->dw);
+               if (dvert_dst->dw)
+                       BLI_cellalloc_free(dvert_dst->dw);
 
-               if(dvert->totweight)
-                       dvert_r->dw= BLI_cellalloc_dupalloc(dvert->dw);
+               if (dvert_src->totweight)
+                       dvert_dst->dw= BLI_cellalloc_dupalloc(dvert_src->dw);
                else
-                       dvert_r->dw= NULL;
+                       dvert_dst->dw= NULL;
+
+               dvert_dst->totweight = dvert_src->totweight;
+       }
+}
+
+/* copy an index from one dvert to another
+ * - do nothing if neither are set.
+ * - add destination weight if needed.
+ */
+void defvert_copy_index(MDeformVert *dvert_dst, const MDeformVert *dvert_src, const int defgroup)
+{
+       MDeformWeight *dw_src, *dw_dst;
+
+       dw_src= defvert_find_index(dvert_src, defgroup);
+
+       if (dw_src) {
+               /* source is valid, verify destination */
+               dw_dst= defvert_verify_index(dvert_dst, defgroup);
+               dw_dst->weight= dw_src->weight;
+       }
+       else {
+               /* source was NULL, assign zero, could also remove */
+               dw_dst= defvert_find_index(dvert_dst, defgroup);
 
-               dvert_r->totweight = dvert->totweight;
+               if (dw_dst) {
+                       dw_dst->weight= 0.0f;
+               }
        }
 }
 
 /* only sync over matching weights, don't add or remove groups
  * warning, loop within loop.
  */
-void defvert_sync (MDeformVert *dvert_r, const MDeformVert *dvert, int use_verify)
+void defvert_sync(MDeformVert *dvert_dst, const MDeformVert *dvert_src, int use_verify)
 {
-       if(dvert->totweight && dvert_r->totweight) {
+       if (dvert_src->totweight && dvert_dst->totweight) {
                int i;
-               MDeformWeight *dw;
-               for(i=0, dw=dvert->dw; i < dvert->totweight; i++, dw++) {
-                       MDeformWeight *dw_r;
-                       if(use_verify)  dw_r= defvert_verify_index(dvert_r, dw->def_nr);
-                       else                    dw_r= defvert_find_index(dvert_r, dw->def_nr);
-
-                       if(dw_r) {
-                               dw_r->weight= dw->weight;
+               MDeformWeight *dw_src;
+               for (i=0, dw_src=dvert_src->dw; i < dvert_src->totweight; i++, dw_src++) {
+                       MDeformWeight *dw_dst;
+                       if (use_verify) dw_dst= defvert_verify_index(dvert_dst, dw_src->def_nr);
+                       else            dw_dst= defvert_find_index(dvert_dst, dw_src->def_nr);
+
+                       if (dw_dst) {
+                               dw_dst->weight= dw_src->weight;
                        }
                }
        }
 }
 
 /* be sure all flip_map values are valid */
-void defvert_sync_mapped (MDeformVert *dvert_r, const MDeformVert *dvert, const int *flip_map, const int flip_map_len, const int use_verify)
+void defvert_sync_mapped(MDeformVert *dvert_dst, const MDeformVert *dvert_src,
+                         const int *flip_map, const int flip_map_len, const int use_verify)
 {
-       if (dvert->totweight && dvert_r->totweight) {
+       if (dvert_src->totweight && dvert_dst->totweight) {
                int i;
-               MDeformWeight *dw;
-               for (i=0, dw=dvert->dw; i < dvert->totweight; i++, dw++) {
-                       if (dw->def_nr < flip_map_len) {
-                               MDeformWeight *dw_r;
-                               if(use_verify)  dw_r= defvert_verify_index(dvert_r, flip_map[dw->def_nr]);
-                               else                    dw_r= defvert_find_index(dvert_r, flip_map[dw->def_nr]);
-
-                               if(dw_r) {
-                                       dw_r->weight= dw->weight;
+               MDeformWeight *dw_src;
+               for (i=0, dw_src=dvert_src->dw; i < dvert_src->totweight; i++, dw_src++) {
+                       if (dw_src->def_nr < flip_map_len) {
+                               MDeformWeight *dw_dst;
+                               if (use_verify) dw_dst= defvert_verify_index(dvert_dst, flip_map[dw_src->def_nr]);
+                               else            dw_dst= defvert_find_index(dvert_dst, flip_map[dw_src->def_nr]);
+
+                               if (dw_dst) {
+                                       dw_dst->weight= dw_src->weight;
                                }
                        }
                }
@@ -138,18 +164,18 @@ void defvert_sync_mapped (MDeformVert *dvert_r, const MDeformVert *dvert, const
 }
 
 /* be sure all flip_map values are valid */
-void defvert_remap (MDeformVert *dvert, int *map)
+void defvert_remap(MDeformVert *dvert, int *map)
 {
        MDeformWeight *dw;
        int i;
-       for(i=0, dw=dvert->dw; i<dvert->totweight; i++, dw++) {
+       for (i=0, dw=dvert->dw; i<dvert->totweight; i++, dw++) {
                dw->def_nr= map[dw->def_nr];
        }
 }
 
-void defvert_normalize (MDeformVert *dvert)
+void defvert_normalize(MDeformVert *dvert)
 {
-       if(dvert->totweight<=0) {
+       if (dvert->totweight<=0) {
                /* nothing */
        }
        else if (dvert->totweight==1) {
@@ -159,30 +185,30 @@ void defvert_normalize (MDeformVert *dvert)
                int i;
                float tot= 0.0f;
                MDeformWeight *dw;
-               for(i=0, dw=dvert->dw; i < dvert->totweight; i++, dw++)
+               for (i=0, dw=dvert->dw; i < dvert->totweight; i++, dw++)
                        tot += dw->weight;
 
-               if(tot > 0.0f) {
-                       for(i=0, dw=dvert->dw; i < dvert->totweight; i++, dw++)
+               if (tot > 0.0f) {
+                       for (i=0, dw=dvert->dw; i < dvert->totweight; i++, dw++)
                                dw->weight /= tot;
                }
        }
 }
 
-void defvert_flip (MDeformVert *dvert, const int *flip_map, const int flip_map_len)
+void defvert_flip(MDeformVert *dvert, const int *flip_map, const int flip_map_len)
 {
        MDeformWeight *dw;
        int i;
 
-       for(dw= dvert->dw, i=0; i<dvert->totweight; dw++, i++) {
-               if((dw->def_nr < flip_map_len) && (flip_map[dw->def_nr] >= 0)) {
+       for (dw= dvert->dw, i=0; i<dvert->totweight; dw++, i++) {
+               if ((dw->def_nr < flip_map_len) && (flip_map[dw->def_nr] >= 0)) {
                        dw->def_nr= flip_map[dw->def_nr];
                }
        }
 }
 
 
-bDeformGroup *defgroup_find_name (Object *ob, const char *name)
+bDeformGroup *defgroup_find_name(Object *ob, const char *name)
 {
        /* return a pointer to the deform group with this name
         * or return NULL otherwise.
@@ -197,7 +223,7 @@ bDeformGroup *defgroup_find_name (Object *ob, const char *name)
        return NULL;
 }
 
-int defgroup_name_index (Object *ob, const char *name)
+int defgroup_name_index(Object *ob, const char *name)
 {
        /* Return the location of the named deform group within the list of
         * deform groups. This function is a combination of defgroup_find_index and
@@ -206,8 +232,8 @@ int defgroup_name_index (Object *ob, const char *name)
         */
        bDeformGroup *curdef;
        int def_nr;
-       
-       if(name && name[0] != '\0') {
+
+       if (name && name[0] != '\0') {
                for (curdef=ob->defbase.first, def_nr=0; curdef; curdef=curdef->next, def_nr++) {
                        if (!strcmp(curdef->name, name))
                                return def_nr;
@@ -217,7 +243,7 @@ int defgroup_name_index (Object *ob, const char *name)
        return -1;
 }
 
-int defgroup_find_index (Object *ob, bDeformGroup *dg)
+int defgroup_find_index(Object *ob, bDeformGroup *dg)
 {
        /* Fetch the location of this deform group
         * within the linked list of deform groups.
@@ -253,7 +279,7 @@ int defgroup_find_index (Object *ob, bDeformGroup *dg)
         * constant for this)
         */
        if (eg == NULL) return -1;
-       
+
        return def_nr;
 }
 
@@ -262,7 +288,7 @@ int *defgroup_flip_map(Object *ob, int *flip_map_len, int use_default)
 {
        int totdg= *flip_map_len= BLI_countlist(&ob->defbase);
 
-       if(totdg==0) {
+       if (totdg==0) {
                return NULL;
        }
        else {
@@ -275,16 +301,16 @@ int *defgroup_flip_map(Object *ob, int *flip_map_len, int use_default)
                }
 
                for (dg=ob->defbase.first, i=0; dg; dg=dg->next, i++) {
-                       if(map[i] == -1) { /* may be calculated previously */
+                       if (map[i] == -1) { /* may be calculated previously */
 
                                /* incase no valid value is found, use this */
-                               if(use_default)
+                               if (use_default)
                                        map[i]= i;
 
                                flip_side_name(name, dg->name, FALSE);
-                               if(strcmp(name, dg->name)) {
+                               if (strcmp(name, dg->name)) {
                                        flip_num= defgroup_name_index(ob, name);
-                                       if(flip_num >= 0) {
+                                       if (flip_num >= 0) {
                                                map[i]= flip_num;
                                                map[flip_num]= i; /* save an extra lookup */
                                        }
@@ -300,7 +326,7 @@ int *defgroup_flip_map_single(Object *ob, int *flip_map_len, int use_default, in
 {
        int totdg= *flip_map_len= BLI_countlist(&ob->defbase);
 
-       if(totdg==0) {
+       if (totdg==0) {
                return NULL;
        }
        else {
@@ -316,10 +342,10 @@ int *defgroup_flip_map_single(Object *ob, int *flip_map_len, int use_default, in
                dg= BLI_findlink(&ob->defbase, defgroup);
 
                flip_side_name(name, dg->name, FALSE);
-               if(strcmp(name, dg->name)) {
+               if (strcmp(name, dg->name)) {
                        flip_num= defgroup_name_index(ob, name);
 
-                       if(flip_num >= 0) {
+                       if (flip_num >= 0) {
                                map[defgroup]= flip_num;
                                map[flip_num]= defgroup;
                        }
@@ -334,11 +360,11 @@ int defgroup_flip_index(Object *ob, int index, int use_default)
        bDeformGroup *dg= BLI_findlink(&ob->defbase, index);
        int flip_index = -1;
 
-       if(dg) {
+       if (dg) {
                char name[sizeof(dg->name)];
                flip_side_name(name, dg->name, 0);
 
-               if(strcmp(name, dg->name))
+               if (strcmp(name, dg->name))
                        flip_index= defgroup_name_index(ob, name);
        }
 
@@ -348,7 +374,7 @@ int defgroup_flip_index(Object *ob, int index, int use_default)
 static int defgroup_find_name_dupe(const char *name, bDeformGroup *dg, Object *ob)
 {
        bDeformGroup *curdef;
-       
+
        for (curdef = ob->defbase.first; curdef; curdef=curdef->next) {
                if (dg!=curdef) {
                        if (!strcmp(curdef->name, name)) {
@@ -366,7 +392,7 @@ static int defgroup_unique_check(void *arg, const char *name)
        return defgroup_find_name_dupe(name, data->dg, data->ob);
 }
 
-void defgroup_unique_name (bDeformGroup *dg, Object *ob)
+void defgroup_unique_name(bDeformGroup *dg, Object *ob)
 {
        struct {Object *ob; void *dg;} data;
        data.ob= ob;
@@ -378,7 +404,7 @@ void defgroup_unique_name (bDeformGroup *dg, Object *ob)
 /* finds the best possible flipped name. For renaming; check for unique names afterwards */
 /* if strip_number: removes number extensions
  * note: dont use sizeof() for 'name' or 'from_name' */
-void flip_side_name (char name[MAX_VGROUP_NAME], const char from_name[MAX_VGROUP_NAME], int strip_number)
+void flip_side_name(char name[MAX_VGROUP_NAME], const char from_name[MAX_VGROUP_NAME], int strip_number)
 {
        int     len;
        char    prefix[MAX_VGROUP_NAME]=  "";   /* The part before the facing */
@@ -388,15 +414,15 @@ void flip_side_name (char name[MAX_VGROUP_NAME], const char from_name[MAX_VGROUP
        char    *index=NULL;
 
        len= BLI_strnlen(from_name, MAX_VGROUP_NAME);
-       if(len<3) return; // we don't do names like .R or .L
+       if (len < 3) return; // we don't do names like .R or .L
 
        BLI_strncpy(name, from_name, MAX_VGROUP_NAME);
 
        /* We first check the case with a .### extension, let's find the last period */
-       if(isdigit(name[len-1])) {
+       if (isdigit(name[len-1])) {
                index= strrchr(name, '.'); // last occurrence
                if (index && isdigit(index[1]) ) { // doesnt handle case bone.1abc2 correct..., whatever!
-                       if(strip_number==0)
+                       if (strip_number==0)
                                BLI_strncpy(number, index, sizeof(number));
                        *index= 0;
                        len= BLI_strnlen(name, MAX_VGROUP_NAME);
@@ -408,7 +434,7 @@ void flip_side_name (char name[MAX_VGROUP_NAME], const char from_name[MAX_VGROUP
 #define IS_SEPARATOR(a) ((a)=='.' || (a)==' ' || (a)=='-' || (a)=='_')
 
        /* first case; separator . - _ with extensions r R l L  */
-       ifIS_SEPARATOR(name[len-2]) ) {
+       if (IS_SEPARATOR(name[len-2]) ) {
                switch(name[len-1]) {
                        case 'l':
                                prefix[len-1]= 0;
@@ -429,7 +455,7 @@ void flip_side_name (char name[MAX_VGROUP_NAME], const char from_name[MAX_VGROUP
                }
        }
        /* case; beginning with r R l L , with separator after it */
-       else ifIS_SEPARATOR(name[1]) ) {
+       else if (IS_SEPARATOR(name[1]) ) {
                switch(name[0]) {
                        case 'l':
                                strcpy(replace, "r");
@@ -453,14 +479,14 @@ void flip_side_name (char name[MAX_VGROUP_NAME], const char from_name[MAX_VGROUP
                                break;
                }
        }
-       else if(len > 5) {
+       else if (len > 5) {
                /* hrms, why test for a separator? lets do the rule 'ultimate left or right' */
                index = BLI_strcasestr(prefix, "right");
                if (index==prefix || index==prefix+len-5) {
-                       if(index[0]=='r')
+                       if (index[0]=='r')
                                strcpy (replace, "left");
                        else {
-                               if(index[1]=='I')
+                               if (index[1]=='I')
                                        strcpy (replace, "LEFT");
                                else
                                        strcpy (replace, "Left");
@@ -471,10 +497,10 @@ void flip_side_name (char name[MAX_VGROUP_NAME], const char from_name[MAX_VGROUP
                else {
                        index = BLI_strcasestr(prefix, "left");
                        if (index==prefix || index==prefix+len-4) {
-                               if(index[0]=='l')
+                               if (index[0]=='l')
                                        strcpy (replace, "right");
                                else {
-                                       if(index[1]=='E')
+                                       if (index[1]=='E')
                                                strcpy (replace, "RIGHT");
                                        else
                                                strcpy (replace, "Right");
@@ -490,30 +516,32 @@ void flip_side_name (char name[MAX_VGROUP_NAME], const char from_name[MAX_VGROUP
        BLI_snprintf (name, MAX_VGROUP_NAME, "%s%s%s%s", prefix, replace, suffix, number);
 }
 
-float defvert_find_weight(const struct MDeformVert *dvert, const int group_num)
+float defvert_find_weight(const struct MDeformVert *dvert, const int defgroup)
 {
-       MDeformWeight *dw= defvert_find_index(dvert, group_num);
+       MDeformWeight *dw= defvert_find_index(dvert, defgroup);
        return dw ? dw->weight : 0.0f;
 }
 
-float defvert_array_find_weight_safe(const struct MDeformVert *dvert, int index, int group_num)
+float defvert_array_find_weight_safe(const struct MDeformVert *dvert, const int index, const int defgroup)
 {
-       if(group_num == -1 || dvert == NULL)
+       if (defgroup == -1 || dvert == NULL)
                return 1.0f;
 
-       return defvert_find_weight(dvert+index, group_num);
+       return defvert_find_weight(dvert+index, defgroup);
 }
 
 
 MDeformWeight *defvert_find_index(const MDeformVert *dvert, const int defgroup)
 {
-       if(dvert && defgroup >= 0) {
+       if (dvert && defgroup >= 0) {
                MDeformWeight *dw = dvert->dw;
                int i;
 
-               for(i=dvert->totweight; i>0; i--, dw++)
-                       if(dw->def_nr == defgroup)
+               for (i=dvert->totweight; i>0; i--, dw++) {
+                       if (dw->def_nr == defgroup) {
                                return dw;
+                       }
+               }
        }
 
        return NULL;
@@ -521,30 +549,74 @@ MDeformWeight *defvert_find_index(const MDeformVert *dvert, const int defgroup)
 
 /* Ensures that mv has a deform weight entry for the specified defweight group */
 /* Note this function is mirrored in editmesh_tools.c, for use for editvertices */
-MDeformWeight *defvert_verify_index(MDeformVert *dv, const int defgroup)
+MDeformWeight *defvert_verify_index(MDeformVert *dvert, const int defgroup)
 {
-       MDeformWeight *newdw;
+       MDeformWeight *dw_new;
 
        /* do this check always, this function is used to check for it */
-       if(!dv || defgroup < 0)
+       if (!dvert || defgroup < 0)
                return NULL;
 
-       newdw= defvert_find_index(dv, defgroup);
-       if(newdw)
-               return newdw;
+       dw_new= defvert_find_index(dvert, defgroup);
+       if (dw_new)
+               return dw_new;
 
-       newdw= BLI_cellalloc_calloc(sizeof(MDeformWeight)*(dv->totweight+1), "deformWeight");
-       if(dv->dw) {
-               memcpy(newdw, dv->dw, sizeof(MDeformWeight)*dv->totweight);
-               BLI_cellalloc_free(dv->dw);
+       dw_new= BLI_cellalloc_calloc(sizeof(MDeformWeight)*(dv->totweight+1), "deformWeight");
+       if (dvert->dw) {
+               memcpy(dw_new, dvert->dw, sizeof(MDeformWeight)*dvert->totweight);
+               BLI_cellalloc_free(dvert->dw);
        }
-       dv->dw= newdw;
-       newdw += dv->totweight;
-       newdw->weight= 0.0f;
-       newdw->def_nr= defgroup;
+       dvert->dw= dw_new;
+       dw_new += dvert->totweight;
+       dw_new->weight= 0.0f;
+       dw_new->def_nr= defgroup;
        /* Group index */
 
-       dv->totweight++;
+       dvert->totweight++;
+
+       return dw_new;
+}
+
+/* Removes the given vertex from the vertex group, specified either by its defgrp_idx,
+ * or directly by its MDeformWeight pointer, if dw is not NULL.
+ * WARNING: This function frees the given MDeformWeight, do not use it afterward! */
+void defvert_remove_index(MDeformVert *dvert, int defgroup, MDeformWeight *dw)
+{
+       MDeformWeight *dw_new;
+       int i;
+
+       /* Get index of removed MDeformWeight. */
+       if (dw == NULL) {
+               dw = dvert->dw;
+               for (i = dvert->totweight; i > 0; i--, dw++) {
+                       if (dw->def_nr == defgroup)
+                               break;
+               }
+               i--;
+       }
+       else {
+               i = dw - dvert->dw;
+               /* Security check! */
+               if(i < 0 || i >= dvert->totweight)
+                       return;
+       }
 
-       return newdw;
+       dvert->totweight--;
+       /* If there are still other deform weights attached to this vert then remove
+        * this deform weight, and reshuffle the others.
+        */
+       if (dvert->totweight) {
+               dw_new = BLI_cellalloc_malloc(sizeof(MDeformWeight)*(dvert->totweight), __func__);
+               if (dvert->dw){
+                       memcpy(dw_new, dvert->dw, sizeof(MDeformWeight)*i);
+                       memcpy(dw_new+i, dvert->dw+i+1, sizeof(MDeformWeight)*(dvert->totweight-i));
+                       BLI_cellalloc_free(dvert->dw);
+               }
+               dvert->dw = dw_new;
+       }
+       else {
+               /* If there are no other deform weights left then just remove this one. */
+               BLI_cellalloc_free(dvert->dw);
+               dvert->dw = NULL;
+       }
 }
index c7f74f37a2d83604561c50f9212ff716fcf0788c..fb734ea4f3d506edfbb351f29a6e9637805042ea 100644 (file)
@@ -385,19 +385,19 @@ void make_local_image(struct Image *ima)
                extern_local_image(ima);
        }
        else if(is_local && is_lib) {
-               Image *iman= copy_image(ima);
+               Image *ima_new= copy_image(ima);
 
-               iman->id.us= 0;
+               ima_new->id.us= 0;
 
                /* Remap paths of new ID using old library as base. */
-               BKE_id_lib_local_paths(bmain, &iman->id);
+               BKE_id_lib_local_paths(bmain, ima->id.lib, &ima_new->id);
 
                tex= bmain->tex.first;
                while(tex) {
                        if(tex->id.lib==NULL) {
                                if(tex->ima==ima) {
-                                       tex->ima = iman;
-                                       iman->id.us++;
+                                       tex->ima = ima_new;
+                                       ima_new->id.us++;
                                        ima->id.us--;
                                }
                        }
@@ -407,8 +407,8 @@ void make_local_image(struct Image *ima)
                while(brush) {
                        if(brush->id.lib==NULL) {
                                if(brush->clone.image==ima) {
-                                       brush->clone.image = iman;
-                                       iman->id.us++;
+                                       brush->clone.image = ima_new;
+                                       ima_new->id.us++;
                                        ima->id.us--;
                                }
                        }
@@ -429,11 +429,11 @@ void make_local_image(struct Image *ima)
 
                                                for(a=0; a<me->totface; a++, tface++) { 
                                                        if(tface->tpage == ima) {
-                                                               tface->tpage = iman;
-                                                               if(iman->id.us == 0) {
+                                                               tface->tpage = ima_new;
+                                                               if(ima_new->id.us == 0) {
                                                                        tface->tpage->id.us= 1;
                                                                }
-                                                               id_lib_extern((ID*)iman);
+                                                               id_lib_extern((ID*)ima_new);
                                                        }
                                                }
                                        }
index 4edd032dc0445815cad306dd633a239f5b137166..6b4cdc70aeae693b18b22d9615704a0d3142d93a 100644 (file)
@@ -184,19 +184,19 @@ void make_local_lamp(Lamp *la)
                id_clear_lib_data(bmain, &la->id);
        }
        else if(is_local && is_lib) {
-               Lamp *lan= copy_lamp(la);
-               lan->id.us= 0;
+               Lamp *la_new= copy_lamp(la);
+               la_new->id.us= 0;
 
                /* Remap paths of new ID using old library as base. */
-               BKE_id_lib_local_paths(bmain, &lan->id);
+               BKE_id_lib_local_paths(bmain, la->id.lib, &la_new->id);
 
                ob= bmain->object.first;
                while(ob) {
                        if(ob->data==la) {
                                
                                if(ob->id.lib==NULL) {
-                                       ob->data= lan;
-                                       lan->id.us++;
+                                       ob->data= la_new;
+                                       la_new->id.us++;
                                        la->id.us--;
                                }
                        }
index 7c9e2be4493befd2d73f3a32d4c2866f41bd0441..4f02fdd1f46a42b1ae5a229b4eccb882491a74cf 100644 (file)
@@ -271,17 +271,17 @@ void make_local_lattice(Lattice *lt)
                id_clear_lib_data(bmain, &lt->id);
        }
        else if(is_local && is_lib) {
-               Lattice *ltn= copy_lattice(lt);
-               ltn->id.us= 0;
+               Lattice *lt_new= copy_lattice(lt);
+               lt_new->id.us= 0;
 
                /* Remap paths of new ID using old library as base. */
-               BKE_id_lib_local_paths(bmain, &ltn->id);
+               BKE_id_lib_local_paths(bmain, lt->id.lib, &lt_new->id);
 
                for(ob= bmain->object.first; ob; ob= ob->id.next) {
                        if(ob->data==lt) {
                                if(ob->id.lib==NULL) {
-                                       ob->data= ltn;
-                                       ltn->id.us++;
+                                       ob->data= lt_new;
+                                       lt_new->id.us++;
                                        lt->id.us--;
                                }
                        }
index 4155551763ece5cff3342062cb1242623424b390..28524668bd3af0c8a8f36bf8aeea1a1c0480c424 100644 (file)
  * from id_make_local() but then the make local functions would not be self
  * contained.
  * also note that the id _must_ have a library - campbell */
-void BKE_id_lib_local_paths(Main *bmain, ID *id)
+void BKE_id_lib_local_paths(Main *bmain, Library *lib, ID *id)
 {
-       char *bpath_user_data[2]= {bmain->name, (id)->lib->filepath};
+       char *bpath_user_data[2]= {bmain->name, lib->filepath};
 
        bpath_traverse_id(bmain, id,
                                          bpath_relocate_visitor,
@@ -1278,7 +1278,7 @@ int new_id(ListBase *lb, ID *id, const char *tname)
    don't have other library users. */
 void id_clear_lib_data(Main *bmain, ID *id)
 {
-       BKE_id_lib_local_paths(bmain, id);
+       BKE_id_lib_local_paths(bmain, id->lib, id);
 
        id->lib= NULL;
        id->flag= LIB_LOCAL;
index ecf74b1d8e1befa82d9db3c44b3c1b10ee30a963..60ae86063e8d943c124fc3ff37592eb57a2296fd 100644 (file)
@@ -364,12 +364,12 @@ void make_local_material(Material *ma)
        }
        /* Both user and local, so copy. */
        else if(is_local && is_lib) {
-               Material *man= copy_material(ma);
+               Material *ma_new= copy_material(ma);
 
-               man->id.us= 0;
+               ma_new->id.us= 0;
 
                /* Remap paths of new ID using old library as base. */
-               BKE_id_lib_local_paths(bmain, &man->id);
+               BKE_id_lib_local_paths(bmain, ma->id.lib, &ma_new->id);
 
                /* do objects */
                ob= bmain->object.first;
@@ -378,8 +378,8 @@ void make_local_material(Material *ma)
                                for(a=0; a<ob->totcol; a++) {
                                        if(ob->mat[a]==ma) {
                                                if(ob->id.lib==NULL) {
-                                                       ob->mat[a]= man;
-                                                       man->id.us++;
+                                                       ob->mat[a]= ma_new;
+                                                       ma_new->id.us++;
                                                        ma->id.us--;
                                                }
                                        }
@@ -394,8 +394,8 @@ void make_local_material(Material *ma)
                                for(a=0; a<me->totcol; a++) {
                                        if(me->mat[a]==ma) {
                                                if(me->id.lib==NULL) {
-                                                       me->mat[a]= man;
-                                                       man->id.us++;
+                                                       me->mat[a]= ma_new;
+                                                       ma_new->id.us++;
                                                        ma->id.us--;
                                                }
                                        }
@@ -410,8 +410,8 @@ void make_local_material(Material *ma)
                                for(a=0; a<cu->totcol; a++) {
                                        if(cu->mat[a]==ma) {
                                                if(cu->id.lib==NULL) {
-                                                       cu->mat[a]= man;
-                                                       man->id.us++;
+                                                       cu->mat[a]= ma_new;
+                                                       ma_new->id.us++;
                                                        ma->id.us--;
                                                }
                                        }
@@ -426,8 +426,8 @@ void make_local_material(Material *ma)
                                for(a=0; a<mb->totcol; a++) {
                                        if(mb->mat[a]==ma) {
                                                if(mb->id.lib==NULL) {
-                                                       mb->mat[a]= man;
-                                                       man->id.us++;
+                                                       mb->mat[a]= ma_new;
+                                                       ma_new->id.us++;
                                                        ma->id.us--;
                                                }
                                        }
index 3e3f16dcfa39030c2e3bfbc474ac71b3ce108df5..0883ec121d6f32e6ac1e863d27dedbccabe36967 100644 (file)
@@ -174,17 +174,17 @@ void make_local_mball(MetaBall *mb)
                extern_local_mball(mb);
        }
        else if(is_local && is_lib) {
-               MetaBall *mbn= copy_mball(mb);
-               mbn->id.us= 0;
+               MetaBall *mb_new= copy_mball(mb);
+               mb_new->id.us= 0;
 
                /* Remap paths of new ID using old library as base. */
-               BKE_id_lib_local_paths(bmain, &mbn->id);
+               BKE_id_lib_local_paths(bmain, mb->id.lib, &mb_new->id);
 
                for(ob= G.main->object.first; ob; ob= ob->id.next) {
                        if(ob->data == mb) {
                                if(ob->id.lib==NULL) {
-                                       ob->data= mbn;
-                                       mbn->id.us++;
+                                       ob->data= mb_new;
+                                       mb_new->id.us++;
                                        mb->id.us--;
                                }
                        }
index 5b12425ef104cc7d1990011882b9ff5aaa8cbac8..b683d74d5f7f1a80fe8ef7b44e59e9855e7fb2a3 100644 (file)
@@ -655,15 +655,15 @@ void make_local_mesh(Mesh *me)
                expand_local_mesh(me);
        }
        else if(local && lib) {
-               Mesh *men= copy_mesh(me);
-               men->id.us= 0;
+               Mesh *me_new= copy_mesh(me);
+               me_new->id.us= 0;
 
-               BKE_id_lib_local_paths(bmain, &men->id);
+               BKE_id_lib_local_paths(bmain, me->id.lib, &me_new->id);
 
                for(ob= bmain->object.first; ob; ob= ob->id.next) {
                        if(me == ob->data) {
                                if(ob->id.lib==NULL) {
-                                       set_mesh(ob, men);
+                                       set_mesh(ob, me_new);
                                }
                        }
                }
index ffa2a36dcf621f9715601e90b05c815c5adcdf7b..79857c7658cf3ffc8c8518f898471b4697ddbe04 100644 (file)
@@ -121,6 +121,7 @@ void clear_workob(Object *workob)
        memset(workob, 0, sizeof(Object));
        
        workob->size[0]= workob->size[1]= workob->size[2]= 1.0f;
+       workob->dsize[0]= workob->dsize[1]= workob->dsize[2]= 1.0f;
        workob->rotmode= ROT_MODE_EUL;
 }
 
@@ -775,6 +776,7 @@ Object *add_only_object(int type, const char *name)
        ob->col[3]= 1.0;
        
        ob->size[0]= ob->size[1]= ob->size[2]= 1.0;
+       ob->dsize[0]= ob->dsize[1]= ob->dsize[2]= 1.0;
        
        /* objects should default to having Euler XYZ rotations, 
         * but rotations default to quaternions 
@@ -1233,12 +1235,12 @@ void make_local_object(Object *ob)
                        extern_local_object(ob);
                }
                else if(is_local && is_lib) {
-                       Object *obn= copy_object(ob);
+                       Object *ob_new= copy_object(ob);
 
-                       obn->id.us= 0;
+                       ob_new->id.us= 0;
                        
                        /* Remap paths of new ID using old library as base. */
-                       BKE_id_lib_local_paths(bmain, &obn->id);
+                       BKE_id_lib_local_paths(bmain, ob->id.lib, &ob_new->id);
 
                        sce= bmain->scene.first;
                        while(sce) {
@@ -1246,8 +1248,8 @@ void make_local_object(Object *ob)
                                        base= sce->base.first;
                                        while(base) {
                                                if(base->object==ob) {
-                                                       base->object= obn;
-                                                       obn->id.us++;
+                                                       base->object= ob_new;
+                                                       ob_new->id.us++;
                                                        ob->id.us--;
                                                }
                                                base= base->next;
@@ -1442,7 +1444,7 @@ void object_make_proxy(Object *ob, Object *target, Object *gob)
 void object_scale_to_mat3(Object *ob, float mat[][3])
 {
        float vec[3];
-       add_v3_v3v3(vec, ob->size, ob->dsize);
+       mul_v3_v3v3(vec, ob->size, ob->dsize);
        size_to_mat3( mat,vec);
 }
 
@@ -1604,7 +1606,11 @@ void object_apply_mat4(Object *ob, float mat[][4], const short use_compat, const
        }
        
        sub_v3_v3(ob->loc, ob->dloc);
-       sub_v3_v3(ob->size, ob->dsize);
+
+       if (ob->dsize[0] != 0.0f) ob->size[0] /= ob->dsize[0];
+       if (ob->dsize[1] != 0.0f) ob->size[1] /= ob->dsize[1];
+       if (ob->dsize[2] != 0.0f) ob->size[2] /= ob->dsize[2];
+
        /* object_mat3_to_rot handles delta rotations */
 }
 
index d61541155bf5d01acee78bfe7bdf7dae70cdbaba..56d29467ac73d45a7a1aba1f067ad4f311a8e468 100644 (file)
@@ -3645,19 +3645,19 @@ void make_local_particlesettings(ParticleSettings *part)
                expand_local_particlesettings(part);
        }
        else if(is_local && is_lib) {
-               ParticleSettings *partn= psys_copy_settings(part);
-               partn->id.us= 0;
+               ParticleSettings *part_new= psys_copy_settings(part);
+               part_new->id.us= 0;
 
                /* Remap paths of new ID using old library as base. */
-               BKE_id_lib_local_paths(bmain, &partn->id);
+               BKE_id_lib_local_paths(bmain, part->id.lib, &part_new->id);
 
                /* do objects */
                for(ob= bmain->object.first; ob; ob= ob->id.next) {
                        ParticleSystem *psys;
                        for(psys= ob->particlesystem.first; psys; psys=psys->next){
                                if(psys->part==part && ob->id.lib==0) {
-                                       psys->part= partn;
-                                       partn->id.us++;
+                                       psys->part= part_new;
+                                       part_new->id.us++;
                                        part->id.us--;
                                }
                        }
index a14233e9179ff7b6410b7fb6f80af97421cb3ca9..d2c8a8031eeac894cc4321d7fe85794029a8e846 100644 (file)
@@ -106,19 +106,19 @@ void make_local_speaker(Speaker *spk)
                id_clear_lib_data(bmain, &spk->id);
        }
        else if(is_local && is_lib) {
-               Speaker *spkn= copy_speaker(spk);
-               spkn->id.us= 0;
+               Speaker *spk_new= copy_speaker(spk);
+               spk_new->id.us= 0;
 
                /* Remap paths of new ID using old library as base. */
-               BKE_id_lib_local_paths(bmain, &spkn->id);
+               BKE_id_lib_local_paths(bmain, spk->id.lib, &spk_new->id);
 
                ob= bmain->object.first;
                while(ob) {
                        if(ob->data==spk) {
 
                                if(ob->id.lib==NULL) {
-                                       ob->data= spkn;
-                                       spkn->id.us++;
+                                       ob->data= spk_new;
+                                       spk_new->id.us++;
                                        spk->id.us--;
                                }
                        }
index a67a61c763857a5fd2ca23104eb25eb0693e25e9..13205326dd25b85dd8bf8e0b38bc316e28e846e0 100644 (file)
@@ -973,20 +973,20 @@ void make_local_texture(Tex *tex)
                extern_local_texture(tex);
        }
        else if(is_local && is_lib) {
-               Tex *texn= copy_texture(tex);
+               Tex *tex_new= copy_texture(tex);
 
-               texn->id.us= 0;
+               tex_new->id.us= 0;
 
                /* Remap paths of new ID using old library as base. */
-               BKE_id_lib_local_paths(bmain, &texn->id);
+               BKE_id_lib_local_paths(bmain, tex->id.lib, &tex_new->id);
                
                ma= bmain->mat.first;
                while(ma) {
                        for(a=0; a<MAX_MTEX; a++) {
                                if(ma->mtex[a] && ma->mtex[a]->tex==tex) {
                                        if(ma->id.lib==NULL) {
-                                               ma->mtex[a]->tex= texn;
-                                               texn->id.us++;
+                                               ma->mtex[a]->tex= tex_new;
+                                               tex_new->id.us++;
                                                tex->id.us--;
                                        }
                                }
@@ -998,8 +998,8 @@ void make_local_texture(Tex *tex)
                        for(a=0; a<MAX_MTEX; a++) {
                                if(la->mtex[a] && la->mtex[a]->tex==tex) {
                                        if(la->id.lib==NULL) {
-                                               la->mtex[a]->tex= texn;
-                                               texn->id.us++;
+                                               la->mtex[a]->tex= tex_new;
+                                               tex_new->id.us++;
                                                tex->id.us--;
                                        }
                                }
@@ -1011,8 +1011,8 @@ void make_local_texture(Tex *tex)
                        for(a=0; a<MAX_MTEX; a++) {
                                if(wrld->mtex[a] && wrld->mtex[a]->tex==tex) {
                                        if(wrld->id.lib==NULL) {
-                                               wrld->mtex[a]->tex= texn;
-                                               texn->id.us++;
+                                               wrld->mtex[a]->tex= tex_new;
+                                               tex_new->id.us++;
                                                tex->id.us--;
                                        }
                                }
@@ -1023,8 +1023,8 @@ void make_local_texture(Tex *tex)
                while(br) {
                        if(br->mtex.tex==tex) {
                                if(br->id.lib==NULL) {
-                                       br->mtex.tex= texn;
-                                       texn->id.us++;
+                                       br->mtex.tex= tex_new;
+                                       tex_new->id.us++;
                                        tex->id.us--;
                                }
                        }
@@ -1035,8 +1035,8 @@ void make_local_texture(Tex *tex)
                        for(a=0; a<MAX_MTEX; a++) {
                                if(pa->mtex[a] && pa->mtex[a]->tex==tex) {
                                        if(pa->id.lib==NULL) {
-                                               pa->mtex[a]->tex= texn;
-                                               texn->id.us++;
+                                               pa->mtex[a]->tex= tex_new;
+                                               tex_new->id.us++;
                                                tex->id.us--;
                                        }
                                }
index 1d6972b9d611cafe8771a1378fdd2c6bb4666cfa..b3f1e140829d567e4ce97b41ca8fd03f58f9c30f 100644 (file)
@@ -190,17 +190,17 @@ void make_local_world(World *wrld)
                id_clear_lib_data(bmain, &wrld->id);
        }
        else if(is_local && is_lib) {
-               World *wrldn= copy_world(wrld);
-               wrldn->id.us= 0;
+               World *wrld_new= copy_world(wrld);
+               wrld_new->id.us= 0;
 
                /* Remap paths of new ID using old library as base. */
-               BKE_id_lib_local_paths(bmain, &wrldn->id);
+               BKE_id_lib_local_paths(bmain, wrld->id.lib, &wrld_new->id);
 
                for(sce= bmain->scene.first; sce; sce= sce->id.next) {
                        if(sce->world == wrld) {
                                if(sce->id.lib==NULL) {
-                                       sce->world= wrldn;
-                                       wrldn->id.us++;
+                                       sce->world= wrld_new;
+                                       wrld_new->id.us++;
                                        wrld->id.us--;
                                }
                        }
index aa44eca0605f5ac7b318cabd99696d97f9935ba0..cd07bb30d3a3207620a03d210ad236b316d4349b 100644 (file)
@@ -12049,7 +12049,6 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                }
        }
 
-       /* put compatibility code here until next subversion bump */
        if (main->versionfile < 255 || (main->versionfile == 255 && main->subversionfile < 3)) {
                Object *ob;
 
@@ -12066,8 +12065,6 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                }               
        }
 
-       /* put compatibility code here until next subversion bump */
-       
        if (main->versionfile < 256) {
                bScreen *sc;
                ScrArea *sa;
@@ -12686,16 +12683,14 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                }
        }
 
-       /* put compatibility code here until next subversion bump */
+       if (main->versionfile < 260 || (main->versionfile == 260 && main->subversionfile < 6))
        {
                Scene *sce;
                MovieClip *clip;
                bScreen *sc;
 
                for(sce = main->scene.first; sce; sce = sce->id.next) {
-                       if (sce->r.im_format.depth == 0) {
-                               do_versions_image_settings_2_60(sce);
-                       }
+                       do_versions_image_settings_2_60(sce);
                }
 
                for (clip= main->movieclip.first; clip; clip= clip->id.next) {
@@ -12722,6 +12717,29 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                                }
                        }
                }
+
+               {
+                       Object *ob;
+                       for (ob= main->object.first; ob; ob= ob->id.next) {
+                               /* convert delta addition into delta scale */
+                               int i;
+                               for (i= 0; i < 3; i++) {
+                                       if ( (ob->dsize[i] == 0.0f) || /* simple case, user never touched dsize */
+                                            (ob->size[i]  == 0.0f))   /* cant scale the dsize to give a non zero result, so fallback to 1.0f */
+                                       {
+                                               ob->dsize[i]= 1.0f;
+                                       }
+                                       else {
+                                               ob->size[i]= (ob->size[i] + ob->dsize[i]) / ob->size[i];
+                                       }
+                               }
+                       }
+               }
+       }
+
+       /* put compatibility code here until next subversion bump */
+       {
+               /* nothing! */
        }
 
        /* WATCH IT!!!: pointers from libdata have not been converted yet here! */
index 05537004927d7601fae2c41cd1aeb1552703cd45..e0ff5cddf859c9b5fd91f824498e12df44bba756 100644 (file)
@@ -65,6 +65,7 @@ void  ED_region_header_init(struct ARegion *ar);
 void   ED_region_header(const struct bContext *C, struct ARegion *ar);
 void   ED_region_toggle_hidden(struct bContext *C, struct ARegion *ar);
 void   region_scissor_winrct(struct ARegion *ar, struct rcti *winrct);
+void   ED_region_info_draw(struct ARegion *ar, const char *text, int block, float alpha);
 
 /* spaces */
 void   ED_spacetypes_init(void);
index 38b0c2f6d382e6a269b0348884ba7c38558eb8d8..1edfa2f4ea69d4426de30ebe0474ac9254cba92a 100644 (file)
@@ -455,6 +455,7 @@ static void ui_draw_aligned_panel_header(uiStyle *style, uiBlock *block, rcti *r
        hrect= *rect;
        if(dir == 'h') {
                hrect.xmin= rect->xmin+pnl_icons;
+               hrect.ymin += 2.0f/block->aspect;
                uiStyleFontDraw(&style->paneltitle, &hrect, activename);
        }
        else {
@@ -519,9 +520,9 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, rcti *rect)
                        maxx -= 5.0f/block->aspect;
                        
                        glColor4f(0.0f, 0.0f, 0.0f, 0.5f);
-                       fdrawline(minx, y+1, maxx, y+1);
-                       glColor4f(1.0f, 1.0f, 1.0f, 0.25f);
                        fdrawline(minx, y, maxx, y);
+                       glColor4f(1.0f, 1.0f, 1.0f, 0.25f);
+                       fdrawline(minx, y-1, maxx, y-1);
                        glDisable(GL_BLEND);
                }
 
index 40d52e0b2618e32a7777534186121c566a5d976a..2a45a7df735bf7af3c3e6bf967ecf3f38f642531 100644 (file)
@@ -766,7 +766,7 @@ static int childof_set_inverse_exec (bContext *C, wmOperator *op)
                where_is_pose(scene, ob);
        }
        else if (ob) {
-               Object workob = {{NULL}};
+               Object workob;
                
                /* use what_does_parent to find inverse - just like for normal parenting */
                what_does_parent(scene, ob, &workob);
index b4fee991bb28b530be9a887354c70c172f448615..9d8112c323addddfee57589ca28896c89df78e22 100644 (file)
@@ -189,15 +189,15 @@ static void object_clear_scale(Object *ob)
 {
        /* clear scale factors which are not locked */
        if ((ob->protectflag & OB_LOCK_SCALEX)==0) {
-               ob->dsize[0]= 0.0f;
+               ob->dsize[0]= 1.0f;
                ob->size[0]= 1.0f;
        }
        if ((ob->protectflag & OB_LOCK_SCALEY)==0) {
-               ob->dsize[1]= 0.0f;
+               ob->dsize[1]= 1.0f;
                ob->size[1]= 1.0f;
        }
        if ((ob->protectflag & OB_LOCK_SCALEZ)==0) {
-               ob->dsize[2]= 0.0f;
+               ob->dsize[2]= 1.0f;
                ob->size[2]= 1.0f;
        }
 }
index 94328259dc327725dea371f2597f6bbe37916442..6e3fab0385fb74a4d710f51433d2d4cda47b4588 100644 (file)
@@ -1577,13 +1577,21 @@ static void dvert_mirror_op(MDeformVert *dvert, MDeformVert *dvert_mirr,
                }
        }
        else {
-               /* dvert should always be the target */
+               /* dvert should always be the target, only swaps pointer */
                if(sel_mirr) {
                        SWAP(MDeformVert *, dvert, dvert_mirr);
                }
 
-               if(mirror_weights)
-                       defvert_copy(dvert, dvert_mirr);
+               if(mirror_weights) {
+                       if (all_vgroups) {
+                               defvert_copy(dvert, dvert_mirr);
+                       }
+                       else {
+                               defvert_copy_index(dvert, dvert_mirr, act_vgroup);
+                       }
+               }
+
+               /* flip map already modified for 'all_vgroups' */
                if(flip_vgroups) {
                        defvert_flip(dvert, flip_map, flip_map_len);
                }
index 3a2d9f137d77fcd4a20becf6cb4f0845463befd9..35b21c626ed3914d703a662817a8a7346957b636 100644 (file)
@@ -123,17 +123,6 @@ static void screen_opengl_render_apply(OGLRender *oglrender)
 
        rr= RE_AcquireResultRead(oglrender->re);
        
-       /* note on color management:
-        * looked into how best to deal with color management here and found heres how it should work.
-        *
-        * OpenGL materials etc are color corrected, so a float buffer from the graphics card is
-        * color corrected, without running any conversion functions.
-        * 
-        * With color correction disabled blender expects the rr->rectf to be non-color managed so
-        * just do a direct copy from the byte array to the rectf with no conversion too.
-        * notice IMB_float_from_rect has the profile set so no conversion is done.
-        */
-
        if(view_context) {
                GPU_offscreen_bind(oglrender->ofs); /* bind */
 
@@ -208,13 +197,32 @@ static void screen_opengl_render_apply(OGLRender *oglrender)
        if((scene->r.stamp & R_STAMP_ALL) && (scene->r.stamp & R_STAMP_DRAW))
                BKE_stamp_buf(scene, camera, NULL, rr->rectf, rr->rectx, rr->recty, 4);
 
+       /* note on color management:
+        *
+        * OpenGL renders into sRGB colors, but render buffers are expected to be
+        * linear if color management is enabled. So we convert to linear here, so
+        * the conversion back to bytes using the color management flag can make it
+        * sRGB again, and so that e.g. openexr saving also saves the correct linear
+        * float buffer. */
+
+       if(oglrender->scene->r.color_mgt_flag & R_COLOR_MANAGEMENT) {
+               float *rctf = rr->rectf;
+               int i;
+
+               for (i = oglrender->sizex * oglrender->sizey; i > 0; i--, rctf+=4) {
+                       rctf[0]= srgb_to_linearrgb(rctf[0]);
+                       rctf[1]= srgb_to_linearrgb(rctf[1]);
+                       rctf[2]= srgb_to_linearrgb(rctf[2]);
+               }
+       }
+
        RE_ReleaseResult(oglrender->re);
 
        /* update byte from float buffer */
        ibuf= BKE_image_acquire_ibuf(oglrender->ima, &oglrender->iuser, &lock);
 
        if(ibuf) {
-               image_buffer_rect_update(NULL, rr, ibuf, NULL);
+               image_buffer_rect_update(scene, rr, ibuf, NULL);
 
                if(oglrender->write_still) {
                        char name[FILE_MAX];
@@ -307,15 +315,18 @@ static int screen_opengl_render_init(bContext *C, wmOperator *op)
                oglrender->scene->customdata_mask_modal= ED_view3d_datamask(oglrender->scene, oglrender->v3d);
        }
 
+       /* create render */
+       oglrender->re= RE_NewRender(scene->id.name);
+
        /* create image and image user */
        oglrender->ima= BKE_image_verify_viewer(IMA_TYPE_R_RESULT, "Render Result");
        BKE_image_signal(oglrender->ima, NULL, IMA_SIGNAL_FREE);
+       BKE_image_backup_render(oglrender->scene, oglrender->ima);
 
        oglrender->iuser.scene= scene;
        oglrender->iuser.ok= 1;
 
-       /* create render and render result */
-       oglrender->re= RE_NewRender(scene->id.name);
+       /* create render result */
        RE_InitState(oglrender->re, NULL, &scene->r, NULL, sizex, sizey, NULL);
 
        rr= RE_AcquireResultWrite(oglrender->re);
index 24c261095026e8c8edf73831c09badc46115088e..7aacd9f7b86f67b9bf23cd432e6d435fab1702d7 100644 (file)
@@ -1596,7 +1596,7 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, const char *
                        if(pt->draw_header && !(pt->flag & PNL_NO_HEADER) && (open || vertical)) {
                                /* for enabled buttons */
                                panel->layout= uiBlockLayout(block, UI_LAYOUT_HORIZONTAL, UI_LAYOUT_HEADER,
-                                       triangle, UI_UNIT_Y+style->panelspace, UI_UNIT_Y, 1, style);
+                                       triangle, UI_UNIT_Y+style->panelspace+2, UI_UNIT_Y, 1, style);
 
                                pt->draw_header(C, panel);
 
@@ -1776,3 +1776,38 @@ int ED_area_headersize(void)
 {
        return UI_UNIT_Y+6;
 }
+
+void ED_region_info_draw(ARegion *ar, const char *text, int block, float alpha)
+{
+       const int header_height = 18;
+       uiStyle *style= UI_GetStyle();
+       int fontid= style->widget.uifont_id;
+       rcti rect;
+
+       BLF_size(fontid, 11.0f, 72);
+
+       /* background box */
+       rect= ar->winrct;
+       rect.xmin= 0;
+       rect.ymin= ar->winrct.ymax - ar->winrct.ymin - header_height;
+
+       if(block) {
+               rect.xmax= ar->winrct.xmax - ar->winrct.xmin;
+       }
+       else {
+               rect.xmax= rect.xmin + BLF_width(fontid, text) + 24;
+       }
+
+       rect.ymax= ar->winrct.ymax - ar->winrct.ymin;
+
+       glEnable(GL_BLEND);
+       glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
+       glColor4f(0.0f, 0.0f, 0.0f, alpha);
+       glRecti(rect.xmin, rect.ymin, rect.xmax+1, rect.ymax+1);
+       glDisable(GL_BLEND);
+
+       /* text */
+       UI_ThemeColor(TH_TEXT_HI);
+       BLF_position(fontid, 12, rect.ymin + 5, 0.0f);
+       BLF_draw(fontid, text, strlen(text));
+}
index a53da4ce0069c998cf66e7bdc016e0bb8471f0a2..3f9ec3f3c8292692951077a3d0f35a0973e58162 100644 (file)
@@ -204,29 +204,8 @@ static void draw_movieclip_notes(SpaceClip *sc, ARegion *ar)
                        strcpy(str, "Locked");
        }
 
-       if(str[0]) {
-               uiStyle *style= UI_GetStyle();
-               int fontid= style->widget.uifont_id;
-               int fontwidth;
-
-               BLF_size(fontid, 11.0f, 72);
-
-               if(block)
-                       fontwidth= ar->winx;
-               else
-                       fontwidth= BLF_width(fontid, str);
-
-               glEnable(GL_BLEND);
-
-               glColor4f(0.0f, 0.0f, 0.0f, 0.6f);
-               glRecti(0, ar->winy-17, fontwidth+12, ar->winy);
-
-               glColor3f(1.0f, 1.0f, 1.0f);
-               BLF_position(fontid, 6.0f, ar->winy-13.0f, 0.0f);
-               BLF_draw(fontid, str, strlen(str));
-
-               glDisable(GL_BLEND);
-       }
+       if(str[0])
+               ED_region_info_draw(ar, str, block, 0.6f);
 }
 
 static void draw_movieclip_buffer(SpaceClip *sc, ARegion *ar, ImBuf *ibuf,
index 77ac577792cc212bbc1543dabb3e46134bdf6917..dc712e286a172e7dac9f37c14d05551b4677f473 100644 (file)
@@ -63,6 +63,7 @@
 
 #include "ED_gpencil.h"
 #include "ED_image.h"
+#include "ED_screen.h"
 
 #include "UI_interface.h"
 #include "UI_resources.h"
@@ -99,29 +100,11 @@ static void image_verify_buffer_float(Image *ima, ImBuf *ibuf, int color_manage)
 static void draw_render_info(Scene *scene, Image *ima, ARegion *ar)
 {
        RenderResult *rr;
-       rcti rect;
-       float colf[3];
        
        rr= BKE_image_acquire_renderresult(scene, ima);
 
        if(rr && rr->text) {
-               rect= ar->winrct;
-               rect.xmin= 0;
-               rect.ymin= ar->winrct.ymax - ar->winrct.ymin - HEADER_HEIGHT;
-               rect.xmax= ar->winrct.xmax - ar->winrct.xmin;
-               rect.ymax= ar->winrct.ymax - ar->winrct.ymin;
-               
-               /* clear header rect */
-               UI_GetThemeColor3fv(TH_BACK, colf);
-               glEnable(GL_BLEND);
-               glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
-               glColor4f(colf[0]+0.1f, colf[1]+0.1f, colf[2]+0.1f, 0.5f);
-               glRecti(rect.xmin, rect.ymin, rect.xmax, rect.ymax+1);
-               glDisable(GL_BLEND);
-               
-               UI_ThemeColor(TH_TEXT_HI);
-
-               UI_DrawString(12, rect.ymin + 5, rr->text);
+               ED_region_info_draw(ar, rr->text, 1, 0.25);
        }
 
        BKE_image_release_renderresult(scene, ima);
index 4e9ac08d8c8e21f775d235f77f0824283b8a7d64..bd5292e5154fb011320485a1b4eaceabf9871b43 100644 (file)
@@ -2595,18 +2595,32 @@ void node_draw_link_bezier(View2D *v2d, SpaceNode *snode, bNodeLink *link, int t
                        glEnd();
                }
                
-               UI_ThemeColor(th_col1);
+               /* XXX using GL_LINES for shaded node lines is a workaround
+                * for Intel hardware, this breaks with GL_LINE_STRIP and
+                * changing color in begin/end blocks.
+                */
                glLineWidth(1.5f);
-               
-               glBegin(GL_LINE_STRIP);
-               for(i=0; i<=LINK_RESOL; i++) {
-                       if(do_shaded) {
+               if(do_shaded) {
+                       glBegin(GL_LINES);
+                       for(i=0; i<LINK_RESOL; i++) {
                                UI_ThemeColorBlend(th_col1, th_col2, spline_step);
+                               glVertex2fv(coord_array[i]);
+                               
+                               UI_ThemeColorBlend(th_col1, th_col2, spline_step+dist);
+                               glVertex2fv(coord_array[i+1]);
+                               
                                spline_step += dist;
                        }
-                       glVertex2fv(coord_array[i]);
+                       glEnd();
+               }
+               else {
+                       UI_ThemeColor(th_col1);
+                       glBegin(GL_LINE_STRIP);
+                       for(i=0; i<=LINK_RESOL; i++) {
+                               glVertex2fv(coord_array[i]);
+                       }
+                       glEnd();
                }
-               glEnd();
                
                glDisable(GL_LINE_SMOOTH);
                
@@ -2663,14 +2677,31 @@ void node_draw_link_straight(View2D *v2d, SpaceNode *snode, bNodeLink *link, int
        UI_ThemeColor(th_col1);
        glLineWidth(1.5f);
        
-       glBegin(GL_LINE_STRIP);
-       for (i=0; i < LINK_RESOL; ++i) {
-               float t= (float)i/(float)(LINK_RESOL-1);
-               if(do_shaded)
+       /* XXX using GL_LINES for shaded node lines is a workaround
+        * for Intel hardware, this breaks with GL_LINE_STRIP and
+        * changing color in begin/end blocks.
+        */
+       if(do_shaded) {
+               glBegin(GL_LINES);
+               for (i=0; i < LINK_RESOL-1; ++i) {
+                       float t= (float)i/(float)(LINK_RESOL-1);
                        UI_ThemeColorBlend(th_col1, th_col2, t);
-               glVertex2f((1.0f-t)*coord_array[0][0]+t*coord_array[1][0], (1.0f-t)*coord_array[0][1]+t*coord_array[1][1]);
+                       glVertex2f((1.0f-t)*coord_array[0][0]+t*coord_array[1][0], (1.0f-t)*coord_array[0][1]+t*coord_array[1][1]);
+                       
+                       t= (float)(i+1)/(float)(LINK_RESOL-1);
+                       UI_ThemeColorBlend(th_col1, th_col2, t);
+                       glVertex2f((1.0f-t)*coord_array[0][0]+t*coord_array[1][0], (1.0f-t)*coord_array[0][1]+t*coord_array[1][1]);
+               }
+               glEnd();
+       }
+       else {
+               glBegin(GL_LINE_STRIP);
+               for (i=0; i < LINK_RESOL; ++i) {
+                       float t= (float)i/(float)(LINK_RESOL-1);
+                       glVertex2f((1.0f-t)*coord_array[0][0]+t*coord_array[1][0], (1.0f-t)*coord_array[0][1]+t*coord_array[1][1]);
+               }
+               glEnd();
        }
-       glEnd();
        
        glDisable(GL_LINE_SMOOTH);
        
index f4e46d0255d9658aee6def2ea6e2dbfa1cee1f3e..09a125692d27dc586ddc13ec8ae8a1ea9c5e0a05 100644 (file)
@@ -307,10 +307,15 @@ static void object_delete_cb(bContext *C, Scene *scene, TreeElement *te, TreeSto
        }
 }
 
-static void id_local_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeElement *UNUSED(te), TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem)
+static void id_local_cb(bContext *C, Scene *UNUSED(scene), TreeElement *UNUSED(te), TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem)
 {
        if (tselem->id->lib && (tselem->id->flag & LIB_EXTERN)) {
-               id_clear_lib_data(NULL, tselem->id);
+               /* if the ID type has no special local function,
+                * just clear the lib */
+               if (id_make_local(tselem->id, FALSE) == FALSE) {
+                       Main *bmain= CTX_data_main(C);
+                       id_clear_lib_data(bmain, tselem->id);
+               }
        }
 }
 
index 5dfb9cfb5b6bc8cbeec7a67819d7ab2d14d96c8b..3f979787a1f9a124d728c6762b37ab3e0a80f636 100644 (file)
@@ -1506,6 +1506,10 @@ static void draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d)
                        (bgpic->view & (1<<rv3d->view)) || /* check agaist flags */
                        (rv3d->persp==RV3D_CAMOB && bgpic->view == (1<<RV3D_VIEW_CAMERA))
                ) {
+                       /* disable individual images */
+                       if((bgpic->flag&V3D_BGPIC_DISABLED))
+                               continue;
+
                        freeibuf= NULL;
                        if(bgpic->source==V3D_BGPIC_IMAGE) {
                                ima= bgpic->ima;
@@ -2643,28 +2647,10 @@ static int view3d_main_area_draw_engine(const bContext *C, ARegion *ar)
 
 static void view3d_main_area_draw_engine_info(RegionView3D *rv3d, ARegion *ar)
 {
-       rcti rect;
-       const int header_height = 18;
-
        if(!rv3d->render_engine || !rv3d->render_engine->text)
                return;
-       
-       /* background box */
-       rect= ar->winrct;
-       rect.xmin= 0;
-       rect.ymin= ar->winrct.ymax - ar->winrct.ymin - header_height;
-       rect.xmax= ar->winrct.xmax - ar->winrct.xmin;
-       rect.ymax= ar->winrct.ymax - ar->winrct.ymin;
 
-       glEnable(GL_BLEND);
-       glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
-       glColor4f(0.0f, 0.0f, 0.0f, 0.25f);
-       glRecti(rect.xmin, rect.ymin, rect.xmax+1, rect.ymax+1);
-       glDisable(GL_BLEND);
-       
-       /* text */
-       UI_ThemeColor(TH_TEXT_HI);
-       UI_DrawString(12, rect.ymin + 5, rv3d->render_engine->text);
+       ED_region_info_draw(ar, rv3d->render_engine->text, 1, 0.25);
 }
 
 /* warning: this function has duplicate drawing in ED_view3d_draw_offscreen() */
index 93f4b209712449eebd5f2ec61f1fc4d68b6b297e..50136fdcc999dd8196472c30a01a93d5ed83cff2 100644 (file)
@@ -308,6 +308,7 @@ typedef struct View3D {
 /* may want to use 1 for select ?*/
 #define V3D_BGPIC_EXPANDED             2
 #define V3D_BGPIC_CAMERACLIP   4
+#define V3D_BGPIC_DISABLED             8
 
 /* BGPic->source */
 /* may want to use 1 for select ?*/
index 495a83f4bbee291ff7e2cf46c6f94f8602bfedf3..f0a008b4939fb3a0fa306a367282a1fe9fd0db8a 100644 (file)
@@ -1234,7 +1234,7 @@ static void rna_def_background_image(BlenderRNA *brna)
 
        static EnumPropertyItem bgpic_source_items[] = {
                {V3D_BGPIC_IMAGE, "IMAGE", 0, "Image", ""},
-               {V3D_BGPIC_MOVIE, "MOVIE", 0, "Movie", ""},
+               {V3D_BGPIC_MOVIE, "MOVIE_CLIP", 0, "Movie Clip", ""},
            {0, NULL, 0, NULL, NULL}
        };
 
@@ -1311,6 +1311,11 @@ static void rna_def_background_image(BlenderRNA *brna)
        RNA_def_property_boolean_sdna(prop, NULL, "flag", V3D_BGPIC_CAMERACLIP);
        RNA_def_property_ui_text(prop, "Camera Clip", "Use movie clip from active scene camera");
        RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, NULL);
+
+       prop= RNA_def_property(srna, "show_background_image", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", V3D_BGPIC_DISABLED);
+       RNA_def_property_ui_text(prop, "Show Background Image", "Show this image as background");
+       RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, NULL);
 }
 
 static void rna_def_backgroundImages(BlenderRNA *brna, PropertyRNA *cprop)
@@ -2612,6 +2617,12 @@ static void rna_def_space_filebrowser(BlenderRNA *brna)
        prop= RNA_def_property(srna, "active_operator", PROP_POINTER, PROP_NONE);
        RNA_def_property_pointer_sdna(prop, NULL, "op");
        RNA_def_property_ui_text(prop, "Active Operator", "");
+
+       /* keep this for compatibility with existing presets,
+          not exposed in c++ api because of keyword conflict */
+       prop= RNA_def_property(srna, "operator", PROP_POINTER, PROP_NONE);
+       RNA_def_property_pointer_sdna(prop, NULL, "op");
+       RNA_def_property_ui_text(prop, "Active Operator", "");
 }
 
 static void rna_def_space_info(BlenderRNA *brna)
index c2a9ae7555d7e04d25da1d547a43d38517f214e2..e206000f41ddbe305a73a4fce873ee655edd2ad3 100644 (file)
@@ -240,51 +240,6 @@ static void defvert_add_to_group(MDeformVert *dv, int defgrp_idx, const float we
        dv->totweight++;
 }
 
-/* Removes the given vertex from the vertex group, specified either by its defgrp_idx,
- * or directly by its MDeformWeight pointer, if dw is not NULL.
- * WARNING: This function frees the given MDeformWeight, do not use it afterward! */
-static void defvert_remove_from_group(MDeformVert *dv, int defgrp_idx, MDeformWeight *dw)
-{
-       /* TODO, move this into deform.c as a generic function. */
-       MDeformWeight *newdw;
-       int i;
-
-       /* Get index of removed MDeformWeight. */
-       if(dw == NULL) {
-               dw = dv->dw;
-               for (i = dv->totweight; i > 0; i--, dw++) {
-                       if (dw->def_nr == defgrp_idx)
-                               break;
-               }
-               i--;
-       }
-       else {
-               i = dw - dv->dw;
-               /* Security check! */
-               if(i < 0 || i >= dv->totweight)
-                       return;
-       }
-
-       dv->totweight--;
-       /* If there are still other deform weights attached to this vert then remove
-        * this deform weight, and reshuffle the others.
-        */
-       if(dv->totweight) {
-               newdw = MEM_mallocN(sizeof(MDeformWeight)*(dv->totweight), "defvert_remove_from_group, new deformWeight");
-               if(dv->dw){
-                       memcpy(newdw, dv->dw, sizeof(MDeformWeight)*i);
-                       memcpy(newdw+i, dv->dw+i+1, sizeof(MDeformWeight)*(dv->totweight-i));
-                       MEM_freeN(dv->dw);
-               }
-               dv->dw = newdw;
-       }
-       /* If there are no other deform weights left then just remove this one. */
-       else {
-               MEM_freeN(dv->dw);
-               dv->dw = NULL;
-       }
-}
-
 
 /* Applies weights to given vgroup (defgroup), and optionnaly add/remove vertices from the group.
  * If dws is not NULL, it must be an array of MDeformWeight pointers of same length as weights (and
@@ -309,7 +264,7 @@ void weightvg_update_vg(MDeformVert *dvert, int defgrp_idx, MDeformWeight **dws,
                /* If the vertex is in this vgroup, remove it if needed, or just update it. */
                if(dw != NULL) {
                        if(do_rem && w < rem_thresh) {
-                               defvert_remove_from_group(dv, defgrp_idx, dw);
+                               defvert_remove_index(dv, defgrp_idx, dw);
                        }
                        else {
                                dw->weight = w;
index d7c7a1e846f8e4e9b864a85b0e1db4da5b0ce91c..a6426a02e18418e6cedaae45b3cb497c44f03cde 100644 (file)
@@ -265,8 +265,8 @@ static PyObject *bpy_lib_enter(BPy_Library *self, PyObject *UNUSED(args))
 
        /* create a dummy */
        self_from= PyObject_New(BPy_Library, &bpy_lib_Type);
-       BLI_strncpy(self_from->relpath, self->relpath, sizeof(BPy_Library));
-       BLI_strncpy(self_from->abspath, self->abspath, sizeof(BPy_Library));
+       BLI_strncpy(self_from->relpath, self->relpath, sizeof(self_from->relpath));
+       BLI_strncpy(self_from->abspath, self->abspath, sizeof(self_from->abspath));
 
        self_from->blo_handle= NULL;
        self_from->flag= 0;
@@ -396,6 +396,7 @@ static PyObject *bpy_lib_exit(BPy_Library *self, PyObject *UNUSED(args))
                return NULL;
        }
        else {
+               Library *lib= mainl->curlib; /* newly added lib, assign before append end */
                BLO_library_append_end(NULL, mainl, &(self->blo_handle), 0, self->flag);
                BLO_blendhandle_close(self->blo_handle);
                self->blo_handle= NULL;
@@ -406,9 +407,7 @@ static PyObject *bpy_lib_exit(BPy_Library *self, PyObject *UNUSED(args))
 
                        /* append, rather than linking */
                        if ((self->flag & FILE_LINK)==0) {
-                               Library *lib= BLI_findstring(&G.main->library, self->abspath, offsetof(Library, name));
-                               if (lib)  BKE_library_make_local(bmain, lib, 1);
-                               else      BLI_assert(!"cant find name of just added library!");
+                               BKE_library_make_local(bmain, lib, 1);
                        }
                }
 
index 39ad80169d20429340f2447ef0be14eef85395d8..c0d796669d63ede69376a3fe646bf53de51eecb1 100644 (file)
@@ -233,7 +233,7 @@ static void bpy_prop_update_cb(struct bContext *C, struct PointerRNA *ptr, struc
 
 static int bpy_prop_callback_check(PyObject *py_func, int argcount)
 {
-       if (py_func) {
+       if (py_func && py_func != Py_None) {
                if (!PyFunction_Check(py_func)) {
                        PyErr_Format(PyExc_TypeError,
                                     "update keyword: expected a function type, not a %.200s",
index f0fe69259fec5a514dc94baebc50e49ce7197d86..121c5e26e7381b1cc6f7a3859e1779739ad22689 100644 (file)
@@ -39,7 +39,9 @@
 PyDoc_STRVAR(M_Mathutils_doc,
 "This module provides access to matrices, eulers, quaternions and vectors."
 );
-static int mathutils_array_parse_fast(float *array, int array_min, int array_max, PyObject *value, const char *error_prefix)
+static int mathutils_array_parse_fast(float *array,
+                                      int array_min, int array_max,
+                                      PyObject *value, const char *error_prefix)
 {
        PyObject *value_fast= NULL;
        PyObject *item;
@@ -72,7 +74,9 @@ static int mathutils_array_parse_fast(float *array, int array_min, int array_max
        i= size;
        do {
                i--;
-               if (((array[i]= PyFloat_AsDouble((item= PySequence_Fast_GET_ITEM(value_fast, i)))) == -1.0f) && PyErr_Occurred()) {
+               if ( ((array[i]= PyFloat_AsDouble((item= PySequence_Fast_GET_ITEM(value_fast, i)))) == -1.0f) &&
+                    PyErr_Occurred())
+               {
                        PyErr_Format(PyExc_TypeError,
                                     "%.200s: sequence index %d expected a number, "
                                     "found '%.200s' type, ",
index b50535bd70903c4f96510b9989c895671a2031eb..a8170b8145ca2f2d54b3d2d1e0c05162c33918d0 100644 (file)
 extern char BaseMathObject_Wrapped_doc[];
 extern char BaseMathObject_Owner_doc[];
 
-#define BASE_MATH_MEMBERS(_data) \
-       PyObject_VAR_HEAD \
-       float *_data;                           /* array of data (alias), wrapped status depends on wrapped status */ \
-       PyObject *cb_user;                      /* if this vector references another object, otherwise NULL, *Note* this owns its reference */ \
-       unsigned char cb_type;          /* which user funcs do we adhere to, RNA, GameObject, etc */ \
-       unsigned char cb_subtype;       /* subtype: location, rotation... to avoid defining many new functions for every attribute of the same type */ \
-       unsigned char wrapped;          /* wrapped data type? */ \
+#define BASE_MATH_MEMBERS(_data)                                                                                 \
+       PyObject_VAR_HEAD                                                                                            \
+       float *_data;               /* array of data (alias), wrapped status depends on wrapped status */            \
+       PyObject *cb_user;          /* if this vector references another object, otherwise NULL,                     \
+                                    * *Note* this owns its reference */                                             \
+       unsigned char cb_type;      /* which user funcs do we adhere to, RNA, GameObject, etc */                     \
+       unsigned char cb_subtype;   /* subtype: location, rotation...                                                \
+                                    * to avoid defining many new functions for every attribute of the same type */  \
+       unsigned char wrapped       /* wrapped data type? */                                                         \
 
 typedef struct {
-       BASE_MATH_MEMBERS(data)
+       BASE_MATH_MEMBERS(data);
 } BaseMathObject;
 
 /* types */
@@ -80,11 +82,11 @@ int EXPP_VectorsAreEqual(float *vecA, float *vecB, int size, int floatSteps);
 
 typedef struct Mathutils_Callback Mathutils_Callback;
 
-typedef int (*BaseMathCheckFunc)(BaseMathObject *);                                                    /* checks the user is still valid */
-typedef int (*BaseMathGetFunc)(BaseMathObject *, int);                         /* gets the vector from the user */
-typedef int (*BaseMathSetFunc)(BaseMathObject *, int);                         /* sets the users vector values once the vector is modified */
-typedef int (*BaseMathGetIndexFunc)(BaseMathObject *, int, int);       /* same as above but only for an index */
-typedef int (*BaseMathSetIndexFunc)(BaseMathObject *, int, int);       /* same as above but only for an index */
+typedef int (*BaseMathCheckFunc)(BaseMathObject *);               /* checks the user is still valid */
+typedef int (*BaseMathGetFunc)(BaseMathObject *, int);            /* gets the vector from the user */
+typedef int (*BaseMathSetFunc)(BaseMathObject *, int);            /* sets the users vector values once its modified */
+typedef int (*BaseMathGetIndexFunc)(BaseMathObject *, int, int);  /* same as above but only for an index */
+typedef int (*BaseMathSetIndexFunc)(BaseMathObject *, int, int);  /* same as above but only for an index */
 
 struct Mathutils_Callback {
        BaseMathCheckFunc               check;
@@ -102,10 +104,14 @@ int _BaseMathObject_ReadIndexCallback(BaseMathObject *self, int index);
 int _BaseMathObject_WriteIndexCallback(BaseMathObject *self, int index);
 
 /* since this is called so often avoid where possible */
-#define BaseMath_ReadCallback(_self) (((_self)->cb_user ?      _BaseMathObject_ReadCallback((BaseMathObject *)_self):0))
-#define BaseMath_WriteCallback(_self) (((_self)->cb_user ?_BaseMathObject_WriteCallback((BaseMathObject *)_self):0))
-#define BaseMath_ReadIndexCallback(_self, _index) (((_self)->cb_user ? _BaseMathObject_ReadIndexCallback((BaseMathObject *)_self, _index):0))
-#define BaseMath_WriteIndexCallback(_self, _index) (((_self)->cb_user ?        _BaseMathObject_WriteIndexCallback((BaseMathObject *)_self, _index):0))
+#define BaseMath_ReadCallback(_self) \
+       (((_self)->cb_user ?    _BaseMathObject_ReadCallback((BaseMathObject *)_self):0))
+#define BaseMath_WriteCallback(_self) \
+       (((_self)->cb_user ?_BaseMathObject_WriteCallback((BaseMathObject *)_self):0))
+#define BaseMath_ReadIndexCallback(_self, _index) \
+       (((_self)->cb_user ?    _BaseMathObject_ReadIndexCallback((BaseMathObject *)_self, _index):0))
+#define BaseMath_WriteIndexCallback(_self, _index) \
+       (((_self)->cb_user ?    _BaseMathObject_WriteIndexCallback((BaseMathObject *)_self, _index):0))
 
 /* utility func */
 int mathutils_array_parse(float *array, int array_min, int array_max, PyObject *value, const char *error_prefix);
index f218d653ec9993683f3f53e846c9d969a87cbbee..7e8a99089ad2ba788cc9431adff29632604770e6 100644 (file)
@@ -39,7 +39,7 @@ extern PyTypeObject color_Type;
 #define ColorObject_Check(_v) PyObject_TypeCheck((_v), &color_Type)
 
 typedef struct {
-       BASE_MATH_MEMBERS(col)
+       BASE_MATH_MEMBERS(col);
 } ColorObject;
 
 /*struct data contains a pointer to the actual data that the
index 9bf6687fb5ee1341c487a17357eda4004f0ac768..7e769da14cb80d97f3fb30be97518350dd6ae4e3 100644 (file)
@@ -264,8 +264,11 @@ static PyObject *Euler_make_compatible(EulerObject * self, PyObject *value)
        if (BaseMath_ReadCallback(self) == -1)
                return NULL;
 
-       if (mathutils_array_parse(teul, EULER_SIZE, EULER_SIZE, value, "euler.make_compatible(other), invalid 'other' arg") == -1)
+       if (mathutils_array_parse(teul, EULER_SIZE, EULER_SIZE, value,
+                                 "euler.make_compatible(other), invalid 'other' arg") == -1)
+       {
                return NULL;
+       }
 
        compatible_eul(self->eul, teul);
 
index 5760d08e1f6e6408f000805ea2c1792d4ded483e..130384a1792a623e3082555da65c14e72aa499c9 100644 (file)
@@ -39,7 +39,7 @@ extern PyTypeObject euler_Type;
 #define EulerObject_Check(_v) PyObject_TypeCheck((_v), &euler_Type)
 
 typedef struct {
-       BASE_MATH_MEMBERS(eul)
+       BASE_MATH_MEMBERS(eul);
        unsigned char order;            /* rotation order */
 
 } EulerObject;
index 2f62f7141cf59af4185c66abff6dea79e8971e01..ea636ef52fbc0ee180551f14a99830f61f2b79f0 100644 (file)
@@ -125,7 +125,7 @@ static PyObject *Matrix_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
 
        switch(PyTuple_GET_SIZE(args)) {
                case 0:
-                       return (PyObject *) Matrix_CreatePyObject(NULL, 4, 4, Py_NEW, type);
+                       return Matrix_CreatePyObject(NULL, 4, 4, Py_NEW, type);
                case 1:
                {
                        PyObject *arg= PyTuple_GET_ITEM(args, 0);
@@ -478,7 +478,9 @@ static PyObject *C_Matrix_OrthoProjection(PyObject *cls, PyObject *args)
                int vec_size= (matSize == 2 ? 2 : 3);
                float tvec[4];
 
-               if (mathutils_array_parse(tvec, vec_size, vec_size, axis, "Matrix.OrthoProjection(axis, size), invalid 'axis' arg") == -1) {
+               if (mathutils_array_parse(tvec, vec_size, vec_size, axis,
+                                         "Matrix.OrthoProjection(axis, size), invalid 'axis' arg") == -1)
+               {
                        return NULL;
                }
 
@@ -827,12 +829,12 @@ static PyObject *Matrix_to_4x4(MatrixObject *self)
                return NULL;
 
        if (self->col_size==4 && self->row_size==4) {
-               return (PyObject *)Matrix_CreatePyObject(self->contigPtr, 4, 4, Py_NEW, Py_TYPE(self));
+               return Matrix_CreatePyObject(self->contigPtr, 4, 4, Py_NEW, Py_TYPE(self));
        }
        else if (self->col_size==3 && self->row_size==3) {
                float mat[4][4];
                copy_m4_m3(mat, (float (*)[3])self->contigPtr);
-               return (PyObject *)Matrix_CreatePyObject((float *)mat, 4, 4, Py_NEW, Py_TYPE(self));
+               return Matrix_CreatePyObject((float *)mat, 4, 4, Py_NEW, Py_TYPE(self));
        }
        /* TODO, 2x2 matrix */
 
@@ -1133,7 +1135,7 @@ static PyObject *Matrix_lerp(MatrixObject *self, PyObject *args)
                return NULL;
        }
 
-       return (PyObject*)Matrix_CreatePyObject(mat, self->row_size, self->col_size, Py_NEW, Py_TYPE(self));
+       return Matrix_CreatePyObject(mat, self->row_size, self->col_size, Py_NEW, Py_TYPE(self));
 }
 
 /*---------------------------matrix.determinant() ----------------*/
@@ -1286,7 +1288,7 @@ static PyObject *Matrix_copy(MatrixObject *self)
        if (BaseMath_ReadCallback(self) == -1)
                return NULL;
 
-       return (PyObject*)Matrix_CreatePyObject((float (*))self->contigPtr, self->row_size, self->col_size, Py_NEW, Py_TYPE(self));
+       return Matrix_CreatePyObject((float (*))self->contigPtr, self->row_size, self->col_size, Py_NEW, Py_TYPE(self));
 }
 
 /*----------------------------print object (internal)-------------*/
@@ -1470,7 +1472,9 @@ static int Matrix_ass_slice(MatrixObject *self, int begin, int end, PyObject *va
                        /*parse each sub sequence*/
                        PyObject *item= PySequence_Fast_GET_ITEM(value_fast, i);
 
-                       if (mathutils_array_parse(&mat[i * self->col_size], self->col_size, self->col_size, item, "matrix[begin:end] = value assignment") < 0) {
+                       if (mathutils_array_parse(&mat[i * self->col_size], self->col_size, self->col_size, item,
+                                                 "matrix[begin:end] = value assignment") < 0)
+                       {
                                return -1;
                        }
                }
@@ -1956,7 +1960,9 @@ self->matrix[1][1] = self->contigPtr[4] */
  (i.e. it was allocated elsewhere by MEM_mallocN())
   pass Py_NEW - if vector is not a WRAPPER and managed by PYTHON
  (i.e. it must be created here with PyMEM_malloc())*/
-PyObject *Matrix_CreatePyObject(float *mat, const unsigned short rowSize, const unsigned short colSize, int type, PyTypeObject *base_type)
+PyObject *Matrix_CreatePyObject(float *mat,
+                                const unsigned short rowSize, const unsigned short colSize,
+                                int type, PyTypeObject *base_type)
 {
        MatrixObject *self;
        int x, row, col;
index d1984d7299da3edaaf83a43de3bd9597192e6509..6dfcbb1faf9bd4a3f126d0ec3c43ed901b17300c 100644 (file)
@@ -39,7 +39,7 @@ extern PyTypeObject matrix_Type;
 #define MATRIX_MAX_DIM 4
 
 typedef struct {
-       BASE_MATH_MEMBERS(contigPtr)
+       BASE_MATH_MEMBERS(contigPtr);
        float *matrix[MATRIX_MAX_DIM];          /* ptr to the contigPtr (accessor) */
        unsigned short row_size;
        unsigned short col_size;
@@ -51,7 +51,9 @@ be stored in py_data) or be a wrapper for data allocated through
 blender (stored in blend_data). This is an either/or struct not both*/
 
 /*prototypes*/
-PyObject *Matrix_CreatePyObject(float *mat, const unsigned short row_size, const unsigned short col_size, int type, PyTypeObject *base_type);
+PyObject *Matrix_CreatePyObject(float *mat,
+                                const unsigned short row_size, const unsigned short col_size,
+                                int type, PyTypeObject *base_type);
 PyObject *Matrix_CreatePyObject_cb(PyObject *user, int row_size, int col_size, int cb_type, int cb_subtype);
 
 extern int mathutils_matrix_vector_cb_index;
index 44cd28a7c3d0eaf152fa55cff1c8fce1442820ae..cf817003a986eac95d3a1e1fa420ca3aef885a24 100644 (file)
@@ -218,8 +218,11 @@ static PyObject *Quaternion_dot(QuaternionObject *self, PyObject *value)
        if (BaseMath_ReadCallback(self) == -1)
                return NULL;
 
-       if (mathutils_array_parse(tquat, QUAT_SIZE, QUAT_SIZE, value, "Quaternion.dot(other), invalid 'other' arg") == -1)
+       if (mathutils_array_parse(tquat, QUAT_SIZE, QUAT_SIZE, value,
+                                 "Quaternion.dot(other), invalid 'other' arg") == -1)
+       {
                return NULL;
+       }
 
        return PyFloat_FromDouble(dot_qtqt(self->quat, tquat));
 }
@@ -241,8 +244,11 @@ static PyObject *Quaternion_rotation_difference(QuaternionObject *self, PyObject
        if (BaseMath_ReadCallback(self) == -1)
                return NULL;
 
-       if (mathutils_array_parse(tquat, QUAT_SIZE, QUAT_SIZE, value, "Quaternion.difference(other), invalid 'other' arg") == -1)
+       if (mathutils_array_parse(tquat, QUAT_SIZE, QUAT_SIZE, value,
+                                 "Quaternion.difference(other), invalid 'other' arg") == -1)
+       {
                return NULL;
+       }
 
        rotation_between_quats_to_quat(quat, self->quat, tquat);
 
@@ -276,8 +282,11 @@ static PyObject *Quaternion_slerp(QuaternionObject *self, PyObject *args)
        if (BaseMath_ReadCallback(self) == -1)
                return NULL;
 
-       if (mathutils_array_parse(tquat, QUAT_SIZE, QUAT_SIZE, value, "Quaternion.slerp(other), invalid 'other' arg") == -1)
+       if (mathutils_array_parse(tquat, QUAT_SIZE, QUAT_SIZE, value,
+                                 "Quaternion.slerp(other), invalid 'other' arg") == -1)
+       {
                return NULL;
+       }
 
        if (fac > 1.0f || fac < 0.0f) {
                PyErr_SetString(PyExc_ValueError,
@@ -982,7 +991,7 @@ static PyObject *Quaternion_getAxisVec(QuaternionObject *self, void *UNUSED(clos
 
        quat__axis_angle_sanitize(axis, NULL);
 
-       return (PyObject *) Vector_CreatePyObject(axis, 3, Py_NEW, NULL);
+       return Vector_CreatePyObject(axis, 3, Py_NEW, NULL);
 }
 
 static int Quaternion_setAxisVec(QuaternionObject *self, PyObject *value, void *UNUSED(closure))
@@ -1054,7 +1063,7 @@ static PyObject *quat__apply_to_copy(PyNoArgsFunction quat_func, QuaternionObjec
        PyObject *ret_dummy= quat_func(ret);
        if (ret_dummy) {
                Py_DECREF(ret_dummy);
-               return (PyObject *)ret;
+               return ret;
        }
        else { /* error */
                Py_DECREF(ret);
index a34720769fab1d161d58f0b3b0a4ef1c31175eb0..edd5ec55312129c2155c5075ea1e961f22cb72ca 100644 (file)
@@ -39,7 +39,7 @@ extern PyTypeObject quaternion_Type;
 #define QuaternionObject_Check(_v) PyObject_TypeCheck((_v), &quaternion_Type)
 
 typedef struct {
-       BASE_MATH_MEMBERS(quat)
+       BASE_MATH_MEMBERS(quat);
 } QuaternionObject;
 
 /*struct data contains a pointer to the actual data that the
index 1dff33887e3dca607b88d46194da2319264e3003..9d1a22adb127647705cb27d6846986211cc53cc4 100644 (file)
@@ -589,10 +589,10 @@ PyDoc_STRVAR(Vector_angle_doc,
 );
 static PyObject *Vector_angle(VectorObject *self, PyObject *args)
 {
-       const int size= self->size;
+       const int size= MIN2(self->size, 3); /* 4D angle makes no sense */
        float tvec[MAX_DIMENSIONS];
        PyObject *value;
-       double dot = 0.0f, test_v1 = 0.0f, test_v2 = 0.0f;
+       double dot= 0.0f, dot_self= 0.0f, dot_other= 0.0f;
        int x;
        PyObject *fallback= NULL;
 
@@ -602,14 +602,18 @@ static PyObject *Vector_angle(VectorObject *self, PyObject *args)
        if (BaseMath_ReadCallback(self) == -1)
                return NULL;
 
-       if (mathutils_array_parse(tvec, size, size, value, "Vector.angle(other), invalid 'other' arg") == -1)
+       /* don't use clamped size, rule of thumb is vector sizes must match,
+        * even though n this case 'w' is ignored */
+       if (mathutils_array_parse(tvec, self->size, self->size, value, "Vector.angle(other), invalid 'other' arg") == -1)
                return NULL;
 
        for (x = 0; x < size; x++) {
-               test_v1 += (double)(self->vec[x] * self->vec[x]);
-               test_v2 += (double)(tvec[x] * tvec[x]);
+               dot_self  += (double)self->vec[x] * (double)self->vec[x];
+               dot_other += (double)tvec[x]      * (double)tvec[x];
+               dot       += (double)self->vec[x] * (double)tvec[x];
        }
-       if (!test_v1 || !test_v2) {
+
+       if (!dot_self || !dot_other) {
                /* avoid exception */
                if (fallback) {
                        Py_INCREF(fallback);
@@ -623,13 +627,7 @@ static PyObject *Vector_angle(VectorObject *self, PyObject *args)
                }
        }
 
-       //dot product
-       for (x = 0; x < self->size; x++) {
-               dot += (double)(self->vec[x] * tvec[x]);
-       }
-       dot /= (sqrt(test_v1) * sqrt(test_v2));
-
-       return PyFloat_FromDouble(saacos(dot));
+       return PyFloat_FromDouble(saacos(dot / (sqrt(dot_self) * sqrt(dot_other))));
 }
 
 PyDoc_STRVAR(Vector_rotation_difference_doc,
@@ -1755,7 +1753,10 @@ static int Vector_setSwizzle(VectorObject *self, PyObject *value, void *closure)
 
                size_from= axis_from;
        }
-       else if (PyErr_Clear(), (size_from=mathutils_array_parse(vec_assign, 2, 4, value, "mathutils.Vector.**** = swizzle assignment")) == -1) {
+       else if ( (PyErr_Clear()), /* run but ignore the result */
+                 (size_from=mathutils_array_parse(vec_assign, 2, 4, value,
+                                                  "mathutils.Vector.**** = swizzle assignment")) == -1)
+       {
                return -1;
        }
 
index c1550aabb2512c8446e9fc2b497e181a59b148a6..0f7fa174d186e66fc755a6ba43f45c5837d13f96 100644 (file)
@@ -39,7 +39,7 @@ extern PyTypeObject vector_Type;
 #define VectorObject_Check(_v) PyObject_TypeCheck((_v), &vector_Type)
 
 typedef struct {
-       BASE_MATH_MEMBERS(vec)
+       BASE_MATH_MEMBERS(vec);
 
        unsigned char size;                     /* vec size 2,3 or 4 */
 } VectorObject;
index e6e098ce0ce1c6e2b0f167cdee11bc72c03a095e..95c40508e86f29e04cb0b70574d33a6a83a217cd 100644 (file)
@@ -2391,7 +2391,7 @@ static void do_displacement(Render *re, ObjectRen *obr, float mat[][4], float im
        /* Object Size with parenting */
        obt=obr->ob;
        while(obt){
-               add_v3_v3v3(temp, obt->size, obt->dsize);
+               mul_v3_v3v3(temp, obt->size, obt->dsize);
                scale[0]*=temp[0]; scale[1]*=temp[1]; scale[2]*=temp[2];
                obt=obt->parent;
        }
index 26f59189e47e484dad55f6f9df8e3d0dbd47e8ba..fa6521b3ec0f0745b3d86002571b8e8e12cee66f 100644 (file)
@@ -1289,7 +1289,7 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar
        uiItemL(col, "Links", ICON_NONE);
        uiItemStringO(col, IFACE_("Donations"), ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org/blenderorg/blender-foundation/donation-payment");
        uiItemStringO(col, IFACE_("Credits"), ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org/development/credits");
-       uiItemStringO(col, IFACE_("Release Log"), ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org/development/release-logs/blender-260");
+       uiItemStringO(col, IFACE_("Release Log"), ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org/development/release-logs/blender-261");
        uiItemStringO(col, IFACE_("Manual"), ICON_URL, "WM_OT_url_open", "url", "http://wiki.blender.org/index.php/Doc:2.5/Manual");
        uiItemStringO(col, IFACE_("Blender Website"), ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org");
        uiItemStringO(col, IFACE_("User Community"), ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org/community/user-community");
index 7699e86f19fb5221d90521d494c7035a308171dd..2f5125a63dd201395ba718b099ce0e27389190d8 100644 (file)
@@ -765,7 +765,7 @@ void        KX_BlenderSceneConverter::WritePhysicsObjectToAnimationIpo(int frameNumber)
                {
                        KX_GameObject* gameObj = (KX_GameObject*)parentList->GetValue(g);
                        Object* blenderObject = gameObj->GetBlenderObject();
-                       if (blenderObject && blenderObject->parent==NULL && gameObj->GetPhysicsController() != NULL)
+                       if (blenderObject && blenderObject->parent==NULL && gameObj->IsDynamic())
                        {
                                //KX_IPhysicsController* physCtrl = gameObj->GetPhysicsController();