[Bf-blender-cvs] [788a28251ba] master: Geometry Nodes: Realize instances when applying modifiers

Hans Goudey noreply at git.blender.org
Wed Apr 14 21:24:00 CEST 2021


Commit: 788a28251ba4a66ec4f4495fb7503e956eb2e065
Author: Hans Goudey
Date:   Wed Apr 14 14:23:48 2021 -0500
Branches: master
https://developer.blender.org/rB788a28251ba4a66ec4f4495fb7503e956eb2e065

Geometry Nodes: Realize instances when applying modifiers

The fact that geometry from instnances isn't realized when applying
a nodes modifier can be very confusing, especially for new users.
Nodes themselves realize geometry instances implicitly whenever they
need to. We also currently make instances real and convert points to
mesh when a modifier is added after the nodes modifier. With this
commit, we simply do the same thing when applying the modifier.

There are a few downsides though:
 - This can be an extremely heavy operations in some cases where
   geometry nodes is used to instance heavy geometry.
 - We will still have the issues with materials, since instances use
   materials from their original objects, but real geometry uses
   materials from the modifier object.

It was decided to live with the potential performance downsides
for now, the idea is the upsides of the change are more important,
and people making complicated setups will be more likely to know not
to apply the modifier. In the future there could be a warning if it's
necessary though.

Ref T87083

===================================================================

M	source/blender/modifiers/intern/MOD_nodes.cc

===================================================================

diff --git a/source/blender/modifiers/intern/MOD_nodes.cc b/source/blender/modifiers/intern/MOD_nodes.cc
index 216a1c43d3e..49f2d66e54a 100644
--- a/source/blender/modifiers/intern/MOD_nodes.cc
+++ b/source/blender/modifiers/intern/MOD_nodes.cc
@@ -1383,6 +1383,11 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
   geometry_set.get_component_for_write<MeshComponent>().copy_vertex_group_names_from_object(
       *ctx->object);
   modifyGeometry(md, ctx, geometry_set);
+
+  /* This function is only called when applying modifiers. In this case it makes sense to realize
+   * instances, otherwise in some cases there might be no results when applying the modifier. */
+  geometry_set = blender::bke::geometry_set_realize_mesh_for_modifier(geometry_set);
+
   Mesh *new_mesh = geometry_set.get_component_for_write<MeshComponent>().release();
   if (new_mesh == nullptr) {
     return BKE_mesh_new_nomain(0, 0, 0, 0, 0);



More information about the Bf-blender-cvs mailing list