diff options
author | Ton Roosendaal <ton@blender.org> | 2005-12-13 15:41:17 +0300 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2005-12-13 15:41:17 +0300 |
commit | e0dc311fc22f47e70e8b05266754f43548eff234 (patch) | |
tree | b5f5273e27627ed9987ce8459154e5799dc533fd /source/blender/render | |
parent | e51f752e75184f4830bcd70eded77f3b6484d2f7 (diff) |
With the introduction of fixed edge arrays in Mesh, the options to render
wire frame became very limited... the information of faces (vertex colors
and UV reside there) got lost.
Solved it nicely with creating a large index table, and use bsearch() to
get quickly the matching information.
Then I noticed the render code needed fixes too for wire, no proper UV's
were calculated over the wire edge.
Diffstat (limited to 'source/blender/render')
-rw-r--r-- | source/blender/render/intern/source/rendercore.c | 122 |
1 files changed, 71 insertions, 51 deletions
diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c index 1161b10dc3f..01e124b2537 100644 --- a/source/blender/render/intern/source/rendercore.c +++ b/source/blender/render/intern/source/rendercore.c @@ -1790,60 +1790,81 @@ void shade_input_set_coords(ShadeInput *shi, float u, float v, int i1, int i2, i /* calculate U and V, for scanline (normal u and v are -1 to 0) */ 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) ) { - float detsh, t00, t10, t01, t11; - - if(vlr->snproj==0) { - 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]; - } - else if(vlr->snproj==1) { - t00= v3->co[0]-v1->co[0]; t01= v3->co[2]-v1->co[2]; - t10= v3->co[0]-v2->co[0]; t11= v3->co[2]-v2->co[2]; - } - else { - t00= v3->co[1]-v1->co[1]; t01= v3->co[2]-v1->co[2]; - t10= v3->co[1]-v2->co[1]; t11= v3->co[2]-v2->co[2]; - } - - detsh= 1.0/(t00*t11-t10*t01); - t00*= detsh; t01*=detsh; - t10*=detsh; t11*=detsh; - - if(vlr->snproj==0) { - 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) { - shi->dxuv[0]= shi->dxco[0]*t11- shi->dxco[1]*t10; - shi->dxuv[1]= shi->dxco[1]*t00- shi->dxco[0]*t01; - shi->dyuv[0]= shi->dyco[0]*t11- shi->dyco[1]*t10; - shi->dyuv[1]= shi->dyco[1]*t00- shi->dyco[0]*t01; + if( (vlr->flag & R_SMOOTH) || (texco & NEED_UV) ) { + /* exception case for wire render of edge */ + if(vlr->v2==vlr->v3) { + float lend, lenc; + + lend= VecLenf(v2->co, v1->co); + lenc= VecLenf(shi->co, v1->co); + + if(lend==0.0f) { + u=v= 0.0f; } - } - else if(vlr->snproj==1) { - u= (shi->co[0]-v3->co[0])*t11-(shi->co[2]-v3->co[2])*t10; - v= (shi->co[2]-v3->co[2])*t00-(shi->co[0]-v3->co[0])*t01; + else { + u= - (1.0f - lenc/lend); + v= 0.0f; + } + if(shi->osatex) { - shi->dxuv[0]= shi->dxco[0]*t11- shi->dxco[2]*t10; - shi->dxuv[1]= shi->dxco[2]*t00- shi->dxco[0]*t01; - shi->dyuv[0]= shi->dyco[0]*t11- shi->dyco[2]*t10; - shi->dyuv[1]= shi->dyco[2]*t00- shi->dyco[0]*t01; + shi->dxuv[0]= 0.0f; + shi->dxuv[1]= 0.0f; + shi->dyuv[0]= 0.0f; + shi->dyuv[1]= 0.0f; } } else { - u= (shi->co[1]-v3->co[1])*t11-(shi->co[2]-v3->co[2])*t10; - v= (shi->co[2]-v3->co[2])*t00-(shi->co[1]-v3->co[1])*t01; - if(shi->osatex) { - shi->dxuv[0]= shi->dxco[1]*t11- shi->dxco[2]*t10; - shi->dxuv[1]= shi->dxco[2]*t00- shi->dxco[1]*t01; - shi->dyuv[0]= shi->dyco[1]*t11- shi->dyco[2]*t10; - shi->dyuv[1]= shi->dyco[2]*t00- shi->dyco[1]*t01; + float detsh, t00, t10, t01, t11; + + if(vlr->snproj==0) { + 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]; + } + else if(vlr->snproj==1) { + t00= v3->co[0]-v1->co[0]; t01= v3->co[2]-v1->co[2]; + t10= v3->co[0]-v2->co[0]; t11= v3->co[2]-v2->co[2]; + } + else { + t00= v3->co[1]-v1->co[1]; t01= v3->co[2]-v1->co[2]; + t10= v3->co[1]-v2->co[1]; t11= v3->co[2]-v2->co[2]; + } + + detsh= 1.0/(t00*t11-t10*t01); + t00*= detsh; t01*=detsh; + t10*=detsh; t11*=detsh; + + if(vlr->snproj==0) { + 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) { + shi->dxuv[0]= shi->dxco[0]*t11- shi->dxco[1]*t10; + shi->dxuv[1]= shi->dxco[1]*t00- shi->dxco[0]*t01; + shi->dyuv[0]= shi->dyco[0]*t11- shi->dyco[1]*t10; + shi->dyuv[1]= shi->dyco[1]*t00- shi->dyco[0]*t01; + } + } + else if(vlr->snproj==1) { + u= (shi->co[0]-v3->co[0])*t11-(shi->co[2]-v3->co[2])*t10; + v= (shi->co[2]-v3->co[2])*t00-(shi->co[0]-v3->co[0])*t01; + if(shi->osatex) { + shi->dxuv[0]= shi->dxco[0]*t11- shi->dxco[2]*t10; + shi->dxuv[1]= shi->dxco[2]*t00- shi->dxco[0]*t01; + shi->dyuv[0]= shi->dyco[0]*t11- shi->dyco[2]*t10; + shi->dyuv[1]= shi->dyco[2]*t00- shi->dyco[0]*t01; + } + } + else { + u= (shi->co[1]-v3->co[1])*t11-(shi->co[2]-v3->co[2])*t10; + v= (shi->co[2]-v3->co[2])*t00-(shi->co[1]-v3->co[1])*t01; + if(shi->osatex) { + shi->dxuv[0]= shi->dxco[1]*t11- shi->dxco[2]*t10; + shi->dxuv[1]= shi->dxco[2]*t00- shi->dxco[1]*t01; + shi->dyuv[0]= shi->dyco[1]*t11- shi->dyco[2]*t10; + shi->dyuv[1]= shi->dyco[2]*t00- shi->dyco[1]*t01; + } } } - } - + } } l= 1.0+u+v; @@ -1967,10 +1988,9 @@ void shade_input_set_coords(ShadeInput *shi, float u, float v, int i1, int i2, i cp2= (char *)(vlr->vcol+j2); cp3= (char *)(vlr->vcol+j3); - shi->vcol[0]= (l*cp3[3]-u*cp1[3]-v*cp2[3])/255.0; - shi->vcol[1]= (l*cp3[2]-u*cp1[2]-v*cp2[2])/255.0; - shi->vcol[2]= (l*cp3[1]-u*cp1[1]-v*cp2[1])/255.0; - + shi->vcol[0]= (l*((float)cp3[3]) - u*((float)cp1[3]) - v*((float)cp2[3]))/255.0; + shi->vcol[1]= (l*((float)cp3[2]) - u*((float)cp1[2]) - v*((float)cp2[2]))/255.0; + shi->vcol[2]= (l*((float)cp3[1]) - u*((float)cp1[1]) - v*((float)cp2[1]))/255.0; } else { shi->vcol[0]= 0.0; |