Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/nodes/intern/node_geometry_exec.cc')
-rw-r--r--source/blender/nodes/intern/node_geometry_exec.cc37
1 files changed, 36 insertions, 1 deletions
diff --git a/source/blender/nodes/intern/node_geometry_exec.cc b/source/blender/nodes/intern/node_geometry_exec.cc
index 7f4f75c294f..ebbb6f60b78 100644
--- a/source/blender/nodes/intern/node_geometry_exec.cc
+++ b/source/blender/nodes/intern/node_geometry_exec.cc
@@ -14,6 +14,12 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
+#include "DNA_modifier_types.h"
+
+#include "BKE_node_ui_storage.hh"
+
+#include "DEG_depsgraph_query.h"
+
#include "NOD_derived_node_tree.hh"
#include "NOD_geometry_exec.hh"
#include "NOD_type_callbacks.hh"
@@ -22,6 +28,23 @@
namespace blender::nodes {
+void GeoNodeExecParams::error_message_add(const NodeWarningType type, std::string message) const
+{
+ bNodeTree *btree_cow = node_.node_ref().tree().btree();
+ BLI_assert(btree_cow != nullptr);
+ if (btree_cow == nullptr) {
+ return;
+ }
+ bNodeTree *btree_original = (bNodeTree *)DEG_get_original_id((ID *)btree_cow);
+
+ BKE_nodetree_ui_storage_ensure(*btree_original);
+
+ const NodeTreeEvaluationContext context(*self_object_, *modifier_);
+
+ BKE_nodetree_error_message_add(
+ *btree_original, context, *node_.bnode(), type, std::move(message));
+}
+
const bNodeSocket *GeoNodeExecParams::find_available_socket(const StringRef name) const
{
for (const DSocket *socket : node_.inputs()) {
@@ -47,7 +70,19 @@ ReadAttributePtr GeoNodeExecParams::get_input_attribute(const StringRef name,
if (found_socket->type == SOCK_STRING) {
const std::string name = this->get_input<std::string>(found_socket->identifier);
- return component.attribute_get_for_read(name, domain, type, default_value);
+ /* Try getting the attribute without the default value. */
+ ReadAttributePtr attribute = component.attribute_try_get_for_read(name, domain, type);
+ if (attribute) {
+ return attribute;
+ }
+
+ /* If the attribute doesn't exist, use the default value and output an error message
+ * (except when the field is empty, to avoid spamming error messages). */
+ if (!name.empty()) {
+ this->error_message_add(NodeWarningType::Error,
+ std::string("No attribute with name '") + name + "'.");
+ }
+ return component.attribute_get_constant_for_read(domain, type, default_value);
}
if (found_socket->type == SOCK_FLOAT) {
const float value = this->get_input<float>(found_socket->identifier);