diff options
author | Howard Trickey <howard.trickey@gmail.com> | 2020-12-05 15:48:41 +0300 |
---|---|---|
committer | Howard Trickey <howard.trickey@gmail.com> | 2020-12-05 15:48:41 +0300 |
commit | 8982a315b76e70ecf244243c3002d46ca73761f8 (patch) | |
tree | d508a5bddf1fff9021bea19c0431fb36f26b938e /source/blender | |
parent | 887a602448286fe57b77046001a72d488415b1b8 (diff) |
Add more timing hooks for boolean.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenlib/intern/mesh_intersect.cc | 4 | ||||
-rw-r--r-- | source/blender/bmesh/tools/bmesh_boolean.cc | 20 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_boolean.c | 32 |
3 files changed, 54 insertions, 2 deletions
diff --git a/source/blender/blenlib/intern/mesh_intersect.cc b/source/blender/blenlib/intern/mesh_intersect.cc index 64ea25ccc90..ab956c5c735 100644 --- a/source/blender/blenlib/intern/mesh_intersect.cc +++ b/source/blender/blenlib/intern/mesh_intersect.cc @@ -2178,8 +2178,8 @@ static void calc_overlap_itts_range_func(void *__restrict userdata, } /** - * Fill in itt_map with the vector of ITT_values that result from intersecting the triangles in ov. - * Use a canonical order for triangles: (a,b) where a < b. + * Fill in itt_map with the vector of ITT_values that result from intersecting the triangles in + * ov. Use a canonical order for triangles: (a,b) where a < b. */ static void calc_overlap_itts(Map<std::pair<int, int>, ITT_value> &itt_map, const IMesh &tm, diff --git a/source/blender/bmesh/tools/bmesh_boolean.cc b/source/blender/bmesh/tools/bmesh_boolean.cc index 6031e160c8c..bfb093c569f 100644 --- a/source/blender/bmesh/tools/bmesh_boolean.cc +++ b/source/blender/bmesh/tools/bmesh_boolean.cc @@ -30,6 +30,10 @@ #include "bmesh_boolean.h" #include "bmesh_edgesplit.h" +#include "PIL_time.h" + +// #define PERF_DEBUG + namespace blender::meshintersect { #ifdef WITH_GMP @@ -354,7 +358,14 @@ static bool bmesh_boolean(BMesh *bm, { IMeshArena arena; IMesh m_triangulated; +# ifdef PERF_DEBUG + double start_time = PIL_check_seconds_timer(); +# endif IMesh m_in = mesh_from_bm(bm, looptris, looptris_tot, &m_triangulated, &arena); +# ifdef PERF_DEBUG + double mesh_time = PIL_check_seconds_timer(); + std::cout << "bmesh_boolean, imesh_from_bm done, time = " << mesh_time - start_time << "\n"; +# endif std::function<int(int)> shape_fn; if (use_self && boolean_mode == BoolOpType::None) { /* Unary knife operation. Want every face where test_fn doesn't return -1. */ @@ -379,7 +390,16 @@ static bool bmesh_boolean(BMesh *bm, } IMesh m_out = boolean_mesh( m_in, boolean_mode, nshapes, shape_fn, use_self, &m_triangulated, &arena); +# ifdef PERF_DEBUG + double boolean_time = PIL_check_seconds_timer(); + std::cout << "boolean done, time = " << boolean_time - mesh_time << "\n"; +# endif bool any_change = apply_mesh_output_to_bmesh(bm, m_out, keep_hidden); +# ifdef PERF_DEBUG + double apply_mesh_time = PIL_check_seconds_timer(); + std::cout << "applied boolean output to bmesh, time = " << apply_mesh_time - boolean_time + << "\n"; +# endif if (use_separate_all) { /* We are supposed to separate all faces that are incident on intersection edges. */ BM_mesh_edgesplit(bm, false, true, false); diff --git a/source/blender/modifiers/intern/MOD_boolean.c b/source/blender/modifiers/intern/MOD_boolean.c index 4152e8633e5..0513d3af13a 100644 --- a/source/blender/modifiers/intern/MOD_boolean.c +++ b/source/blender/modifiers/intern/MOD_boolean.c @@ -630,7 +630,15 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * Object *operand_ob = bmd->object; +#ifdef DEBUG_TIME + TIMEIT_BLOCK_INIT(operand_get_evaluated_mesh); + TIMEIT_BLOCK_START(operand_get_evaluated_mesh); +#endif mesh_operand_ob = BKE_modifier_get_evaluated_mesh_from_evaluated_object(operand_ob, false); +#ifdef DEBUG_TIME + TIMEIT_BLOCK_END(operand_get_evaluated_mesh); + TIMEIT_BLOCK_STATS(operand_get_evaluated_mesh); +#endif if (mesh_operand_ob) { /* XXX This is utterly non-optimal, we may go from a bmesh to a mesh back to a bmesh! @@ -642,11 +650,35 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * result = get_quick_mesh(object, mesh, operand_ob, mesh_operand_ob, bmd->operation); if (result == NULL) { +#ifdef DEBUG_TIME + TIMEIT_BLOCK_INIT(object_BMD_mesh_bm_create); + TIMEIT_BLOCK_START(object_BMD_mesh_bm_create); +#endif bm = BMD_mesh_bm_create(mesh, object, mesh_operand_ob, operand_ob, &is_flip); +#ifdef DEBUG_TIME + TIMEIT_BLOCK_END(object_BMD_mesh_bm_create); + TIMEIT_BLOCK_STATS(object_BMD_mesh_bm_create); +#endif +#ifdef DEBUG_TIME + TIMEIT_BLOCK_INIT(BMD_mesh_intersection); + TIMEIT_BLOCK_START(BMD_mesh_intersection); +#endif BMD_mesh_intersection(bm, md, ctx, mesh_operand_ob, object, operand_ob, is_flip); +#ifdef DEBUG_TIME + TIMEIT_BLOCK_END(BMD_mesh_intersection); + TIMEIT_BLOCK_STATS(BMD_mesh_intersection); +#endif +#ifdef DEBUG_TIME + TIMEIT_BLOCK_INIT(BKE_mesh_from_bmesh_for_eval_nomain); + TIMEIT_BLOCK_START(BKE_mesh_from_bmesh_for_eval_nomain); +#endif result = BKE_mesh_from_bmesh_for_eval_nomain(bm, NULL, mesh); +#ifdef DEBUG_TIME + TIMEIT_BLOCK_END(BKE_mesh_from_bmesh_for_eval_nomain); + TIMEIT_BLOCK_STATS(BKE_mesh_from_bmesh_for_eval_nomain); +#endif BM_mesh_free(bm); result->runtime.cd_dirty_vert |= CD_MASK_NORMAL; } |