vgroup_modifiers: Addressed most ideasman’s remarks and suggestions in his last review.

*Removed curve init code in readfile (no more needed since the split broke anyway compatibility with earlier WeightVGroup files…).
*Updated get_ob2ob_distance() code (much simpler – I’m not a matrices’ god!).
*Enhanced a few RNA names (Campbell has others in mind here, though, I think).
This commit is contained in:
2011-07-26 18:51:35 +00:00
parent 07dc73fa31
commit af286ac95b
3 changed files with 9 additions and 36 deletions

View File

@@ -11714,24 +11714,8 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
/* put compatibility code here until next subversion bump */
{
Object *ob;
ModifierData *md;
/* WeightVGEdit modifier: CurveMapping pointer… */
for(ob = main->object.first; ob; ob = ob->id.next) {
for(md = ob->modifiers.first; md; md = md->next) {
if(md->type == eModifierType_WeightVGEdit) {
WeightVGEditModifierData *wmd = (WeightVGEditModifierData*) md;
if (wmd->cmap_curve == NULL) {
wmd->cmap_curve = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
curvemapping_initialize(wmd->cmap_curve);
}
}
}
}
}
/* WATCH IT!!!: pointers from libdata have not been converted yet here! */
/* WATCH IT 2!: Userdef struct init has to be in editors/interface/resources.c! */

View File

@@ -2728,8 +2728,10 @@ static void rna_def_modifier_weightvgmix(BlenderRNA *brna)
static void rna_def_modifier_weightvgproximity(BlenderRNA *brna)
{
static EnumPropertyItem weightvg_proximity_modes_items[] = {
{MOD_WVG_PROXIMITY_OBJ2OBJDIST, "OBJ2OBJDIST", 0, "O2O Distance", ""},
{MOD_WVG_PROXIMITY_OBJ2VERTDIST, "OBJ2VERTDIST", 0, "O2V Distance", ""},
{MOD_WVG_PROXIMITY_OBJ2OBJDIST, "OBJ2OBJDIST", 0, "Object Distance",
"Use distance between affected and target objects."},
{MOD_WVG_PROXIMITY_OBJ2VERTDIST, "OBJ2VERTDIST", 0, "Verts Distance",
"Use distance between affected objects vertices and target object, or target objects geometry."},
{0, NULL, 0, NULL, NULL}};
StructRNA *srna;
@@ -2755,19 +2757,19 @@ static void rna_def_modifier_weightvgproximity(BlenderRNA *brna)
prop= RNA_def_property(srna, "obj2vert_verts", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "proximity_flags", MOD_WVG_PROXIMITY_O2VD_VERTS);
RNA_def_property_ui_text(prop, "Use Target Vertices",
RNA_def_property_ui_text(prop, "Verts as Target",
"Use shortest distance to target objects vertices as weight.");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
prop= RNA_def_property(srna, "obj2vert_edges", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "proximity_flags", MOD_WVG_PROXIMITY_O2VD_EDGES);
RNA_def_property_ui_text(prop, "Use Target Edges",
RNA_def_property_ui_text(prop, "Edges as Target",
"Use shortest distance to target objects edges as weight.");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
prop= RNA_def_property(srna, "obj2vert_faces", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "proximity_flags", MOD_WVG_PROXIMITY_O2VD_FACES);
RNA_def_property_ui_text(prop, "Use Target Faces",
RNA_def_property_ui_text(prop, "Faces as Target",
"Use shortest distance to target objects faces as weight.");
RNA_def_property_update(prop, 0, "rna_Modifier_update");

View File

@@ -197,20 +197,7 @@ static void get_vert2ob_distance(int numVerts, float (*v_cos)[3], float *dist,
*/
static float get_ob2ob_distance(const Object* ob, const Object* obr)
{
/* Both objects coordinates. */
float o_wco[3],
o_wro[3][3], /*unused*/
o_wsz[3], /*unused*/
or_wco[3],
or_wro[3][3],/*unused*/
or_wsz[3]; /*unused*/
/* Get world-coordinates of both objects (constraints and anim included).
* We also get rotation and scale, even though we do not want them…
*/
mat4_to_loc_rot_size(o_wco, o_wro, o_wsz, (float (*)[4])ob->obmat);
mat4_to_loc_rot_size(or_wco, or_wro, or_wsz, (float (*)[4])obr->obmat);
/* Return distance between both coordinates. */
return len_v3v3(o_wco, or_wco);
return len_v3v3(ob->obmat[3], obr->obmat[3]);
}
/**************************************