[Bf-codereview] Weight paint transfer (issue 6301097)

ideasman42 at gmail.com ideasman42 at gmail.com
Tue Jun 19 09:27:34 CEST 2012


There are some logical errors with copying still that need resolving.


http://codereview.appspot.com/6301097/diff/1/source/blender/editors/object/object_vgroup.c
File source/blender/editors/object/object_vgroup.c (right):

http://codereview.appspot.com/6301097/diff/1/source/blender/editors/object/object_vgroup.c#newcode469
source/blender/editors/object/object_vgroup.c:469:
BKE_reportf(op->reports, RPT_ERROR, "Transfer failed. Source mesh does
not have vertices");
should be 'Source mesh does not have any vertex groups'

http://codereview.appspot.com/6301097/diff/1/source/blender/editors/object/object_vgroup.c#newcode515
source/blender/editors/object/object_vgroup.c:515: }
there should be an 'else {' ... here, which checks if 'dv_dst' has any
weights and clears them (at least when overwrite is enabled).

This will depend on the options selected, but you see the issue I hope.

http://codereview.appspot.com/6301097/diff/1/source/blender/editors/object/object_vgroup.c#newcode543
source/blender/editors/object/object_vgroup.c:543: }
there should be an 'else {' ... here, which checks if 'dv_dst' has any
weights and clears them (at least when overwrite is enabled). This will
depend on the options selected, but you see the issue I hope.

http://codereview.appspot.com/6301097/diff/1/source/blender/editors/object/object_vgroup.c#newcode599
source/blender/editors/object/object_vgroup.c:599: if
(&mface_src[index_nearest].v4 != NULL) v = 4;
comparing v4 with NULL is misleading, since its not a pointer.
suggest to use this:

mf = &mface_src[index_nearest];
fidx = mf->v4 ? 3 : 2;
do {
     unsigned int vidx = (&mf->v1)[fidx];
     ... operate on vidx ...
} while (fidx--);

http://codereview.appspot.com/6301097/diff/1/source/blender/editors/object/object_vgroup.c#newcode602
source/blender/editors/object/object_vgroup.c:602: weight +=
tmp_weight[j] *
defvert_find_index(dv_array_src[(&mface_src[index_nearest].v1)[j]],
index_src)->weight;
defvert_find_index may be a NULL pointer, so getting ->weight from it
may crash.

better use defvert_find_weight() here which falls back to 0.0 when not
found.

http://codereview.appspot.com/6301097/diff/1/source/blender/editors/object/object_vgroup.c#newcode649
source/blender/editors/object/object_vgroup.c:649: if
(&mface_src[index_nearest].v4 != NULL) {
comparing v4 with NULL is misleading... see above.

http://codereview.appspot.com/6301097/diff/1/source/blender/editors/object/object_vgroup.c#newcode661
source/blender/editors/object/object_vgroup.c:661: }
there should be an 'else {' ... here, which checks if 'dv_dst' has any
weights and clears them (at least when overwrite is enabled). This will
depend on the options selected, but you see the issue I hope.

http://codereview.appspot.com/6301097/diff/1/source/blender/editors/object/object_vgroup.c#newcode3121
source/blender/editors/object/object_vgroup.c:3121: ot->prop =
RNA_def_enum(ot->srna, "method_mode", method_mode_item, 3, "Method",
"");
just 'method' would be better.

http://codereview.appspot.com/6301097/


More information about the Bf-codereview mailing list