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
This commit is contained in:
parent
ac90c8a774
commit
788a28251b
Notes:
blender-bot
2023-02-14 10:29:32 +01:00
Referenced by issue #87083, Convert all data to real mesh when applying the nodes modifier
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue