Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2013-02-04 20:12:42 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2013-02-04 20:12:42 +0400
commit03687b7c66d7064870bbe8d01f889c85de1fad7d (patch)
treeb5a081058b582e3d40b79e58f2c601f31394ea7c /source
parent7c9d99334705498932a272f68f74121953d4974a (diff)
Compositor "Relative" option for Translate node, same as for other nodes this
makes it possible to specify an offset relative to the render resolution (so 0.5 is half the image rather than giving the number of pixels). It's a bit late but it's a trivial change and needed for 4k mango render.
Diffstat (limited to 'source')
-rw-r--r--source/blender/compositor/nodes/COM_TranslateNode.cpp12
-rw-r--r--source/blender/compositor/operations/COM_TranslateOperation.cpp9
-rw-r--r--source/blender/compositor/operations/COM_TranslateOperation.h8
-rw-r--r--source/blender/editors/space_node/drawnode.c1
-rw-r--r--source/blender/makesdna/DNA_node_types.h4
-rw-r--r--source/blender/makesrna/intern/rna_nodetree.c5
6 files changed, 34 insertions, 5 deletions
diff --git a/source/blender/compositor/nodes/COM_TranslateNode.cpp b/source/blender/compositor/nodes/COM_TranslateNode.cpp
index 1d21b23fa74..887190b44b9 100644
--- a/source/blender/compositor/nodes/COM_TranslateNode.cpp
+++ b/source/blender/compositor/nodes/COM_TranslateNode.cpp
@@ -38,10 +38,18 @@ void TranslateNode::convertToOperations(ExecutionSystem *graph, CompositorContex
OutputSocket *outputSocket = this->getOutputSocket(0);
TranslateOperation *operation = new TranslateOperation();
- bNode *editorNode = this->getbNode();
- NodeTranslateData *data = (NodeTranslateData *)editorNode->storage;
+ bNode *bnode = this->getbNode();
+ NodeTranslateData *data = (NodeTranslateData *)bnode->storage;
operation->setWrapping(data->wrap_axis);
+ if (data->relative) {
+ const RenderData *rd = context->getRenderData();
+ float fx = rd->xsch * rd->size / 100.0f;
+ float fy = rd->ysch * rd->size / 100.0f;
+
+ operation->setFactorXY(fx, fy);
+ }
+
inputSocket->relinkConnections(operation->getInputSocket(0), 0, graph);
inputXSocket->relinkConnections(operation->getInputSocket(1), 1, graph);
inputYSocket->relinkConnections(operation->getInputSocket(2), 2, graph);
diff --git a/source/blender/compositor/operations/COM_TranslateOperation.cpp b/source/blender/compositor/operations/COM_TranslateOperation.cpp
index 253c5df8f9d..27651a772ee 100644
--- a/source/blender/compositor/operations/COM_TranslateOperation.cpp
+++ b/source/blender/compositor/operations/COM_TranslateOperation.cpp
@@ -34,6 +34,8 @@ TranslateOperation::TranslateOperation() : NodeOperation()
this->m_inputXOperation = NULL;
this->m_inputYOperation = NULL;
this->m_isDeltaSet = false;
+ this->m_factorX = 1.0f;
+ this->m_factorY = 1.0f;
}
void TranslateOperation::initExecution()
{
@@ -180,3 +182,10 @@ float TranslateOperation::getWrappedOriginalYPos(float y)
while (originalYPos < 0) originalYPos += this->m_height;
return fmodf(originalYPos, this->getHeight());
}
+
+float TranslateOperation::setFactorXY(float factorX, float factorY)
+{
+ m_factorX = factorX;
+ m_factorY = factorY;
+}
+
diff --git a/source/blender/compositor/operations/COM_TranslateOperation.h b/source/blender/compositor/operations/COM_TranslateOperation.h
index d93f09e2ab6..4512f97550c 100644
--- a/source/blender/compositor/operations/COM_TranslateOperation.h
+++ b/source/blender/compositor/operations/COM_TranslateOperation.h
@@ -35,6 +35,8 @@ private:
bool m_isDeltaSet;
float m_relativeOffsetX;
float m_relativeOffsetY;
+ float m_factorX;
+ float m_factorY;
char m_wrappingType;
public:
TranslateOperation();
@@ -44,8 +46,8 @@ public:
void initExecution();
void deinitExecution();
- float getDeltaX() { return this->m_deltaX; }
- float getDeltaY() { return this->m_deltaY; }
+ float getDeltaX() { return this->m_deltaX * this->m_factorX; }
+ float getDeltaY() { return this->m_deltaY * this->m_factorY; }
inline void ensureDelta() {
if (!this->m_isDeltaSet) {
@@ -61,6 +63,8 @@ public:
void setWrapping(char wrapping_type);
float getWrappedOriginalXPos(float x);
float getWrappedOriginalYPos(float y);
+
+ float setFactorXY(float factorX, float factorY);
};
#endif
diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c
index f3deef45a1b..9b342ed8f44 100644
--- a/source/blender/editors/space_node/drawnode.c
+++ b/source/blender/editors/space_node/drawnode.c
@@ -2381,6 +2381,7 @@ static void node_composit_buts_stabilize2d(uiLayout *layout, bContext *C, Pointe
static void node_composit_buts_translate(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
{
+ uiItemR(layout, ptr, "use_relative", 0, NULL, ICON_NONE);
uiItemR(layout, ptr, "wrap_axis", 0, NULL, ICON_NONE);
}
diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h
index 376d775f719..116b2327d29 100644
--- a/source/blender/makesdna/DNA_node_types.h
+++ b/source/blender/makesdna/DNA_node_types.h
@@ -712,7 +712,9 @@ typedef struct NodeTrackPosData {
} NodeTrackPosData;
typedef struct NodeTranslateData {
- char wrap_axis, pad[7];
+ char wrap_axis;
+ char relative;
+ char pad[6];
} NodeTranslateData;
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index f5e3867cfe4..a3eaeb64cda 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -4239,6 +4239,11 @@ static void def_cmp_translate(StructRNA *srna)
RNA_def_struct_sdna_from(srna, "NodeTranslateData", "storage");
+ prop = RNA_def_property(srna, "use_relative", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "relative", 1);
+ RNA_def_property_ui_text(prop, "Relative", "Use relative (percent) values to define blur radius");
+ RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
+
prop = RNA_def_property(srna, "wrap_axis", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "wrap_axis");
RNA_def_property_enum_items(prop, translate_items);