Dictionary Curve3D::_get_data() const { Dictionary dc; Vector3Array d; d.resize(points.size()*3); Vector3Array::Write w = d.write(); RealArray t; t.resize(points.size()); RealArray::Write wt = t.write(); for(int i=0;i<points.size();i++) { w[i*3+0]=points[i].in; w[i*3+1]=points[i].out; w[i*3+2]=points[i].pos; wt[i]=points[i].tilt; } w=Vector3Array::Write(); wt=RealArray::Write(); dc["points"]=d; dc["tilts"]=t; return dc; }
Vector3Array Curve3D::tesselate(int p_max_stages,float p_tolerance) const { Vector3Array tess; if (points.size()==0) { return tess; } Vector< Map<float,Vector3> > midpoints; midpoints.resize(points.size()-1); int pc=1; for(int i=0;i<points.size()-1;i++) { _bake_segment3d(midpoints[i],0,1,points[i].pos,points[i].out,points[i+1].pos,points[i+1].in,0,p_max_stages,p_tolerance); pc++; pc+=midpoints[i].size(); } tess.resize(pc); Vector3Array::Write bpw=tess.write(); bpw[0]=points[0].pos; int pidx=0; for(int i=0;i<points.size()-1;i++) { for(Map<float,Vector3>::Element *E=midpoints[i].front();E;E=E->next()) { pidx++; bpw[pidx] = E->get(); } pidx++; bpw[pidx] = points[i+1].pos; } bpw=Vector3Array::Write (); return tess; }