diff options
author | Sergej Reich <sergej.reich@googlemail.com> | 2012-10-20 20:48:54 +0400 |
---|---|---|
committer | Sergej Reich <sergej.reich@googlemail.com> | 2012-10-20 20:48:54 +0400 |
commit | 0a590aadf5655175f73af5b59e61acfb0fe0b144 (patch) | |
tree | 337b9aa216d33a1c4f84d1d5d3364ca927309753 /source/blender/editors/object | |
parent | d20128bbbcae252e9b39af14246dfcc6534dc0d6 (diff) |
Add option to set object origin to the center of mass
This uses the weighted average of polygon centroids based on area
It work well in most cases but will be slightly wrong when polygons have
many vertices.
Diffstat (limited to 'source/blender/editors/object')
-rw-r--r-- | source/blender/editors/object/object_transform.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c index 4c95884a51a..9bf1bbfa102 100644 --- a/source/blender/editors/object/object_transform.c +++ b/source/blender/editors/object/object_transform.c @@ -654,7 +654,8 @@ void OBJECT_OT_transform_apply(wmOperatorType *ot) enum { GEOMETRY_TO_ORIGIN = 0, ORIGIN_TO_GEOMETRY, - ORIGIN_TO_CURSOR + ORIGIN_TO_CURSOR, + ORIGIN_TO_CENTER_OF_MASS }; static int object_origin_set_exec(bContext *C, wmOperator *op) @@ -785,6 +786,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) Mesh *me = ob->data; if (centermode == ORIGIN_TO_CURSOR) { /* done */ } + else if (centermode == ORIGIN_TO_CENTER_OF_MASS) { BKE_mesh_center_centroid(me, cent); } else if (around == V3D_CENTROID) { BKE_mesh_center_median(me, cent); } else { BKE_mesh_center_bounds(me, cent); } @@ -980,6 +982,8 @@ void OBJECT_OT_origin_set(wmOperatorType *ot) "Move object origin to center of object geometry"}, {ORIGIN_TO_CURSOR, "ORIGIN_CURSOR", 0, "Origin to 3D Cursor", "Move object origin to position of the 3D cursor"}, + {ORIGIN_TO_CENTER_OF_MASS, "ORIGIN_CENTER_OF_MASS", 0, "Origin to Center of Mass", + "Move object origin to the object center of mass (assuming uniform density)"}, {0, NULL, 0, NULL, NULL} }; @@ -1006,4 +1010,3 @@ void OBJECT_OT_origin_set(wmOperatorType *ot) ot->prop = RNA_def_enum(ot->srna, "type", prop_set_center_types, 0, "Type", ""); RNA_def_enum(ot->srna, "center", prop_set_bounds_types, V3D_CENTROID, "Center", ""); } - |