diff options
author | Ton Roosendaal <ton@blender.org> | 2006-01-24 01:05:47 +0300 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2006-01-24 01:05:47 +0300 |
commit | 042d612df219c8f6a29afa235537380f227b5684 (patch) | |
tree | 310a2c859b99c559115bbcda0aa70f2543bf962c /source/blender/src/view.c | |
parent | 5668480c99001a617fd59a2383deb858195ffb26 (diff) |
Giant commit!
A full detailed description of this will be done later... is several days
of work. Here's a summary:
Render:
- Full cleanup of render code, removing *all* globals and bad level calls
all over blender. Render module is now not called abusive anymore
- API-fied calls to rendering
- Full recode of internal render pipeline. Is now rendering tiles by
default, prepared for much smarter 'bucket' render later.
- Each thread now can render a full part
- Renders were tested with 4 threads, goes fine, apart from some lookup
tables in softshadow and AO still
- Rendering is prepared to do multiple layers and passes
- No single 32 bits trick in render code anymore, all 100% floats now.
Writing images/movies
- moved writing images to blender kernel (bye bye 'schrijfplaatje'!)
- made a new Movie handle system, also in kernel. This will enable much
easier use of movies in Blender
PreviewRender:
- Using new render API, previewrender (in buttons) now uses regular render
code to generate images.
- new datafile 'preview.blend.c' has the preview scenes in it
- previews get rendered in exact displayed size (1 pixel = 1 pixel)
3D Preview render
- new; press Pkey in 3d window, for a panel that continuously renders
(pkey is for games, i know... but we dont do that in orange now!)
- this render works nearly identical to buttons-preview render, so it stops
rendering on any event (mouse, keyboard, etc)
- on moving/scaling the panel, the render code doesn't recreate all geometry
- same for shifting/panning view
- all other operations (now) regenerate the full render database still.
- this is WIP... but big fun, especially for simple scenes!
Compositor
- Using same node system as now in use for shaders, you can composit images
- works pretty straightforward... needs much more options/tools and integration
with rendering still
- is not threaded yet, nor is so smart to only recalculate changes... will be
done soon!
- the "Render Result" node will get all layers/passes as output sockets
- The "Output" node renders to a builtin image, which you can view in the Image
window. (yes, output nodes to render-result, and to files, is on the list!)
The Bad News
- "Unified Render" is removed. It might come back in some stage, but this
system should be built from scratch. I can't really understand this code...
I expect it is not much needed, especially with advanced layer/passes
control
- Panorama render, Field render, Motion blur, is not coded yet... (I had to
recode every single feature in render, so...!)
- Lens Flare is also not back... needs total revision, might become composit
effect though (using zbuffer for visibility)
- Part render is gone! (well, thats obvious, its default now).
- The render window is only restored with limited functionality... I am going
to check first the option to render to a Image window, so Blender can become
a true single-window application. :)
For example, the 'Spare render buffer' (jkey) doesnt work.
- Render with border, now default creates a smaller image
- No zbuffers are written yet... on the todo!
- Scons files and MSVC will need work to get compiling again
OK... thats what I can quickly recall. Now go compiling!
Diffstat (limited to 'source/blender/src/view.c')
-rw-r--r-- | source/blender/src/view.c | 126 |
1 files changed, 70 insertions, 56 deletions
diff --git a/source/blender/src/view.c b/source/blender/src/view.c index d62fc90ee05..b2999c65d2b 100644 --- a/source/blender/src/view.c +++ b/source/blender/src/view.c @@ -70,6 +70,7 @@ #include "BIF_gl.h" #include "BIF_space.h" #include "BIF_mywindow.h" +#include "BIF_previewrender.h" #include "BIF_screen.h" #include "BIF_toolbox.h" @@ -83,9 +84,6 @@ #include "mydevice.h" #include "blendef.h" -/* Modules used */ -#include "render.h" /* R. stuff for ogl view render */ - #define TRACKBALLSIZE (1.1) #define BL_NEAR_CLIP 0.001 @@ -536,6 +534,7 @@ void viewmove(int mode) int firsttime=1; short mvalball[2], mval[2], mvalo[2]; short use_sel = 0; + short preview3d_event= 1; /* sometimes this routine is called from headerbuttons */ areawinset(curarea->win); @@ -701,6 +700,7 @@ void viewmove(int mode) G.vd->camdy += (mvalo[1]-mval[1])/(max); CLAMP(G.vd->camdx, -1.0f, 1.0f); CLAMP(G.vd->camdy, -1.0f, 1.0f); + preview3d_event= 0; } else { window_to_3d(dvec, mval[0]-mvalo[0], mval[1]-mvalo[1]); @@ -737,6 +737,8 @@ void viewmove(int mode) mval[1]= mvalo[1]; /* preserve first value */ mval[0]= mvalo[0]; + + if(G.vd->persp==0 || G.vd->persp==2) preview3d_event= 0; } mvalo[0]= mval[0]; @@ -760,26 +762,29 @@ void viewmove(int mode) /* this in the end, otherwise get_mbut does not work on a PC... */ if( !(get_mbut() & (L_MOUSE|M_MOUSE))) break; } -} -short v3d_windowmode=0; + if(preview3d_event) + BIF_view3d_previewrender_signal(curarea, PR_DBASE|PR_DISPRECT); + else + BIF_view3d_previewrender_signal(curarea, PR_PROJECTED); + +} -/* important to not set windows active in here, can be renderwin for example */ -void setwinmatrixview3d(rctf *rect) /* rect: for picking */ +int get_view3d_viewplane(int winxi, int winyi, rctf *viewplane, float *clipsta, float *clipend) { - Camera *cam=0; - float near, far, winx = 0.0, winy = 0.0; + Camera *cam=NULL; float lens, fac, x1, y1, x2, y2; - short orth; + float winx= (float)winxi, winy= (float)winyi; + int orth= 0; lens= G.vd->lens; - near= G.vd->near; - far= G.vd->far; + *clipsta= G.vd->near; + *clipend= G.vd->far; if(G.vd->persp==2) { - near= G.vd->near; - far= G.vd->far; + *clipsta= G.vd->near; + *clipend= G.vd->far; if(G.vd->camera) { if(G.vd->camera->type==OB_LAMP ) { Lamp *la; @@ -790,27 +795,18 @@ void setwinmatrixview3d(rctf *rect) /* rect: for picking */ x1= saacos(fac); lens= 16.0*fac/sin(x1); - near= la->clipsta; - far= la->clipend; + *clipsta= la->clipsta; + *clipend= la->clipend; } else if(G.vd->camera->type==OB_CAMERA) { cam= G.vd->camera->data; lens= cam->lens; - near= cam->clipsta; - far= cam->clipend; + *clipsta= cam->clipsta; + *clipend= cam->clipend; } } } - if(v3d_windowmode) { // hackish - winx= R.rectx; - winy= R.recty; - } - else { - winx= curarea->winx; - winy= curarea->winy; - } - if(G.vd->persp==0) { if(winx>winy) x1= -G.vd->dist; else x1= -winx*G.vd->dist/winy; @@ -820,8 +816,8 @@ void setwinmatrixview3d(rctf *rect) /* rect: for picking */ else y1= -G.vd->dist; y2= -y1; - far*= 0.5; // otherwise too extreme low zbuffer quality - near= -far; + *clipend *= 0.5; // otherwise too extreme low zbuffer quality + *clipsta= - *clipend; orth= 1; } else { @@ -851,9 +847,9 @@ void setwinmatrixview3d(rctf *rect) /* rect: for picking */ if(winx>winy) dfac= 64.0/(fac*winx*lens); else dfac= 64.0/(fac*winy*lens); - x1= - near*winx*dfac; + x1= - *clipsta * winx*dfac; x2= -x1; - y1= - near*winy*dfac; + y1= - *clipsta * winy*dfac; y2= -y1; orth= 0; } @@ -867,40 +863,54 @@ void setwinmatrixview3d(rctf *rect) /* rect: for picking */ y2+= dy; } } + + viewplane->xmin= x1; + viewplane->ymin= y1; + viewplane->xmax= x2; + viewplane->ymax= y2; + + return orth; +} +/* important to not set windows active in here, can be renderwin for example */ +void setwinmatrixview3d(int winx, int winy, rctf *rect) /* rect: for picking */ +{ + rctf viewplane; + float clipsta, clipend, x1, y1, x2, y2; + int orth; + + orth= get_view3d_viewplane(winx, winy, &viewplane, &clipsta, &clipend); +// printf("%d %d %f %f %f %f %f %f\n", winx, winy, viewplane.xmin, viewplane.ymin, viewplane.xmax, viewplane.ymax, clipsta, clipend); + x1= viewplane.xmin; + y1= viewplane.ymin; + x2= viewplane.xmax; + y2= viewplane.ymax; + if(rect) { /* picking */ - rect->xmin/= winx; + rect->xmin/= (float)curarea->winx; rect->xmin= x1+rect->xmin*(x2-x1); - rect->ymin/= winy; + rect->ymin/= (float)curarea->winy; rect->ymin= y1+rect->ymin*(y2-y1); - rect->xmax/= winx; + rect->xmax/= (float)curarea->winx; rect->xmax= x1+rect->xmax*(x2-x1); - rect->ymax/= winy; + rect->ymax/= (float)curarea->winy; rect->ymax= y1+rect->ymax*(y2-y1); - - if(orth) myortho(rect->xmin, rect->xmax, rect->ymin, rect->ymax, -far, far); - else mywindow(rect->xmin, rect->xmax, rect->ymin, rect->ymax, near, far); - + + if(orth) myortho(rect->xmin, rect->xmax, rect->ymin, rect->ymax, -clipend, clipend); + else mywindow(rect->xmin, rect->xmax, rect->ymin, rect->ymax, clipsta, clipend); + } else { - if(v3d_windowmode) { - if(orth) i_ortho(x1, x2, y1, y2, near, far, R.winmat); - else i_window(x1, x2, y1, y2, near, far, R.winmat); - } - else { - if(orth) myortho(x1, x2, y1, y2, near, far); - else mywindow(x1, x2, y1, y2, near, far); - } + if(orth) myortho(x1, x2, y1, y2, clipsta, clipend); + else mywindow(x1, x2, y1, y2, clipsta, clipend); } - if(v3d_windowmode==0) { - glMatrixMode(GL_PROJECTION); - mygetmatrix(curarea->winmat); - glMatrixMode(GL_MODELVIEW); - } + /* not sure what this was for? (ton) */ + glMatrixMode(GL_PROJECTION); + mygetmatrix(curarea->winmat); + glMatrixMode(GL_MODELVIEW); } - void obmat_to_viewmat(Object *ob) { float bmat[4][4]; @@ -987,7 +997,7 @@ short view3d_opengl_select(unsigned int *buffer, unsigned int bufsize, short x1 } /* get rid of overlay button matrix */ persp(PERSP_VIEW); - setwinmatrixview3d(&rect); + setwinmatrixview3d(curarea->winx, curarea->winy, &rect); Mat4MulMat4(G.vd->persmat, G.vd->viewmat, curarea->winmat); if(G.vd->drawtype > OB_WIRE) { @@ -1051,7 +1061,7 @@ short view3d_opengl_select(unsigned int *buffer, unsigned int bufsize, short x1 if(hits<0) error("Too many objects in select buffer"); G.f &= ~G_PICKSEL; - setwinmatrixview3d(0); + setwinmatrixview3d(curarea->winx, curarea->winy, NULL); Mat4MulMat4(G.vd->persmat, G.vd->viewmat, curarea->winmat); if(G.vd->drawtype > OB_WIRE) { @@ -1206,6 +1216,7 @@ void initlocalview() G.vd->localview= 0; } + BIF_view3d_previewrender_signal(curarea, PR_DBASE|PR_DISPRECT); } void centreview() /* like a localview without local! */ @@ -1288,6 +1299,7 @@ void centreview() /* like a localview without local! */ G.vd->cursor[2]= -G.vd->ofs[2]; scrarea_queue_winredraw(curarea); + BIF_view3d_previewrender_signal(curarea, PR_DBASE|PR_DISPRECT); } @@ -1349,7 +1361,7 @@ void endlocalview(ScrArea *sa) countall(); allqueue(REDRAWVIEW3D, 0); /* because of select */ allqueue(REDRAWOOPS, 0); /* because of select */ - + BIF_view3d_previewrender_signal(curarea, PR_DBASE|PR_DISPRECT); } } @@ -1404,6 +1416,8 @@ void view3d_home(int centre) scrarea_queue_winredraw(curarea); } + BIF_view3d_previewrender_signal(curarea, PR_DBASE|PR_DISPRECT); + } |