forked from bartvdbraak/blender
Four mirrored Weight Paint improvement/fixes:
- If the mirrored group doesn't exist yet, it creates that group now. - Painting on any non-mirror group (not a name complying mirror rules), it will now paint mirrored on the group itself. - The Mesh octree for mirror painting was not created on loading a file in WeightPaint mode, or on exiting Editmode for Mesh. This caused mirror painting to not work always. - Tweaked the threshold calculation for vertices, so it gives fewer misses.
This commit is contained in:
parent
51e70835cc
commit
63ca05b7b3
@ -120,14 +120,6 @@
|
|||||||
#include "BKE_utildefines.h"
|
#include "BKE_utildefines.h"
|
||||||
#include "BKE_modifier.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_butspace.h"
|
||||||
#include "BIF_editconstraint.h"
|
#include "BIF_editconstraint.h"
|
||||||
#include "BIF_editdeform.h"
|
#include "BIF_editdeform.h"
|
||||||
@ -137,7 +129,16 @@
|
|||||||
#include "BIF_editoops.h"
|
#include "BIF_editoops.h"
|
||||||
#include "BIF_editview.h"
|
#include "BIF_editview.h"
|
||||||
#include "BIF_editarmature.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_resources.h"
|
||||||
|
#include "BIF_screen.h"
|
||||||
|
#include "BIF_space.h"
|
||||||
|
#include "BIF_toolbox.h"
|
||||||
|
#include "BIF_toets.h"
|
||||||
|
|
||||||
#include "BSE_edit.h"
|
#include "BSE_edit.h"
|
||||||
#include "BSE_editipo.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();
|
set_seamtface();
|
||||||
allqueue(REDRAWIMAGE, 0);
|
allqueue(REDRAWIMAGE, 0);
|
||||||
}
|
}
|
||||||
|
if(G.f & G_WEIGHTPAINT)
|
||||||
|
mesh_octree_table(G.obedit, NULL, 'e');
|
||||||
}
|
}
|
||||||
else if (G.obedit->type==OB_ARMATURE){
|
else if (G.obedit->type==OB_ARMATURE){
|
||||||
load_editArmature();
|
load_editArmature();
|
||||||
|
@ -598,7 +598,7 @@ void sort_faces(void)
|
|||||||
|
|
||||||
#define MOC_RES 8
|
#define MOC_RES 8
|
||||||
#define MOC_NODE_RES 8
|
#define MOC_NODE_RES 8
|
||||||
#define MOC_THRESH 0.0001f
|
#define MOC_THRESH 0.0002f
|
||||||
|
|
||||||
typedef struct MocNode {
|
typedef struct MocNode {
|
||||||
struct MocNode *next;
|
struct MocNode *next;
|
||||||
@ -735,6 +735,9 @@ int mesh_octree_table(Object *ob, float *co, char mode)
|
|||||||
static float offs[3], div[3];
|
static float offs[3], div[3];
|
||||||
|
|
||||||
if(mode=='u') { /* use table */
|
if(mode=='u') { /* use table */
|
||||||
|
if(basetable==NULL)
|
||||||
|
mesh_octree_table(ob, NULL, 's');
|
||||||
|
|
||||||
if(basetable) {
|
if(basetable) {
|
||||||
Mesh *me= ob->data;
|
Mesh *me= ob->data;
|
||||||
bt= basetable + mesh_octree_get_base_offs(co, offs, div);
|
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 */
|
/* for quick unit coordinate calculus */
|
||||||
VECCOPY(offs, bb->vec[0]);
|
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);
|
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);
|
VecMulf(div, 1.0f/MOC_RES);
|
||||||
if(div[0]==0.0f) div[0]= 1.0f;
|
if(div[0]==0.0f) div[0]= 1.0f;
|
||||||
if(div[1]==0.0f) div[1]= 1.0f;
|
if(div[1]==0.0f) div[1]= 1.0f;
|
||||||
|
@ -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);
|
wpaint_blend(dw, uw, (float)alpha/255.0, paintweight);
|
||||||
|
|
||||||
if(Gwp.flag & VP_MIRROR_X) { /* x mirror painting */
|
if(Gwp.flag & VP_MIRROR_X) { /* x mirror painting */
|
||||||
if(vgroup_mirror != -1) {
|
int j= mesh_get_x_mirror_vert(ob, index);
|
||||||
int j= mesh_get_x_mirror_vert(ob, index);
|
if(j>=0) {
|
||||||
if(j>=0) {
|
/* copy, not paint again */
|
||||||
/* copy, not paint again */
|
if(vgroup_mirror != -1)
|
||||||
uw= verify_defweight(me->dvert+j, vgroup_mirror);
|
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);
|
vertexcosnos= mesh_get_mapped_verts_nors(ob);
|
||||||
|
|
||||||
/* this happens on a Bone select, when no vgroup existed yet */
|
/* this happens on a Bone select, when no vgroup existed yet */
|
||||||
if(ob->actdef==0) {
|
if(ob->actdef<=0) {
|
||||||
Object *modob;
|
Object *modob;
|
||||||
if((modob = modifiers_isDeformedByArmature(ob))) {
|
if((modob = modifiers_isDeformedByArmature(ob))) {
|
||||||
bPoseChannel *pchan;
|
bPoseChannel *pchan;
|
||||||
@ -1075,14 +1077,19 @@ void weight_paint(void)
|
|||||||
bDeformGroup *curdef;
|
bDeformGroup *curdef;
|
||||||
int actdef= 0;
|
int actdef= 0;
|
||||||
char name[32];
|
char name[32];
|
||||||
|
|
||||||
BLI_strncpy(name, defgroup->name, 32);
|
BLI_strncpy(name, defgroup->name, 32);
|
||||||
bone_flip_name(name, 0); // 0 = don't strip off number extensions
|
bone_flip_name(name, 0); // 0 = don't strip off number extensions
|
||||||
|
|
||||||
for (curdef = ob->defbase.first; curdef; curdef=curdef->next, actdef++)
|
for (curdef = ob->defbase.first; curdef; curdef=curdef->next, actdef++)
|
||||||
if (!strcmp(curdef->name, name))
|
if (!strcmp(curdef->name, name))
|
||||||
break;
|
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)
|
if(curdef && curdef!=defgroup)
|
||||||
vgroup_mirror= actdef;
|
vgroup_mirror= actdef;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user