1
1

Compare commits

...

12 Commits

49 changed files with 912 additions and 400 deletions

View File

@@ -31,6 +31,7 @@ _modules = [
"console",
"constraint",
"file",
"geometry_nodes",
"image",
"mesh",
"node",
@@ -42,7 +43,6 @@ _modules = [
"rigidbody",
"screen_play_rendered_anim",
"sequencer",
"simulation",
"userpref",
"uvcalc_follow_active",
"uvcalc_lightmap",

View File

@@ -19,23 +19,30 @@
import bpy
class NewSimulation(bpy.types.Operator):
"""Create a new simulation data block and edit it in the opened simulation editor"""
class NewGeometryNodeTree(bpy.types.Operator):
"""Create a new geometry node tree"""
bl_idname = "simulation.new"
bl_label = "New Simulation"
bl_idname = "node.new_geometry_node_tree"
bl_label = "New Geometry Node Tree"
bl_options = {'REGISTER', 'UNDO'}
@classmethod
def poll(cls, context):
return context.area.type == 'NODE_EDITOR' and context.space_data.tree_type == 'SimulationNodeTree'
return context.area.type == 'NODE_EDITOR' and context.space_data.tree_type == 'GeometryNodeTree'
def execute(self, context):
simulation = bpy.data.simulations.new("Simulation")
context.space_data.simulation = simulation
group = bpy.data.node_groups.new("Node Tree", 'GeometryNodeTree')
group.inputs.new('NodeSocketGeometry', "Geometry")
group.outputs.new('NodeSocketGeometry', "Geometry")
input_node = group.nodes.new('NodeGroupInput')
output_node = group.nodes.new('NodeGroupOutput')
input_node.location.x = -200 - input_node.width
output_node.location.x = 200
context.space_data.node_tree = group
return {'FINISHED'}
classes = (
NewSimulation,
NewGeometryNodeTree,
)

View File

@@ -151,13 +151,10 @@ class NODE_HT_header(Header):
if snode_id:
layout.prop(snode_id, "use_nodes")
elif snode.tree_type == 'SimulationNodeTree':
row = layout.row(align=True)
row.prop(snode, "simulation", text="")
row.operator("simulation.new", text="", icon='ADD')
simulation = snode.simulation
if simulation:
row.prop(snode.simulation, "use_fake_user", text="")
elif snode.tree_type == 'GeometryNodeTree':
NODE_MT_editor_menus.draw_collapsible(context, layout)
layout.separator_spacer()
layout.template_ID(snode, "node_tree", new="node.new_geometry_node_tree")
else:
# Custom node tree is edited as independent ID block

View File

@@ -58,11 +58,11 @@ class TextureNodeCategory(SortedNodeCategory):
context.space_data.tree_type == 'TextureNodeTree')
class SimulationNodeCategory(SortedNodeCategory):
class GeometryNodeCategory(SortedNodeCategory):
@classmethod
def poll(cls, context):
return (context.space_data.type == 'NODE_EDITOR' and
context.space_data.tree_type == 'SimulationNodeTree')
context.space_data.tree_type == 'GeometryNodeTree')
# menu entry for node group tools
@@ -77,11 +77,11 @@ node_tree_group_type = {
'CompositorNodeTree': 'CompositorNodeGroup',
'ShaderNodeTree': 'ShaderNodeGroup',
'TextureNodeTree': 'TextureNodeGroup',
'SimulationNodeTree': 'SimulationNodeGroup',
'GeometryNodeTree': 'GeometryNodeGroup',
}
# generic node group items generator for shader, compositor, simulation and texture node groups
# generic node group items generator for shader, compositor, geometry and texture node groups
def node_group_items(context):
if context is None:
return
@@ -483,10 +483,13 @@ def not_implemented_node(idname):
return NodeItem(idname, label=label)
simulation_node_categories = [
# Simulation Nodes
SimulationNodeCategory("SIM_GROUP", "Group", items=node_group_items),
SimulationNodeCategory("SIM_LAYOUT", "Layout", items=[
geometry_node_categories = [
# Geometry Nodes
GeometryNodeCategory("GEO_MESH", "Mesh", items=[
NodeItem("GeometryNodeTriangulate"),
]),
GeometryNodeCategory("GEO_GROUP", "Group", items=node_group_items),
GeometryNodeCategory("GEO_LAYOUT", "Layout", items=[
NodeItem("NodeFrame"),
NodeItem("NodeReroute"),
]),
@@ -497,14 +500,14 @@ def register():
nodeitems_utils.register_node_categories('SHADER', shader_node_categories)
nodeitems_utils.register_node_categories('COMPOSITING', compositor_node_categories)
nodeitems_utils.register_node_categories('TEXTURE', texture_node_categories)
nodeitems_utils.register_node_categories('SIMULATION', simulation_node_categories)
nodeitems_utils.register_node_categories('GEOMETRY', geometry_node_categories)
def unregister():
nodeitems_utils.unregister_node_categories('SHADER')
nodeitems_utils.unregister_node_categories('COMPOSITING')
nodeitems_utils.unregister_node_categories('TEXTURE')
nodeitems_utils.unregister_node_categories('SIMULATION')
nodeitems_utils.unregister_node_categories('GEOMETRY')
if __name__ == "__main__":

View File

@@ -0,0 +1,58 @@
/*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#pragma once
/** \file
* \ingroup bke
*/
struct Mesh;
namespace blender::bke {
class Geometry {
private:
/* Only contains a mesh for now. */
Mesh *mesh_ = nullptr;
public:
Geometry() = default;
~Geometry();
/** Takes ownership of the mesh. */
static Geometry *from_mesh(Mesh *mesh)
{
Geometry *geometry = new Geometry();
geometry->mesh_ = mesh;
return geometry;
}
Mesh *mesh()
{
return mesh_;
}
/* The caller takes ownership of the mesh and removes it from the geometry. */
Mesh *extract_mesh()
{
Mesh *mesh = mesh_;
mesh_ = nullptr;
return mesh;
}
};
} // namespace blender::bke

View File

@@ -112,6 +112,8 @@ namespace blender {
namespace nodes {
class SocketMFNetworkBuilder;
class NodeMFNetworkBuilder;
class GeoNodeInput;
class GeoNodeOutput;
} // namespace nodes
namespace fn {
class MFDataType;
@@ -121,11 +123,15 @@ class MFDataType;
using NodeExpandInMFNetworkFunction = void (*)(blender::nodes::NodeMFNetworkBuilder &builder);
using SocketGetMFDataTypeFunction = blender::fn::MFDataType (*)();
using SocketExpandInMFNetworkFunction = void (*)(blender::nodes::SocketMFNetworkBuilder &builder);
using GeometryNodeExecFunction = void (*)(struct bNode *node,
blender::nodes::GeoNodeInput input,
blender::nodes::GeoNodeOutput output);
#else
typedef void *NodeExpandInMFNetworkFunction;
typedef void *SocketGetMFDataTypeFunction;
typedef void *SocketExpandInMFNetworkFunction;
typedef void *GeometryNodeExecFunction;
#endif
/**
@@ -302,6 +308,9 @@ typedef struct bNodeType {
/* Expands the bNode into nodes in a multi-function network, which will be evaluated later on. */
NodeExpandInMFNetworkFunction expand_in_mf_network;
/* Execute a geometry node. */
GeometryNodeExecFunction geometry_node_execute;
/* RNA integration */
ExtensionRNA rna_ext;
} bNodeType;
@@ -1323,6 +1332,14 @@ int ntreeTexExecTree(struct bNodeTree *ntree,
struct MTex *mtex);
/** \} */
/* -------------------------------------------------------------------- */
/** \name Geometry Nodes
* \{ */
#define GEO_NODE_TRIANGULATE 1000
/** \} */
/* -------------------------------------------------------------------- */
/** \name Function Nodes
* \{ */

View File

@@ -124,6 +124,7 @@ set(SRC
intern/fmodifier.c
intern/font.c
intern/freestyle.c
intern/geometry.cc
intern/gpencil.c
intern/gpencil_curve.c
intern/gpencil_geom.c
@@ -310,6 +311,7 @@ set(SRC
BKE_fluid.h
BKE_font.h
BKE_freestyle.h
BKE_geometry.hh
BKE_global.h
BKE_gpencil.h
BKE_gpencil_curve.h

View File

@@ -0,0 +1,32 @@
/*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "BKE_geometry.hh"
#include "BKE_mesh.h"
#include "MEM_guardedalloc.h"
namespace blender::bke {
Geometry::~Geometry()
{
if (mesh_ != nullptr) {
BKE_mesh_free(mesh_);
MEM_freeN(mesh_);
}
}
} // namespace blender::bke

View File

@@ -65,7 +65,6 @@
#include "BKE_lib_query.h"
#include "BKE_main.h"
#include "BKE_node.h"
#include "BKE_simulation.h"
#include "BLI_ghash.h"
#include "BLI_threads.h"
@@ -75,8 +74,8 @@
#include "NOD_common.h"
#include "NOD_composite.h"
#include "NOD_function.h"
#include "NOD_geometry.h"
#include "NOD_shader.h"
#include "NOD_simulation.h"
#include "NOD_socket.h"
#include "NOD_texture.h"
@@ -281,6 +280,7 @@ static void library_foreach_node_socket(LibraryForeachIDData *data, bNodeSocket
case __SOCK_MESH:
case SOCK_CUSTOM:
case SOCK_SHADER:
case SOCK_GEOMETRY:
break;
}
}
@@ -373,6 +373,7 @@ static void write_node_socket_default_value(BlendWriter *writer, bNodeSocket *so
case __SOCK_MESH:
case SOCK_CUSTOM:
case SOCK_SHADER:
case SOCK_GEOMETRY:
BLI_assert(false);
break;
}
@@ -715,6 +716,7 @@ static void lib_link_node_socket(BlendLibReader *reader, Library *lib, bNodeSock
case __SOCK_MESH:
case SOCK_CUSTOM:
case SOCK_SHADER:
case SOCK_GEOMETRY:
break;
}
}
@@ -793,6 +795,7 @@ static void expand_node_socket(BlendExpander *expander, bNodeSocket *sock)
case __SOCK_MESH:
case SOCK_CUSTOM:
case SOCK_SHADER:
case SOCK_GEOMETRY:
break;
}
}
@@ -1345,6 +1348,7 @@ static void socket_id_user_increment(bNodeSocket *sock)
case __SOCK_MESH:
case SOCK_CUSTOM:
case SOCK_SHADER:
case SOCK_GEOMETRY:
break;
}
}
@@ -1371,6 +1375,7 @@ static void socket_id_user_decrement(bNodeSocket *sock)
case __SOCK_MESH:
case SOCK_CUSTOM:
case SOCK_SHADER:
case SOCK_GEOMETRY:
break;
}
}
@@ -1498,6 +1503,8 @@ const char *nodeStaticSocketType(int type, int subtype)
return "NodeSocketObject";
case SOCK_IMAGE:
return "NodeSocketImage";
case SOCK_GEOMETRY:
return "NodeSocketGeometry";
}
return NULL;
}
@@ -1563,6 +1570,8 @@ const char *nodeStaticSocketInterfaceType(int type, int subtype)
return "NodeSocketInterfaceObject";
case SOCK_IMAGE:
return "NodeSocketInterfaceImage";
case SOCK_GEOMETRY:
return "NodeSocketInterfaceGeometry";
}
return NULL;
}
@@ -4646,9 +4655,11 @@ static void registerTextureNodes(void)
register_node_type_tex_proc_distnoise();
}
static void registerSimulationNodes(void)
static void registerGeometryNodes(void)
{
register_node_type_sim_group();
register_node_type_geo_group();
register_node_type_geo_triangulate();
}
static void registerFunctionNodes(void)
@@ -4675,7 +4686,7 @@ void init_nodesystem(void)
register_node_tree_type_cmp();
register_node_tree_type_sh();
register_node_tree_type_tex();
register_node_tree_type_sim();
register_node_tree_type_geo();
register_node_type_frame();
register_node_type_reroute();
@@ -4685,7 +4696,7 @@ void init_nodesystem(void)
registerCompositNodes();
registerShaderNodes();
registerTextureNodes();
registerSimulationNodes();
registerGeometryNodes();
registerFunctionNodes();
}

View File

@@ -1187,9 +1187,6 @@ static bool foreach_object_modifier_ptcache(Object *object,
}
}
}
else if (md->type == eModifierType_Simulation) {
/* TODO(jacques): */
}
}
return true;
}

View File

@@ -48,8 +48,8 @@
#include "BKE_pointcache.h"
#include "BKE_simulation.h"
#include "NOD_geometry.h"
#include "NOD_node_tree_multi_function.hh"
#include "NOD_simulation.h"
#include "BLI_map.hh"
#include "BLT_translation.h"
@@ -70,7 +70,7 @@ static void simulation_init_data(ID *id)
MEMCPY_STRUCT_AFTER(simulation, DNA_struct_default_get(Simulation), id);
bNodeTree *ntree = ntreeAddTree(nullptr, "Simulation Nodetree", ntreeType_Simulation->idname);
bNodeTree *ntree = ntreeAddTree(nullptr, "Geometry Nodetree", ntreeType_Geometry->idname);
simulation->nodetree = ntree;
}

View File

@@ -158,7 +158,6 @@
#include "BKE_screen.h"
#include "BKE_sequencer.h"
#include "BKE_shader_fx.h"
#include "BKE_simulation.h"
#include "BKE_sound.h"
#include "BKE_volume.h"
#include "BKE_workspace.h"

View File

@@ -141,6 +141,9 @@ void DEG_add_object_relation(struct DepsNodeHandle *node_handle,
void DEG_add_simulation_relation(struct DepsNodeHandle *node_handle,
struct Simulation *simulation,
const char *description);
void DEG_add_node_tree_relation(struct DepsNodeHandle *node_handle,
struct bNodeTree *node_tree,
const char *description);
void DEG_add_bone_relation(struct DepsNodeHandle *handle,
struct Object *object,
const char *bone_name,

View File

@@ -32,6 +32,7 @@
#include "PIL_time_utildefines.h"
#include "DNA_cachefile_types.h"
#include "DNA_node_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_simulation_types.h"
@@ -116,6 +117,17 @@ void DEG_add_simulation_relation(DepsNodeHandle *node_handle,
deg_node_handle->builder->add_node_handle_relation(operation_key, deg_node_handle, description);
}
void DEG_add_node_tree_relation(DepsNodeHandle *node_handle,
bNodeTree *node_tree,
const char *description)
{
/* Using shading key, because that's the one that exists right now. Should use something else in
* the future. */
deg::ComponentKey shading_key(&node_tree->id, deg::NodeType::SHADING);
deg::DepsNodeHandle *deg_node_handle = get_node_handle(node_handle);
deg_node_handle->builder->add_node_handle_relation(shading_key, deg_node_handle, description);
}
void DEG_add_object_cache_relation(DepsNodeHandle *node_handle,
CacheFile *cache_file,
eDepsObjectComponentType component,

View File

@@ -96,7 +96,7 @@ void ED_node_set_tree_type(struct SpaceNode *snode, struct bNodeTreeType *typein
bool ED_node_is_compositor(struct SpaceNode *snode);
bool ED_node_is_shader(struct SpaceNode *snode);
bool ED_node_is_texture(struct SpaceNode *snode);
bool ED_node_is_simulation(struct SpaceNode *snode);
bool ED_node_is_geometry(struct SpaceNode *snode);
void ED_node_shader_default(const struct bContext *C, struct ID *id);
void ED_node_composit_default(const struct bContext *C, struct Scene *scene);

View File

@@ -68,8 +68,8 @@
#include "IMB_imbuf_types.h"
#include "NOD_composite.h"
#include "NOD_geometry.h"
#include "NOD_shader.h"
#include "NOD_simulation.h"
#include "NOD_texture.h"
#include "node_intern.h" /* own include */
@@ -3138,9 +3138,9 @@ static void node_texture_set_butfunc(bNodeType *ntype)
}
}
/* ****************** BUTTON CALLBACKS FOR SIMULATION NODES ***************** */
/* ****************** BUTTON CALLBACKS FOR GEOMETRY NODES ***************** */
static void node_simulation_set_butfunc(bNodeType *UNUSED(ntype))
static void node_geometry_set_butfunc(bNodeType *UNUSED(ntype))
{
}
@@ -3286,7 +3286,7 @@ void ED_node_init_butfuncs(void)
node_composit_set_butfunc(ntype);
node_shader_set_butfunc(ntype);
node_texture_set_butfunc(ntype);
node_simulation_set_butfunc(ntype);
node_geometry_set_butfunc(ntype);
node_function_set_butfunc(ntype);
/* define update callbacks for socket properties */
@@ -3298,7 +3298,7 @@ void ED_node_init_butfuncs(void)
ntreeType_Composite->ui_icon = ICON_NODE_COMPOSITING;
ntreeType_Shader->ui_icon = ICON_NODE_MATERIAL;
ntreeType_Texture->ui_icon = ICON_NODE_TEXTURE;
ntreeType_Simulation->ui_icon = ICON_PHYSICS; /* TODO: Use correct icon. */
ntreeType_Geometry->ui_icon = ICON_PHYSICS; /* TODO: Use correct icon. */
}
void ED_init_custom_node_type(bNodeType *ntype)
@@ -3329,6 +3329,7 @@ static const float std_node_socket_colors[][4] = {
{0.39, 0.39, 0.39, 1.0}, /* SOCK_STRING */
{0.40, 0.10, 0.10, 1.0}, /* SOCK_OBJECT */
{0.10, 0.40, 0.10, 1.0}, /* SOCK_IMAGE */
{0.00, 0.00, 0.00, 1.0}, /* SOCK_GEOMETRY, TODO: Choose color. */
};
/* common color callbacks for standard types */

View File

@@ -68,8 +68,8 @@
#include "IMB_imbuf_types.h"
#include "NOD_composite.h"
#include "NOD_geometry.h"
#include "NOD_shader.h"
#include "NOD_simulation.h"
#include "NOD_texture.h"
#include "node_intern.h" /* own include */
@@ -391,6 +391,7 @@ void snode_dag_update(bContext *C, SpaceNode *snode)
}
DEG_id_tag_update(snode->id, 0);
DEG_id_tag_update(&snode->nodetree->id, 0);
}
void snode_notify(bContext *C, SpaceNode *snode)
@@ -443,9 +444,9 @@ bool ED_node_is_texture(struct SpaceNode *snode)
return STREQ(snode->tree_idname, ntreeType_Texture->idname);
}
bool ED_node_is_simulation(struct SpaceNode *snode)
bool ED_node_is_geometry(struct SpaceNode *snode)
{
return STREQ(snode->tree_idname, ntreeType_Simulation->idname);
return STREQ(snode->tree_idname, ntreeType_Geometry->idname);
}
/* assumes nothing being done in ntree yet, sets the default in/out node */
@@ -1696,7 +1697,7 @@ static int node_mute_exec(bContext *C, wmOperator *UNUSED(op))
}
}
do_tag_update |= ED_node_is_simulation(snode);
do_tag_update |= ED_node_is_geometry(snode);
snode_notify(C, snode);
if (do_tag_update) {
@@ -1740,7 +1741,7 @@ static int node_delete_exec(bContext *C, wmOperator *UNUSED(op))
}
}
do_tag_update |= ED_node_is_simulation(snode);
do_tag_update |= ED_node_is_geometry(snode);
ntreeUpdateTree(CTX_data_main(C), snode->edittree);

View File

@@ -71,7 +71,7 @@ static bool node_group_operator_active(bContext *C)
if (STREQ(snode->tree_idname, "ShaderNodeTree") ||
STREQ(snode->tree_idname, "CompositorNodeTree") ||
STREQ(snode->tree_idname, "TextureNodeTree") ||
STREQ(snode->tree_idname, "SimulationNodeTree")) {
STREQ(snode->tree_idname, "GeometryNodeTree")) {
return true;
}
}
@@ -88,7 +88,7 @@ static bool node_group_operator_editable(bContext *C)
* with same keymap.
*/
if (ED_node_is_shader(snode) || ED_node_is_compositor(snode) || ED_node_is_texture(snode) ||
ED_node_is_simulation(snode)) {
ED_node_is_geometry(snode)) {
return true;
}
}
@@ -114,8 +114,8 @@ static const char *group_node_idname(bContext *C)
if (ED_node_is_texture(snode)) {
return "TextureNodeGroup";
}
if (ED_node_is_simulation(snode)) {
return "SimulationNodeGroup";
if (ED_node_is_geometry(snode)) {
return "GeometryNodeGroup";
}
return "";

View File

@@ -655,7 +655,7 @@ static void node_link_exit(bContext *C, wmOperator *op, bool apply_links)
}
ntree->is_updating = false;
do_tag_update |= ED_node_is_simulation(snode);
do_tag_update |= ED_node_is_geometry(snode);
ntreeUpdateTree(bmain, ntree);
snode_notify(C, snode);
@@ -1052,7 +1052,7 @@ static int cut_links_exec(bContext *C, wmOperator *op)
}
}
do_tag_update |= ED_node_is_simulation(snode);
do_tag_update |= ED_node_is_geometry(snode);
if (found) {
ntreeUpdateTree(CTX_data_main(C), snode->edittree);

View File

@@ -936,7 +936,7 @@ static void node_space_subtype_item_extend(bContext *C, EnumPropertyItem **item,
const EnumPropertyItem *item_src = RNA_enum_node_tree_types_itemf_impl(C, &free);
for (const EnumPropertyItem *item_iter = item_src; item_iter->identifier; item_iter++) {
if (!U.experimental.use_new_geometry_nodes &&
STREQ(item_iter->identifier, "SimulationNodeTree")) {
STREQ(item_iter->identifier, "GeometryNodeTree")) {
continue;
}
RNA_enum_item_add(item, totitem, item_iter);

View File

@@ -38,6 +38,7 @@ set(SRC
FN_array_spans.hh
FN_attributes_ref.hh
FN_cpp_type.hh
FN_generic_pointer.hh
FN_generic_vector_array.hh
FN_multi_function.hh
FN_multi_function_builder.hh

View File

@@ -0,0 +1,70 @@
/*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#pragma once
#include "FN_cpp_type.hh"
namespace blender::fn {
/**
* A generic pointer whose type is only known at runtime.
*/
class GMutablePointer {
private:
const CPPType *type_ = nullptr;
void *data_ = nullptr;
public:
GMutablePointer() = default;
GMutablePointer(const CPPType *type, void *data = nullptr) : type_(type), data_(data)
{
/* If there is data, there has to be a type. */
BLI_assert(data_ == nullptr || type_ != nullptr);
}
GMutablePointer(const CPPType &type, void *data = nullptr) : GMutablePointer(&type, data)
{
}
template<typename T> GMutablePointer(T *data) : GMutablePointer(&CPPType::get<T>(), data)
{
}
void *get() const
{
return data_;
}
const CPPType *type() const
{
return type_;
}
template<typename T> T *get() const
{
BLI_assert(this->is_type<T>());
return reinterpret_cast<T *>(data_);
}
template<typename T> bool is_type() const
{
return type_ != nullptr && type_->is<T>();
}
};
} // namespace blender::fn

View File

@@ -574,7 +574,7 @@
.flag = 0, \
}
#define _DNA_DEFAULT_SimulationModifierData \
#define _DNA_DEFAULT_NodesModifierData \
{ 0 }
#define _DNA_DEFAULT_SkinModifierData \

View File

@@ -94,7 +94,7 @@ typedef enum ModifierType {
eModifierType_WeightedNormal = 54,
eModifierType_Weld = 55,
eModifierType_Fluid = 56,
eModifierType_Simulation = 57,
eModifierType_Nodes = 57,
eModifierType_MeshToVolume = 58,
eModifierType_VolumeDisplace = 59,
eModifierType_VolumeToMesh = 60,
@@ -2217,9 +2217,10 @@ enum {
#define MOD_MESHSEQ_READ_ALL \
(MOD_MESHSEQ_READ_VERT | MOD_MESHSEQ_READ_POLY | MOD_MESHSEQ_READ_UV | MOD_MESHSEQ_READ_COLOR)
typedef struct SimulationModifierData {
typedef struct NodesModifierData {
ModifierData modifier;
} SimulationModifierData;
struct bNodeTree *node_tree;
} NodesModifierData;
typedef struct MeshToVolumeModifierData {
ModifierData modifier;

View File

@@ -155,6 +155,7 @@ typedef enum eNodeSocketDatatype {
SOCK_STRING = 7,
SOCK_OBJECT = 8,
SOCK_IMAGE = 9,
SOCK_GEOMETRY = 10,
} eNodeSocketDatatype;
/* socket shape */
@@ -499,7 +500,7 @@ typedef struct bNodeTree {
#define NTREE_SHADER 0
#define NTREE_COMPOSIT 1
#define NTREE_TEXTURE 2
#define NTREE_SIMULATION 3
#define NTREE_GEOMETRY 3
/* ntree->init, flag */
#define NTREE_TYPE_INIT 1
@@ -1422,15 +1423,3 @@ typedef enum NodeShaderOutputTarget {
SHD_OUTPUT_EEVEE = 1,
SHD_OUTPUT_CYCLES = 2,
} NodeShaderOutputTarget;
/* Particle Time Step Event node */
typedef enum NodeSimParticleTimeStepEventType {
NODE_PARTICLE_TIME_STEP_EVENT_BEGIN = 0,
NODE_PARTICLE_TIME_STEP_EVENT_END = 1,
} NodeSimParticleTimeStepEventType;
/* Simulation Time node */
typedef enum NodeSimInputTimeType {
NODE_SIM_INPUT_SIMULATION_TIME = 0,
NODE_SIM_INPUT_SCENE_TIME = 1,
} NodeSimInputTimeType;

View File

@@ -271,7 +271,7 @@ SDNA_DEFAULT_DECL_STRUCT(ScrewModifierData);
/* Shape key modifier has no items. */
SDNA_DEFAULT_DECL_STRUCT(ShrinkwrapModifierData);
SDNA_DEFAULT_DECL_STRUCT(SimpleDeformModifierData);
SDNA_DEFAULT_DECL_STRUCT(SimulationModifierData);
SDNA_DEFAULT_DECL_STRUCT(NodesModifierData);
SDNA_DEFAULT_DECL_STRUCT(SkinModifierData);
SDNA_DEFAULT_DECL_STRUCT(SmoothModifierData);
/* Softbody modifier skipped for now. */
@@ -491,7 +491,7 @@ const void *DNA_default_table[SDNA_TYPE_MAX] = {
/* Shape key modifier has no items. */
SDNA_DEFAULT_DECL(ShrinkwrapModifierData),
SDNA_DEFAULT_DECL(SimpleDeformModifierData),
SDNA_DEFAULT_DECL(SimulationModifierData),
SDNA_DEFAULT_DECL(NodesModifierData),
SDNA_DEFAULT_DECL(SkinModifierData),
SDNA_DEFAULT_DECL(SmoothModifierData),
/* Softbody modifier skipped for now. */

View File

@@ -566,10 +566,10 @@ extern StructRNA RNA_SimpleDeformModifier;
extern StructRNA RNA_SimplifyGpencilModifier;
extern StructRNA RNA_Simulation;
#ifdef WITH_GEOMETRY_NODES
extern StructRNA RNA_SimulationModifier;
extern StructRNA RNA_NodesModifier;
#endif
extern StructRNA RNA_SimulationNode;
extern StructRNA RNA_SimulationNodeTree;
extern StructRNA RNA_GeometryNode;
extern StructRNA RNA_GeometryNodeTree;
extern StructRNA RNA_SkinModifier;
extern StructRNA RNA_SmoothGpencilModifier;
extern StructRNA RNA_SmoothModifier;

View File

@@ -29,7 +29,6 @@
#include "DNA_object_force_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_simulation_types.h"
#include "MEM_guardedalloc.h"
@@ -161,6 +160,7 @@ const EnumPropertyItem rna_enum_object_modifier_type_items[] = {
ICON_MOD_MULTIRES,
"Multiresolution",
"Subdivide the mesh in a way that allows editing the higher subdivision levels"},
{eModifierType_Nodes, "NODES", ICON_MESH_DATA, "Nodes", ""}, /* TODO: Use correct icon. */
{eModifierType_Remesh,
"REMESH",
ICON_MOD_REMESH,
@@ -305,11 +305,6 @@ const EnumPropertyItem rna_enum_object_modifier_type_items[] = {
"Spawn particles from the shape"},
{eModifierType_Softbody, "SOFT_BODY", ICON_MOD_SOFT, "Soft Body", ""},
{eModifierType_Surface, "SURFACE", ICON_MODIFIER, "Surface", ""},
{eModifierType_Simulation,
"SIMULATION",
ICON_PHYSICS,
"Simulation",
""}, /* TODO: Use correct icon. */
{0, NULL, 0, NULL, NULL},
};
@@ -1602,6 +1597,14 @@ static int rna_MeshSequenceCacheModifier_read_velocity_get(PointerRNA *ptr)
# endif
}
static bool rna_NodesModifier_node_tree_poll(PointerRNA *ptr, PointerRNA value)
{
NodesModifierData *nmd = ptr->data;
bNodeTree *ntree = value.data;
UNUSED_VARS(nmd, ntree);
return true;
}
#else
/* NOTE: *MUST* return subdivision_type property. */
@@ -6920,17 +6923,24 @@ static void rna_def_modifier_weightednormal(BlenderRNA *brna)
}
# ifdef WITH_GEOMETRY_NODES
static void rna_def_modifier_simulation(BlenderRNA *brna)
static void rna_def_modifier_nodes(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
srna = RNA_def_struct(brna, "SimulationModifier", "Modifier");
RNA_def_struct_ui_text(srna, "Simulation Modifier", "");
RNA_def_struct_sdna(srna, "SimulationModifierData");
RNA_def_struct_ui_icon(srna, ICON_PHYSICS); /* TODO: Use correct icon. */
srna = RNA_def_struct(brna, "NodesModifier", "Modifier");
RNA_def_struct_ui_text(srna, "Nodes Modifier", "");
RNA_def_struct_sdna(srna, "NodesModifierData");
RNA_def_struct_ui_icon(srna, ICON_MESH_DATA); /* TODO: Use correct icon. */
RNA_define_lib_overridable(true);
prop = RNA_def_property(srna, "node_tree", PROP_POINTER, PROP_NONE);
RNA_def_property_ui_text(prop, "Node Tree", "Node tree that controls what this modifier does");
RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_NodesModifier_node_tree_poll");
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
RNA_define_lib_overridable(false);
}
# endif
@@ -7290,7 +7300,7 @@ void RNA_def_modifier(BlenderRNA *brna)
rna_def_modifier_surfacedeform(brna);
rna_def_modifier_weightednormal(brna);
# ifdef WITH_GEOMETRY_NODES
rna_def_modifier_simulation(brna);
rna_def_modifier_nodes(brna);
# endif
rna_def_modifier_mesh_to_volume(brna);
rna_def_modifier_volume_displace(brna);

View File

@@ -38,7 +38,6 @@
#include "BKE_animsys.h"
#include "BKE_image.h"
#include "BKE_node.h"
#include "BKE_simulation.h"
#include "BKE_texture.h"
#include "RNA_access.h"
@@ -84,6 +83,7 @@ static const EnumPropertyItem node_socket_type_items[] = {
{SOCK_SHADER, "SHADER", 0, "Shader", ""},
{SOCK_OBJECT, "OBJECT", 0, "Object", ""},
{SOCK_IMAGE, "IMAGE", 0, "Image", ""},
{SOCK_GEOMETRY, "GEOMETRY", 0, "Geometry", ""},
{0, NULL, 0, NULL, NULL},
};
@@ -96,6 +96,7 @@ static const EnumPropertyItem node_socket_data_type_items[] = {
{SOCK_RGBA, "RGBA", 0, "Color", ""},
{SOCK_OBJECT, "OBJECT", 0, "Object", ""},
{SOCK_IMAGE, "IMAGE", 0, "Image", ""},
{SOCK_GEOMETRY, "GEOMETRY", 0, "Geometry", ""},
{0, NULL, 0, NULL, NULL},
};
@@ -725,9 +726,9 @@ static const EnumPropertyItem *rna_node_static_type_itemf(bContext *UNUSED(C),
# undef DefNode
}
if (RNA_struct_is_a(ptr->type, &RNA_SimulationNode)) {
if (RNA_struct_is_a(ptr->type, &RNA_GeometryNode)) {
# define DefNode(Category, ID, DefFunc, EnumName, StructName, UIName, UIDesc) \
if (STREQ(#Category, "SimulationNode")) { \
if (STREQ(#Category, "GeometryNode")) { \
tmp.value = ID; \
tmp.identifier = EnumName; \
tmp.name = UIName; \
@@ -1868,16 +1869,16 @@ static StructRNA *rna_TextureNode_register(Main *bmain,
return nt->rna_ext.srna;
}
static StructRNA *rna_SimulationNode_register(Main *bmain,
ReportList *reports,
void *data,
const char *identifier,
StructValidateFunc validate,
StructCallbackFunc call,
StructFreeFunc free)
static StructRNA *rna_GeometryNode_register(Main *bmain,
ReportList *reports,
void *data,
const char *identifier,
StructValidateFunc validate,
StructCallbackFunc call,
StructFreeFunc free)
{
bNodeType *nt = rna_Node_register_base(
bmain, reports, &RNA_SimulationNode, data, identifier, validate, call, free);
bmain, reports, &RNA_GeometryNode, data, identifier, validate, call, free);
if (!nt) {
return NULL;
}
@@ -8177,14 +8178,14 @@ static void rna_def_texture_node(BlenderRNA *brna)
RNA_def_struct_register_funcs(srna, "rna_TextureNode_register", "rna_Node_unregister", NULL);
}
static void rna_def_simulation_node(BlenderRNA *brna)
static void rna_def_geometry_node(BlenderRNA *brna)
{
StructRNA *srna;
srna = RNA_def_struct(brna, "SimulationNode", "NodeInternal");
RNA_def_struct_ui_text(srna, "Simulation Node", "");
srna = RNA_def_struct(brna, "GeometryNode", "NodeInternal");
RNA_def_struct_ui_text(srna, "Geometry Node", "");
RNA_def_struct_sdna(srna, "bNode");
RNA_def_struct_register_funcs(srna, "rna_SimulationNode_register", "rna_Node_unregister", NULL);
RNA_def_struct_register_funcs(srna, "rna_GeometryNode_register", "rna_Node_unregister", NULL);
}
static void rna_def_function_node(BlenderRNA *brna)
@@ -8831,6 +8832,21 @@ static void rna_def_node_socket_image(BlenderRNA *brna,
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeSocketInterface_update");
}
static void rna_def_node_socket_geometry(BlenderRNA *brna,
const char *identifier,
const char *interface_idname)
{
StructRNA *srna;
srna = RNA_def_struct(brna, identifier, "NodeSocketStandard");
RNA_def_struct_ui_text(srna, "Geometry Node Socket", "Geometry socket of a node");
RNA_def_struct_sdna(srna, "bNodeSocket");
srna = RNA_def_struct(brna, interface_idname, "NodeSocketInterfaceStandard");
RNA_def_struct_ui_text(srna, "Geometry Node Socket Interface", "Geometry socket of a node");
RNA_def_struct_sdna(srna, "bNodeSocket");
}
static void rna_def_node_socket_standard_types(BlenderRNA *brna)
{
/* XXX Workaround: Registered functions are not exposed in python by bpy,
@@ -8969,6 +8985,8 @@ static void rna_def_node_socket_standard_types(BlenderRNA *brna)
rna_def_node_socket_object(brna, "NodeSocketObject", "NodeSocketInterfaceObject");
rna_def_node_socket_image(brna, "NodeSocketImage", "NodeSocketInterfaceImage");
rna_def_node_socket_geometry(brna, "NodeSocketGeometry", "NodeSocketInterfaceGeometry");
}
static void rna_def_internal_node(BlenderRNA *brna)
@@ -9606,7 +9624,7 @@ static void rna_def_nodetree(BlenderRNA *brna)
{NTREE_SHADER, "SHADER", ICON_MATERIAL, "Shader", "Shader nodes"},
{NTREE_TEXTURE, "TEXTURE", ICON_TEXTURE, "Texture", "Texture nodes"},
{NTREE_COMPOSIT, "COMPOSITING", ICON_RENDERLAYERS, "Compositing", "Compositing nodes"},
{NTREE_SIMULATION, "SIMULATION", ICON_PHYSICS, "Simulation", "Simulation nodes"},
{NTREE_GEOMETRY, "GEOMETRY", ICON_MESH_DATA, "Geometry", "Geometry nodes"},
{0, NULL, 0, NULL, NULL},
};
@@ -9830,15 +9848,15 @@ static void rna_def_texture_nodetree(BlenderRNA *brna)
RNA_def_struct_ui_icon(srna, ICON_TEXTURE);
}
static void rna_def_simulation_nodetree(BlenderRNA *brna)
static void rna_def_geometry_nodetree(BlenderRNA *brna)
{
StructRNA *srna;
srna = RNA_def_struct(brna, "SimulationNodeTree", "NodeTree");
srna = RNA_def_struct(brna, "GeometryNodeTree", "NodeTree");
RNA_def_struct_ui_text(
srna, "Simulation Node Tree", "Node tree consisting of linked nodes used for simulations");
srna, "Geometry Node Tree", "Node tree consisting of linked nodes used for geometries");
RNA_def_struct_sdna(srna, "bNodeTree");
RNA_def_struct_ui_icon(srna, ICON_PHYSICS); /* TODO: Use correct icon. */
RNA_def_struct_ui_icon(srna, ICON_MESH_DATA); /* TODO: Use correct icon. */
}
static StructRNA *define_specific_node(BlenderRNA *brna,
@@ -9927,7 +9945,7 @@ void RNA_def_nodetree(BlenderRNA *brna)
rna_def_shader_node(brna);
rna_def_compositor_node(brna);
rna_def_texture_node(brna);
rna_def_simulation_node(brna);
rna_def_geometry_node(brna);
rna_def_function_node(brna);
rna_def_nodetree(brna);
@@ -9937,7 +9955,7 @@ void RNA_def_nodetree(BlenderRNA *brna)
rna_def_composite_nodetree(brna);
rna_def_shader_nodetree(brna);
rna_def_texture_nodetree(brna);
rna_def_simulation_nodetree(brna);
rna_def_geometry_nodetree(brna);
# define DefNode(Category, ID, DefFunc, EnumName, StructName, UIName, UIDesc) \
{ \
@@ -9954,13 +9972,13 @@ void RNA_def_nodetree(BlenderRNA *brna)
*/
# include "../../nodes/NOD_static_types.h"
/* Node group types need to be defined for shader, compositor, texture, simulation nodes
/* Node group types need to be defined for shader, compositor, texture, geometry nodes
* individually. Cannot use the static types header for this, since they share the same int id.
*/
define_specific_node(brna, "ShaderNodeGroup", "ShaderNode", "Group", "", def_group);
define_specific_node(brna, "CompositorNodeGroup", "CompositorNode", "Group", "", def_group);
define_specific_node(brna, "TextureNodeGroup", "TextureNode", "Group", "", def_group);
define_specific_node(brna, "SimulationNodeGroup", "SimulationNode", "Group", "", def_group);
define_specific_node(brna, "GeometryNodeGroup", "GeometryNode", "Group", "", def_group);
def_custom_group(brna,
"ShaderNodeCustomGroup",
"ShaderNode",

View File

@@ -45,7 +45,6 @@
#include "DNA_node_types.h"
#include "DNA_object_types.h"
#include "DNA_sequence_types.h"
#include "DNA_simulation_types.h"
#include "DNA_space_types.h"
#include "DNA_view3d_types.h"
#include "DNA_workspace_types.h"
@@ -2178,40 +2177,6 @@ static void rna_SpaceNodeEditor_node_tree_update(const bContext *C, PointerRNA *
ED_node_tree_update(C);
}
# ifdef WITH_GEOMETRY_NODES
static PointerRNA rna_SpaceNodeEditor_simulation_get(PointerRNA *ptr)
{
SpaceNode *snode = (SpaceNode *)ptr->data;
ID *id = snode->id;
if (id && GS(id->name) == ID_SIM) {
return rna_pointer_inherit_refine(ptr, &RNA_Simulation, snode->id);
}
else {
return PointerRNA_NULL;
}
}
static void rna_SpaceNodeEditor_simulation_set(PointerRNA *ptr,
const PointerRNA value,
struct ReportList *UNUSED(reports))
{
SpaceNode *snode = (SpaceNode *)ptr->data;
if (!STREQ(snode->tree_idname, "SimulationNodeTree")) {
return;
}
Simulation *sim = (Simulation *)value.data;
if (sim != NULL) {
bNodeTree *ntree = sim->nodetree;
ED_node_tree_start(snode, ntree, NULL, NULL);
}
else {
ED_node_tree_start(snode, NULL, NULL, NULL);
}
snode->id = &sim->id;
}
# endif
static int rna_SpaceNodeEditor_tree_type_get(PointerRNA *ptr)
{
SpaceNode *snode = (SpaceNode *)ptr->data;
@@ -6347,19 +6312,6 @@ static void rna_def_space_node(BlenderRNA *brna)
RNA_def_property_ui_text(
prop, "ID From", "Data-block from which the edited data-block is linked");
# ifdef WITH_GEOMETRY_NODES
prop = RNA_def_property(srna, "simulation", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_struct_type(prop, "Simulation");
RNA_def_property_ui_text(prop, "Simulation", "Simulation that is being edited");
RNA_def_property_pointer_funcs(prop,
"rna_SpaceNodeEditor_simulation_get",
"rna_SpaceNodeEditor_simulation_set",
NULL,
NULL);
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_NODE, NULL);
# endif
prop = RNA_def_property(srna, "path", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "treepath", NULL);
RNA_def_property_struct_type(prop, "NodeTreePath");

View File

@@ -29,8 +29,10 @@ set(INC
../bmesh
../depsgraph
../editors/include
../functions
../makesdna
../makesrna
../nodes
../render/extern/include
../windowmanager
../../../intern/eigen
@@ -86,7 +88,7 @@ set(SRC
intern/MOD_shapekey.c
intern/MOD_shrinkwrap.c
intern/MOD_simpledeform.c
intern/MOD_simulation.cc
intern/MOD_nodes.cc
intern/MOD_skin.c
intern/MOD_smooth.c
intern/MOD_softbody.c

View File

@@ -85,7 +85,7 @@ extern ModifierTypeInfo modifierType_CorrectiveSmooth;
extern ModifierTypeInfo modifierType_MeshSequenceCache;
extern ModifierTypeInfo modifierType_SurfaceDeform;
extern ModifierTypeInfo modifierType_WeightedNormal;
extern ModifierTypeInfo modifierType_Simulation;
extern ModifierTypeInfo modifierType_Nodes;
extern ModifierTypeInfo modifierType_MeshToVolume;
extern ModifierTypeInfo modifierType_VolumeDisplace;
extern ModifierTypeInfo modifierType_VolumeToMesh;

View File

@@ -0,0 +1,290 @@
/*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2005 by the Blender Foundation.
* All rights reserved.
*/
/** \file
* \ingroup modifiers
*/
#include <cstring>
#include <iostream>
#include <string>
#include "MEM_guardedalloc.h"
#include "BLI_float3.hh"
#include "BLI_listbase.h"
#include "BLI_string.h"
#include "BLI_utildefines.h"
#include "DNA_defaults.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_modifier_types.h"
#include "DNA_node_types.h"
#include "DNA_object_types.h"
#include "DNA_pointcloud_types.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "BKE_customdata.h"
#include "BKE_lib_query.h"
#include "BKE_mesh.h"
#include "BKE_modifier.h"
#include "BKE_pointcloud.h"
#include "BKE_screen.h"
#include "BKE_simulation.h"
#include "BLO_read_write.h"
#include "UI_interface.h"
#include "UI_resources.h"
#include "RNA_access.h"
#include "DEG_depsgraph_build.h"
#include "DEG_depsgraph_query.h"
#include "MOD_modifiertypes.h"
#include "MOD_ui_common.h"
#include "NOD_derived_node_tree.hh"
#include "NOD_geometry_exec.hh"
using blender::float3;
static void initData(ModifierData *md)
{
NodesModifierData *nmd = (NodesModifierData *)md;
BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(nmd, modifier));
MEMCPY_STRUCT_AFTER(nmd, DNA_struct_default_get(NodesModifierData), modifier);
}
static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *ctx)
{
NodesModifierData *nmd = reinterpret_cast<NodesModifierData *>(md);
if (nmd->node_tree != nullptr) {
DEG_add_node_tree_relation(ctx->node, nmd->node_tree, "Nodes Modifier");
}
}
static void foreachIDLink(ModifierData *md, Object *ob, IDWalkFunc walk, void *userData)
{
NodesModifierData *nmd = reinterpret_cast<NodesModifierData *>(md);
walk(userData, ob, (ID **)&nmd->node_tree, IDWALK_CB_USER);
}
static bool isDisabled(const struct Scene *UNUSED(scene),
ModifierData *md,
bool UNUSED(useRenderParams))
{
NodesModifierData *nmd = reinterpret_cast<NodesModifierData *>(md);
UNUSED_VARS(nmd);
return false;
}
static PointCloud *modifyPointCloud(ModifierData *md,
const ModifierEvalContext *UNUSED(ctx),
PointCloud *pointcloud)
{
NodesModifierData *nmd = reinterpret_cast<NodesModifierData *>(md);
UNUSED_VARS(nmd);
std::cout << __func__ << "\n";
return pointcloud;
}
using namespace blender;
using namespace blender::nodes;
using namespace blender::fn;
using namespace blender::bke;
static Geometry *compute_geometry(const DOutputSocket *group_input,
Geometry *group_input_geometry,
const DInputSocket &socket_to_compute)
{
Span<const DOutputSocket *> from_sockets = socket_to_compute.linked_sockets();
Span<const DGroupInput *> from_group_inputs = socket_to_compute.linked_group_inputs();
const int total_inputs = from_sockets.size() + from_group_inputs.size();
if (total_inputs != 1) {
return nullptr;
}
if (!from_group_inputs.is_empty()) {
return nullptr;
}
const DOutputSocket &from_socket = *from_sockets[0];
if (&from_socket == group_input) {
return group_input_geometry;
}
if (from_socket.idname() != "NodeSocketGeometry") {
return nullptr;
}
const DNode &from_node = from_socket.node();
if (from_node.inputs().size() != 1) {
return nullptr;
}
Geometry *input_geometry = compute_geometry(
group_input, group_input_geometry, from_node.input(0));
bNode *bnode = from_node.node_ref().bnode();
GeometryNodeExecFunction execute = bnode->typeinfo->geometry_node_execute;
LinearAllocator<> allocator;
GeoNodeInputBuilder input_builder;
GeometryP geometry_p{input_geometry};
input_builder.add("Geometry", CPPType::get<GeometryP>(), &geometry_p);
GeoNodeOutputCollector output_collector{allocator};
execute(bnode, input_builder, output_collector);
Geometry *output_geometry =
output_collector.get<GeometryP>(from_socket.socket_ref().bsocket()->identifier).p;
return output_geometry;
}
static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *UNUSED(ctx), Mesh *mesh)
{
NodesModifierData *nmd = reinterpret_cast<NodesModifierData *>(md);
if (nmd->node_tree == nullptr) {
return mesh;
}
NodeTreeRefMap tree_refs;
DerivedNodeTree tree{nmd->node_tree, tree_refs};
Span<const DNode *> input_nodes = tree.nodes_by_type("NodeGroupInput");
Span<const DNode *> output_nodes = tree.nodes_by_type("NodeGroupOutput");
if (input_nodes.size() > 1) {
return mesh;
}
if (output_nodes.size() != 1) {
return mesh;
}
Span<const DOutputSocket *> group_inputs = (input_nodes.size() == 1) ?
input_nodes[0]->outputs().drop_back(1) :
Span<const DOutputSocket *>{};
Span<const DInputSocket *> group_outputs = output_nodes[0]->inputs().drop_back(1);
if (group_outputs.size() != 1) {
return mesh;
}
const DInputSocket *group_output = group_outputs[0];
if (group_output->idname() != "NodeSocketGeometry") {
return mesh;
}
Geometry *input_geometry = Geometry::from_mesh(mesh);
Geometry *new_geometry = compute_geometry(group_inputs[0], input_geometry, *group_outputs[0]);
if (new_geometry == nullptr) {
return mesh;
}
Mesh *new_mesh = new_geometry->extract_mesh();
return new_mesh;
}
static void panel_draw(const bContext *UNUSED(C), Panel *panel)
{
uiLayout *layout = panel->layout;
PointerRNA ob_ptr;
PointerRNA *ptr = modifier_panel_get_property_pointers(panel, &ob_ptr);
uiLayoutSetPropSep(layout, true);
uiLayoutSetPropDecorate(layout, false);
uiItemR(layout, ptr, "node_tree", 0, NULL, ICON_MESH_DATA);
modifier_panel_end(layout, ptr);
}
static void panelRegister(ARegionType *region_type)
{
modifier_panel_register(region_type, eModifierType_Nodes, panel_draw);
}
static void blendWrite(BlendWriter *writer, const ModifierData *md)
{
const NodesModifierData *nmd = reinterpret_cast<const NodesModifierData *>(md);
UNUSED_VARS(nmd, writer);
}
static void blendRead(BlendDataReader *reader, ModifierData *md)
{
NodesModifierData *nmd = reinterpret_cast<NodesModifierData *>(md);
UNUSED_VARS(nmd, reader);
}
static void copyData(const ModifierData *md, ModifierData *target, const int flag)
{
const NodesModifierData *nmd = reinterpret_cast<const NodesModifierData *>(md);
NodesModifierData *tnmd = reinterpret_cast<NodesModifierData *>(target);
UNUSED_VARS(nmd, tnmd);
BKE_modifier_copydata_generic(md, target, flag);
}
static void freeData(ModifierData *md)
{
NodesModifierData *nmd = reinterpret_cast<NodesModifierData *>(md);
UNUSED_VARS(nmd);
}
ModifierTypeInfo modifierType_Nodes = {
/* name */ "Nodes",
/* structName */ "NodesModifierData",
/* structSize */ sizeof(NodesModifierData),
#ifdef WITH_GEOMETRY_NODES
/* srna */ &RNA_NodesModifier,
#else
/* srna */ &RNA_Modifier,
#endif
/* type */ eModifierTypeType_Constructive,
/* flags */ eModifierTypeFlag_AcceptsMesh,
/* icon */ ICON_MESH_DATA, /* TODO: Use correct icon. */
/* copyData */ copyData,
/* deformVerts */ NULL,
/* deformMatrices */ NULL,
/* deformVertsEM */ NULL,
/* deformMatricesEM */ NULL,
/* modifyMesh */ modifyMesh,
/* modifyHair */ NULL,
/* modifyPointCloud */ modifyPointCloud,
/* modifyVolume */ NULL,
/* initData */ initData,
/* requiredDataMask */ NULL,
/* freeData */ freeData,
/* isDisabled */ isDisabled,
/* updateDepsgraph */ updateDepsgraph,
/* dependsOnTime */ NULL,
/* dependsOnNormals */ NULL,
/* foreachIDLink */ foreachIDLink,
/* foreachTexLink */ NULL,
/* freeRuntimeData */ NULL,
/* panelRegister */ panelRegister,
/* blendWrite */ blendWrite,
/* blendRead */ blendRead,
};

View File

@@ -1,194 +0,0 @@
/*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2005 by the Blender Foundation.
* All rights reserved.
*/
/** \file
* \ingroup modifiers
*/
#include <cstring>
#include <iostream>
#include <string>
#include "MEM_guardedalloc.h"
#include "BLI_float3.hh"
#include "BLI_listbase.h"
#include "BLI_string.h"
#include "BLI_utildefines.h"
#include "DNA_defaults.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_modifier_types.h"
#include "DNA_object_types.h"
#include "DNA_pointcloud_types.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "DNA_simulation_types.h"
#include "BKE_customdata.h"
#include "BKE_lib_query.h"
#include "BKE_mesh.h"
#include "BKE_modifier.h"
#include "BKE_pointcloud.h"
#include "BKE_screen.h"
#include "BKE_simulation.h"
#include "BLO_read_write.h"
#include "UI_interface.h"
#include "UI_resources.h"
#include "RNA_access.h"
#include "DEG_depsgraph_build.h"
#include "DEG_depsgraph_query.h"
#include "MOD_modifiertypes.h"
#include "MOD_ui_common.h"
using blender::float3;
static void initData(ModifierData *md)
{
SimulationModifierData *smd = (SimulationModifierData *)md;
BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(smd, modifier));
MEMCPY_STRUCT_AFTER(smd, DNA_struct_default_get(SimulationModifierData), modifier);
}
static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *UNUSED(ctx))
{
SimulationModifierData *smd = reinterpret_cast<SimulationModifierData *>(md);
UNUSED_VARS(smd);
}
static void foreachIDLink(ModifierData *md,
Object *UNUSED(ob),
IDWalkFunc UNUSED(walk),
void *UNUSED(userData))
{
SimulationModifierData *smd = reinterpret_cast<SimulationModifierData *>(md);
UNUSED_VARS(smd);
}
static bool isDisabled(const struct Scene *UNUSED(scene),
ModifierData *md,
bool UNUSED(useRenderParams))
{
SimulationModifierData *smd = reinterpret_cast<SimulationModifierData *>(md);
UNUSED_VARS(smd);
return false;
}
static PointCloud *modifyPointCloud(ModifierData *md,
const ModifierEvalContext *UNUSED(ctx),
PointCloud *pointcloud)
{
SimulationModifierData *smd = reinterpret_cast<SimulationModifierData *>(md);
UNUSED_VARS(smd);
return pointcloud;
}
static void panel_draw(const bContext *UNUSED(C), Panel *panel)
{
uiLayout *layout = panel->layout;
PointerRNA ob_ptr;
PointerRNA *ptr = modifier_panel_get_property_pointers(panel, &ob_ptr);
uiLayoutSetPropSep(layout, true);
uiLayoutSetPropDecorate(layout, false);
uiItemL(layout, "This modifier does nothing currently", ICON_INFO);
modifier_panel_end(layout, ptr);
}
static void panelRegister(ARegionType *region_type)
{
modifier_panel_register(region_type, eModifierType_Simulation, panel_draw);
}
static void blendWrite(BlendWriter *writer, const ModifierData *md)
{
const SimulationModifierData *smd = reinterpret_cast<const SimulationModifierData *>(md);
UNUSED_VARS(smd, writer);
}
static void blendRead(BlendDataReader *reader, ModifierData *md)
{
SimulationModifierData *smd = reinterpret_cast<SimulationModifierData *>(md);
UNUSED_VARS(smd, reader);
}
static void copyData(const ModifierData *md, ModifierData *target, const int flag)
{
const SimulationModifierData *smd = reinterpret_cast<const SimulationModifierData *>(md);
SimulationModifierData *tsmd = reinterpret_cast<SimulationModifierData *>(target);
UNUSED_VARS(smd, tsmd);
BKE_modifier_copydata_generic(md, target, flag);
}
static void freeData(ModifierData *md)
{
SimulationModifierData *smd = reinterpret_cast<SimulationModifierData *>(md);
UNUSED_VARS(smd);
}
ModifierTypeInfo modifierType_Simulation = {
/* name */ "Simulation",
/* structName */ "SimulationModifierData",
/* structSize */ sizeof(SimulationModifierData),
#ifdef WITH_GEOMETRY_NODES
/* srna */ &RNA_SimulationModifier,
#else
/* srna */ &RNA_Modifier,
#endif
/* type */ eModifierTypeType_None,
/* flags */ (ModifierTypeFlag)0,
/* icon */ ICON_PHYSICS, /* TODO: Use correct icon. */
/* copyData */ copyData,
/* deformVerts */ NULL,
/* deformMatrices */ NULL,
/* deformVertsEM */ NULL,
/* deformMatricesEM */ NULL,
/* modifyMesh */ NULL,
/* modifyHair */ NULL,
/* modifyPointCloud */ modifyPointCloud,
/* modifyVolume */ NULL,
/* initData */ initData,
/* requiredDataMask */ NULL,
/* freeData */ freeData,
/* isDisabled */ isDisabled,
/* updateDepsgraph */ updateDepsgraph,
/* dependsOnTime */ NULL,
/* dependsOnNormals */ NULL,
/* foreachIDLink */ foreachIDLink,
/* foreachTexLink */ NULL,
/* freeRuntimeData */ NULL,
/* panelRegister */ panelRegister,
/* blendWrite */ blendWrite,
/* blendRead */ blendRead,
};

View File

@@ -48,11 +48,17 @@
#include "MOD_modifiertypes.h"
#include "MOD_ui_common.h"
static Mesh *triangulate_mesh(Mesh *mesh,
const int quad_method,
const int ngon_method,
const int min_vertices,
const int flag)
Mesh *triangulate_mesh(Mesh *mesh,
const int quad_method,
const int ngon_method,
const int min_vertices,
const int flag);
Mesh *triangulate_mesh(Mesh *mesh,
const int quad_method,
const int ngon_method,
const int min_vertices,
const int flag)
{
Mesh *result;
BMesh *bm;

View File

@@ -342,7 +342,7 @@ void modifier_type_init(ModifierTypeInfo *types[])
INIT_TYPE(MeshSequenceCache);
INIT_TYPE(SurfaceDeform);
INIT_TYPE(WeightedNormal);
INIT_TYPE(Simulation);
INIT_TYPE(Nodes);
INIT_TYPE(MeshToVolume);
INIT_TYPE(VolumeDisplace);
INIT_TYPE(VolumeToMesh);

View File

@@ -24,7 +24,7 @@ set(INC
function
intern
shader
simulation
geometry
texture
../blenkernel
../blenlib
@@ -137,6 +137,12 @@ set(SRC
function/nodes/node_fn_switch.cc
function/node_function_util.cc
geometry/nodes/node_geo_common.cc
geometry/nodes/node_geo_triangulate.cc
geometry/node_geometry_exec.cc
geometry/node_geometry_tree.cc
geometry/node_geometry_util.cc
shader/nodes/node_shader_add_shader.c
shader/nodes/node_shader_ambient_occlusion.c
shader/nodes/node_shader_attribute.c
@@ -230,10 +236,6 @@ set(SRC
shader/node_shader_tree.c
shader/node_shader_util.c
simulation/nodes/node_sim_common.cc
simulation/node_simulation_tree.cc
simulation/node_simulation_util.cc
texture/nodes/node_texture_at.c
texture/nodes/node_texture_bricks.c
texture/nodes/node_texture_checker.c
@@ -272,7 +274,7 @@ set(SRC
composite/node_composite_util.h
function/node_function_util.hh
shader/node_shader_util.h
simulation/node_simulation_util.h
geometry/node_geometry_util.hh
texture/node_texture_util.h
NOD_common.h
@@ -283,7 +285,7 @@ set(SRC
NOD_node_tree_multi_function.hh
NOD_node_tree_ref.hh
NOD_shader.h
NOD_simulation.h
NOD_geometry.h
NOD_socket.h
NOD_static_types.h
NOD_texture.h

View File

@@ -20,11 +20,13 @@
extern "C" {
#endif
extern struct bNodeTreeType *ntreeType_Simulation;
extern struct bNodeTreeType *ntreeType_Geometry;
void register_node_tree_type_sim(void);
void register_node_tree_type_geo(void);
void register_node_type_sim_group(void);
void register_node_type_geo_group(void);
void register_node_type_geo_triangulate(void);
#ifdef __cplusplus
}

View File

@@ -0,0 +1,129 @@
/*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#pragma once
#include "FN_generic_pointer.hh"
#include "BLI_linear_allocator.hh"
#include "BLI_map.hh"
#include "BKE_geometry.hh"
namespace blender::nodes {
using bke::Geometry;
using fn::CPPType;
using fn::GMutablePointer;
class GeoNodeInputBuilder {
private:
Map<StringRef, GMutablePointer> values_;
friend class GeoNodeInput;
public:
void add(StringRef name, const CPPType &type, void *data)
{
values_.add_new(name, GMutablePointer{type, data});
}
};
class GeoNodeInput {
private:
const GeoNodeInputBuilder &builder_;
public:
GeoNodeInput(const GeoNodeInputBuilder &builder) : builder_(builder)
{
}
GMutablePointer get(StringRef name)
{
return builder_.values_.lookup(name);
}
template<typename T> T &get(StringRef name)
{
return *this->get(name).get<T>();
}
};
class GeoNodeOutputCollector {
private:
LinearAllocator<> &allocator_;
Map<StringRef, GMutablePointer> values_;
friend class GeoNodeOutput;
public:
GeoNodeOutputCollector(LinearAllocator<> &allocator) : allocator_(allocator)
{
}
GMutablePointer get(StringRef name)
{
return values_.lookup(name);
}
template<typename T> T &get(StringRef name)
{
return *this->get(name).get<T>();
}
};
class GeoNodeOutput {
private:
GeoNodeOutputCollector &collector_;
public:
GeoNodeOutput(GeoNodeOutputCollector &collector) : collector_(collector)
{
}
void set(StringRef name, const CPPType &type, void *data)
{
collector_.values_.add(name, GMutablePointer{type, data});
}
template<typename T> void set(StringRef name, T &&data)
{
T *copied_data = collector_.allocator_.construct<T>(std::forward<T>(data));
collector_.values_.add_new(name, GMutablePointer{copied_data});
}
};
struct GeometryP {
bke::Geometry *p = nullptr;
uint64_t hash() const
{
return DefaultHash<bke::Geometry *>{}(p);
}
friend std::ostream &operator<<(std::ostream &stream, const GeometryP &geometry)
{
stream << geometry.p;
return stream;
}
friend bool operator==(const GeometryP &a, const GeometryP &b)
{
return a.p == b.p;
}
};
} // namespace blender::nodes

View File

@@ -266,6 +266,8 @@ DefNode(FunctionNode, FN_NODE_COMBINE_STRINGS, 0, "COMBINE_STRINGS
DefNode(FunctionNode, FN_NODE_OBJECT_TRANSFORMS, 0, "OBJECT_TRANSFORMS", ObjectTransforms, "Object Transforms", "")
DefNode(FunctionNode, FN_NODE_RANDOM_FLOAT, 0, "RANDOM_FLOAT", RandomFloat, "Random Float", "")
DefNode(GeometryNode, GEO_NODE_TRIANGULATE, 0, "TRIANGULATE", Triangulate, "Triangulate", "")
/* undefine macros */
#undef DefNode

View File

@@ -20,7 +20,7 @@
bool fn_node_poll_default(bNodeType *UNUSED(ntype), bNodeTree *ntree)
{
/* Function nodes are only supported in simulation node trees so far. */
return STREQ(ntree->idname, "SimulationNodeTree");
return STREQ(ntree->idname, "GeometryNodeTree");
}
void fn_node_type_base(bNodeType *ntype, int type, const char *name, short nclass, short flag)

View File

@@ -0,0 +1,23 @@
/*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "NOD_geometry_exec.hh"
MAKE_CPP_TYPE(GeometryP, blender::nodes::GeometryP);
namespace blender::nodes {
}

View File

@@ -18,7 +18,7 @@
#include "MEM_guardedalloc.h"
#include "NOD_simulation.h"
#include "NOD_geometry.h"
#include "BKE_node.h"
@@ -28,18 +28,18 @@
#include "RNA_access.h"
bNodeTreeType *ntreeType_Simulation;
bNodeTreeType *ntreeType_Geometry;
void register_node_tree_type_sim(void)
void register_node_tree_type_geo(void)
{
bNodeTreeType *tt = ntreeType_Simulation = static_cast<bNodeTreeType *>(
MEM_callocN(sizeof(bNodeTreeType), "simulation node tree type"));
tt->type = NTREE_SIMULATION;
strcpy(tt->idname, "SimulationNodeTree");
strcpy(tt->ui_name, N_("Simulation Editor"));
bNodeTreeType *tt = ntreeType_Geometry = static_cast<bNodeTreeType *>(
MEM_callocN(sizeof(bNodeTreeType), "geometry node tree type"));
tt->type = NTREE_GEOMETRY;
strcpy(tt->idname, "GeometryNodeTree");
strcpy(tt->ui_name, N_("Geometry Node Editor"));
tt->ui_icon = 0; /* defined in drawnode.c */
strcpy(tt->ui_description, N_("Simulation nodes"));
tt->rna_ext.srna = &RNA_SimulationNodeTree;
strcpy(tt->ui_description, N_("Geometry nodes"));
tt->rna_ext.srna = &RNA_GeometryNodeTree;
ntreeTypeAdd(tt);
}

View File

@@ -14,16 +14,16 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "node_simulation_util.h"
#include "node_geometry_util.hh"
#include "node_util.h"
bool sim_node_poll_default(bNodeType *UNUSED(ntype), bNodeTree *ntree)
bool geo_node_poll_default(bNodeType *UNUSED(ntype), bNodeTree *ntree)
{
return STREQ(ntree->idname, "SimulationNodeTree");
return STREQ(ntree->idname, "GeometryNodeTree");
}
void sim_node_type_base(bNodeType *ntype, int type, const char *name, short nclass, short flag)
void geo_node_type_base(bNodeType *ntype, int type, const char *name, short nclass, short flag)
{
node_type_base(ntype, type, name, nclass, flag);
ntype->poll = sim_node_poll_default;
ntype->poll = geo_node_poll_default;
}

View File

@@ -28,10 +28,11 @@
#include "BLT_translation.h"
#include "NOD_simulation.h"
#include "NOD_geometry.h"
#include "NOD_geometry_exec.hh"
#include "node_util.h"
void sim_node_type_base(
void geo_node_type_base(
struct bNodeType *ntype, int type, const char *name, short nclass, short flag);
bool sim_node_poll_default(struct bNodeType *ntype, struct bNodeTree *ntree);
bool geo_node_poll_default(struct bNodeType *ntype, struct bNodeTree *ntree);

View File

@@ -16,23 +16,23 @@
#include "BKE_node.h"
#include "NOD_simulation.h"
#include "NOD_geometry.h"
#include "NOD_common.h"
#include "node_common.h"
#include "node_simulation_util.h"
#include "node_geometry_util.hh"
void register_node_type_sim_group(void)
void register_node_type_geo_group(void)
{
static bNodeType ntype;
node_type_base_custom(&ntype, "SimulationNodeGroup", "Group", 0, 0);
node_type_base_custom(&ntype, "GeometryNodeGroup", "Group", 0, 0);
ntype.type = NODE_GROUP;
ntype.poll = sim_node_poll_default;
ntype.poll = geo_node_poll_default;
ntype.poll_instance = node_group_poll_instance;
ntype.insert_link = node_insert_link_default;
ntype.update_internal_links = node_update_internal_links_default;
ntype.rna_ext.srna = RNA_struct_find("SimulationNodeGroup");
ntype.rna_ext.srna = RNA_struct_find("GeometryNodeGroup");
BLI_assert(ntype.rna_ext.srna != NULL);
RNA_struct_blender_type_set(ntype.rna_ext.srna, &ntype);

View File

@@ -0,0 +1,60 @@
/*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "node_geometry_util.hh"
extern "C" {
Mesh *triangulate_mesh(Mesh *mesh,
const int quad_method,
const int ngon_method,
const int min_vertices,
const int flag);
}
static bNodeSocketTemplate geo_node_triangulate_in[] = {
{SOCK_GEOMETRY, N_("Geometry")},
{-1, ""},
};
static bNodeSocketTemplate geo_node_triangulate_out[] = {
{SOCK_GEOMETRY, N_("Geometry")},
{-1, ""},
};
namespace blender::nodes {
static void geo_triangulate_exec(bNode *UNUSED(node), GeoNodeInput input, GeoNodeOutput output)
{
Geometry *geometry = input.get<GeometryP>("Geometry").p;
if (geometry != nullptr) {
Mesh *old_mesh = geometry->extract_mesh();
if (old_mesh != nullptr) {
Mesh *new_mesh = triangulate_mesh(old_mesh, 3, 0, 4, 0);
geometry = Geometry::from_mesh(new_mesh);
}
}
output.set("Geometry", GeometryP{geometry});
}
} // namespace blender::nodes
void register_node_type_geo_triangulate()
{
static bNodeType ntype;
geo_node_type_base(&ntype, GEO_NODE_TRIANGULATE, "Triangulate", 0, 0);
node_type_socket_templates(&ntype, geo_node_triangulate_in, geo_node_triangulate_out);
ntype.geometry_node_execute = blender::nodes::geo_triangulate_exec;
nodeRegisterType(&ntype);
}

View File

@@ -672,6 +672,12 @@ static bNodeSocketType *make_socket_type_object()
return socktype;
}
static bNodeSocketType *make_socket_type_geometry()
{
bNodeSocketType *socktype = make_standard_socket_type(SOCK_GEOMETRY, PROP_NONE);
return socktype;
}
void register_standard_node_socket_types(void)
{
/* draw callbacks are set in drawnode.c to avoid bad-level calls */
@@ -708,5 +714,7 @@ void register_standard_node_socket_types(void)
nodeRegisterSocketType(make_standard_socket_type(SOCK_IMAGE, PROP_NONE));
nodeRegisterSocketType(make_socket_type_geometry());
nodeRegisterSocketType(make_socket_type_virtual());
}

View File

@@ -34,7 +34,7 @@ bool sh_node_poll_default(bNodeType *UNUSED(ntype), bNodeTree *ntree)
static bool sh_fn_poll_default(bNodeType *UNUSED(ntype), bNodeTree *ntree)
{
return STREQ(ntree->idname, "ShaderNodeTree") || STREQ(ntree->idname, "SimulationNodeTree");
return STREQ(ntree->idname, "ShaderNodeTree") || STREQ(ntree->idname, "GeometryNodeTree");
}
void sh_node_type_base(