Ejemplo n.º 1
0
Vector2Array Curve2D::tesselate(int p_max_stages,float p_tolerance) const {

	Vector2Array tess;


	if (points.size()==0) {
		return tess;
	}
	Vector< Map<float,Vector2> > midpoints;

	midpoints.resize(points.size()-1);

	int pc=1;
	for(int i=0;i<points.size()-1;i++) {

		_bake_segment2d(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);
	Vector2Array::Write bpw=tess.write();
	bpw[0]=points[0].pos;
	int pidx=0;

	for(int i=0;i<points.size()-1;i++) {

		for(Map<float,Vector2>::Element *E=midpoints[i].front();E;E=E->next()) {

			pidx++;
			bpw[pidx] = E->get();
		}

		pidx++;
		bpw[pidx] = points[i+1].pos;

	}

	bpw=Vector2Array::Write ();

	return tess;

}
Ejemplo n.º 2
0
Dictionary Curve2D::_get_data() const {

	Dictionary dc;

	Vector2Array d;
	d.resize(points.size()*3);
	Vector2Array::Write w = d.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;

	}

	w=Vector2Array::Write();

	dc["points"]=d;

	return dc;
}