Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/transform/transform_snap_object.c
| Show First 20 Lines • Show All 385 Lines • ▼ Show 20 Lines | if (BLI_ghash_ensure_p(sctx->cache.object_map, ob_eval, &sod_p)) { | ||||
| if (sod->type != SNAP_EDIT_MESH) { | if (sod->type != SNAP_EDIT_MESH) { | ||||
| is_dirty = true; | is_dirty = true; | ||||
| } | } | ||||
| else if (sod->treedata_editmesh.em != em) { | else if (sod->treedata_editmesh.em != em) { | ||||
| is_dirty = true; | is_dirty = true; | ||||
| } | } | ||||
| else if (sod->mesh_runtime) { | else if (sod->mesh_runtime) { | ||||
| if (sod->mesh_runtime != snap_object_data_editmesh_runtime_get(ob_eval)) { | if (sod->mesh_runtime != snap_object_data_editmesh_runtime_get(ob_eval)) { | ||||
| if (G.moving) { | if (G.moving && !sod->treedata_editmesh.cached && !sod->cached[0] && !sod->cached[1]) { | ||||
| /* Hack to avoid updating while transforming. */ | /* Hack to avoid updating while transforming. */ | ||||
| BLI_assert(!sod->treedata_editmesh.cached && !sod->cached[0] && !sod->cached[1]); | |||||
| sod->mesh_runtime = snap_object_data_editmesh_runtime_get(ob_eval); | sod->mesh_runtime = snap_object_data_editmesh_runtime_get(ob_eval); | ||||
| } | } | ||||
| else { | else { | ||||
| is_dirty = true; | is_dirty = true; | ||||
| } | } | ||||
| } | } | ||||
| else if (sod->treedata_editmesh.tree && sod->treedata_editmesh.cached && | else if (sod->treedata_editmesh.tree && sod->treedata_editmesh.cached && | ||||
| !bvhcache_has_tree(sod->mesh_runtime->bvh_cache, sod->treedata_editmesh.tree)) { | !bvhcache_has_tree(sod->mesh_runtime->bvh_cache, sod->treedata_editmesh.tree)) { | ||||
| ▲ Show 20 Lines • Show All 2,420 Lines • ▼ Show 20 Lines | void ED_transform_snap_object_context_destroy(SnapObjectContext *sctx) | ||||
| if (sctx->cache.data_to_object_map != NULL) { | if (sctx->cache.data_to_object_map != NULL) { | ||||
| BLI_ghash_free(sctx->cache.data_to_object_map, NULL, NULL); | BLI_ghash_free(sctx->cache.data_to_object_map, NULL, NULL); | ||||
| } | } | ||||
| BLI_memarena_free(sctx->cache.mem_arena); | BLI_memarena_free(sctx->cache.mem_arena); | ||||
| MEM_freeN(sctx); | MEM_freeN(sctx); | ||||
| } | } | ||||
| static void transform_snap_object_context_cache_clear(SnapObjectContext *sctx) | |||||
| { | |||||
| BLI_ghash_clear(sctx->cache.object_map, NULL, snap_object_data_free); | |||||
| if (sctx->cache.data_to_object_map != NULL) { | |||||
| BLI_ghash_clear(sctx->cache.data_to_object_map, NULL, NULL); | |||||
| } | |||||
| BLI_memarena_clear(sctx->cache.mem_arena); | |||||
| } | |||||
| void ED_transform_snap_object_context_set_editmesh_callbacks( | void ED_transform_snap_object_context_set_editmesh_callbacks( | ||||
| SnapObjectContext *sctx, | SnapObjectContext *sctx, | ||||
| bool (*test_vert_fn)(BMVert *, void *user_data), | bool (*test_vert_fn)(BMVert *, void *user_data), | ||||
| bool (*test_edge_fn)(BMEdge *, void *user_data), | bool (*test_edge_fn)(BMEdge *, void *user_data), | ||||
| bool (*test_face_fn)(BMFace *, void *user_data), | bool (*test_face_fn)(BMFace *, void *user_data), | ||||
| void *user_data) | void *user_data) | ||||
| { | { | ||||
| bool is_cache_dirty = false; | |||||
| if (sctx->callbacks.edit_mesh.test_vert_fn != test_vert_fn) { | |||||
| sctx->callbacks.edit_mesh.test_vert_fn = test_vert_fn; | sctx->callbacks.edit_mesh.test_vert_fn = test_vert_fn; | ||||
| is_cache_dirty = true; | |||||
| } | |||||
| if (sctx->callbacks.edit_mesh.test_edge_fn != test_edge_fn) { | |||||
| sctx->callbacks.edit_mesh.test_edge_fn = test_edge_fn; | sctx->callbacks.edit_mesh.test_edge_fn = test_edge_fn; | ||||
| is_cache_dirty = true; | |||||
| } | |||||
| if (sctx->callbacks.edit_mesh.test_face_fn != test_face_fn) { | |||||
| sctx->callbacks.edit_mesh.test_face_fn = test_face_fn; | sctx->callbacks.edit_mesh.test_face_fn = test_face_fn; | ||||
| is_cache_dirty = true; | |||||
| } | |||||
| if (sctx->callbacks.edit_mesh.user_data != user_data) { | |||||
| sctx->callbacks.edit_mesh.user_data = user_data; | sctx->callbacks.edit_mesh.user_data = user_data; | ||||
| is_cache_dirty = true; | |||||
| } | |||||
| if (is_cache_dirty) { | |||||
| transform_snap_object_context_cache_clear(sctx); | |||||
| } | |||||
| } | } | ||||
| bool ED_transform_snap_object_project_ray_ex(SnapObjectContext *sctx, | bool ED_transform_snap_object_project_ray_ex(SnapObjectContext *sctx, | ||||
| Depsgraph *depsgraph, | Depsgraph *depsgraph, | ||||
| const View3D *v3d, | const View3D *v3d, | ||||
| const struct SnapObjectParams *params, | const struct SnapObjectParams *params, | ||||
| const float ray_start[3], | const float ray_start[3], | ||||
| const float ray_normal[3], | const float ray_normal[3], | ||||
| ▲ Show 20 Lines • Show All 391 Lines • Show Last 20 Lines | |||||