Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorHans Goudey <h.goudey@me.com>2022-04-14 02:49:11 +0300
committerHans Goudey <h.goudey@me.com>2022-04-14 02:49:11 +0300
commit0ba061c3bc9bf299c17e064c5fc0f6ae9ac906a1 (patch)
tree578ab9199ea83b3f388170ee8b89c127c560460b /source
parent232b388455a53fdd2c6028be99a094ed796b4d18 (diff)
Edit Mesh: Parallelize bounds calculation with deform modifiers
When displaying a deform modifier in edit mode, a cached array of positions is used. Parallelizing bounds calculation when that array exists can improve the framerate when editing slightly (a few percent). I observed an improvement of the min/max itself of about 10x (4-5ms to 0.4ms).
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/intern/editmesh_cache.cc16
1 files changed, 10 insertions, 6 deletions
diff --git a/source/blender/blenkernel/intern/editmesh_cache.cc b/source/blender/blenkernel/intern/editmesh_cache.cc
index c2ce1405111..438d287fb28 100644
--- a/source/blender/blenkernel/intern/editmesh_cache.cc
+++ b/source/blender/blenkernel/intern/editmesh_cache.cc
@@ -8,7 +8,9 @@
#include "MEM_guardedalloc.h"
+#include "BLI_bounds.hh"
#include "BLI_math_vector.h"
+#include "BLI_span.hh"
#include "DNA_mesh_types.h"
@@ -114,18 +116,20 @@ bool BKE_editmesh_cache_calc_minmax(struct BMEditMesh *em,
float min[3],
float max[3])
{
+ using namespace blender;
BMesh *bm = em->bm;
- BMVert *eve;
- BMIter iter;
- int i;
if (bm->totvert) {
if (emd->vertexCos) {
- BM_ITER_MESH_INDEX (eve, &iter, bm, BM_VERTS_OF_MESH, i) {
- minmax_v3v3_v3(min, max, emd->vertexCos[i]);
- }
+ Span<float3> vert_coords(reinterpret_cast<const float3 *>(emd->vertexCos), bm->totvert);
+ std::optional<bounds::MinMaxResult<float3>> bounds = bounds::min_max(vert_coords);
+ BLI_assert(bounds.has_value());
+ copy_v3_v3(min, math::min(bounds->min, float3(min)));
+ copy_v3_v3(max, math::max(bounds->max, float3(max)));
}
else {
+ BMVert *eve;
+ BMIter iter;
BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) {
minmax_v3v3_v3(min, max, eve->co);
}