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:
authorJacques Lucke <mail@jlucke.com>2020-01-03 15:17:37 +0300
committerJacques Lucke <mail@jlucke.com>2020-01-03 15:17:37 +0300
commit9c2e7a4e1cd4deb8ead7ed249ed8ad0f26c07f68 (patch)
tree39299b8e58effa6157dc8f025d29e21ff3bf713c /source/blender/functions/FN_node_tree_multi_function_network.h
parente083ab2d0233547c5f894158f5c0b359bbed1fcc (diff)
only map dummy sockets when function network has been created
Diffstat (limited to 'source/blender/functions/FN_node_tree_multi_function_network.h')
-rw-r--r--source/blender/functions/FN_node_tree_multi_function_network.h34
1 files changed, 15 insertions, 19 deletions
diff --git a/source/blender/functions/FN_node_tree_multi_function_network.h b/source/blender/functions/FN_node_tree_multi_function_network.h
index 14c5035a501..206d285384f 100644
--- a/source/blender/functions/FN_node_tree_multi_function_network.h
+++ b/source/blender/functions/FN_node_tree_multi_function_network.h
@@ -4,11 +4,13 @@
#include "FN_node_tree.h"
#include "BLI_multi_map.h"
+#include "BLI_index_map.h"
#include "FN_multi_function_network.h"
namespace FN {
+using BLI::IndexMap;
using BLI::MultiMap;
#define IdMultiMap_UNMAPPED UINT_MAX
@@ -75,60 +77,54 @@ class IdMultiMap {
class InlinedTreeMFSocketMap {
private:
- /* An input fsocket can be mapped to multiple sockets.
- * An output fsocket can be mapped to at most one socket.
- */
const FunctionNodeTree *m_function_tree;
const MFNetwork *m_network;
- IdMultiMap m_socket_by_fsocket;
- Array<uint> m_fsocket_by_socket;
+
+ IndexMap<const MFSocket *> m_dummy_socket_by_fsocket_id;
+ IndexMap<const FSocket *> m_fsocket_by_dummy_socket_id;
public:
InlinedTreeMFSocketMap(const FunctionNodeTree &function_tree,
const MFNetwork &network,
- IdMultiMap socket_by_fsocket,
- Array<uint> fsocket_by_socket)
+ IndexMap<const MFSocket *> dummy_socket_by_fsocket_id,
+ IndexMap<const FSocket *> fsocket_by_dummy_socket_id)
: m_function_tree(&function_tree),
m_network(&network),
- m_socket_by_fsocket(std::move(socket_by_fsocket)),
- m_fsocket_by_socket(std::move(fsocket_by_socket))
+ m_dummy_socket_by_fsocket_id(std::move(dummy_socket_by_fsocket_id)),
+ m_fsocket_by_dummy_socket_id(std::move(fsocket_by_dummy_socket_id))
{
}
bool is_mapped(const FSocket &fsocket) const
{
- return m_socket_by_fsocket.contains(fsocket.id());
+ return m_dummy_socket_by_fsocket_id.contains(fsocket.id());
}
bool is_mapped(const MFSocket &socket) const
{
- return m_fsocket_by_socket[socket.id()] != IdMultiMap_UNMAPPED;
+ return m_fsocket_by_dummy_socket_id.contains(socket.id());
}
const MFInputSocket &lookup_singly_mapped_input_socket(const FInputSocket &fsocket) const
{
- uint mapped_id = m_socket_by_fsocket.lookup_single(fsocket.id());
- return m_network->socket_by_id(mapped_id).as_input();
+ return m_dummy_socket_by_fsocket_id.lookup(fsocket.id())->as_input();
}
const MFOutputSocket &lookup_socket(const FOutputSocket &fsocket) const
{
- uint mapped_id = m_socket_by_fsocket.lookup_single(fsocket.id());
- return m_network->socket_by_id(mapped_id).as_output();
+ return m_dummy_socket_by_fsocket_id.lookup(fsocket.id())->as_output();
}
const FInputSocket &lookup_fsocket(const MFInputSocket &socket) const
{
BLI_assert(socket.node().is_dummy());
- uint mapped_id = m_fsocket_by_socket[socket.id()];
- return m_function_tree->socket_by_id(mapped_id).as_input();
+ return m_fsocket_by_dummy_socket_id.lookup(socket.id())->as_input();
}
const FOutputSocket &lookup_fsocket(const MFOutputSocket &socket) const
{
BLI_assert(socket.node().is_dummy());
- uint mapped_id = m_fsocket_by_socket[socket.id()];
- return m_function_tree->socket_by_id(mapped_id).as_output();
+ return m_fsocket_by_dummy_socket_id.lookup(socket.id())->as_output();
}
};