Commit 60af788a authored by Sabrina Templeton's avatar Sabrina Templeton
Browse files

commiting here in case it breaks

parent d6e8b2db
......@@ -131,10 +131,10 @@ vec3 calc_intersect(vec3 p1, vec3 p2, vec3 q1, vec3 q2){ // p1 and p2 are seeds,
return vec3(x0, y0, 0);
}
void calc_poly(vec3 zi, vec3 zj, inout vec3[4] curr_poly){
void calc_poly(vec3 zi, vec3 zj, inout vec3[MAX_VERTS] curr_poly, int poly_space){
//where zi is the pt and zj is the current nearest neighbor
//first step : start with just the initial polygon for now and perform one clip
vec3 new_poly[4];//= vec3[4](vec3(0, 0, 0), vec3(0, 0, 0), vec3(0, 0, 0), vec3(0, 0, 0));
vec3 new_poly[MAX_VERTS];//= vec3[4](vec3(0, 0, 0), vec3(0, 0, 0), vec3(0, 0, 0), vec3(0, 0, 0));
for (int i = 0; i < 4; i++) {
......@@ -144,8 +144,8 @@ void calc_poly(vec3 zi, vec3 zj, inout vec3[4] curr_poly){
vec3 b0 = vec3(0, 0, 0);
vec3 b1 = vec3(0, 0, 0);
if (i == curr_poly.length() -1){
b0 = curr_poly[curr_poly.length() -1];
if (i == poly_space-1){
b0 = curr_poly[poly_space -1];
b1 = curr_poly[0];
}
else{
......@@ -173,15 +173,18 @@ void calc_poly(vec3 zi, vec3 zj, inout vec3[4] curr_poly){
if (side1 != side2){
intersect = calc_intersect(zi, zj, b0, b1); //b0 and b1 are the current border points
if (side1 == 1){
new_poly[i] = curr_poly[i];
new_poly[i+1] = intersect;
new_poly[poly_space] = b0;
new_poly[poly_space+1] = intersect;
poly_space += 2;
}
else{
new_poly[i] = intersect;
new_poly[poly_space] = intersect;
poly_space += 1;
}
}
else if (side1 == 1){ //meaning both sides are 1
new_poly[i] = curr_poly[i]; // append pt 1 essentially
new_poly[poly_space] = b0; // append pt 1 essentially
poly_space += 1;
}
//otherwise both sides are -1 and we take neither
......@@ -223,8 +226,12 @@ main() {
render_square(curr_poly4, .02);
vec3 poly[MAX_VERTS];
vec3[4] curr_poly = vec3[4](curr_poly1, curr_poly2, curr_poly3, curr_poly4);
vec3 test = vec3(0, 0, 0);
vec3[MAX_VERTS] curr_poly;
// = vec3[MAX_VERTS](curr_poly1, curr_poly2, curr_poly3, curr_poly4);
curr_poly[0] = curr_poly1;
curr_poly[1] = curr_poly2;
curr_poly[2] = curr_poly3;
curr_poly[3] = curr_poly4;
//************************************************************************************************
//This is a test of the the intersect function. It works!!
// vec3 test_pt = calc_intersect(vec3(.3, .5, 0), vec3(.3, -.5, 0), vec3(0, .5, 0), vec3(0, -.5, 0));
......@@ -242,7 +249,7 @@ main() {
// test.y += .1;
// test.z += .1;
/*curr_poly = */calc_poly(p0, nn0, curr_poly);
calc_poly(p0, nn0, curr_poly, 4);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment