Compare commits

...

50 Commits

Author SHA1 Message Date
c5e2a8fbbd add runtime field to Simulation 2020-04-16 13:04:33 +02:00
401ddff410 get current scene time 2020-04-16 12:44:34 +02:00
5f47593f50 separate simulation eval function 2020-04-16 12:23:52 +02:00
89880e891c initial testing for integration in depsgraph 2020-04-15 18:26:07 +02:00
fd6d8ac791 Add Boolean Math, Switch and Float Compare function nodes
Since those nodes did not exist for shader node trees before,
I implemented them directly as "function nodes". Those could later
be used in shader node trees as well.

Differential Revision: https://developer.blender.org/D7424
2020-04-14 13:47:38 +02:00
ff3d82d7ef Use some shader nodes in the simulation nodes
This makes a subset of the shader nodes available in simulation node trees.
More can be made available in the future, but we might not be able to actually
implement all the nodes before the release.

For now, their name remains `ShaderNode...`. We should rename them to
e.g. `FunctionNode...` and move them to a separate folder in the future.

Differential Revision: https://developer.blender.org/D7422
2020-04-14 12:31:27 +02:00
d26c3e9e75 Core particle nodes (ui only)
Differential Revision: https://developer.blender.org/D7384
2020-04-09 15:00:55 +02:00
b9e1e769fb show name in particle simulation node 2020-04-09 13:04:34 +02:00
26e114efb8 add missing cases for new types in switch statement 2020-04-09 12:38:25 +02:00
c9bdeef488 core particle simulation nodes 2020-04-09 12:34:12 +02:00
827861cfdf Merge branch 'image-and-object-socket-type' into influence-and-control-flow-socket-types 2020-04-09 11:39:05 +02:00
82db1198a5 Merge branch 'embedded_simulation_node_tree' into image-and-object-socket-type 2020-04-09 11:35:24 +02:00
c8bcb7cc2b Merge branch 'simulation-tree-arc' into embedded_simulation_node_tree 2020-04-09 11:32:38 +02:00
9eb90548c5 Merge branch 'simulation-data-block' into simulation-tree-arc 2020-04-09 11:28:42 +02:00
40b269f50b Merge branch 'master' into simulation-data-block 2020-04-09 11:24:11 +02:00
9b3bdce6a6 add missing enum item 2020-04-09 11:23:26 +02:00
b392632b8d add simulation node trees to node tree iterator 2020-04-09 11:23:06 +02:00
ebd8f94050 fix user counting when freeing interface sockets 2020-04-09 11:19:56 +02:00
5c15a74d63 copy object/image pointer in node_socket_copy_default_value 2020-04-09 11:12:16 +02:00
4dc3831a2a bring back a break 2020-04-06 15:22:22 +02:00
5bb1a05d9e handle node tree in lib_query.c 2020-04-06 15:20:25 +02:00
6a447a32fe Add emitters, events, forces and control flow socket types
This is part of T73324.

The shapes and colors of the sockets will most likely change later on.

This script can be used to create a node with the new socket types:
```
import bpy

class MyCustomNode(bpy.types.Node):
    bl_idname = 'CustomNodeType'
    bl_label = "Custom Node"

    def init(self, context):
        self.inputs.new('NodeSocketEmitters', "Emitters")
        self.inputs.new('NodeSocketEvents', "Events")
        self.inputs.new('NodeSocketForces', "Forces")
        self.inputs.new('NodeSocketControlFlow', "Control Flow")

        self.outputs.new('NodeSocketEmitters', "Emitters")
        self.outputs.new('NodeSocketEvents', "Events")
        self.outputs.new('NodeSocketForces', "Forces")
        self.outputs.new('NodeSocketControlFlow', "Control Flow")

bpy.utils.register_class(MyCustomNode)

if len(bpy.data.simulations) == 0:
    bpy.data.simulations.new("Simulation")

sim = bpy.data.simulations[0]
sim.node_tree.nodes.new("CustomNodeType")
```

Differential Revision: https://developer.blender.org/D7349
2020-04-06 13:52:50 +02:00
7dfdb1a8a0 New Object and Image socket types
The main difficulty with adding these types is that they are the first sockets types
that reference ID data in their `default_value`. That means that I had to add some
new logic in a few places to deal with reference counting. I hope I found all the places...
It seems to work fine in my tests.

For now these socket types can only be created using a script like the one below:
```
import bpy

class MyCustomNode(bpy.types.Node):
    bl_idname = 'CustomNodeType'
    bl_label = "Custom Node"

    def init(self, context):
        self.inputs.new('NodeSocketObject', "Object")
        self.inputs.new('NodeSocketImage', "Image")

bpy.utils.register_class(MyCustomNode)

if len(bpy.data.simulations) == 0:
    bpy.data.simulations.new("Simulation")

sim = bpy.data.simulations[0]
sim.node_tree.nodes.new("CustomNodeType")
```

After running the script, go to the simulation editor and select the newly created simulation.

---

We might want to change `readfile.c` so that linked objects/images are only loaded,
when the socket is not connected. Otherwise it can be tricky to figure out why certain
id data blocks are still referenced by the node tree later on.

Differential Revision: https://developer.blender.org/D7347
2020-04-06 13:23:20 +02:00
2b1e84c0de Merge branch 'simulation-tree-arc' into embedded_simulation_node_tree 2020-04-06 12:04:40 +02:00
2cc55bcdc2 fix after merge 2020-04-06 12:01:13 +02:00
ffb3285672 Merge branch 'simulation-data-block' into simulation-tree-arc 2020-04-06 11:55:43 +02:00
69aecad547 Merge branch 'master' into simulation-data-block 2020-04-06 11:51:57 +02:00
3fab8acfd8 Embed simulation node tree in simulation data block
This also shows the node tree in the Simulation Editor.
There is a new operator to add a simulation.

One debatable aspect of this patch is how I integrated the `SpaceNodeEditor.simulation`
property in RNA. I decided to wrap the existing `id` property, because the description
says `Data-block whose nodes are being edited`, which is exactly what is happening here.

Differential Revision: https://developer.blender.org/D7301
2020-04-01 12:17:03 +02:00
78b545f1fe better handling when id has wrong type 2020-04-01 11:44:02 +02:00
cbf3f46ffd better support for building without simulation type 2020-04-01 11:34:13 +02:00
fcc4a68482 show some builtin nodes in menu 2020-04-01 11:31:06 +02:00
b344800177 support adding new simulation from header 2020-04-01 11:27:39 +02:00
bd690a4d57 cleanup simulation property of space 2020-04-01 11:16:24 +02:00
b11de611d0 Merge branch 'simulation-tree-arc' into embedded_simulation_node_tree 2020-04-01 10:56:24 +02:00
6fda1d007f add license headers 2020-04-01 10:52:39 +02:00
8b08366e32 initial node tree embedding and simulation editor 2020-03-31 14:05:58 +02:00
456c7f2f90 Add simulation node tree type
This implements a new builtin node tree type called `SimulationNodeTree`.
It is not yet embedded in the `Simulation` data block.

This is part of T73324.

The `WITH_NEW_SIMULATION_TYPE` cmake option is used to control whether `Simulation Editor` is shown in the editors menu.
Disabling the rna code with this option was a bit tricky, because the node tree type stores a reference to the rna type.
I could do the `#ifdef WITH_NEW_SIMULATION_TYPE` everywhere, but I'm not sure if it is worth the effort.

Currently there is only the group node, which is unusable, because there are no other nodes.
I'll submit those for review separately.

Differential Revision: https://developer.blender.org/D7287
2020-03-31 12:27:41 +02:00
ebecd0aae5 Merge branch 'master' into simulation-data-block 2020-03-31 09:40:01 +02:00
118a9f8589 Replace VO_DS_EXPAND with SIM_DS_EXPAND 2020-03-24 16:30:29 +01:00
fc751901d8 remove unnecessary case in lib_remap.c 2020-03-24 16:29:02 +01:00
bd0f203d39 rename WITH_SIMULATION_DATA_BLOCK_RNA to WITH_NEW_SIMULATION_TYPE 2020-03-24 16:28:16 +01:00
727ed66065 Add new simulation data block
This introduces a new id data block with type `ID_SIM`.

The RNA part of this change is disabled by default for now.
The corresponding cmake option is `WITH_SIMULATION_DATA_BLOCK_RNA`.

The new data block does not yet have an embedded node tree.
I want to add that separately.

This is part of T73324.

The set of files I changed is based on rBb0a1cf2c9ae696.
However, I had to change fewer files, because I did not add a new object type.

Differential Revision: https://developer.blender.org/D7225
2020-03-24 14:59:16 +01:00
7f95682ac6 remove unnecessary todo 2020-03-24 14:37:10 +01:00
0055db5838 cleanup 2020-03-24 14:29:13 +01:00
64854506d1 add back blank line 2020-03-24 14:28:37 +01:00
3e07f2e322 remove unnecessary todo 2020-03-24 14:28:08 +01:00
b58db00ddf remove unnecessary includes 2020-03-24 14:25:58 +01:00
3689b783b7 Merge branch 'master' into simulation-data-block 2020-03-24 14:17:27 +01:00
1f1f1b018e add cmake option for simulation data block 2020-03-24 14:16:10 +01:00
78d0ec3586 initial new Simulation data block 2020-03-24 13:30:37 +01:00
115 changed files with 2818 additions and 127 deletions

View File

@@ -323,6 +323,10 @@ option(WITH_FREESTYLE "Enable Freestyle (advanced edges rendering)" ON)
option(WITH_NEW_OBJECT_TYPES "Enable new hair and pointcloud objects (use for development only, don't save in files)" OFF)
mark_as_advanced(WITH_NEW_OBJECT_TYPES)
# New simulation data block
option(WITH_NEW_SIMULATION_TYPE "Enable simulation data block (use for development only, don't save in files)" OFF)
mark_as_advanced(WITH_NEW_SIMULATION_TYPE)
# Misc
if(WIN32)
option(WITH_INPUT_IME "Enable Input Method Editor (IME) for complex Asian character input" ON)

View File

@@ -42,6 +42,7 @@ _modules = [
"rigidbody",
"screen_play_rendered_anim",
"sequencer",
"simulation",
"userpref",
"uvcalc_follow_active",
"uvcalc_lightmap",

View File

@@ -0,0 +1,39 @@
# ##### BEGIN GPL LICENSE BLOCK #####
#
# 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.
#
# ##### END GPL LICENSE BLOCK #####
import bpy
class NewSimulation(bpy.types.Operator):
"""Create a new simulation data block and edit it in the opened simulation editor"""
bl_idname = "simulation.new"
bl_label = "New Simulation"
bl_options = {'REGISTER', 'UNDO'}
@classmethod
def poll(cls, context):
return context.area.type == 'NODE_EDITOR' and context.space_data.tree_type == 'SimulationNodeTree'
def execute(self, context):
simulation = bpy.data.simulations.new("Simulation")
context.space_data.simulation = simulation
return {'FINISHED'}
classes = (
NewSimulation,
)

View File

@@ -58,6 +58,8 @@ class DATA_PT_pointcloud(DataButtonsPanel, Panel):
def draw(self, context):
layout = self.layout
pointcloud = context.pointcloud
layout.prop(pointcloud, "source_simulation")
pass
class DATA_PT_custom_props_pointcloud(DataButtonsPanel, PropertyPanel, Panel):

View File

@@ -151,6 +151,14 @@ 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="")
else:
# Custom node tree is edited as independent ID block
NODE_MT_editor_menus.draw_collapsible(context, layout)

View File

@@ -58,6 +58,13 @@ class TextureNodeCategory(SortedNodeCategory):
context.space_data.tree_type == 'TextureNodeTree')
class SimulationNodeCategory(SortedNodeCategory):
@classmethod
def poll(cls, context):
return (context.space_data.type == 'NODE_EDITOR' and
context.space_data.tree_type == 'SimulationNodeTree')
# menu entry for node group tools
def group_tools_draw(self, layout, context):
layout.operator("node.group_make")
@@ -70,6 +77,7 @@ node_tree_group_type = {
'CompositorNodeTree': 'CompositorNodeGroup',
'ShaderNodeTree': 'ShaderNodeGroup',
'TextureNodeTree': 'TextureNodeGroup',
'SimulationNodeTree': 'SimulationNodeGroup',
}
@@ -467,17 +475,79 @@ texture_node_categories = [
]),
]
simulation_node_categories = [
# Simulation Nodes
SimulationNodeCategory("SIM_OUTPUT", "Output", items=[
NodeItem("SimulationNodeParticleSimulation"),
]),
SimulationNodeCategory("SIM_EMITTERS", "Emitters", items=[
NodeItem("SimulationNodeParticleMeshEmitter"),
NodeItem("SimulationNodeEmitParticles"),
]),
SimulationNodeCategory("SIM_EVENTS", "Events", items=[
NodeItem("SimulationNodeParticleBirthEvent"),
NodeItem("SimulationNodeParticleTimeStepEvent"),
NodeItem("SimulationNodeParticleMeshCollisionEvent"),
]),
SimulationNodeCategory("SIM_FORCES", "Forces", items=[
NodeItem("SimulationNodeForce"),
]),
SimulationNodeCategory("SIM_EXECUTE", "Execute", items=[
NodeItem("SimulationNodeSetParticleAttribute"),
NodeItem("SimulationNodeExecuteCondition"),
NodeItem("SimulationNodeMultiExecute"),
]),
SimulationNodeCategory("SIM_FUNCTION_INPUTS", "Function Inputs", items=[
NodeItem("SimulationNodeSimulationTime"),
NodeItem("SimulationNodeParticleAttribute"),
]),
SimulationNodeCategory("SIM_NOISE", "Noise", items=[
NodeItem("ShaderNodeTexNoise"),
NodeItem("ShaderNodeTexWhiteNoise"),
]),
SimulationNodeCategory("SIM_COLOR", "Color", items=[
NodeItem("ShaderNodeMixRGB"),
NodeItem("ShaderNodeInvert"),
NodeItem("ShaderNodeHueSaturation"),
NodeItem("ShaderNodeGamma"),
NodeItem("ShaderNodeBrightContrast"),
]),
SimulationNodeCategory("SIM_CONVERTER", "Converter", items=[
NodeItem("ShaderNodeMapRange"),
NodeItem("ShaderNodeClamp"),
NodeItem("ShaderNodeMath"),
NodeItem("ShaderNodeValToRGB"),
NodeItem("ShaderNodeVectorMath"),
NodeItem("ShaderNodeSeparateRGB"),
NodeItem("ShaderNodeCombineRGB"),
NodeItem("ShaderNodeSeparateXYZ"),
NodeItem("ShaderNodeCombineXYZ"),
NodeItem("ShaderNodeSeparateHSV"),
NodeItem("ShaderNodeCombineHSV"),
NodeItem("FunctionNodeBooleanMath"),
NodeItem("FunctionNodeFloatCompare"),
NodeItem("FunctionNodeSwitch"),
]),
SimulationNodeCategory("SIM_GROUP", "Group", items=node_group_items),
SimulationNodeCategory("SIM_LAYOUT", "Layout", items=[
NodeItem("NodeFrame"),
NodeItem("NodeReroute"),
]),
]
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)
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')
if __name__ == "__main__":

View File

@@ -165,6 +165,7 @@ extern IDTypeInfo IDType_ID_LP;
extern IDTypeInfo IDType_ID_HA;
extern IDTypeInfo IDType_ID_PT;
extern IDTypeInfo IDType_ID_VO;
extern IDTypeInfo IDType_ID_SIM;
extern IDTypeInfo IDType_ID_LINK_PLACEHOLDER;

View File

@@ -147,6 +147,7 @@ typedef struct Main {
ListBase hairs;
ListBase pointclouds;
ListBase volumes;
ListBase simulations;
/**
* Must be generated, used and freed by same code - never assume this is valid data unless you
@@ -220,7 +221,7 @@ const char *BKE_main_blendfile_path_from_global(void);
struct ListBase *which_libbase(struct Main *mainlib, short type);
#define MAX_LIBARRAY 40
#define MAX_LIBARRAY 41
int set_listbasepointers(struct Main *main, struct ListBase *lb[MAX_LIBARRAY]);
#define MAIN_VERSION_ATLEAST(main, ver, subver) \

View File

@@ -852,6 +852,7 @@ struct NodeTreeIterStore {
struct Light *light;
struct World *world;
struct FreestyleLineStyle *linestyle;
struct Simulation *simulation;
};
void BKE_node_tree_iter_init(struct NodeTreeIterStore *ntreeiter, struct Main *bmain);
@@ -1282,6 +1283,35 @@ int ntreeTexExecTree(struct bNodeTree *ntree,
struct MTex *mtex);
/** \} */
/* -------------------------------------------------------------------- */
/** \name Simulation Nodes
* \{ */
#define SIM_NODE_PARTICLE_SIMULATION 1000
#define SIM_NODE_FORCE 1001
#define SIM_NODE_SET_PARTICLE_ATTRIBUTE 1002
#define SIM_NODE_PARTICLE_BIRTH_EVENT 1003
#define SIM_NODE_PARTICLE_TIME_STEP_EVENT 1004
#define SIM_NODE_EXECUTE_CONDITION 1005
#define SIM_NODE_MULTI_EXECUTE 1006
#define SIM_NODE_PARTICLE_MESH_EMITTER 1007
#define SIM_NODE_PARTICLE_MESH_COLLISION_EVENT 1008
#define SIM_NODE_EMIT_PARTICLES 1009
#define SIM_NODE_SIMULATION_TIME 1010
#define SIM_NODE_PARTICLE_ATTRIBUTE 1011
/** \} */
/* -------------------------------------------------------------------- */
/** \name Function Nodes
* \{ */
#define FN_NODE_BOOLEAN_MATH 1200
#define FN_NODE_SWITCH 1201
#define FN_NODE_FLOAT_COMPARE 1202
/** \} */
void init_nodesystem(void);
void free_nodesystem(void);

View File

@@ -0,0 +1,39 @@
/*
* 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.
*/
#ifndef __BKE_SIMULATION_H__
#define __BKE_SIMULATION_H__
#ifdef __cplusplus
extern "C" {
#endif
struct Depsgraph;
struct Main;
struct Scene;
struct Simulation;
void *BKE_simulation_add(struct Main *bmain, const char *name);
void BKE_simulation_eval(struct Depsgraph *depsgraph,
struct Simulation *simulation,
struct Scene *scene);
#ifdef __cplusplus
}
#endif
#endif /* __BKE_SIMULATION_H__ */

View File

@@ -211,6 +211,7 @@ set(SRC
intern/sequencer.c
intern/shader_fx.c
intern/shrinkwrap.c
intern/simulation.cc
intern/softbody.c
intern/sound.c
intern/speaker.c
@@ -362,6 +363,7 @@ set(SRC
BKE_sequencer.h
BKE_shader_fx.h
BKE_shrinkwrap.h
BKE_simulation.h
BKE_softbody.h
BKE_sound.h
BKE_speaker.h

View File

@@ -95,6 +95,7 @@ bool id_type_can_have_animdata(const short id_type)
case ID_HA:
case ID_PT:
case ID_VO:
case ID_SIM:
return true;
/* no AnimData */
@@ -1321,6 +1322,9 @@ void BKE_animdata_main_cb(Main *bmain, ID_AnimData_Edit_Callback func, void *use
/* volumes */
ANIMDATA_IDS_CB(bmain->volumes.first);
/* simulations */
ANIMDATA_IDS_CB(bmain->simulations.first);
}
/* Fix all RNA-Paths throughout the database (directly access the Global.main version)
@@ -1430,6 +1434,9 @@ void BKE_animdata_fix_paths_rename_all(ID *ref_id,
/* volumes */
RENAMEFIX_ANIM_IDS(bmain->volumes.first);
/* simulations */
RENAMEFIX_ANIM_IDS(bmain->simulations.first);
/* scenes */
RENAMEFIX_ANIM_NODETREE_IDS(bmain->scenes.first, Scene);
}

View File

@@ -2690,6 +2690,9 @@ void BKE_animsys_evaluate_all_animation(Main *main,
/* volumes */
EVAL_ANIM_IDS(main->volumes.first, ADT_RECALC_ANIM);
/* simulations */
EVAL_ANIM_IDS(main->simulations.first, ADT_RECALC_ANIM);
/* objects */
/* ADT_RECALC_ANIM doesn't need to be supplied here, since object AnimData gets
* this tagged by Depsgraph on framechange. This optimization means that objects

View File

@@ -92,6 +92,7 @@ static void id_type_init(void)
INIT_TYPE(ID_HA);
INIT_TYPE(ID_PT);
INIT_TYPE(ID_VO);
INIT_TYPE(ID_SIM);
/* Special naughty boy... */
BLI_assert(IDType_ID_LINK_PLACEHOLDER.main_listbase_index == INDEX_ID_NULL);
@@ -251,6 +252,7 @@ uint64_t BKE_idtype_idcode_to_idfilter(const short idcode)
CASE_IDFILTER(PT);
CASE_IDFILTER(LP);
CASE_IDFILTER(SCE);
CASE_IDFILTER(SIM);
CASE_IDFILTER(SPK);
CASE_IDFILTER(SO);
CASE_IDFILTER(TE);
@@ -302,6 +304,7 @@ short BKE_idtype_idcode_from_idfilter(const uint64_t idfilter)
CASE_IDFILTER(PT);
CASE_IDFILTER(LP);
CASE_IDFILTER(SCE);
CASE_IDFILTER(SIM);
CASE_IDFILTER(SPK);
CASE_IDFILTER(SO);
CASE_IDFILTER(TE);
@@ -356,6 +359,7 @@ int BKE_idtype_idcode_to_index(const short idcode)
CASE_IDINDEX(LP);
CASE_IDINDEX(SCE);
CASE_IDINDEX(SCR);
CASE_IDINDEX(SIM);
CASE_IDINDEX(SPK);
CASE_IDINDEX(SO);
CASE_IDINDEX(TE);
@@ -417,6 +421,7 @@ short BKE_idtype_idcode_from_index(const int index)
CASE_IDCODE(LP);
CASE_IDCODE(SCE);
CASE_IDCODE(SCR);
CASE_IDCODE(SIM);
CASE_IDCODE(SPK);
CASE_IDCODE(SO);
CASE_IDCODE(TE);

View File

@@ -49,6 +49,7 @@
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "DNA_sequence_types.h"
#include "DNA_simulation_types.h"
#include "DNA_sound_types.h"
#include "DNA_space_types.h"
#include "DNA_speaker_types.h"
@@ -204,6 +205,40 @@ static void library_foreach_idproperty_ID_link(LibraryForeachIDData *data,
FOREACH_FINALIZE_VOID;
}
static void library_foreach_node_socket(LibraryForeachIDData *data, bNodeSocket *sock)
{
library_foreach_idproperty_ID_link(data, sock->prop, IDWALK_CB_USER);
switch ((eNodeSocketDatatype)sock->type) {
case SOCK_OBJECT: {
bNodeSocketValueObject *default_value = sock->default_value;
FOREACH_CALLBACK_INVOKE_ID_PP(data, (ID **)&default_value->value, IDWALK_CB_USER);
break;
}
case SOCK_IMAGE: {
bNodeSocketValueImage *default_value = sock->default_value;
FOREACH_CALLBACK_INVOKE_ID_PP(data, (ID **)&default_value->value, IDWALK_CB_USER);
break;
}
case SOCK_FLOAT:
case SOCK_VECTOR:
case SOCK_RGBA:
case SOCK_BOOLEAN:
case SOCK_INT:
case SOCK_STRING:
case __SOCK_MESH:
case SOCK_CUSTOM:
case SOCK_SHADER:
case SOCK_EMITTERS:
case SOCK_EVENTS:
case SOCK_FORCES:
case SOCK_CONTROL_FLOW:
break;
}
FOREACH_FINALIZE_VOID;
}
static void library_foreach_rigidbodyworldSceneLooper(struct RigidBodyWorld *UNUSED(rbw),
ID **id_pointer,
void *user_data,
@@ -1016,7 +1051,6 @@ static void library_foreach_ID_link(Main *bmain,
case ID_NT: {
bNodeTree *ntree = (bNodeTree *)id;
bNode *node;
bNodeSocket *sock;
CALLBACK_INVOKE(ntree->gpd, IDWALK_CB_USER);
@@ -1024,19 +1058,19 @@ static void library_foreach_ID_link(Main *bmain,
CALLBACK_INVOKE_ID(node->id, IDWALK_CB_USER);
library_foreach_idproperty_ID_link(&data, node->prop, IDWALK_CB_USER);
for (sock = node->inputs.first; sock; sock = sock->next) {
library_foreach_idproperty_ID_link(&data, sock->prop, IDWALK_CB_USER);
LISTBASE_FOREACH (bNodeSocket *, sock, &node->inputs) {
library_foreach_node_socket(&data, sock);
}
for (sock = node->outputs.first; sock; sock = sock->next) {
library_foreach_idproperty_ID_link(&data, sock->prop, IDWALK_CB_USER);
LISTBASE_FOREACH (bNodeSocket *, sock, &node->outputs) {
library_foreach_node_socket(&data, sock);
}
}
for (sock = ntree->inputs.first; sock; sock = sock->next) {
library_foreach_idproperty_ID_link(&data, sock->prop, IDWALK_CB_USER);
LISTBASE_FOREACH (bNodeSocket *, sock, &ntree->inputs) {
library_foreach_node_socket(&data, sock);
}
for (sock = ntree->outputs.first; sock; sock = sock->next) {
library_foreach_idproperty_ID_link(&data, sock->prop, IDWALK_CB_USER);
LISTBASE_FOREACH (bNodeSocket *, sock, &ntree->outputs) {
library_foreach_node_socket(&data, sock);
}
break;
}
@@ -1264,6 +1298,7 @@ static void library_foreach_ID_link(Main *bmain,
for (i = 0; i < pointcloud->totcol; i++) {
CALLBACK_INVOKE(pointcloud->mat[i], IDWALK_CB_USER);
}
CALLBACK_INVOKE(pointcloud->source_simulation, IDWALK_CB_USER);
break;
}
case ID_VO: {
@@ -1284,6 +1319,15 @@ static void library_foreach_ID_link(Main *bmain,
}
break;
}
case ID_SIM: {
Simulation *simulation = (Simulation *)id;
if (simulation->nodetree) {
/* nodetree **are owned by IDs**, treat them as mere sub-data and not real ID! */
library_foreach_ID_as_subdata_link(
(ID **)&simulation->nodetree, callback, user_data, flag, &data);
}
break;
}
/* Nothing needed for those... */
case ID_IM:
@@ -1455,6 +1499,7 @@ bool BKE_library_id_can_use_idtype(ID *id_owner, const short id_type_used)
case ID_PAL:
case ID_PC:
case ID_CF:
case ID_SIM:
/* Those types never use/reference other IDs... */
return false;
case ID_IP:

View File

@@ -479,6 +479,8 @@ ListBase *which_libbase(Main *bmain, short type)
return &(bmain->pointclouds);
case ID_VO:
return &(bmain->volumes);
case ID_SIM:
return &(bmain->simulations);
}
return NULL;
}
@@ -554,6 +556,7 @@ int set_listbasepointers(Main *bmain, ListBase **lb)
lb[INDEX_ID_WS] = &(bmain->workspaces); /* before wm, so it's freed after it! */
lb[INDEX_ID_WM] = &(bmain->wm);
lb[INDEX_ID_MSK] = &(bmain->masks);
lb[INDEX_ID_SIM] = &(bmain->simulations);
lb[INDEX_ID_NULL] = NULL;

View File

@@ -37,6 +37,7 @@
#include "DNA_material_types.h"
#include "DNA_node_types.h"
#include "DNA_scene_types.h"
#include "DNA_simulation_types.h"
#include "DNA_texture_types.h"
#include "DNA_world_types.h"
@@ -66,7 +67,9 @@
#include "NOD_common.h"
#include "NOD_composite.h"
#include "NOD_function.h"
#include "NOD_shader.h"
#include "NOD_simulation.h"
#include "NOD_socket.h"
#include "NOD_texture.h"
@@ -86,7 +89,9 @@ static void ntree_set_typeinfo(bNodeTree *ntree, bNodeTreeType *typeinfo);
static void node_socket_copy(bNodeSocket *sock_dst, const bNodeSocket *sock_src, const int flag);
static void free_localized_node_groups(bNodeTree *ntree);
static void node_free_node(bNodeTree *ntree, bNode *node);
static void node_socket_interface_free(bNodeTree *UNUSED(ntree), bNodeSocket *sock);
static void node_socket_interface_free(bNodeTree *UNUSED(ntree),
bNodeSocket *sock,
const bool do_id_user);
static void ntree_init_data(ID *id)
{
@@ -229,12 +234,12 @@ static void ntree_free_data(ID *id)
/* free interface sockets */
for (sock = ntree->inputs.first; sock; sock = nextsock) {
nextsock = sock->next;
node_socket_interface_free(ntree, sock);
node_socket_interface_free(ntree, sock, false);
MEM_freeN(sock);
}
for (sock = ntree->outputs.first; sock; sock = nextsock) {
nextsock = sock->next;
node_socket_interface_free(ntree, sock);
node_socket_interface_free(ntree, sock, false);
MEM_freeN(sock);
}
@@ -744,6 +749,66 @@ static bNodeSocket *make_socket(bNodeTree *ntree,
return sock;
}
static void socket_id_user_increment(bNodeSocket *sock)
{
switch ((eNodeSocketDatatype)sock->type) {
case SOCK_OBJECT: {
bNodeSocketValueObject *default_value = sock->default_value;
id_us_plus(&default_value->value->id);
break;
}
case SOCK_IMAGE: {
bNodeSocketValueImage *default_value = sock->default_value;
id_us_plus(&default_value->value->id);
break;
}
case SOCK_FLOAT:
case SOCK_VECTOR:
case SOCK_RGBA:
case SOCK_BOOLEAN:
case SOCK_INT:
case SOCK_STRING:
case __SOCK_MESH:
case SOCK_CUSTOM:
case SOCK_SHADER:
case SOCK_EMITTERS:
case SOCK_EVENTS:
case SOCK_FORCES:
case SOCK_CONTROL_FLOW:
break;
}
}
static void socket_id_user_decrement(bNodeSocket *sock)
{
switch ((eNodeSocketDatatype)sock->type) {
case SOCK_OBJECT: {
bNodeSocketValueObject *default_value = sock->default_value;
id_us_min(&default_value->value->id);
break;
}
case SOCK_IMAGE: {
bNodeSocketValueImage *default_value = sock->default_value;
id_us_min(&default_value->value->id);
break;
}
case SOCK_FLOAT:
case SOCK_VECTOR:
case SOCK_RGBA:
case SOCK_BOOLEAN:
case SOCK_INT:
case SOCK_STRING:
case __SOCK_MESH:
case SOCK_CUSTOM:
case SOCK_SHADER:
case SOCK_EMITTERS:
case SOCK_EVENTS:
case SOCK_FORCES:
case SOCK_CONTROL_FLOW:
break;
}
}
void nodeModifySocketType(
bNodeTree *ntree, bNode *UNUSED(node), bNodeSocket *sock, int type, int subtype)
{
@@ -755,6 +820,7 @@ void nodeModifySocketType(
}
if (sock->default_value) {
socket_id_user_decrement(sock);
MEM_freeN(sock->default_value);
sock->default_value = NULL;
}
@@ -858,6 +924,18 @@ const char *nodeStaticSocketType(int type, int subtype)
return "NodeSocketString";
case SOCK_SHADER:
return "NodeSocketShader";
case SOCK_OBJECT:
return "NodeSocketObject";
case SOCK_IMAGE:
return "NodeSocketImage";
case SOCK_EMITTERS:
return "NodeSocketEmitters";
case SOCK_EVENTS:
return "NodeSocketEvents";
case SOCK_FORCES:
return "NodeSocketForces";
case SOCK_CONTROL_FLOW:
return "NodeSocketControlFlow";
}
return NULL;
}
@@ -919,6 +997,18 @@ const char *nodeStaticSocketInterfaceType(int type, int subtype)
return "NodeSocketInterfaceString";
case SOCK_SHADER:
return "NodeSocketInterfaceShader";
case SOCK_OBJECT:
return "NodeSocketInterfaceObject";
case SOCK_IMAGE:
return "NodeSocketInterfaceImage";
case SOCK_EMITTERS:
return "NodeSocketInterfaceEmitters";
case SOCK_EVENTS:
return "NodeSocketInterfaceEvents";
case SOCK_FORCES:
return "NodeSocketInterfaceForces";
case SOCK_CONTROL_FLOW:
return "NodeSocketInterfaceControlFlow";
}
return NULL;
}
@@ -977,6 +1067,9 @@ static void node_socket_free(bNodeTree *UNUSED(ntree),
}
if (sock->default_value) {
if (do_id_user) {
socket_id_user_decrement(sock);
}
MEM_freeN(sock->default_value);
}
}
@@ -1263,6 +1356,10 @@ static void node_socket_copy(bNodeSocket *sock_dst, const bNodeSocket *sock_src,
if (sock_src->default_value) {
sock_dst->default_value = MEM_dupallocN(sock_src->default_value);
if ((flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0) {
socket_id_user_increment(sock_dst);
}
}
sock_dst->stack_index = 0;
@@ -2083,6 +2180,13 @@ void nodeRemoveNode(Main *bmain, bNodeTree *ntree, bNode *node, bool do_id_user)
if (node->id) {
id_us_min(node->id);
}
LISTBASE_FOREACH (bNodeSocket *, sock, &node->inputs) {
socket_id_user_decrement(sock);
}
LISTBASE_FOREACH (bNodeSocket *, sock, &node->outputs) {
socket_id_user_decrement(sock);
}
}
/* Remove animation data. */
@@ -2102,13 +2206,18 @@ void nodeRemoveNode(Main *bmain, bNodeTree *ntree, bNode *node, bool do_id_user)
node_free_node(ntree, node);
}
static void node_socket_interface_free(bNodeTree *UNUSED(ntree), bNodeSocket *sock)
static void node_socket_interface_free(bNodeTree *UNUSED(ntree),
bNodeSocket *sock,
const bool do_id_user)
{
if (sock->prop) {
IDP_FreeProperty(sock->prop);
IDP_FreeProperty_ex(sock->prop, do_id_user);
}
if (sock->default_value) {
if (do_id_user) {
socket_id_user_decrement(sock);
}
MEM_freeN(sock->default_value);
}
}
@@ -2266,6 +2375,8 @@ bNodeTree **BKE_ntree_ptr_from_id(ID *id)
return &((Scene *)id)->nodetree;
case ID_LS:
return &((FreestyleLineStyle *)id)->nodetree;
case ID_SIM:
return &((Simulation *)id)->nodetree;
default:
return NULL;
}
@@ -2529,7 +2640,7 @@ void ntreeRemoveSocketInterface(bNodeTree *ntree, bNodeSocket *sock)
BLI_remlink(&ntree->inputs, sock);
BLI_remlink(&ntree->outputs, sock);
node_socket_interface_free(ntree, sock);
node_socket_interface_free(ntree, sock, true);
MEM_freeN(sock);
ntree->update |= NTREE_UPDATE_GROUP;
@@ -4114,6 +4225,31 @@ static void registerTextureNodes(void)
register_node_type_tex_proc_distnoise();
}
static void registerSimulationNodes(void)
{
register_node_type_sim_group();
register_node_type_sim_particle_simulation();
register_node_type_sim_force();
register_node_type_sim_set_particle_attribute();
register_node_type_sim_particle_birth_event();
register_node_type_sim_particle_time_step_event();
register_node_type_sim_execute_condition();
register_node_type_sim_multi_execute();
register_node_type_sim_particle_mesh_emitter();
register_node_type_sim_particle_mesh_collision_event();
register_node_type_sim_emit_particles();
register_node_type_sim_simulation_time();
register_node_type_sim_particle_attribute();
}
static void registerFunctionNodes(void)
{
register_node_type_fn_boolean_math();
register_node_type_fn_float_compare();
register_node_type_fn_switch();
}
void init_nodesystem(void)
{
nodetreetypes_hash = BLI_ghash_str_new("nodetreetypes_hash gh");
@@ -4127,6 +4263,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_type_frame();
register_node_type_reroute();
@@ -4136,6 +4273,8 @@ void init_nodesystem(void)
registerCompositNodes();
registerShaderNodes();
registerTextureNodes();
registerSimulationNodes();
registerFunctionNodes();
}
void free_nodesystem(void)
@@ -4192,6 +4331,7 @@ void BKE_node_tree_iter_init(struct NodeTreeIterStore *ntreeiter, struct Main *b
ntreeiter->light = bmain->lights.first;
ntreeiter->world = bmain->worlds.first;
ntreeiter->linestyle = bmain->linestyles.first;
ntreeiter->simulation = bmain->simulations.first;
}
bool BKE_node_tree_iter_step(struct NodeTreeIterStore *ntreeiter,
bNodeTree **r_nodetree,
@@ -4232,6 +4372,11 @@ bool BKE_node_tree_iter_step(struct NodeTreeIterStore *ntreeiter,
*r_id = (ID *)ntreeiter->linestyle;
ntreeiter->linestyle = ntreeiter->linestyle->id.next;
}
else if (ntreeiter->simulation) {
*r_nodetree = ntreeiter->simulation->nodetree;
*r_id = (ID *)ntreeiter->simulation;
ntreeiter->simulation = ntreeiter->simulation->id.next;
}
else {
return false;
}

View File

@@ -21,8 +21,11 @@
#include "MEM_guardedalloc.h"
#include "DNA_defaults.h"
#include "DNA_node_types.h"
#include "DNA_object_types.h"
#include "DNA_pointcloud_types.h"
#include "DNA_scene_types.h"
#include "DNA_simulation_types.h"
#include "BLI_listbase.h"
#include "BLI_math.h"
@@ -48,24 +51,6 @@
/* PointCloud datablock */
static void pointcloud_random(PointCloud *pointcloud)
{
pointcloud->totpoint = 400;
CustomData_realloc(&pointcloud->pdata, pointcloud->totpoint);
BKE_pointcloud_update_customdata_pointers(pointcloud);
RNG *rng = BLI_rng_new(0);
for (int i = 0; i < pointcloud->totpoint; i++) {
pointcloud->co[i][0] = 2.0f * BLI_rng_get_float(rng) - 1.0f;
pointcloud->co[i][1] = 2.0f * BLI_rng_get_float(rng) - 1.0f;
pointcloud->co[i][2] = 2.0f * BLI_rng_get_float(rng) - 1.0f;
pointcloud->radius[i] = 0.05f * BLI_rng_get_float(rng);
}
BLI_rng_free(rng);
}
static void pointcloud_init_data(ID *id)
{
PointCloud *pointcloud = (PointCloud *)id;
@@ -77,8 +62,6 @@ static void pointcloud_init_data(ID *id)
CustomData_add_layer(&pointcloud->pdata, CD_LOCATION, CD_CALLOC, NULL, pointcloud->totpoint);
CustomData_add_layer(&pointcloud->pdata, CD_RADIUS, CD_CALLOC, NULL, pointcloud->totpoint);
BKE_pointcloud_update_customdata_pointers(pointcloud);
pointcloud_random(pointcloud);
}
void *BKE_pointcloud_add(Main *bmain, const char *name)
@@ -184,7 +167,7 @@ void BKE_pointcloud_update_customdata_pointers(PointCloud *pointcloud)
PointCloud *BKE_pointcloud_new_for_eval(const PointCloud *pointcloud_src, int totpoint)
{
PointCloud *pointcloud_dst = BKE_id_new_nomain(ID_HA, NULL);
PointCloud *pointcloud_dst = BKE_id_new_nomain(ID_PT, NULL);
STRNCPY(pointcloud_dst->id.name, pointcloud_src->id.name);
pointcloud_dst->mat = MEM_dupallocN(pointcloud_src->mat);
@@ -212,11 +195,35 @@ PointCloud *BKE_pointcloud_copy_for_eval(struct PointCloud *pointcloud_src, bool
}
static PointCloud *pointcloud_evaluate_modifiers(struct Depsgraph *UNUSED(depsgraph),
struct Scene *UNUSED(scene),
Scene *scene,
Object *UNUSED(object),
PointCloud *pointcloud_input)
{
return pointcloud_input;
PointCloud *pointcloud = BKE_id_new_nomain(ID_PT, "New Point Cloud");
Simulation *simulation = pointcloud_input->source_simulation;
if (simulation == NULL) {
pointcloud->totpoint = 20;
}
else {
pointcloud->totpoint = BLI_listbase_count(&simulation->nodetree->nodes);
}
CustomData_realloc(&pointcloud->pdata, pointcloud->totpoint);
BKE_pointcloud_update_customdata_pointers(pointcloud);
RNG *rng = BLI_rng_new(45);
printf("PointCloud eval\n");
for (int i = 0; i < pointcloud->totpoint; i++) {
pointcloud->co[i][0] = 0.1f * scene->r.cfra;
pointcloud->co[i][1] = BLI_rng_get_float(rng);
pointcloud->co[i][2] = BLI_rng_get_float(rng);
pointcloud->radius[i] = 0.1f;
}
BLI_rng_free(rng);
return pointcloud;
}
void BKE_pointcloud_data_update(struct Depsgraph *depsgraph, struct Scene *scene, Object *object)

View File

@@ -0,0 +1,139 @@
/*
* 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.
*/
/** \file
* \ingroup bke
*/
#include "MEM_guardedalloc.h"
#include "DNA_ID.h"
#include "DNA_defaults.h"
#include "DNA_simulation_types.h"
#include "BLI_compiler_compat.h"
#include "BLI_listbase.h"
#include "BLI_math.h"
#include "BLI_string.h"
#include "BLI_utildefines.h"
#include "BKE_anim_data.h"
#include "BKE_animsys.h"
#include "BKE_idtype.h"
#include "BKE_lib_id.h"
#include "BKE_lib_query.h"
#include "BKE_lib_remap.h"
#include "BKE_main.h"
#include "BKE_node.h"
#include "BKE_simulation.h"
#include "NOD_simulation.h"
#include "BLT_translation.h"
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_query.h"
struct SimulationRuntime {
};
static void simulation_init_data(ID *id)
{
Simulation *simulation = (Simulation *)id;
BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(simulation, id));
MEMCPY_STRUCT_AFTER(simulation, DNA_struct_default_get(Simulation), id);
}
static void simulation_copy_data(Main *bmain, ID *id_dst, const ID *id_src, const int flag)
{
Simulation *simulation_dst = (Simulation *)id_dst;
Simulation *simulation_src = (Simulation *)id_src;
/* We always need allocation of our private ID data. */
const int flag_private_id_data = flag & ~LIB_ID_CREATE_NO_ALLOCATE;
if (simulation_src->nodetree) {
BKE_id_copy_ex(bmain,
(ID *)simulation_src->nodetree,
(ID **)&simulation_dst->nodetree,
flag_private_id_data);
}
simulation_dst->runtime = nullptr;
}
static void simulation_make_local(Main *bmain, ID *id, const int flags)
{
BKE_lib_id_make_local_generic(bmain, id, flags);
}
static void simulation_free_data(ID *id)
{
Simulation *simulation = (Simulation *)id;
BKE_animdata_free(&simulation->id, false);
if (simulation->nodetree) {
ntreeFreeNestedTree(simulation->nodetree);
MEM_freeN(simulation->nodetree);
simulation->nodetree = nullptr;
}
if (simulation->runtime) {
delete simulation->runtime;
simulation->runtime = nullptr;
}
}
void *BKE_simulation_add(Main *bmain, const char *name)
{
Simulation *simulation = (Simulation *)BKE_libblock_alloc(bmain, ID_SIM, name, 0);
simulation_init_data(&simulation->id);
bNodeTree *ntree = ntreeAddTree(nullptr, "Simulation Nodetree", ntreeType_Simulation->idname);
simulation->nodetree = ntree;
return simulation;
}
IDTypeInfo IDType_ID_SIM = {
/* id_code */ ID_SIM,
/* id_filter */ FILTER_ID_SIM,
/* main_listbase_index */ INDEX_ID_SIM,
/* struct_size */ sizeof(Simulation),
/* name */ "Simulation",
/* name_plural */ "simulations",
/* translation_context */ BLT_I18NCONTEXT_ID_SIMULATION,
/* flags */ 0,
/* init_data */ simulation_init_data,
/* copy_data */ simulation_copy_data,
/* free_data */ simulation_free_data,
/* make_local */ simulation_make_local,
};
void BKE_simulation_eval(Depsgraph *depsgraph, Simulation *simulation, Scene *scene)
{
Simulation *simulation_orig = (Simulation *)DEG_get_original_id(&simulation->id);
if (simulation_orig->runtime == nullptr) {
simulation_orig->runtime = new SimulationRuntime();
}
SimulationRuntime &sim_runtime = *(SimulationRuntime *)simulation_orig->runtime;
int output_scene_frame = scene->r.cfra;
float output_scene_subframe = scene->r.subframe;
}

View File

@@ -86,6 +86,7 @@
#include "DNA_sdna_types.h"
#include "DNA_sequence_types.h"
#include "DNA_shader_fx_types.h"
#include "DNA_simulation_types.h"
#include "DNA_sound_types.h"
#include "DNA_space_types.h"
#include "DNA_speaker_types.h"
@@ -146,6 +147,7 @@
#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"
@@ -3595,6 +3597,45 @@ static void lib_link_workspace_instance_hook(FileData *fd, WorkSpaceInstanceHook
/** \name Read ID: Node Tree
* \{ */
static void lib_link_node_socket(FileData *fd, Library *lib, bNodeSocket *sock)
{
IDP_LibLinkProperty(sock->prop, fd);
switch ((eNodeSocketDatatype)sock->type) {
case SOCK_OBJECT: {
bNodeSocketValueObject *default_value = sock->default_value;
default_value->value = newlibadr(fd, lib, default_value->value);
break;
}
case SOCK_IMAGE: {
bNodeSocketValueImage *default_value = sock->default_value;
default_value->value = newlibadr(fd, lib, default_value->value);
break;
}
case SOCK_FLOAT:
case SOCK_VECTOR:
case SOCK_RGBA:
case SOCK_BOOLEAN:
case SOCK_INT:
case SOCK_STRING:
case __SOCK_MESH:
case SOCK_CUSTOM:
case SOCK_SHADER:
case SOCK_EMITTERS:
case SOCK_EVENTS:
case SOCK_FORCES:
case SOCK_CONTROL_FLOW:
break;
}
}
static void lib_link_node_sockets(FileData *fd, Library *lib, ListBase *sockets)
{
LISTBASE_FOREACH (bNodeSocket *, sock, sockets) {
lib_link_node_socket(fd, lib, sock);
}
}
/* Single node tree (also used for material/scene trees), ntree is not NULL */
static void lib_link_ntree(FileData *fd, Library *lib, bNodeTree *ntree)
{
@@ -3609,20 +3650,12 @@ static void lib_link_ntree(FileData *fd, Library *lib, bNodeTree *ntree)
node->id = newlibadr(fd, lib, node->id);
LISTBASE_FOREACH (bNodeSocket *, sock, &node->inputs) {
IDP_LibLinkProperty(sock->prop, fd);
}
LISTBASE_FOREACH (bNodeSocket *, sock, &node->outputs) {
IDP_LibLinkProperty(sock->prop, fd);
}
lib_link_node_sockets(fd, lib, &node->inputs);
lib_link_node_sockets(fd, lib, &node->outputs);
}
LISTBASE_FOREACH (bNodeSocket *, sock, &ntree->inputs) {
IDP_LibLinkProperty(sock->prop, fd);
}
LISTBASE_FOREACH (bNodeSocket *, sock, &ntree->outputs) {
IDP_LibLinkProperty(sock->prop, fd);
}
lib_link_node_sockets(fd, lib, &ntree->inputs);
lib_link_node_sockets(fd, lib, &ntree->outputs);
/* Set node->typeinfo pointers. This is done in lib linking, after the
* first versioning that can change types still without functions that
@@ -9098,6 +9131,7 @@ static void lib_link_pointcloud(FileData *fd, Main *UNUSED(main), PointCloud *po
for (int a = 0; a < pointcloud->totcol; a++) {
pointcloud->mat[a] = newlibadr(fd, pointcloud->id.lib, pointcloud->mat[a]);
}
pointcloud->source_simulation = newlibadr(fd, pointcloud->id.lib, pointcloud->source_simulation);
}
static void direct_link_pointcloud(FileData *fd, PointCloud *pointcloud)
@@ -9112,6 +9146,8 @@ static void direct_link_pointcloud(FileData *fd, PointCloud *pointcloud)
/* Materials */
pointcloud->mat = newdataadr(fd, pointcloud->mat);
test_pointer_array(fd, (void **)&pointcloud->mat);
pointcloud->batch_cache = NULL;
}
/** \} */
@@ -9144,6 +9180,25 @@ static void direct_link_volume(FileData *fd, Volume *volume)
/** \} */
/* -------------------------------------------------------------------- */
/** \name Read ID: Simulation
* \{ */
static void lib_link_simulation(FileData *UNUSED(fd),
Main *UNUSED(main),
Simulation *UNUSED(simulation))
{
}
static void direct_link_simulation(FileData *fd, Simulation *simulation)
{
simulation->adt = newdataadr(fd, simulation->adt);
direct_link_animdata(fd, simulation->adt);
simulation->runtime = NULL;
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name Read Library Data Block
* \{ */
@@ -9262,6 +9317,8 @@ static const char *dataname(short id_code)
return "Data from PT";
case ID_VO:
return "Data from VO";
case ID_SIM:
return "Data from SIM";
}
return "Data from Lib Block";
}
@@ -9413,6 +9470,9 @@ static bool direct_link_id(FileData *fd, Main *main, const int tag, ID *id, ID *
case ID_VO:
direct_link_volume(fd, (Volume *)id);
break;
case ID_SIM:
direct_link_simulation(fd, (Simulation *)id);
break;
}
return success;
@@ -10092,6 +10152,9 @@ static void lib_link_all(FileData *fd, Main *bmain)
case ID_AC:
lib_link_action(fd, bmain, (bAction *)id);
break;
case ID_SIM:
lib_link_simulation(fd, bmain, (Simulation *)id);
break;
case ID_IP:
/* XXX deprecated... still needs to be maintained for version patches still. */
lib_link_ipo(fd, bmain, (Ipo *)id);
@@ -10934,10 +10997,51 @@ static void expand_key(FileData *fd, Main *mainvar, Key *key)
expand_doit(fd, mainvar, key->ipo); // XXX deprecated - old animation system
}
static void expand_node_socket(FileData *fd, Main *mainvar, bNodeSocket *sock)
{
expand_idprops(fd, mainvar, sock->prop);
if (sock->default_value != NULL) {
switch ((eNodeSocketDatatype)sock->type) {
case SOCK_OBJECT: {
bNodeSocketValueObject *default_value = sock->default_value;
expand_doit(fd, mainvar, default_value->value);
break;
}
case SOCK_IMAGE: {
bNodeSocketValueImage *default_value = sock->default_value;
expand_doit(fd, mainvar, default_value->value);
break;
}
case SOCK_FLOAT:
case SOCK_VECTOR:
case SOCK_RGBA:
case SOCK_BOOLEAN:
case SOCK_INT:
case SOCK_STRING:
case __SOCK_MESH:
case SOCK_CUSTOM:
case SOCK_SHADER:
case SOCK_EMITTERS:
case SOCK_EVENTS:
case SOCK_FORCES:
case SOCK_CONTROL_FLOW:
break;
}
}
}
static void expand_node_sockets(FileData *fd, Main *mainvar, ListBase *sockets)
{
LISTBASE_FOREACH (bNodeSocket *, sock, sockets) {
expand_node_socket(fd, mainvar, sock);
}
}
static void expand_nodetree(FileData *fd, Main *mainvar, bNodeTree *ntree)
{
bNode *node;
bNodeSocket *sock;
if (ntree->gpd) {
expand_doit(fd, mainvar, ntree->gpd);
@@ -10950,20 +11054,12 @@ static void expand_nodetree(FileData *fd, Main *mainvar, bNodeTree *ntree)
expand_idprops(fd, mainvar, node->prop);
for (sock = node->inputs.first; sock; sock = sock->next) {
expand_idprops(fd, mainvar, sock->prop);
}
for (sock = node->outputs.first; sock; sock = sock->next) {
expand_idprops(fd, mainvar, sock->prop);
}
expand_node_sockets(fd, mainvar, &node->inputs);
expand_node_sockets(fd, mainvar, &node->outputs);
}
for (sock = ntree->inputs.first; sock; sock = sock->next) {
expand_idprops(fd, mainvar, sock->prop);
}
for (sock = ntree->outputs.first; sock; sock = sock->next) {
expand_idprops(fd, mainvar, sock->prop);
}
expand_node_sockets(fd, mainvar, &ntree->inputs);
expand_node_sockets(fd, mainvar, &ntree->outputs);
}
static void expand_texture(FileData *fd, Main *mainvar, Tex *tex)
@@ -11514,6 +11610,13 @@ static void expand_volume(FileData *fd, Main *mainvar, Volume *volume)
}
}
static void expand_simulation(FileData *fd, Main *mainvar, Simulation *simulation)
{
if (simulation->adt) {
expand_animdata(fd, mainvar, simulation->adt);
}
}
/**
* Set the callback func used over all ID data found by \a BLO_expand_main func.
*
@@ -11643,6 +11746,9 @@ void BLO_expand_main(void *fdhandle, Main *mainvar)
case ID_VO:
expand_volume(fd, mainvar, (Volume *)id);
break;
case ID_SIM:
expand_simulation(fd, mainvar, (Simulation *)id);
break;
default:
break;
}

View File

@@ -133,6 +133,7 @@
#include "DNA_sdna_types.h"
#include "DNA_sequence_types.h"
#include "DNA_shader_fx_types.h"
#include "DNA_simulation_types.h"
#include "DNA_sound_types.h"
#include "DNA_space_types.h"
#include "DNA_speaker_types.h"
@@ -990,9 +991,19 @@ static void write_node_socket_default_value(WriteData *wd, bNodeSocket *sock)
case SOCK_STRING:
writestruct(wd, DATA, bNodeSocketValueString, 1, sock->default_value);
break;
case SOCK_OBJECT:
writestruct(wd, DATA, bNodeSocketValueObject, 1, sock->default_value);
break;
case SOCK_IMAGE:
writestruct(wd, DATA, bNodeSocketValueImage, 1, sock->default_value);
break;
case __SOCK_MESH:
case SOCK_CUSTOM:
case SOCK_SHADER:
case SOCK_EMITTERS:
case SOCK_EVENTS:
case SOCK_FORCES:
case SOCK_CONTROL_FLOW:
BLI_assert(false);
break;
}
@@ -3858,6 +3869,24 @@ static void write_volume(WriteData *wd, Volume *volume, const void *id_address)
}
}
static void write_simulation(WriteData *wd, Simulation *simulation)
{
if (simulation->id.us > 0 || wd->use_memfile) {
writestruct(wd, ID_SIM, Simulation, 1, simulation);
write_iddata(wd, &simulation->id);
if (simulation->adt) {
write_animdata(wd, simulation->adt);
}
/* nodetree is integral part of simulation, no libdata */
if (simulation->nodetree) {
writestruct(wd, DATA, bNodeTree, 1, simulation->nodetree);
write_nodetree_nolib(wd, simulation->nodetree);
}
}
}
/* Keep it last of write_foodata functions. */
static void write_libraries(WriteData *wd, Main *main)
{
@@ -4185,6 +4214,9 @@ static bool write_file_handle(Main *mainvar,
case ID_VO:
write_volume(wd, (Volume *)id_buffer, id);
break;
case ID_SIM:
write_simulation(wd, (Simulation *)id);
break;
case ID_LI:
/* Do nothing, handled below - and should never be reached. */
BLI_assert(0);

View File

@@ -122,6 +122,7 @@ bool BLT_lang_is_ime_supported(void);
#define BLT_I18NCONTEXT_ID_IMAGE "Image"
/*#define BLT_I18NCONTEXT_ID_IPO "Ipo"*/ /* Deprecated */
#define BLT_I18NCONTEXT_ID_SHAPEKEY "Key"
#define BLT_I18NCONTEXT_ID_SIMULATION "Simulation"
#define BLT_I18NCONTEXT_ID_LIGHT "Light"
#define BLT_I18NCONTEXT_ID_LIBRARY "Library"
#define BLT_I18NCONTEXT_ID_LATTICE "Lattice"
@@ -202,6 +203,7 @@ typedef struct {
BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_SCENE, "id_scene"), \
BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_SCREEN, "id_screen"), \
BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_SEQUENCE, "id_sequence"), \
BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_SIMULATION, "id_simulation"), \
BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_SPEAKER, "id_speaker"), \
BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_SOUND, "id_sound"), \
BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_ID_TEXTURE, "id_texture"), \

View File

@@ -57,9 +57,11 @@ extern "C" {
#include "DNA_node_types.h"
#include "DNA_object_types.h"
#include "DNA_particle_types.h"
#include "DNA_pointcloud_types.h"
#include "DNA_rigidbody_types.h"
#include "DNA_scene_types.h"
#include "DNA_sequence_types.h"
#include "DNA_simulation_types.h"
#include "DNA_sound_types.h"
#include "DNA_speaker_types.h"
#include "DNA_texture_types.h"
@@ -96,6 +98,7 @@ extern "C" {
#include "BKE_scene.h"
#include "BKE_sequencer.h"
#include "BKE_shader_fx.h"
#include "BKE_simulation.h"
#include "BKE_sound.h"
#include "BKE_tracking.h"
#include "BKE_volume.h"
@@ -481,6 +484,9 @@ void DepsgraphNodeBuilder::build_id(ID *id)
case ID_SCE:
build_scene_parameters((Scene *)id);
break;
case ID_SIM:
build_simulation((Simulation *)id);
break;
default:
fprintf(stderr, "Unhandled ID %s\n", id->name);
BLI_assert(!"Should never happen");
@@ -1357,6 +1363,11 @@ void DepsgraphNodeBuilder::build_object_data_geometry_datablock(ID *obdata, bool
case ID_PT: {
op_node = add_operation_node(obdata, NodeType::GEOMETRY, OperationCode::GEOMETRY_EVAL);
op_node->set_as_entry();
PointCloud *pointcloud = (PointCloud *)obdata;
if (pointcloud->source_simulation) {
build_simulation(pointcloud->source_simulation);
}
break;
}
case ID_VO: {
@@ -1699,6 +1710,25 @@ void DepsgraphNodeBuilder::build_sound(bSound *sound)
build_parameters(&sound->id);
}
void DepsgraphNodeBuilder::build_simulation(Simulation *simulation)
{
if (built_map_.checkIsBuiltAndTag(simulation)) {
return;
}
Simulation *simulation_cow = get_cow_datablock(simulation);
Scene *scene_cow = get_cow_datablock(scene_);
add_operation_node(&simulation->id,
NodeType::PARAMETERS,
OperationCode::SIMULATION_EVAL,
function_bind(BKE_simulation_eval, _1, simulation_cow, scene_cow));
add_id_node(&simulation->id);
build_animdata(&simulation->id);
build_parameters(&simulation->id);
build_nodetree(simulation->nodetree);
}
void DepsgraphNodeBuilder::build_scene_sequencer(Scene *scene)
{
if (scene->ed == nullptr) {

View File

@@ -52,6 +52,7 @@ struct MovieClip;
struct Object;
struct ParticleSettings;
struct Scene;
struct Simulation;
struct Speaker;
struct Tex;
struct World;
@@ -217,6 +218,7 @@ class DepsgraphNodeBuilder : public DepsgraphBuilder {
virtual void build_lightprobe(LightProbe *probe);
virtual void build_speaker(Speaker *speaker);
virtual void build_sound(bSound *sound);
virtual void build_simulation(Simulation *simulation);
virtual void build_scene_sequencer(Scene *scene);
virtual void build_scene_audio(Scene *scene);
virtual void build_scene_speakers(Scene *scene, ViewLayer *view_layer);

View File

@@ -59,9 +59,11 @@ extern "C" {
#include "DNA_object_force_types.h"
#include "DNA_object_types.h"
#include "DNA_particle_types.h"
#include "DNA_pointcloud_types.h"
#include "DNA_rigidbody_types.h"
#include "DNA_scene_types.h"
#include "DNA_sequence_types.h"
#include "DNA_simulation_types.h"
#include "DNA_sound_types.h"
#include "DNA_speaker_types.h"
#include "DNA_texture_types.h"
@@ -558,6 +560,9 @@ void DepsgraphRelationBuilder::build_id(ID *id)
case ID_SCE:
build_scene_parameters((Scene *)id);
break;
case ID_SIM:
build_simulation((Simulation *)id);
break;
default:
fprintf(stderr, "Unhandled ID %s\n", id->name);
BLI_assert(!"Should never happen");
@@ -2159,8 +2164,16 @@ void DepsgraphRelationBuilder::build_object_data_geometry_datablock(ID *obdata)
}
case ID_HA:
break;
case ID_PT:
case ID_PT: {
PointCloud *pointcloud = (PointCloud *)obdata;
if (pointcloud->source_simulation != NULL) {
ComponentKey simulation_key(&pointcloud->source_simulation->id, NodeType::PARAMETERS);
ComponentKey geometry_key(obdata, NodeType::GEOMETRY);
add_relation(simulation_key, geometry_key, "Source Simulation");
build_simulation(pointcloud->source_simulation);
}
break;
}
case ID_VO: {
Volume *volume = (Volume *)obdata;
if (volume->is_sequence) {
@@ -2502,6 +2515,28 @@ void DepsgraphRelationBuilder::build_sound(bSound *sound)
build_parameters(&sound->id);
}
void DepsgraphRelationBuilder::build_simulation(Simulation *simulation)
{
if (built_map_.checkIsBuiltAndTag(simulation)) {
return;
}
build_animdata(&simulation->id);
build_parameters(&simulation->id);
TimeSourceKey time_key;
OperationKey simulation_key(
&simulation->id, NodeType::PARAMETERS, OperationCode::SIMULATION_EVAL);
add_relation(time_key, simulation_key, "Simulation time source");
OperationKey parameters_exit_key(
&simulation->id, NodeType::PARAMETERS, OperationCode::PARAMETERS_EXIT);
add_relation(simulation_key, parameters_exit_key, "Simulation exit relation");
build_nodetree(simulation->nodetree);
ComponentKey nodetree_key(&simulation->nodetree->id, NodeType::PARAMETERS);
add_relation(nodetree_key, simulation_key, "Simulation node tree");
}
void DepsgraphRelationBuilder::build_scene_sequencer(Scene *scene)
{
if (scene->ed == nullptr) {

View File

@@ -68,6 +68,7 @@ struct Object;
struct ParticleSettings;
struct ParticleSystem;
struct Scene;
struct Simulation;
struct Speaker;
struct Tex;
struct ViewLayer;
@@ -282,6 +283,7 @@ class DepsgraphRelationBuilder : public DepsgraphBuilder {
virtual void build_lightprobe(LightProbe *probe);
virtual void build_speaker(Speaker *speaker);
virtual void build_sound(bSound *sound);
virtual void build_simulation(Simulation *simulation);
virtual void build_scene_sequencer(Scene *scene);
virtual void build_scene_audio(Scene *scene);
virtual void build_scene_speakers(Scene *scene, ViewLayer *view_layer);

View File

@@ -193,6 +193,9 @@ const char *operationCodeAsString(OperationCode opcode)
/* instancing/duplication. */
case OperationCode::DUPLI:
return "DUPLI";
/* Simulation. */
case OperationCode::SIMULATION_EVAL:
return "SIMULATION_EVAL";
}
BLI_assert(!"Unhandled operation code, should never happen.");
return "UNKNOWN";

View File

@@ -197,6 +197,9 @@ enum class OperationCode {
/* Duplication/instancing system. --------------------------------------- */
DUPLI,
/* Simulation. ---------------------------------------------------------- */
SIMULATION_EVAL,
};
const char *operationCodeAsString(OperationCode opcode);

View File

@@ -134,7 +134,7 @@ static void pointcloud_batch_cache_ensure_pos(Object *ob, PointCloudBatchCache *
/* initialize vertex format */
pos_id = GPU_vertformat_attr_add(&format, "pointcloud_pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
radius_id = GPU_vertformat_attr_add(
&format, "pointcloud_radius", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
&format, "pointcloud_radius", GPU_COMP_F32, 1, GPU_FETCH_FLOAT);
}
GPU_VERTBUF_DISCARD_SAFE(cache->pos);

View File

@@ -51,6 +51,7 @@
#include "DNA_pointcloud_types.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "DNA_simulation_types.h"
#include "DNA_space_types.h"
#include "DNA_speaker_types.h"
#include "DNA_volume_types.h"
@@ -3033,6 +3034,83 @@ static bAnimChannelType ACF_DSVOLUME = {
acf_dsvolume_setting_ptr /* pointer for setting */
};
/* Simulation Expander ----------------------------------------- */
static int acf_dssimulation_icon(bAnimListElem *UNUSED(ale))
{
/* TODO: Use correct icon. */
return ICON_PHYSICS;
}
static int acf_dssimulation_setting_flag(bAnimContext *UNUSED(ac),
eAnimChannel_Settings setting,
bool *neg)
{
/* clear extra return data first */
*neg = false;
switch (setting) {
case ACHANNEL_SETTING_EXPAND: /* expanded */
return SIM_DS_EXPAND;
case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */
return ADT_NLA_EVAL_OFF;
case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */
*neg = true;
return ADT_CURVES_NOT_VISIBLE;
case ACHANNEL_SETTING_SELECT: /* selected */
return ADT_UI_SELECTED;
default: /* unsupported */
return 0;
}
}
static void *acf_dssimulation_setting_ptr(bAnimListElem *ale,
eAnimChannel_Settings setting,
short *type)
{
Simulation *simulation = (Simulation *)ale->data;
/* clear extra return data first */
*type = 0;
switch (setting) {
case ACHANNEL_SETTING_EXPAND: /* expanded */
return GET_ACF_FLAG_PTR(simulation->flag, type);
case ACHANNEL_SETTING_SELECT: /* selected */
case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */
case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */
if (simulation->adt)
return GET_ACF_FLAG_PTR(simulation->adt->flag, type);
return NULL;
default: /* unsupported */
return NULL;
}
}
static bAnimChannelType ACF_DSSIMULATION = {
"Simulation Expander", /* type name */
ACHANNEL_ROLE_EXPANDER, /* role */
acf_generic_dataexpand_color, /* backdrop color */
acf_generic_dataexpand_backdrop, /* backdrop */
acf_generic_indention_1, /* indent level */
acf_generic_basic_offset, /* offset */
acf_generic_idblock_name, /* name */
acf_generic_idblock_name_prop, /* name prop */
acf_dssimulation_icon, /* icon */
acf_generic_dataexpand_setting_valid, /* has setting */
acf_dssimulation_setting_flag, /* flag for setting */
acf_dssimulation_setting_ptr /* pointer for setting */
};
/* GPencil Expander ------------------------------------------- */
// TODO: just get this from RNA?
@@ -4049,6 +4127,7 @@ static void ANIM_init_channel_typeinfo_data(void)
animchannelTypeInfo[type++] = &ACF_DSHAIR; /* Hair Channel */
animchannelTypeInfo[type++] = &ACF_DSPOINTCLOUD; /* PointCloud Channel */
animchannelTypeInfo[type++] = &ACF_DSVOLUME; /* Volume Channel */
animchannelTypeInfo[type++] = &ACF_DSSIMULATION; /* Simulation Channel */
animchannelTypeInfo[type++] = &ACF_SHAPEKEY; /* ShapeKey */

View File

@@ -138,7 +138,8 @@ void ANIM_set_active_channel(bAnimContext *ac,
case ANIMTYPE_DSMCLIP:
case ANIMTYPE_DSHAIR:
case ANIMTYPE_DSPOINTCLOUD:
case ANIMTYPE_DSVOLUME: {
case ANIMTYPE_DSVOLUME:
case ANIMTYPE_DSSIMULATION: {
/* need to verify that this data is valid for now */
if (ale->adt) {
ACHANNEL_SET_FLAG(ale->adt, ACHANNEL_SETFLAG_CLEAR, ADT_UI_ACTIVE);
@@ -194,7 +195,8 @@ void ANIM_set_active_channel(bAnimContext *ac,
case ANIMTYPE_DSMCLIP:
case ANIMTYPE_DSHAIR:
case ANIMTYPE_DSPOINTCLOUD:
case ANIMTYPE_DSVOLUME: {
case ANIMTYPE_DSVOLUME:
case ANIMTYPE_DSSIMULATION: {
/* need to verify that this data is valid for now */
if (ale && ale->adt) {
ale->adt->flag |= ADT_UI_ACTIVE;
@@ -332,7 +334,8 @@ void ANIM_deselect_anim_channels(
case ANIMTYPE_DSMCLIP:
case ANIMTYPE_DSHAIR:
case ANIMTYPE_DSPOINTCLOUD:
case ANIMTYPE_DSVOLUME: {
case ANIMTYPE_DSVOLUME:
case ANIMTYPE_DSSIMULATION: {
if ((ale->adt) && (ale->adt->flag & ADT_UI_SELECTED)) {
sel = ACHANNEL_SETFLAG_CLEAR;
}
@@ -428,7 +431,8 @@ void ANIM_deselect_anim_channels(
case ANIMTYPE_DSMCLIP:
case ANIMTYPE_DSHAIR:
case ANIMTYPE_DSPOINTCLOUD:
case ANIMTYPE_DSVOLUME: {
case ANIMTYPE_DSVOLUME:
case ANIMTYPE_DSSIMULATION: {
/* need to verify that this data is valid for now */
if (ale->adt) {
ACHANNEL_SET_FLAG(ale->adt, sel, ADT_UI_SELECTED);
@@ -2964,7 +2968,8 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index,
case ANIMTYPE_DSMCLIP:
case ANIMTYPE_DSHAIR:
case ANIMTYPE_DSPOINTCLOUD:
case ANIMTYPE_DSVOLUME: {
case ANIMTYPE_DSVOLUME:
case ANIMTYPE_DSSIMULATION: {
/* sanity checking... */
if (ale->adt) {
/* select/deselect */

View File

@@ -67,6 +67,7 @@
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "DNA_sequence_types.h"
#include "DNA_simulation_types.h"
#include "DNA_space_types.h"
#include "DNA_speaker_types.h"
#include "DNA_userdef_types.h"
@@ -826,6 +827,18 @@ static bAnimListElem *make_new_animlistelem(void *data,
ale->adt = BKE_animdata_from_id(data);
break;
}
case ANIMTYPE_DSSIMULATION: {
Simulation *simulation = (Simulation *)data;
AnimData *adt = simulation->adt;
ale->flag = FILTER_SIMULATION_OBJD(simulation);
ale->key_data = (adt) ? adt->action : NULL;
ale->datatype = ALE_ACT;
ale->adt = BKE_animdata_from_id(data);
break;
}
case ANIMTYPE_DSSKEY: {
Key *key = (Key *)data;
AnimData *adt = key->adt;

View File

@@ -229,6 +229,7 @@ typedef enum eAnim_ChannelType {
ANIMTYPE_DSHAIR,
ANIMTYPE_DSPOINTCLOUD,
ANIMTYPE_DSVOLUME,
ANIMTYPE_DSSIMULATION,
ANIMTYPE_SHAPEKEY,
@@ -356,6 +357,8 @@ typedef enum eAnimFilter_Flags {
#define FILTER_HAIR_OBJD(ha) (CHECK_TYPE_INLINE(ha, Hair *), ((ha->flag & HA_DS_EXPAND)))
#define FILTER_POINTS_OBJD(pt) (CHECK_TYPE_INLINE(pt, PointCloud *), ((pt->flag & PT_DS_EXPAND)))
#define FILTER_VOLUME_OBJD(vo) (CHECK_TYPE_INLINE(vo, Volume *), ((vo->flag & VO_DS_EXPAND)))
#define FILTER_SIMULATION_OBJD(sim) \
(CHECK_TYPE_INLINE(sim, Simulation *), ((sim->flag & SIM_DS_EXPAND)))
/* Variable use expanders */
#define FILTER_NTREE_DATA(ntree) \
(CHECK_TYPE_INLINE(ntree, bNodeTree *), (((ntree)->flag & NTREE_DS_EXPAND)))

View File

@@ -94,6 +94,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);
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

@@ -2326,6 +2326,9 @@ int UI_idcode_icon_get(const int idcode)
return ICON_WORLD_DATA;
case ID_WS:
return ICON_WORKSPACE;
case ID_SIM:
/* TODO: Use correct icon. */
return ICON_PHYSICS;
default:
return ICON_NONE;
}

View File

@@ -681,6 +681,8 @@ static const char *template_id_browse_tip(const StructRNA *type)
return N_("Browse Point Cloud Data to be linked");
case ID_VO:
return N_("Browse Volume Data to be linked");
case ID_SIM:
return N_("Browser Simulation to be linked");
}
}
return N_("Browse ID data to be linked");
@@ -746,7 +748,8 @@ static uiBut *template_id_def_new_but(uiBlock *block,
BLT_I18NCONTEXT_ID_LIGHTPROBE,
BLT_I18NCONTEXT_ID_HAIR,
BLT_I18NCONTEXT_ID_POINTCLOUD,
BLT_I18NCONTEXT_ID_VOLUME, );
BLT_I18NCONTEXT_ID_VOLUME,
BLT_I18NCONTEXT_ID_SIMULATION, );
/* Note: BLT_I18N_MSGID_MULTI_CTXT takes a maximum number of parameters,
* check the definition to see if a new call must be added when the limit
* is exceeded. */

View File

@@ -630,6 +630,7 @@ static int gather_frames_to_render_for_id(LibraryIDLinkCallbackData *cb_data)
case ID_HA: /* Hair */
case ID_PT: /* PointCloud */
case ID_VO: /* Volume */
case ID_SIM: /* Simulation */
break;
/* Blacklist: */

View File

@@ -143,7 +143,8 @@ bool nla_panel_context(const bContext *C,
case ANIMTYPE_PALETTE:
case ANIMTYPE_DSHAIR:
case ANIMTYPE_DSPOINTCLOUD:
case ANIMTYPE_DSVOLUME: {
case ANIMTYPE_DSVOLUME:
case ANIMTYPE_DSSIMULATION: {
/* for these channels, we only do AnimData */
if (ale->adt && adt_ptr) {
ID *id;

View File

@@ -193,7 +193,8 @@ static int mouse_nla_channels(
case ANIMTYPE_PALETTE:
case ANIMTYPE_DSHAIR:
case ANIMTYPE_DSPOINTCLOUD:
case ANIMTYPE_DSVOLUME: {
case ANIMTYPE_DSVOLUME:
case ANIMTYPE_DSSIMULATION: {
/* sanity checking... */
if (ale->adt) {
/* select/deselect */

View File

@@ -75,6 +75,10 @@ if(WITH_OPENIMAGEDENOISE)
add_definitions(-DWITH_OPENIMAGEDENOISE)
endif()
if (WITH_NEW_SIMULATION_TYPE)
add_definitions(-DWITH_NEW_SIMULATION_TYPE)
endif()
add_definitions(${GL_DEFINITIONS})
blender_add_lib(bf_editor_space_node "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")

View File

@@ -69,6 +69,7 @@
#include "NOD_composite.h"
#include "NOD_shader.h"
#include "NOD_simulation.h"
#include "NOD_texture.h"
#include "node_intern.h" /* own include */
@@ -3122,6 +3123,88 @@ static void node_texture_set_butfunc(bNodeType *ntype)
}
}
/* ****************** BUTTON CALLBACKS FOR SIMULATION NODES ***************** */
static void node_simulation_buts_particle_simulation(uiLayout *layout,
bContext *UNUSED(C),
PointerRNA *ptr)
{
uiItemR(layout, ptr, "name", 0, "", ICON_NONE);
}
static void node_simulation_buts_particle_time_step_event(uiLayout *layout,
bContext *UNUSED(C),
PointerRNA *ptr)
{
uiItemR(layout, ptr, "mode", 0, "", ICON_NONE);
}
static void node_simulation_buts_particle_attribute(uiLayout *layout,
bContext *UNUSED(C),
PointerRNA *ptr)
{
uiItemR(layout, ptr, "data_type", 0, "", ICON_NONE);
}
static void node_simulation_buts_set_particle_attribute(uiLayout *layout,
bContext *UNUSED(C),
PointerRNA *ptr)
{
uiItemR(layout, ptr, "data_type", 0, "", ICON_NONE);
}
static void node_simulation_set_butfunc(bNodeType *ntype)
{
switch (ntype->type) {
case SIM_NODE_PARTICLE_SIMULATION:
ntype->draw_buttons = node_simulation_buts_particle_simulation;
break;
case SIM_NODE_PARTICLE_TIME_STEP_EVENT:
ntype->draw_buttons = node_simulation_buts_particle_time_step_event;
break;
case SIM_NODE_PARTICLE_ATTRIBUTE:
ntype->draw_buttons = node_simulation_buts_particle_attribute;
break;
case SIM_NODE_SET_PARTICLE_ATTRIBUTE:
ntype->draw_buttons = node_simulation_buts_set_particle_attribute;
break;
}
}
/* ****************** BUTTON CALLBACKS FOR FUNCTION NODES ***************** */
static void node_function_buts_boolean_math(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
{
uiItemR(layout, ptr, "operation", 0, "", ICON_NONE);
}
static void node_function_buts_float_compare(uiLayout *layout,
bContext *UNUSED(C),
PointerRNA *ptr)
{
uiItemR(layout, ptr, "operation", 0, "", ICON_NONE);
}
static void node_function_buts_switch(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
{
uiItemR(layout, ptr, "data_type", 0, "", ICON_NONE);
}
static void node_function_set_butfunc(bNodeType *ntype)
{
switch (ntype->type) {
case FN_NODE_BOOLEAN_MATH:
ntype->draw_buttons = node_function_buts_boolean_math;
break;
case FN_NODE_FLOAT_COMPARE:
ntype->draw_buttons = node_function_buts_float_compare;
break;
case FN_NODE_SWITCH:
ntype->draw_buttons = node_function_buts_switch;
break;
}
}
/* ****** init draw callbacks for all tree types, only called in usiblender.c, once ************ */
static void node_property_update_default(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
@@ -3230,6 +3313,8 @@ 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_function_set_butfunc(ntype);
/* define update callbacks for socket properties */
node_template_properties_update(ntype);
@@ -3240,6 +3325,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. */
}
void ED_init_custom_node_type(bNodeType *ntype)
@@ -3268,6 +3354,12 @@ static const float std_node_socket_colors[][4] = {
{0.0, 0.0, 0.0, 1.0}, /*__SOCK_MESH (deprecated) */
{0.06, 0.52, 0.15, 1.0}, /* SOCK_INT */
{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.80, 0.80, 0.20, 1.0}, /* SOCK_EMITTERS */
{0.80, 0.20, 0.80, 1.0}, /* SOCK_EVENTS */
{0.20, 0.80, 0.80, 1.0}, /* SOCK_FORCES */
{0.30, 0.30, 0.30, 1.0}, /* SOCK_CONTROL_FLOW */
};
/* common color callbacks for standard types */
@@ -3385,6 +3477,14 @@ static void std_node_socket_draw(
uiItemR(row, ptr, "default_value", 0, "", 0);
break;
}
case SOCK_OBJECT: {
uiItemR(layout, ptr, "default_value", 0, text, 0);
break;
}
case SOCK_IMAGE: {
uiItemR(layout, ptr, "default_value", 0, text, 0);
break;
}
default:
node_socket_button_label(C, layout, ptr, node_ptr, text);
break;

View File

@@ -90,36 +90,9 @@ void ED_node_tree_update(const bContext *C)
}
}
/* id is supposed to contain a node tree */
static bNodeTree *node_tree_from_ID(ID *id)
{
if (id) {
short idtype = GS(id->name);
switch (idtype) {
case ID_NT:
return (bNodeTree *)id;
case ID_MA:
return ((Material *)id)->nodetree;
case ID_LA:
return ((Light *)id)->nodetree;
case ID_WO:
return ((World *)id)->nodetree;
case ID_SCE:
return ((Scene *)id)->nodetree;
case ID_TE:
return ((Tex *)id)->nodetree;
case ID_LS:
return ((FreestyleLineStyle *)id)->nodetree;
}
}
return NULL;
}
void ED_node_tag_update_id(ID *id)
{
bNodeTree *ntree = node_tree_from_ID(id);
bNodeTree *ntree = ntreeFromID(id);
if (id == NULL || ntree == NULL) {
return;
}

View File

@@ -69,6 +69,7 @@
#include "NOD_composite.h"
#include "NOD_shader.h"
#include "NOD_simulation.h"
#include "NOD_texture.h"
#include "node_intern.h" /* own include */
@@ -438,6 +439,11 @@ bool ED_node_is_texture(struct SpaceNode *snode)
return STREQ(snode->tree_idname, ntreeType_Texture->idname);
}
bool ED_node_is_simulation(struct SpaceNode *snode)
{
return STREQ(snode->tree_idname, ntreeType_Simulation->idname);
}
/* assumes nothing being done in ntree yet, sets the default in/out node */
/* called from shading buttons or header */
void ED_node_shader_default(const bContext *C, ID *id)

View File

@@ -69,7 +69,8 @@ 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, "TextureNodeTree") ||
STREQ(snode->tree_idname, "SimulationNodeTree")) {
return true;
}
}
@@ -85,7 +86,8 @@ static bool node_group_operator_editable(bContext *C)
* Disabled otherwise to allow pynodes define their own operators
* with same keymap.
*/
if (ED_node_is_shader(snode) || ED_node_is_compositor(snode) || ED_node_is_texture(snode)) {
if (ED_node_is_shader(snode) || ED_node_is_compositor(snode) || ED_node_is_texture(snode) ||
ED_node_is_simulation(snode)) {
return true;
}
}
@@ -111,6 +113,9 @@ static const char *group_node_idname(bContext *C)
else if (ED_node_is_texture(snode)) {
return "TextureNodeGroup";
}
else if (ED_node_is_simulation(snode)) {
return "SimulationNodeGroup";
}
return "";
}

View File

@@ -939,6 +939,11 @@ static void node_space_subtype_item_extend(bContext *C, EnumPropertyItem **item,
bool free;
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++) {
#ifndef WITH_NEW_SIMULATION_TYPE
if (STREQ(item_iter->identifier, "SimulationNodeTree")) {
continue;
}
#endif
RNA_enum_item_add(item, totitem, item_iter);
}
if (free) {

View File

@@ -2581,6 +2581,10 @@ TreeElementIcon tree_element_get_icon(TreeStoreElem *tselem, TreeElement *te)
case ID_PC:
data.icon = ICON_CURVE_BEZCURVE;
break;
case ID_SIM:
/* TODO: Use correct icon. */
data.icon = ICON_PHYSICS;
break;
default:
break;
}

View File

@@ -108,7 +108,8 @@ typedef struct TreeElementIcon {
ID_LP, \
ID_HA, \
ID_PT, \
ID_VO) || /* Only in 'blendfile' mode ... :/ */ \
ID_VO, \
ID_SIM) || /* Only in 'blendfile' mode ... :/ */ \
ELEM(GS((_id)->name), \
ID_SCR, \
ID_WM, \

View File

@@ -39,6 +39,7 @@
#include "DNA_pointcloud_types.h"
#include "DNA_scene_types.h"
#include "DNA_sequence_types.h"
#include "DNA_simulation_types.h"
#include "DNA_volume_types.h"
#include "DNA_world_types.h"
@@ -160,6 +161,7 @@ static void set_operation_types(SpaceOutliner *soops,
case ID_HA:
case ID_PT:
case ID_VO:
case ID_SIM:
is_standard_id = true;
break;
case ID_WM:

View File

@@ -46,6 +46,7 @@
#include "DNA_pointcloud_types.h"
#include "DNA_scene_types.h"
#include "DNA_sequence_types.h"
#include "DNA_simulation_types.h"
#include "DNA_speaker_types.h"
#include "DNA_volume_types.h"
#include "DNA_world_types.h"
@@ -773,6 +774,13 @@ static void outliner_add_id_contents(SpaceOutliner *soops,
outliner_add_element(soops, &te->subtree, volume, te, TSE_ANIM_DATA, 0);
break;
}
case ID_SIM: {
Simulation *simulation = (Simulation *)id;
if (outliner_animdata_test(simulation->adt)) {
outliner_add_element(soops, &te->subtree, simulation, te, TSE_ANIM_DATA, 0);
}
break;
}
default:
break;
}

View File

@@ -408,6 +408,7 @@ typedef enum ID_Type {
ID_HA = MAKE_ID2('H', 'A'), /* Hair */
ID_PT = MAKE_ID2('P', 'T'), /* PointCloud */
ID_VO = MAKE_ID2('V', 'O'), /* Volume */
ID_SIM = MAKE_ID2('S', 'I'), /* Simulation */
} ID_Type;
/* Only used as 'placeholder' in .blend files for directly linked data-blocks. */
@@ -707,6 +708,7 @@ typedef enum IDRecalcFlag {
#define FILTER_ID_HA (1ULL << 32)
#define FILTER_ID_PT (1ULL << 33)
#define FILTER_ID_VO (1ULL << 34)
#define FILTER_ID_SIM (1ULL << 35)
#define FILTER_ID_ALL \
(FILTER_ID_AC | FILTER_ID_AR | FILTER_ID_BR | FILTER_ID_CA | FILTER_ID_CU | FILTER_ID_GD | \
@@ -714,7 +716,7 @@ typedef enum IDRecalcFlag {
FILTER_ID_MB | FILTER_ID_MC | FILTER_ID_ME | FILTER_ID_MSK | FILTER_ID_NT | FILTER_ID_OB | \
FILTER_ID_PA | FILTER_ID_PAL | FILTER_ID_PC | FILTER_ID_SCE | FILTER_ID_SPK | FILTER_ID_SO | \
FILTER_ID_TE | FILTER_ID_TXT | FILTER_ID_VF | FILTER_ID_WO | FILTER_ID_CF | FILTER_ID_WS | \
FILTER_ID_LP | FILTER_ID_HA | FILTER_ID_PT | FILTER_ID_VO)
FILTER_ID_LP | FILTER_ID_HA | FILTER_ID_PT | FILTER_ID_VO | FILTER_ID_SIM)
/* IMPORTANT: this enum matches the order currently use in set_listbasepointers,
* keep them in sync! */
@@ -758,6 +760,7 @@ enum {
INDEX_ID_WS,
INDEX_ID_WM,
INDEX_ID_MSK,
INDEX_ID_SIM,
INDEX_ID_NULL,
INDEX_ID_MAX,
};

View File

@@ -154,6 +154,12 @@ typedef enum eNodeSocketDatatype {
__SOCK_MESH = 5, /* deprecated */
SOCK_INT = 6,
SOCK_STRING = 7,
SOCK_OBJECT = 8,
SOCK_IMAGE = 9,
SOCK_EMITTERS = 10,
SOCK_EVENTS = 11,
SOCK_FORCES = 12,
SOCK_CONTROL_FLOW = 13,
} eNodeSocketDatatype;
/* socket shape */
@@ -498,6 +504,7 @@ typedef struct bNodeTree {
#define NTREE_SHADER 0
#define NTREE_COMPOSIT 1
#define NTREE_TEXTURE 2
#define NTREE_SIMULATION 3
/* ntree->init, flag */
#define NTREE_TYPE_INIT 1
@@ -565,6 +572,14 @@ typedef struct bNodeSocketValueString {
char value[1024];
} bNodeSocketValueString;
typedef struct bNodeSocketValueObject {
struct Object *value;
} bNodeSocketValueObject;
typedef struct bNodeSocketValueImage {
struct Image *value;
} bNodeSocketValueImage;
/* data structs, for node->storage */
enum {
CMP_NODE_MASKTYPE_ADD = 0,
@@ -1293,6 +1308,23 @@ enum {
NODE_VECTOR_MATH_TANGENT = 23,
};
/* Boolean math node operations. */
enum {
NODE_BOOLEAN_MATH_AND = 0,
NODE_BOOLEAN_MATH_OR = 1,
NODE_BOOLEAN_MATH_NOT = 2,
};
/* Float compare node operations. */
enum {
NODE_FLOAT_COMPARE_LESS_THAN = 0,
NODE_FLOAT_COMPARE_LESS_EQUAL = 1,
NODE_FLOAT_COMPARE_GREATER_THAN = 2,
NODE_FLOAT_COMPARE_GREATER_EQUAL = 3,
NODE_FLOAT_COMPARE_EQUAL = 4,
NODE_FLOAT_COMPARE_NOT_EQUAL = 5,
};
/* Clamp node types. */
enum {
NODE_CLAMP_MINMAX = 0,
@@ -1385,4 +1417,10 @@ typedef enum NodeShaderOutputTarget {
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;
#endif

View File

@@ -24,6 +24,8 @@
#include "DNA_ID.h"
#include "DNA_customdata_types.h"
struct Simulation;
typedef struct PointCloud {
ID id;
struct AnimData *adt; /* animation data (must be immediately after id) */
@@ -45,6 +47,8 @@ typedef struct PointCloud {
short totcol;
short _pad3[3];
struct Simulation *source_simulation;
/* Draw Cache */
void *batch_cache;
} PointCloud;

View File

@@ -0,0 +1,40 @@
/*
* 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.
*/
/** \file
* \ingroup DNA
*/
#ifndef __DNA_SIMULATION_DEFAULTS_H__
#define __DNA_SIMULATION_DEFAULTS_H__
/* Struct members on own line. */
/* clang-format off */
/* -------------------------------------------------------------------- */
/** \name Simulation Struct
* \{ */
#define _DNA_DEFAULT_Simulation \
{ \
.flag = 0, \
}
/** \} */
/* clang-format on */
#endif /* __DNA_SIMULATION_DEFAULTS_H__ */

View File

@@ -0,0 +1,43 @@
/*
* 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.
*/
/** \file
* \ingroup DNA
*/
#ifndef __DNA_SIMULATION_TYPES_H__
#define __DNA_SIMULATION_TYPES_H__
#include "DNA_ID.h"
typedef struct Simulation {
ID id;
struct AnimData *adt; /* animation data (must be immediately after id) */
struct bNodeTree *nodetree;
int flag;
int _pad1[1];
void *runtime;
} Simulation;
/* Simulation.flag */
enum {
SIM_DS_EXPAND = (1 << 0),
};
#endif /* __DNA_SIMULATION_TYPES_H__ */

View File

@@ -146,6 +146,7 @@ set(SRC
../DNA_object_defaults.h
../DNA_pointcloud_defaults.h
../DNA_scene_defaults.h
../DNA_simulation_defaults.h
../DNA_speaker_defaults.h
../DNA_texture_defaults.h
../DNA_vec_defaults.h

View File

@@ -71,6 +71,7 @@
#include "DNA_object_types.h"
#include "DNA_pointcloud_types.h"
#include "DNA_scene_types.h"
#include "DNA_simulation_types.h"
#include "DNA_space_types.h"
#include "DNA_speaker_types.h"
#include "DNA_texture_types.h"
@@ -93,6 +94,7 @@
#include "DNA_object_defaults.h"
#include "DNA_pointcloud_defaults.h"
#include "DNA_scene_defaults.h"
#include "DNA_simulation_defaults.h"
#include "DNA_speaker_defaults.h"
#include "DNA_texture_defaults.h"
#include "DNA_volume_defaults.h"
@@ -150,6 +152,9 @@ SDNA_DEFAULT_DECL_STRUCT(PointCloud);
SDNA_DEFAULT_DECL_STRUCT(Scene);
SDNA_DEFAULT_DECL_STRUCT(ToolSettings);
/* DNA_simulation_defaults.h */
SDNA_DEFAULT_DECL_STRUCT(Simulation);
/* DNA_speaker_defaults.h */
SDNA_DEFAULT_DECL_STRUCT(Speaker);
@@ -260,6 +265,9 @@ const void *DNA_default_table[SDNA_TYPE_MAX] = {
SDNA_DEFAULT_DECL_EX(GP_Sculpt_Settings, ToolSettings.gp_sculpt),
SDNA_DEFAULT_DECL_EX(GP_Sculpt_Guide, ToolSettings.gp_sculpt.guide),
/* DNA_simulation_defaults.h */
SDNA_DEFAULT_DECL(Simulation),
/* DNA_speaker_defaults.h */
SDNA_DEFAULT_DECL(Speaker),

View File

@@ -136,6 +136,7 @@ static const char *includefiles[] = {
"DNA_hair_types.h",
"DNA_pointcloud_types.h",
"DNA_volume_types.h",
"DNA_simulation_types.h",
/* see comment above before editing! */
@@ -1590,6 +1591,7 @@ int main(int argc, char **argv)
#include "DNA_sdna_types.h"
#include "DNA_sequence_types.h"
#include "DNA_shader_fx_types.h"
#include "DNA_simulation_types.h"
#include "DNA_sound_types.h"
#include "DNA_space_types.h"
#include "DNA_speaker_types.h"

View File

@@ -259,6 +259,7 @@ extern StructRNA RNA_FreestyleLineStyle;
extern StructRNA RNA_FreestyleModuleSettings;
extern StructRNA RNA_FreestyleSettings;
extern StructRNA RNA_Function;
extern StructRNA RNA_FunctionNode;
extern StructRNA RNA_GPencilFrame;
extern StructRNA RNA_GPencilInterpolateSettings;
extern StructRNA RNA_GPencilLayer;
@@ -548,6 +549,9 @@ extern StructRNA RNA_ShrinkwrapConstraint;
extern StructRNA RNA_ShrinkwrapModifier;
extern StructRNA RNA_SimpleDeformModifier;
extern StructRNA RNA_SimplifyGpencilModifier;
extern StructRNA RNA_Simulation;
extern StructRNA RNA_SimulationNode;
extern StructRNA RNA_SimulationNodeTree;
extern StructRNA RNA_SkinModifier;
extern StructRNA RNA_SmoothGpencilModifier;
extern StructRNA RNA_SmoothModifier;

View File

@@ -191,6 +191,8 @@ extern const EnumPropertyItem rna_enum_node_socket_in_out_items[];
extern const EnumPropertyItem rna_enum_node_math_items[];
extern const EnumPropertyItem rna_enum_mapping_type_items[];
extern const EnumPropertyItem rna_enum_node_vec_math_items[];
extern const EnumPropertyItem rna_enum_node_boolean_math_items[];
extern const EnumPropertyItem rna_enum_node_float_compare_items[];
extern const EnumPropertyItem rna_enum_node_filter_items[];
extern const EnumPropertyItem rna_enum_node_map_range_items[];
extern const EnumPropertyItem rna_enum_node_clamp_items[];

View File

@@ -103,6 +103,13 @@ if(WITH_NEW_OBJECT_TYPES)
)
endif()
if (WITH_NEW_SIMULATION_TYPE)
list(APPEND DEFSRC
rna_simulation.c
)
endif()
set(APISRC
rna_action_api.c
rna_animation_api.c
@@ -342,6 +349,11 @@ if(WITH_NEW_OBJECT_TYPES)
add_definitions(-DWITH_NEW_OBJECT_TYPES)
endif()
if (WITH_NEW_SIMULATION_TYPE)
add_definitions(-DWITH_NEW_SIMULATION_TYPE)
endif()
# Build makesrna executable
blender_include_dirs(
.

View File

@@ -4302,6 +4302,9 @@ static RNAProcessItem PROCESS_ITEMS[] = {
{"rna_screen.c", NULL, RNA_def_screen},
{"rna_sculpt_paint.c", NULL, RNA_def_sculpt_paint},
{"rna_sequencer.c", "rna_sequencer_api.c", RNA_def_sequencer},
#ifdef WITH_NEW_SIMULATION_TYPE
{"rna_simulation.c", NULL, RNA_def_simulation},
#endif
{"rna_space.c", "rna_space_api.c", RNA_def_space},
{"rna_speaker.c", NULL, RNA_def_speaker},
{"rna_test.c", NULL, RNA_def_test},

View File

@@ -71,6 +71,9 @@ const EnumPropertyItem rna_enum_id_type_items[] = {
{ID_PA, "PARTICLE", ICON_PARTICLE_DATA, "Particle", ""},
{ID_LP, "LIGHT_PROBE", ICON_LIGHTPROBE_CUBEMAP, "Light Probe", ""},
{ID_SCE, "SCENE", ICON_SCENE_DATA, "Scene", ""},
#ifdef WITH_NEW_SIMULATION_TYPE
{ID_SIM, "SIMULATION", ICON_PHYSICS, "Simulation", ""}, /* TODO: Use correct icon. */
#endif
{ID_SO, "SOUND", ICON_SOUND, "Sound", ""},
{ID_SPK, "SPEAKER", ICON_SPEAKER, "Speaker", ""},
{ID_TXT, "TEXT", ICON_TEXT, "Text", ""},
@@ -303,6 +306,11 @@ short RNA_type_to_ID_code(const StructRNA *type)
if (base_type == &RNA_Screen) {
return ID_SCR;
}
# ifdef WITH_NEW_SIMULATION_TYPE
if (base_type == &RNA_Simulation) {
return ID_SIM;
}
# endif
if (base_type == &RNA_Sound) {
return ID_SO;
}
@@ -405,6 +413,12 @@ StructRNA *ID_code_to_RNA_type(short idcode)
return &RNA_Scene;
case ID_SCR:
return &RNA_Screen;
case ID_SIM:
# ifdef WITH_NEW_SIMULATION_TYPE
return &RNA_Simulation;
# else
return &RNA_ID;
# endif
case ID_SO:
return &RNA_Sound;
case ID_SPK:

View File

@@ -185,6 +185,7 @@ void RNA_def_render(struct BlenderRNA *brna);
void RNA_def_rigidbody(struct BlenderRNA *brna);
void RNA_def_rna(struct BlenderRNA *brna);
void RNA_def_scene(struct BlenderRNA *brna);
void RNA_def_simulation(struct BlenderRNA *brna);
void RNA_def_view_layer(struct BlenderRNA *brna);
void RNA_def_screen(struct BlenderRNA *brna);
void RNA_def_sculpt_paint(struct BlenderRNA *brna);
@@ -449,6 +450,7 @@ void RNA_def_main_lightprobes(BlenderRNA *brna, PropertyRNA *cprop);
void RNA_def_main_hairs(BlenderRNA *brna, PropertyRNA *cprop);
void RNA_def_main_pointclouds(BlenderRNA *brna, PropertyRNA *cprop);
void RNA_def_main_volumes(BlenderRNA *brna, PropertyRNA *cprop);
void RNA_def_main_simulations(BlenderRNA *brna, PropertyRNA *cprop);
/* ID Properties */

View File

@@ -134,6 +134,9 @@ RNA_MAIN_LISTBASE_FUNCS_DEF(pointclouds)
RNA_MAIN_LISTBASE_FUNCS_DEF(scenes)
RNA_MAIN_LISTBASE_FUNCS_DEF(screens)
RNA_MAIN_LISTBASE_FUNCS_DEF(shapekeys)
# ifdef WITH_NEW_SIMULATION_TYPE
RNA_MAIN_LISTBASE_FUNCS_DEF(simulations)
# endif
RNA_MAIN_LISTBASE_FUNCS_DEF(sounds)
RNA_MAIN_LISTBASE_FUNCS_DEF(speakers)
RNA_MAIN_LISTBASE_FUNCS_DEF(texts)
@@ -402,6 +405,14 @@ void RNA_def_main(BlenderRNA *brna)
"Volumes",
"Volume data-blocks",
RNA_def_main_volumes},
# ifdef WITH_NEW_SIMULATION_TYPE
{"simulations",
"Simulation",
"rna_Main_simulations_begin",
"Simulations",
"Simulation data-blocks",
RNA_def_main_simulations},
# endif
{NULL, NULL, NULL, NULL, NULL, NULL},
};

View File

@@ -69,6 +69,7 @@
# include "BKE_particle.h"
# include "BKE_pointcloud.h"
# include "BKE_scene.h"
# include "BKE_simulation.h"
# include "BKE_sound.h"
# include "BKE_speaker.h"
# include "BKE_text.h"
@@ -98,6 +99,7 @@
# include "DNA_node_types.h"
# include "DNA_particle_types.h"
# include "DNA_pointcloud_types.h"
# include "DNA_simulation_types.h"
# include "DNA_sound_types.h"
# include "DNA_speaker_types.h"
# include "DNA_text_types.h"
@@ -738,6 +740,18 @@ static Volume *rna_Main_volumes_new(Main *bmain, const char *name)
return volume;
}
# ifdef WITH_NEW_SIMULATION_TYPE
static Simulation *rna_Main_simulations_new(Main *bmain, const char *name)
{
char safe_name[MAX_ID_NAME - 2];
rna_idname_validate(name, safe_name);
Simulation *simulation = BKE_simulation_add(bmain, safe_name);
id_us_min(&simulation->id);
return simulation;
}
# endif
/* tag functions, all the same */
# define RNA_MAIN_ID_TAG_FUNCS_DEF(_func_name, _listbase_name, _id_type) \
static void rna_Main_##_func_name##_tag(Main *bmain, bool value) \
@@ -785,6 +799,9 @@ RNA_MAIN_ID_TAG_FUNCS_DEF(hairs, hairs, ID_HA)
RNA_MAIN_ID_TAG_FUNCS_DEF(pointclouds, pointclouds, ID_PT)
# endif
RNA_MAIN_ID_TAG_FUNCS_DEF(volumes, volumes, ID_VO)
# ifdef WITH_NEW_SIMULATION_TYPE
RNA_MAIN_ID_TAG_FUNCS_DEF(simulations, simulations, ID_SIM)
# endif
# undef RNA_MAIN_ID_TAG_FUNCS_DEF
@@ -2304,4 +2321,44 @@ void RNA_def_main_volumes(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
}
void RNA_def_main_simulations(BlenderRNA *brna, PropertyRNA *cprop)
{
StructRNA *srna;
FunctionRNA *func;
PropertyRNA *parm;
RNA_def_property_srna(cprop, "BlendDataSimulations");
srna = RNA_def_struct(brna, "BlendDataSimulations", NULL);
RNA_def_struct_sdna(srna, "Main");
RNA_def_struct_ui_text(srna, "Main Simulations", "Collection of simulations");
func = RNA_def_function(srna, "new", "rna_Main_simulations_new");
RNA_def_function_ui_description(func, "Add a new simulation to the main database");
parm = RNA_def_string(func, "name", "Simulation", 0, "", "New name for the data-block");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
/* return type */
parm = RNA_def_pointer(func, "simulation", "Simulation", "", "New simulation data-block");
RNA_def_function_return(func, parm);
func = RNA_def_function(srna, "remove", "rna_Main_ID_remove");
RNA_def_function_flag(func, FUNC_USE_REPORTS);
RNA_def_function_ui_description(func, "Remove a simulation from the current blendfile");
parm = RNA_def_pointer(func, "simulation", "Simulation", "", "Simulation to remove");
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
RNA_def_boolean(
func, "do_unlink", true, "", "Unlink all usages of this simulation before deleting it");
RNA_def_boolean(func,
"do_id_user",
true,
"",
"Decrement user counter of all datablocks used by this simulation data");
RNA_def_boolean(
func, "do_ui_user", true, "", "Make sure interface does not reference this simulation data");
func = RNA_def_function(srna, "tag", "rna_Main_simulations_tag");
parm = RNA_def_boolean(func, "value", 0, "Value", "");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
}
#endif

View File

@@ -81,6 +81,35 @@ static const EnumPropertyItem node_socket_type_items[] = {
{SOCK_STRING, "STRING", 0, "String", ""},
{SOCK_RGBA, "RGBA", 0, "RGBA", ""},
{SOCK_SHADER, "SHADER", 0, "Shader", ""},
{SOCK_OBJECT, "OBJECT", 0, "Object", ""},
{SOCK_IMAGE, "IMAGE", 0, "Image", ""},
{SOCK_EMITTERS, "EMITTERS", 0, "Emitters", ""},
{SOCK_EVENTS, "EVENTS", 0, "Events", ""},
{SOCK_FORCES, "FORCES", 0, "Forces", ""},
{SOCK_CONTROL_FLOW, "CONTROL_FLOW", 0, "Control Flow", ""},
{0, NULL, 0, NULL, NULL},
};
static const EnumPropertyItem particle_attribute_socket_type_items[] = {
{SOCK_FLOAT, "FLOAT", 0, "Float", ""},
{SOCK_INT, "INT", 0, "Int", ""},
{SOCK_BOOLEAN, "BOOLEAN", 0, "Boolean", ""},
{SOCK_VECTOR, "VECTOR", 0, "Vector", ""},
{SOCK_RGBA, "RGBA", 0, "Color", ""},
{SOCK_OBJECT, "OBJECT", 0, "Object", ""},
{SOCK_IMAGE, "IMAGE", 0, "Image", ""},
{0, NULL, 0, NULL, NULL},
};
static const EnumPropertyItem node_socket_data_type_items[] = {
{SOCK_FLOAT, "FLOAT", 0, "Float", ""},
{SOCK_INT, "INT", 0, "Int", ""},
{SOCK_BOOLEAN, "BOOLEAN", 0, "Boolean", ""},
{SOCK_VECTOR, "VECTOR", 0, "Vector", ""},
{SOCK_STRING, "STRING", 0, "String", ""},
{SOCK_RGBA, "RGBA", 0, "Color", ""},
{SOCK_OBJECT, "OBJECT", 0, "Object", ""},
{SOCK_IMAGE, "IMAGE", 0, "Image", ""},
{0, NULL, 0, NULL, NULL},
};
@@ -244,6 +273,47 @@ const EnumPropertyItem rna_enum_node_vec_math_items[] = {
{0, NULL, 0, NULL, NULL},
};
const EnumPropertyItem rna_enum_node_boolean_math_items[] = {
{NODE_BOOLEAN_MATH_AND, "AND", 0, "And", "Outputs true only when both inputs are true"},
{NODE_BOOLEAN_MATH_OR, "OR", 0, "Or", "Outputs or when at least one of the inputs is true"},
{NODE_BOOLEAN_MATH_NOT, "NOT", 0, "Not", "Outputs the opposite of the input"},
{0, NULL, 0, NULL, NULL},
};
const EnumPropertyItem rna_enum_node_float_compare_items[] = {
{NODE_FLOAT_COMPARE_LESS_THAN,
"LESS_THAN",
0,
"A < B",
"True when the first input is smaller than second input"},
{NODE_FLOAT_COMPARE_LESS_EQUAL,
"LESS_EQUAL",
0,
"A <= B",
"True when the first input is smaller than the second input or equal"},
{NODE_FLOAT_COMPARE_GREATER_THAN,
"GREATER_THAN",
0,
"A > B",
"True when the first input is greater than the second input"},
{NODE_FLOAT_COMPARE_GREATER_EQUAL,
"GREATER_EQUAL",
0,
"A >= B",
"True when the first input is greater than the second input or equal"},
{NODE_FLOAT_COMPARE_EQUAL,
"EQUAL",
0,
"A = B",
"True when both inputs are approximately equal"},
{NODE_FLOAT_COMPARE_NOT_EQUAL,
"NOT_EQUAL",
0,
"A != B",
"True when both inputs are not approximately equal"},
{0, NULL, 0, NULL, NULL},
};
const EnumPropertyItem rna_enum_node_map_range_items[] = {
{NODE_MAP_RANGE_LINEAR,
"LINEAR",
@@ -669,6 +739,34 @@ static const EnumPropertyItem *rna_node_static_type_itemf(bContext *UNUSED(C),
# undef DefNode
}
if (RNA_struct_is_a(ptr->type, &RNA_SimulationNode)) {
# define DefNode(Category, ID, DefFunc, EnumName, StructName, UIName, UIDesc) \
if (STREQ(#Category, "SimulationNode")) { \
tmp.value = ID; \
tmp.identifier = EnumName; \
tmp.name = UIName; \
tmp.description = UIDesc; \
tmp.icon = ICON_NONE; \
RNA_enum_item_add(&item, &totitem, &tmp); \
}
# include "../../nodes/NOD_static_types.h"
# undef DefNode
}
if (RNA_struct_is_a(ptr->type, &RNA_FunctionNode)) {
# define DefNode(Category, ID, DefFunc, EnumName, StructName, UIName, UIDesc) \
if (STREQ(#Category, "FunctionNode")) { \
tmp.value = ID; \
tmp.identifier = EnumName; \
tmp.name = UIName; \
tmp.description = UIDesc; \
tmp.icon = ICON_NONE; \
RNA_enum_item_add(&item, &totitem, &tmp); \
}
# include "../../nodes/NOD_static_types.h"
# undef DefNode
}
RNA_enum_item_end(&item, &totitem);
*r_free = true;
@@ -1785,6 +1883,50 @@ 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)
{
bNodeType *nt = rna_Node_register_base(
bmain, reports, &RNA_SimulationNode, data, identifier, validate, call, free);
if (!nt) {
return NULL;
}
nodeRegisterType(nt);
/* update while blender is running */
WM_main_add_notifier(NC_NODE | NA_EDITED, NULL);
return nt->rna_ext.srna;
}
static StructRNA *rna_FunctionNode_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_FunctionNode, data, identifier, validate, call, free);
if (!nt) {
return NULL;
}
nodeRegisterType(nt);
/* update while blender is running */
WM_main_add_notifier(NC_NODE | NA_EDITED, NULL);
return nt->rna_ext.srna;
}
static IDProperty *rna_Node_idprops(PointerRNA *ptr, bool create)
{
bNode *node = ptr->data;
@@ -3581,6 +3723,15 @@ static void rna_ShaderNode_socket_update(Main *bmain, Scene *scene, PointerRNA *
rna_Node_update(bmain, scene, ptr);
}
static void rna_FunctionNode_socket_update(Main *bmain, Scene *scene, PointerRNA *ptr)
{
bNodeTree *ntree = (bNodeTree *)ptr->owner_id;
bNode *node = (bNode *)ptr->data;
nodeUpdate(ntree, node);
rna_Node_update(bmain, scene, ptr);
}
static void rna_CompositorNodeScale_update(Main *bmain, Scene *scene, PointerRNA *ptr)
{
bNodeTree *ntree = (bNodeTree *)ptr->owner_id;
@@ -3590,6 +3741,15 @@ static void rna_CompositorNodeScale_update(Main *bmain, Scene *scene, PointerRNA
rna_Node_update(bmain, scene, ptr);
}
static void rna_SimulationNode_socket_update(Main *bmain, Scene *scene, PointerRNA *ptr)
{
bNodeTree *ntree = (bNodeTree *)ptr->owner_id;
bNode *node = (bNode *)ptr->data;
nodeUpdate(ntree, node);
rna_Node_update(bmain, scene, ptr);
}
static PointerRNA rna_ShaderNodePointDensity_psys_get(PointerRNA *ptr)
{
bNode *node = ptr->data;
@@ -4016,6 +4176,39 @@ static void def_math(StructRNA *srna)
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
}
static void def_boolean_math(StructRNA *srna)
{
PropertyRNA *prop;
prop = RNA_def_property(srna, "operation", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "custom1");
RNA_def_property_enum_items(prop, rna_enum_node_boolean_math_items);
RNA_def_property_ui_text(prop, "Operation", "");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_FunctionNode_socket_update");
}
static void def_float_compare(StructRNA *srna)
{
PropertyRNA *prop;
prop = RNA_def_property(srna, "operation", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "custom1");
RNA_def_property_enum_items(prop, rna_enum_node_float_compare_items);
RNA_def_property_ui_text(prop, "Operation", "");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_FunctionNode_socket_update");
}
static void def_fn_switch(StructRNA *srna)
{
PropertyRNA *prop;
prop = RNA_def_property(srna, "data_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "custom1");
RNA_def_property_enum_items(prop, node_socket_data_type_items);
RNA_def_property_ui_text(prop, "Data Type", "Data type for inputs and outputs");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_FunctionNode_socket_update");
}
static void def_vector_math(StructRNA *srna)
{
PropertyRNA *prop;
@@ -7899,6 +8092,61 @@ static void def_tex_bricks(StructRNA *srna)
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
}
/* -- Simulation Nodes --------------------------------------------------------- */
static void def_sim_particle_time_step_event(StructRNA *srna)
{
static const EnumPropertyItem mode_items[] = {
{NODE_PARTICLE_TIME_STEP_EVENT_BEGIN,
"BEGIN",
0,
"Begin",
"Execute for every particle at the beginning of each time step"},
{NODE_PARTICLE_TIME_STEP_EVENT_END,
"END",
0,
"End",
"Execute for every particle at the end of each time step"},
{0, NULL, 0, NULL, NULL},
};
PropertyRNA *prop;
prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "custom1");
RNA_def_property_enum_items(prop, mode_items);
RNA_def_property_ui_text(prop, "Mode", "When in each time step is the event triggered");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
}
static void def_sim_particle_attribute(StructRNA *srna)
{
PropertyRNA *prop;
prop = RNA_def_property(srna, "data_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "custom1");
RNA_def_property_enum_items(prop, particle_attribute_socket_type_items);
RNA_def_property_ui_text(
prop,
"Data Type",
"Expected type of the attribute. A default value is returned if the type is not correct");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_SimulationNode_socket_update");
}
static void def_sim_set_particle_attribute(StructRNA *srna)
{
PropertyRNA *prop;
prop = RNA_def_property(srna, "data_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "custom1");
RNA_def_property_enum_items(prop, particle_attribute_socket_type_items);
RNA_def_property_ui_text(
prop,
"Data Type",
"Expected type of the attribute. Nothing is done if the type is not correct");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_SimulationNode_socket_update");
}
/* -------------------------------------------------------------------------- */
static void rna_def_shader_node(BlenderRNA *brna)
@@ -7936,6 +8184,26 @@ 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)
{
StructRNA *srna;
srna = RNA_def_struct(brna, "SimulationNode", "NodeInternal");
RNA_def_struct_ui_text(srna, "Simulation Node", "");
RNA_def_struct_sdna(srna, "bNode");
RNA_def_struct_register_funcs(srna, "rna_SimulationNode_register", "rna_Node_unregister", NULL);
}
static void rna_def_function_node(BlenderRNA *brna)
{
StructRNA *srna;
srna = RNA_def_struct(brna, "FunctionNode", "NodeInternal");
RNA_def_struct_ui_text(srna, "Function Node", "");
RNA_def_struct_sdna(srna, "bNode");
RNA_def_struct_register_funcs(srna, "rna_FunctionNode_register", "rna_Node_unregister", NULL);
}
/* -------------------------------------------------------------------------- */
static void rna_def_node_socket(BlenderRNA *brna)
@@ -8492,6 +8760,104 @@ static void rna_def_node_socket_virtual(BlenderRNA *brna, const char *identifier
RNA_def_struct_sdna(srna, "bNodeSocket");
}
static void rna_def_node_socket_object(BlenderRNA *brna,
const char *identifier,
const char *interface_idname)
{
StructRNA *srna;
PropertyRNA *prop;
srna = RNA_def_struct(brna, identifier, "NodeSocketStandard");
RNA_def_struct_ui_text(srna, "Object Node Socket", "Object socket of a node");
RNA_def_struct_sdna(srna, "bNodeSocket");
RNA_def_struct_sdna_from(srna, "bNodeSocketValueObject", "default_value");
prop = RNA_def_property(srna, "default_value", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "value");
RNA_def_property_struct_type(prop, "Object");
RNA_def_property_ui_text(prop, "Default Value", "Input value used for unconnected socket");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeSocketStandard_value_update");
RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_REFCOUNT | PROP_CONTEXT_UPDATE);
/* socket interface */
srna = RNA_def_struct(brna, interface_idname, "NodeSocketInterfaceStandard");
RNA_def_struct_ui_text(srna, "Object Node Socket Interface", "Object socket of a node");
RNA_def_struct_sdna(srna, "bNodeSocket");
RNA_def_struct_sdna_from(srna, "bNodeSocketValueObject", "default_value");
prop = RNA_def_property(srna, "default_value", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "value");
RNA_def_property_struct_type(prop, "Object");
RNA_def_property_ui_text(prop, "Default Value", "Input value used for unconnected socket");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeSocketInterface_update");
}
static void rna_def_node_socket_image(BlenderRNA *brna,
const char *identifier,
const char *interface_idname)
{
StructRNA *srna;
PropertyRNA *prop;
srna = RNA_def_struct(brna, identifier, "NodeSocketStandard");
RNA_def_struct_ui_text(srna, "Image Node Socket", "Image socket of a node");
RNA_def_struct_sdna(srna, "bNodeSocket");
RNA_def_struct_sdna_from(srna, "bNodeSocketValueImage", "default_value");
prop = RNA_def_property(srna, "default_value", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "value");
RNA_def_property_struct_type(prop, "Image");
RNA_def_property_ui_text(prop, "Default Value", "Input value used for unconnected socket");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeSocketStandard_value_update");
RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_REFCOUNT | PROP_CONTEXT_UPDATE);
/* socket interface */
srna = RNA_def_struct(brna, interface_idname, "NodeSocketInterfaceStandard");
RNA_def_struct_ui_text(srna, "Image Node Socket Interface", "Image socket of a node");
RNA_def_struct_sdna(srna, "bNodeSocket");
RNA_def_struct_sdna_from(srna, "bNodeSocketValueImage", "default_value");
prop = RNA_def_property(srna, "default_value", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "value");
RNA_def_property_struct_type(prop, "Image");
RNA_def_property_ui_text(prop, "Default Value", "Input value used for unconnected socket");
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeSocketInterface_update");
}
static void rna_def_node_socket_effector(BlenderRNA *brna,
const char *identifier,
const char *interface_idname)
{
StructRNA *srna;
srna = RNA_def_struct(brna, identifier, "NodeSocketStandard");
RNA_def_struct_ui_text(srna, "", "");
RNA_def_struct_sdna(srna, "bNodeSocket");
srna = RNA_def_struct(brna, interface_idname, "NodeSocketInterfaceStandard");
RNA_def_struct_ui_text(srna, "", "");
RNA_def_struct_sdna(srna, "bNodeSocket");
}
static void rna_def_node_socket_control_flow(BlenderRNA *brna,
const char *identifier,
const char *interface_idname)
{
StructRNA *srna;
srna = RNA_def_struct(brna, identifier, "NodeSocketStandard");
RNA_def_struct_ui_text(srna, "", "");
RNA_def_struct_sdna(srna, "bNodeSocket");
srna = RNA_def_struct(brna, interface_idname, "NodeSocketInterfaceStandard");
RNA_def_struct_ui_text(srna, "", "");
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,
@@ -8626,6 +8992,17 @@ static void rna_def_node_socket_standard_types(BlenderRNA *brna)
rna_def_node_socket_shader(brna, "NodeSocketShader", "NodeSocketInterfaceShader");
rna_def_node_socket_virtual(brna, "NodeSocketVirtual");
rna_def_node_socket_object(brna, "NodeSocketObject", "NodeSocketInterfaceObject");
rna_def_node_socket_image(brna, "NodeSocketImage", "NodeSocketInterfaceImage");
rna_def_node_socket_effector(brna, "NodeSocketEmitters", "NodeSocketInterfaceEmitters");
rna_def_node_socket_effector(brna, "NodeSocketEvents", "NodeSocketInterfaceEvents");
rna_def_node_socket_effector(brna, "NodeSocketForces", "NodeSocketInterfaceForces");
rna_def_node_socket_control_flow(
brna, "NodeSocketControlFlow", "NodeSocketInterfaceControlFlow");
}
static void rna_def_internal_node(BlenderRNA *brna)
@@ -9251,6 +9628,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"},
{0, NULL, 0, NULL, NULL},
};
@@ -9474,6 +9852,17 @@ static void rna_def_texture_nodetree(BlenderRNA *brna)
RNA_def_struct_ui_icon(srna, ICON_TEXTURE);
}
static void rna_def_simulation_nodetree(BlenderRNA *brna)
{
StructRNA *srna;
srna = RNA_def_struct(brna, "SimulationNodeTree", "NodeTree");
RNA_def_struct_ui_text(
srna, "Simulation Node Tree", "Node tree consisting of linked nodes used for simulations");
RNA_def_struct_sdna(srna, "bNodeTree");
RNA_def_struct_ui_icon(srna, ICON_PHYSICS); /* TODO: Use correct icon. */
}
static StructRNA *define_specific_node(BlenderRNA *brna,
const char *struct_name,
const char *base_name,
@@ -9560,6 +9949,8 @@ 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_function_node(brna);
rna_def_nodetree(brna);
@@ -9568,6 +9959,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);
# define DefNode(Category, ID, DefFunc, EnumName, StructName, UIName, UIDesc) \
{ \
@@ -9584,12 +9976,13 @@ void RNA_def_nodetree(BlenderRNA *brna)
*/
# include "../../nodes/NOD_static_types.h"
/* Node group types need to be defined for shader, compositor, texture nodes individually.
* Cannot use the static types header for this, since they share the same int id.
/* Node group types need to be defined for shader, compositor, texture, simulation 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);
def_custom_group(brna,
"ShaderNodeCustomGroup",
"ShaderNode",

View File

@@ -37,6 +37,7 @@
# include "BKE_pointcloud.h"
# include "DEG_depsgraph.h"
# include "DEG_depsgraph_build.h"
# include "WM_api.h"
# include "WM_types.h"
@@ -101,6 +102,16 @@ static void rna_PointCloud_update_data(struct Main *UNUSED(bmain),
}
}
static void rna_PointCloud_source_simulation_update(struct Main *bmain,
struct Scene *UNUSED(scene),
PointerRNA *ptr)
{
ID *id = ptr->owner_id;
DEG_relations_tag_update(bmain);
WM_main_add_notifier(NC_GEOM | ND_DATA, id);
}
#else
static void rna_def_point(BlenderRNA *brna)
@@ -156,6 +167,13 @@ static void rna_def_pointcloud(BlenderRNA *brna)
RNA_def_property_collection_funcs(
prop, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "rna_IDMaterials_assign_int");
/* source_simulation */
prop = RNA_def_property(srna, "source_simulation", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "Simulation");
RNA_def_property_ui_text(prop, "Source Simulation", "Simulation to define points source");
RNA_def_property_update(prop, 0, "rna_PointCloud_source_simulation_update");
RNA_def_property_flag(prop, PROP_EDITABLE);
/* common */
rna_def_animdata_common(srna);
}

View File

@@ -0,0 +1,56 @@
/*
* 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.
*/
/** \file
* \ingroup RNA
*/
#include <stdlib.h>
#include "RNA_define.h"
#include "RNA_enum_types.h"
#include "DNA_simulation_types.h"
#include "rna_internal.h"
#ifdef RNA_RUNTIME
#else
static void rna_def_simulation(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
srna = RNA_def_struct(brna, "Simulation", "ID");
RNA_def_struct_ui_text(srna, "Simulation", "Simulation data-block");
RNA_def_struct_ui_icon(srna, ICON_PHYSICS); /* TODO: Use correct icon. */
prop = RNA_def_property(srna, "node_tree", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "nodetree");
RNA_def_property_ui_text(prop, "Node Tree", "Node tree defining the simulation");
/* common */
rna_def_animdata_common(srna);
}
void RNA_def_simulation(BlenderRNA *brna)
{
rna_def_simulation(brna);
}
#endif

View File

@@ -45,6 +45,7 @@
#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"
@@ -2166,6 +2167,40 @@ static void rna_SpaceNodeEditor_node_tree_update(const bContext *C, PointerRNA *
ED_node_tree_update(C);
}
# ifdef WITH_NEW_SIMULATION_TYPE
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;
@@ -5521,6 +5556,13 @@ static void rna_def_fileselect_idfilter(BlenderRNA *brna)
"Show/hide Point Cloud data-blocks"},
# endif
{FILTER_ID_SCE, "filter_scene", ICON_SCENE_DATA, "Scenes", "Show Scene data-blocks"},
# ifdef WITH_NEW_SIMULATION_TYPE
{FILTER_ID_SIM,
"filter_simulation",
ICON_PHYSICS,
"Simulations",
"Show Simulation data-blocks"}, /* TODO: Use correct icon. */
# endif
{FILTER_ID_SPK, "filter_speaker", ICON_SPEAKER, "Speakers", "Show Speaker data-blocks"},
{FILTER_ID_SO, "filter_sound", ICON_SOUND, "Sounds", "Show Sound data-blocks"},
{FILTER_ID_TE, "filter_texture", ICON_TEXTURE_DATA, "Textures", "Show Texture data-blocks"},
@@ -6202,6 +6244,19 @@ 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_NEW_SIMULATION_TYPE
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

@@ -21,8 +21,10 @@
set(INC
.
composite
function
intern
shader
simulation
texture
../blenkernel
../blenlib
@@ -127,6 +129,11 @@ set(SRC
composite/node_composite_tree.c
composite/node_composite_util.c
function/nodes/node_fn_boolean_math.cc
function/nodes/node_fn_float_compare.cc
function/nodes/node_fn_switch.cc
function/node_function_util.cc
shader/nodes/node_shader_add_shader.c
shader/nodes/node_shader_ambient_occlusion.c
shader/nodes/node_shader_attribute.c
@@ -220,6 +227,22 @@ set(SRC
shader/node_shader_tree.c
shader/node_shader_util.c
simulation/nodes/node_sim_common.cc
simulation/nodes/node_sim_emit_particles.cc
simulation/nodes/node_sim_execute_condition.cc
simulation/nodes/node_sim_force.cc
simulation/nodes/node_sim_multi_execute.cc
simulation/nodes/node_sim_particle_attribute.cc
simulation/nodes/node_sim_particle_birth_event.cc
simulation/nodes/node_sim_particle_mesh_collision_event.cc
simulation/nodes/node_sim_particle_mesh_emitter.cc
simulation/nodes/node_sim_particle_simulation.cc
simulation/nodes/node_sim_particle_time_step_event.cc
simulation/nodes/node_sim_set_particle_attribute.cc
simulation/nodes/node_sim_simulation_time.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
@@ -252,12 +275,16 @@ set(SRC
intern/node_util.c
composite/node_composite_util.h
function/node_function_util.h
shader/node_shader_util.h
simulation/node_simulation_util.h
texture/node_texture_util.h
NOD_common.h
NOD_composite.h
NOD_function.h
NOD_shader.h
NOD_simulation.h
NOD_socket.h
NOD_static_types.h
NOD_texture.h

View File

@@ -26,6 +26,10 @@
#include "BKE_node.h"
#ifdef __cplusplus
extern "C" {
#endif
void register_node_type_frame(void);
void register_node_type_reroute(void);
@@ -42,4 +46,8 @@ struct bNodeSocket *node_group_output_find_socket(struct bNode *node, const char
void node_group_input_update(struct bNodeTree *ntree, struct bNode *node);
void node_group_output_update(struct bNodeTree *ntree, struct bNode *node);
#ifdef __cplusplus
}
#endif
#endif /* __NOD_COMMON_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.
*/
#ifndef __NOD_FUNCTION_H__
#define __NOD_FUNCTION_H__
#ifdef __cplusplus
extern "C" {
#endif
void register_node_type_fn_boolean_math(void);
void register_node_type_fn_float_compare(void);
void register_node_type_fn_switch(void);
#ifdef __cplusplus
}
#endif
#endif /* __NOD_FUNCTION_H__ */

View File

@@ -0,0 +1,47 @@
/*
* 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.
*/
#ifndef __NOD_SIMULATION_H__
#define __NOD_SIMULATION_H__
#ifdef __cplusplus
extern "C" {
#endif
extern struct bNodeTreeType *ntreeType_Simulation;
void register_node_tree_type_sim(void);
void register_node_type_sim_group(void);
void register_node_type_sim_particle_simulation(void);
void register_node_type_sim_force(void);
void register_node_type_sim_set_particle_attribute(void);
void register_node_type_sim_particle_birth_event(void);
void register_node_type_sim_particle_time_step_event(void);
void register_node_type_sim_execute_condition(void);
void register_node_type_sim_multi_execute(void);
void register_node_type_sim_particle_mesh_emitter(void);
void register_node_type_sim_particle_mesh_collision_event(void);
void register_node_type_sim_emit_particles(void);
void register_node_type_sim_simulation_time(void);
void register_node_type_sim_particle_attribute(void);
#ifdef __cplusplus
}
#endif
#endif /* __NOD_SIMULATION_H__ */

View File

@@ -258,7 +258,25 @@ DefNode(TextureNode, TEX_NODE_PROC+TEX_NOISE, 0, "TEX_NO
DefNode(TextureNode, TEX_NODE_PROC+TEX_STUCCI, 0, "TEX_STUCCI", TexStucci, "Stucci", "" )
DefNode(TextureNode, TEX_NODE_PROC+TEX_DISTNOISE, 0, "TEX_DISTNOISE", TexDistNoise, "Distorted Noise", "" )
DefNode(SimulationNode, SIM_NODE_PARTICLE_SIMULATION, 0, "PARTICLE_SIMULATION", ParticleSimulation, "Particle Simulation", "")
DefNode(SimulationNode, SIM_NODE_FORCE, 0, "FORCE", Force, "Force", "")
DefNode(SimulationNode, SIM_NODE_SET_PARTICLE_ATTRIBUTE, def_sim_set_particle_attribute, "SET_PARTICLE_ATTRIBUTE", SetParticleAttribute, "Set Particle Attribute", "")
DefNode(SimulationNode, SIM_NODE_PARTICLE_BIRTH_EVENT, 0, "PARTICLE_BIRTH_EVENT", ParticleBirthEvent, "Particle Birth Event", "")
DefNode(SimulationNode, SIM_NODE_PARTICLE_TIME_STEP_EVENT, def_sim_particle_time_step_event, "PARTICLE_TIME_STEP_EVENT", ParticleTimeStepEvent, "Particle Time Step Event", "")
DefNode(SimulationNode, SIM_NODE_EXECUTE_CONDITION, 0, "EXECUTE_CONDITION", ExecuteCondition, "Execute Condition", "")
DefNode(SimulationNode, SIM_NODE_MULTI_EXECUTE, 0, "MULTI_EXECUTE", MultiExecute, "Multi Execute", "")
DefNode(SimulationNode, SIM_NODE_PARTICLE_MESH_EMITTER, 0, "PARTICLE_MESH_EMITTER", ParticleMeshEmitter, "Particle Mesh Emitter", "")
DefNode(SimulationNode, SIM_NODE_PARTICLE_MESH_COLLISION_EVENT, 0, "PARTICLE_MESH_COLLISION_EVENT", ParticleMeshCollisionEvent, "Particle Mesh Collision Event", "")
DefNode(SimulationNode, SIM_NODE_EMIT_PARTICLES, 0, "EMIT_PARTICLES", EmitParticles, "Emit Particles", "")
DefNode(SimulationNode, SIM_NODE_SIMULATION_TIME, 0, "SIMULATION_TIME", SimulationTime, "Simulation Time", "")
DefNode(SimulationNode, SIM_NODE_PARTICLE_ATTRIBUTE, def_sim_particle_attribute, "PARTICLE_ATTRIBUTE", ParticleAttribute, "Particle Attribute", "")
DefNode(FunctionNode, FN_NODE_BOOLEAN_MATH, def_boolean_math, "BOOLEAN_MATH", BooleanMath, "Boolean Math", "");
DefNode(FunctionNode, FN_NODE_FLOAT_COMPARE, def_float_compare, "FLOAT_COMPARE", FloatCompare, "Float Compare", "");
DefNode(FunctionNode, FN_NODE_SWITCH, def_fn_switch, "SWITCH", Switch, "Switch", "");
/* undefine macros */
#undef DefNode
/* clang-format on */
/* clang-format on */

View File

@@ -0,0 +1,30 @@
/*
* 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_function_util.h"
#include "node_util.h"
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");
}
void fn_node_type_base(bNodeType *ntype, int type, const char *name, short nclass, short flag)
{
node_type_base(ntype, type, name, nclass, flag);
ntype->poll = fn_node_poll_default;
}

View File

@@ -0,0 +1,40 @@
/*
* 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.
*/
#ifndef __NODE_FUNCTION_UTIL_H__
#define __NODE_FUNCTION_UTIL_H__
#include <string.h>
#include "BLI_utildefines.h"
#include "MEM_guardedalloc.h"
#include "DNA_node_types.h"
#include "BKE_node.h"
#include "BLT_translation.h"
#include "NOD_function.h"
#include "node_util.h"
void fn_node_type_base(
struct bNodeType *ntype, int type, const char *name, short nclass, short flag);
bool fn_node_poll_default(struct bNodeType *ntype, struct bNodeTree *ntree);
#endif /* __NODE_FUNCTION_UTIL_H__ */

View File

@@ -0,0 +1,62 @@
/*
* 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 "BLI_listbase.h"
#include "BLI_string.h"
#include "RNA_enum_types.h"
#include "node_function_util.h"
static bNodeSocketTemplate fn_node_boolean_math_in[] = {
{SOCK_BOOLEAN, N_("Boolean")},
{SOCK_BOOLEAN, N_("Boolean")},
{-1, ""},
};
static bNodeSocketTemplate fn_node_boolean_math_out[] = {
{SOCK_BOOLEAN, N_("Boolean")},
{-1, ""},
};
static void node_boolean_math_update(bNodeTree *UNUSED(ntree), bNode *node)
{
bNodeSocket *sockB = (bNodeSocket *)BLI_findlink(&node->inputs, 1);
nodeSetSocketAvailability(sockB,
ELEM(node->custom1, NODE_BOOLEAN_MATH_AND, NODE_BOOLEAN_MATH_OR));
}
static void node_boolean_math_label(bNodeTree *UNUSED(ntree), bNode *node, char *label, int maxlen)
{
const char *name;
bool enum_label = RNA_enum_name(rna_enum_node_boolean_math_items, node->custom1, &name);
if (!enum_label) {
name = "Unknown";
}
BLI_strncpy(label, IFACE_(name), maxlen);
}
void register_node_type_fn_boolean_math()
{
static bNodeType ntype;
fn_node_type_base(&ntype, FN_NODE_BOOLEAN_MATH, "Boolean Math", 0, 0);
node_type_socket_templates(&ntype, fn_node_boolean_math_in, fn_node_boolean_math_out);
node_type_label(&ntype, node_boolean_math_label);
node_type_update(&ntype, node_boolean_math_update);
nodeRegisterType(&ntype);
}

View File

@@ -0,0 +1,66 @@
/*
* 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 "BLI_listbase.h"
#include "BLI_string.h"
#include "RNA_enum_types.h"
#include "node_function_util.h"
static bNodeSocketTemplate fn_node_float_compare_in[] = {
{SOCK_FLOAT, N_("A"), 0.0f, 0.0f, 0.0f, 0.0f, -10000.0f, 10000.0f},
{SOCK_FLOAT, N_("B"), 0.0f, 0.0f, 0.0f, 0.0f, -10000.0f, 10000.0f},
{SOCK_FLOAT, N_("Epsilon"), 0.001f, 0.0f, 0.0f, 0.0f, -10000.0f, 10000.0f},
{-1, ""},
};
static bNodeSocketTemplate fn_node_float_compare_out[] = {
{SOCK_BOOLEAN, N_("Result")},
{-1, ""},
};
static void node_float_compare_update(bNodeTree *UNUSED(ntree), bNode *node)
{
bNodeSocket *sockEpsilon = (bNodeSocket *)BLI_findlink(&node->inputs, 2);
nodeSetSocketAvailability(
sockEpsilon, ELEM(node->custom1, NODE_FLOAT_COMPARE_EQUAL, NODE_FLOAT_COMPARE_NOT_EQUAL));
}
static void node_float_compare_label(bNodeTree *UNUSED(ntree),
bNode *node,
char *label,
int maxlen)
{
const char *name;
bool enum_label = RNA_enum_name(rna_enum_node_float_compare_items, node->custom1, &name);
if (!enum_label) {
name = "Unknown";
}
BLI_strncpy(label, IFACE_(name), maxlen);
}
void register_node_type_fn_float_compare()
{
static bNodeType ntype;
fn_node_type_base(&ntype, FN_NODE_FLOAT_COMPARE, "Boolean Math", 0, 0);
node_type_socket_templates(&ntype, fn_node_float_compare_in, fn_node_float_compare_out);
node_type_label(&ntype, node_float_compare_label);
node_type_update(&ntype, node_float_compare_update);
nodeRegisterType(&ntype);
}

View File

@@ -0,0 +1,76 @@
/*
* 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 "BLI_listbase.h"
#include "node_function_util.h"
static bNodeSocketTemplate fn_node_switch_in[] = {
{SOCK_BOOLEAN, N_("Switch")},
{SOCK_FLOAT, N_("If False"), 0.0f, 0.0f, 0.0f, 0.0f, -10000.0f, 10000.0f},
{SOCK_INT, N_("If False"), 0, 0, 0, 0, -10000, 10000},
{SOCK_BOOLEAN, N_("If False")},
{SOCK_VECTOR, N_("If False"), 0.0f, 0.0f, 0.0f, 0.0f, -10000.0f, 10000.0f},
{SOCK_STRING, N_("If False")},
{SOCK_RGBA, N_("If False"), 0.8f, 0.8f, 0.8f, 1.0f},
{SOCK_OBJECT, N_("If False")},
{SOCK_IMAGE, N_("If False")},
{SOCK_FLOAT, N_("If True"), 0.0f, 0.0f, 0.0f, 0.0f, -10000.0f, 10000.0f},
{SOCK_INT, N_("If True"), 0, 0, 0, 0, -10000, 10000},
{SOCK_BOOLEAN, N_("If True")},
{SOCK_VECTOR, N_("If True"), 0.0f, 0.0f, 0.0f, 0.0f, -10000.0f, 10000.0f},
{SOCK_STRING, N_("If True")},
{SOCK_RGBA, N_("If True"), 0.8f, 0.8f, 0.8f, 1.0f},
{SOCK_OBJECT, N_("If True")},
{SOCK_IMAGE, N_("If True")},
{-1, ""},
};
static bNodeSocketTemplate fn_node_switch_out[] = {
{SOCK_FLOAT, N_("Result")},
{SOCK_INT, N_("Result")},
{SOCK_BOOLEAN, N_("Result")},
{SOCK_VECTOR, N_("Result")},
{SOCK_STRING, N_("Result")},
{SOCK_RGBA, N_("Result")},
{SOCK_OBJECT, N_("Result")},
{SOCK_IMAGE, N_("Result")},
{-1, ""},
};
static void fn_node_switch_update(bNodeTree *UNUSED(ntree), bNode *node)
{
int index = 0;
LISTBASE_FOREACH (bNodeSocket *, sock, &node->inputs) {
nodeSetSocketAvailability(sock, index == 0 || sock->type == node->custom1);
index++;
}
LISTBASE_FOREACH (bNodeSocket *, sock, &node->outputs) {
nodeSetSocketAvailability(sock, sock->type == node->custom1);
}
}
void register_node_type_fn_switch()
{
static bNodeType ntype;
fn_node_type_base(&ntype, FN_NODE_SWITCH, "Switch", 0, 0);
node_type_socket_templates(&ntype, fn_node_switch_in, fn_node_switch_out);
node_type_update(&ntype, fn_node_switch_update);
nodeRegisterType(&ntype);
}

View File

@@ -26,6 +26,10 @@
#include "DNA_listBase.h"
#ifdef __cplusplus
extern "C" {
#endif
struct bNodeTree;
void node_group_label(struct bNodeTree *ntree, struct bNode *node, char *label, int maxlen);
@@ -33,4 +37,8 @@ bool node_group_poll_instance(struct bNode *node, struct bNodeTree *nodetree);
void ntree_update_reroute_nodes(struct bNodeTree *ntree);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -30,6 +30,7 @@
#include "BLI_string.h"
#include "BLI_utildefines.h"
#include "BKE_lib_id.h"
#include "BKE_node.h"
#include "RNA_access.h"
@@ -256,6 +257,22 @@ void node_socket_init_default_value(bNodeSocket *sock)
dval->subtype = subtype;
dval->value[0] = '\0';
sock->default_value = dval;
break;
}
case SOCK_OBJECT: {
bNodeSocketValueObject *dval = MEM_callocN(sizeof(bNodeSocketValueObject),
"node socket value object");
dval->value = NULL;
sock->default_value = dval;
break;
}
case SOCK_IMAGE: {
bNodeSocketValueImage *dval = MEM_callocN(sizeof(bNodeSocketValueImage),
"node socket value image");
dval->value = NULL;
sock->default_value = dval;
break;
}
@@ -317,6 +334,20 @@ void node_socket_copy_default_value(bNodeSocket *to, const bNodeSocket *from)
*toval = *fromval;
break;
}
case SOCK_OBJECT: {
bNodeSocketValueObject *toval = to->default_value;
bNodeSocketValueObject *fromval = from->default_value;
*toval = *fromval;
id_us_plus(&toval->value->id);
break;
}
case SOCK_IMAGE: {
bNodeSocketValueImage *toval = to->default_value;
bNodeSocketValueImage *fromval = from->default_value;
*toval = *fromval;
id_us_plus(&toval->value->id);
break;
}
}
to->flag |= (from->flag & SOCK_HIDE_VALUE);
@@ -467,6 +498,19 @@ static bNodeSocketType *make_socket_type_virtual(void)
return stype;
}
static bNodeSocketType *make_socket_type_effector(int type)
{
bNodeSocketType *stype = make_standard_socket_type(type, PROP_NONE);
stype->input_link_limit = 0xFFF;
return stype;
}
static bNodeSocketType *make_socket_type_control_flow(int type)
{
bNodeSocketType *stype = make_standard_socket_type(type, PROP_NONE);
return stype;
}
void register_standard_node_socket_types(void)
{
/* draw callbacks are set in drawnode.c to avoid bad-level calls */
@@ -499,5 +543,15 @@ void register_standard_node_socket_types(void)
nodeRegisterSocketType(make_standard_socket_type(SOCK_SHADER, PROP_NONE));
nodeRegisterSocketType(make_standard_socket_type(SOCK_OBJECT, PROP_NONE));
nodeRegisterSocketType(make_standard_socket_type(SOCK_IMAGE, PROP_NONE));
nodeRegisterSocketType(make_socket_type_effector(SOCK_EMITTERS));
nodeRegisterSocketType(make_socket_type_effector(SOCK_EVENTS));
nodeRegisterSocketType(make_socket_type_effector(SOCK_FORCES));
nodeRegisterSocketType(make_socket_type_control_flow(SOCK_CONTROL_FLOW));
nodeRegisterSocketType(make_socket_type_virtual());
}

View File

@@ -38,6 +38,10 @@
#include "RNA_access.h"
#ifdef __cplusplus
extern "C" {
#endif
struct bNode;
struct bNodeTree;
@@ -103,4 +107,8 @@ void node_socket_set_vector(struct bNodeTree *ntree,
struct bNodeSocket *sock,
const float *value);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -32,6 +32,11 @@ bool sh_node_poll_default(bNodeType *UNUSED(ntype), bNodeTree *ntree)
return STREQ(ntree->idname, "ShaderNodeTree");
}
static bool sh_fn_poll_default(bNodeType *UNUSED(ntype), bNodeTree *ntree)
{
return STREQ(ntree->idname, "ShaderNodeTree") || STREQ(ntree->idname, "SimulationNodeTree");
}
void sh_node_type_base(
struct bNodeType *ntype, int type, const char *name, short nclass, short flag)
{
@@ -42,6 +47,12 @@ void sh_node_type_base(
ntype->update_internal_links = node_update_internal_links_default;
}
void sh_fn_node_type_base(bNodeType *ntype, int type, const char *name, short nclass, short flag)
{
sh_node_type_base(ntype, type, name, nclass, flag);
ntype->poll = sh_fn_poll_default;
}
/* ****** */
void nodestack_get_vec(float *in, short type_in, bNodeStack *ns)

View File

@@ -72,6 +72,8 @@
bool sh_node_poll_default(struct bNodeType *ntype, struct bNodeTree *ntree);
void sh_node_type_base(
struct bNodeType *ntype, int type, const char *name, short nclass, short flag);
void sh_fn_node_type_base(
struct bNodeType *ntype, int type, const char *name, short nclass, short flag);
/* ********* exec data struct, remains internal *********** */

View File

@@ -46,7 +46,7 @@ void register_node_type_sh_brightcontrast(void)
{
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_BRIGHTCONTRAST, "Bright/Contrast", NODE_CLASS_OP_COLOR, 0);
sh_fn_node_type_base(&ntype, SH_NODE_BRIGHTCONTRAST, "Bright/Contrast", NODE_CLASS_OP_COLOR, 0);
node_type_socket_templates(&ntype, sh_node_brightcontrast_in, sh_node_brightcontrast_out);
node_type_init(&ntype, NULL);
node_type_storage(&ntype, "", NULL, NULL);

View File

@@ -54,7 +54,7 @@ void register_node_type_sh_clamp(void)
{
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_CLAMP, "Clamp", NODE_CLASS_CONVERTOR, 0);
sh_fn_node_type_base(&ntype, SH_NODE_CLAMP, "Clamp", NODE_CLASS_CONVERTOR, 0);
node_type_socket_templates(&ntype, sh_node_clamp_in, sh_node_clamp_out);
node_type_init(&ntype, node_shader_init_clamp);
node_type_gpu(&ntype, gpu_shader_clamp);

View File

@@ -62,7 +62,7 @@ void register_node_type_sh_gamma(void)
{
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_GAMMA, "Gamma", NODE_CLASS_OP_COLOR, 0);
sh_fn_node_type_base(&ntype, SH_NODE_GAMMA, "Gamma", NODE_CLASS_OP_COLOR, 0);
node_type_socket_templates(&ntype, sh_node_gamma_in, sh_node_gamma_out);
node_type_init(&ntype, NULL);
node_type_storage(&ntype, "", NULL, NULL);

View File

@@ -89,7 +89,7 @@ void register_node_type_sh_hue_sat(void)
{
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_HUE_SAT, "Hue Saturation Value", NODE_CLASS_OP_COLOR, 0);
sh_fn_node_type_base(&ntype, SH_NODE_HUE_SAT, "Hue Saturation Value", NODE_CLASS_OP_COLOR, 0);
node_type_socket_templates(&ntype, sh_node_hue_sat_in, sh_node_hue_sat_out);
node_type_size_preset(&ntype, NODE_SIZE_MIDDLE);
node_type_exec(&ntype, NULL, NULL, node_shader_exec_hue_sat);

View File

@@ -69,7 +69,7 @@ void register_node_type_sh_invert(void)
{
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_INVERT, "Invert", NODE_CLASS_OP_COLOR, 0);
sh_fn_node_type_base(&ntype, SH_NODE_INVERT, "Invert", NODE_CLASS_OP_COLOR, 0);
node_type_socket_templates(&ntype, sh_node_invert_in, sh_node_invert_out);
node_type_exec(&ntype, NULL, NULL, node_shader_exec_invert);
node_type_gpu(&ntype, gpu_shader_invert);

View File

@@ -81,7 +81,7 @@ void register_node_type_sh_map_range(void)
{
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_MAP_RANGE, "Map Range", NODE_CLASS_CONVERTOR, 0);
sh_fn_node_type_base(&ntype, SH_NODE_MAP_RANGE, "Map Range", NODE_CLASS_CONVERTOR, 0);
node_type_socket_templates(&ntype, sh_node_map_range_in, sh_node_map_range_out);
node_type_init(&ntype, node_shader_init_map_range);
node_type_update(&ntype, node_shader_update_map_range);

View File

@@ -105,7 +105,7 @@ void register_node_type_sh_math(void)
{
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_MATH, "Math", NODE_CLASS_CONVERTOR, 0);
sh_fn_node_type_base(&ntype, SH_NODE_MATH, "Math", NODE_CLASS_CONVERTOR, 0);
node_type_socket_templates(&ntype, sh_node_math_in, sh_node_math_out);
node_type_label(&ntype, node_math_label);
node_type_gpu(&ntype, gpu_shader_math);

View File

@@ -107,7 +107,7 @@ void register_node_type_sh_mix_rgb(void)
{
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_MIX_RGB, "Mix", NODE_CLASS_OP_COLOR, 0);
sh_fn_node_type_base(&ntype, SH_NODE_MIX_RGB, "Mix", NODE_CLASS_OP_COLOR, 0);
node_type_socket_templates(&ntype, sh_node_mix_rgb_in, sh_node_mix_rgb_out);
node_type_label(&ntype, node_blend_label);
node_type_exec(&ntype, NULL, NULL, node_shader_exec_mix_rgb);

View File

@@ -61,7 +61,7 @@ void register_node_type_sh_sephsv(void)
{
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_SEPHSV, "Separate HSV", NODE_CLASS_CONVERTOR, 0);
sh_fn_node_type_base(&ntype, SH_NODE_SEPHSV, "Separate HSV", NODE_CLASS_CONVERTOR, 0);
node_type_socket_templates(&ntype, sh_node_sephsv_in, sh_node_sephsv_out);
node_type_exec(&ntype, NULL, NULL, node_shader_exec_sephsv);
node_type_gpu(&ntype, gpu_shader_sephsv);
@@ -109,7 +109,7 @@ void register_node_type_sh_combhsv(void)
{
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_COMBHSV, "Combine HSV", NODE_CLASS_CONVERTOR, 0);
sh_fn_node_type_base(&ntype, SH_NODE_COMBHSV, "Combine HSV", NODE_CLASS_CONVERTOR, 0);
node_type_socket_templates(&ntype, sh_node_combhsv_in, sh_node_combhsv_out);
node_type_exec(&ntype, NULL, NULL, node_shader_exec_combhsv);
node_type_gpu(&ntype, gpu_shader_combhsv);

View File

@@ -63,7 +63,7 @@ void register_node_type_sh_seprgb(void)
{
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_SEPRGB, "Separate RGB", NODE_CLASS_CONVERTOR, 0);
sh_fn_node_type_base(&ntype, SH_NODE_SEPRGB, "Separate RGB", NODE_CLASS_CONVERTOR, 0);
node_type_socket_templates(&ntype, sh_node_seprgb_in, sh_node_seprgb_out);
node_type_exec(&ntype, NULL, NULL, node_shader_exec_seprgb);
node_type_gpu(&ntype, gpu_shader_seprgb);
@@ -113,7 +113,7 @@ void register_node_type_sh_combrgb(void)
{
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_COMBRGB, "Combine RGB", NODE_CLASS_CONVERTOR, 0);
sh_fn_node_type_base(&ntype, SH_NODE_COMBRGB, "Combine RGB", NODE_CLASS_CONVERTOR, 0);
node_type_socket_templates(&ntype, sh_node_combrgb_in, sh_node_combrgb_out);
node_type_exec(&ntype, NULL, NULL, node_shader_exec_combrgb);
node_type_gpu(&ntype, gpu_shader_combrgb);

View File

@@ -48,7 +48,7 @@ void register_node_type_sh_sepxyz(void)
{
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_SEPXYZ, "Separate XYZ", NODE_CLASS_CONVERTOR, 0);
sh_fn_node_type_base(&ntype, SH_NODE_SEPXYZ, "Separate XYZ", NODE_CLASS_CONVERTOR, 0);
node_type_socket_templates(&ntype, sh_node_sepxyz_in, sh_node_sepxyz_out);
node_type_gpu(&ntype, gpu_shader_sepxyz);
@@ -80,7 +80,7 @@ void register_node_type_sh_combxyz(void)
{
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_COMBXYZ, "Combine XYZ", NODE_CLASS_CONVERTOR, 0);
sh_fn_node_type_base(&ntype, SH_NODE_COMBXYZ, "Combine XYZ", NODE_CLASS_CONVERTOR, 0);
node_type_socket_templates(&ntype, sh_node_combxyz_in, sh_node_combxyz_out);
node_type_gpu(&ntype, gpu_shader_combxyz);

View File

@@ -90,7 +90,7 @@ void register_node_type_sh_tex_noise(void)
{
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_TEX_NOISE, "Noise Texture", NODE_CLASS_TEXTURE, 0);
sh_fn_node_type_base(&ntype, SH_NODE_TEX_NOISE, "Noise Texture", NODE_CLASS_TEXTURE, 0);
node_type_socket_templates(&ntype, sh_node_tex_noise_in, sh_node_tex_noise_out);
node_type_init(&ntype, node_shader_init_tex_noise);
node_type_storage(

View File

@@ -72,7 +72,8 @@ void register_node_type_sh_tex_white_noise(void)
{
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_TEX_WHITE_NOISE, "White Noise Texture", NODE_CLASS_TEXTURE, 0);
sh_fn_node_type_base(
&ntype, SH_NODE_TEX_WHITE_NOISE, "White Noise Texture", NODE_CLASS_TEXTURE, 0);
node_type_socket_templates(&ntype, sh_node_tex_white_noise_in, sh_node_tex_white_noise_out);
node_type_init(&ntype, node_shader_init_tex_white_noise);
node_type_gpu(&ntype, gpu_shader_tex_white_noise);

View File

@@ -125,7 +125,7 @@ void register_node_type_sh_valtorgb(void)
{
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_VALTORGB, "ColorRamp", NODE_CLASS_CONVERTOR, 0);
sh_fn_node_type_base(&ntype, SH_NODE_VALTORGB, "ColorRamp", NODE_CLASS_CONVERTOR, 0);
node_type_socket_templates(&ntype, sh_node_valtorgb_in, sh_node_valtorgb_out);
node_type_init(&ntype, node_shader_init_valtorgb);
node_type_size_preset(&ntype, NODE_SIZE_LARGE);

View File

@@ -134,7 +134,7 @@ void register_node_type_sh_vect_math(void)
{
static bNodeType ntype;
sh_node_type_base(&ntype, SH_NODE_VECTOR_MATH, "Vector Math", NODE_CLASS_OP_VECTOR, 0);
sh_fn_node_type_base(&ntype, SH_NODE_VECTOR_MATH, "Vector Math", NODE_CLASS_OP_VECTOR, 0);
node_type_socket_templates(&ntype, sh_node_vector_math_in, sh_node_vector_math_out);
node_type_label(&ntype, node_vector_math_label);
node_type_gpu(&ntype, gpu_shader_vector_math);

View File

@@ -0,0 +1,45 @@
/*
* 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 <string.h>
#include "MEM_guardedalloc.h"
#include "NOD_simulation.h"
#include "BKE_node.h"
#include "BLT_translation.h"
#include "DNA_node_types.h"
#include "RNA_access.h"
bNodeTreeType *ntreeType_Simulation;
void register_node_tree_type_sim(void)
{
bNodeTreeType *tt = ntreeType_Simulation = (bNodeTreeType *)MEM_callocN(
sizeof(bNodeTreeType), "simulation node tree type");
tt->type = NTREE_SIMULATION;
strcpy(tt->idname, "SimulationNodeTree");
strcpy(tt->ui_name, N_("Simulation Editor"));
tt->ui_icon = 0; /* defined in drawnode.c */
strcpy(tt->ui_description, N_("Simulation nodes"));
tt->rna_ext.srna = &RNA_SimulationNodeTree;
ntreeTypeAdd(tt);
}

Some files were not shown because too many files have changed in this diff Show More