From 7ad59c4e2cb752b10c45501aaa0db04c50a850db Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 1 Sep 2013 22:38:41 +0000 Subject: fix odd (intentional) behavior with vertex parent, curve children of a triangle vertex parent would only display their relationship line to the first vertex. (confusing) also added OB_TYPE_SUPPORT_PARVERT macro. --- source/blender/blenkernel/intern/object.c | 24 +++++++++--------------- source/blender/editors/object/object_relations.c | 2 +- source/blender/makesdna/DNA_object_types.h | 2 ++ source/blender/makesrna/intern/rna_object.c | 2 +- 4 files changed, 13 insertions(+), 17 deletions(-) diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 832d2791a7d..6ffab678691 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -2013,29 +2013,23 @@ static void give_parvert(Object *par, int nr, float vec[3]) static void ob_parvert3(Object *ob, Object *par, float mat[4][4]) { - float cmat[3][3], v1[3], v2[3], v3[3], q[4]; /* in local ob space */ - unit_m4(mat); - - if (ELEM4(par->type, OB_MESH, OB_SURF, OB_CURVE, OB_LATTICE)) { - + if (OB_TYPE_SUPPORT_PARVERT(par->type)) { + float cmat[3][3], v1[3], v2[3], v3[3], q[4]; + give_parvert(par, ob->par1, v1); give_parvert(par, ob->par2, v2); give_parvert(par, ob->par3, v3); - + tri_to_quat(q, v1, v2, v3); quat_to_mat3(cmat, q); copy_m4_m3(mat, cmat); - - if (ob->type == OB_CURVE) { - copy_v3_v3(mat[3], v1); - } - else { - add_v3_v3v3(mat[3], v1, v2); - add_v3_v3(mat[3], v3); - mul_v3_fl(mat[3], 1.0f / 3.0f); - } + + mid_v3_v3v3v3(mat[3], v1, v2, v3); + } + else { + unit_m4(mat); } } diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index ad486d43da7..be4948d8a80 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -904,7 +904,7 @@ static int parent_set_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent } /* vertex parenting */ - if (ELEM4(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_LATTICE)) { + if (OB_TYPE_SUPPORT_PARVERT(ob->type)) { uiItemEnumO_ptr(layout, ot, NULL, 0, "type", PAR_VERTEX); uiItemEnumO_ptr(layout, ot, NULL, 0, "type", PAR_VERTEX_TRI); } diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h index 44c1a0500be..53d2ab1df07 100644 --- a/source/blender/makesdna/DNA_object_types.h +++ b/source/blender/makesdna/DNA_object_types.h @@ -353,6 +353,8 @@ enum { (ELEM(_type, OB_MESH, OB_LATTICE)) #define OB_TYPE_SUPPORT_EDITMODE(_type) \ (ELEM7(_type, OB_MESH, OB_FONT, OB_CURVE, OB_SURF, OB_MBALL, OB_LATTICE, OB_ARMATURE)) +#define OB_TYPE_SUPPORT_PARVERT(_type) \ + (ELEM4(_type, OB_MESH, OB_SURF, OB_CURVE, OB_LATTICE)) /* is this ID type used as object data */ #define OB_DATA_SUPPORT_ID(_id_type) \ diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 4c04b0de71e..9bf9bc1deac 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -465,7 +465,7 @@ static EnumPropertyItem *rna_Object_parent_type_itemf(bContext *UNUSED(C), Point RNA_enum_items_add_value(&item, &totitem, parent_type_items, PARBONE); } - if (ELEM4(par->type, OB_MESH, OB_CURVE, OB_SURF, OB_LATTICE)) { + if (OB_TYPE_SUPPORT_PARVERT(par->type)) { RNA_enum_items_add_value(&item, &totitem, parent_type_items, PARVERT1); RNA_enum_items_add_value(&item, &totitem, parent_type_items, PARVERT3); } -- cgit v1.2.3