Geometry Nodes: add simulation support #104924
|
@ -684,7 +684,6 @@ classes = (
|
|||
NODE_MT_geometry_node_mesh_topology,
|
||||
NODE_MT_category_GEO_POINT,
|
||||
NODE_MT_category_simulation,
|
||||
NODE_MT_category_GEO_TEXT,
|
||||
NODE_MT_category_GEO_VOLUME,
|
||||
NODE_MT_geometry_node_GEO_MATERIAL,
|
||||
NODE_MT_category_GEO_TEXTURE,
|
||||
|
|
|
@ -121,7 +121,7 @@ struct TreeDrawContext {
|
|||
*/
|
||||
bool used_by_realtime_compositor = false;
|
||||
|
||||
Vector<blender::ed::space_node::SubContext> sub_contexts;
|
||||
blender::Vector<blender::ed::space_node::SubContext> sub_contexts;
|
||||
};
|
||||
|
||||
float ED_node_grid_size()
|
||||
|
@ -3126,13 +3126,12 @@ static void node_draw_sub_context_frames(TreeDrawContext &tree_draw_ctx,
|
|||
}
|
||||
|
||||
if (snode.runtime->linkdrag) {
|
||||
for (const bNodeLink *link : snode.runtime->linkdrag->links) {
|
||||
if (link->fromnode == nullptr) {
|
||||
for (const bNodeLink &link : snode.runtime->linkdrag->links) {
|
||||
if (link.fromnode == nullptr) {
|
||||
continue;
|
||||
}
|
||||
if (nodes_in_context.contains(link->fromnode) &&
|
||||
!context_outputs.contains(link->fromnode)) {
|
||||
const float2 pos = node_link_bezier_points_dragged(snode, *link)[3];
|
||||
if (nodes_in_context.contains(link.fromnode) && !context_outputs.contains(link.fromnode)) {
|
||||
const float2 pos = node_link_bezier_points_dragged(snode, link)[3];
|
||||
rctf rect;
|
||||
BLI_rctf_init_pt_radius(&rect, pos, padding);
|
||||
add_rect_corner_positions(possible_boundary_positions, rect);
|
||||
|
@ -3164,7 +3163,8 @@ static void node_draw_sub_context_frames(TreeDrawContext &tree_draw_ctx,
|
|||
IndexRange(1),
|
||||
VArray<float>::ForSingle(UI_UNIT_X / 2, num_convex_positions),
|
||||
VArray<int>::ForSingle(5, num_convex_positions),
|
||||
true);
|
||||
true,
|
||||
{});
|
||||
const Span<float3> boundary_positions = fillet_curve.positions();
|
||||
|
||||
const uint pos = GPU_vertformat_attr_add(
|
||||
|
|
|
@ -1413,6 +1413,19 @@ static void modifyGeometry(ModifierData *md,
|
|||
}
|
||||
}
|
||||
|
||||
static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh)
|
||||
{
|
||||
GeometrySet geometry_set = GeometrySet::create_with_mesh(mesh, GeometryOwnershipType::Editable);
|
||||
|
||||
modifyGeometry(md, ctx, geometry_set);
|
||||
|
||||
Mesh *new_mesh = geometry_set.get_component_for_write<MeshComponent>().release();
|
||||
if (new_mesh == nullptr) {
|
||||
return BKE_mesh_new_nomain(0, 0, 0, 0, 0);
|
||||
}
|
||||
return new_mesh;
|
||||
}
|
||||
|
||||
static void modifyGeometrySet(ModifierData *md,
|
||||
const ModifierEvalContext *ctx,
|
||||
GeometrySet *geometry_set)
|
||||
|
|
|
@ -1331,6 +1331,11 @@ struct GeometryNodesLazyFunctionGraphBuilder {
|
|||
this->handle_viewer_node(*bnode);
|
||||
break;
|
||||
}
|
||||
case GEO_NODE_SIMULATION_OUTPUT: {
|
||||
const lf::FunctionNode &lf_node = this->handle_geometry_node(*bnode);
|
||||
mapping_->sim_output_node_map.add_new(bnode, &lf_node);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
if (node_type->geometry_node_execute) {
|
||||
this->handle_geometry_node(*bnode);
|
||||
|
@ -1479,13 +1484,13 @@ struct GeometryNodesLazyFunctionGraphBuilder {
|
|||
lf_graph_info_->functions.append(std::move(lazy_function));
|
||||
}
|
||||
|
||||
void handle_geometry_node(const bNode &bnode)
|
||||
lf::FunctionNode &handle_geometry_node(const bNode &bnode)
|
||||
{
|
||||
Vector<const bNodeSocket *> used_inputs;
|
||||
Vector<const bNodeSocket *> used_outputs;
|
||||
auto lazy_function = std::make_unique<LazyFunctionForGeometryNode>(
|
||||
bnode, used_inputs, used_outputs);
|
||||
lf::Node &lf_node = lf_graph_->add_function(*lazy_function);
|
||||
lf::FunctionNode &lf_node = lf_graph_->add_function(*lazy_function);
|
||||
|
||||
for (const int i : used_inputs.index_range()) {
|
||||
const bNodeSocket &bsocket = *used_inputs[i];
|
||||
|
@ -1527,6 +1532,8 @@ struct GeometryNodesLazyFunctionGraphBuilder {
|
|||
}
|
||||
|
||||
lf_graph_info_->functions.append(std::move(lazy_function));
|
||||
|
||||
return lf_node;
|
||||
}
|
||||
|
||||
void handle_multi_function_node(const bNode &bnode, const NodeMultiFunctions::Item &fn_item)
|
||||
|
|
Loading…
Reference in New Issue