Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Hays <jason_hays22@mymail.eku.edu>2011-09-18 05:09:18 +0400
committerJason Hays <jason_hays22@mymail.eku.edu>2011-09-18 05:09:18 +0400
commit1b5d16f1bf80f2da8d3d4da5bbfaf4819c14a225 (patch)
treebd0b61b204bfc020c9ab781a3e6183a4c45fca6c
parent101937e2ddf4d0453868373b644873586febf6e2 (diff)
I made multitude of fixes based on the comments provided online:
Removed the drawSelectedVerts and added drawSelectedVertices, which uses dm->foreachMappedVert. In calc_weightpaint_vert_color(): Made the weight paint color black and return instead of input=-1 Made the pose bone selection normal when multi-paint is inactive. Name fix for functions using mv instead of mvert. Used vector functions provided by the math lib. Changed some MEM_callocN references to be stacks. Changed dm_deform_clear to use ob->derivedDeform primarily Made the variable "float **changes" into "float (*changes)[2]" Used CTX_data_active_object() in place of CTX_data_pointer_get_type() Added the invert selection hotkey "Ctrl+I" to weight paint's vertex mask.
-rw-r--r--source/blender/blenkernel/BKE_DerivedMesh.h3
-rw-r--r--source/blender/blenkernel/intern/DerivedMesh.c14
-rw-r--r--source/blender/blenkernel/intern/cdderivedmesh.c40
-rw-r--r--source/blender/editors/armature/editarmature.c9
-rw-r--r--source/blender/editors/mesh/editmesh.c2
-rw-r--r--source/blender/editors/object/object_vgroup.c110
-rw-r--r--source/blender/editors/sculpt_paint/paint_intern.h1
-rw-r--r--source/blender/editors/sculpt_paint/paint_ops.c2
-rw-r--r--source/blender/editors/sculpt_paint/paint_utils.c19
-rw-r--r--source/blender/editors/space_view3d/drawobject.c60
10 files changed, 133 insertions, 127 deletions
diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h
index a109d5722ab..6e17b056685 100644
--- a/source/blender/blenkernel/BKE_DerivedMesh.h
+++ b/source/blender/blenkernel/BKE_DerivedMesh.h
@@ -222,9 +222,6 @@ struct DerivedMesh {
/* Draw all vertices as bgl points (no options) */
void (*drawVerts)(DerivedMesh *dm);
- /* Jason Draw all selected vertices as bgl points (no options) */
- void (*drawSelectedVerts)(DerivedMesh *dm);
-
/* Draw edges in the UV mesh (if exists) */
void (*drawUVEdges)(DerivedMesh *dm);
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index e4198d578c4..10feba59ccc 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -1726,13 +1726,15 @@ static void calc_weightpaint_vert_color(Object *ob, ColorBand *coba, int vert, u
}
if (make_black) {
- input = -1;
- }
- else {
- CLAMP(input, 0.0f, 1.0f);
+ col[3] = 0;
+ col[2] = 0;
+ col[1] = 0;
+ col[0] = 255;
+ return;
}
-
-
+
+ CLAMP(input, 0.0f, 1.0f);
+
if(coba)
do_colorband(coba, input, colf);
else
diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c
index d810de9d182..44359a142c9 100644
--- a/source/blender/blenkernel/intern/cdderivedmesh.c
+++ b/source/blender/blenkernel/intern/cdderivedmesh.c
@@ -265,44 +265,6 @@ static void cdDM_update_normals_from_pbvh(DerivedMesh *dm)
BLI_pbvh_update(cddm->pbvh, PBVH_UpdateNormals, face_nors);
}
-// Jason
-static void cdDM_drawSelectedVerts(DerivedMesh *dm)
-{
- CDDerivedMesh *cddm = (CDDerivedMesh*) dm;
- MVert *mv = cddm->mvert;
- int i;
- if( GPU_buffer_legacy(dm) ) {
- char prev_sel= 0; /* always invalid */;
-
- glBegin(GL_POINTS);
- for(i = 0; i < dm->numVertData; i++, mv++) {
- if(!(mv->flag & ME_HIDE)) {
- const char sel= mv->flag & 1;
- if(prev_sel != sel) {
- prev_sel= sel;
-
- // TODO define selected color
- if(sel) {
- glColor3f(1.0f, 1.0f, 0.0f);
- }else {
- glColor3f(0.0f, 0.0f, 0.0f);
- }
- }
-
- glVertex3fv(mv->co);
- }
- }
- glEnd();
- }
- else { /* use OpenGL VBOs or Vertex Arrays instead for better, faster rendering */
- GPU_vertex_setup(dm);
- if( !GPU_buffer_legacy(dm) ) {
- if(dm->drawObject->tot_triangle_point) glDrawArrays(GL_POINTS,0, dm->drawObject->tot_triangle_point);
- else glDrawArrays(GL_POINTS,0, dm->drawObject->tot_loose_point);
- }
- GPU_buffer_unbind();
- }
-}
static void cdDM_drawVerts(DerivedMesh *dm)
{
@@ -1589,8 +1551,6 @@ static CDDerivedMesh *cdDM_create(const char *desc)
dm->getFaceMap = cdDM_getFaceMap;
dm->drawVerts = cdDM_drawVerts;
- // Jason
- dm->drawSelectedVerts = cdDM_drawSelectedVerts;
dm->drawUVEdges = cdDM_drawUVEdges;
dm->drawEdges = cdDM_drawEdges;
diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c
index ad140681c66..80a7e703474 100644
--- a/source/blender/editors/armature/editarmature.c
+++ b/source/blender/editors/armature/editarmature.c
@@ -4297,8 +4297,6 @@ int ED_do_pose_selectbuffer(Scene *scene, Base *base, unsigned int *buffer, shor
{
Object *ob= base->object;
Bone *nearBone;
- // Jason
- Bone *new_act_bone;
if (!ob || !ob->pose) return 0;
@@ -4310,7 +4308,8 @@ int ED_do_pose_selectbuffer(Scene *scene, Base *base, unsigned int *buffer, shor
/* since we do unified select, we don't shift+select a bone if the armature object was not active yet */
/* Jason was here, I'm doing a select for multibone painting */
- if ((base != scene->basact)) {//if (!(extend) || (base != scene->basact)) {
+ if (scene->toolsettings->multipaint && (base != scene->basact)) {//if (!(extend) || (base != scene->basact)) {
+ Bone *new_act_bone;
/* Jason was here */
/* only deselect all if they aren't using 'shift' */
if(!extend) {
@@ -4341,6 +4340,10 @@ int ED_do_pose_selectbuffer(Scene *scene, Base *base, unsigned int *buffer, shor
DAG_id_tag_update(&OBACT->id, OB_RECALC_DATA);
// XXX old cruft! use notifiers instead
//select_actionchannel_by_name(ob->action, nearBone->name, 1);
+ } else if (!(extend) || (base != scene->basact)) {
+ ED_pose_deselectall(ob, 0);
+ nearBone->flag |= (BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL);
+ arm->act_bone= nearBone;
}
else {
if (nearBone->flag & BONE_SELECTED) {
diff --git a/source/blender/editors/mesh/editmesh.c b/source/blender/editors/mesh/editmesh.c
index 1634b464dfd..024331e8dc6 100644
--- a/source/blender/editors/mesh/editmesh.c
+++ b/source/blender/editors/mesh/editmesh.c
@@ -1992,7 +1992,7 @@ void paintvert_flush_flags(Object *ob)
}
}
}
-/* Jason note: caller needs to run paintvert_flush_flags(ob) after this */
+/* Jason note: if the caller passes FALSE to flush_flags, then they will need to run paintvert_flush_flags(ob) themselves */
void paintvert_deselect_all_visible(Object *ob, int action, short flush_flags)
{
Mesh *me;
diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c
index 7f78f25e1ce..f1fb879f4c9 100644
--- a/source/blender/editors/object/object_vgroup.c
+++ b/source/blender/editors/object/object_vgroup.c
@@ -705,7 +705,7 @@ static void vgroup_normalize(Object *ob)
int i, def_nr, dvert_tot=0;
// Jason
Mesh *me = ob->data;
- MVert *mv = me->mvert;
+ MVert *mvert = me->mvert;
const int use_vert_sel= (me->editflag & ME_EDIT_VERT_SEL) != 0;
ED_vgroup_give_parray(ob->data, &dvert_array, &dvert_tot);
@@ -719,7 +719,7 @@ static void vgroup_normalize(Object *ob)
for(i = 0; i < dvert_tot; i++) {
// Jason
- if(use_vert_sel && !((mv+i)->flag & SELECT)) {
+ if(use_vert_sel && !((mvert+i)->flag & SELECT)) {
continue;
}
@@ -733,7 +733,7 @@ static void vgroup_normalize(Object *ob)
if(weight_max > 0.0f) {
for(i = 0; i < dvert_tot; i++) {
// Jason
- if(use_vert_sel && !((mv+i)->flag & SELECT)) {
+ if(use_vert_sel && !((mvert+i)->flag & SELECT)) {
continue;
}
@@ -848,19 +848,13 @@ static int* getSurroundingVerts(Mesh *me, int vert, int *count) {
/* get a single point in space by averaging a point cloud (vectors of size 3)
coord is the place the average is stored, points is the point cloud, count is the number of points in the cloud
*/
-static void getSingleCoordinate(MVert **points, int count, float *coord) {
- int i, k;
- for(k = 0; k < 3; k++) {
- coord[k] = 0;
- }
+static void getSingleCoordinate(MVert *points, int count, float coord[3]) {
+ int i;
+ zero_v3(coord);
for(i = 0; i < count; i++) {
- for(k = 0; k < 3; k++) {
- coord[k] += points[i]->co[k];
- }
- }
- for(k = 0; k < 3; k++) {
- coord[k] /= count;
+ add_v3_v3(coord, points[i].co);
}
+ mul_v3_fl(coord, 1.0f/count);
}
/* Jason */
/* find the closest point on a plane to another point and store it in dst */
@@ -894,12 +888,11 @@ static float distance(float* a, float *b, int length) {
compute the amount of vertical distance relative to the plane and store it in dists,
then get the horizontal and vertical change and store them in changes
*/
-static void getVerticalAndHorizontalChange(float *norm, float d, float *coord, float *start, float distToStart, float *end, float **changes, float *dists, int index) {
+static void getVerticalAndHorizontalChange(float *norm, float d, float *coord, float *start, float distToStart, float *end, float (*changes)[2], float *dists, int index) {
// A=Q-((Q-P).N)N
// D = (a*x0 + b*y0 +c*z0 +d)
- float *projA, *projB;
- projA = MEM_callocN(sizeof(float)*3, "projectedA");
- projB = MEM_callocN(sizeof(float)*3, "projectedB");
+ float projA[3] = {0}, projB[3] = {0};
+
getNearestPointOnPlane(norm, coord, start, projA);
getNearestPointOnPlane(norm, coord, end, projB);
// (vertical and horizontal refer to the plane's y and xz respectively)
@@ -910,16 +903,19 @@ static void getVerticalAndHorizontalChange(float *norm, float d, float *coord, f
//printf("vc %f %f\n", distance(end, projB, 3)-distance(start, projA, 3), changes[index][0]);
// horizontal change
changes[index][1] = distance(projA, projB, 3);
-
- MEM_freeN(projA);
- MEM_freeN(projB);
}
// Jason
// I need the derived mesh to be forgotten so the positions are recalculated with weight changes (see dm_deform_recalc)
static void dm_deform_clear(DerivedMesh *dm, Object *ob) {
- dm->needsFree = 1;
- dm->release(dm);
- ob->derivedDeform=NULL;
+ if(ob->derivedDeform && (ob->derivedDeform)==dm) {
+ ob->derivedDeform->needsFree = 1;
+ ob->derivedDeform->release(ob->derivedDeform);
+ ob->derivedDeform = NULL;
+ }
+ else if(dm) {
+ dm->needsFree = 1;
+ dm->release(dm);
+ }
}
// Jason
// recalculate the deformation
@@ -935,17 +931,17 @@ index is the index of the vertex being moved
norm and d are the plane's properties for the equation: ax + by + cz + d = 0
coord is a point on the plane
*/
-static void moveCloserToDistanceFromPlane(Scene *scene, Object *ob, Mesh *me, int index, float *norm, float *coord, float d, float distToBe, float strength, float cp) {
+static void moveCloserToDistanceFromPlane(Scene *scene, Object *ob, Mesh *me, int index, float norm[3], float coord[3], float d, float distToBe, float strength, float cp) {
DerivedMesh *dm;
MDeformWeight *dw;
MVert m;
MDeformVert *dvert = me->dvert+index;
int totweight = dvert->totweight;
float oldw = 0;
- float *oldPos = MEM_callocN(sizeof(float)*3, "oldPosition");
+ float oldPos[3] = {0};
float vc, hc, dist;
int i, k;
- float **changes = MEM_mallocN(sizeof(float *)*totweight, "vertHorzChange");
+ float (*changes)[2] = MEM_mallocN(sizeof(float *)*totweight*2, "vertHorzChange");
float *dists = MEM_mallocN(sizeof(float)*totweight, "distance");
int *upDown = MEM_callocN(sizeof(int)*totweight, "upDownTracker");// track if up or down moved it closer for each bone
int *dwIndices = MEM_callocN(sizeof(int)*totweight, "dwIndexTracker");
@@ -955,9 +951,6 @@ static void moveCloserToDistanceFromPlane(Scene *scene, Object *ob, Mesh *me, in
char wasUp;
int lastIndex = -1;
float originalDistToBe = distToBe;
- for(i = 0; i < totweight; i++) {
- changes[i] = MEM_callocN(sizeof(float)*2, "vertHorzChange_"+i);
- }
do {
wasChange = FALSE;
dm = dm_deform_recalc(scene, ob);
@@ -1097,13 +1090,9 @@ static void moveCloserToDistanceFromPlane(Scene *scene, Object *ob, Mesh *me, in
}
}while(wasChange && (distToStart-distToBe)/fabs(distToStart-distToBe) == (dists[bestIndex]-distToBe)/fabs(dists[bestIndex]-distToBe));
MEM_freeN(upDown);
- for(i = 0; i < totweight; i++) {
- MEM_freeN(changes[i]);
- }
MEM_freeN(changes);
MEM_freeN(dists);
MEM_freeN(dwIndices);
- MEM_freeN(oldPos);
}
// Jason
/* this is used to try to smooth a surface by only adjusting the nonzero weights of a vertex
@@ -1113,43 +1102,42 @@ static void vgroup_fix(Scene *scene, Object *ob, float distToBe, float strength,
int i;
Mesh *me = ob->data;
- MVert *mv = me->mvert;
+ MVert *mvert = me->mvert;
const int use_vert_sel= (me->editflag & ME_EDIT_VERT_SEL) != 0;
int *verts = NULL;
- for(i = 0; i < me->totvert && mv; i++, mv++) {
+ for(i = 0; i < me->totvert && mvert; i++, mvert++) {
// Jason
- if(use_vert_sel && (mv->flag & SELECT)) {
+ if(use_vert_sel && (mvert->flag & SELECT)) {
int count=0;
if((verts = getSurroundingVerts(me, i, &count))) {
MVert m;
- MVert **p = MEM_callocN(sizeof(MVert*)*(count), "deformedPoints");
+ MVert *p = MEM_callocN(sizeof(MVert)*(count), "deformedPoints");
int k;
DerivedMesh *dm = mesh_get_derived_deform(scene, ob, CD_MASK_BAREMESH);
for(k = 0; k < count; k++) {
dm->getVert(dm, verts[k], &m);
- p[k] = &m;
+ p[k] = m;
}
if(count >= 3) {
float d /*, dist */ /* UNUSED */, mag;
- float *coord = MEM_callocN(sizeof(float)*3, "deformedCoord");
- float *norm = MEM_callocN(sizeof(float)*3, "planeNorm");
+ float coord[3] = {0};
+ float norm[3] = {0};
getSingleCoordinate(p, count, coord);
dm->getVert(dm, i, &m);
norm[0] = m.co[0]-coord[0];
norm[1] = m.co[1]-coord[1];
norm[2] = m.co[2]-coord[2];
mag = sqrt(norm[0]*norm[0] + norm[1]*norm[1] + norm[2]*norm[2]);
- for(k = 0; k < 3; k++) {
- norm[k]/=mag;
+ if(mag) {// zeros fix
+ mul_v3_fl(norm, 1.0f/mag);
+
+ d = -norm[0]*coord[0] -norm[1]*coord[1] -norm[2]*coord[2];
+ /* dist = (norm[0]*m.co[0] + norm[1]*m.co[1] + norm[2]*m.co[2] + d); */ /* UNUSED */
+ moveCloserToDistanceFromPlane(scene, ob, me, i, norm, coord, d, distToBe, strength, cp);
}
- d = -norm[0]*coord[0] -norm[1]*coord[1] -norm[2]*coord[2];
- /* dist = (norm[0]*m.co[0] + norm[1]*m.co[1] + norm[2]*m.co[2] + d); */ /* UNUSED */
- moveCloserToDistanceFromPlane(scene, ob, me, i, norm, coord, d, distToBe, strength, cp);
- MEM_freeN(coord);
- MEM_freeN(norm);
}
MEM_freeN(verts);
@@ -1167,7 +1155,7 @@ static void vgroup_levels(Object *ob, float offset, float gain)
int i, def_nr, dvert_tot=0;
// Jason
Mesh *me = ob->data;
- MVert *mv = me->mvert;
+ MVert *mvert = me->mvert;
const int use_vert_sel= (me->editflag & ME_EDIT_VERT_SEL) != 0;
ED_vgroup_give_parray(ob->data, &dvert_array, &dvert_tot);
@@ -1179,7 +1167,7 @@ static void vgroup_levels(Object *ob, float offset, float gain)
for(i = 0; i < dvert_tot; i++) {
// Jason
- if(use_vert_sel && !((mv+i)->flag & SELECT)) {
+ if(use_vert_sel && !((mvert+i)->flag & SELECT)) {
continue;
}
@@ -1206,7 +1194,7 @@ static void vgroup_normalize_all(Object *ob, int lock_active)
// Jason
Mesh *me = ob->data;
- MVert *mv = me->mvert;
+ MVert *mvert = me->mvert;
const int use_vert_sel= (me->editflag & ME_EDIT_VERT_SEL) != 0;
ED_vgroup_give_parray(ob->data, &dvert_array, &dvert_tot);
@@ -1219,7 +1207,7 @@ static void vgroup_normalize_all(Object *ob, int lock_active)
float lock_iweight= 1.0f;
int j;
// Jason
- if(use_vert_sel && !((mv+i)->flag & SELECT)) {
+ if(use_vert_sel && !((mvert+i)->flag & SELECT)) {
continue;
}
@@ -1263,7 +1251,7 @@ static void vgroup_normalize_all(Object *ob, int lock_active)
for(i = 0; i < dvert_tot; i++) {
int j;
// Jason
- if(use_vert_sel && !((mv+i)->flag & SELECT)) {
+ if(use_vert_sel && !((mvert+i)->flag & SELECT)) {
continue;
}
@@ -1331,7 +1319,7 @@ static void vgroup_invert(Object *ob, int auto_assign, int auto_remove)
int i, def_nr, dvert_tot=0;
// Jason
Mesh *me = ob->data;
- MVert *mv = me->mvert;
+ MVert *mvert = me->mvert;
const int use_vert_sel= (me->editflag & ME_EDIT_VERT_SEL) != 0;
ED_vgroup_give_parray(ob->data, &dvert_array, &dvert_tot);
@@ -1344,7 +1332,7 @@ static void vgroup_invert(Object *ob, int auto_assign, int auto_remove)
for(i = 0; i < dvert_tot; i++) {
// Jason
- if(use_vert_sel && !((mv+i)->flag & SELECT)) {
+ if(use_vert_sel && !((mvert+i)->flag & SELECT)) {
continue;
}
dvert = dvert_array[i];
@@ -1461,7 +1449,7 @@ static void vgroup_clean(Object *ob, float eul, int keep_single)
int i, def_nr, dvert_tot=0;
// Jason
Mesh *me = ob->data;
- MVert *mv = me->mvert;
+ MVert *mvert = me->mvert;
const int use_vert_sel= (me->editflag & ME_EDIT_VERT_SEL) != 0;
ED_vgroup_give_parray(ob->data, &dvert_array, &dvert_tot);
@@ -1473,7 +1461,7 @@ static void vgroup_clean(Object *ob, float eul, int keep_single)
for(i = 0; i < dvert_tot; i++) {
// Jason
- if(use_vert_sel && !((mv+i)->flag & SELECT)) {
+ if(use_vert_sel && !((mvert+i)->flag & SELECT)) {
continue;
}
dvert = dvert_array[i];
@@ -1499,7 +1487,7 @@ static void vgroup_clean_all(Object *ob, float eul, int keep_single)
int i, dvert_tot=0;
// Jason
Mesh *me = ob->data;
- MVert *mv = me->mvert;
+ MVert *mvert = me->mvert;
const int use_vert_sel= (me->editflag & ME_EDIT_VERT_SEL) != 0;
ED_vgroup_give_parray(ob->data, &dvert_array, &dvert_tot);
@@ -1508,7 +1496,7 @@ static void vgroup_clean_all(Object *ob, float eul, int keep_single)
for(i = 0; i < dvert_tot; i++) {
int j;
// Jason
- if(use_vert_sel && !((mv+i)->flag & SELECT)) {
+ if(use_vert_sel && !((mvert+i)->flag & SELECT)) {
continue;
}
@@ -2334,7 +2322,7 @@ void OBJECT_OT_vertex_group_normalize_all(wmOperatorType *ot)
/* Jason */
static int vertex_group_fix_exec(bContext *C, wmOperator *op)
{
- Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
+ Object *ob= CTX_data_active_object(C);
Scene *scene= CTX_data_scene(C);
float distToBe= RNA_float_get(op->ptr,"dist");
@@ -2382,7 +2370,7 @@ void OBJECT_OT_vertex_group_fix(wmOperatorType *ot)
/* Jason was here */
static int vertex_group_lock_exec(bContext *C, wmOperator *op)
{
- Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
+ Object *ob= CTX_data_active_object(C);
int action = RNA_enum_get(op->ptr, "action");
diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h
index 95a6d0c2732..c8ffdb73cf5 100644
--- a/source/blender/editors/sculpt_paint/paint_intern.h
+++ b/source/blender/editors/sculpt_paint/paint_intern.h
@@ -123,6 +123,7 @@ void PAINT_OT_face_select_hide(struct wmOperatorType *ot);
void PAINT_OT_face_select_reveal(struct wmOperatorType *ot);
/* Jason */
void PAINT_OT_vert_select_all(struct wmOperatorType *ot);
+void PAINT_OT_vert_select_inverse(struct wmOperatorType *ot);
int vert_paint_poll(struct bContext *C);
int mask_paint_poll(struct bContext *C);
diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c
index 6aab104b79a..5708cc0f602 100644
--- a/source/blender/editors/sculpt_paint/paint_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_ops.c
@@ -375,6 +375,7 @@ void ED_operatortypes_paint(void)
/* Jason, vertex selection */
WM_operatortype_append(PAINT_OT_vert_select_all);
+ WM_operatortype_append(PAINT_OT_vert_select_inverse);
/* vertex */
WM_operatortype_append(PAINT_OT_vertex_paint_toggle);
@@ -615,6 +616,7 @@ void ED_keymap_paint(wmKeyConfig *keyconf)
keymap= WM_keymap_find(keyconf, "Weight Paint Vertex Selection", 0, 0);
keymap->poll= vert_paint_poll;
WM_keymap_add_item(keymap, "PAINT_OT_vert_select_all", AKEY, KM_PRESS, 0, 0);
+ WM_keymap_add_item(keymap, "PAINT_OT_vert_select_inverse", IKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_item(keymap, "VIEW3D_OT_select_border", BKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "VIEW3D_OT_select_lasso", EVT_TWEAK_A, KM_ANY, KM_CTRL, 0);
RNA_boolean_set(WM_keymap_add_item(keymap, "VIEW3D_OT_select_lasso", EVT_TWEAK_A, KM_ANY, KM_SHIFT|KM_CTRL, 0)->ptr, "deselect", 1);
diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c
index 18f59536092..8d7a3323f57 100644
--- a/source/blender/editors/sculpt_paint/paint_utils.c
+++ b/source/blender/editors/sculpt_paint/paint_utils.c
@@ -381,7 +381,26 @@ void PAINT_OT_vert_select_all(wmOperatorType *ot)
WM_operator_properties_select_all(ot);
}
+/* Jason */
+static int vert_select_inverse_exec(bContext *C, wmOperator *UNUSED(op))
+{
+ Object *ob= CTX_data_active_object(C);
+ paintvert_deselect_all_visible(ob, SEL_INVERT, TRUE);
+ ED_region_tag_redraw(CTX_wm_region(C));
+ return OPERATOR_FINISHED;
+}
+/* Jason */
+void PAINT_OT_vert_select_inverse(wmOperatorType *ot)
+{
+ ot->name= "Vertex Select Invert";
+ ot->description= "Invert selection of vertices";
+ ot->idname= "PAINT_OT_vert_select_inverse";
+
+ ot->exec= vert_select_inverse_exec;
+ ot->poll= vert_paint_poll;
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
static int face_select_inverse_exec(bContext *C, wmOperator *UNUSED(op))
{
Object *ob= CTX_data_active_object(C);
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index 439f05c3986..7a10a7216d9 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -77,6 +77,7 @@
#include "BKE_pointcache.h"
#include "BKE_unit.h"
+
#include "smoke_API.h"
#include "IMB_imbuf.h"
@@ -85,6 +86,7 @@
#include "BIF_gl.h"
#include "BIF_glutil.h"
+#include "GPU_buffers.h"// Jason
#include "GPU_draw.h"
#include "GPU_extensions.h"
@@ -1752,6 +1754,32 @@ void mesh_obmode_foreachScreenVert(ViewContext *vc, void (*func)(void *userData,
dm->release(dm);
}
+
+/* Jason draw callback */
+static void drawSelectedVertices__mapFunc(void *userData, int index, float *co, float *no_f, short *no_s)
+{
+ MVert *mv = userData;
+ mv+=index;
+ //printf("%d\n", index);
+ if(!(mv->flag & ME_HIDE)) {
+ const char sel= mv->flag & 1;
+
+ // TODO define selected color
+ if(sel) {
+ glColor3f(1.0f, 1.0f, 0.0f);
+ }else {
+ glColor3f(0.0f, 0.0f, 0.0f);
+ }
+
+ glVertex3fv(co);
+ }
+}
+/* Jason */
+static void drawSelectedVertices(DerivedMesh *dm, Mesh *me) {
+ glBegin(GL_POINTS);
+ dm->foreachMappedVert(dm, drawSelectedVertices__mapFunc, me->mvert);
+ glEnd();
+}
static void mesh_foreachScreenEdge__mapFunc(void *userData, int index, float *v0co, float *v1co)
{
struct { void (*func)(void *userData, EditEdge *eed, int x0, int y0, int x1, int y1, int index); void *userData; ViewContext vc; int clipVerts; } *data = userData;
@@ -2937,10 +2965,13 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
}
}
// Jason
- if(paint_vertsel_test(ob) && dm->drawSelectedVerts) {
+ if(paint_vertsel_test(ob)) {
+
glColor3f(0.0f, 0.0f, 0.0f);
glPointSize(UI_GetThemeValuef(TH_VERTEX_SIZE));
- dm->drawSelectedVerts(dm);
+
+ drawSelectedVertices(dm, ob->data);
+
glPointSize(1.0f);
}
dm->release(dm);
@@ -6528,23 +6559,26 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
/* Jason */
static void bbs_obmode_mesh_verts__mapFunc(void *userData, int index, float *co, float *UNUSED(no_f), short *UNUSED(no_s))
{
- // TODO: support hidden vertices
- int offset = (intptr_t) userData;
- //EditVert *eve = EM_get_vert_for_index(index);
+ struct {void* offset; MVert *mvert;} *data = userData;
+ MVert *mv = data->mvert+index;
+ int offset = (intptr_t) data->offset;
- //if (eve->h==0) {
- WM_set_framebuffer_index_color(offset+index);
- bglVertex3fv(co);
- //}
+ if (!(mv->flag & ME_HIDE)) {
+ WM_set_framebuffer_index_color(offset+index);
+ bglVertex3fv(co);
+ }
}
/* Jason */
-static void bbs_obmode_mesh_verts(Object *UNUSED(ob), DerivedMesh *dm, int offset)
+static void bbs_obmode_mesh_verts(Object *ob, DerivedMesh *dm, int offset)
{
- /* Mesh *me = (Mesh*)ob->data; */ /* UNUSED */
-
+ struct {void* offset; struct MVert *mvert;} data;
+ Mesh *me = ob->data;
+ MVert *mvert = me->mvert;
+ data.mvert = mvert;
+ data.offset = (void*)(intptr_t) offset;
glPointSize( UI_GetThemeValuef(TH_VERTEX_SIZE) );
bglBegin(GL_POINTS);
- dm->foreachMappedVert(dm, bbs_obmode_mesh_verts__mapFunc, (void*)(intptr_t) offset);
+ dm->foreachMappedVert(dm, bbs_obmode_mesh_verts__mapFunc, &data);
bglEnd();
glPointSize(1.0);
}