diff options
author | Jacques Lucke <jacques@blender.org> | 2021-01-21 12:32:42 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2021-01-21 12:32:42 +0300 |
commit | 793547e7d1401ad545e0450b80c7bafd521c60e1 (patch) | |
tree | 74ebdf40005711eb545fd1889bcf8226dd5bcafd /source/blender/depsgraph | |
parent | 985bc08688b7fb58a910171c63a1417580cffece (diff) |
Geometry Nodes: initial support for volumes
For the most part, this just adds boilerplate code for volume support in geometry nodes:
* Add `VolumeComponent` next to `MeshComponent`, etc.
* Support `VolumeComponent` in depsgraph object iterator.
Furthermore, I added initial volume support in a few nodes:
* The Object Info node outputs an object instance when the input is a volume object
(that will be the same for mesh objects soonish, to avoid copies).
* Support transforming a `VolumeComponent` in the Transform node.
* Support the `VolumeComponent` in Join Geometry nodes, but only when just one of the
inputs has a volume component for now.
Right now, there is no way to create a `VolumeComponent`, because the Object Info node
outputs an object instance. The `VolumeComponent` will be necessary for upcoming nodes,
which will generate volumes on the fly.
Viewport selection does not work correctly with `VolumeComponent`s currently. I don't
know why that is. That can be figured out a bit later, once we can actually create
new volumes in geometry nodes.
Ref T84604.
Differential Revision: https://developer.blender.org/D10147
Diffstat (limited to 'source/blender/depsgraph')
-rw-r--r-- | source/blender/depsgraph/intern/depsgraph_query_iter.cc | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/source/blender/depsgraph/intern/depsgraph_query_iter.cc b/source/blender/depsgraph/intern/depsgraph_query_iter.cc index e472d82f2ee..c9780b9b129 100644 --- a/source/blender/depsgraph/intern/depsgraph_query_iter.cc +++ b/source/blender/depsgraph/intern/depsgraph_query_iter.cc @@ -193,6 +193,30 @@ bool deg_iterator_components_step(BLI_Iterator *iter) } } + /* The volume component. */ + if (data->geometry_component_id == 2) { + data->geometry_component_id++; + + /* Don't use a temporary object for this component, when the owner is a volume object. */ + if (data->geometry_component_owner->type == OB_VOLUME) { + iter->current = data->geometry_component_owner; + return true; + } + + const VolumeComponent *component = geometry_set->get_component_for_read<VolumeComponent>(); + if (component != nullptr) { + const Volume *volume = component->get_for_read(); + + Object *temp_object = &data->temp_geometry_component_object; + *temp_object = *data->geometry_component_owner; + temp_object->type = OB_VOLUME; + temp_object->data = (void *)volume; + temp_object->runtime.select_id = data->geometry_component_owner->runtime.select_id; + iter->current = temp_object; + return true; + } + } + data->geometry_component_owner = nullptr; return false; } |