Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/transform/transform_conversions.c
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
| Show All 22 Lines | |||||
| #include <string.h> | #include <string.h> | ||||
| #include <math.h> | #include <math.h> | ||||
| #include <limits.h> | #include <limits.h> | ||||
| #include "DNA_anim_types.h" | #include "DNA_anim_types.h" | ||||
| #include "DNA_brush_types.h" | #include "DNA_brush_types.h" | ||||
| #include "DNA_armature_types.h" | #include "DNA_armature_types.h" | ||||
| #include "DNA_camera_types.h" | |||||
| #include "DNA_lattice_types.h" | #include "DNA_lattice_types.h" | ||||
| #include "DNA_mesh_types.h" | #include "DNA_mesh_types.h" | ||||
| #include "DNA_meta_types.h" | #include "DNA_meta_types.h" | ||||
| #include "DNA_node_types.h" | #include "DNA_node_types.h" | ||||
| #include "DNA_screen_types.h" | #include "DNA_screen_types.h" | ||||
| #include "DNA_space_types.h" | #include "DNA_space_types.h" | ||||
| #include "DNA_sequence_types.h" | #include "DNA_sequence_types.h" | ||||
| #include "DNA_view3d_types.h" | #include "DNA_view3d_types.h" | ||||
| ▲ Show 20 Lines • Show All 9,294 Lines • ▼ Show 20 Lines | static int countAndCleanTransDataContainer(TransInfo *t) | ||||
| } | } | ||||
| if (data_container_len_orig != t->data_container_len) { | if (data_container_len_orig != t->data_container_len) { | ||||
| t->data_container = MEM_reallocN(t->data_container, | t->data_container = MEM_reallocN(t->data_container, | ||||
| sizeof(*t->data_container) * t->data_container_len); | sizeof(*t->data_container) * t->data_container_len); | ||||
| } | } | ||||
| return t->data_len_all; | return t->data_len_all; | ||||
| } | } | ||||
| static void count_trans_object_deps_cb(ID *id, void *user_data) | |||||
| { | |||||
| /* Here we only handle object IDs. */ | |||||
| if (GS(id->name) != ID_OB) { | |||||
| return; | |||||
| } | |||||
| if (id->tag & LIB_TAG_DOIT) { | |||||
| int *num_ob_dependencies = user_data; | |||||
| *num_ob_dependencies += 1; | |||||
| } | |||||
| } | |||||
| /* We could have a flag to easily check an object is being transformed. */ | |||||
| static bool is_transforming_object(TransInfo *t, Object *obact, Object *ob) | |||||
| { | |||||
| bool r_is_transforming = false; | |||||
| if (ob == obact) { | |||||
| r_is_transforming = true; | |||||
| } | |||||
| else if (BKE_object_is_child_recursive(obact, ob)) { | |||||
| r_is_transforming = true; | |||||
| } | |||||
| else if (ob->id.tag & LIB_TAG_DOIT) { | |||||
| /* Other types of dependencies may interfere with the transformation. */ | |||||
| r_is_transforming = true; | |||||
| /* Ignore dependencies that do not interfere with transformation. */ | |||||
| int num_ignored_dependencies = 0; | |||||
| if (ob->type == OB_CAMERA) { | |||||
| Camera *cam = ob->data; | |||||
| if (cam->dof_ob && (cam->dof_ob->id.tag & LIB_TAG_DOIT)) { | |||||
| num_ignored_dependencies += 1; | |||||
| } | |||||
| } | |||||
| if (num_ignored_dependencies) { | |||||
| int num_ob_dependencies = 0; | |||||
| DEG_foreach_ancestor_ID( | |||||
| t->depsgraph, &ob->id, count_trans_object_deps_cb, &num_ob_dependencies); | |||||
| r_is_transforming = num_ob_dependencies > num_ignored_dependencies; | |||||
| } | |||||
| } | |||||
| return r_is_transforming; | |||||
| } | |||||
| void createTransData(bContext *C, TransInfo *t) | void createTransData(bContext *C, TransInfo *t) | ||||
| { | { | ||||
| Scene *scene = t->scene; | Scene *scene = t->scene; | ||||
| ViewLayer *view_layer = t->view_layer; | ViewLayer *view_layer = t->view_layer; | ||||
| Object *ob = OBACT(view_layer); | Object *ob = OBACT(view_layer); | ||||
| bool has_transform_context = true; | bool has_transform_context = true; | ||||
| t->data_len_all = -1; | t->data_len_all = -1; | ||||
| ▲ Show 20 Lines • Show All 310 Lines • ▼ Show 20 Lines | if (t->data_len_all && t->flag & T_PROP_EDIT) { | ||||
| // selected objects are already first, no need to presort | // selected objects are already first, no need to presort | ||||
| set_prop_dist(t, 1); | set_prop_dist(t, 1); | ||||
| sort_trans_data_dist(t); | sort_trans_data_dist(t); | ||||
| } | } | ||||
| /* Check if we're transforming the camera from the camera */ | /* Check if we're transforming the camera from the camera */ | ||||
| if ((t->spacetype == SPACE_VIEW3D) && (t->ar->regiontype == RGN_TYPE_WINDOW)) { | if ((t->spacetype == SPACE_VIEW3D) && (t->ar->regiontype == RGN_TYPE_WINDOW)) { | ||||
| View3D *v3d = t->view; | View3D *v3d = t->view; | ||||
| RegionView3D *rv3d = t->ar->regiondata; | RegionView3D *rv3d = t->ar->regiondata; | ||||
| if ((rv3d->persp == RV3D_CAMOB) && v3d->camera) { | if ((rv3d->persp == RV3D_CAMOB) && v3d->camera && | ||||
campbellbarton: check the object type is `OB_CAMERA` before casting. | |||||
| /* we could have a flag to easily check an object is being transformed */ | is_transforming_object(t, ob, v3d->camera)) { | ||||
Done Inline ActionsI am not sure what is the value of referencing bug reports. This doesn't make it any more clear why stuff is happening the way it does happen. There is only a vague explanation in the commit message. Such information should be put into the comments, so you don't spent your life chasing bug reports, reading comments there, then trying to extract more information from a commit message. sergey: I am not sure what is the value of referencing bug reports. This doesn't make it any more clear… | |||||
| if (v3d->camera->id.tag & LIB_TAG_DOIT) { | |||||
| t->flag |= T_CAMERA; | t->flag |= T_CAMERA; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | |||||
| /* Check that 'countAndCleanTransDataContainer' ran. */ | /* Check that 'countAndCleanTransDataContainer' ran. */ | ||||
| if (has_transform_context) { | if (has_transform_context) { | ||||
| BLI_assert(t->data_len_all != -1); | BLI_assert(t->data_len_all != -1); | ||||
| } | } | ||||
| else { | else { | ||||
| BLI_assert(t->data_len_all == -1); | BLI_assert(t->data_len_all == -1); | ||||
| t->data_len_all = 0; | t->data_len_all = 0; | ||||
| } | } | ||||
| BLI_assert((!(t->flag & T_EDIT)) == (!(t->obedit_type != -1))); | BLI_assert((!(t->flag & T_EDIT)) == (!(t->obedit_type != -1))); | ||||
| } | } | ||||
check the object type is OB_CAMERA before casting.