diff options
author | Jeroen Bakker <j.bakker@atmind.nl> | 2012-06-12 08:23:21 +0400 |
---|---|---|
committer | Jeroen Bakker <j.bakker@atmind.nl> | 2012-06-12 08:23:21 +0400 |
commit | ac5a735e3fe9fe29e38e3a20c20da87b27feb112 (patch) | |
tree | 52059f3dbc9827eb498abe772e763e541b3b3608 /source/blender/compositor/intern | |
parent | 7977078227d6da77e294dd860f4685387f0bae56 (diff) |
* FIX for
- [#31777] Border Crop gives black
- [#31768] Crash when connecting a Math node to a translate node in Tiles comp
- [#31638] View node in new node compo system crashes when inside a group
* make sure a very fast vignette can be made by using a EliipseMask + Fast Gaussian blur
Diffstat (limited to 'source/blender/compositor/intern')
10 files changed, 110 insertions, 28 deletions
diff --git a/source/blender/compositor/intern/COM_CompositorContext.cpp b/source/blender/compositor/intern/COM_CompositorContext.cpp index 911de822f80..bb8e7d9606d 100644 --- a/source/blender/compositor/intern/COM_CompositorContext.cpp +++ b/source/blender/compositor/intern/COM_CompositorContext.cpp @@ -29,6 +29,7 @@ CompositorContext::CompositorContext() this->scene = NULL; this->quality = COM_QUALITY_HIGH; this->hasActiveOpenCLDevices = false; + this->activegNode = NULL; } const int CompositorContext::getFramenumber() const diff --git a/source/blender/compositor/intern/COM_CompositorContext.h b/source/blender/compositor/intern/COM_CompositorContext.h index 2889f43290e..8425030aec2 100644 --- a/source/blender/compositor/intern/COM_CompositorContext.h +++ b/source/blender/compositor/intern/COM_CompositorContext.h @@ -63,6 +63,11 @@ private: * @see ExecutionSystem */ bNodeTree *bnodetree; + + /** + * @brief activegNode the group node that is currently being edited. + */ + bNode *activegNode; /** * @brief does this system have active opencl devices? @@ -101,6 +106,16 @@ public: const bNodeTree * getbNodeTree() const {return this->bnodetree;} /** + * @brief set the active groupnode of the context + */ + void setActivegNode(bNode *gnode) {this->activegNode = gnode;} + + /** + * @brief get the active groupnode of the context + */ + const bNode * getActivegNode() const {return this->activegNode;} + + /** * @brief get the scene of the context */ const Scene *getScene() const {return this->scene;} diff --git a/source/blender/compositor/intern/COM_ExecutionGroup.cpp b/source/blender/compositor/intern/COM_ExecutionGroup.cpp index 481b83c81a3..e46b4934217 100644 --- a/source/blender/compositor/intern/COM_ExecutionGroup.cpp +++ b/source/blender/compositor/intern/COM_ExecutionGroup.cpp @@ -184,11 +184,8 @@ void ExecutionGroup::deinitExecution() void ExecutionGroup::determineResolution(unsigned int resolution[]) { NodeOperation *operation = this->getOutputNodeOperation(); - unsigned int preferredResolution[2]; - preferredResolution[0] = 0; - preferredResolution[1] = 0; - operation->determineResolution(resolution, preferredResolution); - operation->setResolution(resolution); + resolution[0] = operation->getWidth(); + resolution[1] = operation->getHeight(); this->setResolution(resolution); } diff --git a/source/blender/compositor/intern/COM_ExecutionSystem.cpp b/source/blender/compositor/intern/COM_ExecutionSystem.cpp index 8c0b37a0685..1056c6d3f65 100644 --- a/source/blender/compositor/intern/COM_ExecutionSystem.cpp +++ b/source/blender/compositor/intern/COM_ExecutionSystem.cpp @@ -41,7 +41,14 @@ ExecutionSystem::ExecutionSystem(bNodeTree *editingtree, bool rendering) { - this->context.setbNodeTree(editingtree); + context.setbNodeTree(editingtree); + bNode* gnode; + for (gnode = (bNode*)editingtree->nodes.first ; gnode ; gnode = (bNode*)gnode->next) { + if (gnode->type == NODE_GROUP && gnode->typeinfo->group_edit_get(gnode)) { + context.setActivegNode(gnode); + break; + } + } /* initialize the CompositorContext */ if (rendering) { @@ -55,25 +62,25 @@ ExecutionSystem::ExecutionSystem(bNodeTree *editingtree, bool rendering) Node *mainOutputNode=NULL; - mainOutputNode = ExecutionSystemHelper::addbNodeTree(*this, 0, editingtree); + mainOutputNode = ExecutionSystemHelper::addbNodeTree(*this, 0, editingtree, NULL); if (mainOutputNode) { context.setScene((Scene*)mainOutputNode->getbNode()->id); this->convertToOperations(); this->groupOperations(); /* group operations in ExecutionGroups */ - vector<ExecutionGroup*> executionGroups; - this->findOutputExecutionGroup(&executionGroups); unsigned int index; unsigned int resolution[2]; - for (index = 0 ; index < executionGroups.size(); index ++) { + for (index = 0 ; index < this->groups.size(); index ++) { resolution[0]=0; resolution[1]=0; - ExecutionGroup *executionGroup = executionGroups[index]; + ExecutionGroup *executionGroup = groups[index]; executionGroup->determineResolution(resolution); } } - if (G.f & G_DEBUG) ExecutionSystemHelper::debugDump(this); +#ifdef COM_DEBUG + ExecutionSystemHelper::debugDump(this); +#endif } ExecutionSystem::~ExecutionSystem() @@ -180,11 +187,13 @@ void ExecutionSystem::addReadWriteBufferOperations(NodeOperation *operation) writeoperation->setbNodeTree(this->getContext().getbNodeTree()); this->addOperation(writeoperation); ExecutionSystemHelper::addLink(this->getConnections(), fromsocket, writeoperation->getInputSocket(0)); + writeoperation->readResolutionFromInputSocket(); } ReadBufferOperation *readoperation = new ReadBufferOperation(); readoperation->setMemoryProxy(writeoperation->getMemoryProxy()); connection->setFromSocket(readoperation->getOutputSocket()); readoperation->getOutputSocket()->addConnection(connection); + readoperation->readResolutionFromWriteBuffer(); this->addOperation(readoperation); } } @@ -207,9 +216,11 @@ void ExecutionSystem::addReadWriteBufferOperations(NodeOperation *operation) readoperation->setMemoryProxy(writeOperation->getMemoryProxy()); connection->setFromSocket(readoperation->getOutputSocket()); readoperation->getOutputSocket()->addConnection(connection); + readoperation->readResolutionFromWriteBuffer(); this->addOperation(readoperation); } ExecutionSystemHelper::addLink(this->getConnections(), outputsocket, writeOperation->getInputSocket(0)); + writeOperation->readResolutionFromInputSocket(); } } @@ -237,7 +248,16 @@ void ExecutionSystem::convertToOperations() // determine all resolutions of the operations (Width/Height) for (index = 0 ; index < this->operations.size(); index ++) { NodeOperation *operation = this->operations[index]; - if (operation->isOutputOperation(context.isRendering())) { + if (operation->isOutputOperation(context.isRendering()) && !operation->isPreviewOperation()) { + unsigned int resolution[2] = {0,0}; + unsigned int preferredResolution[2] = {0,0}; + operation->determineResolution(resolution, preferredResolution); + operation->setResolution(resolution); + } + } + for (index = 0 ; index < this->operations.size(); index ++) { + NodeOperation *operation = this->operations[index]; + if (operation->isOutputOperation(context.isRendering()) && operation->isPreviewOperation()) { unsigned int resolution[2] = {0,0}; unsigned int preferredResolution[2] = {0,0}; operation->determineResolution(resolution, preferredResolution); diff --git a/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp b/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp index 67554cd464b..75be8df74de 100644 --- a/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp +++ b/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp @@ -35,16 +35,20 @@ #include "COM_GroupNode.h" #include "COM_WriteBufferOperation.h" #include "COM_ReadBufferOperation.h" +#include "COM_ViewerBaseOperation.h" -Node *ExecutionSystemHelper::addbNodeTree(ExecutionSystem &system, int nodes_start, bNodeTree *tree) +Node *ExecutionSystemHelper::addbNodeTree(ExecutionSystem &system, int nodes_start, bNodeTree * tree, bNode *groupnode) { vector<Node*>& nodes = system.getNodes(); vector<SocketConnection*>& links = system.getConnections(); Node *mainnode = NULL; + const bNode * activeGroupNode = system.getContext().getActivegNode(); + bool isActiveGroup = activeGroupNode == groupnode; + /* add all nodes of the tree to the node list */ bNode *node = (bNode*)tree->nodes.first; while (node != NULL) { - Node *execnode = addNode(nodes, node); + Node *execnode = addNode(nodes, node, isActiveGroup); if (node->type == CMP_NODE_COMPOSITE) { mainnode = execnode; } @@ -77,11 +81,12 @@ void ExecutionSystemHelper::addNode(vector<Node*>& nodes, Node *node) nodes.push_back(node); } -Node *ExecutionSystemHelper::addNode(vector<Node*>& nodes, bNode *bNode) +Node *ExecutionSystemHelper::addNode(vector<Node*>& nodes, bNode *bNode, bool inActiveGroup) { Converter converter; Node * node; node = converter.convert(bNode); + node->setIsInActiveGroup(inActiveGroup); if (node != NULL) { addNode(nodes, node); return node; @@ -232,7 +237,12 @@ void ExecutionSystemHelper::debugDump(ExecutionSystem *system) printf("|"); } if (operation->isViewerOperation()) { - printf("Viewer"); + ViewerBaseOperation * viewer = (ViewerBaseOperation*)operation; + if (viewer->isActiveViewerOutput()) { + printf("Active viewer"); + } else { + printf("Viewer"); + } } else if (operation->isOutputOperation(system->getContext().isRendering())) { printf("Output"); @@ -249,6 +259,7 @@ void ExecutionSystemHelper::debugDump(ExecutionSystem *system) else { printf("O_%p", operation); } + printf(" (%d,%d)", operation->getWidth(), operation->getHeight()); tot2 = operation->getNumberOfOutputSockets(); if (tot2 != 0) { printf("|"); diff --git a/source/blender/compositor/intern/COM_ExecutionSystemHelper.h b/source/blender/compositor/intern/COM_ExecutionSystemHelper.h index a72e269115e..9321cb571e8 100644 --- a/source/blender/compositor/intern/COM_ExecutionSystemHelper.h +++ b/source/blender/compositor/intern/COM_ExecutionSystemHelper.h @@ -48,7 +48,7 @@ public: * @param tree bNodeTree to add * @return Node representing the "Compositor node" of the maintree. or NULL when a subtree is added */ - static Node *addbNodeTree(ExecutionSystem &system, int nodes_start, bNodeTree * tree); + static Node *addbNodeTree(ExecutionSystem &system, int nodes_start, bNodeTree* tree, bNode *groupnode); /** * @brief add an editor node to the system. @@ -58,7 +58,7 @@ public: * @param bNode node to add * @return Node that represents the bNode or null when not able to convert. */ - static Node *addNode(vector<Node*>& nodes, bNode *bNode); + static Node *addNode(vector<Node*>& nodes, bNode *bNode, bool isInActiveGroup); /** * @brief Add a Node to a list diff --git a/source/blender/compositor/intern/COM_Node.cpp b/source/blender/compositor/intern/COM_Node.cpp index 264725b4b2c..2324eacd26c 100644 --- a/source/blender/compositor/intern/COM_Node.cpp +++ b/source/blender/compositor/intern/COM_Node.cpp @@ -85,16 +85,18 @@ void Node::addSetValueOperation(ExecutionSystem *graph, InputSocket *inputsocket void Node::addPreviewOperation(ExecutionSystem *system, OutputSocket *outputSocket) { - PreviewOperation *operation = new PreviewOperation(); - system->addOperation(operation); - operation->setbNode(this->getbNode()); - operation->setbNodeTree(system->getContext().getbNodeTree()); - this->addLink(system, outputSocket, operation->getInputSocket(0)); + if (this->isInActiveGroup()) { + PreviewOperation *operation = new PreviewOperation(); + system->addOperation(operation); + operation->setbNode(this->getbNode()); + operation->setbNodeTree(system->getContext().getbNodeTree()); + this->addLink(system, outputSocket, operation->getInputSocket(0)); + } } void Node::addPreviewOperation(ExecutionSystem *system, InputSocket *inputSocket) { - if (inputSocket->isConnected()) { + if (inputSocket->isConnected() && this->isInActiveGroup()) { OutputSocket *outputsocket = inputSocket->getConnection()->getFromSocket(); this->addPreviewOperation(system, outputsocket); } diff --git a/source/blender/compositor/intern/COM_Node.h b/source/blender/compositor/intern/COM_Node.h index 23744adf642..0546062f790 100644 --- a/source/blender/compositor/intern/COM_Node.h +++ b/source/blender/compositor/intern/COM_Node.h @@ -52,6 +52,11 @@ private: */ bNode *editorNode; + /** + * @brief Is this node part of the active group + */ + bool inActiveGroup; + public: Node(bNode *editorNode, bool create_sockets=true); @@ -61,6 +66,20 @@ public: bNode *getbNode(); /** + * @brief Is this node in the active group (the group that is being edited) + * @param isInActiveGroup + */ + void setIsInActiveGroup(bool isInActiveGroup) {this->inActiveGroup = isInActiveGroup; } + + /** + * @brief Is this node part of the active group + * the active group is the group that is currently being edited. When no group is edited, + * the active group will be the main tree (all nodes that are not part of a group will be active) + * @return bool [false:true] + */ + inline bool isInActiveGroup() {return this->inActiveGroup;} + + /** * @brief convert node to operation * * @todo this must be described furter diff --git a/source/blender/compositor/intern/COM_NodeOperation.h b/source/blender/compositor/intern/COM_NodeOperation.h index 2219907b0c8..db1fdda0bcf 100644 --- a/source/blender/compositor/intern/COM_NodeOperation.h +++ b/source/blender/compositor/intern/COM_NodeOperation.h @@ -160,11 +160,22 @@ public: virtual void deinitExecution(); void deinitMutex(); + bool isResolutionSet() { + return this->width != 0 && height != 0; + } + /** * @brief set the resolution * @param resolution the resolution to set */ - void setResolution(unsigned int resolution[]) {this->width = resolution[0];this->height = resolution[1];} + void setResolution(unsigned int resolution[]) { + if (!isResolutionSet()) { + this->width = resolution[0]; + this->height = resolution[1]; + } + } + + void getConnectedInputSockets(vector<InputSocket*> *sockets); /** @@ -221,6 +232,7 @@ public: bool isOpenCL() { return this->openCL; } virtual bool isViewerOperation() {return false;} + virtual bool isPreviewOperation() {return false;} protected: NodeOperation(); diff --git a/source/blender/compositor/intern/COM_OutputSocket.cpp b/source/blender/compositor/intern/COM_OutputSocket.cpp index 00d3518cd15..708b2d65d46 100644 --- a/source/blender/compositor/intern/COM_OutputSocket.cpp +++ b/source/blender/compositor/intern/COM_OutputSocket.cpp @@ -47,8 +47,13 @@ void OutputSocket::determineResolution(unsigned int resolution[], unsigned int p NodeBase *node = this->getNode(); if (node->isOperation()) { NodeOperation *operation = (NodeOperation*)node; - operation->determineResolution(resolution, preferredResolution); - operation->setResolution(resolution); + if (operation->isResolutionSet()) { + resolution[0] = operation->getWidth(); + resolution[1] = operation->getHeight(); + } else { + operation->determineResolution(resolution, preferredResolution); + operation->setResolution(resolution); + } } } |