Changeset View
Changeset View
Standalone View
Standalone View
source/blender/modifiers/intern/MOD_nodes.cc
| Show First 20 Lines • Show All 76 Lines • ▼ Show 20 Lines | |||||
| #include "NOD_type_callbacks.hh" | #include "NOD_type_callbacks.hh" | ||||
| using blender::float3; | using blender::float3; | ||||
| using blender::IndexRange; | using blender::IndexRange; | ||||
| using blender::Map; | using blender::Map; | ||||
| using blender::Set; | using blender::Set; | ||||
| using blender::Span; | using blender::Span; | ||||
| using blender::StringRef; | using blender::StringRef; | ||||
| using blender::StringRefNull; | |||||
| using blender::Vector; | using blender::Vector; | ||||
| using blender::bke::PersistentCollectionHandle; | using blender::bke::PersistentCollectionHandle; | ||||
| using blender::bke::PersistentDataHandleMap; | using blender::bke::PersistentDataHandleMap; | ||||
| using blender::bke::PersistentObjectHandle; | using blender::bke::PersistentObjectHandle; | ||||
| using blender::fn::GMutablePointer; | using blender::fn::GMutablePointer; | ||||
| using blender::fn::GValueMap; | using blender::fn::GValueMap; | ||||
| using blender::nodes::GeoNodeExecParams; | using blender::nodes::GeoNodeExecParams; | ||||
| using namespace blender::nodes::derived_node_tree_types; | using namespace blender::nodes::derived_node_tree_types; | ||||
| ▲ Show 20 Lines • Show All 290 Lines • ▼ Show 20 Lines | for (const DOutputSocket *output_socket : node.outputs()) { | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| void execute_node(const DNode &node, GeoNodeExecParams params) | void execute_node(const DNode &node, GeoNodeExecParams params) | ||||
| { | { | ||||
| const bNode &bnode = params.node(); | const bNode &bnode = params.node(); | ||||
| this->store_ui_hints(node, params); | |||||
| /* Use the geometry-node-execute callback if it exists. */ | /* Use the geometry-node-execute callback if it exists. */ | ||||
| if (bnode.typeinfo->geometry_node_execute != nullptr) { | if (bnode.typeinfo->geometry_node_execute != nullptr) { | ||||
| bnode.typeinfo->geometry_node_execute(params); | bnode.typeinfo->geometry_node_execute(params); | ||||
| return; | return; | ||||
| } | } | ||||
| /* Use the multi-function implementation if it exists. */ | /* Use the multi-function implementation if it exists. */ | ||||
| const MultiFunction *multi_function = mf_by_node_.lookup_default(&node, nullptr); | const MultiFunction *multi_function = mf_by_node_.lookup_default(&node, nullptr); | ||||
| if (multi_function != nullptr) { | if (multi_function != nullptr) { | ||||
| this->execute_multi_function_node(node, params, *multi_function); | this->execute_multi_function_node(node, params, *multi_function); | ||||
| return; | return; | ||||
| } | } | ||||
| /* Just output default values if no implementation exists. */ | /* Just output default values if no implementation exists. */ | ||||
| this->execute_unknown_node(node, params); | this->execute_unknown_node(node, params); | ||||
| } | } | ||||
| void store_ui_hints(const DNode &node, GeoNodeExecParams params) const | |||||
| { | |||||
| for (const DInputSocket *dsocket : node.inputs()) { | |||||
| if (!dsocket->is_available()) { | |||||
| continue; | |||||
| } | |||||
| if (dsocket->bsocket()->type != SOCK_GEOMETRY) { | |||||
| continue; | |||||
| } | |||||
| bNodeTree *btree_cow = node.node_ref().tree().btree(); | |||||
| bNodeTree *btree_original = (bNodeTree *)DEG_get_original_id((ID *)btree_cow); | |||||
| const NodeTreeEvaluationContext context(*self_object_, *modifier_); | |||||
| const GeometrySet &geometry_set = params.get_input<GeometrySet>(dsocket->identifier()); | |||||
| const Vector<const GeometryComponent *> components = geometry_set.get_components_for_read(); | |||||
| for (const GeometryComponent *component : components) { | |||||
| component->attribute_foreach([&](StringRefNull attribute_name, | |||||
| const AttributeMetaData &UNUSED(meta_data)) { | |||||
| BKE_nodetree_attribute_hint_add(*btree_original, context, *node.bnode(), attribute_name); | |||||
| return true; | |||||
| }); | |||||
| } | |||||
| } | |||||
| } | |||||
| void execute_multi_function_node(const DNode &node, | void execute_multi_function_node(const DNode &node, | ||||
| GeoNodeExecParams params, | GeoNodeExecParams params, | ||||
| const MultiFunction &fn) | const MultiFunction &fn) | ||||
| { | { | ||||
| MFContextBuilder fn_context; | MFContextBuilder fn_context; | ||||
| MFParamsBuilder fn_params{fn, 1}; | MFParamsBuilder fn_params{fn, 1}; | ||||
| Vector<GMutablePointer> input_data; | Vector<GMutablePointer> input_data; | ||||
| for (const DInputSocket *dsocket : node.inputs()) { | for (const DInputSocket *dsocket : node.inputs()) { | ||||
| ▲ Show 20 Lines • Show All 911 Lines • Show Last 20 Lines | |||||