diff --git a/source/blender/src/editobject.c b/source/blender/src/editobject.c index 088a66f378a..a7a8ba0c5a6 100644 --- a/source/blender/src/editobject.c +++ b/source/blender/src/editobject.c @@ -120,14 +120,6 @@ #include "BKE_utildefines.h" #include "BKE_modifier.h" -#include "BIF_gl.h" -#include "BIF_graphics.h" -#include "BIF_interface.h" -#include "BIF_mywindow.h" -#include "BIF_toolbox.h" -#include "BIF_screen.h" -#include "BIF_space.h" -#include "BIF_toets.h" #include "BIF_butspace.h" #include "BIF_editconstraint.h" #include "BIF_editdeform.h" @@ -137,7 +129,16 @@ #include "BIF_editoops.h" #include "BIF_editview.h" #include "BIF_editarmature.h" +#include "BIF_gl.h" +#include "BIF_graphics.h" +#include "BIF_interface.h" +#include "BIF_meshtools.h" +#include "BIF_mywindow.h" #include "BIF_resources.h" +#include "BIF_screen.h" +#include "BIF_space.h" +#include "BIF_toolbox.h" +#include "BIF_toets.h" #include "BSE_edit.h" #include "BSE_editipo.h" @@ -1504,6 +1505,8 @@ void exit_editmode(int freedata) /* freedata==0 at render, 1= freedata, 2= do un set_seamtface(); allqueue(REDRAWIMAGE, 0); } + if(G.f & G_WEIGHTPAINT) + mesh_octree_table(G.obedit, NULL, 'e'); } else if (G.obedit->type==OB_ARMATURE){ load_editArmature(); diff --git a/source/blender/src/meshtools.c b/source/blender/src/meshtools.c index 2a8ee7570af..1ef7320763c 100644 --- a/source/blender/src/meshtools.c +++ b/source/blender/src/meshtools.c @@ -598,7 +598,7 @@ void sort_faces(void) #define MOC_RES 8 #define MOC_NODE_RES 8 -#define MOC_THRESH 0.0001f +#define MOC_THRESH 0.0002f typedef struct MocNode { struct MocNode *next; @@ -735,6 +735,9 @@ int mesh_octree_table(Object *ob, float *co, char mode) static float offs[3], div[3]; if(mode=='u') { /* use table */ + if(basetable==NULL) + mesh_octree_table(ob, NULL, 's'); + if(basetable) { Mesh *me= ob->data; bt= basetable + mesh_octree_get_base_offs(co, offs, div); @@ -751,7 +754,15 @@ int mesh_octree_table(Object *ob, float *co, char mode) /* for quick unit coordinate calculus */ VECCOPY(offs, bb->vec[0]); + offs[0]+= MOC_THRESH; /* we offset it 1 threshold unit extra */ + offs[1]+= MOC_THRESH; + offs[2]+= MOC_THRESH; + VecSubf(div, bb->vec[6], offs); + div[0]+= MOC_THRESH; /* and divide with 1 threshold unit more extra (try 8x8 unit grid on paint) */ + div[1]+= MOC_THRESH; + div[2]+= MOC_THRESH; + VecMulf(div, 1.0f/MOC_RES); if(div[0]==0.0f) div[0]= 1.0f; if(div[1]==0.0f) div[1]= 1.0f; diff --git a/source/blender/src/vpaint.c b/source/blender/src/vpaint.c index ec73a3c5ec6..ad62f6c0dc0 100644 --- a/source/blender/src/vpaint.c +++ b/source/blender/src/vpaint.c @@ -969,13 +969,15 @@ static void do_weight_paint_vertex(Object *ob, int index, int alpha, float paint wpaint_blend(dw, uw, (float)alpha/255.0, paintweight); if(Gwp.flag & VP_MIRROR_X) { /* x mirror painting */ - if(vgroup_mirror != -1) { - int j= mesh_get_x_mirror_vert(ob, index); - if(j>=0) { - /* copy, not paint again */ + int j= mesh_get_x_mirror_vert(ob, index); + if(j>=0) { + /* copy, not paint again */ + if(vgroup_mirror != -1) uw= verify_defweight(me->dvert+j, vgroup_mirror); - uw->weight= dw->weight; - } + else + uw= verify_defweight(me->dvert+j, vgroup); + + uw->weight= dw->weight; } } } @@ -1020,7 +1022,7 @@ void weight_paint(void) vertexcosnos= mesh_get_mapped_verts_nors(ob); /* this happens on a Bone select, when no vgroup existed yet */ - if(ob->actdef==0) { + if(ob->actdef<=0) { Object *modob; if((modob = modifiers_isDeformedByArmature(ob))) { bPoseChannel *pchan; @@ -1075,14 +1077,19 @@ void weight_paint(void) bDeformGroup *curdef; int actdef= 0; char name[32]; - + BLI_strncpy(name, defgroup->name, 32); bone_flip_name(name, 0); // 0 = don't strip off number extensions for (curdef = ob->defbase.first; curdef; curdef=curdef->next, actdef++) if (!strcmp(curdef->name, name)) break; - + if(curdef==NULL) { + int olddef= ob->actdef; /* tsk, add_defgroup sets the active defgroup */ + curdef= add_defgroup_name (ob, name); + ob->actdef= olddef; + } + if(curdef && curdef!=defgroup) vgroup_mirror= actdef; }