Fix simulation
This commit is contained in:
parent
50a2c77c4e
commit
468f43c7a6
|
@ -1124,12 +1124,12 @@ static void node_init(const bContext *C, bNodeTree *ntree, bNode *node)
|
|||
BLI_strncpy(node->name, DATA_(ntype->ui_name), NODE_MAXSTR);
|
||||
nodeUniqueName(ntree, node);
|
||||
|
||||
node_add_sockets_from_type(ntree, node, ntype);
|
||||
|
||||
if (ntype->initfunc != nullptr) {
|
||||
ntype->initfunc(ntree, node);
|
||||
}
|
||||
|
||||
node_add_sockets_from_type(ntree, node, ntype);
|
||||
|
||||
if (ntree->typeinfo && ntree->typeinfo->node_add_init) {
|
||||
ntree->typeinfo->node_add_init(ntree, node);
|
||||
}
|
||||
|
|
|
@ -1594,7 +1594,7 @@ typedef struct NodeGeometrySimulationOutput {
|
|||
int state_items_num;
|
||||
|
||||
int8_t use_persistent_cache;
|
||||
int _pad[3];
|
||||
char _pad[3];
|
||||
} NodeGeometrySimulationOutput;
|
||||
|
||||
typedef struct NodeGeometryDistributePointsInVolume {
|
||||
|
|
|
@ -527,7 +527,7 @@ inline NodeDeclarationBuilder::NodeDeclarationBuilder(NodeDeclaration &declarati
|
|||
|
||||
inline NodeDeclarationBuilder::NodeDeclarationBuilder(const bNode &node,
|
||||
NodeDeclaration &declaration)
|
||||
: node_(&node), declaration_(declaration)
|
||||
: declaration_(declaration), node_(&node)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,8 @@ static void node_declare(NodeDeclarationBuilder &b)
|
|||
const bNode &node = b.node();
|
||||
const NodeGeometrySimulationInput &storage = node_storage(node);
|
||||
const int32_t sim_output_node_id = storage.output_node_id;
|
||||
/* TODO: Add node tree and ndoe as arguments to new dynamic declaration function. */
|
||||
node.owner_tree().ensure_topology_cache();
|
||||
const bNode *sim_output_node = node.owner_tree().node_by_id(sim_output_node_id);
|
||||
if (!sim_output_node) {
|
||||
return;
|
||||
|
|
|
@ -58,28 +58,35 @@ static void node_declare(NodeDeclarationBuilder &b)
|
|||
|
||||
static void node_init(bNodeTree * /*tree*/, bNode *node)
|
||||
{
|
||||
NodeGeometrySimulationOutput *data = MEM_cnew<NodeGeometrySimulationOutput>(__func__);
|
||||
data->state_items = MEM_cnew_array<SimulationStateItem>(1, __func__);
|
||||
data->state_items[0].name = BLI_strdup(DATA_("Geometry"));
|
||||
data->state_items[0].data_type = SOCK_GEOMETRY;
|
||||
data->state_items_num = 1;
|
||||
data->use_persistent_cache = false;
|
||||
node->storage = data;
|
||||
NodeGeometrySimulationOutput *storage = MEM_cnew<NodeGeometrySimulationOutput>(__func__);
|
||||
storage->state_items = MEM_cnew_array<SimulationStateItem>(1, __func__);
|
||||
storage->state_items[0].name = BLI_strdup(DATA_("Geometry"));
|
||||
storage->state_items[0].data_type = SOCK_GEOMETRY;
|
||||
storage->state_items_num = 1;
|
||||
storage->use_persistent_cache = false;
|
||||
node->storage = storage;
|
||||
}
|
||||
|
||||
static void node_free_storage(bNode *node)
|
||||
{
|
||||
NodeGeometrySimulationOutput &storage = node_storage(*node);
|
||||
for (SimulationStateItem &item : MutableSpan(storage.state_items, storage.state_items_num)) {
|
||||
MEM_SAFE_FREE(item.name);
|
||||
}
|
||||
MEM_SAFE_FREE(storage.state_items);
|
||||
}
|
||||
|
||||
void node_copy_storage(bNodeTree * /*dest_ntree*/, bNode *dst_node, const bNode *src_node)
|
||||
static void node_copy_storage(bNodeTree * /*dest_ntree*/, bNode *dst_node, const bNode *src_node)
|
||||
{
|
||||
const NodeGeometrySimulationOutput &src = node_storage(*src_node);
|
||||
NodeGeometrySimulationOutput &dst = node_storage(*dst_node);
|
||||
MEM_SAFE_FREE(dst.state_items);
|
||||
dst.state_items = MEM_cnew_array<SimulationStateItem>(src.state_items_num, __func__);
|
||||
dst.state_items_num = src.state_items_num;
|
||||
NodeGeometrySimulationOutput *dst = MEM_cnew<NodeGeometrySimulationOutput>(__func__);
|
||||
MEM_SAFE_FREE(dst->state_items);
|
||||
dst->state_items = MEM_cnew_array<SimulationStateItem>(src.state_items_num, __func__);
|
||||
dst->state_items_num = src.state_items_num;
|
||||
for (const int i : IndexRange(dst->state_items_num)) {
|
||||
dst->state_items[i].name = static_cast<char *>(MEM_dupallocN(src.state_items[i].name));
|
||||
}
|
||||
dst_node->storage = dst;
|
||||
}
|
||||
|
||||
static void node_geo_exec(GeoNodeExecParams params)
|
||||
|
|
Loading…
Reference in New Issue