Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_view3d/view3d_iterators.cc
- This file was moved from source/blender/editors/space_view3d/view3d_iterators.c.
| Show First 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | |||||
| */ | */ | ||||
| static int content_planes_from_clip_flag(const ARegion *region, | static int content_planes_from_clip_flag(const ARegion *region, | ||||
| const Object *ob, | const Object *ob, | ||||
| const eV3DProjTest clip_flag, | const eV3DProjTest clip_flag, | ||||
| float planes[6][4]) | float planes[6][4]) | ||||
| { | { | ||||
| BLI_assert(clip_flag & V3D_PROJ_TEST_CLIP_CONTENT); | BLI_assert(clip_flag & V3D_PROJ_TEST_CLIP_CONTENT); | ||||
| float *clip_xmin = NULL, *clip_xmax = NULL; | float *clip_xmin = nullptr, *clip_xmax = nullptr; | ||||
| float *clip_ymin = NULL, *clip_ymax = NULL; | float *clip_ymin = nullptr, *clip_ymax = nullptr; | ||||
| float *clip_zmin = NULL, *clip_zmax = NULL; | float *clip_zmin = nullptr, *clip_zmax = nullptr; | ||||
| int planes_len = 0; | int planes_len = 0; | ||||
| /* The order of `planes` has been selected based on the likelihood of points being fully | /* The order of `planes` has been selected based on the likelihood of points being fully | ||||
| * outside the plane to increase the chance of an early exit in #clip_segment_v3_plane_n. | * outside the plane to increase the chance of an early exit in #clip_segment_v3_plane_n. | ||||
| * With "near" being most likely and "far" being unlikely. | * With "near" being most likely and "far" being unlikely. | ||||
| * | * | ||||
| * Otherwise the order of axes in `planes` isn't significant. */ | * Otherwise the order of axes in `planes` isn't significant. */ | ||||
| if (clip_flag & V3D_PROJ_TEST_CLIP_NEAR) { | if (clip_flag & V3D_PROJ_TEST_CLIP_NEAR) { | ||||
| clip_zmin = planes[planes_len++]; | clip_zmin = planes[planes_len++]; | ||||
| } | } | ||||
| if (clip_flag & V3D_PROJ_TEST_CLIP_WIN) { | if (clip_flag & V3D_PROJ_TEST_CLIP_WIN) { | ||||
| clip_xmin = planes[planes_len++]; | clip_xmin = planes[planes_len++]; | ||||
| clip_xmax = planes[planes_len++]; | clip_xmax = planes[planes_len++]; | ||||
| clip_ymin = planes[planes_len++]; | clip_ymin = planes[planes_len++]; | ||||
| clip_ymax = planes[planes_len++]; | clip_ymax = planes[planes_len++]; | ||||
| } | } | ||||
| if (clip_flag & V3D_PROJ_TEST_CLIP_FAR) { | if (clip_flag & V3D_PROJ_TEST_CLIP_FAR) { | ||||
| clip_zmax = planes[planes_len++]; | clip_zmax = planes[planes_len++]; | ||||
| } | } | ||||
| BLI_assert(planes_len <= 6); | BLI_assert(planes_len <= 6); | ||||
| if (planes_len != 0) { | if (planes_len != 0) { | ||||
| RegionView3D *rv3d = region->regiondata; | RegionView3D *rv3d = static_cast<RegionView3D *>(region->regiondata); | ||||
| float projmat[4][4]; | float projmat[4][4]; | ||||
| ED_view3d_ob_project_mat_get(rv3d, ob, projmat); | ED_view3d_ob_project_mat_get(rv3d, ob, projmat); | ||||
| planes_from_projmat(projmat, clip_xmin, clip_xmax, clip_ymin, clip_ymax, clip_zmin, clip_zmax); | planes_from_projmat(projmat, clip_xmin, clip_xmax, clip_ymin, clip_ymax, clip_zmin, clip_zmax); | ||||
| } | } | ||||
| return planes_len; | return planes_len; | ||||
| } | } | ||||
| /** | /** | ||||
| ▲ Show 20 Lines • Show All 101 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Private User Data Structures | /** \name Private User Data Structures | ||||
| * \{ */ | * \{ */ | ||||
| typedef struct foreachScreenObjectVert_userData { | struct foreachScreenObjectVert_userData { | ||||
| void (*func)(void *userData, MVert *mv, const float screen_co[2], int index); | void (*func)(void *userData, MVert *mv, const float screen_co[2], int index); | ||||
| void *userData; | void *userData; | ||||
| ViewContext vc; | ViewContext vc; | ||||
| MVert *verts; | MVert *verts; | ||||
| const bool *hide_vert; | const bool *hide_vert; | ||||
| eV3DProjTest clip_flag; | eV3DProjTest clip_flag; | ||||
| } foreachScreenObjectVert_userData; | }; | ||||
| typedef struct foreachScreenVert_userData { | struct foreachScreenVert_userData { | ||||
| void (*func)(void *userData, BMVert *eve, const float screen_co[2], int index); | void (*func)(void *userData, BMVert *eve, const float screen_co[2], int index); | ||||
| void *userData; | void *userData; | ||||
| ViewContext vc; | ViewContext vc; | ||||
| eV3DProjTest clip_flag; | eV3DProjTest clip_flag; | ||||
| } foreachScreenVert_userData; | }; | ||||
| /* user data structures for derived mesh callbacks */ | /* user data structures for derived mesh callbacks */ | ||||
| typedef struct foreachScreenEdge_userData { | struct foreachScreenEdge_userData { | ||||
| void (*func)(void *userData, | void (*func)(void *userData, | ||||
| BMEdge *eed, | BMEdge *eed, | ||||
| const float screen_co_a[2], | const float screen_co_a[2], | ||||
| const float screen_co_b[2], | const float screen_co_b[2], | ||||
| int index); | int index); | ||||
| void *userData; | void *userData; | ||||
| ViewContext vc; | ViewContext vc; | ||||
| eV3DProjTest clip_flag; | eV3DProjTest clip_flag; | ||||
| rctf win_rect; /* copy of: vc.region->winx/winy, use for faster tests, minx/y will always be 0 */ | rctf win_rect; /* copy of: vc.region->winx/winy, use for faster tests, minx/y will always be 0 */ | ||||
| /** | /** | ||||
| * Clip plans defined by the view bounds, | * Clip plans defined by the view bounds, | ||||
| * use when #V3D_PROJ_TEST_CLIP_CONTENT is enabled. | * use when #V3D_PROJ_TEST_CLIP_CONTENT is enabled. | ||||
| */ | */ | ||||
| float content_planes[6][4]; | float content_planes[6][4]; | ||||
| int content_planes_len; | int content_planes_len; | ||||
| } foreachScreenEdge_userData; | }; | ||||
| typedef struct foreachScreenFace_userData { | struct foreachScreenFace_userData { | ||||
| void (*func)(void *userData, BMFace *efa, const float screen_co_b[2], int index); | void (*func)(void *userData, BMFace *efa, const float screen_co_b[2], int index); | ||||
| void *userData; | void *userData; | ||||
| ViewContext vc; | ViewContext vc; | ||||
| eV3DProjTest clip_flag; | eV3DProjTest clip_flag; | ||||
| } foreachScreenFace_userData; | }; | ||||
| /** | /** | ||||
| * \note foreach functions should be called while drawing or directly after | * \note foreach functions should be called while drawing or directly after | ||||
| * if not, #ED_view3d_init_mats_rv3d() can be used for selection tools | * if not, #ED_view3d_init_mats_rv3d() can be used for selection tools | ||||
| * but would not give correct results with dupli's for eg. which don't | * but would not give correct results with dupli's for eg. which don't | ||||
| * use the object matrix in the usual way. | * use the object matrix in the usual way. | ||||
| */ | */ | ||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Edit-Mesh: For Each Screen Vertex | /** \name Edit-Mesh: For Each Screen Vertex | ||||
| * \{ */ | * \{ */ | ||||
| static void meshobject_foreachScreenVert__mapFunc(void *userData, | static void meshobject_foreachScreenVert__mapFunc(void *userData, | ||||
| int index, | int index, | ||||
| const float co[3], | const float co[3], | ||||
| const float UNUSED(no[3])) | const float UNUSED(no[3])) | ||||
| { | { | ||||
| foreachScreenObjectVert_userData *data = userData; | foreachScreenObjectVert_userData *data = static_cast<foreachScreenObjectVert_userData *>( | ||||
| userData); | |||||
| if (data->hide_vert && data->hide_vert[index]) { | if (data->hide_vert && data->hide_vert[index]) { | ||||
| return; | return; | ||||
| } | } | ||||
| MVert *mv = &data->verts[index]; | MVert *mv = &data->verts[index]; | ||||
| float screen_co[2]; | float screen_co[2]; | ||||
| if (ED_view3d_project_float_object(data->vc.region, co, screen_co, data->clip_flag) != | if (ED_view3d_project_float_object(data->vc.region, co, screen_co, data->clip_flag) != | ||||
| Show All 36 Lines | void meshobject_foreachScreenVert( | ||||
| BKE_mesh_foreach_mapped_vert(me, meshobject_foreachScreenVert__mapFunc, &data, MESH_FOREACH_NOP); | BKE_mesh_foreach_mapped_vert(me, meshobject_foreachScreenVert__mapFunc, &data, MESH_FOREACH_NOP); | ||||
| } | } | ||||
| static void mesh_foreachScreenVert__mapFunc(void *userData, | static void mesh_foreachScreenVert__mapFunc(void *userData, | ||||
| int index, | int index, | ||||
| const float co[3], | const float co[3], | ||||
| const float UNUSED(no[3])) | const float UNUSED(no[3])) | ||||
| { | { | ||||
| foreachScreenVert_userData *data = userData; | foreachScreenVert_userData *data = static_cast<foreachScreenVert_userData *>(userData); | ||||
| BMVert *eve = BM_vert_at_index(data->vc.em->bm, index); | BMVert *eve = BM_vert_at_index(data->vc.em->bm, index); | ||||
| if (UNLIKELY(BM_elem_flag_test(eve, BM_ELEM_HIDDEN))) { | if (UNLIKELY(BM_elem_flag_test(eve, BM_ELEM_HIDDEN))) { | ||||
| return; | return; | ||||
| } | } | ||||
| float screen_co[2]; | float screen_co[2]; | ||||
| if (ED_view3d_project_float_object(data->vc.region, co, screen_co, data->clip_flag) != | if (ED_view3d_project_float_object(data->vc.region, co, screen_co, data->clip_flag) != | ||||
| V3D_PROJ_RET_OK) { | V3D_PROJ_RET_OK) { | ||||
| Show All 36 Lines | |||||
| /** \name Edit-Mesh: For Each Screen Mesh Edge | /** \name Edit-Mesh: For Each Screen Mesh Edge | ||||
| * \{ */ | * \{ */ | ||||
| static void mesh_foreachScreenEdge__mapFunc(void *userData, | static void mesh_foreachScreenEdge__mapFunc(void *userData, | ||||
| int index, | int index, | ||||
| const float v_a[3], | const float v_a[3], | ||||
| const float v_b[3]) | const float v_b[3]) | ||||
| { | { | ||||
| foreachScreenEdge_userData *data = userData; | foreachScreenEdge_userData *data = static_cast<foreachScreenEdge_userData *>(userData); | ||||
| BMEdge *eed = BM_edge_at_index(data->vc.em->bm, index); | BMEdge *eed = BM_edge_at_index(data->vc.em->bm, index); | ||||
| if (UNLIKELY(BM_elem_flag_test(eed, BM_ELEM_HIDDEN))) { | if (UNLIKELY(BM_elem_flag_test(eed, BM_ELEM_HIDDEN))) { | ||||
| return; | return; | ||||
| } | } | ||||
| float screen_co_a[2], screen_co_b[2]; | float screen_co_a[2], screen_co_b[2]; | ||||
| if (!view3d_project_segment_to_screen_with_content_clip_planes(data->vc.region, | if (!view3d_project_segment_to_screen_with_content_clip_planes(data->vc.region, | ||||
| v_a, | v_a, | ||||
| ▲ Show 20 Lines • Show All 64 Lines • ▼ Show 20 Lines | |||||
| * Only call for bound-box clipping. | * Only call for bound-box clipping. | ||||
| * Otherwise call #mesh_foreachScreenEdge__mapFunc | * Otherwise call #mesh_foreachScreenEdge__mapFunc | ||||
| */ | */ | ||||
| static void mesh_foreachScreenEdge_clip_bb_segment__mapFunc(void *userData, | static void mesh_foreachScreenEdge_clip_bb_segment__mapFunc(void *userData, | ||||
| int index, | int index, | ||||
| const float v_a[3], | const float v_a[3], | ||||
| const float v_b[3]) | const float v_b[3]) | ||||
| { | { | ||||
| foreachScreenEdge_userData *data = userData; | foreachScreenEdge_userData *data = static_cast<foreachScreenEdge_userData *>(userData); | ||||
| BMEdge *eed = BM_edge_at_index(data->vc.em->bm, index); | BMEdge *eed = BM_edge_at_index(data->vc.em->bm, index); | ||||
| if (UNLIKELY(BM_elem_flag_test(eed, BM_ELEM_HIDDEN))) { | if (UNLIKELY(BM_elem_flag_test(eed, BM_ELEM_HIDDEN))) { | ||||
| return; | return; | ||||
| } | } | ||||
| BLI_assert(data->clip_flag & V3D_PROJ_TEST_CLIP_BB); | BLI_assert(data->clip_flag & V3D_PROJ_TEST_CLIP_BB); | ||||
| float v_a_clip[3], v_b_clip[3]; | float v_a_clip[3], v_b_clip[3]; | ||||
| ▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | data.content_planes_len = content_planes_from_clip_flag( | ||||
| vc->region, vc->obedit, clip_flag, data.content_planes); | vc->region, vc->obedit, clip_flag, data.content_planes); | ||||
| } | } | ||||
| else { | else { | ||||
| data.content_planes_len = 0; | data.content_planes_len = 0; | ||||
| } | } | ||||
| BM_mesh_elem_table_ensure(vc->em->bm, BM_EDGE); | BM_mesh_elem_table_ensure(vc->em->bm, BM_EDGE); | ||||
| if ((clip_flag & V3D_PROJ_TEST_CLIP_BB) && (vc->rv3d->clipbb != NULL)) { | if ((clip_flag & V3D_PROJ_TEST_CLIP_BB) && (vc->rv3d->clipbb != nullptr)) { | ||||
| ED_view3d_clipping_local(vc->rv3d, vc->obedit->obmat); /* for local clipping lookups. */ | ED_view3d_clipping_local(vc->rv3d, vc->obedit->obmat); /* for local clipping lookups. */ | ||||
| BKE_mesh_foreach_mapped_edge( | BKE_mesh_foreach_mapped_edge( | ||||
| me, vc->em->bm->totedge, mesh_foreachScreenEdge_clip_bb_segment__mapFunc, &data); | me, vc->em->bm->totedge, mesh_foreachScreenEdge_clip_bb_segment__mapFunc, &data); | ||||
| } | } | ||||
| else { | else { | ||||
| BKE_mesh_foreach_mapped_edge(me, vc->em->bm->totedge, mesh_foreachScreenEdge__mapFunc, &data); | BKE_mesh_foreach_mapped_edge(me, vc->em->bm->totedge, mesh_foreachScreenEdge__mapFunc, &data); | ||||
| } | } | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Edit-Mesh: For Each Screen Face Center | /** \name Edit-Mesh: For Each Screen Face Center | ||||
| * \{ */ | * \{ */ | ||||
| static void mesh_foreachScreenFace__mapFunc(void *userData, | static void mesh_foreachScreenFace__mapFunc(void *userData, | ||||
| int index, | int index, | ||||
| const float cent[3], | const float cent[3], | ||||
| const float UNUSED(no[3])) | const float UNUSED(no[3])) | ||||
| { | { | ||||
| foreachScreenFace_userData *data = userData; | foreachScreenFace_userData *data = static_cast<foreachScreenFace_userData *>(userData); | ||||
| BMFace *efa = BM_face_at_index(data->vc.em->bm, index); | BMFace *efa = BM_face_at_index(data->vc.em->bm, index); | ||||
| if (UNLIKELY(BM_elem_flag_test(efa, BM_ELEM_HIDDEN))) { | if (UNLIKELY(BM_elem_flag_test(efa, BM_ELEM_HIDDEN))) { | ||||
| return; | return; | ||||
| } | } | ||||
| float screen_co[2]; | float screen_co[2]; | ||||
| if (ED_view3d_project_float_object(data->vc.region, cent, screen_co, data->clip_flag) != | if (ED_view3d_project_float_object(data->vc.region, cent, screen_co, data->clip_flag) != | ||||
| V3D_PROJ_RET_OK) { | V3D_PROJ_RET_OK) { | ||||
| Show All 19 Lines | void mesh_foreachScreenFace( | ||||
| data.vc = *vc; | data.vc = *vc; | ||||
| data.func = func; | data.func = func; | ||||
| data.userData = userData; | data.userData = userData; | ||||
| data.clip_flag = clip_flag; | data.clip_flag = clip_flag; | ||||
| BM_mesh_elem_table_ensure(vc->em->bm, BM_FACE); | BM_mesh_elem_table_ensure(vc->em->bm, BM_FACE); | ||||
| if (me->runtime.subsurf_face_dot_tags != NULL) { | if (me->runtime.subsurf_face_dot_tags != nullptr) { | ||||
| BKE_mesh_foreach_mapped_subdiv_face_center( | BKE_mesh_foreach_mapped_subdiv_face_center( | ||||
| me, mesh_foreachScreenFace__mapFunc, &data, MESH_FOREACH_NOP); | me, mesh_foreachScreenFace__mapFunc, &data, MESH_FOREACH_NOP); | ||||
| } | } | ||||
| else { | else { | ||||
| BKE_mesh_foreach_mapped_face_center( | BKE_mesh_foreach_mapped_face_center( | ||||
| me, mesh_foreachScreenFace__mapFunc, &data, MESH_FOREACH_NOP); | me, mesh_foreachScreenFace__mapFunc, &data, MESH_FOREACH_NOP); | ||||
| } | } | ||||
| } | } | ||||
| Show All 10 Lines | void nurbs_foreachScreenVert(ViewContext *vc, | ||||
| BPoint *bp, | BPoint *bp, | ||||
| BezTriple *bezt, | BezTriple *bezt, | ||||
| int beztindex, | int beztindex, | ||||
| bool handles_visible, | bool handles_visible, | ||||
| const float screen_co_b[2]), | const float screen_co_b[2]), | ||||
| void *userData, | void *userData, | ||||
| const eV3DProjTest clip_flag) | const eV3DProjTest clip_flag) | ||||
| { | { | ||||
| Curve *cu = vc->obedit->data; | Curve *cu = static_cast<Curve *>(vc->obedit->data); | ||||
| Nurb *nu; | |||||
| int i; | int i; | ||||
| ListBase *nurbs = BKE_curve_editNurbs_get(cu); | ListBase *nurbs = BKE_curve_editNurbs_get(cu); | ||||
| /* If no point in the triple is selected, the handles are invisible. */ | /* If no point in the triple is selected, the handles are invisible. */ | ||||
| const bool only_selected = (vc->v3d->overlay.handle_display == CURVE_HANDLE_SELECTED); | const bool only_selected = (vc->v3d->overlay.handle_display == CURVE_HANDLE_SELECTED); | ||||
| ED_view3d_check_mats_rv3d(vc->rv3d); | ED_view3d_check_mats_rv3d(vc->rv3d); | ||||
| if (clip_flag & V3D_PROJ_TEST_CLIP_BB) { | if (clip_flag & V3D_PROJ_TEST_CLIP_BB) { | ||||
| ED_view3d_clipping_local(vc->rv3d, vc->obedit->obmat); /* for local clipping lookups */ | ED_view3d_clipping_local(vc->rv3d, vc->obedit->obmat); /* for local clipping lookups */ | ||||
| } | } | ||||
| for (nu = nurbs->first; nu; nu = nu->next) { | LISTBASE_FOREACH (Nurb *, nu, nurbs) { | ||||
| if (nu->type == CU_BEZIER) { | if (nu->type == CU_BEZIER) { | ||||
| for (i = 0; i < nu->pntsu; i++) { | for (i = 0; i < nu->pntsu; i++) { | ||||
| BezTriple *bezt = &nu->bezt[i]; | BezTriple *bezt = &nu->bezt[i]; | ||||
| if (bezt->hide == 0) { | if (bezt->hide == 0) { | ||||
| const bool handles_visible = (vc->v3d->overlay.handle_display != CURVE_HANDLE_NONE) && | const bool handles_visible = (vc->v3d->overlay.handle_display != CURVE_HANDLE_NONE) && | ||||
| (!only_selected || BEZT_ISSEL_ANY(bezt)); | (!only_selected || BEZT_ISSEL_ANY(bezt)); | ||||
| float screen_co[2]; | float screen_co[2]; | ||||
| if (!handles_visible) { | if (!handles_visible) { | ||||
| if (ED_view3d_project_float_object(vc->region, | if (ED_view3d_project_float_object( | ||||
| vc->region, | |||||
| bezt->vec[1], | bezt->vec[1], | ||||
| screen_co, | screen_co, | ||||
| V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN) == | eV3DProjTest(V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN)) == | ||||
| V3D_PROJ_RET_OK) { | V3D_PROJ_RET_OK) { | ||||
| func(userData, nu, NULL, bezt, 1, false, screen_co); | func(userData, nu, nullptr, bezt, 1, false, screen_co); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| if (ED_view3d_project_float_object(vc->region, | if (ED_view3d_project_float_object( | ||||
| vc->region, | |||||
| bezt->vec[0], | bezt->vec[0], | ||||
| screen_co, | screen_co, | ||||
| V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN) == | eV3DProjTest(V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN)) == | ||||
| V3D_PROJ_RET_OK) { | V3D_PROJ_RET_OK) { | ||||
| func(userData, nu, NULL, bezt, 0, true, screen_co); | func(userData, nu, nullptr, bezt, 0, true, screen_co); | ||||
| } | } | ||||
| if (ED_view3d_project_float_object(vc->region, | if (ED_view3d_project_float_object( | ||||
| vc->region, | |||||
| bezt->vec[1], | bezt->vec[1], | ||||
| screen_co, | screen_co, | ||||
| V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN) == | eV3DProjTest(V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN)) == | ||||
| V3D_PROJ_RET_OK) { | V3D_PROJ_RET_OK) { | ||||
| func(userData, nu, NULL, bezt, 1, true, screen_co); | func(userData, nu, nullptr, bezt, 1, true, screen_co); | ||||
| } | } | ||||
| if (ED_view3d_project_float_object(vc->region, | if (ED_view3d_project_float_object( | ||||
| vc->region, | |||||
| bezt->vec[2], | bezt->vec[2], | ||||
| screen_co, | screen_co, | ||||
| V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN) == | eV3DProjTest(V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN)) == | ||||
| V3D_PROJ_RET_OK) { | V3D_PROJ_RET_OK) { | ||||
| func(userData, nu, NULL, bezt, 2, true, screen_co); | func(userData, nu, nullptr, bezt, 2, true, screen_co); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| for (i = 0; i < nu->pntsu * nu->pntsv; i++) { | for (i = 0; i < nu->pntsu * nu->pntsv; i++) { | ||||
| BPoint *bp = &nu->bp[i]; | BPoint *bp = &nu->bp[i]; | ||||
| if (bp->hide == 0) { | if (bp->hide == 0) { | ||||
| float screen_co[2]; | float screen_co[2]; | ||||
| if (ED_view3d_project_float_object( | if (ED_view3d_project_float_object( | ||||
| vc->region, bp->vec, screen_co, V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN) == | vc->region, | ||||
| V3D_PROJ_RET_OK) { | bp->vec, | ||||
| func(userData, nu, bp, NULL, -1, false, screen_co); | screen_co, | ||||
| eV3DProjTest(V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN)) == V3D_PROJ_RET_OK) { | |||||
| func(userData, nu, bp, nullptr, -1, false, screen_co); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Edit-Meta: For Each Screen Meta-Element | /** \name Edit-Meta: For Each Screen Meta-Element | ||||
| * \{ */ | * \{ */ | ||||
| void mball_foreachScreenElem(struct ViewContext *vc, | void mball_foreachScreenElem(ViewContext *vc, | ||||
| void (*func)(void *userData, | void (*func)(void *userData, | ||||
| struct MetaElem *ml, | MetaElem *ml, | ||||
| const float screen_co_b[2]), | const float screen_co_b[2]), | ||||
| void *userData, | void *userData, | ||||
| const eV3DProjTest clip_flag) | const eV3DProjTest clip_flag) | ||||
| { | { | ||||
| MetaBall *mb = (MetaBall *)vc->obedit->data; | MetaBall *mb = (MetaBall *)vc->obedit->data; | ||||
| MetaElem *ml; | |||||
| ED_view3d_check_mats_rv3d(vc->rv3d); | ED_view3d_check_mats_rv3d(vc->rv3d); | ||||
| for (ml = mb->editelems->first; ml; ml = ml->next) { | LISTBASE_FOREACH (MetaElem *, ml, mb->editelems) { | ||||
| float screen_co[2]; | float screen_co[2]; | ||||
| if (ED_view3d_project_float_object(vc->region, &ml->x, screen_co, clip_flag) == | if (ED_view3d_project_float_object(vc->region, &ml->x, screen_co, clip_flag) == | ||||
| V3D_PROJ_RET_OK) { | V3D_PROJ_RET_OK) { | ||||
| func(userData, ml, screen_co); | func(userData, ml, screen_co); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Edit-Lattice: For Each Screen Vertex | /** \name Edit-Lattice: For Each Screen Vertex | ||||
| * \{ */ | * \{ */ | ||||
| void lattice_foreachScreenVert(ViewContext *vc, | void lattice_foreachScreenVert(ViewContext *vc, | ||||
| void (*func)(void *userData, BPoint *bp, const float screen_co[2]), | void (*func)(void *userData, BPoint *bp, const float screen_co[2]), | ||||
| void *userData, | void *userData, | ||||
| const eV3DProjTest clip_flag) | const eV3DProjTest clip_flag) | ||||
| { | { | ||||
| Object *obedit = vc->obedit; | Object *obedit = vc->obedit; | ||||
| Lattice *lt = obedit->data; | Lattice *lt = static_cast<Lattice *>(obedit->data); | ||||
| BPoint *bp = lt->editlatt->latt->def; | BPoint *bp = lt->editlatt->latt->def; | ||||
| DispList *dl = obedit->runtime.curve_cache ? | DispList *dl = obedit->runtime.curve_cache ? | ||||
| BKE_displist_find(&obedit->runtime.curve_cache->disp, DL_VERTS) : | BKE_displist_find(&obedit->runtime.curve_cache->disp, DL_VERTS) : | ||||
| NULL; | nullptr; | ||||
| const float *co = dl ? dl->verts : NULL; | const float *co = dl ? dl->verts : nullptr; | ||||
| int i, N = lt->editlatt->latt->pntsu * lt->editlatt->latt->pntsv * lt->editlatt->latt->pntsw; | int i, N = lt->editlatt->latt->pntsu * lt->editlatt->latt->pntsv * lt->editlatt->latt->pntsw; | ||||
| ED_view3d_check_mats_rv3d(vc->rv3d); | ED_view3d_check_mats_rv3d(vc->rv3d); | ||||
| if (clip_flag & V3D_PROJ_TEST_CLIP_BB) { | if (clip_flag & V3D_PROJ_TEST_CLIP_BB) { | ||||
| ED_view3d_clipping_local(vc->rv3d, obedit->obmat); /* for local clipping lookups */ | ED_view3d_clipping_local(vc->rv3d, obedit->obmat); /* for local clipping lookups */ | ||||
| } | } | ||||
| Show All 9 Lines | |||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Edit-Armature: For Each Screen Bone | /** \name Edit-Armature: For Each Screen Bone | ||||
| * \{ */ | * \{ */ | ||||
| void armature_foreachScreenBone(struct ViewContext *vc, | void armature_foreachScreenBone(ViewContext *vc, | ||||
| void (*func)(void *userData, | void (*func)(void *userData, | ||||
| struct EditBone *ebone, | EditBone *ebone, | ||||
| const float screen_co_a[2], | const float screen_co_a[2], | ||||
| const float screen_co_b[2]), | const float screen_co_b[2]), | ||||
| void *userData, | void *userData, | ||||
| const eV3DProjTest clip_flag) | const eV3DProjTest clip_flag) | ||||
| { | { | ||||
| bArmature *arm = vc->obedit->data; | bArmature *arm = static_cast<bArmature *>(vc->obedit->data); | ||||
| EditBone *ebone; | |||||
| ED_view3d_check_mats_rv3d(vc->rv3d); | ED_view3d_check_mats_rv3d(vc->rv3d); | ||||
| float content_planes[6][4]; | float content_planes[6][4]; | ||||
| int content_planes_len; | int content_planes_len; | ||||
| rctf win_rect; | rctf win_rect; | ||||
| if (clip_flag & V3D_PROJ_TEST_CLIP_CONTENT) { | if (clip_flag & V3D_PROJ_TEST_CLIP_CONTENT) { | ||||
| content_planes_len = content_planes_from_clip_flag( | content_planes_len = content_planes_from_clip_flag( | ||||
| vc->region, vc->obedit, clip_flag, content_planes); | vc->region, vc->obedit, clip_flag, content_planes); | ||||
| win_rect.xmin = 0; | win_rect.xmin = 0; | ||||
| win_rect.ymin = 0; | win_rect.ymin = 0; | ||||
| win_rect.xmax = vc->region->winx; | win_rect.xmax = vc->region->winx; | ||||
| win_rect.ymax = vc->region->winy; | win_rect.ymax = vc->region->winy; | ||||
| } | } | ||||
| else { | else { | ||||
| content_planes_len = 0; | content_planes_len = 0; | ||||
| } | } | ||||
| for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { | LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) { | ||||
| if (!EBONE_VISIBLE(arm, ebone)) { | if (!EBONE_VISIBLE(arm, ebone)) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| float screen_co_a[2], screen_co_b[2]; | float screen_co_a[2], screen_co_b[2]; | ||||
| const float *v_a = ebone->head, *v_b = ebone->tail; | const float *v_a = ebone->head, *v_b = ebone->tail; | ||||
| if (clip_flag & V3D_PROJ_TEST_CLIP_CONTENT) { | if (clip_flag & V3D_PROJ_TEST_CLIP_CONTENT) { | ||||
| Show All 21 Lines | |||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Pose: For Each Screen Bone | /** \name Pose: For Each Screen Bone | ||||
| * \{ */ | * \{ */ | ||||
| void pose_foreachScreenBone(struct ViewContext *vc, | void pose_foreachScreenBone(ViewContext *vc, | ||||
| void (*func)(void *userData, | void (*func)(void *userData, | ||||
| struct bPoseChannel *pchan, | bPoseChannel *pchan, | ||||
| const float screen_co_a[2], | const float screen_co_a[2], | ||||
| const float screen_co_b[2]), | const float screen_co_b[2]), | ||||
| void *userData, | void *userData, | ||||
| const eV3DProjTest clip_flag) | const eV3DProjTest clip_flag) | ||||
| { | { | ||||
| /* Almost _exact_ copy of #armature_foreachScreenBone */ | /* Almost _exact_ copy of #armature_foreachScreenBone */ | ||||
| const Object *ob_eval = DEG_get_evaluated_object(vc->depsgraph, vc->obact); | const Object *ob_eval = DEG_get_evaluated_object(vc->depsgraph, vc->obact); | ||||
| const bArmature *arm_eval = ob_eval->data; | const bArmature *arm_eval = static_cast<const bArmature *>(ob_eval->data); | ||||
| bPose *pose = vc->obact->pose; | bPose *pose = vc->obact->pose; | ||||
| bPoseChannel *pchan; | |||||
| ED_view3d_check_mats_rv3d(vc->rv3d); | ED_view3d_check_mats_rv3d(vc->rv3d); | ||||
| float content_planes[6][4]; | float content_planes[6][4]; | ||||
| int content_planes_len; | int content_planes_len; | ||||
| rctf win_rect; | rctf win_rect; | ||||
| if (clip_flag & V3D_PROJ_TEST_CLIP_CONTENT) { | if (clip_flag & V3D_PROJ_TEST_CLIP_CONTENT) { | ||||
| content_planes_len = content_planes_from_clip_flag( | content_planes_len = content_planes_from_clip_flag( | ||||
| vc->region, ob_eval, clip_flag, content_planes); | vc->region, ob_eval, clip_flag, content_planes); | ||||
| win_rect.xmin = 0; | win_rect.xmin = 0; | ||||
| win_rect.ymin = 0; | win_rect.ymin = 0; | ||||
| win_rect.xmax = vc->region->winx; | win_rect.xmax = vc->region->winx; | ||||
| win_rect.ymax = vc->region->winy; | win_rect.ymax = vc->region->winy; | ||||
| } | } | ||||
| else { | else { | ||||
| content_planes_len = 0; | content_planes_len = 0; | ||||
| } | } | ||||
| for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) { | LISTBASE_FOREACH (bPoseChannel *, pchan, &pose->chanbase) { | ||||
| if (!PBONE_VISIBLE(arm_eval, pchan->bone)) { | if (!PBONE_VISIBLE(arm_eval, pchan->bone)) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| bPoseChannel *pchan_eval = BKE_pose_channel_find_name(ob_eval->pose, pchan->name); | bPoseChannel *pchan_eval = BKE_pose_channel_find_name(ob_eval->pose, pchan->name); | ||||
| float screen_co_a[2], screen_co_b[2]; | float screen_co_a[2], screen_co_b[2]; | ||||
| const float *v_a = pchan_eval->pose_head, *v_b = pchan_eval->pose_tail; | const float *v_a = pchan_eval->pose_head, *v_b = pchan_eval->pose_tail; | ||||
| Show All 25 Lines | |||||