diff options
author | Hans Goudey <h.goudey@me.com> | 2022-09-28 22:31:32 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2022-09-28 22:31:32 +0300 |
commit | 25533dbe219f8bbcb3f04ffe2ff1e57599addf3f (patch) | |
tree | fd4d4260fbb807d3d0484d2c4259b43378390875 /source/blender/render | |
parent | 878dea4e0fcca68ba3ad93edeae22114e1252f9e (diff) |
Mesh: Add C++ implementaiton of topology mappings
Because they are friendlier to use in C++ code than the existing mesh
mapping API, these mappings from one domain to another were often
reimplemented in separate files. This commit moves some basic
implementations to a `mesh_topology` namespace in the existing
mesh mapping header file. These is plenty of room for performance
improvement here, particularly by not using an array of Vectors, but
that can come later.
Split from D16029
Diffstat (limited to 'source/blender/render')
-rw-r--r-- | source/blender/render/intern/texture_margin.cc | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/source/blender/render/intern/texture_margin.cc b/source/blender/render/intern/texture_margin.cc index 201908234fe..a69449d9386 100644 --- a/source/blender/render/intern/texture_margin.cc +++ b/source/blender/render/intern/texture_margin.cc @@ -14,6 +14,7 @@ #include "BKE_DerivedMesh.h" #include "BKE_customdata.h" #include "BKE_mesh.h" +#include "BKE_mesh_mapping.h" #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" @@ -44,7 +45,7 @@ class TextureMarginMap { /** Maps UV-edges to their corresponding UV-edge. */ Vector<int> loop_adjacency_map_; /** Maps UV-edges to their corresponding polygon. */ - Vector<int> loop_to_poly_map_; + Array<int> loop_to_poly_map_; int w_, h_; float uv_offset_[2]; @@ -289,13 +290,8 @@ class TextureMarginMap { void build_tables() { - loop_to_poly_map_.resize(totloop_); - for (int i = 0; i < totpoly_; i++) { - for (int j = 0; j < mpoly_[i].totloop; j++) { - int l = j + mpoly_[i].loopstart; - loop_to_poly_map_[l] = i; - } - } + loop_to_poly_map_ = blender::mesh_topology::build_corner_to_poly_map({mpoly_, totpoly_}, + totloop_); loop_adjacency_map_.resize(totloop_, -1); |