diff options
author | Ton Roosendaal <ton@blender.org> | 2004-11-03 14:25:27 +0300 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2004-11-03 14:25:27 +0300 |
commit | 691302f28dcf515cc99b1d7ad0c9e41970ab1fdd (patch) | |
tree | 9ba7ce787651c9715c9829b654477a18e34bf5c6 /source/blender/blenlib | |
parent | 318fb94c4b4c15c66737493436929393357b963c (diff) |
Two fixes;
- The function "convex()" in editmesh_lib() actually did not deliver
a proper test for convex at all. It was checking only if a quad could
be subdivided into 2 trias. Code for adding face (FKEY) used this
call in total confusing manner. That code was there in 1.40 already,
cannot find any clue what it was supposed todo... :)
Recoded convex() to deliver a proper test. FKEY will give warning on
attempt to make convex faces now.
- Added undo-free for editmode undo on file load
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/BLI_arithb.h | 12 | ||||
-rw-r--r-- | source/blender/blenlib/intern/arithb.c | 50 |
2 files changed, 62 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_arithb.h b/source/blender/blenlib/BLI_arithb.h index 4df5db5f39e..9935932ca31 100644 --- a/source/blender/blenlib/BLI_arithb.h +++ b/source/blender/blenlib/BLI_arithb.h @@ -540,6 +540,18 @@ VecRotToMat3( float phi, float mat[][3] ); + +/* intersect Line-Line + return: + -1: colliniar + 0: no intersection of segments + 1: exact intersection of segments + 2: cross-intersection of segments +*/ +extern short IsectLL2Df(float *v1, float *v2, float *v3, float *v4); +extern short IsectLL2Ds(short *v1, short *v2, short *v3, short *v4); + + float * vectoquat( float *vec, diff --git a/source/blender/blenlib/intern/arithb.c b/source/blender/blenlib/intern/arithb.c index ff057a61e51..08a26821ccd 100644 --- a/source/blender/blenlib/intern/arithb.c +++ b/source/blender/blenlib/intern/arithb.c @@ -1874,6 +1874,56 @@ float AreaPoly3Dfl(int nr, float *verts, float *normal) return (float)fabs(0.5*area/max); } +/* intersect Line-Line, shorts */ +short IsectLL2Ds(short *v1, short *v2, short *v3, short *v4) +{ + /* return: + -1: colliniar + 0: no intersection of segments + 1: exact intersection of segments + 2: cross-intersection of segments + */ + float div, labda, mu; + + div= (v2[0]-v1[0])*(v4[1]-v3[1])-(v2[1]-v1[1])*(v4[0]-v3[0]); + if(div==0.0) return -1; + + labda= ((float)(v1[1]-v3[1])*(v4[0]-v3[0])-(v1[0]-v3[0])*(v4[1]-v3[1]))/div; + + mu= ((float)(v1[1]-v3[1])*(v2[0]-v1[0])-(v1[0]-v3[0])*(v2[1]-v1[1]))/div; + + if(labda>=0.0 && labda<=1.0 && mu>=0.0 && mu<=1.0) { + if(labda==0.0 || labda==1.0 || mu==0.0 || mu==1.0) return 1; + return 2; + } + return 0; +} + +/* intersect Line-Line, floats */ +short IsectLL2Df(float *v1, float *v2, float *v3, float *v4) +{ + /* return: + -1: colliniar +0: no intersection of segments +1: exact intersection of segments +2: cross-intersection of segments + */ + float div, labda, mu; + + div= (v2[0]-v1[0])*(v4[1]-v3[1])-(v2[1]-v1[1])*(v4[0]-v3[0]); + if(div==0.0) return -1; + + labda= ((float)(v1[1]-v3[1])*(v4[0]-v3[0])-(v1[0]-v3[0])*(v4[1]-v3[1]))/div; + + mu= ((float)(v1[1]-v3[1])*(v2[0]-v1[0])-(v1[0]-v3[0])*(v2[1]-v1[1]))/div; + + if(labda>=0.0 && labda<=1.0 && mu>=0.0 && mu<=1.0) { + if(labda==0.0 || labda==1.0 || mu==0.0 || mu==1.0) return 1; + return 2; + } + return 0; +} + void MinMax3(float *min, float *max, float *vec) { if(min[0]>vec[0]) min[0]= vec[0]; |