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:
authorTon Roosendaal <ton@blender.org>2005-01-30 14:25:27 +0300
committerTon Roosendaal <ton@blender.org>2005-01-30 14:25:27 +0300
commit996374bb5a475eb68d50ec5d21b6921049300914 (patch)
tree8b045f89ed1355b5f62f082475db047ee2ebc5a5 /source/blender
parent3180afe2cffd05f8cae26744c41a638b3168d51b (diff)
Fixed old annoyance; enabling true Ortho render in Blender.
It used to be a simple hack, scaling lens with 100, and moving the camera to the back with an equivalent amount. Because of the hack, making it 100% compatible with older files I could not achieve (yet?). To help reminding users, I've added a print when reading old files with Ortho cameras. Full description of how it works can be found here; http://www.blender3d.com/cms/Render_changes.515.0.html
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/intern/object.c1
-rw-r--r--source/blender/blenkernel/intern/world.c8
-rw-r--r--source/blender/blenlib/intern/arithb.c14
-rw-r--r--source/blender/blenloader/intern/readfile.c8
-rw-r--r--source/blender/makesdna/DNA_camera_types.h4
-rw-r--r--source/blender/render/intern/source/initrender.c42
-rw-r--r--source/blender/render/intern/source/renderHelp.c18
-rw-r--r--source/blender/render/intern/source/rendercore.c179
-rw-r--r--source/blender/render/intern/source/shadbuf.c14
-rw-r--r--source/blender/render/intern/source/zbuf.c9
-rw-r--r--source/blender/renderconverter/intern/convertBlenderScene.c2
-rw-r--r--source/blender/src/buttons_editing.c5
-rw-r--r--source/blender/src/buttons_shading.c4
-rw-r--r--source/blender/src/drawobject.c40
-rw-r--r--source/blender/src/view.c67
15 files changed, 240 insertions, 175 deletions
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index d0b42312fff..ffc1dc36e69 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -414,6 +414,7 @@ void *add_camera()
cam->clipsta= 0.1f;
cam->clipend= 100.0f;
cam->drawsize= 0.5f;
+ cam->ortho_scale= 6.0;
return cam;
}
diff --git a/source/blender/blenkernel/intern/world.c b/source/blender/blenkernel/intern/world.c
index 9676f08ee78..526176407a9 100644
--- a/source/blender/blenkernel/intern/world.c
+++ b/source/blender/blenkernel/intern/world.c
@@ -199,14 +199,6 @@ void init_render_world()
for(a=0; a<MAX_MTEX; a++)
if(R.wrld.mtex[a] && R.wrld.mtex[a]->tex) R.wrld.skytype |= WO_SKYTEX;
- if(G.scene->camera && G.scene->camera->type==OB_CAMERA) {
- Camera *cam= G.scene->camera->data;
- if(cam->type==CAM_ORTHO) {
- /* this is an estimation */
- R.wrld.miststa+= (float)fabs(R.viewmat[3][2]);
- }
- }
-
}
else {
memset(&R.wrld, 0, sizeof(World));
diff --git a/source/blender/blenlib/intern/arithb.c b/source/blender/blenlib/intern/arithb.c
index fd2fb833d04..095f8fb5052 100644
--- a/source/blender/blenlib/intern/arithb.c
+++ b/source/blender/blenlib/intern/arithb.c
@@ -964,10 +964,10 @@ void printvecf( char *str, float v[3])
void printmatrix4( char *str, float m[][4])
{
printf("%s\n", str);
- printf("%f %f %f %f\n",m[0][0],m[0][1],m[0][2],m[0][3]);
- printf("%f %f %f %f\n",m[1][0],m[1][1],m[1][2],m[1][3]);
- printf("%f %f %f %f\n",m[2][0],m[2][1],m[2][2],m[2][3]);
- printf("%f %f %f %f\n",m[3][0],m[3][1],m[3][2],m[3][3]);
+ printf("%f %f %f %f\n",m[0][0],m[1][0],m[2][0],m[3][0]);
+ printf("%f %f %f %f\n",m[0][1],m[1][1],m[2][1],m[3][1]);
+ printf("%f %f %f %f\n",m[0][2],m[1][2],m[2][2],m[3][2]);
+ printf("%f %f %f %f\n",m[0][3],m[1][3],m[2][3],m[3][3]);
printf("\n");
}
@@ -975,9 +975,9 @@ void printmatrix4( char *str, float m[][4])
void printmatrix3( char *str, float m[][3])
{
printf("%s\n", str);
- printf("%f %f %f\n",m[0][0],m[0][1],m[0][2]);
- printf("%f %f %f\n",m[1][0],m[1][1],m[1][2]);
- printf("%f %f %f\n",m[2][0],m[2][1],m[2][2]);
+ printf("%f %f %f\n",m[0][0],m[1][0],m[2][0]);
+ printf("%f %f %f\n",m[0][1],m[1][1],m[2][1]);
+ printf("%f %f %f\n",m[0][2],m[1][2],m[2][2]);
printf("\n");
}
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 37e21e39279..ad4b36f3b0b 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -4618,11 +4618,19 @@ static void do_versions(Main *main)
}
if(main->versionfile <= 236) {
Scene *sce= main->scene.first;
+ Camera *cam= main->camera.first;
while(sce) {
if(sce->r.postsat==0.0) sce->r.postsat= 1.0;
sce= sce->id.next;
}
+ while(cam) {
+ if(cam->ortho_scale==0.0) {
+ cam->ortho_scale= 256.0/cam->lens;
+ if(cam->type==CAM_ORTHO) printf("NOTE: ortho render has changed, tweak new Camera 'scale' value.\n");
+ }
+ cam= cam->id.next;
+ }
}
/* don't forget to set version number in blender.c! */
diff --git a/source/blender/makesdna/DNA_camera_types.h b/source/blender/makesdna/DNA_camera_types.h
index 1f25f371f97..8b6f0eb369b 100644
--- a/source/blender/makesdna/DNA_camera_types.h
+++ b/source/blender/makesdna/DNA_camera_types.h
@@ -46,9 +46,9 @@ struct Ipo;
typedef struct Camera {
ID id;
- short type, flag, drawzoom, hold;
+ short type, flag;
float clipsta, clipend;
- float lens, drawsize;
+ float lens, ortho_scale, drawsize;
/* yafray: dof params */
float YF_dofdist, YF_aperture;
diff --git a/source/blender/render/intern/source/initrender.c b/source/blender/render/intern/source/initrender.c
index 3b3d272b18d..18504eb21b3 100644
--- a/source/blender/render/intern/source/initrender.c
+++ b/source/blender/render/intern/source/initrender.c
@@ -488,11 +488,11 @@ void RE_make_existing_file(char *name)
void RE_setwindowclip(int mode, int jmode)
{
extern float bluroffsx, bluroffsy; // rendercore.c... hackish (ton)
- Camera *cam=0;
+ Camera *cam=NULL;
float lens, minx, miny, maxx, maxy;
float xd, yd, afmx, afmy;
- if(G.scene->camera==0) return;
+ if(G.scene->camera==NULL) return;
afmx= R.afmx;
afmy= R.afmy;
@@ -519,19 +519,28 @@ void RE_setwindowclip(int mode, int jmode)
lens= 16.0;
}
- if( (R.r.xasp*afmx) >= (R.r.yasp*afmy) ) {
- R.viewfac= (afmx*lens)/16.0;
+ if(R.r.mode & R_ORTHO) {
+ if( (R.r.xasp*afmx) >= (R.r.yasp*afmy) ) {
+ R.viewfac= 2.0*afmx;
+ }
+ else {
+ R.viewfac= 2.0*R.ycor*afmy;
+ }
+ /* ortho_scale == 1.0 means exact 1 to 1 mapping */
+ R.pixsize= cam->ortho_scale/R.viewfac;
}
else {
- R.viewfac= R.ycor*(afmy*lens)/16.0;
- }
- if(R.r.mode & R_ORTHO) {
- R.near*= 100.0;
- R.viewfac*= 100.0;
+ if( (R.r.xasp*afmx) >= (R.r.yasp*afmy) ) {
+ R.viewfac= (afmx*lens)/16.0;
+ }
+ else {
+ R.viewfac= R.ycor*(afmy*lens)/16.0;
+ }
+
+ R.pixsize= R.near/R.viewfac;
}
-
- R.pixsize= R.near/R.viewfac;
-
+
+ /* pixsize is not a real global... get rid of it! (ton) */
}
/* revision / simplification of subpixel offsets:
@@ -567,11 +576,12 @@ void RE_setwindowclip(int mode, int jmode)
miny= R.pixsize*(miny+yd);
maxy= R.pixsize*(maxy+yd);
- if(R.r.mode & R_ORTHO) {
- i_window(minx, maxx, miny, maxy, R.near, 100.0*R.far, R.winmat);
- }
- else i_window(minx, maxx, miny, maxy, R.near, R.far, R.winmat);
+ if(R.r.mode & R_ORTHO)
+ i_ortho(minx, maxx, miny, maxy, R.near, R.far, R.winmat);
+ else
+ i_window(minx, maxx, miny, maxy, R.near, R.far, R.winmat);
+// printmatrix4("win", R.winmat);
}
diff --git a/source/blender/render/intern/source/renderHelp.c b/source/blender/render/intern/source/renderHelp.c
index 5b0ae9147aa..4ab675238f5 100644
--- a/source/blender/render/intern/source/renderHelp.c
+++ b/source/blender/render/intern/source/renderHelp.c
@@ -256,8 +256,8 @@ void setzbufvlaggen( void (*projectfunc)(float *, float *) )
void set_normalflags(void)
{
VlakRen *vlr = NULL;
- float vec[3], xn, yn, zn;
- int a1;
+ float *v1, xn, yn, zn;
+ int a1, doflip;
/* switch normal 'snproj' values (define which axis is the optimal one for calculations) */
for(a1=0; a1<R.totvlak; a1++) {
@@ -267,12 +267,16 @@ void set_normalflags(void)
/* abuse of this flag... this is code that just sets face normal in direction of camera */
/* that convention we should get rid of */
if((vlr->flag & R_NOPUNOFLIP)==0) {
-
- vec[0]= vlr->v1->co[0];
- vec[1]= vlr->v1->co[1];
- vec[2]= vlr->v1->co[2];
- if( (vec[0]*vlr->n[0] +vec[1]*vlr->n[1] +vec[2]*vlr->n[2])<0.0 ) {
+ doflip= 0;
+ if(R.r.mode & R_ORTHO) {
+ if(vlr->n[2]>0.0) doflip= 1;
+ }
+ else {
+ v1= vlr->v1->co;
+ if( (v1[0]*vlr->n[0] +v1[1]*vlr->n[1] +v1[2]*vlr->n[2])<0.0 ) doflip= 1;
+ }
+ if(doflip) {
vlr->n[0]= -vlr->n[0];
vlr->n[1]= -vlr->n[1];
vlr->n[2]= -vlr->n[2];
diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c
index 6634d9df50a..a98feaf0c3d 100644
--- a/source/blender/render/intern/source/rendercore.c
+++ b/source/blender/render/intern/source/rendercore.c
@@ -84,6 +84,37 @@
/* global for this file. struct render will be more dynamic later, to allow multiple renderers */
RE_Render R;
+float bluroffsx=0.0, bluroffsy=0.0; // set in initrender.c (bad, ton)
+
+/* x and y are current pixels to be rendered */
+static void calc_view_vector(float *view, float x, float y)
+{
+
+ if(R.r.mode & R_ORTHO) {
+ view[0]= view[1]= 0.0;
+ }
+ else {
+ view[0]= (x+(R.xstart)+bluroffsx +0.5);
+
+ if(R.flag & R_SEC_FIELD) {
+ if(R.r.mode & R_ODDFIELD) view[1]= (y+R.ystart)*R.ycor;
+ else view[1]= (y+R.ystart+1.0)*R.ycor;
+ }
+ else view[1]= (y+R.ystart+bluroffsy+0.5)*R.ycor;
+ }
+ view[2]= -R.viewfac;
+
+ if(R.r.mode & R_PANORAMA) {
+ float panoco, panosi, u, v;
+ panoco = getPanovCo();
+ panosi = getPanovSi();
+
+ u= view[0]; v= view[2];
+ view[0]= panoco*u + panosi*v;
+ view[2]= -panosi*u + panoco*v;
+ }
+}
+
float mistfactor(float zcor, float *co) /* dist en height, return alpha */
{
float fac, hi;
@@ -158,7 +189,18 @@ static void spothalo(struct LampRen *lar, ShadeInput *shi, float *intens)
*intens= 0.0;
haint= lar->haint;
- VECCOPY(npos, lar->sh_invcampos); /* in initlamp calculated */
+ if(R.r.mode & R_ORTHO) {
+ /* camera pos (view vector) cannot be used... */
+ /* camera position (cox,coy,0) rotate around lamp */
+ p1[0]= shi->co[0]-lar->co[0];
+ p1[1]= shi->co[1]-lar->co[1];
+ p1[2]= -lar->co[2];
+ MTC_Mat3MulVecfl(lar->imat, p1);
+ VECCOPY(npos, p1); // npos is double!
+ }
+ else {
+ VECCOPY(npos, lar->sh_invcampos); /* in initlamp calculated */
+ }
/* rotate view */
VECCOPY(nray, shi->view);
@@ -1629,6 +1671,8 @@ void shade_lamp_loop(ShadeInput *shi, ShadeResult *shr)
}
+/* this function sets all coords for render (shared with raytracer) */
+/* warning; exception for ortho render is here, can be done better! */
void shade_input_set_coords(ShadeInput *shi, float u, float v, int i1, int i2, int i3)
{
VertRen *v1, *v2, *v3;
@@ -1673,10 +1717,10 @@ void shade_input_set_coords(ShadeInput *shi, float u, float v, int i1, int i2, i
if(u==1.0) {
/* exception case for wire render of edge */
if(vlr->v2==vlr->v3);
- else if( (vlr->flag & R_SMOOTH) || (texco & NEED_UV)) {
+ else if( (vlr->flag & R_SMOOTH) || (texco & NEED_UV) || (R.r.mode && R_ORTHO)) {
float detsh, t00, t10, t01, t11;
- if(vlr->snproj==0) {
+ if(vlr->snproj==0 || (R.r.mode && R_ORTHO)) {
t00= v3->co[0]-v1->co[0]; t01= v3->co[1]-v1->co[1];
t10= v3->co[0]-v2->co[0]; t11= v3->co[1]-v2->co[1];
}
@@ -1689,11 +1733,11 @@ void shade_input_set_coords(ShadeInput *shi, float u, float v, int i1, int i2, i
t10= v3->co[1]-v2->co[1]; t11= v3->co[2]-v2->co[2];
}
- detsh= t00*t11-t10*t01;
- t00/= detsh; t01/=detsh;
- t10/=detsh; t11/=detsh;
+ detsh= 1.0/(t00*t11-t10*t01);
+ t00*= detsh; t01*=detsh;
+ t10*=detsh; t11*=detsh;
- if(vlr->snproj==0) {
+ if(vlr->snproj==0 || (R.r.mode && R_ORTHO)) {
u= (shi->co[0]-v3->co[0])*t11-(shi->co[1]-v3->co[1])*t10;
v= (shi->co[1]-v3->co[1])*t00-(shi->co[0]-v3->co[0])*t01;
if(shi->osatex) {
@@ -1702,6 +1746,10 @@ void shade_input_set_coords(ShadeInput *shi, float u, float v, int i1, int i2, i
shi->dyuv[0]= shi->dyco[0]*t11- shi->dyco[1]*t10;
shi->dyuv[1]= shi->dyco[1]*t00- shi->dyco[0]*t01;
}
+ // exception!!!
+ if(R.r.mode && R_ORTHO) {
+ shi->co[2]= (1.0+u+v)*v3->co[2] - u*v1->co[2] - v*v2->co[2];
+ }
}
else if(vlr->snproj==1) {
u= (shi->co[0]-v3->co[0])*t11-(shi->co[2]-v3->co[2])*t10;
@@ -1955,8 +2003,6 @@ static float isec_view_line(float *view, float *v3, float *v4)
#endif
-float bluroffsx=0.0, bluroffsy=0.0; // set in initrender.c (bad, ton)
-
/* x,y: window coordinate from 0 to rectx,y */
/* return pointer to rendered face */
void *shadepixel(float x, float y, int z, int facenr, int mask, float *col)
@@ -2002,26 +2048,8 @@ void *shadepixel(float x, float y, int z, int facenr, int mask, float *col)
v1= vlr->v1;
/* COXYZ AND VIEW VECTOR */
- shi.view[0]= (x+(R.xstart)+bluroffsx +0.5);
-
- if(R.flag & R_SEC_FIELD) {
- if(R.r.mode & R_ODDFIELD) shi.view[1]= (y+R.ystart)*R.ycor;
- else shi.view[1]= (y+R.ystart+1.0)*R.ycor;
- }
- else shi.view[1]= (y+R.ystart+bluroffsy+0.5)*R.ycor;
-
- shi.view[2]= -R.viewfac;
+ calc_view_vector(shi.view, x, y);
- if(R.r.mode & R_PANORAMA) {
- float panoco, panosi, u, v;
- panoco = getPanovCo();
- panosi = getPanovSi();
-
- u= shi.view[0]; v= shi.view[2];
- shi.view[0]= panoco*u + panosi*v;
- shi.view[2]= -panosi*u + panoco*v;
- }
-
/* wire cannot use normal for calculating shi.co */
if(shi.mat->mode & MA_WIRE) {
float zco;
@@ -2036,36 +2064,61 @@ void *shadepixel(float x, float y, int z, int facenr, int mask, float *col)
shi.co[1]= fac*shi.view[1];
}
else {
- float div, dface;
-
- dface= v1->co[0]*shi.facenor[0]+v1->co[1]*shi.facenor[1]+v1->co[2]*shi.facenor[2];
- div= shi.facenor[0]*shi.view[0] + shi.facenor[1]*shi.view[1] + shi.facenor[2]*shi.view[2];
- if (div!=0.0) fac= zcor= dface/div;
- else fac= zcor= 0.0;
+ /* ortho viewplane cannot intersect using view vector originating in (0,0,0) */
+ if(R.r.mode & R_ORTHO) {
+ /* x and y 3d coordinate can be derived from pixel coord and winmat */
+ float fx= 2.0/(R.rectx*R.winmat[0][0]);
+ float fy= 2.0/(R.recty*R.winmat[1][1]);
+
+ shi.co[0]= (x - 0.5*R.rectx)*fx - R.winmat[3][0]/R.winmat[0][0];
+ shi.co[1]= (y - 0.5*R.recty)*fy - R.winmat[3][1]/R.winmat[1][1];
+
+ /* for shi.co[2] we cannot use zbuffer value, full-osa doesnt store z's */
+ /* so is calculated in shade_input_set_coords */
+ zcor= 1.0; // only to prevent not-initialize
+
+ if(shi.osatex || (R.r.mode & R_SHADOW) ) {
+ shi.dxco[0]= fx;
+ shi.dxco[1]= 0.0;
+ shi.dxco[2]= (shi.facenor[0]*fx)/shi.facenor[2];
+
+ shi.dyco[0]= 0.0;
+ shi.dyco[1]= fy;
+ shi.dyco[2]= (shi.facenor[1]*fy)/shi.facenor[2];
+ }
+ }
+ else {
+ float div, dface;
+
+ dface= v1->co[0]*shi.facenor[0]+v1->co[1]*shi.facenor[1]+v1->co[2]*shi.facenor[2];
+ div= shi.facenor[0]*shi.view[0] + shi.facenor[1]*shi.view[1] + shi.facenor[2]*shi.view[2];
+ if (div!=0.0) fac= zcor= dface/div;
+ else fac= zcor= 0.0;
+
+ shi.co[0]= fac*shi.view[0];
+ shi.co[1]= fac*shi.view[1];
+ shi.co[2]= fac*shi.view[2];
- shi.co[0]= fac*shi.view[0];
- shi.co[1]= fac*shi.view[1];
- shi.co[2]= fac*shi.view[2];
-
- /* pixel dx/dy for render coord */
- if(shi.osatex || (R.r.mode & R_SHADOW) ) {
- float u= dface/(div-shi.facenor[0]);
- float v= dface/(div- R.ycor*shi.facenor[1]);
+ /* pixel dx/dy for render coord */
+ if(shi.osatex || (R.r.mode & R_SHADOW) ) {
+ float u= dface/(div-shi.facenor[0]);
+ float v= dface/(div- R.ycor*shi.facenor[1]);
- shi.dxco[0]= shi.co[0]- (shi.view[0]-1.0)*u;
- shi.dxco[1]= shi.co[1]- (shi.view[1])*u;
- shi.dxco[2]= shi.co[2]- (shi.view[2])*u;
+ shi.dxco[0]= shi.co[0]- (shi.view[0]-1.0)*u;
+ shi.dxco[1]= shi.co[1]- (shi.view[1])*u;
+ shi.dxco[2]= shi.co[2]- (shi.view[2])*u;
- shi.dyco[0]= shi.co[0]- (shi.view[0])*v;
- shi.dyco[1]= shi.co[1]- (shi.view[1]-1.0*R.ycor)*v;
- shi.dyco[2]= shi.co[2]- (shi.view[2])*v;
+ shi.dyco[0]= shi.co[0]- (shi.view[0])*v;
+ shi.dyco[1]= shi.co[1]- (shi.view[1]-1.0*R.ycor)*v;
+ shi.dyco[2]= shi.co[2]- (shi.view[2])*v;
+ }
}
}
/* cannot normalise earlier, code above needs it at pixel level */
fac= Normalise(shi.view);
- zcor*= fac;
+ zcor*= fac; // for mist, distance of point from camera
if(shi.osatex) {
if( (shi.mat->texco & TEXCO_REFL) ) {
@@ -2183,8 +2236,11 @@ void *shadepixel(float x, float y, int z, int facenr, int mask, float *col)
}
/* MIST */
- if( (R.wrld.mode & WO_MIST) && (shi.mat->mode & MA_NOMIST)==0 ){
- alpha= mistfactor(zcor, shi.co);
+ if( (R.wrld.mode & WO_MIST) && (shi.mat->mode & MA_NOMIST)==0 ) {
+ if(R.r.mode & R_ORTHO)
+ alpha= mistfactor(-shi.co[2], shi.co);
+ else
+ alpha= mistfactor(zcor, shi.co);
}
else alpha= 1.0;
@@ -2208,26 +2264,7 @@ void *shadepixel(float x, float y, int z, int facenr, int mask, float *col)
if(R.flag & R_LAMPHALO) {
if(facenr<=0) { /* calc view vector and put shi.co at far */
- shi.view[0]= (x+(R.xstart)+0.5);
-
- if(R.flag & R_SEC_FIELD) {
- if(R.r.mode & R_ODDFIELD) shi.view[1]= (y+R.ystart)*R.ycor;
- else shi.view[1]= (y+R.ystart+1.0)*R.ycor;
- }
- else shi.view[1]= (y+R.ystart+0.5)*R.ycor;
-
- shi.view[2]= -R.viewfac;
-
- if(R.r.mode & R_PANORAMA) {
- float u,v, panoco, panosi;
- panoco = getPanovCo();
- panosi = getPanovSi();
-
- u= shi.view[0]; v= shi.view[2];
- shi.view[0]= panoco*u + panosi*v;
- shi.view[2]= -panosi*u + panoco*v;
- }
-
+ calc_view_vector(shi.view, x, y);
shi.co[2]= 0.0;
}
diff --git a/source/blender/render/intern/source/shadbuf.c b/source/blender/render/intern/source/shadbuf.c
index b87635a51c2..8510df2de3d 100644
--- a/source/blender/render/intern/source/shadbuf.c
+++ b/source/blender/render/intern/source/shadbuf.c
@@ -82,7 +82,7 @@ void RE_initshadowbuf(LampRen *lar, float mat[][4])
shb= (struct ShadBuf *)MEM_callocN( sizeof(struct ShadBuf),"initshadbuf");
lar->shb= shb;
- if(shb==0) return;
+ if(shb==NULL) return;
VECCOPY(shb->co, lar->co);
@@ -195,14 +195,16 @@ void makeshadowbuf(LampRen *lar)
float temp, wsize, dist;
int *rz, *rz1, verg, verg1;
unsigned long *ztile;
- int a, x, y, minx, miny, byt1, byt2;
+ int a, x, y, minx, miny, byt1, byt2, tempmode;
short temprx,tempry, square;
char *rc, *rcline, *ctile, *zt;
panophi = getPanoPhi();
/* store viewvars */
- temprx= R.rectx; tempry= R.recty;
+ temprx= R.rectx; tempry= R.recty;
+ tempmode= R.r.mode;
+ R.r.mode &= ~R_ORTHO;
R.rectx= R.recty= shb->size;
shb->jit= give_jitter_tab(shb->samp);
@@ -332,9 +334,11 @@ void makeshadowbuf(LampRen *lar)
}
MEM_freeN(rcline);
- MEM_freeN(R.rectz); R.rectz= 0;
-
+ MEM_freeN(R.rectz); R.rectz= NULL;
+
+ /* old globals back */
R.rectx= temprx; R.recty= tempry;
+ R.r.mode= tempmode;
MTC_Mat4SwapMat4(shb->persmat, R.winmat);
/* printf("lampbuf %d\n", sizeoflampbuf(shb)); */
diff --git a/source/blender/render/intern/source/zbuf.c b/source/blender/render/intern/source/zbuf.c
index 6fc76f31e25..528cffe876a 100644
--- a/source/blender/render/intern/source/zbuf.c
+++ b/source/blender/render/intern/source/zbuf.c
@@ -1728,11 +1728,12 @@ void RE_projectverto(float *v1, float *adr)
x= v1[0];
y= v1[1];
z= v1[2];
- adr[0]= x*R.winmat[0][0] + z*R.winmat[2][0];
- adr[1]= y*R.winmat[1][1]+ z*R.winmat[2][1];
- adr[2]= z*R.winmat[2][2] + R.winmat[3][2];
- adr[3]= z*R.winmat[2][3] + R.winmat[3][3];
+ adr[0]= x*R.winmat[0][0] + z*R.winmat[2][0] + R.winmat[3][0];
+ adr[1]= y*R.winmat[1][1] + z*R.winmat[2][1] + R.winmat[3][1];
+ adr[2]= z*R.winmat[2][2] + R.winmat[3][2];
+ adr[3]= z*R.winmat[2][3] + R.winmat[3][3];
+ //printf("hoco %f %f %f %f\n", adr[0], adr[1], adr[2], adr[3]);
}
/* ------------------------------------------------------------------------- */
diff --git a/source/blender/renderconverter/intern/convertBlenderScene.c b/source/blender/renderconverter/intern/convertBlenderScene.c
index 8204ee17f0a..a0426089cbb 100644
--- a/source/blender/renderconverter/intern/convertBlenderScene.c
+++ b/source/blender/renderconverter/intern/convertBlenderScene.c
@@ -2956,7 +2956,7 @@ void RE_rotateBlenderScene(void)
MTC_Mat4Invert(R.viewmat, R.viewinv);
/* not so neat: now the viewinv is not equal to viewmat. used for Texcos and such. Improve! */
- if(R.r.mode & R_ORTHO) R.viewmat[3][2]*= 100.0;
+ //if(R.r.mode & R_ORTHO) R.viewmat[3][2]*= 100.0;
RE_setwindowclip(1,-1); /* no jit:(-1) */
diff --git a/source/blender/src/buttons_editing.c b/source/blender/src/buttons_editing.c
index d43152111f0..7db12acd344 100644
--- a/source/blender/src/buttons_editing.c
+++ b/source/blender/src/buttons_editing.c
@@ -1312,7 +1312,10 @@ static void editing_panel_camera_type(Object *ob, Camera *cam)
block= uiNewBlock(&curarea->uiblocks, "editing_panel_camera_type", UI_EMBOSS, UI_HELV, curarea->win);
if(uiNewPanel(curarea, block, "Camera", "Editing", 320, 0, 318, 204)==0) return;
- uiDefButF(block, NUM,REDRAWVIEW3D, "Lens:", 470,178,160,20, &cam->lens, 1.0, 250.0, 100, 0, "Specify the lens of the camera");
+ if(cam->type==CAM_ORTHO)
+ uiDefButF(block, NUM,REDRAWVIEW3D, "Scale:", 470,178,160,20, &cam->ortho_scale, 0.01, 1000.0, 50, 0, "Specify the ortho scaling of the used camera");
+ else
+ uiDefButF(block, NUM,REDRAWVIEW3D, "Lens:", 470,178,160,20, &cam->lens, 1.0, 250.0, 100, 0, "Specify the lens of the camera");
uiBlockBeginAlign(block);
uiDefButF(block, NUM,REDRAWVIEW3D, "ClipSta:", 470,147,160,20, &cam->clipsta, 0.001*grid, 100.0*grid, 10, 0, "Specify the startvalue of the the field of view");
diff --git a/source/blender/src/buttons_shading.c b/source/blender/src/buttons_shading.c
index eb5c172bb67..3ac192f1cdc 100644
--- a/source/blender/src/buttons_shading.c
+++ b/source/blender/src/buttons_shading.c
@@ -2790,9 +2790,9 @@ static void material_panel_tramir(Material *ma)
uiBlockBeginAlign(block);
if(ma->mode & MA_RAYTRANSP)
- uiDefButF(block, NUM, B_MATPRV, "Filt:", 10,110,100,20, &(ma->filter), 0.0, 1.0, 0, 0, "Amount of filtering for transparent raytrace");
+ uiDefButF(block, NUM, B_MATPRV, "Filt:", 10,110,100,20, &(ma->filter), 0.0, 1.0, 10, 0, "Amount of filtering for transparent raytrace");
else
- uiDefButF(block, NUM, B_DIFF, "Zoffs:", 10,110,100,20, &(ma->zoffs), 0.0, 10.0, 0, 0, "Gives faces an artificial offset in the Z buffer for Ztransp option");
+ uiDefButF(block, NUM, B_DIFF, "Zoffs:", 10,110,100,20, &(ma->zoffs), 0.0, 10.0, 100, 0, "Gives faces an artificial offset in the Z buffer for Ztransp option");
uiDefButI(block, TOG|BIT|6, B_MATZTRANSP,"ZTransp", 110,110,100,20, &(ma->mode), 0, 0, 0, 0, "Enables Z-Buffering of transparent faces");
uiDefButI(block, TOG|BIT|17, B_MATRAYTRANSP,"Ray Transp",210,110,100,20, &(ma->mode), 0, 0, 0, 0, "Enables raytracing for transparency rendering");
diff --git a/source/blender/src/drawobject.c b/source/blender/src/drawobject.c
index 6b4b837a6e7..584b1c59679 100644
--- a/source/blender/src/drawobject.c
+++ b/source/blender/src/drawobject.c
@@ -664,46 +664,48 @@ void drawcamera(Object *ob)
float vec[8][4], tmat[4][4], fac, facx, facy, depth;
cam= ob->data;
- /* this code only works for perspective */
- if(G.vd->persp==2 && ob==G.vd->camera && cam->type==CAM_ORTHO) return;
glDisable(GL_LIGHTING);
glDisable(GL_CULL_FACE);
- /* that way it's always visible */
- fac= cam->drawsize;
- if(G.vd->persp>=2 && ob==G.vd->camera) fac= cam->clipsta+0.1;
-
- depth= - fac*cam->lens/16.0;
- facx= fac*1.28;
- facy= fac*1.024;
+ if(G.vd->persp>=2 && cam->type==CAM_ORTHO && ob==G.vd->camera) {
+ facx= 0.5*cam->ortho_scale*1.28;
+ facy= 0.5*cam->ortho_scale*1.024;
+ depth= -cam->clipsta-0.1;
+ }
+ else {
+ fac= cam->drawsize;
+ if(G.vd->persp>=2 && ob==G.vd->camera) fac= cam->clipsta+0.1; /* that way it's always visible */
+
+ depth= - fac*cam->lens/16.0;
+ facx= fac*1.28;
+ facy= fac*1.024;
+ }
- vec[0][0]= 0; vec[0][1]= 0; vec[0][2]= 0.001; /* GLBUG: for picking at iris Entry (well thats old!) */
+ vec[0][0]= 0.0; vec[0][1]= 0.0; vec[0][2]= 0.001; /* GLBUG: for picking at iris Entry (well thats old!) */
vec[1][0]= facx; vec[1][1]= facy; vec[1][2]= depth;
vec[2][0]= facx; vec[2][1]= -facy; vec[2][2]= depth;
vec[3][0]= -facx; vec[3][1]= -facy; vec[3][2]= depth;
vec[4][0]= -facx; vec[4][1]= facy; vec[4][2]= depth;
glBegin(GL_LINE_LOOP);
- glVertex3fv(vec[0]);
glVertex3fv(vec[1]);
glVertex3fv(vec[2]);
- glVertex3fv(vec[0]);
glVertex3fv(vec[3]);
glVertex3fv(vec[4]);
glEnd();
- glBegin(GL_LINES);
+ if(G.vd->persp>=2 && ob==G.vd->camera) return;
+
+ glBegin(GL_LINE_STRIP);
glVertex3fv(vec[2]);
- glVertex3fv(vec[3]);
- glEnd();
-
- glBegin(GL_LINES);
- glVertex3fv(vec[4]);
+ glVertex3fv(vec[0]);
glVertex3fv(vec[1]);
+ glVertex3fv(vec[4]);
+ glVertex3fv(vec[0]);
+ glVertex3fv(vec[3]);
glEnd();
- if(G.vd->persp>=2) return;
/* arrow on top */
vec[0][2]= depth;
diff --git a/source/blender/src/view.c b/source/blender/src/view.c
index f809d9bde1b..41d29c78a08 100644
--- a/source/blender/src/view.c
+++ b/source/blender/src/view.c
@@ -587,8 +587,8 @@ short v3d_windowmode=0;
void setwinmatrixview3d(rctf *rect) /* rect: for picking */
{
Camera *cam=0;
- float d, near, far, winx = 0.0, winy = 0.0;
- float lens, dfac, fac, x1, y1, x2, y2;
+ float near, far, winx = 0.0, winy = 0.0;
+ float lens, fac, x1, y1, x2, y2;
short orth;
lens= G.vd->lens;
@@ -617,12 +617,6 @@ void setwinmatrixview3d(rctf *rect) /* rect: for picking */
lens= cam->lens;
near= cam->clipsta;
far= cam->clipend;
-
- if(cam->type==CAM_ORTHO) {
- lens*= 100.0;
- near= (near+1.0)*100.0; /* otherwise zbuffer troubles. a Patch! */
- far*= 100.0;
- }
}
}
}
@@ -636,21 +630,16 @@ void setwinmatrixview3d(rctf *rect) /* rect: for picking */
winy= curarea->winy;
}
- if(winx>winy) d= 0.015625*winx*lens;
- else d= 0.015625*winy*lens;
-
- dfac= near/d;
-
if(G.vd->persp==0) {
if(winx>winy) x1= -G.vd->dist;
else x1= -winx*G.vd->dist/winy;
-
x2= -x1;
if(winx>winy) y1= -winy*G.vd->dist/winx;
else y1= -G.vd->dist;
-
y2= -y1;
+
+ near= -far;
orth= 1;
}
else {
@@ -660,12 +649,32 @@ void setwinmatrixview3d(rctf *rect) /* rect: for picking */
}
else fac= 2.0;
- x1= -dfac*(winx/fac);
- x2= -x1;
- y1= -dfac*(winy/fac);
- y2= -y1;
-
- orth= 0;
+ /* viewplane size depends... */
+ if(cam && cam->type==CAM_ORTHO) {
+ /* ortho_scale == 1 means exact 1 to 1 mapping */
+ float dfac= 2.0*cam->ortho_scale/fac;
+
+ if(winx>winy) x1= -dfac;
+ else x1= -winx*dfac/winy;
+ x2= -x1;
+
+ if(winx>winy) y1= -winy*dfac/winx;
+ else y1= -dfac;
+ y2= -y1;
+ orth= 1;
+ }
+ else {
+ float dfac;
+
+ if(winx>winy) dfac= 64.0/(fac*winx*lens);
+ else dfac= 64.0/(fac*winy*lens);
+
+ x1= - near*winx*dfac;
+ x2= -x1;
+ y1= - near*winy*dfac;
+ y2= -y1;
+ orth= 0;
+ }
}
if(rect) { /* picking */
@@ -684,18 +693,12 @@ void setwinmatrixview3d(rctf *rect) /* rect: for picking */
}
else {
if(v3d_windowmode) {
- if(orth) i_ortho(x1, x2, y1, y2, -far, far, R.winmat);
- else {
- if(cam && cam->type==CAM_ORTHO) i_window(x1, x2, y1, y2, near, far, R.winmat);
- else i_window(x1, x2, y1, y2, near, far, R.winmat);
- }
+ 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, -far, far);
- else {
- if(cam && cam->type==CAM_ORTHO) mywindow(x1, x2, y1, y2, near, far);
- else mywindow(x1, x2, y1, y2, near, far);
- }
+ if(orth) myortho(x1, x2, y1, y2, near, far);
+ else mywindow(x1, x2, y1, y2, near, far);
}
}
@@ -734,7 +737,7 @@ void setviewmatrixview3d()
if(G.vd->camera->type==OB_CAMERA) {
cam= G.vd->camera->data;
- if(cam->type==CAM_ORTHO) G.vd->viewmat[3][2]*= 100.0;
+ //if(cam->type==CAM_ORTHO) G.vd->viewmat[3][2]*= 100.0;
}
}
else {