diff options
Diffstat (limited to 'Build/source/utils/asymptote/beziercurve.h')
-rw-r--r-- | Build/source/utils/asymptote/beziercurve.h | 124 |
1 files changed, 37 insertions, 87 deletions
diff --git a/Build/source/utils/asymptote/beziercurve.h b/Build/source/utils/asymptote/beziercurve.h index 573b48a7929..e3c460e3151 100644 --- a/Build/source/utils/asymptote/beziercurve.h +++ b/Build/source/utils/asymptote/beziercurve.h @@ -17,116 +17,66 @@ namespace camp { extern const double Fuzz; extern const double Fuzz2; -class vertexData1 { -public: - GLfloat position[3]; - GLint material; - vertexData1() {}; - vertexData1(const triple& v) { - position[0]=v.getx(); - position[1]=v.gety(); - position[2]=v.getz(); - material=drawElement::materialIndex; - } -}; - -class pixelData { -public: - GLfloat position[3]; - GLint material; - GLfloat width; - pixelData() {}; - pixelData(const triple& v, double width) : width(width) { - position[0]=v.getx(); - position[1]=v.gety(); - position[2]=v.getz(); - material=drawElement::materialIndex; - } -}; - struct BezierCurve { - static std::vector<vertexData1> vertexbuffer; - static std::vector<GLuint> indices; + vertexBuffer data; double res,res2; - triple Min,Max; - - static GLuint vertsBufferIndex; - static GLuint elemBufferIndex; + bool Onscreen; - void init(double res, const triple& Min, const triple& Max); + void init(double res); -// Store the vertex v in the buffer. - static GLuint vertex(const triple &v) { - size_t nvertices=vertexbuffer.size(); - vertexbuffer.push_back(vertexData1(v)); - return nvertices; + // Approximate bounds by bounding box of control polyhedron. + bool offscreen(size_t n, const triple *v) { + if(bbox2(n,v).offscreen()) { + Onscreen=false; + return true; + } + return false; } - - void createBuffers() { - glGenBuffers(1,&vertsBufferIndex); - glGenBuffers(1,&elemBufferIndex); - //vbo - registerBuffer(vertexbuffer,vertsBufferIndex); - - //ebo - registerBuffer(indices,elemBufferIndex); - } + void render(const triple *p, bool straight); + void render(const triple *p, GLuint I0, GLuint I1); -// Approximate bounds by bounding box of control polyhedron. - bool offscreen(size_t n, const triple *v) { - double x,y,z; - double X,Y,Z; + void append() { + material1Data.append1(data); - boundstriples(x,y,z,X,Y,Z,n,v); - return - X < Min.getx() || x > Max.getx() || - Y < Min.gety() || y > Max.gety() || - Z < Min.getz() || z > Max.getz(); - } - - static void clear() { - vertexbuffer.clear(); - indices.clear(); + if(material1Data.vertices1.size() >= gl::maxvertices) { + drawBuffer(material1Data,noNormalShader); + material1Data.clear(); + gl::forceRemesh=true; + } } - ~BezierCurve() {} - - void render(const triple *p, GLuint I0, GLuint I1); - void render(const triple *p, bool straight); - - void queue(const triple *g, bool straight, double ratio, - const triple& Min, const triple& Max) { - init(pixel*ratio,Min,Max); + void queue(const triple *g, bool straight, double ratio) { + data.clear(); + Onscreen=true; + init(pixel*ratio); render(g,straight); } - void draw(); - void draw(const triple *g, bool straight, double ratio, - const triple& Min, const triple& Max) { - queue(g,straight,ratio,Min,Max); - draw(); - } }; struct Pixel { - static std::vector<pixelData> vertexbuffer; + vertexBuffer data; -// Store the vertex v in the buffer. - static void vertex(const triple &v, double width) { - vertexbuffer.push_back(pixelData(v,width)); + void append() { + material0Data.append0(data); + + if(material0Data.vertices0.size() >= gl::maxvertices) { + drawBuffer(material0Data,pixelShader); + material0Data.clear(); + gl::forceRemesh=true; + } } - static void clear() { - vertexbuffer.clear(); + void queue(const triple& p, double width) { + data.clear(); + MaterialIndex=materialIndex; + data.indices.push_back(data.vertex0(p,width)); + append(); } - Pixel() {} - ~Pixel() {} - - void queue(const triple& p, double width); void draw(); }; |