[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gzz-commits] libvob include/vob/geom/Fillets.hxx vob/demo/mu...
From: |
Tuomas J. Lukka |
Subject: |
[Gzz-commits] libvob include/vob/geom/Fillets.hxx vob/demo/mu... |
Date: |
Fri, 30 May 2003 02:20:42 -0400 |
CVSROOT: /cvsroot/libvob
Module name: libvob
Changes by: Tuomas J. Lukka <address@hidden> 03/05/30 02:20:42
Modified files:
include/vob/geom: Fillets.hxx
vob/demo : multifil.py
Log message:
Fix center of connection artifacts - now line thickness remains
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/include/vob/geom/Fillets.hxx.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/vob/demo/multifil.py.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
Patches:
Index: libvob/include/vob/geom/Fillets.hxx
diff -u libvob/include/vob/geom/Fillets.hxx:1.5
libvob/include/vob/geom/Fillets.hxx:1.6
--- libvob/include/vob/geom/Fillets.hxx:1.5 Thu May 29 14:47:17 2003
+++ libvob/include/vob/geom/Fillets.hxx Fri May 30 02:20:42 2003
@@ -13,6 +13,7 @@
float r;
Vec ctr;
Vec filletcenter;
+ Vec endPoint;
float filletrad;
float dist;
@@ -38,6 +39,7 @@
this->dist = dist;
Vec dir = dirVec(angle);
Vec p = ctr + dist * dir + .5 * thick * sign * dir.cw90();
+ this->endPoint = p;
this->filletcenter =
circle__point_norm_circle(p, sign * dir.cw90(), ctr, r);
this->filletrad =
@@ -52,6 +54,20 @@
dirconn.cross(dirtang) * dirconn.cross(dir) >= 0;
}
+ bool atEnd(Vec dir) {
+ if(!infillet(dir)) return false;
+ bool succ;
+ project2circle(ctr + dir, ctr, filletcenter,
+ filletrad, -1, &succ);
+ if(!succ) {
+ return true;
+ }
+ return false;
+ }
+ Vec end() {
+ return endPoint;
+ }
+
/** Get the radius of the filleted curve
* at the given direction.
*/
@@ -71,6 +87,8 @@
return r;
}
}
+
+
};
@@ -171,20 +189,26 @@
// Angle of real current sample
float ang = lerp(aa, aang, 2*fract);
Vec d = dirVec(ang);
- float r0 = this->a.rad(d);
+ ZVec p;
+ if(a.atEnd(d)) {
+ p = a.end();
+ p.z = za;
+ } else {
+ float r0 = this->a.rad(d);
- // Angles to use for the blended curve when aa-ab==fangle:
- Vec da = dirVec(aa + fangle/2 * (2*fract));
- Vec db = dirVec(ab - fangle + fangle/2 * (2*fract));
- float ra = this->a.rad(da);
- float rb = this->b.rad(db);
- float curvfra = blend(ra-r, rb-r) + r;
-
- ZVec p = ctr + lerp(
- da * curvfra,
- d * r0,
- f);
- p.z = lerp(ctr.z, za, ((p-ctr).length() - r) / (this->da-r));
+ // Angles to use for the blended curve when aa-ab==fangle:
+ Vec da = dirVec(aa + fangle/2 * (2*fract));
+ Vec db = dirVec(ab - fangle + fangle/2 * (2*fract));
+ float ra = this->a.rad(da);
+ float rb = this->b.rad(db);
+ float curvfra = blend(ra-r, rb-r) + r;
+
+ p = ctr + lerp(
+ da * curvfra,
+ d * r0,
+ f);
+ p.z = lerp(ctr.z, za, ((p-ctr).length() - r) /
(this->da-r));
+ }
if(intern) {
if(fract < .47) {
@@ -207,20 +231,27 @@
float ang = lerp(ab, bang, 2*fract);
Vec d = dirVec(ang);
- float r0 = this->b.rad(d);
+ ZVec p;
- // Angles to use for the blended curve when aa-ab==fangle:
- Vec db = dirVec(ab - fangle/2 * (2*fract));
- Vec da = dirVec(aa + fangle - fangle/2 * (2*fract));
- float rb = this->b.rad(db);
- float ra = this->a.rad(da);
- float curvfra = blend(rb-r, ra-r) + r;
-
- ZVec p = ctr + lerp(
- db * curvfra,
- d * r0,
- f);
- p.z = lerp(ctr.z, zb, ((p-ctr).length() - r) / (this->db-r));
+ if(b.atEnd(d)) {
+ p = b.end();
+ p.z = zb;
+ } else {
+ float r0 = this->b.rad(d);
+
+ // Angles to use for the blended curve when aa-ab==fangle:
+ Vec db = dirVec(ab - fangle/2 * (2*fract));
+ Vec da = dirVec(aa + fangle - fangle/2 * (2*fract));
+ float rb = this->b.rad(db);
+ float ra = this->a.rad(da);
+ float curvfra = blend(rb-r, ra-r) + r;
+
+ p = ctr + lerp(
+ db * curvfra,
+ d * r0,
+ f);
+ p.z = lerp(ctr.z, zb, ((p-ctr).length() - r) /
(this->db-r));
+ }
if(intern) {
if(fract < .47) {
@@ -243,28 +274,37 @@
} else {
// Use angle
Vec d = dirVec(lerp(aa, ab, fract));
- float ra = a.rad(d);
- float rb = b.rad(d);
+ ZVec res;
float z, resr;
- if(type == SEPARATE) {
- if(ra > rb) {
- z = lerp(ctr.z, za, (ra - r) / (da-r)) ;
- resr = ra;
+ if(a.atEnd(d)) {
+ res = a.end();
+ z = za;
+ } else if(b.atEnd(d)) {
+ res = b.end();
+ z = zb;
+ } else {
+ float ra = a.rad(d);
+ float rb = b.rad(d);
+ if(type == SEPARATE) {
+ if(ra > rb) {
+ z = lerp(ctr.z, za, (ra - r) / (da-r)) ;
+ resr = ra;
+ } else {
+ z = lerp(ctr.z, zb, (rb - r) / (db-r)) ;
+ resr = rb;
+ }
} else {
- z = lerp(ctr.z, zb, (rb - r) / (db-r)) ;
- resr = rb;
+ resr = blend(ra-r, rb-r) + r;
+ z = blend(ra-r, rb-r,
+ lerp(ctr.z, za, (ra - r) / (da-r)),
+ lerp(ctr.z, zb, (rb - r) / (db-r))
+ );
}
- } else {
- resr = blend(ra-r, rb-r) + r;
- z = blend(ra-r, rb-r,
- lerp(ctr.z, za, (ra - r) / (da-r)),
- lerp(ctr.z, zb, (rb - r) / (db-r))
- );
+ res = ctr + d * resr;
}
- ZVec res = ctr + d * resr;
if(intern) {
if(fract < .47) {
- *intern = d*resr;
+ *intern = res - ctr;
*intern -= intern->dot(a.dirconn.cw90()) * a.dirconn.cw90();
intern->z = z - ctr.z;
if(intern->length() <= r) *intern = ZVec(0,0,0);
@@ -272,7 +312,7 @@
} else if(fract < .53) {
*intern = ctr;
} else {
- *intern = d*resr;
+ *intern = res - ctr;
*intern -= intern->dot(b.dirconn.cw90()) * b.dirconn.cw90();
intern->z = z - ctr.z;
if(intern->length() <= r) *intern = ZVec(0,0,0);
Index: libvob/vob/demo/multifil.py
diff -u libvob/vob/demo/multifil.py:1.5 libvob/vob/demo/multifil.py:1.6
--- libvob/vob/demo/multifil.py:1.5 Thu May 29 14:47:17 2003
+++ libvob/vob/demo/multifil.py Fri May 30 02:20:42 2003
@@ -27,8 +27,8 @@
PushAttrib POLYGON_BIT
Enable DEPTH_TEST
DepthFunc LEQUAL
- LineWidth 1
- PolygonOffset 0 0
+ LineWidth 10
+ PolygonOffset -100 -100
ShadeModel SMOOTH
"""))