Changeset View
Changeset View
Standalone View
Standalone View
source/blender/depsgraph/intern/builder/deg_builder_relations_impl.h
| /* SPDX-License-Identifier: GPL-2.0-or-later | /* SPDX-License-Identifier: GPL-2.0-or-later | ||||
| * Copyright 2013 Blender Foundation. All rights reserved. */ | * Copyright 2013 Blender Foundation. All rights reserved. */ | ||||
| /** \file | /** \file | ||||
| * \ingroup depsgraph | * \ingroup depsgraph | ||||
| */ | */ | ||||
| #pragma once | #pragma once | ||||
| #include "intern/node/deg_node_id.h" | #include "intern/node/deg_node_id.h" | ||||
| #include <iostream> | |||||
| #include "DNA_ID.h" | #include "DNA_ID.h" | ||||
| #include "DNA_object_types.h" | #include "DNA_object_types.h" | ||||
| #include "DNA_rigidbody_types.h" | #include "DNA_rigidbody_types.h" | ||||
| namespace blender { | namespace blender { | ||||
| namespace deg { | namespace deg { | ||||
| template<typename KeyType> | template<typename KeyType> | ||||
| OperationNode *DepsgraphRelationBuilder::find_operation_node(const KeyType &key) | OperationNode *DepsgraphRelationBuilder::find_operation_node(const KeyType &key) | ||||
| { | { | ||||
| Node *node = get_node(key); | Node *node = get_node(key); | ||||
| return node != nullptr ? node->get_exit_operation() : nullptr; | return node != nullptr ? node->get_exit_operation() : nullptr; | ||||
| } | } | ||||
| template<typename KeyFrom, typename KeyTo> | template<typename KeyFrom, typename KeyTo> | ||||
| Relation *DepsgraphRelationBuilder::add_relation(const KeyFrom &key_from, | Relation *DepsgraphRelationBuilder::add_relation(const KeyFrom &key_from, | ||||
| const KeyTo &key_to, | const KeyTo &key_to, | ||||
| const char *description, | const char *description, | ||||
| int flags) | int flags) | ||||
| { | { | ||||
| Node *node_from = get_node(key_from); | Node *node_from = get_node(key_from); | ||||
| Node *node_to = get_node(key_to); | Node *node_to = get_node(key_to); | ||||
| OperationNode *op_from = node_from ? node_from->get_exit_operation() : nullptr; | OperationNode *op_from = node_from ? node_from->get_exit_operation() : nullptr; | ||||
| OperationNode *op_to = node_to ? node_to->get_entry_operation() : nullptr; | OperationNode *op_to = node_to ? node_to->get_entry_operation() : nullptr; | ||||
| if (op_from && op_to) { | if (op_from && op_to) { | ||||
| return add_operation_relation(op_from, op_to, description, flags); | return add_operation_relation(op_from, op_to, description, flags); | ||||
| } | } | ||||
| /* TODO(sergey): Report error in the interface. */ | |||||
| std::cerr << "--------------------------------------------------------------------\n"; | |||||
| std::cerr << "Failed to add relation \"" << description << "\"\n"; | |||||
| if (!op_from) { | if (!op_from) { | ||||
| /* XXX TODO: handle as error or report if needed. */ | std::cerr << "Could not find op_from: " << key_from.identifier() << "\n"; | ||||
| fprintf(stderr, | |||||
| "add_relation(%s) - Could not find op_from (%s)\n", | |||||
| description, | |||||
| key_from.identifier().c_str()); | |||||
| } | |||||
| else { | |||||
| fprintf(stderr, | |||||
| "add_relation(%s) - Failed, but op_from (%s) was ok\n", | |||||
| description, | |||||
| key_from.identifier().c_str()); | |||||
| } | } | ||||
| if (!op_to) { | if (!op_to) { | ||||
| /* XXX TODO: handle as error or report if needed. */ | std::cerr << "Could not find op_to: " << key_to.identifier() << "\n"; | ||||
| fprintf(stderr, | |||||
| "add_relation(%s) - Could not find op_to (%s)\n", | |||||
| description, | |||||
| key_to.identifier().c_str()); | |||||
| } | } | ||||
| else { | |||||
| fprintf(stderr, | if (!stack_.is_empty()) { | ||||
| "add_relation(%s) - Failed, but op_to (%s) was ok\n", | std::cerr << "\nTrace:\n\n"; | ||||
| description, | stack_.print_backtrace(std::cerr); | ||||
| key_to.identifier().c_str()); | std::cerr << "\n"; | ||||
| } | } | ||||
| return nullptr; | return nullptr; | ||||
| } | } | ||||
| template<typename KeyTo> | template<typename KeyTo> | ||||
| Relation *DepsgraphRelationBuilder::add_relation(const TimeSourceKey &key_from, | Relation *DepsgraphRelationBuilder::add_relation(const TimeSourceKey &key_from, | ||||
| const KeyTo &key_to, | const KeyTo &key_to, | ||||
| ▲ Show 20 Lines • Show All 146 Lines • Show Last 20 Lines | |||||