qvolray
changeset 35:6ca076bf5084
sucks ass
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sun, 15 Apr 2012 02:22:13 +0300 |
parents | e7c006b774ed |
children | 70b937008134 |
files | sdr/volray.p.glsl src/ui_xferview.cc src/ui_xferview.h src/volray.cc |
diffstat | 4 files changed, 48 insertions(+), 27 deletions(-) [+] |
line diff
1.1 --- a/sdr/volray.p.glsl Sun Apr 15 00:11:38 2012 +0300 1.2 +++ b/sdr/volray.p.glsl Sun Apr 15 02:22:13 2012 +0300 1.3 @@ -125,6 +125,7 @@ 1.4 return ray; 1.5 } 1.6 1.7 +#ifdef USE_AABB 1.8 ISect intersect_aabb(Ray ray, AABBox aabb) 1.9 { 1.10 ISect res; 1.11 @@ -172,7 +173,7 @@ 1.12 res.hit = true; 1.13 return res; 1.14 } 1.15 - 1.16 +#else 1.17 1.18 ISect intersect_sphere(Ray ray, float rad) 1.19 { 1.20 @@ -193,11 +194,12 @@ 1.21 float t0 = (-b + sqrt_d) / (2.0 * a); 1.22 float t1 = (-b - sqrt_d) / (2.0 * a); 1.23 1.24 - res.t0 = min(t0, t1); 1.25 - res.t1 = max(t0, t1); 1.26 + res.t0 = max(min(t0, t1), 0.0); 1.27 + res.t1 = max(max(t0, t1), 0.0); 1.28 res.hit = true; 1.29 1.30 /*res.pos = ray.origin + ray.dir * res.t0; 1.31 res.normal = normalize(res.pos);*/ 1.32 return res; 1.33 } 1.34 +#endif
2.1 --- a/src/ui_xferview.cc Sun Apr 15 00:11:38 2012 +0300 2.2 +++ b/src/ui_xferview.cc Sun Apr 15 02:22:13 2012 +0300 2.3 @@ -1,6 +1,9 @@ 2.4 +#include <QtGui> 2.5 #include "ui_xferview.h" 2.6 #include "volray.h" 2.7 2.8 +static int prev_x, prev_y; 2.9 + 2.10 XFerGLView::XFerGLView(QGLWidget *share_widget) 2.11 : QGLWidget(QGLFormat(QGL::DoubleBuffer), 0, share_widget) 2.12 { 2.13 @@ -24,3 +27,25 @@ 2.14 { 2.15 volray_draw_xfer(); 2.16 } 2.17 + 2.18 +void XFerGLView::mousePressEvent(QMouseEvent *ev) 2.19 +{ 2.20 + prev_x = ev->x(); 2.21 + prev_y = ev->y(); 2.22 +} 2.23 + 2.24 +void modxfer(int dx, int dy, int max_x, int max_y); 2.25 + 2.26 +void XFerGLView::mouseMoveEvent(QMouseEvent *ev) 2.27 +{ 2.28 + int x = ev->x(); 2.29 + int y = ev->y(); 2.30 + 2.31 + int dx = x - prev_x; 2.32 + int dy = y - prev_y; 2.33 + 2.34 + prev_x = x; 2.35 + prev_y = y; 2.36 + 2.37 + modxfer(dx, dy, width(), height()); 2.38 +}
3.1 --- a/src/ui_xferview.h Sun Apr 15 00:11:38 2012 +0300 3.2 +++ b/src/ui_xferview.h Sun Apr 15 02:22:13 2012 +0300 3.3 @@ -11,6 +11,9 @@ 3.4 void resizeGL(int xsz, int ysz); 3.5 void paintGL(); 3.6 3.7 + void mousePressEvent(QMouseEvent *ev); 3.8 + void mouseMoveEvent(QMouseEvent *ev); 3.9 + 3.10 public: 3.11 XFerGLView(QGLWidget *share_widget = 0); 3.12
4.1 --- a/src/volray.cc Sun Apr 15 00:11:38 2012 +0300 4.2 +++ b/src/volray.cc Sun Apr 15 02:22:13 2012 +0300 4.3 @@ -259,20 +259,6 @@ 4.4 glEnd(); 4.5 4.6 glDisable(GL_TEXTURE_1D); 4.7 - 4.8 - glLineWidth(2.0); 4.9 - glBegin(GL_LINE_LOOP); 4.10 - /*if(uimode == UIMODE_XFER) { 4.11 - glColor3f(1, 0, 0); 4.12 - } else {*/ 4.13 - glColor3f(0, 0, 1); 4.14 - //} 4.15 - glVertex2f(0, 0); 4.16 - glVertex2f(1, 0); 4.17 - glVertex2f(1, 1); 4.18 - glVertex2f(0, 1); 4.19 - glEnd(); 4.20 - 4.21 glPopMatrix(); 4.22 } 4.23 4.24 @@ -342,6 +328,21 @@ 4.25 prev_y = y; 4.26 } 4.27 4.28 +void modxfer(int dx, int dy, int max_x, int max_y) 4.29 +{ 4.30 + if(!dx && !dy) 4.31 + return; 4.32 + 4.33 + xfer_mean += dx / (float)max_x; 4.34 + xfer_sdev += 0.5 * dy / (float)max_y; 4.35 + 4.36 + xfer_mean = xfer_mean < 0.0 ? 0.0 : (xfer_mean > 1.0 ? 1.0 : xfer_mean); 4.37 + xfer_sdev = xfer_sdev < 0.0 ? 0.0 : (xfer_sdev > 1.0 ? 1.0 : xfer_sdev); 4.38 + 4.39 + xfertex_needs_recalc = true; 4.40 + post_redisplay(); 4.41 +} 4.42 + 4.43 void volray_motion(int x, int y) 4.44 { 4.45 int dx = x - prev_x; 4.46 @@ -351,16 +352,6 @@ 4.47 4.48 /*switch(uimode) { 4.49 case UIMODE_XFER: 4.50 - if(dx || dy) { 4.51 - xfer_mean += dx / (float)win_xsz; 4.52 - xfer_sdev += 0.5 * dy / (float)win_ysz; 4.53 - 4.54 - xfer_mean = xfer_mean < 0.0 ? 0.0 : (xfer_mean > 1.0 ? 1.0 : xfer_mean); 4.55 - xfer_sdev = xfer_sdev < 0.0 ? 0.0 : (xfer_sdev > 1.0 ? 1.0 : xfer_sdev); 4.56 - 4.57 - xfertex_needs_recalc = true; 4.58 - post_redisplay(); 4.59 - } 4.60 break; 4.61 4.62 case UIMODE_CURSOR: