summaryrefslogtreecommitdiff
path: root/Build/source/utils/asymptote/drawpath3.cc
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2021-01-02 16:31:31 +0000
committerKarl Berry <karl@freefriends.org>2021-01-02 16:31:31 +0000
commit6457cd3f6e21e23e21db6dafff021d17f5457567 (patch)
tree08f169333e47c5fc1c50e828cf3a0f50bdf9b508 /Build/source/utils/asymptote/drawpath3.cc
parentdc2504a4c02af0ec2fff00e6b833c6143a06b4cd (diff)
asy 2.68 sources
git-svn-id: svn://tug.org/texlive/trunk@57291 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/utils/asymptote/drawpath3.cc')
-rw-r--r--Build/source/utils/asymptote/drawpath3.cc142
1 files changed, 62 insertions, 80 deletions
diff --git a/Build/source/utils/asymptote/drawpath3.cc b/Build/source/utils/asymptote/drawpath3.cc
index 07c64ef1a9f..088d2705db9 100644
--- a/Build/source/utils/asymptote/drawpath3.cc
+++ b/Build/source/utils/asymptote/drawpath3.cc
@@ -18,60 +18,43 @@ namespace camp {
using vm::array;
using namespace prc;
-
+
bool drawPath3::write(prcfile *out, unsigned int *, double, groupsmap&)
{
- Int n=g.length();
- if(n == 0 || invisible)
+ if(invisible)
return true;
if(straight) {
- triple *controls=new(UseGC) triple[n+1];
- for(Int i=0; i <= n; ++i)
- controls[i]=g.point(i);
-
- out->addLine(n+1,controls,diffuse);
+ triple controls[]={g.point((Int) 0),g.point((Int) 1)};
+ out->addLine(2,controls,diffuse);
} else {
- int m=3*n+1;
- triple *controls=new(UseGC) triple[m];
- controls[0]=g.point((Int) 0);
- controls[1]=g.postcontrol((Int) 0);
- size_t k=1;
- for(Int i=1; i < n; ++i) {
- controls[++k]=g.precontrol(i);
- controls[++k]=g.point(i);
- controls[++k]=g.postcontrol(i);
- }
- controls[++k]=g.precontrol(n);
- controls[++k]=g.point(n);
- out->addBezierCurve(m,controls,diffuse);
+ triple controls[]={g.point((Int) 0),g.postcontrol((Int) 0),
+ g.precontrol((Int) 1),g.point((Int) 1)};
+ out->addBezierCurve(4,controls,diffuse);
}
-
+
return true;
}
bool drawPath3::write(jsfile *out)
{
#ifdef HAVE_LIBGLM
- Int n=g.length();
- if(n == 0 || invisible)
+ if(invisible)
return true;
if(billboard) {
meshinit();
drawElement::centerIndex=centerIndex;
} else drawElement::centerIndex=0;
-
+
setcolors(false,diffuse,emissive,specular,shininess,metallic,fresnel0,out);
-
- for(Int i=0; i < n; ++i) {
- if(g.straight(i)) {
- out->addCurve(g.point(i),g.point(i+1),Min,Max);
- } else
- out->addCurve(g.point(i),g.postcontrol(i),
- g.precontrol(i+1),g.point(i+1),Min,Max);
- }
-#endif
+
+ if(straight)
+ out->addCurve(g.point((Int) 0),g.point((Int) 1),Min,Max);
+ else
+ out->addCurve(g.point((Int) 0),g.postcontrol((Int) 0),
+ g.precontrol((Int) 1),g.point((Int) 1),Min,Max);
+#endif
return true;
}
@@ -79,49 +62,48 @@ void drawPath3::render(double size2, const triple& b, const triple& B,
double perspective, bool remesh)
{
#ifdef HAVE_GL
- Int n=g.length();
- if(n == 0 || invisible) return;
+ if(invisible) return;
setcolors(false,diffuse,emissive,specular,shininess,metallic,fresnel0);
setMaterial(material1Data,drawMaterial1);
-
+
bool offscreen;
- if(gl::exporting)
- offscreen=false;
- else if(billboard) {
+ if(billboard) {
drawElement::centerIndex=centerIndex;
BB.init(center);
offscreen=bbox2(Min,Max,BB).offscreen();
} else
offscreen=bbox2(Min,Max).offscreen();
-
+
if(offscreen) { // Fully offscreen
R.Onscreen=false;
R.data.clear();
+ R.notRendered();
return;
}
- for(Int i=0; i < n; ++i) {
- triple controls[]={g.point(i),g.postcontrol(i),g.precontrol(i+1),
- g.point(i+1)};
- triple *Controls;
- triple Controls0[4];
- if(billboard) {
- Controls=Controls0;
- for(size_t i=0; i < 4; i++) {
- Controls[i]=BB.transform(controls[i]);
- }
- } else
- Controls=controls;
-
- double s=perspective ? Min.getz()*perspective : 1.0; // Move to glrender
-
- const pair size3(s*(B.getx()-b.getx()),s*(B.gety()-b.gety()));
-
- R.queue(controls,g.straight(i),size3.length()/size2);
+ triple controls[]={g.point((Int) 0),g.postcontrol((Int) 0),
+ g.precontrol((Int) 1),g.point((Int) 1)};
+ triple *Controls;
+ triple Controls0[4];
+ if(billboard) {
+ Controls=Controls0;
+ for(size_t i=0; i < 4; i++)
+ Controls[i]=BB.transform(controls[i]);
+ } else {
+ Controls=controls;
+ if(!remesh && R.Onscreen) { // Fully onscreen; no need to re-render
+ R.append();
+ return;
+ }
}
-
+
+ double s=perspective ? Min.getz()*perspective : 1.0; // Move to glrender
+
+ const pair size3(s*(B.getx()-b.getx()),s*(B.gety()-b.gety()));
+
+ R.queue(controls,straight,size3.length()/size2);
#endif
}
@@ -129,14 +111,14 @@ drawElement *drawPath3::transformed(const double* t)
{
return new drawPath3(t,this);
}
-
+
bool drawNurbsPath3::write(prcfile *out, unsigned int *, double, groupsmap&)
{
if(invisible)
return true;
out->addCurve(degree,n,controls,knots,color,weights);
-
+
return true;
}
@@ -145,7 +127,7 @@ void drawNurbsPath3::bounds(const double* t, bbox3& b)
{
double x,y,z;
double X,Y,Z;
-
+
triple* Controls;
if(t == NULL) Controls=controls;
else {
@@ -153,12 +135,12 @@ void drawNurbsPath3::bounds(const double* t, bbox3& b)
for(size_t i=0; i < n; i++)
Controls[i]=t*controls[i];
}
-
+
boundstriples(x,y,z,X,Y,Z,n,Controls);
-
+
b.add(x,y,z);
b.add(X,Y,Z);
-
+
if(t == NULL) {
Min=triple(x,y,z);
Max=triple(X,Y,Z);
@@ -180,13 +162,13 @@ void drawNurbsPath3::ratio(const double* t, pair &b, double (*m)(double, double)
for(size_t i=0; i < n; i++)
Controls[i]=t*controls[i];
}
-
+
if(first) {
first=false;
triple v=Controls[0];
b=pair(xratio(v),yratio(v));
}
-
+
double x=b.getx();
double y=b.gety();
for(size_t i=0; i < n; ++i) {
@@ -195,7 +177,7 @@ void drawNurbsPath3::ratio(const double* t, pair &b, double (*m)(double, double)
y=m(y,yratio(v));
}
b=pair(x,y);
-
+
if(t != NULL)
delete[] Controls;
}
@@ -214,10 +196,10 @@ void drawNurbsPath3::displacement()
else
for(size_t i=0; i < n; ++i)
store(Controls+3*i,controls[i]);
-
+
for(size_t i=0; i < nknots; ++i)
Knots[i]=knots[i];
-#endif
+#endif
}
void drawNurbsPath3::render(double, const triple&, const triple&,
@@ -225,7 +207,7 @@ void drawNurbsPath3::render(double, const triple&, const triple&,
{
#ifdef HAVE_GL
if(invisible) return;
-
+
// TODO: implement NURBS renderer
#endif
}
@@ -236,10 +218,10 @@ bool drawPixel::write(prcfile *out, unsigned int *, double, groupsmap&)
return true;
out->addPoint(v,color,width);
-
+
return true;
}
-
+
bool drawPixel::write(jsfile *out)
{
#ifdef HAVE_LIBGLM
@@ -248,24 +230,24 @@ bool drawPixel::write(jsfile *out)
RGBAColour Black(0.0,0.0,0.0,color.A);
setcolors(false,color,color,Black,1.0,0.0,0.04,out);
-
+
out->addPixel(v,width,Min,Max);
-#endif
+#endif
return true;
}
void drawPixel::render(double size2, const triple& b, const triple& B,
- double perspective, bool remesh)
+ double perspective, bool remesh)
{
#ifdef HAVE_GL
if(invisible) return;
-
+
RGBAColour Black(0.0,0.0,0.0,color.A);
setcolors(false,color,color,Black,1.0,0.0,0.04);
setMaterial(material0Data,drawMaterial0);
- if(!gl::exporting && bbox2(Min,Max).offscreen()) { // Fully offscreen
+ if(bbox2(Min,Max).offscreen()) { // Fully offscreen
R.data.clear();
return;
}
@@ -278,5 +260,5 @@ drawElement *drawPixel::transformed(const double* t)
{
return new drawPixel(t*v,p,width,KEY);
}
-
+
} //namespace camp