707 |
}; |
}; |
708 |
|
|
709 |
ZVec blend(Conn *conns[], int N, float r, ZVec pt) const { |
ZVec blend(Conn *conns[], int N, float r, ZVec pt) const { |
710 |
int num = 0; |
int i, num = 0; |
711 |
float sum = 0; |
float sum = 0; |
712 |
|
float x[N]; |
713 |
|
|
714 |
for (int i = 0; i < N; i++) { |
// Compute distances from the node for each fillet surface |
715 |
|
for (i = 0; i < N; i++) { |
716 |
bool success; |
bool success; |
717 |
float t = conns[i]->rad(pt, success); |
float t = conns[i]->rad(pt, success); |
718 |
if (success) { |
if (success) |
719 |
sum += t - r; |
sum += x[num++] = (t - r) / r; |
|
num++; |
|
|
} |
|
720 |
} |
} |
721 |
|
|
722 |
return pt * (1 + sum / r); |
// Compute p for an l^p norm to be used as the blending function |
723 |
|
// p == 1: sum of distance, |
724 |
|
// p == \infty: maximum of distances |
725 |
|
float p = 1.0 + sum; |
726 |
|
|
727 |
|
sum = 0; |
728 |
|
for (i = 0; i < num; i++) |
729 |
|
sum += pow(x[i], p); |
730 |
|
|
731 |
|
return pt * (1 + pow(sum, 1 / p)); |
732 |
|
|
733 |
} |
} |
734 |
|
|
804 |
} |
} |
805 |
glNormal(norm[i][0]); |
glNormal(norm[i][0]); |
806 |
glVertex(pt[i][0]); |
glVertex(pt[i][0]); |
807 |
|
|
808 |
|
glNormal(norm[i+1][0]); |
809 |
|
glVertex(pt[i+1][0]); |
810 |
glEnd(); |
glEnd(); |
811 |
} |
} |
812 |
|
|