[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [27875] branches/soc-2008-mxcurioni/source /blender/freestyle/intern: Fix for the issue described in the commit log of revision 27846: Made

Tamito Kajiyama rd6t-kjym at asahi-net.or.jp
Tue Mar 30 19:10:52 CEST 2010


Revision: 27875
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=27875
Author:   kjym3
Date:     2010-03-30 19:10:52 +0200 (Tue, 30 Mar 2010)

Log Message:
-----------
Fix for the issue described in the commit log of revision 27846: Made
the diffuse and Z depth information accessible from style modules when
the border option is enabled.

Revision Links:
--------------
    http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=27846

Modified Paths:
--------------
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/application/AppCanvas.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/application/AppCanvas.h
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/application/AppView.h
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/application/AppCanvas.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/application/AppCanvas.cpp	2010-03-30 17:10:24 UTC (rev 27874)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/application/AppCanvas.cpp	2010-03-30 17:10:52 UTC (rev 27875)
@@ -69,9 +69,14 @@
 
 int AppCanvas::height() const
 {
-  return _pViewer->height();;
+  return _pViewer->height();
 }
 
+BBox<Vec2i> AppCanvas::border() const
+{
+  return _pViewer->border();
+}
+
 BBox<Vec3r> AppCanvas::scene3DBBox() const 
 {
   return _pViewer->scene3DBBox();
@@ -116,18 +121,22 @@
 	int xsch = width();
 	int ysch = height();
 	if (_pass_diffuse.buf) {
+		int xmin = border().getMin().x();
+		int ymin = border().getMin().y();
+		int xmax = border().getMax().x();
+		int ymax = border().getMax().y();
 		int rectx = _pass_z.width;
 		int recty = _pass_z.height;
-		float xfac = ((float)rectx) / ((float)xsch);
-		float yfac = ((float)recty) / ((float)ysch);
-		//printf("readColorPixels %d x %d @ (%d, %d) in %d x %d -- %d x %d @ %d%%\n", w, h, x, y, xsch, ysch, rectx, recty, (int)(xfac * 100.0f));
+		float xfac = ((float)rectx) / ((float)(xmax - xmin));
+		float yfac = ((float)recty) / ((float)(ymax - ymin));
+		//printf("readColorPixels %d x %d @ (%d, %d) in %d x %d [%d x %d] -- %d x %d @ %d%%\n", w, h, x, y, xsch, ysch, xmax - xmin, ymax - ymin, rectx, recty, (int)(xfac * 100.0f));
 		int ii, jj;
 		for (int j = 0; j < h; j++) {
-			jj = (int)((y + j) * yfac);
+			jj = (int)((y - ymin + j) * yfac);
 			if (jj < 0 || jj >= recty)
 				continue;
 			for (int i = 0; i < w; i++) {
-				ii = (int)((x + i) * xfac);
+				ii = (int)((x - xmin + i) * xfac);
 				if (ii < 0 || ii >= rectx)
 					continue;
 				memcpy(rgb + (w * j + i) * 3, _pass_diffuse.buf + (rectx * jj + ii) * 3, sizeof(float) * 3);
@@ -144,18 +153,22 @@
 	int xsch = width();
 	int ysch = height();
 	if (_pass_z.buf) {
+		int xmin = border().getMin().x();
+		int ymin = border().getMin().y();
+		int xmax = border().getMax().x();
+		int ymax = border().getMax().y();
 		int rectx = _pass_z.width;
 		int recty = _pass_z.height;
-		float xfac = ((float)rectx) / ((float)xsch);
-		float yfac = ((float)recty) / ((float)ysch);
-		//printf("readDepthPixels %d x %d @ (%d, %d) in %d x %d -- %d x %d @ %d%%\n", w, h, x, y, xsch, ysch, rectx, recty, (int)(xfac * 100.0f));
+		float xfac = ((float)rectx) / ((float)(xmax - xmin));
+		float yfac = ((float)recty) / ((float)(ymax - ymin));
+		//printf("readDepthPixels %d x %d @ (%d, %d) in %d x %d [%d x %d] -- %d x %d @ %d%%\n", w, h, x, y, xsch, ysch, xmax - xmin, ymax - ymin, rectx, recty, (int)(xfac * 100.0f));
 		int ii, jj;
 		for (int j = 0; j < h; j++) {
-			jj = (int)((y + j) * yfac);
+			jj = (int)((y - ymin + j) * yfac);
 			if (jj < 0 || jj >= recty)
 				continue;
 			for (int i = 0; i < w; i++) {
-				ii = (int)((x + i) * xfac);
+				ii = (int)((x - xmin + i) * xfac);
 				if (ii < 0 || ii >= rectx)
 					continue;
 				z[w * j + i] = _pass_z.buf[rectx * jj + ii];

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/application/AppCanvas.h
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/application/AppCanvas.h	2010-03-30 17:10:24 UTC (rev 27874)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/application/AppCanvas.h	2010-03-30 17:10:52 UTC (rev 27875)
@@ -40,6 +40,7 @@
   /*! accessors */
   virtual int width() const ;
   virtual int height() const ;
+  virtual BBox<Vec2i> AppCanvas::border() const ;
 
 	AppView *_pViewer;
   inline const AppView * viewer() const {return _pViewer;}

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/application/AppView.h
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/application/AppView.h	2010-03-30 17:10:24 UTC (rev 27874)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/application/AppView.h	2010-03-30 17:10:52 UTC (rev 27875)
@@ -29,11 +29,16 @@
 	//inherited
 		inline unsigned int width() { return _width; }
 		inline unsigned int height() { return _height; }
+		inline BBox<Vec2i> border() { return _border; }
 		inline void setWidth( unsigned int width ) { _width = width; }
 		inline void setHeight( unsigned int height ) { _height = height; }
+		inline void setBorder( int xmin, int ymin, int xmax, int ymax ) {
+			_border = BBox<Vec2i>(Vec2i(xmin, ymin), Vec2i(xmax, ymax));
+		}
 		
 protected:
 	unsigned int _width, _height;
+	BBox<Vec2i> _border;
 
 public:
 

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp	2010-03-30 17:10:24 UTC (rev 27874)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp	2010-03-30 17:10:52 UTC (rev 27875)
@@ -84,6 +84,10 @@
 		float ycor = ((float)re->r.yasp) / ((float)re->r.xasp);
 		int width = re->r.xsch;
 		int height = (int)(((float)re->r.ysch) * ycor);
+		int xmin = re->r.border.xmin * width;
+		int xmax = re->r.border.xmax * width;
+		int ymin = re->r.border.ymin * height;
+		int ymax = re->r.border.ymax * height;
 		
 		freestyle_viewport[0] = freestyle_viewport[1] = 0;
 		freestyle_viewport[2] = width;
@@ -91,6 +95,13 @@
 		
 		view->setWidth( width );
 		view->setHeight( height );
+		view->setBorder( xmin, ymin, xmax, ymax );
+
+		cout << "\n===  Dimensions of the 2D image coordinate system  ===" << endl;
+		cout << "Width  : " << width << endl;
+		cout << "Height : " << height << endl;
+		if (re->r.mode & R_BORDER)
+			cout << "Border : (" << xmin << ", " << ymin << ") - (" << xmax << ", " << ymax << ")" << endl;
 	}
 
 	void init_camera(Render* re){





More information about the Bf-blender-cvs mailing list