diff options
Diffstat (limited to 'graphics/asymptote/base/three_surface.asy')
-rw-r--r-- | graphics/asymptote/base/three_surface.asy | 90 |
1 files changed, 50 insertions, 40 deletions
diff --git a/graphics/asymptote/base/three_surface.asy b/graphics/asymptote/base/three_surface.asy index bdb56cb0ca..4ad31d6d2d 100644 --- a/graphics/asymptote/base/three_surface.asy +++ b/graphics/asymptote/base/three_surface.asy @@ -1402,15 +1402,20 @@ void draw3D(frame f, int type=0, patch s, triple center=O, material m, light light=currentlight, interaction interaction=Embedded, bool prc=true) { - if(s.colors.length > 0) + bool straight=s.straight && s.planar; + bool prc=prc(); + if(s.colors.length > 0) { + if(prc && light.on()) + straight=false; // PRC vertex colors (for quads only) ignore lighting m=mean(s.colors); + } m=material(m,light); - real PRCshininess; - if(prc()) - PRCshininess=PRCshininess(m.shininess); + real PRCshininess; + if(prc) PRCshininess=PRCshininess(m.shininess); + (s.triangular ? drawbeziertriangle : draw) - (f,s.P,center,s.straight && s.planar,m.p,m.opacity,m.shininess, + (f,s.P,center,straight,m.p,m.opacity,m.shininess, m.metallic,m.fresnel0,PRCshininess,s.colors,interaction.type,prc); } @@ -1435,7 +1440,7 @@ void draw(frame f, triple[] v, int[][] vi, triple[] n={}, int[][] ni={}, material m=currentpen, pen[] p={}, int[][] pi={}, light light=currentlight) { - bool normals=ni.length > 0; + bool normals=n.length > 0; if(!normals) { ni=new int[vi.length][3]; normals=computeNormals(v,vi,n,ni) > 0; @@ -1455,7 +1460,8 @@ void draw(picture pic=currentpicture, triple[] v, int[][] vi, triple[] n={}, int[][] ni={}, material m=currentpen, pen[] p={}, int[][] pi={}, light light=currentlight) { - bool normals=ni.length > 0; + bool prc=prc(); + bool normals=n.length > 0; if(!normals) { ni=new int[vi.length][3]; normals=computeNormals(v,vi,n,ni) > 0; @@ -1501,7 +1507,7 @@ void draw(picture pic=currentpicture, triple[] v, int[][] vi, project(v[vii[2]],P)--cycle; pen p=color(n[ni[i][0]],m,light); fill(pic,g,p); - if(opacity(m.diffuse()) == 1) // Fill subdivision cracks + if(prc && opacity(m.diffuse()) == 1) // Fill subdivision cracks draw(pic,g,p); } } @@ -1843,6 +1849,7 @@ void label(frame f, Label L, triple position, align align=NoAlign, interaction interaction=LabelInteraction(), projection P=currentprojection) { + bool prc=prc(); Label L=L.copy(); L.align(align); L.p(p); @@ -1873,7 +1880,7 @@ void label(frame f, Label L, triple position, align align=NoAlign, S=centering*S; draw3D(f3,S,position,L.p,light,interaction); // Fill subdivision cracks - if(render.labelfill && opacity(L.p) == 1 && !lighton) + if(prc && render.labelfill && opacity(L.p) == 1 && !lighton) _draw(f3,S.external(),position,L.p,interaction.type); } endgroup3(f3); @@ -1893,7 +1900,7 @@ void label(frame f, Label L, triple position, align align=NoAlign, position; draw3D(f,S,V,L.p,light,interaction); // Fill subdivision cracks - if(render.labelfill && opacity(L.p) == 1 && !lighton) + if(prc && render.labelfill && opacity(L.p) == 1 && !lighton) _draw(f,S.external(),V,L.p,interaction.type); } endgroup3(f); @@ -1927,6 +1934,7 @@ void label(picture pic=currentpicture, Label L, triple position, pic.add(new void(frame f, transform3 t, picture pic2, projection P) { // Handle relative projected 3D alignments. + bool prc=prc(); Label L=L.copy(); triple v=t*position; if(!align.is3D && L.align.relative && L.align.dir3 != O && @@ -1942,44 +1950,46 @@ void label(picture pic=currentpicture, Label L, triple position, if(is3D()) { bool lighton=light.on(); if(name == "") name=L.s; - if(prc() && interaction.type == Billboard.type) { + if(prc && interaction.type == Billboard.type) { surface s=surface(texpath(L,bbox=P.bboxonly)); - transform3 centering=L.align.is3D ? - alignshift(s,L.T3,v,L.align.dir3) : identity4; - transform3 positioning= - shift(L.align.is3D ? v+L.align.dir3*labelmargin(L.p) : v); - frame f1,f2,f3; - begingroup3(f1,name,render); - if(L.defaulttransform3) - begingroup3(f3,render,v,interaction.type); - else { - begingroup3(f2,render,v,interaction.type); - begingroup3(f3,render,v); - } - for(patch S : s.s) { - S=centering*S; - draw3D(f3,S,v,L.p,light,interaction); - // Fill subdivision cracks - if(render.labelfill && opacity(L.p) == 1 && !lighton) - _draw(f3,S.external(),v,L.p,interaction.type); - } - endgroup3(f3); - if(L.defaulttransform3) - add(f1,T*f3); - else { - add(f2,inverse(T)*L.T3*f3); - endgroup3(f2); - add(f1,T*f2); + if(s.s.length > 0) { + transform3 centering=L.align.is3D ? + alignshift(s,L.T3,v,L.align.dir3) : identity4; + transform3 positioning= + shift(L.align.is3D ? v+L.align.dir3*labelmargin(L.p) : v); + frame f1,f2,f3; + begingroup3(f1,name,render); + if(L.defaulttransform3) + begingroup3(f3,render,v,interaction.type); + else { + begingroup3(f2,render,v,interaction.type); + begingroup3(f3,render,v); + } + for(patch S : s.s) { + S=centering*S; + draw3D(f3,S,v,L.p,light,interaction); + // Fill subdivision cracks + if(prc && render.labelfill && opacity(L.p) == 1 && !lighton) + _draw(f3,S.external(),v,L.p,interaction.type); + } + endgroup3(f3); + if(L.defaulttransform3) + add(f1,T*f3); + else { + add(f2,inverse(T)*L.T3*f3); + endgroup3(f2); + add(f1,T*f2); + } + endgroup3(f1); + add(f,positioning*f1); } - endgroup3(f1); - add(f,positioning*f1); } else { begingroup3(f,name,render); for(patch S : surface(L,v,bbox=P.bboxonly).s) { triple V=L.align.is3D ? v+L.align.dir3*labelmargin(L.p) : v; draw3D(f,S,V,L.p,light,interaction); // Fill subdivision cracks - if(render.labelfill && opacity(L.p) == 1 && !lighton) + if(prc && render.labelfill && opacity(L.p) == 1 && !lighton) _draw(f,S.external(),V,L.p,interaction.type); } endgroup3(f); |