Skip to content

Instantly share code, notes, and snippets.

@sobotka
Created November 26, 2017 23:07
Show Gist options
  • Save sobotka/0f02d4635835aa2b0770b8157da6248d to your computer and use it in GitHub Desktop.
Save sobotka/0f02d4635835aa2b0770b8157da6248d to your computer and use it in GitHub Desktop.
Node Skeleton Patch against 587b2f105c4e14031f4d70c31d12f9d4da7439ca
diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h
index 4ee5c894b5..d57edd45cc 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -700,6 +700,8 @@ void ntreeGPUMaterialNodes(struct bNodeTree *ntree, struct GPUMateria
#define CMP_NODE_BOKEHBLUR 316
#define CMP_NODE_SWITCH 317
+#define CMP_NODE_SKELETON 330
+
/* channel toggles */
#define CMP_CHAN_RGB 1
#define CMP_CHAN_A 2
diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c
index 0ff6b7abbc..5d3b18636c 100644
--- a/source/blender/blenkernel/intern/node.c
+++ b/source/blender/blenkernel/intern/node.c
@@ -2201,6 +2201,8 @@ static void registerCompositNodes(bNodeTreeType *ttype)
register_node_type_cmp_mask(ttype);
register_node_type_cmp_trackpos(ttype);
+
+ register_node_type_cmp_skeleton(ttype);
}
static void registerShaderNodes(bNodeTreeType *ttype)
diff --git a/source/blender/compositor/CMakeLists.txt b/source/blender/compositor/CMakeLists.txt
index 9932ed1737..27c7d2adb4 100644
--- a/source/blender/compositor/CMakeLists.txt
+++ b/source/blender/compositor/CMakeLists.txt
@@ -323,6 +323,11 @@ set(SRC
operations/COM_GammaCorrectOperation.h
operations/COM_GammaCorrectOperation.cpp
+ nodes/COM_SkeletonNode.cpp
+ nodes/COM_SkeletonNode.h
+ operations/COM_SkeletonOperation.cpp
+ operations/COM_SkeletonOperation.h
+
# Matte nodes
nodes/COM_BoxMaskNode.cpp
nodes/COM_BoxMaskNode.h
diff --git a/source/blender/compositor/intern/COM_Converter.cpp b/source/blender/compositor/intern/COM_Converter.cpp
index 71067ac8f1..412c1ef767 100644
--- a/source/blender/compositor/intern/COM_Converter.cpp
+++ b/source/blender/compositor/intern/COM_Converter.cpp
@@ -119,6 +119,7 @@
#include "COM_ViewLevelsNode.h"
#include "COM_ViewerNode.h"
#include "COM_ZCombineNode.h"
+#include "COM_SkeletonNode.h"
Node *Converter::convert(bNode *b_node, bool fast)
{
@@ -389,6 +390,9 @@ Node *Converter::convert(bNode *b_node, bool fast)
case CMP_NODE_TRACKPOS:
node = new TrackPositionNode(b_node);
break;
+ case CMP_NODE_SKELETON:
+ node = new SkeletonNode(b_node);
+ break;
/* not inplemented yet */
default:
node = new MuteNode(b_node);
diff --git a/source/blender/compositor/nodes/COM_SkeletonNode.cpp b/source/blender/compositor/nodes/COM_SkeletonNode.cpp
new file mode 100644
index 0000000000..b39240c4ab
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_SkeletonNode.cpp
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * 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.
+ *
+ * Contributor:
+ * <AUTHOR NAME HERE>
+ */
+
+#include "COM_SkeletonNode.h"
+
+#include "COM_SkeletonOperation.h"
+#include "COM_ExecutionSystem.h"
+
+SkeletonNode::SkeletonNode(bNode *editorNode) : Node(editorNode)
+{
+ /* pass */
+}
+
+void SkeletonNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
+{
+ InputSocket *inputSocket = this->getInputSocket(0);
+ OutputSocket *outputSocket = this->getOutputSocket(0);
+ SkeletonOperation *operation = new SkeletonOperation();
+
+ //bNode *editorsnode = getbNode();
+ //operation->setSettings((NodeSkeleton *)editorsnode->storage);
+
+ inputSocket->relinkConnections(operation->getInputSocket(0), 0, graph);
+ outputSocket->relinkConnections(operation->getOutputSocket(0));
+ graph->addOperation(operation);
+}
diff --git a/source/blender/compositor/nodes/COM_SkeletonNode.h b/source/blender/compositor/nodes/COM_SkeletonNode.h
new file mode 100644
index 0000000000..ef2c0e3aee
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_SkeletonNode.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * 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.
+ *
+ * Contributor:
+ * <AUTHOR NAME HERE>
+ */
+
+#ifndef _COM_SkeletonNode_h_
+#define _COM_SkeletonNode_h_
+
+#include "COM_Node.h"
+
+/**
+ * @brief FlipNode
+ * @ingroup Node
+ */
+class SkeletonNode : public Node {
+public:
+ SkeletonNode(bNode *editorNode);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+};
+
+#endif
diff --git a/source/blender/compositor/operations/COM_SkeletonOperation.cpp b/source/blender/compositor/operations/COM_SkeletonOperation.cpp
new file mode 100644
index 0000000000..0cea6c2009
--- /dev/null
+++ b/source/blender/compositor/operations/COM_SkeletonOperation.cpp
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * 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.
+ *
+ * Contributor:
+ * <AUTHOR NAME HERE>
+ */
+
+#include "COM_SkeletonOperation.h"
+
+SkeletonOperation::SkeletonOperation() : NodeOperation()
+{
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->setResolutionInputSocketIndex(0);
+ this->m_inputOperation = NULL;
+}
+void SkeletonOperation::initExecution()
+{
+ this->m_inputOperation = this->getInputSocketReader(0);
+}
+
+void SkeletonOperation::deinitExecution()
+{
+ this->m_inputOperation = NULL;
+}
+
+
+void SkeletonOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
+{
+ this->m_inputOperation->read(output, x, y, sampler);
+}
+
+bool SkeletonOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
+{
+ rcti newInput;
+
+ return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
+}
diff --git a/source/blender/compositor/operations/COM_SkeletonOperation.h b/source/blender/compositor/operations/COM_SkeletonOperation.h
new file mode 100644
index 0000000000..6498723b76
--- /dev/null
+++ b/source/blender/compositor/operations/COM_SkeletonOperation.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * 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.
+ *
+ * Contributor:
+ * <AUTHOR NAME HERE>
+ */
+
+#ifndef _COM_SkeletonOperation_h_
+#define _COM_SkeletonOperation_h_
+
+#include "COM_NodeOperation.h"
+
+class SkeletonOperation : public NodeOperation {
+private:
+ //NodeSkeleton *m_settings;
+ SocketReader *m_inputOperation;
+ // float skeleton_float_declaration; /* Matches the RNA declaration */
+public:
+ SkeletonOperation();
+ bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
+ void executePixel(float output[4], float x, float y, PixelSampler sampler);
+
+ //void setSettings(NodeSkeleton *nodeSkeleton) { this->m_settings = nodeSkeleton; }
+ void initExecution();
+ void deinitExecution();
+};
+
+#endif
diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c
index 67508f2087..7425aa90f0 100644
--- a/source/blender/editors/space_node/drawnode.c
+++ b/source/blender/editors/space_node/drawnode.c
@@ -2424,6 +2424,11 @@ static void node_composit_buts_bokehblur(uiLayout *layout, bContext *UNUSED(C),
uiItemR(layout, ptr, "blur_max", 0, NULL, ICON_NONE);
}
+static void node_composit_skeleton(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+{
+ uiItemR(layout, ptr, "skeleton_float", 0, NULL, ICON_NONE);
+}
+
static void node_composit_backdrop_viewer(SpaceNode *snode, ImBuf *backdrop, bNode *node, int x, int y)
{
// node_composit_backdrop_canvas(snode, backdrop, node, x, y);
@@ -2862,6 +2867,9 @@ static void node_composit_set_butfunc(bNodeType *ntype)
case CMP_NODE_TRACKPOS:
ntype->uifunc = node_composit_buts_trackpos;
break;
+ case CMP_NODE_SKELETON:
+ ntype->uifunc = node_composit_skeleton;
+ break;
default:
ntype->uifunc = NULL;
}
diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h
index 3f1f493358..134ad61517 100644
--- a/source/blender/makesdna/DNA_node_types.h
+++ b/source/blender/makesdna/DNA_node_types.h
@@ -564,6 +564,11 @@ typedef struct NodeTonemap {
int type;
} NodeTonemap;
+
+typedef struct NodeSkeleton {
+ float skeleton_float, pad;
+} NodeSkeleton;
+
/* qdn: lens distortion node */
typedef struct NodeLensDist {
short jit, proj, fit, pad;
@@ -702,6 +707,7 @@ typedef struct NodeTrackPosData {
char track_name[64];
} NodeTrackPosData;
+
/* frame node flags */
#define NODE_FRAME_SHRINK 1 /* keep the bounding box minimal */
#define NODE_FRAME_RESIZEABLE 2 /* test flag, if frame can be resized by user */
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index 0d7d20d04a..08aef8b5c5 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -3868,6 +3868,18 @@ static void def_cmp_trackpos(StructRNA *srna)
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
}
+static void def_cmp_skeleton(StructRNA *srna)
+{
+ PropertyRNA *prop;
+ RNA_def_struct_sdna_from(srna, "NodeSkeleton", "storage");
+
+ prop = RNA_def_property(srna, "skeleton_float", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "skeleton_float");
+ RNA_def_property_range(prop, 0.0f, 1.0f);
+ RNA_def_property_ui_text(prop, "Skeleton Float", "Skeleton float data");
+ RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
+}
+
/* -- Texture Nodes --------------------------------------------------------- */
static void def_tex_output(StructRNA *srna)
diff --git a/source/blender/makesrna/intern/rna_nodetree_types.h b/source/blender/makesrna/intern/rna_nodetree_types.h
index 6d97e95911..252f68f90b 100644
--- a/source/blender/makesrna/intern/rna_nodetree_types.h
+++ b/source/blender/makesrna/intern/rna_nodetree_types.h
@@ -176,6 +176,8 @@ DefNode( CompositorNode, CMP_NODE_MASK, def_cmp_mask, "MASK"
DefNode( CompositorNode, CMP_NODE_KEYINGSCREEN, def_cmp_keyingscreen, "KEYINGSCREEN", KeyingScreen, "KeyingScreen", "" )
DefNode( CompositorNode, CMP_NODE_KEYING, def_cmp_keying, "KEYING", Keying, "Keying", "" )
DefNode( CompositorNode, CMP_NODE_TRACKPOS, def_cmp_trackpos, "TRACKPOS", TrackPos, "Track Position", "" )
+
+DefNode( CompositorNode, CMP_NODE_SKELETON, def_cmp_skeleton, "SKELETON", Skeleton, "Skeleton", "" )
DefNode( TextureNode, TEX_NODE_OUTPUT, def_tex_output, "OUTPUT", Output, "Output", "" )
DefNode( TextureNode, TEX_NODE_CHECKER, 0, "CHECKER", Checker, "Checker", "" )
diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt
index 3fd9bfeced..5b815cbf78 100644
--- a/source/blender/nodes/CMakeLists.txt
+++ b/source/blender/nodes/CMakeLists.txt
@@ -120,6 +120,8 @@ set(SRC
composite/nodes/node_composite_switch.c
composite/nodes/node_composite_colorcorrection.c
+ composite/nodes/node_composite_skeleton.c
+
composite/node_composite_tree.c
composite/node_composite_util.c
diff --git a/source/blender/nodes/NOD_composite.h b/source/blender/nodes/NOD_composite.h
index bcef230e1d..1fb3abec57 100644
--- a/source/blender/nodes/NOD_composite.h
+++ b/source/blender/nodes/NOD_composite.h
@@ -136,4 +136,5 @@ void register_node_type_cmp_switch(struct bNodeTreeType *ttype);
void register_node_type_cmp_trackpos(struct bNodeTreeType *ttype);
+void register_node_type_cmp_skeleton(struct bNodeTreeType *ttype);
#endif
diff --git a/source/blender/nodes/composite/nodes/node_composite_skeleton.c b/source/blender/nodes/composite/nodes/node_composite_skeleton.c
new file mode 100644
index 0000000000..61c0088e26
--- /dev/null
+++ b/source/blender/nodes/composite/nodes/node_composite_skeleton.c
@@ -0,0 +1,78 @@
+/*
+ * ***** 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.
+ *
+ * The Original Code is Copyright (C) 2006 Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/nodes/composite/nodes/node_composite_skeleton.c
+ * \ingroup cmpnodes
+ */
+
+
+#include "node_composite_util.h"
+
+/* **************** Flip ******************** */
+static bNodeSocketTemplate cmp_node_skeleton_in[]= {
+ { SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
+ { -1, 0, "" }
+};
+
+static bNodeSocketTemplate cmp_node_skeleton_out[]= {
+ { SOCK_RGBA, 0, N_("Image")},
+ { -1, 0, "" }
+};
+
+#ifdef WITH_COMPOSITOR_LEGACY
+
+static void node_composit_exec_skeleton(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out)
+{
+ /* Pass. Legacy not supported. */
+}
+
+#endif /* WITH_COMPOSITOR_LEGACY */
+
+static void node_composit_init_skeleton(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp))
+{
+ NodeSkeleton *data = MEM_callocN(sizeof(NodeSkeleton), "NodeSkeleton");
+ node->storage = data;
+}
+
+void register_node_type_cmp_skeleton(bNodeTreeType *ttype)
+{
+ static bNodeType ntype;
+
+ /* The following defines where your node appears and how it looks. In
+ particular, NODE_CLASS_OP_COLOR defines the menu. The size is as
+ defined. */
+ node_type_base(ttype, &ntype, CMP_NODE_SKELETON, "Skeleton", NODE_CLASS_OP_COLOR, NODE_OPTIONS);
+ node_type_socket_templates(&ntype, cmp_node_skeleton_in, cmp_node_skeleton_out);
+ node_type_size(&ntype, 140, 100, 320);
+ node_type_init(&ntype, node_composit_init_skeleton);
+ node_type_storage(&ntype, "NodeSkeleton", node_free_standard_storage, node_copy_standard_storage);
+#ifdef WITH_COMPOSITOR_LEGACY
+ node_type_exec(&ntype, node_composit_exec_skeleton);
+#endif
+
+ nodeRegisterType(ttype, &ntype);
+}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment