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:
authorIliya Katueshenock <Moder>2022-10-05 20:31:01 +0300
committerHans Goudey <h.goudey@me.com>2022-10-05 20:42:46 +0300
commite89b2b12213580315e55c693ee5384a39c554688 (patch)
tree41d78a3de77dcadbc22f3ff6551607f84ee3d0aa /source/blender/blenkernel
parent124df79e784bc2722a551f6c245f2612f471c62a (diff)
Mesh: Skip some domain interpolations for single values
Completely skip the work of interpolating domains for single values for many to and from combinations. Similar to 535f50e5a6a248b7aa74b59, but slightly more complex because of the possibility of loose elements on some mesh domains. From D16054, with added comments.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/intern/geometry_component_mesh.cc32
1 files changed, 32 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/geometry_component_mesh.cc b/source/blender/blenkernel/intern/geometry_component_mesh.cc
index 827fef8b6d0..228c27cedf7 100644
--- a/source/blender/blenkernel/intern/geometry_component_mesh.cc
+++ b/source/blender/blenkernel/intern/geometry_component_mesh.cc
@@ -765,6 +765,30 @@ static GVArray adapt_mesh_domain_edge_to_face(const Mesh &mesh, const GVArray &v
} // namespace blender::bke
+static bool can_simple_adapt_for_single(const eAttrDomain from_domain, const eAttrDomain to_domain)
+{
+ /* For some domain combinations, a single value will always map directly. For others, there may
+ * be loose elements on the result domain that should have the default value rather than the
+ * single value from the source. */
+ switch (from_domain) {
+ case ATTR_DOMAIN_POINT:
+ /* All other domains are always connected to points. */
+ return true;
+ case ATTR_DOMAIN_EDGE:
+ /* There may be loose vertices not connected to edges. */
+ return ELEM(to_domain, ATTR_DOMAIN_FACE, ATTR_DOMAIN_CORNER);
+ case ATTR_DOMAIN_FACE:
+ /* There may be loose vertices or edges not connected to faces. */
+ return to_domain == ATTR_DOMAIN_CORNER;
+ case ATTR_DOMAIN_CORNER:
+ /* Only faces are always connected to corners. */
+ return to_domain == ATTR_DOMAIN_FACE;
+ default:
+ BLI_assert_unreachable();
+ return false;
+ }
+}
+
static blender::GVArray adapt_mesh_attribute_domain(const Mesh &mesh,
const blender::GVArray &varray,
const eAttrDomain from_domain,
@@ -779,6 +803,14 @@ static blender::GVArray adapt_mesh_attribute_domain(const Mesh &mesh,
if (from_domain == to_domain) {
return varray;
}
+ if (varray.is_single()) {
+ if (can_simple_adapt_for_single(from_domain, to_domain)) {
+ BUFFER_FOR_CPP_TYPE_VALUE(varray.type(), value);
+ varray.get_internal_single(value);
+ return blender::GVArray::ForSingle(
+ varray.type(), mesh.attributes().domain_size(to_domain), value);
+ }
+ }
switch (from_domain) {
case ATTR_DOMAIN_CORNER: {