Revision: 58943
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=58943
Author: lockal
Date: 2013-08-05 19:16:52 +0000 (Mon, 05 Aug 2013)
Log Message:
-----------
SplitViewer node:
- fix thumbnail preview (previously it showed only one input)
- make SplitViewer node update even if the second input is not connected
- now it works when the first socket is connected to a zero-sized node tree (e.
g. Color Input node)
- SplitViewer node is now based on 2 operations: SplitOperation and
ViewerOperation.
- ViewerBaseOperation was removed as a redundant one. Any future viewer style
node can use the same principle and prepare the output before passing to an
actual ViewerOperation.
Thanks Lukas Toenne for reviewing this patch and giving me get few pieces of
advice.
Modified Paths:
--------------
trunk/blender/source/blender/compositor/CMakeLists.txt
trunk/blender/source/blender/compositor/COM_compositor.h
trunk/blender/source/blender/compositor/intern/COM_ExecutionGroup.cpp
trunk/blender/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp
trunk/blender/source/blender/compositor/nodes/COM_SplitViewerNode.cpp
trunk/blender/source/blender/compositor/operations/COM_ViewerOperation.cpp
trunk/blender/source/blender/compositor/operations/COM_ViewerOperation.h
Added Paths:
-----------
trunk/blender/source/blender/compositor/operations/COM_SplitOperation.cpp
trunk/blender/source/blender/compositor/operations/COM_SplitOperation.h
Removed Paths:
-------------
trunk/blender/source/blender/compositor/operations/COM_SplitViewerOperation.cpp
trunk/blender/source/blender/compositor/operations/COM_SplitViewerOperation.h
trunk/blender/source/blender/compositor/operations/COM_ViewerBaseOperation.cpp
trunk/blender/source/blender/compositor/operations/COM_ViewerBaseOperation.h
Modified: trunk/blender/source/blender/compositor/CMakeLists.txt
===================================================================
--- trunk/blender/source/blender/compositor/CMakeLists.txt 2013-08-05
19:06:37 UTC (rev 58942)
+++ trunk/blender/source/blender/compositor/CMakeLists.txt 2013-08-05
19:16:52 UTC (rev 58943)
@@ -425,14 +425,12 @@
operations/COM_CompositorOperation.cpp
operations/COM_OutputFileOperation.h
operations/COM_OutputFileOperation.cpp
- operations/COM_ViewerBaseOperation.h
- operations/COM_ViewerBaseOperation.cpp
operations/COM_ViewerOperation.h
operations/COM_ViewerOperation.cpp
operations/COM_PreviewOperation.h
operations/COM_PreviewOperation.cpp
- operations/COM_SplitViewerOperation.h
- operations/COM_SplitViewerOperation.cpp
+ operations/COM_SplitOperation.h
+ operations/COM_SplitOperation.cpp
operations/COM_ConvertValueToColorProg.h
operations/COM_ConvertValueToColorProg.cpp
operations/COM_ConvertColorToValueProg.h
Modified: trunk/blender/source/blender/compositor/COM_compositor.h
===================================================================
--- trunk/blender/source/blender/compositor/COM_compositor.h 2013-08-05
19:06:37 UTC (rev 58942)
+++ trunk/blender/source/blender/compositor/COM_compositor.h 2013-08-05
19:16:52 UTC (rev 58943)
@@ -107,7 +107,7 @@
* - [@ref ChunkExecutionState.COM_ES_EXECUTED]: Chunk is finished
*
* @see ExecutionGroup.execute
- * @see ViewerBaseOperation.getChunkOrder
+ * @see ViewerOperation.getChunkOrder
* @see OrderOfChunks
*
* @section interest Area of interest
Modified: trunk/blender/source/blender/compositor/intern/COM_ExecutionGroup.cpp
===================================================================
--- trunk/blender/source/blender/compositor/intern/COM_ExecutionGroup.cpp
2013-08-05 19:06:37 UTC (rev 58942)
+++ trunk/blender/source/blender/compositor/intern/COM_ExecutionGroup.cpp
2013-08-05 19:16:52 UTC (rev 58943)
@@ -248,7 +248,7 @@
OrderOfChunks chunkorder = COM_ORDER_OF_CHUNKS_DEFAULT;
if (operation->isViewerOperation()) {
- ViewerBaseOperation *viewer = (ViewerBaseOperation *)operation;
+ ViewerOperation *viewer = (ViewerOperation *)operation;
centerX = viewer->getCenterX();
centerY = viewer->getCenterY();
chunkorder = viewer->getChunkOrder();
Modified:
trunk/blender/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp
===================================================================
---
trunk/blender/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp
2013-08-05 19:06:37 UTC (rev 58942)
+++
trunk/blender/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp
2013-08-05 19:16:52 UTC (rev 58943)
@@ -36,7 +36,7 @@
#include "COM_GroupNode.h"
#include "COM_WriteBufferOperation.h"
#include "COM_ReadBufferOperation.h"
-#include "COM_ViewerBaseOperation.h"
+#include "COM_ViewerOperation.h"
extern "C" {
#include "BKE_node.h"
@@ -212,7 +212,7 @@
printf("|");
}
if (operation->isViewerOperation()) {
- ViewerBaseOperation *viewer = (ViewerBaseOperation
*)operation;
+ ViewerOperation *viewer = (ViewerOperation *)operation;
if (viewer->isActiveViewerOutput()) {
printf("Active viewer");
}
Modified: trunk/blender/source/blender/compositor/nodes/COM_SplitViewerNode.cpp
===================================================================
--- trunk/blender/source/blender/compositor/nodes/COM_SplitViewerNode.cpp
2013-08-05 19:06:37 UTC (rev 58942)
+++ trunk/blender/source/blender/compositor/nodes/COM_SplitViewerNode.cpp
2013-08-05 19:16:52 UTC (rev 58943)
@@ -23,7 +23,8 @@
#include "COM_SplitViewerNode.h"
#include "BKE_global.h"
-#include "COM_SplitViewerOperation.h"
+#include "COM_SplitOperation.h"
+#include "COM_ViewerOperation.h"
#include "COM_ExecutionSystem.h"
SplitViewerNode::SplitViewerNode(bNode *editorNode) : Node(editorNode)
@@ -42,29 +43,32 @@
InputSocket *image2Socket = this->getInputSocket(1);
Image *image = (Image *)this->getbNode()->id;
ImageUser *imageUser = (ImageUser *) this->getbNode()->storage;
- if (image1Socket->isConnected() && image2Socket->isConnected()) {
- SplitViewerOperation *splitViewerOperation = new
SplitViewerOperation();
- splitViewerOperation->setImage(image);
- splitViewerOperation->setImageUser(imageUser);
- splitViewerOperation->setActive(is_active);
-
splitViewerOperation->setSplitPercentage(this->getbNode()->custom1);
-
splitViewerOperation->setViewSettings(context->getViewSettings());
-
splitViewerOperation->setDisplaySettings(context->getDisplaySettings());
+ SplitOperation *splitViewerOperation = new SplitOperation();
+ splitViewerOperation->setSplitPercentage(this->getbNode()->custom1);
+ splitViewerOperation->setXSplit(!this->getbNode()->custom2);
- /* defaults - the viewer node has these options but not exposed
for split view
- * we could use the split to define an area of interest on one
axis at least */
-
splitViewerOperation->setChunkOrder(COM_ORDER_OF_CHUNKS_DEFAULT);
- splitViewerOperation->setCenterX(0.5f);
- splitViewerOperation->setCenterY(0.5f);
+
image1Socket->relinkConnections(splitViewerOperation->getInputSocket(0), 0,
graph);
+
image2Socket->relinkConnections(splitViewerOperation->getInputSocket(1), 1,
graph);
- splitViewerOperation->setXSplit(!this->getbNode()->custom2);
-
image1Socket->relinkConnections(splitViewerOperation->getInputSocket(0), 0,
graph);
-
image2Socket->relinkConnections(splitViewerOperation->getInputSocket(1), 1,
graph);
+ ViewerOperation *viewerOperation = new ViewerOperation();
+ viewerOperation->setImage(image);
+ viewerOperation->setImageUser(imageUser);
+ viewerOperation->setActive(is_active);
+ viewerOperation->setViewSettings(context->getViewSettings());
+ viewerOperation->setDisplaySettings(context->getDisplaySettings());
- if (is_active)
- addPreviewOperation(graph, context,
splitViewerOperation->getInputSocket(0));
+ /* defaults - the viewer node has these options but not exposed for
split view
+ * we could use the split to define an area of interest on one axis at
least */
+ viewerOperation->setChunkOrder(COM_ORDER_OF_CHUNKS_DEFAULT);
+ viewerOperation->setCenterX(0.5f);
+ viewerOperation->setCenterY(0.5f);
- graph->addOperation(splitViewerOperation);
- }
+ addLink(graph, splitViewerOperation->getOutputSocket(),
viewerOperation->getInputSocket(0));
+
+ if (is_active)
+ addPreviewOperation(graph, context,
viewerOperation->getInputSocket(0));
+
+ graph->addOperation(splitViewerOperation);
+ graph->addOperation(viewerOperation);
}
Copied:
trunk/blender/source/blender/compositor/operations/COM_SplitOperation.cpp (from
rev 58938,
trunk/blender/source/blender/compositor/operations/COM_SplitViewerOperation.cpp)
===================================================================
--- trunk/blender/source/blender/compositor/operations/COM_SplitOperation.cpp
(rev 0)
+++ trunk/blender/source/blender/compositor/operations/COM_SplitOperation.cpp
2013-08-05 19:16:52 UTC (rev 58943)
@@ -0,0 +1,81 @@
+/*
+ * 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:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_SplitOperation.h"
+#include "COM_SocketConnection.h"
+#include "BLI_listbase.h"
+#include "BKE_image.h"
+#include "BLI_utildefines.h"
+#include "BLI_math_color.h"
+#include "BLI_math_vector.h"
+
+extern "C" {
+ #include "MEM_guardedalloc.h"
+ #include "IMB_imbuf.h"
+ #include "IMB_imbuf_types.h"
+}
+
+
+SplitOperation::SplitOperation() : NodeOperation()
+{
+ this->addInputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->m_image1Input = NULL;
+ this->m_image2Input = NULL;
+}
+
+void SplitOperation::initExecution()
+{
+ // When initializing the tree during initial load the width and height
can be zero.
+ this->m_image1Input = getInputSocketReader(0);
+ this->m_image2Input = getInputSocketReader(1);
+}
+
+void SplitOperation::deinitExecution()
+{
+ this->m_image1Input = NULL;
+ this->m_image2Input = NULL;
+}
+
+void SplitOperation::executePixel(float output[4], float x, float y,
PixelSampler sampler)
+{
+ int perc = this->m_xSplit ? this->m_splitPercentage * this->getWidth()
/ 100.0f : this->m_splitPercentage * this->getHeight() / 100.0f;
+ bool image1 = this->m_xSplit ? x > perc : y > perc;
+ if (image1) {
+ this->m_image1Input->read(output, x, y, COM_PS_NEAREST);
+ }
+ else {
+ this->m_image2Input->read(output, x, y, COM_PS_NEAREST);
+ }
+}
+
+void SplitOperation::determineResolution(unsigned int resolution[2], unsigned
int preferredResolution[2])
+{
+ unsigned int tempPreferredResolution[2] = {0, 0};
+ unsigned int tempResolution[2];
+
+ this->getInputSocket(0)->determineResolution(tempResolution,
tempPreferredResolution);
+ this->setResolutionInputSocketIndex((tempResolution[0] &&
tempResolution[1]) ? 0 : 1);
+
+ NodeOperation::determineResolution(resolution, preferredResolution);
+}
Copied: trunk/blender/source/blender/compositor/operations/COM_SplitOperation.h
(from rev 58938,
trunk/blender/source/blender/compositor/operations/COM_SplitViewerOperation.h)
===================================================================
--- trunk/blender/source/blender/compositor/operations/COM_SplitOperation.h
(rev 0)
+++ trunk/blender/source/blender/compositor/operations/COM_SplitOperation.h
2013-08-05 19:16:52 UTC (rev 58943)
@@ -0,0 +1,43 @@
+/*
+ * 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.
+ *
@@ Diff output truncated at 10240 characters. @@
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs