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
diff options
context:
space:
mode:
authorTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2010-02-17 00:44:18 +0300
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2010-02-17 00:44:18 +0300
commit39ea873a8bc91a7fc4df7b1fa7a7a18239fddae1 (patch)
tree68a81953a98bc282e804c924b32781230ee74af1 /source/blender/freestyle/intern/application
parentca908e21e215a87f0783fed47feed394ccdea4d6 (diff)
Fixed bugs in AppCanvas::readColorPixels() and
AppCanvas::readDepthPixels() that caused a crash when the aspect ratio was not 1:1.
Diffstat (limited to 'source/blender/freestyle/intern/application')
-rwxr-xr-xsource/blender/freestyle/intern/application/AppCanvas.cpp84
-rwxr-xr-xsource/blender/freestyle/intern/application/AppCanvas.h18
-rwxr-xr-xsource/blender/freestyle/intern/application/Controller.cpp15
-rwxr-xr-xsource/blender/freestyle/intern/application/Controller.h4
4 files changed, 75 insertions, 46 deletions
diff --git a/source/blender/freestyle/intern/application/AppCanvas.cpp b/source/blender/freestyle/intern/application/AppCanvas.cpp
index 4ee7244a7dd..4d4ab33cc59 100755
--- a/source/blender/freestyle/intern/application/AppCanvas.cpp
+++ b/source/blender/freestyle/intern/application/AppCanvas.cpp
@@ -111,46 +111,58 @@ void AppCanvas::Erase()
void AppCanvas::readColorPixels(int x,int y,int w, int h, RGBImage& oImage) const
{
- float *rgb = new float[3*w*h];
- memset(rgb, 0, sizeof(float) * 3 * w * h);
- if (_pass_diffuse) {
- int rectx = width(), recty = height();
- int i, ii, j, jj;
- for (j = 0; j < h; j++) {
- jj = y + j;
- if (jj < 0 || jj >= recty)
- continue;
- for (i = 0; i < w; i++) {
- ii = x + i;
- if (ii < 0 || ii >= rectx)
- continue;
- memcpy(rgb + (w * j + i) * 3, _pass_diffuse + (rectx * jj + ii) * 3, sizeof(float) * 3);
- }
- }
- }
- oImage.setArray(rgb, width(), height(), w,h, x, y, false);
+ float *rgb = new float[3*w*h];
+ memset(rgb, 0, sizeof(float) * 3 * w * h);
+ int xsch = width();
+ int ysch = height();
+ if (_pass_diffuse.buf) {
+ 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));
+ int ii, jj;
+ for (int j = 0; j < h; j++) {
+ jj = (int)((y + j) * yfac);
+ if (jj < 0 || jj >= recty)
+ continue;
+ for (int i = 0; i < w; i++) {
+ ii = (int)((x + i) * xfac);
+ if (ii < 0 || ii >= rectx)
+ continue;
+ memcpy(rgb + (w * j + i) * 3, _pass_diffuse.buf + (rectx * jj + ii) * 3, sizeof(float) * 3);
+ }
+ }
+ }
+ oImage.setArray(rgb, xsch, ysch, w, h, x, y, false);
}
void AppCanvas::readDepthPixels(int x,int y,int w, int h, GrayImage& oImage) const
{
- float *z = new float[w*h];
- memset(z, 0, sizeof(float) * w * h);
- if (_pass_z) {
- int rectx = width(), recty = height();
- int i, ii, j, jj;
- for (j = 0; j < h; j++) {
- jj = y + j;
- if (jj < 0 || jj >= recty)
- continue;
- for (i = 0; i < w; i++) {
- ii = x + i;
- if (ii < 0 || ii >= rectx)
- continue;
- z[w * j + i] = _pass_z[rectx * jj + ii];
- }
- }
- }
- oImage.setArray(z, width(), height(), w,h, x, y, false);
+ float *z = new float[w*h];
+ memset(z, 0, sizeof(float) * w * h);
+ int xsch = width();
+ int ysch = height();
+ if (_pass_z.buf) {
+ 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));
+ int ii, jj;
+ for (int j = 0; j < h; j++) {
+ jj = (int)((y + j) * yfac);
+ if (jj < 0 || jj >= recty)
+ continue;
+ for (int i = 0; i < w; i++) {
+ ii = (int)((x + i) * xfac);
+ if (ii < 0 || ii >= rectx)
+ continue;
+ z[w * j + i] = _pass_z.buf[rectx * jj + ii];
+ }
+ }
+ }
+ oImage.setArray(z, xsch, ysch, w, h, x, y, false);
}
void AppCanvas::RenderStroke(Stroke *iStroke) {
diff --git a/source/blender/freestyle/intern/application/AppCanvas.h b/source/blender/freestyle/intern/application/AppCanvas.h
index 7678014d4a0..b45aafbaf33 100755
--- a/source/blender/freestyle/intern/application/AppCanvas.h
+++ b/source/blender/freestyle/intern/application/AppCanvas.h
@@ -48,11 +48,21 @@ public:
void setViewer(AppView *iViewer) ;
// soc
- void setPassDiffuse(float *p) {_pass_diffuse = p;}
- void setPassZ(float *p) {_pass_z = p;}
+ void setPassDiffuse(float *buf, int width, int height) {
+ _pass_diffuse.buf = buf;
+ _pass_diffuse.width = width;
+ _pass_diffuse.height = height;
+ }
+ void setPassZ(float *buf, int width, int height) {
+ _pass_z.buf = buf;
+ _pass_z.width = width;
+ _pass_z.height = height;
+ }
private:
- float *_pass_diffuse;
- float *_pass_z;
+ struct {
+ float *buf;
+ int width, height;
+ } _pass_diffuse, _pass_z;
};
diff --git a/source/blender/freestyle/intern/application/Controller.cpp b/source/blender/freestyle/intern/application/Controller.cpp
index bf8d30b243e..43f091d3fa1 100755
--- a/source/blender/freestyle/intern/application/Controller.cpp
+++ b/source/blender/freestyle/intern/application/Controller.cpp
@@ -176,18 +176,18 @@ void Controller::setView(AppView *iView)
_Canvas->setViewer(_pView);
}
-void Controller::setPassDiffuse(float *pass)
+void Controller::setPassDiffuse(float *buf, int width, int height)
{
AppCanvas *app_canvas = dynamic_cast<AppCanvas *>(_Canvas);
assert(app_canvas != 0);
- app_canvas->setPassDiffuse(pass);
+ app_canvas->setPassDiffuse(buf, width, height);
}
-void Controller::setPassZ(float *pass)
+void Controller::setPassZ(float *buf, int width, int height)
{
AppCanvas *app_canvas = dynamic_cast<AppCanvas *>(_Canvas);
assert(app_canvas != 0);
- app_canvas->setPassZ(pass);
+ app_canvas->setPassZ(buf, width, height);
}
void Controller::setContext(bContext *C)
@@ -367,6 +367,9 @@ void Controller::CloseFile()
_SceneNumFaces = 0;
_minEdgeSize = DBL_MAX;
+ // soc: reset passes
+ setPassDiffuse(NULL, 0, 0);
+ setPassZ(NULL, 0, 0);
}
@@ -867,4 +870,8 @@ void Controller::init_options(){
// soc: initialize canvas
_Canvas->init();
+
+ // soc: initialize passes
+ setPassDiffuse(NULL, 0, 0);
+ setPassZ(NULL, 0, 0);
}
diff --git a/source/blender/freestyle/intern/application/Controller.h b/source/blender/freestyle/intern/application/Controller.h
index 83a4f2754b9..9d1db24a026 100755
--- a/source/blender/freestyle/intern/application/Controller.h
+++ b/source/blender/freestyle/intern/application/Controller.h
@@ -70,8 +70,8 @@ public:
~Controller() ;
void setView(AppView *iView);
- void setPassDiffuse(float *p);
- void setPassZ(float *p);
+ void setPassDiffuse(float *buf, int width, int height);
+ void setPassZ(float *buf, int width, int height);
void setContext(bContext *C);
//soc