Geometry Nodes: add simulation support #104924
|
@ -187,7 +187,7 @@ void NODE_OT_clipboard_copy(wmOperatorType *ot)
|
|||
static void remap_pairing(bNodeTree &dst_tree, const Map<const bNode *, bNode *> &node_map)
|
||||
{
|
||||
/* We don't have the old tree for looking up output nodes by ID,
|
||||
* so have to build a map first to find copied output nodes in the new tree. */
|
||||
* so we have to build a map first to find copied output nodes in the new tree. */
|
||||
Map<int32_t, bNode *> dst_output_node_map;
|
||||
for (const auto &item : node_map.items()) {
|
||||
if (item.key->type == GEO_NODE_SIMULATION_OUTPUT) {
|
||||
|
@ -197,15 +197,14 @@ static void remap_pairing(bNodeTree &dst_tree, const Map<const bNode *, bNode *>
|
|||
|
||||
for (bNode *dst_node : node_map.values()) {
|
||||
if (dst_node->type == GEO_NODE_SIMULATION_INPUT) {
|
||||
NodeGeometrySimulationInput *data = static_cast<NodeGeometrySimulationInput *>(
|
||||
NodeGeometrySimulationInput &data = *static_cast<NodeGeometrySimulationInput *>(
|
||||
dst_node->storage);
|
||||
const bNode *dst_output_node = dst_output_node_map.lookup_default(data->output_node_id,
|
||||
nullptr);
|
||||
if (dst_output_node != nullptr) {
|
||||
data->output_node_id = dst_output_node->identifier;
|
||||
if (const bNode *output_node = dst_output_node_map.lookup_default(data.output_node_id,
|
||||
nullptr)) {
|
||||
data.output_node_id = output_node->identifier;
|
||||
}
|
||||
else {
|
||||
data->output_node_id = 0;
|
||||
data.output_node_id = 0;
|
||||
blender::nodes::update_node_declaration_and_sockets(dst_tree, *dst_node);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1252,7 +1252,7 @@ static void node_duplicate_reparent_recursive(bNodeTree *ntree,
|
|||
static void remap_pairing(bNodeTree &dst_tree, const Map<bNode *, bNode *> &node_map)
|
||||
{
|
||||
/* We don't have the old tree for looking up output nodes by ID,
|
||||
* so have to build a map first to find copied output nodes in the new tree. */
|
||||
* so we have to build a map first to find copied output nodes in the new tree. */
|
||||
Map<uint32_t, bNode *> dst_output_node_map;
|
||||
for (const auto &item : node_map.items()) {
|
||||
if (item.key->type == GEO_NODE_SIMULATION_OUTPUT) {
|
||||
|
@ -1264,10 +1264,9 @@ static void remap_pairing(bNodeTree &dst_tree, const Map<bNode *, bNode *> &node
|
|||
if (dst_node->type == GEO_NODE_SIMULATION_INPUT) {
|
||||
NodeGeometrySimulationInput *data = static_cast<NodeGeometrySimulationInput *>(
|
||||
dst_node->storage);
|
||||
const bNode *dst_output_node = dst_output_node_map.lookup_default(data->output_node_id,
|
||||
nullptr);
|
||||
if (dst_output_node != nullptr) {
|
||||
data->output_node_id = dst_output_node->identifier;
|
||||
if (const bNode *output_node = dst_output_node_map.lookup_default(data->output_node_id,
|
||||
nullptr)) {
|
||||
data->output_node_id = output_node->identifier;
|
||||
}
|
||||
else {
|
||||
data->output_node_id = 0;
|
||||
|
|
|
@ -440,20 +440,18 @@ static void remap_pairing(bNodeTree &dst_tree, const Set<bNode *> &nodes)
|
|||
{
|
||||
for (bNode *dst_node : nodes) {
|
||||
if (dst_node->type == GEO_NODE_SIMULATION_INPUT) {
|
||||
NodeGeometrySimulationInput *data = static_cast<NodeGeometrySimulationInput *>(
|
||||
NodeGeometrySimulationInput &data = *static_cast<NodeGeometrySimulationInput *>(
|
||||
dst_node->storage);
|
||||
/* XXX Technically this is not correct because the output_node_id is only valid
|
||||
* in the original node group tree and we'd have map old IDs to new nodes first.
|
||||
* The ungroup operator does not build a node map, it just expects node IDs to
|
||||
* remain unchanged, which is probably true most of the time because they are
|
||||
* mostly random numbers out of the uint32_t range.
|
||||
*/
|
||||
const bNode *dst_output_node = dst_tree.node_by_id(data->output_node_id);
|
||||
if (dst_output_node != nullptr) {
|
||||
data->output_node_id = dst_output_node->identifier;
|
||||
* mostly random numbers out of the uint32_t range. */
|
||||
if (const bNode *output_node = dst_tree.node_by_id(data.output_node_id)) {
|
||||
data.output_node_id = output_node->identifier;
|
||||
}
|
||||
else {
|
||||
data->output_node_id = 0;
|
||||
data.output_node_id = 0;
|
||||
blender::nodes::update_node_declaration_and_sockets(dst_tree, *dst_node);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue