[Plib-cvs] plib/src/sg sg.cxx,1.39,1.40 sg.h,1.51,1.52 sgd.cxx,1.11,1.12
Brought to you by:
sjbaker
From: M?rten Str?m. <str...@us...> - 2003-11-12 12:39:40
|
Update of /cvsroot/plib/plib/src/sg In directory sc8-pr-cvs1:/tmp/cvs-serv28092 Modified Files: sg.cxx sg.h sgd.cxx Log Message: Patches by Brano Kemen + sgFrustum/sgBox intersection. Index: sg.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/sg/sg.cxx,v retrieving revision 1.39 retrieving revision 1.40 diff -u -d -r1.39 -r1.40 --- sg.cxx 7 Oct 2003 03:00:08 -0000 1.39 +++ sg.cxx 12 Nov 2003 12:39:16 -0000 1.40 @@ -667,32 +667,22 @@ * and (A,B,C,D) is the same plane expressed in eye coordinates. */ - sgVec4 pln[6] = { - { SG_ONE, SG_ZERO, SG_ZERO, SG_ONE }, // left - { -SG_ONE, SG_ZERO, SG_ZERO, SG_ONE }, // right - { SG_ZERO, SG_ONE, SG_ZERO, SG_ONE }, // bottom - { SG_ZERO, -SG_ONE, SG_ZERO, SG_ONE }, // top - { SG_ZERO, SG_ZERO, SG_ONE, SG_ONE }, // near - { SG_ZERO, SG_ZERO, -SG_ONE, SG_ONE }, // far - }; [...82 lines suppressed...] + { b->getMin()[0], b->getMin()[1], b->getMax()[2] }, + { b->getMax()[0], b->getMin()[1], b->getMax()[2] }, + { b->getMin()[0], b->getMax()[1], b->getMax()[2] }, + { b->getMax()[0], b->getMax()[1], b->getMax()[2] }, + } ; + + int all = -1 ; + int one = 0 ; + + for (int i = 0 ; i < 8 ; i++ ) + { + int tmp = ~ getOutcode ( p[i] ) ; + all &= tmp ; + one |= tmp ; + } + + return ( all ? SG_OUTSIDE : one ? SG_STRADDLE : SG_INSIDE ) ; } Index: sg.h =================================================================== RCS file: /cvsroot/plib/plib/src/sg/sg.h,v retrieving revision 1.51 retrieving revision 1.52 diff -u -d -r1.51 -r1.52 --- sg.h 7 Oct 2003 03:00:11 -0000 1.51 +++ sg.h 12 Nov 2003 12:39:16 -0000 1.52 @@ -917,6 +917,7 @@ { sgVec3 center ; SGfloat radius ; + public: sgSphere () { empty () ; } @@ -1026,12 +1027,13 @@ int intersects ( const sgVec4 plane ) const ; } ; [...326 lines suppressed...] +void sgdTriangleSolver_ASStoSAA ( SGDfloat angB, SGDfloat lenA, SGDfloat lenB, + int angA_is_obtuse, + SGDfloat *lenC, SGDfloat *angA, SGDfloat *angC ) ; /* SPRING-MASS-DAMPER (with simple Euler integrator) @@ -2736,9 +2853,10 @@ sgZeroVec3 ( force ) ; } - float *getPos () { return pos ; } - float *getVel () { return vel ; } - float *getForce () { return force ; } + const SGfloat *getPos () const { return pos ; } + const SGfloat *getVel () const { return vel ; } + const SGfloat *getForce () const { return force ; } + float getOneOverMass () { return ooMass ; } float getMass () { return 1.0f / ooMass ; } Index: sgd.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/sg/sgd.cxx,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- sgd.cxx 2 Sep 2002 06:05:46 -0000 1.11 +++ sgd.cxx 12 Nov 2003 12:39:16 -0000 1.12 @@ -24,6 +24,8 @@ #include "sg.h" +sgdVec3 _sgdGravity = { 0.0f, 0.0f, -9.8f } ; + void sgdVectorProductVec3 ( sgdVec3 dst, const sgdVec3 a, const sgdVec3 b ) { dst[0] = a[1] * b[2] - a[2] * b[1] ; @@ -83,6 +85,214 @@ } [...1213 lines suppressed...] + /* Use SAStoASA to get the last length */ + + sgdTriangleSolver_SAStoASA ( lenA, cc, lenB, NULL, lenC, NULL ) ; +} + + +void sgdTriangleSolver_SAAtoASS ( SGDfloat lenA, SGDfloat angB, SGDfloat angA, + SGDfloat *angC, SGDfloat *lenB, SGDfloat *lenC ) +{ + /* Find the missing angle */ + + SGDfloat cc = SGD_180 - (angB + angA) ; + + if ( angC ) *angC = cc ; + + sgdTriangleSolver_ASAtoSAS ( cc, lenA, angB, lenC, NULL, lenB ) ; +} + |