main sync #3

Merged
Patrick Busch merged 318 commits from blender/blender:main into main 2023-03-17 15:52:21 +01:00
5 changed files with 18 additions and 3 deletions
Showing only changes of commit f9c627b275 - Show all commits

View File

@ -1585,6 +1585,11 @@ bool BKE_mesh_minmax(const Mesh *me, float r_min[3], float r_max[3])
return true;
}
void Mesh::bounds_set_eager(const blender::Bounds<float3> &bounds)
{
this->runtime->bounds_cache.ensure([&](blender::Bounds<float3> &r_data) { r_data = bounds; });
}
void BKE_mesh_transform(Mesh *me, const float mat[4][4], bool do_keys)
{
MutableSpan<float3> positions = me->vert_positions_for_write();

View File

@ -5549,9 +5549,9 @@ void SCULPT_flush_update_step(bContext *C, SculptUpdateType update_flags)
/* When sculpting and changing the positions of a mesh, tag them as changed and update. */
BKE_mesh_tag_positions_changed(mesh);
/* Update the mesh's bounds eagerly since the PBVH already has that information. */
mesh->runtime->bounds_cache.ensure([&](Bounds<float3> &r_bounds) {
BKE_pbvh_bounding_box(ob->sculpt->pbvh, r_bounds.min, r_bounds.max);
});
Bounds<float3> bounds;
BKE_pbvh_bounding_box(ob->sculpt->pbvh, bounds.min, bounds.max);
mesh->bounds_set_eager(bounds);
}
}
}

View File

@ -418,6 +418,9 @@ Mesh *create_cuboid_mesh(const float3 &size,
calculate_uvs(config, mesh, uv_id);
}
const float3 bounds = size * 0.5f;
mesh->bounds_set_eager({-bounds, bounds});
return mesh;
}

View File

@ -16,6 +16,7 @@
/** Workaround to forward-declare C++ type in C header. */
#ifdef __cplusplus
# include "BLI_bounds_types.hh"
# include "BLI_math_vector_types.hh"
namespace blender {
@ -261,6 +262,9 @@ typedef struct Mesh {
*/
blender::Span<MLoopTri> looptris() const;
/** Set cached mesh bounds to a known-correct value to avoid their lazy calculation later on. */
void bounds_set_eager(const blender::Bounds<blender::float3> &bounds);
/**
* Cached information about loose edges, calculated lazily when necessary.
*/

View File

@ -148,6 +148,9 @@ Mesh *create_grid_mesh(const int verts_x,
mesh->loose_edges_tag_none();
const float3 bounds = float3(size_x * 0.5f, size_y * 0.5f, 0.0f);
mesh->bounds_set_eager({-bounds, bounds});
return mesh;
}