Merge with trunk r38663
authorMiika Hamalainen <blender@miikah.org>
Sun, 24 Jul 2011 18:01:20 +0000 (18:01 +0000)
committerMiika Hamalainen <blender@miikah.org>
Sun, 24 Jul 2011 18:01:20 +0000 (18:01 +0000)
16 files changed:
intern/audaspace/OpenAL/AUD_OpenALDevice.cpp
intern/audaspace/OpenAL/AUD_OpenALDevice.h
release/scripts/startup/bl_operators/screen_play_rendered_anim.py
release/scripts/startup/bl_ui/properties_world.py
release/scripts/startup/bl_ui/space_info.py
release/scripts/startup/bl_ui/space_view3d.py
release/scripts/startup/bl_ui/space_view3d_toolbar.py
source/blender/blenkernel/BKE_effect.h
source/blender/blenkernel/intern/effect.c
source/blender/editors/interface/interface_templates.c
source/blender/editors/object/object_edit.c
source/blender/editors/space_view3d/view3d_header.c
source/blender/imbuf/IMB_imbuf.h
source/blender/imbuf/intern/filter.c
source/blender/makesrna/intern/rna_scene.c
source/blender/render/intern/source/rendercore.c

index b9e30bbf62aa94897b901f29962de288a8820859..71e7b7677e888a7ae35d52b1a3223ef050526ed4 100644 (file)
@@ -105,12 +105,15 @@ void* AUD_openalRunThread(void* device)
        return NULL;
 }
 
-void AUD_OpenALDevice::start()
+void AUD_OpenALDevice::start(bool join)
 {
        lock();
 
        if(!m_playing)
        {
+               if(join)
+                       pthread_join(m_thread, NULL);
+
                pthread_attr_t attr;
                pthread_attr_init(&attr);
                pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
@@ -271,8 +274,8 @@ void AUD_OpenALDevice::updateStreams()
                // stop thread
                if(m_playingSounds->empty() || (cerr != ALC_NO_ERROR))
                {
-                       unlock();
                        m_playing = false;
+                       unlock();
                        pthread_exit(NULL);
                }
 
@@ -366,6 +369,8 @@ AUD_OpenALDevice::AUD_OpenALDevice(AUD_DeviceSpecs specs, int buffersize)
        pthread_mutex_init(&m_mutex, &attr);
 
        pthread_mutexattr_destroy(&attr);
+
+       start(false);
 }
 
 AUD_OpenALDevice::~AUD_OpenALDevice()
@@ -414,13 +419,8 @@ AUD_OpenALDevice::~AUD_OpenALDevice()
        alcProcessContext(m_context);
 
        // wait for the thread to stop
-       if(m_playing)
-       {
-               unlock();
-               pthread_join(m_thread, NULL);
-       }
-       else
-               unlock();
+       unlock();
+       pthread_join(m_thread, NULL);
 
        delete m_playingSounds;
        delete m_pausedSounds;
index 3bbbe85d7e6480930f6e3b11a0723f2621c68a8c..127f69beca8bc5d3ef00bd88302f58de7204d2eb 100644 (file)
@@ -106,7 +106,7 @@ private:
        /**
         * Starts the streaming thread.
         */
-       void start();
+       void start(bool join = true);
 
        /**
         * Checks if a handle is valid.
index 910ccf96c0e41e96cd3487d7bd8c687e52b07495..8699862d24b4d872c4d16df81f123b2218bb6660 100644 (file)
@@ -59,6 +59,9 @@ def guess_player_path(preset):
 
     elif preset == 'MPLAYER':
         player_path = "mplayer"
+    
+    else:
+        player_path = ""
 
     return player_path
 
@@ -131,12 +134,14 @@ class PlayRenderedAnim(bpy.types.Operator):
             cmd.extend(opts)
         else:  # 'CUSTOM'
             cmd.append(file)
-
-        # launch it
-        try:
-            process = subprocess.Popen(cmd)
-        except:
-            pass
-            #raise OSError("Couldn't find an external animation player.")
+            
+        if (player_path == "") or (os.path.exists(player_path)==False):
+            self.report({'ERROR'}, "Couldn't find an external animation player")
+        else:
+            # launch it
+            try:
+                process = subprocess.Popen(cmd)
+            except:
+                pass
 
         return {'FINISHED'}
index 4f398c9fbd97daef2431bc37c12f3772bbf2ed10..0272667e754a890dd5afbc66a1bf016c3d3a9dee 100644 (file)
@@ -20,8 +20,6 @@
 import bpy
 from rna_prop_ui import PropertyPanel
 
-# TODO, "color_range" not in the UI
-
 
 class WorldButtonsPanel():
     bl_space_type = 'PROPERTIES'
@@ -95,6 +93,10 @@ class WORLD_PT_world(WorldButtonsPanel, bpy.types.Panel):
         col.prop(world, "zenith_color")
         col.active = world.use_sky_blend
         row.column().prop(world, "ambient_color")
+        
+        row = layout.row()
+        row.prop(world, "exposure")
+        row.prop(world, "color_range")
 
 
 class WORLD_PT_ambient_occlusion(WorldButtonsPanel, bpy.types.Panel):
index 2b12e75564c0b4d4c01c37aa9e9e70348422b29e..cda37b3119aaf6bf58d78c44dad85838b5e27856 100644 (file)
@@ -60,8 +60,10 @@ class INFO_HT_header(bpy.types.Header):
         layout.template_running_jobs()
 
         layout.template_reports_banner()
-
-        layout.label(text=scene.statistics())
+        
+        row = layout.row(align=True)
+        row.operator("wm.splash", text="", icon='BLENDER', emboss=False)
+        row.label(text=scene.statistics())
 
         # XXX: this should be right-aligned to the RHS of the region
         layout.operator("wm.window_fullscreen_toggle", icon='FULLSCREEN_ENTER', text="")
index aef6accb4e1bff3011260bf21313f4ce3ebe0786..7d35ca9ddb8eca8ff3e2711c12d22fae3512d99e 100644 (file)
@@ -54,21 +54,13 @@ class VIEW3D_HT_header(bpy.types.Header):
                 sub.menu("VIEW3D_MT_object")
 
         row = layout.row()
-        row.template_header_3D()
-
-        # do in C for now since these buttons cant be both toggle AND exclusive.
-        '''
-        if obj and obj.mode == 'EDIT' and obj.type == 'MESH':
-            row_sub = row.row(align=True)
-            row_sub.prop(toolsettings, "mesh_select_mode", text="", index=0, icon='VERTEXSEL')
-            row_sub.prop(toolsettings, "mesh_select_mode", text="", index=1, icon='EDGESEL')
-            row_sub.prop(toolsettings, "mesh_select_mode", text="", index=2, icon='FACESEL')
-        '''
+        # Contains buttons like Mode, Pivot, Manipulator, Layer, Mesh Select Mode...
+        row.template_header_3D() 
 
         if obj:
             # Particle edit
             if obj.mode == 'PARTICLE_EDIT':
-                row.prop(toolsettings.particle_edit, "select_mode", text="", expand=True, toggle=True)
+                row.prop(toolsettings.particle_edit, "select_mode", text="", expand=True)
 
             # Occlude geometry
             if view.viewport_shade in {'SOLID', 'SHADED', 'TEXTURED'} and (obj.mode == 'PARTICLE_EDIT' or (obj.mode == 'EDIT' and obj.type == 'MESH')):
index e1efeed87ea5fc7ed386dffda15443a4d040f8f2..19c3224f138115eb1ad3fdd0319bd6f1d5fe1d4d 100644 (file)
@@ -116,7 +116,8 @@ class VIEW3D_PT_tools_meshedit(View3DPanel, bpy.types.Panel):
         col.operator("transform.translate")
         col.operator("transform.rotate")
         col.operator("transform.resize", text="Scale")
-        col.operator("transform.shrink_fatten", text="Along Normal")
+        col.operator("transform.shrink_fatten", text="Shrink/Fatten")
+        col.operator("transform.push_pull", text="Push/Pull")
 
         col = layout.column(align=True)
         col.label(text="Deform:")
index 97ac711651b6b3cb0d2d66c942d0d997af38b1c7..12f9383cefbf8d877eeb7747bc15cbb025a9a297 100644 (file)
@@ -105,6 +105,7 @@ typedef struct EffectorCache {
        /* precalculated for guides */
        struct GuideEffectorData *guide_data;
        float guide_loc[4], guide_dir[3], guide_radius;
+       float velocity[3];
 
        float frame;
        int flag;
index ee46bef6038469de9756b98ba635e1b9681b1bb4..4b95c44f55feb66b6d20dbf3b05295a913d7539c 100644 (file)
@@ -241,6 +241,16 @@ static void precalculate_effector(EffectorCache *eff)
        }
        else if(eff->psys)
                psys_update_particle_tree(eff->psys, eff->scene->r.cfra);
+
+       /* Store object velocity */
+       if(eff->ob) {
+               float old_vel[3];
+
+               where_is_object_time(eff->scene, eff->ob, cfra - 1.0f);
+               copy_v3_v3(old_vel, eff->ob->obmat[3]); 
+               where_is_object_time(eff->scene, eff->ob, cfra);
+               sub_v3_v3v3(eff->velocity, eff->ob->obmat[3], old_vel);
+       }
 }
 static EffectorCache *new_effector_cache(Scene *scene, Object *ob, ParticleSystem *psys, PartDeflect *pd)
 {
@@ -680,10 +690,6 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin
                Object *ob = eff->ob;
                Object obcopy = *ob;
 
-               /* XXX this is not thread-safe, but used from multiple threads by
-                  particle system */
-               where_is_object_time(eff->scene, ob, cfra);
-
                /* use z-axis as normal*/
                normalize_v3_v3(efd->nor, ob->obmat[2]);
 
@@ -702,13 +708,8 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin
                        VECCOPY(efd->loc, ob->obmat[3]);
                }
 
-               if(real_velocity) {
-                       VECCOPY(efd->vel, ob->obmat[3]);
-
-                       where_is_object_time(eff->scene, ob, cfra - 1.0f);
-
-                       sub_v3_v3v3(efd->vel, efd->vel, ob->obmat[3]);
-               }
+               if(real_velocity)
+                       copy_v3_v3(efd->vel, eff->velocity);
 
                *eff->ob = obcopy;
 
index 85f8f93a4762c0d2a80e3c861c0da53a80053757..3c29369c6ac5ace2f82fdb65e0ddce0256614ba5 100644 (file)
@@ -853,7 +853,7 @@ uiLayout *uiTemplateModifier(uiLayout *layout, bContext *C, PointerRNA *ptr)
 
        /* verify we have valid data */
        if(!RNA_struct_is_a(ptr->type, &RNA_Modifier)) {
-               RNA_warning("uiTemplateModifier: expected modifier on object.\n");
+               RNA_warning("uiTemplateModifier: Expected modifier on object.\n");
                return NULL;
        }
 
@@ -861,7 +861,7 @@ uiLayout *uiTemplateModifier(uiLayout *layout, bContext *C, PointerRNA *ptr)
        md= ptr->data;
 
        if(!ob || !(GS(ob->id.name) == ID_OB)) {
-               RNA_warning("uiTemplateModifier: expected modifier on object.\n");
+               RNA_warning("uiTemplateModifier: Expected modifier on object.\n");
                return NULL;
        }
        
@@ -978,9 +978,6 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con)
        block= uiLayoutGetBlock(box);
 
        /* Draw constraint header */
-       
-       /* rounded header */
-       // rb_col= (con->flag & CONSTRAINT_ACTIVE)?50:20; // UNUSED
 
        /* open/close */
        uiBlockSetEmboss(block, UI_EMBOSSN);
@@ -1085,7 +1082,7 @@ uiLayout *uiTemplateConstraint(uiLayout *layout, PointerRNA *ptr)
 
        /* verify we have valid data */
        if(!RNA_struct_is_a(ptr->type, &RNA_Constraint)) {
-               RNA_warning("uiTemplateConstraint: expected constraint on object.\n");
+               RNA_warning("uiTemplateConstraint: Expected constraint on object.\n");
                return NULL;
        }
 
@@ -1093,7 +1090,7 @@ uiLayout *uiTemplateConstraint(uiLayout *layout, PointerRNA *ptr)
        con= ptr->data;
 
        if(!ob || !(GS(ob->id.name) == ID_OB)) {
-               RNA_warning("uiTemplateConstraint: expected constraint on object.\n");
+               RNA_warning("uiTemplateConstraint: Expected constraint on object.\n");
                return NULL;
        }
        
@@ -1139,7 +1136,7 @@ void uiTemplatePreview(uiLayout *layout, ID *id, int show_buttons, ID *parent, M
        PointerRNA texture_ptr;
 
        if(id && !ELEM4(GS(id->name), ID_MA, ID_TE, ID_WO, ID_LA)) {
-               RNA_warning("uiTemplatePreview: expected ID of type material, texture, lamp or world.\n");
+               RNA_warning("uiTemplatePreview: Expected ID of type material, texture, lamp or world.\n");
                return;
        }
 
@@ -2198,14 +2195,14 @@ void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char *
        if(prop) {
                type= RNA_property_type(prop);
                if(type != PROP_COLLECTION) {
-                       RNA_warning("uiTemplateList: expected collection property.\n");
+                       RNA_warning("uiTemplateList: Expected collection property.\n");
                        return;
                }
        }
 
        activetype= RNA_property_type(activeprop);
        if(activetype != PROP_INT) {
-               RNA_warning("uiTemplateList: expected integer property.\n");
+               RNA_warning("uiTemplateList: Expected integer property.\n");
                return;
        }
 
index 29a740affc534051240f5303cda2208fd106211c..395705dc029c8b501d156d2cfaf79438cc16a707 100644 (file)
@@ -2162,16 +2162,20 @@ static int game_property_copy_exec(bContext *C, wmOperator *op)
                        } CTX_DATA_END;
                }
        }
-       else if (ELEM(type, COPY_PROPERTIES_REPLACE, COPY_PROPERTIES_MERGE)) {
+
+       else {
                CTX_DATA_BEGIN(C, Object*, ob_iter, selected_editable_objects) {
                        if (ob != ob_iter) {
                                if (ob->data != ob_iter->data){
-                                       if (type == 2) {/* merge */
+                                       if (type == COPY_PROPERTIES_REPLACE)
+                                               copy_properties( &ob_iter->prop, &ob->prop );
+
+                                       /* merge - the default when calling with no argument */
+                                       else {
                                                for(prop = ob->prop.first; prop; prop= prop->next ) {
                                                        set_ob_property(ob_iter, prop);
                                                }
-                                       } else /* replace */
-                                               copy_properties( &ob_iter->prop, &ob->prop );
+                                       }
                                }
                        }
                }
index 75c8d5cae73110c7628f60d629da4f8c3f7042e0..ae80a554e08796d872a5f9afe517fdddeb26721e 100644 (file)
@@ -505,17 +505,6 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C)
                uiItemR(row, &v3dptr, "pivot_point", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
                uiItemR(row, &v3dptr, "use_pivot_point_align", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
 
-               /* NDOF */
-               /* Not implemented yet
-               if (G.ndofdevice ==0 ) {
-                       uiDefIconTextButC(block, ICONTEXTROW,B_NDOF, ICON_NDOF_TURN, ndof_pup(), 0,0,UI_UNIT_X+10,UI_UNIT_Y, &(v3d->ndofmode), 0, 3.0, 0, 0, "Ndof mode");
-
-                       uiDefIconButC(block, TOG, B_NDOF,  ICON_NDOF_DOM,
-                                       0,0,UI_UNIT_X,UI_UNIT_Y,
-                                       &v3d->ndoffilter, 0, 1, 0, 0, "dominant axis");
-               }
-                */
-
                /* Transform widget / manipulators */
                row= uiLayoutRow(layout, 1);
                uiItemR(row, &v3dptr, "show_manipulator", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
index ff01e3a8a1e7838a9a1118b7d9670e2ea7e7c00f..36123592c546e289f519a871c60d99b99b551dc2 100644 (file)
@@ -252,7 +252,7 @@ void IMB_filter(struct ImBuf *ibuf);
 void IMB_filterN(struct ImBuf *out, struct ImBuf *in);
 void IMB_mask_filter_extend(char *mask, int width, int height);
 void IMB_mask_clear(struct ImBuf *ibuf, char *mask, int val);
-void IMB_filter_extend(struct ImBuf *ibuf, char *mask);
+void IMB_filter_extend(struct ImBuf *ibuf, char *mask, int filter);
 void IMB_makemipmap(struct ImBuf *ibuf, int use_filter);
 void IMB_remakemipmap(struct ImBuf *ibuf, int use_filter);
 struct ImBuf *IMB_getmipmap(struct ImBuf *ibuf, int level);
index d12360e5a7ead984f9436ec12f621018d9bdd6e6..1644e653df4aa87826999835ee81f3974d25f4cf 100644 (file)
@@ -21,7 +21,7 @@
  *
  * The Original Code is: all of this file.
  *
- * Contributor(s): none yet.
+ * Contributor(s): Morten Mikkelsen.
  *
  * ***** END GPL LICENSE BLOCK *****
  * filter.c
@@ -326,121 +326,132 @@ void IMB_mask_clear(ImBuf *ibuf, char *mask, int val)
        }
 }
 
-#define EXTEND_PIXEL(color, w) if((color)[3]) {r+= w*(color)[0]; g+= w*(color)[1]; b+= w*(color)[2]; a+= w*(color)[3]; tot+=w;}
+static int filter_make_index(const int x, const int y, const int w, const int h)
+{
+       if(x<0 || x>=w || y<0 || y>=h) return -1;       /* return bad index */
+       else return y*w+x;
+}
+
+static int check_pixel_assigned(const void *buffer, const char *mask, const int index, const int depth, const int is_float)
+{
+       int res = 0;
+
+       if(index>=0) {
+               const int alpha_index = depth*index+(depth-1);
+
+               if(mask!=NULL) {
+                       res = mask[index]!=0 ? 1 : 0;
+               }
+               else if( (is_float && ((const float *) buffer)[alpha_index]!=0.0f) ||
+                               (!is_float && ((const unsigned char *) buffer)[alpha_index]!=0) ) {
+                       res=1;
+               }
+       }
+
+       return res;
+}
 
 /* if alpha is zero, it checks surrounding pixels and averages color. sets new alphas to 1.0
  * 
  * When a mask is given, only effect pixels with a mask value of 1, defined as BAKE_MASK_MARGIN in rendercore.c
  * */
-void IMB_filter_extend(struct ImBuf *ibuf, char *mask)
+void IMB_filter_extend(struct ImBuf *ibuf, char *mask, int filter)
 {
-       register char *row1, *row2, *row3;
-       register char *cp; 
-       int rowlen, x, y;
-       
-       rowlen= ibuf->x;
-       
-       
-       if (ibuf->rect_float) {
-               float *temprect;
-               float *row1f, *row2f, *row3f;
-               float *fp;
-               temprect= MEM_dupallocN(ibuf->rect_float);
-               
-               for(y=1; y<=ibuf->y; y++) {
-                       /* setup rows */
-                       row1f= (float *)(temprect + (y-2)*rowlen*4);
-                       row2f= row1f + 4*rowlen;
-                       row3f= row2f + 4*rowlen;
-                       if(y==1)
-                               row1f= row2f;
-                       else if(y==ibuf->y)
-                               row3f= row2f;
-                       
-                       fp= (float *)(ibuf->rect_float + (y-1)*rowlen*4);
-                               
-                       for(x=0; x<rowlen; x++) {
-                               if((mask==NULL && fp[3]==0.0f) || (mask && mask[((y-1)*rowlen)+x]==1)) {
-                                       int tot= 0;
-                                       float r=0.0f, g=0.0f, b=0.0f, a=0.0f;
-                                       
-                                       EXTEND_PIXEL(row1f, 1);
-                                       EXTEND_PIXEL(row2f, 2);
-                                       EXTEND_PIXEL(row3f, 1);
-                                       EXTEND_PIXEL(row1f+4, 2);
-                                       EXTEND_PIXEL(row3f+4, 2);
-                                       if(x!=rowlen-1) {
-                                               EXTEND_PIXEL(row1f+8, 1);
-                                               EXTEND_PIXEL(row2f+8, 2);
-                                               EXTEND_PIXEL(row3f+8, 1);
-                                       }                                       
-                                       if(tot) {
-                                               fp[0]= r/tot;
-                                               fp[1]= g/tot;
-                                               fp[2]= b/tot;
-                                               fp[3]= a/tot;
+       const int width= ibuf->x;
+       const int height= ibuf->y;
+       const int depth= 4;             /* always 4 channels */
+       const int chsize= ibuf->rect_float ? sizeof(float) : sizeof(unsigned char);
+       const int bsize= width*height*depth*chsize;
+       const int is_float= ibuf->rect_float!=NULL;
+       void *dstbuf= (void *) MEM_dupallocN(ibuf->rect_float ? (void *) ibuf->rect_float : (void *) ibuf->rect);
+       char *dstmask= mask==NULL ? NULL : (char *) MEM_dupallocN(mask);
+       void *srcbuf= ibuf->rect_float ? (void *) ibuf->rect_float : (void *) ibuf->rect;
+       char *srcmask= mask;
+       int cannot_early_out= 1, r, n, k, i, j, c;
+       float weight[25];
+
+       /* build a weights buffer */
+       n= 2;
+       k= 0;
+       for(i = -n; i <= n; i++)
+               for(j = -n; j <= n; j++)
+                       weight[k++] = sqrt((float) i * i + j * j);
+
+       /* run passes */
+       for(r = 0; cannot_early_out == 1 && r < filter; r++) {
+               int x, y;
+               cannot_early_out = 0;
+
+               for(y= 0; y<height; y++) {
+                       for(x= 0; x<width; x++) {
+                               const int index= filter_make_index(x, y, width, height);
+
+                               /* only update unassigned pixels */
+                               if(!check_pixel_assigned(srcbuf, srcmask, index, depth, is_float)) {
+                                       float tmp[4];
+                                       float wsum=0;
+                                       float acc[4]={0,0,0,0};
+                                       k = 0;
+
+                                       if (check_pixel_assigned(srcbuf, srcmask, filter_make_index(x-1, y, width, height), depth, is_float) ||
+                                               check_pixel_assigned(srcbuf, srcmask, filter_make_index(x+1, y, width, height), depth, is_float) ||
+                                               check_pixel_assigned(srcbuf, srcmask, filter_make_index(x, y-1, width, height), depth, is_float) ||
+                                               check_pixel_assigned(srcbuf, srcmask, filter_make_index(x, y+1, width, height), depth, is_float)) {
+                                               for(i= -n; i<=n; i++) {
+                                                       for(j=-n; j<=n; j++) {
+                                                               if(i != 0 || j != 0) {
+                                                                       const int tmpindex= filter_make_index(x+i, y+j, width, height);
+
+                                                                       if(check_pixel_assigned(srcbuf, srcmask, tmpindex, depth, is_float))    { 
+                                                                               if(is_float) {
+                                                                                       for(c=0; c<depth; c++)
+                                                                                               tmp[c] = ((const float *) srcbuf)[depth*tmpindex+c];
+                                                                               }
+                                                                               else {
+                                                                                       for(c=0; c<depth; c++)
+                                                                                               tmp[c] = (float) ((const unsigned char *) srcbuf)[depth*tmpindex+c];
+                                                                               }
+
+                                                                               wsum+= weight[k];
+
+                                                                               for(c=0; c<depth; c++)
+                                                                                       acc[c]+= weight[k] * tmp[c];
+                                                                       }
+                                                               }
+                                                               k++;
+                                                       }
+                                               }
+
+                                               if(wsum!=0) {
+                                                       for(c=0; c<depth; c++)
+                                                               acc[c]/= wsum;
+
+                                                       if(is_float) {
+                                                               for(c=0; c<depth; c++)
+                                                                       ((float *) dstbuf)[depth*index+c] = acc[c];
+                                                       }
+                                                       else {
+                                                               for(c=0; c<depth; c++) {
+                                                                       ((unsigned char *) dstbuf)[depth*index+c]= acc[c] > 255 ? 255 : (acc[c] < 0 ? 0 : ((unsigned char) (acc[c]+0.5f)));
+                                                               }
+                                                       }
+
+                                                       if(dstmask!=NULL) dstmask[index]=FILTER_MASK_MARGIN;    /* assigned */
+                                                       cannot_early_out = 1;
+                                               }
                                        }
                                }
-                               fp+=4; 
-                               
-                               if(x!=0) {
-                                       row1f+=4; row2f+=4; row3f+=4;
-                               }
                        }
                }
 
-               MEM_freeN(temprect);
-       }
-       else if(ibuf->rect) {
-               int *temprect;
-               
-               /* make a copy, to prevent flooding */
-               temprect= MEM_dupallocN(ibuf->rect);
-               
-               for(y=1; y<=ibuf->y; y++) {
-                       /* setup rows */
-                       row1= (char *)(temprect + (y-2)*rowlen);
-                       row2= row1 + 4*rowlen;
-                       row3= row2 + 4*rowlen;
-                       if(y==1)
-                               row1= row2;
-                       else if(y==ibuf->y)
-                               row3= row2;
-                       
-                       cp= (char *)(ibuf->rect + (y-1)*rowlen);
-                       
-                       for(x=0; x<rowlen; x++) {
-                               /*if(cp[3]==0) {*/
-                               if((mask==NULL && cp[3]==0) || (mask && mask[((y-1)*rowlen)+x]==1)) {
-                                       int tot= 0, r=0, g=0, b=0, a=0;
-                                       
-                                       EXTEND_PIXEL(row1, 1);
-                                       EXTEND_PIXEL(row2, 2);
-                                       EXTEND_PIXEL(row3, 1);
-                                       EXTEND_PIXEL(row1+4, 2);
-                                       EXTEND_PIXEL(row3+4, 2);
-                                       if(x!=rowlen-1) {
-                                               EXTEND_PIXEL(row1+8, 1);
-                                               EXTEND_PIXEL(row2+8, 2);
-                                               EXTEND_PIXEL(row3+8, 1);
-                                       }                                       
-                                       if(tot) {
-                                               cp[0]= r/tot;
-                                               cp[1]= g/tot;
-                                               cp[2]= b/tot;
-                                               cp[3]= a/tot;
-                                       }
-                               }
-                               cp+=4;
-                               
-                               if(x!=0) {
-                                       row1+=4; row2+=4; row3+=4;
-                               }
-                       }
-               }
-               
-               MEM_freeN(temprect);
+               /* keep the original buffer up to date. */
+               memcpy(srcbuf, dstbuf, bsize);
+               if(dstmask!=NULL) memcpy(srcmask, dstmask, width*height);
        }
+
+       /* free memory */
+       MEM_freeN(dstbuf);
+       if(dstmask!=NULL) MEM_freeN(dstmask);
 }
 
 /* threadsafe version, only recreates existing maps */
index 9f751da484e43349f07c811f43a7b68d7bdd29af..d9475eaa6832d65bb7bf13d8ae9a26902d1b379f 100644 (file)
@@ -2815,7 +2815,7 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
        
        prop= RNA_def_property(srna, "bake_margin", PROP_INT, PROP_NONE);
        RNA_def_property_int_sdna(prop, NULL, "bake_filter");
-       RNA_def_property_range(prop, 0, 32);
+       RNA_def_property_range(prop, 0, 64);
        RNA_def_property_ui_text(prop, "Margin", "Amount of pixels to extend the baked result with, as post process filter");
 
        prop= RNA_def_property(srna, "bake_distance", PROP_FLOAT, PROP_NONE);
index 3aca334cffe096d74a57fd6a6d8e45a15f2972ee..a7e19c8db4f474123ee73f975aaf7e3847e43424 100644 (file)
@@ -2577,27 +2577,7 @@ void RE_bake_ibuf_filter(ImBuf *ibuf, char *mask, const int filter)
 
        /* Margin */
        if(filter) {
-               char *temprect;
-               int i;
-
-               /* extend the mask +2 pixels from the image,
-                * this is so colors dont blend in from outside */
-
-               for(i=0; i< filter; i++)
-                       IMB_mask_filter_extend(mask, ibuf->x, ibuf->y);
-
-               temprect = MEM_dupallocN(mask);
-
-               /* expand twice to clear this many pixels, so they blend back in */
-               IMB_mask_filter_extend(temprect, ibuf->x, ibuf->y);
-               IMB_mask_filter_extend(temprect, ibuf->x, ibuf->y);
-
-               /* clear all pixels in the margin */
-               IMB_mask_clear(ibuf, temprect, FILTER_MASK_MARGIN);
-               MEM_freeN(temprect);
-
-               for(i= 0; i < filter; i++)
-                       IMB_filter_extend(ibuf, mask);
+               IMB_filter_extend(ibuf, mask, filter);
        }
 
        /* if the bake results in new alpha then change the image setting */