[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [55451] trunk/blender/source/blender: Changes to compositor output node

Sergey Sharybin sergey.vfx at gmail.com
Wed Mar 20 19:01:47 CET 2013


Revision: 55451
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=55451
Author:   nazgul
Date:     2013-03-20 18:01:47 +0000 (Wed, 20 Mar 2013)
Log Message:
-----------
Changes to compositor output node

Make it so compositor output node wouldn't be calculated
when Render Result image is not visible on the screen.
This makes compositor tree editing more friendly and
faster.

Also, if there's no viewer image visible on the screen
viewer nodes wouldn't be handled.

Final rendering keeps unchanged for now.

This solves issues when for performance artists are
disconnecting compo output node before tweaking values
in compositor and forgets to attach compo output
node before sending file to the farm.

Modified Paths:
--------------
    trunk/blender/source/blender/compositor/nodes/COM_CompositorNode.cpp
    trunk/blender/source/blender/compositor/nodes/COM_SplitViewerNode.cpp
    trunk/blender/source/blender/compositor/nodes/COM_ViewerNode.cpp
    trunk/blender/source/blender/compositor/operations/COM_CompositorOperation.cpp
    trunk/blender/source/blender/compositor/operations/COM_CompositorOperation.h
    trunk/blender/source/blender/editors/space_node/node_edit.c
    trunk/blender/source/blender/makesdna/DNA_node_types.h

Modified: trunk/blender/source/blender/compositor/nodes/COM_CompositorNode.cpp
===================================================================
--- trunk/blender/source/blender/compositor/nodes/COM_CompositorNode.cpp	2013-03-20 18:01:41 UTC (rev 55450)
+++ trunk/blender/source/blender/compositor/nodes/COM_CompositorNode.cpp	2013-03-20 18:01:47 UTC (rev 55451)
@@ -32,6 +32,8 @@
 void CompositorNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
 {
 	bNode *editorNode = this->getbNode();
+	bool is_active = (editorNode->flag & NODE_DO_OUTPUT_RECALC) ||
+	                 context->isRendering();
 
 	InputSocket *imageSocket = this->getInputSocket(0);
 	InputSocket *alphaSocket = this->getInputSocket(1);
@@ -42,10 +44,12 @@
 	compositorOperation->setRenderData(context->getRenderData());
 	compositorOperation->setbNodeTree(context->getbNodeTree());
 	compositorOperation->setIgnoreAlpha(editorNode->custom2 & CMP_NODE_OUTPUT_IGNORE_ALPHA);
+	compositorOperation->setActive(is_active);
 	imageSocket->relinkConnections(compositorOperation->getInputSocket(0), 0, graph);
 	alphaSocket->relinkConnections(compositorOperation->getInputSocket(1));
 	depthSocket->relinkConnections(compositorOperation->getInputSocket(2));
 	graph->addOperation(compositorOperation);
-	addPreviewOperation(graph, context, compositorOperation->getInputSocket(0));
+
+	if (is_active)
+		addPreviewOperation(graph, context, compositorOperation->getInputSocket(0));
 }
-

Modified: trunk/blender/source/blender/compositor/nodes/COM_SplitViewerNode.cpp
===================================================================
--- trunk/blender/source/blender/compositor/nodes/COM_SplitViewerNode.cpp	2013-03-20 18:01:41 UTC (rev 55450)
+++ trunk/blender/source/blender/compositor/nodes/COM_SplitViewerNode.cpp	2013-03-20 18:01:47 UTC (rev 55451)
@@ -33,6 +33,11 @@
 
 void SplitViewerNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
 {
+	bNode *editorNode = this->getbNode();
+	bool is_active = ((editorNode->flag & NODE_DO_OUTPUT_RECALC) &&
+	                  (editorNode->flag & NODE_DO_OUTPUT) && this->isInActiveGroup()) ||
+	                 context->isRendering();
+
 	InputSocket *image1Socket = this->getInputSocket(0);
 	InputSocket *image2Socket = this->getInputSocket(1);
 	Image *image = (Image *)this->getbNode()->id;
@@ -41,7 +46,7 @@
 		SplitViewerOperation *splitViewerOperation = new SplitViewerOperation();
 		splitViewerOperation->setImage(image);
 		splitViewerOperation->setImageUser(imageUser);
-		splitViewerOperation->setActive((this->getbNode()->flag & NODE_DO_OUTPUT) && this->isInActiveGroup());
+		splitViewerOperation->setActive(is_active);
 		splitViewerOperation->setSplitPercentage(this->getbNode()->custom1);
 
 		splitViewerOperation->setViewSettings(context->getViewSettings());
@@ -56,7 +61,10 @@
 		splitViewerOperation->setXSplit(!this->getbNode()->custom2);
 		image1Socket->relinkConnections(splitViewerOperation->getInputSocket(0), 0, graph);
 		image2Socket->relinkConnections(splitViewerOperation->getInputSocket(1), 1, graph);
-		addPreviewOperation(graph, context, splitViewerOperation->getInputSocket(0));
+
+		if (is_active)
+			addPreviewOperation(graph, context, splitViewerOperation->getInputSocket(0));
+
 		graph->addOperation(splitViewerOperation);
 	}
 }

Modified: trunk/blender/source/blender/compositor/nodes/COM_ViewerNode.cpp
===================================================================
--- trunk/blender/source/blender/compositor/nodes/COM_ViewerNode.cpp	2013-03-20 18:01:41 UTC (rev 55450)
+++ trunk/blender/source/blender/compositor/nodes/COM_ViewerNode.cpp	2013-03-20 18:01:47 UTC (rev 55451)
@@ -33,17 +33,21 @@
 
 void ViewerNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
 {
+	bNode *editorNode = this->getbNode();
+	bool is_active = ((editorNode->flag & NODE_DO_OUTPUT_RECALC) &&
+	                  (editorNode->flag & NODE_DO_OUTPUT) && this->isInActiveGroup()) ||
+	                 context->isRendering();
+
 	InputSocket *imageSocket = this->getInputSocket(0);
 	InputSocket *alphaSocket = this->getInputSocket(1);
 	InputSocket *depthSocket = this->getInputSocket(2);
 	Image *image = (Image *)this->getbNode()->id;
 	ImageUser *imageUser = (ImageUser *) this->getbNode()->storage;
-	bNode *editorNode = this->getbNode();
 	ViewerOperation *viewerOperation = new ViewerOperation();
 	viewerOperation->setbNodeTree(context->getbNodeTree());
 	viewerOperation->setImage(image);
 	viewerOperation->setImageUser(imageUser);
-	viewerOperation->setActive((editorNode->flag & NODE_DO_OUTPUT) && this->isInActiveGroup());
+	viewerOperation->setActive(is_active);
 	viewerOperation->setChunkOrder((OrderOfChunks)editorNode->custom1);
 	viewerOperation->setCenterX(editorNode->custom3);
 	viewerOperation->setCenterY(editorNode->custom4);
@@ -63,5 +67,7 @@
 	alphaSocket->relinkConnections(viewerOperation->getInputSocket(1));
 	depthSocket->relinkConnections(viewerOperation->getInputSocket(2));
 	graph->addOperation(viewerOperation);
-	addPreviewOperation(graph, context, viewerOperation->getInputSocket(0));
+
+	if (is_active)
+		addPreviewOperation(graph, context, viewerOperation->getInputSocket(0));
 }

Modified: trunk/blender/source/blender/compositor/operations/COM_CompositorOperation.cpp
===================================================================
--- trunk/blender/source/blender/compositor/operations/COM_CompositorOperation.cpp	2013-03-20 18:01:41 UTC (rev 55450)
+++ trunk/blender/source/blender/compositor/operations/COM_CompositorOperation.cpp	2013-03-20 18:01:47 UTC (rev 55451)
@@ -50,12 +50,16 @@
 	this->m_depthInput = NULL;
 
 	this->m_ignoreAlpha = false;
+	this->m_active = false;
 
 	this->m_sceneName[0] = '\0';
 }
 
 void CompositorOperation::initExecution()
 {
+	if (!this->m_active)
+		return;
+
 	// When initializing the tree during initial load the width and height can be zero.
 	this->m_imageInput = getInputSocketReader(0);
 	this->m_alphaInput = getInputSocketReader(1);
@@ -70,6 +74,9 @@
 
 void CompositorOperation::deinitExecution()
 {
+	if (!this->m_active)
+		return;
+
 	if (!isBreaked()) {
 		Render *re = RE_GetRender(this->m_sceneName);
 		RenderResult *rr = RE_AcquireResultWrite(re);

Modified: trunk/blender/source/blender/compositor/operations/COM_CompositorOperation.h
===================================================================
--- trunk/blender/source/blender/compositor/operations/COM_CompositorOperation.h	2013-03-20 18:01:41 UTC (rev 55450)
+++ trunk/blender/source/blender/compositor/operations/COM_CompositorOperation.h	2013-03-20 18:01:47 UTC (rev 55451)
@@ -66,19 +66,28 @@
 	 */
 	SocketReader *m_depthInput;
 
-	/* Ignore any alpha input */
+	/**
+	 * @brief Ignore any alpha input
+	 */
 	bool m_ignoreAlpha;
 
+	/**
+	 * @brief operation is active for calculating final compo result
+	 */
+	bool m_active;
 public:
 	CompositorOperation();
+	const bool isActiveCompositorOutput() const { return this->m_active; }
 	void executeRegion(rcti *rect, unsigned int tileNumber);
 	void setSceneName(const char *sceneName) { BLI_strncpy(this->m_sceneName, sceneName, sizeof(this->m_sceneName)); }
 	void setRenderData(const RenderData *rd) { this->m_rd = rd; }
-	bool isOutputOperation(bool rendering) const { return true; }
+	bool isOutputOperation(bool rendering) const { return this->isActiveCompositorOutput(); }
 	void initExecution();
 	void deinitExecution();
 	const CompositorPriority getRenderPriority() const { return COM_PRIORITY_MEDIUM; }
 	void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
 	void setIgnoreAlpha(bool value) { this->m_ignoreAlpha = value; }
+	void setActive(bool active) { this->m_active = active; }
 };
 #endif
+

Modified: trunk/blender/source/blender/editors/space_node/node_edit.c
===================================================================
--- trunk/blender/source/blender/editors/space_node/node_edit.c	2013-03-20 18:01:41 UTC (rev 55450)
+++ trunk/blender/source/blender/editors/space_node/node_edit.c	2013-03-20 18:01:47 UTC (rev 55451)
@@ -90,6 +90,11 @@
 
 /* ***************** composite job manager ********************** */
 
+enum {
+	COM_RECALC_COMPOSITE = 1,
+	COM_RECALC_VIEWER    = 2
+};
+
 typedef struct CompoJob {
 	Scene *scene;
 	bNodeTree *ntree;
@@ -98,8 +103,55 @@
 	short *do_update;
 	float *progress;
 	short need_sync;
+	int recalc_flags;
 } CompoJob;
 
+static void compo_tag_output_nodes(bNodeTree *nodetree, int recalc_flags)
+{
+	bNode *node;
+
+	for (node = nodetree->nodes.first; node; node = node->next) {
+		if (node->type == CMP_NODE_COMPOSITE) {
+			if (recalc_flags & COM_RECALC_COMPOSITE)
+				node->flag |= NODE_DO_OUTPUT_RECALC;
+		}
+		else if (node->type == CMP_NODE_VIEWER) {
+			if (recalc_flags & COM_RECALC_VIEWER)
+				node->flag |= NODE_DO_OUTPUT_RECALC;
+		}
+		else if (node->type == NODE_GROUP) {
+			if (node->id)
+				compo_tag_output_nodes((bNodeTree *)node->id, recalc_flags);
+		}
+	}
+}
+
+static int compo_get_recalc_flags(const bContext *C)
+{
+	bScreen *sc = CTX_wm_screen(C);
+	ScrArea *sa;
+	int recalc_flags = 0;
+
+	for (sa = sc->areabase.first; sa; sa = sa->next) {
+		if (sa->spacetype == SPACE_IMAGE) {
+			SpaceImage *sima = sa->spacedata.first;
+			if (sima->image) {
+				if (sima->image->type == IMA_TYPE_R_RESULT)
+					recalc_flags |= COM_RECALC_COMPOSITE;
+				else if (sima->image->type == IMA_TYPE_COMPOSITE)
+					recalc_flags |= COM_RECALC_VIEWER;
+			}
+		}
+		else if (sa->spacetype == SPACE_NODE) {
+			SpaceNode *snode = sa->spacedata.first;
+			if (snode->flag & SNODE_BACKDRAW)
+				recalc_flags |= COM_RECALC_VIEWER;
+		}
+	}
+
+	return recalc_flags;
+}
+
 /* called by compo, only to check job 'stop' value */
 static int compo_breakjob(void *cjv)
 {
@@ -148,6 +200,9 @@
 	CompoJob *cj = cjv;
 
 	cj->localtree = ntreeLocalize(cj->ntree);
+
+	if (cj->recalc_flags)
+		compo_tag_output_nodes(cj->localtree, cj->recalc_flags);
 }
 
 /* called before redraw notifiers, it moves finished previews over */
@@ -234,6 +289,7 @@
 	/* customdata for preview thread */
 	cj->scene = CTX_data_scene(C);
 	cj->ntree = nodetree;
+	cj->recalc_flags = compo_get_recalc_flags(C);
 
 	/* setup job */
 	WM_jobs_customdata_set(wm_job, cj, compo_freejob);

Modified: trunk/blender/source/blender/makesdna/DNA_node_types.h
===================================================================

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list