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
diff options
context:
space:
mode:
authorJacques Lucke <jacques@blender.org>2022-09-24 12:41:08 +0300
committerJacques Lucke <jacques@blender.org>2022-09-24 12:41:08 +0300
commitc25df02ac3036449081701349d36d2f16b2c92f2 (patch)
tree29603afd3baced747546f4a841cbd4ab73bc7052 /source/blender/blenkernel
parent8422da13c929f65850a723794a27baa924929377 (diff)
Cleanup: simplify accessing mesh looptris
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/intern/mesh_remesh_voxel.cc3
-rw-r--r--source/blender/blenkernel/intern/mesh_runtime.cc7
-rw-r--r--source/blender/blenkernel/intern/mesh_sample.cc21
3 files changed, 15 insertions, 16 deletions
diff --git a/source/blender/blenkernel/intern/mesh_remesh_voxel.cc b/source/blender/blenkernel/intern/mesh_remesh_voxel.cc
index 12f42dbc4ec..3c492e2e167 100644
--- a/source/blender/blenkernel/intern/mesh_remesh_voxel.cc
+++ b/source/blender/blenkernel/intern/mesh_remesh_voxel.cc
@@ -194,8 +194,7 @@ static openvdb::FloatGrid::Ptr remesh_voxel_level_set_create(const Mesh *mesh,
{
const Span<MVert> verts = mesh->verts();
const Span<MLoop> loops = mesh->loops();
- Span<MLoopTri> looptris{BKE_mesh_runtime_looptri_ensure(mesh),
- BKE_mesh_runtime_looptri_len(mesh)};
+ const Span<MLoopTri> looptris = mesh->looptris();
std::vector<openvdb::Vec3s> points(mesh->totvert);
std::vector<openvdb::Vec3I> triangles(looptris.size());
diff --git a/source/blender/blenkernel/intern/mesh_runtime.cc b/source/blender/blenkernel/intern/mesh_runtime.cc
index 782657428f5..062d6cdb952 100644
--- a/source/blender/blenkernel/intern/mesh_runtime.cc
+++ b/source/blender/blenkernel/intern/mesh_runtime.cc
@@ -112,6 +112,13 @@ void BKE_mesh_runtime_clear_cache(Mesh *mesh)
BKE_mesh_clear_derived_normals(mesh);
}
+blender::Span<MLoopTri> Mesh::looptris() const
+{
+ const MLoopTri *looptris = BKE_mesh_runtime_looptri_ensure(this);
+ const int num_looptris = BKE_mesh_runtime_looptri_len(this);
+ return {looptris, num_looptris};
+}
+
/**
* Ensure the array is large enough
*
diff --git a/source/blender/blenkernel/intern/mesh_sample.cc b/source/blender/blenkernel/intern/mesh_sample.cc
index 1ddac19304d..ed7ae8113a7 100644
--- a/source/blender/blenkernel/intern/mesh_sample.cc
+++ b/source/blender/blenkernel/intern/mesh_sample.cc
@@ -22,8 +22,7 @@ BLI_NOINLINE static void sample_point_attribute(const Mesh &mesh,
const MutableSpan<T> dst)
{
const Span<MLoop> loops = mesh.loops();
- const Span<MLoopTri> looptris{BKE_mesh_runtime_looptri_ensure(&mesh),
- BKE_mesh_runtime_looptri_len(&mesh)};
+ const Span<MLoopTri> looptris = mesh.looptris();
for (const int i : mask) {
const int looptri_index = looptri_indices[i];
@@ -69,8 +68,7 @@ BLI_NOINLINE static void sample_corner_attribute(const Mesh &mesh,
const IndexMask mask,
const MutableSpan<T> dst)
{
- const Span<MLoopTri> looptris{BKE_mesh_runtime_looptri_ensure(&mesh),
- BKE_mesh_runtime_looptri_len(&mesh)};
+ const Span<MLoopTri> looptris = mesh.looptris();
for (const int i : mask) {
const int looptri_index = looptri_indices[i];
@@ -115,8 +113,7 @@ void sample_face_attribute(const Mesh &mesh,
const IndexMask mask,
const MutableSpan<T> dst)
{
- const Span<MLoopTri> looptris{BKE_mesh_runtime_looptri_ensure(&mesh),
- BKE_mesh_runtime_looptri_len(&mesh)};
+ const Span<MLoopTri> looptris = mesh.looptris();
for (const int i : mask) {
const int looptri_index = looptri_indices[i];
@@ -161,8 +158,7 @@ Span<float3> MeshAttributeInterpolator::ensure_barycentric_coords()
const Span<MVert> verts = mesh_->verts();
const Span<MLoop> loops = mesh_->loops();
- const Span<MLoopTri> looptris{BKE_mesh_runtime_looptri_ensure(mesh_),
- BKE_mesh_runtime_looptri_len(mesh_)};
+ const Span<MLoopTri> looptris = mesh_->looptris();
for (const int i : mask_) {
const int looptri_index = looptri_indices_[i];
@@ -191,8 +187,7 @@ Span<float3> MeshAttributeInterpolator::ensure_nearest_weights()
const Span<MVert> verts = mesh_->verts();
const Span<MLoop> loops = mesh_->loops();
- const Span<MLoopTri> looptris{BKE_mesh_runtime_looptri_ensure(mesh_),
- BKE_mesh_runtime_looptri_len(mesh_)};
+ const Span<MLoopTri> looptris = mesh_->looptris();
for (const int i : mask_) {
const int looptri_index = looptri_indices_[i];
@@ -265,8 +260,7 @@ int sample_surface_points_spherical(RandomNumberGenerator &rng,
{
const Span<MVert> verts = mesh.verts();
const Span<MLoop> loops = mesh.loops();
- const Span<MLoopTri> looptris{BKE_mesh_runtime_looptri_ensure(&mesh),
- BKE_mesh_runtime_looptri_len(&mesh)};
+ const Span<MLoopTri> looptris = mesh.looptris();
const float sample_radius_sq = pow2f(sample_radius);
const float sample_plane_area = M_PI * sample_radius_sq;
@@ -363,8 +357,7 @@ int sample_surface_points_projected(
{
const Span<MVert> verts = mesh.verts();
const Span<MLoop> loops = mesh.loops();
- const Span<MLoopTri> looptris{BKE_mesh_runtime_looptri_ensure(&mesh),
- BKE_mesh_runtime_looptri_len(&mesh)};
+ const Span<MLoopTri> looptris = mesh.looptris();
int point_count = 0;
for ([[maybe_unused]] const int _ : IndexRange(tries_num)) {