diff options
author | Hans Goudey <h.goudey@me.com> | 2021-04-14 22:23:48 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2021-04-14 22:23:48 +0300 |
commit | 788a28251ba4a66ec4f4495fb7503e956eb2e065 (patch) | |
tree | 8a9cca5394e3dd8401a80dd8a684e852effbb7ff /source/blender/modifiers | |
parent | ac90c8a7743f6d01ae2c013207ce9cd90cc87b66 (diff) |
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
Diffstat (limited to 'source/blender/modifiers')
-rw-r--r-- | source/blender/modifiers/intern/MOD_nodes.cc | 5 |
1 files changed, 5 insertions, 0 deletions
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); |