[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [47936] trunk/blender/source/blender: add node scale offset for old compositor too - also fix for error in last commit .
Campbell Barton
ideasman42 at gmail.com
Fri Jun 15 10:01:47 CEST 2012
Revision: 47936
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=47936
Author: campbellbarton
Date: 2012-06-15 08:01:41 +0000 (Fri, 15 Jun 2012)
Log Message:
-----------
add node scale offset for old compositor too - also fix for error in last commit.
Modified Paths:
--------------
trunk/blender/source/blender/compositor/operations/COM_ScaleOperation.cpp
trunk/blender/source/blender/nodes/composite/nodes/node_composite_scale.c
Modified: trunk/blender/source/blender/compositor/operations/COM_ScaleOperation.cpp
===================================================================
--- trunk/blender/source/blender/compositor/operations/COM_ScaleOperation.cpp 2012-06-15 07:50:27 UTC (rev 47935)
+++ trunk/blender/source/blender/compositor/operations/COM_ScaleOperation.cpp 2012-06-15 08:01:41 UTC (rev 47936)
@@ -223,13 +223,13 @@
/* fit X */
const float div = asp_src / asp_dst;
this->relX /= div;
- this->offsetX = ((w_src - (w_src * div)) / (w_src / w_dst)) / 2.0f;
+ this->offsetX += ((w_src - (w_src * div)) / (w_src / w_dst)) / 2.0f;
}
else {
/* fit Y */
const float div = asp_dst / asp_src;
this->relY /= div;
- this->offsetY = ((h_src - (h_src * div)) / (h_src / h_dst)) / 2.0f;
+ this->offsetY += ((h_src - (h_src * div)) / (h_src / h_dst)) / 2.0f;
}
this->is_offset = true;
Modified: trunk/blender/source/blender/nodes/composite/nodes/node_composite_scale.c
===================================================================
--- trunk/blender/source/blender/nodes/composite/nodes/node_composite_scale.c 2012-06-15 07:50:27 UTC (rev 47935)
+++ trunk/blender/source/blender/nodes/composite/nodes/node_composite_scale.c 2012-06-15 08:01:41 UTC (rev 47936)
@@ -57,6 +57,7 @@
CompBuf *stackbuf, *cbuf = typecheck_compbuf(in[0]->data, CB_RGBA);
ImBuf *ibuf;
int newx, newy;
+ float ofsx = 0.0f, ofsy = 0.0f;
if (node->custom1 == CMP_SCALE_RELATIVE) {
newx = MAX2((int)(in[1]->vec[0] * cbuf->x), 1);
@@ -67,6 +68,21 @@
newy = cbuf->y * (rd->size / 100.0f);
}
else if (node->custom1 == CMP_SCALE_RENDERPERCENT) {
+
+ if (node->custom3 != 0.0f || node->custom4 != 0.0f) {
+ const float w_dst = (rd->xsch * rd->size) / 100;
+ const float h_dst = (rd->ysch * rd->size) / 100;
+
+ if (w_dst > h_dst) {
+ ofsx = node->custom3 * w_dst;
+ ofsy = node->custom4 * w_dst;
+ }
+ else {
+ ofsx = node->custom3 * h_dst;
+ ofsy = node->custom4 * h_dst;
+ }
+ }
+
/* supports framing options */
if (node->custom2 & CMP_SCALE_RENDERSIZE_FRAME_ASPECT) {
/* apply aspect from clip */
@@ -133,8 +149,8 @@
IMB_freeImBuf(ibuf);
/* also do the translation vector */
- stackbuf->xof = (int)(((float)newx / (float)cbuf->x) * (float)cbuf->xof);
- stackbuf->yof = (int)(((float)newy / (float)cbuf->y) * (float)cbuf->yof);
+ stackbuf->xof = (int)(ofsx + (((float)newx / (float)cbuf->x) * (float)cbuf->xof));
+ stackbuf->yof = (int)(ofsy + (((float)newy / (float)cbuf->y) * (float)cbuf->yof));
}
else {
stackbuf = dupalloc_compbuf(cbuf);
More information about the Bf-blender-cvs
mailing list