Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/transform/transform_generics.c
| Show First 20 Lines • Show All 403 Lines • ▼ Show 20 Lines | if (constraint_axis[0] || constraint_axis[1] || constraint_axis[2]) { | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| { | { | ||||
| short orient_types[3]; | short orient_types[3]; | ||||
| float custom_matrix[3][3]; | float custom_matrix[3][3]; | ||||
| short orient_type_scene = V3D_ORIENT_GLOBAL; | int orient_type_scene = V3D_ORIENT_GLOBAL; | ||||
| short orient_type_set = V3D_ORIENT_GLOBAL; | int orient_type_default = -1; | ||||
| short orient_type_matrix_set = -1; | int orient_type_set = -1; | ||||
| int orient_type_matrix_set = -1; | |||||
| bool use_orient_axis = false; | bool use_orient_axis = false; | ||||
| if ((t->spacetype == SPACE_VIEW3D) && (t->region->regiontype == RGN_TYPE_WINDOW)) { | if ((t->spacetype == SPACE_VIEW3D) && (t->region->regiontype == RGN_TYPE_WINDOW)) { | ||||
| TransformOrientationSlot *orient_slot = &t->scene->orientation_slots[SCE_ORIENT_DEFAULT]; | TransformOrientationSlot *orient_slot = &t->scene->orientation_slots[SCE_ORIENT_DEFAULT]; | ||||
| orient_type_scene = orient_slot->type; | orient_type_scene = orient_slot->type; | ||||
| if (orient_type_scene == V3D_ORIENT_CUSTOM) { | if (orient_type_scene == V3D_ORIENT_CUSTOM) { | ||||
| const int index_custom = orient_slot->index_custom; | const int index_custom = orient_slot->index_custom; | ||||
| orient_type_scene += index_custom; | orient_type_scene += index_custom; | ||||
| } | } | ||||
| } | } | ||||
| short orient_type_default = orient_type_scene; | if (op && ((prop = RNA_struct_find_property(op->ptr, "orient_type")) && | ||||
| RNA_property_is_set(op->ptr, prop))) { | |||||
| orient_type_set = RNA_property_enum_get(op->ptr, prop); | |||||
| if (orient_type_set >= V3D_ORIENT_CUSTOM + BIF_countTransformOrientation(C)) { | |||||
| orient_type_set = V3D_ORIENT_GLOBAL; | |||||
| } | |||||
| } | |||||
| if (op && (prop = RNA_struct_find_property(op->ptr, "orient_axis"))) { | if (op && (prop = RNA_struct_find_property(op->ptr, "orient_axis"))) { | ||||
| t->orient_axis = RNA_property_enum_get(op->ptr, prop); | t->orient_axis = RNA_property_enum_get(op->ptr, prop); | ||||
| use_orient_axis = true; | use_orient_axis = true; | ||||
| } | } | ||||
| if (op && (prop = RNA_struct_find_property(op->ptr, "orient_axis_ortho"))) { | if (op && (prop = RNA_struct_find_property(op->ptr, "orient_axis_ortho"))) { | ||||
| t->orient_axis_ortho = RNA_property_enum_get(op->ptr, prop); | t->orient_axis_ortho = RNA_property_enum_get(op->ptr, prop); | ||||
| } | } | ||||
| if (op && ((prop = RNA_struct_find_property(op->ptr, "orient_type")) && | if (op && ((prop = RNA_struct_find_property(op->ptr, "orient_matrix")) && | ||||
| RNA_property_is_set(op->ptr, prop))) { | RNA_property_is_set(op->ptr, prop))) { | ||||
| orient_type_set = RNA_property_enum_get(op->ptr, prop); | RNA_property_float_get_array(op->ptr, prop, &custom_matrix[0][0]); | ||||
| if (orient_type_set >= V3D_ORIENT_CUSTOM + BIF_countTransformOrientation(C)) { | |||||
| orient_type_set = V3D_ORIENT_GLOBAL; | if ((prop = RNA_struct_find_property(op->ptr, "orient_matrix_type")) && | ||||
| RNA_property_is_set(op->ptr, prop)) { | |||||
| orient_type_matrix_set = RNA_property_enum_get(op->ptr, prop); | |||||
| } | |||||
| else if (orient_type_set == -1) { | |||||
| orient_type_set = V3D_ORIENT_CUSTOM_MATRIX; | |||||
| } | |||||
| } | } | ||||
| /* Change the default orientation to be used when redoing. */ | if (orient_type_set != -1) { | ||||
| orient_type_default = orient_type_set; | orient_type_default = orient_type_set; | ||||
| } | } | ||||
| else if (orient_type_matrix_set != -1) { | |||||
| orient_type_default = orient_type_set = orient_type_matrix_set; | |||||
| } | |||||
| else if (t->con.mode & CON_APPLY) { | else if (t->con.mode & CON_APPLY) { | ||||
| orient_type_set = orient_type_scene; | orient_type_default = orient_type_set = orient_type_scene; | ||||
| } | } | ||||
| else { | else { | ||||
| if (orient_type_set == orient_type_scene) { | if (orient_type_scene == V3D_ORIENT_GLOBAL) { | ||||
| BLI_assert(orient_type_set == V3D_ORIENT_GLOBAL); | |||||
| orient_type_set = V3D_ORIENT_LOCAL; | orient_type_set = V3D_ORIENT_LOCAL; | ||||
| } | } | ||||
| else { | |||||
| orient_type_set = V3D_ORIENT_GLOBAL; | |||||
| } | |||||
| if ((t->flag & T_MODAL) && (use_orient_axis || transform_mode_is_changeable(t->mode)) && | if ((t->flag & T_MODAL) && (use_orient_axis || transform_mode_is_changeable(t->mode)) && | ||||
| (t->mode != TFM_ALIGN)) { | (t->mode != TFM_ALIGN)) { | ||||
| orient_type_default = V3D_ORIENT_VIEW; | orient_type_default = V3D_ORIENT_VIEW; | ||||
| } | } | ||||
| } | |||||
| if (op && ((prop = RNA_struct_find_property(op->ptr, "orient_matrix")) && | |||||
| RNA_property_is_set(op->ptr, prop))) { | |||||
| RNA_property_float_get_array(op->ptr, prop, &custom_matrix[0][0]); | |||||
| if ((prop = RNA_struct_find_property(op->ptr, "orient_matrix_type")) && | |||||
| RNA_property_is_set(op->ptr, prop)) { | |||||
| orient_type_matrix_set = RNA_property_enum_get(op->ptr, prop); | |||||
| } | |||||
| else { | else { | ||||
| orient_type_matrix_set = orient_type_set; | orient_type_default = orient_type_scene; | ||||
| } | |||||
| } | } | ||||
| BLI_assert(!ELEM(-1, orient_type_default, orient_type_set)); | |||||
| if (orient_type_matrix_set == orient_type_set) { | if (orient_type_matrix_set == orient_type_set) { | ||||
| /* Constraints are forced to use the custom matrix when redoing. */ | /* Constraints are forced to use the custom matrix when redoing. */ | ||||
| orient_type_set = V3D_ORIENT_CUSTOM_MATRIX; | orient_type_set = V3D_ORIENT_CUSTOM_MATRIX; | ||||
| } | } | ||||
| } | |||||
| orient_types[0] = orient_type_default; | orient_types[0] = (short)orient_type_default; | ||||
| orient_types[1] = orient_type_scene; | orient_types[1] = (short)orient_type_scene; | ||||
| orient_types[2] = orient_type_set; | orient_types[2] = (short)orient_type_set; | ||||
| for (int i = 0; i < 3; i++) { | for (int i = 0; i < 3; i++) { | ||||
| /* For efficiency, avoid calculating the same orientation twice. */ | /* For efficiency, avoid calculating the same orientation twice. */ | ||||
| int j; | int j; | ||||
| for (j = 0; j < i; j++) { | for (j = 0; j < i; j++) { | ||||
| if (orient_types[j] == orient_types[i]) { | if (orient_types[j] == orient_types[i]) { | ||||
| memcpy(&t->orient[i], &t->orient[j], sizeof(*t->orient)); | memcpy(&t->orient[i], &t->orient[j], sizeof(*t->orient)); | ||||
| break; | break; | ||||
| ▲ Show 20 Lines • Show All 910 Lines • Show Last 20 Lines | |||||