[Plib-cvs] plib/src/ssg ssg.h,1.147,1.148 ssgContext.cxx,1.15,1.16 ssgEntity.cxx,1.21,1.22 ssgOptimi
Brought to you by:
sjbaker
From: M?rten Str?m. <str...@us...> - 2002-09-09 09:08:32
|
Update of /cvsroot/plib/plib/src/ssg In directory usw-pr-cvs1:/tmp/cvs-serv5200 Modified Files: ssg.h ssgContext.cxx ssgEntity.cxx ssgOptimiser.cxx Log Message: Added orthographic culling support. Index: ssg.h =================================================================== RCS file: /cvsroot/plib/plib/src/ssg/ssg.h,v retrieving revision 1.147 retrieving revision 1.148 diff -u -d -r1.147 -r1.148 --- ssg.h 2 Sep 2002 06:05:47 -0000 1.147 +++ ssg.h 9 Sep 2002 09:08:29 -0000 1.148 @@ -2247,7 +2247,6 @@ ssgSimpleState *basicState ; sgFrustum *frustum ; - int orthographic ; sgMat4 cameraMatrix ; int cullFace ; int ovTexture ; @@ -2307,21 +2306,22 @@ int cullfaceIsEnabled () { return cullFace ; } sgFrustum *getFrustum () { return frustum ; } - void setFrustum ( const SGfloat l, const SGfloat r, - const SGfloat b, const SGfloat t, - const SGfloat n, const SGfloat f ) - { - frustum->setFrustum ( l,r,b,t,n,f ); - } + // make a perspective projection + void setFrustum ( float l, float r, float b, float t, float n, float f ) ; + + // make an orthographic projection + void setOrtho ( float l, float r, float b, float t, float n, float f ) ; + void getNearFar ( float *n, float *f ) ; void getFOV ( float *w, float *h ) ; void getOrtho ( float *w, float *h ) ; + void setNearFar ( float n, float f ) ; - void setOrtho ( float w, float h ) ; - void setFOV ( float w, float h ) ; + void setOrtho ( float w, float h ) ; // make orthographic + void setFOV ( float w, float h ) ; // make perspective - int isOrtho () { return orthographic ; } + int isOrtho () { return frustum -> isOrtho () ; } // is orthographic ssgSimpleState *getState () { return currentState ; } void cull ( ssgRoot *r ) ; @@ -2382,6 +2382,16 @@ _ssgCurrentContext->getOrtho ( w, h ) ; } +inline void ssgSetFrustum ( float l, float r, float b, float t, float n, float f ) +{ + _ssgCurrentContext->setFrustum ( l, r, b, t, n, f ) ; +} + +inline void ssgSetOrtho ( float l, float r, float b, float t, float n, float f ) +{ + _ssgCurrentContext->setOrtho ( l, r, b, t, n, f ) ; +} + inline void ssgSetFOV ( float w, float h ) { _ssgCurrentContext->setFOV ( w, h ) ; @@ -2457,14 +2467,6 @@ { return _ssgCurrentContext -> getFrustum() ; } - -inline void ssgSetFrustum ( const SGfloat l, const SGfloat r, - const SGfloat b, const SGfloat t, - const SGfloat n, const SGfloat f ) -{ - ssgGetFrustum()->setFrustum ( l,r,b,t,n,f ); -} - void ssgInit () ; Index: ssgContext.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/ssg/ssgContext.cxx,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- ssgContext.cxx 2 Sep 2002 06:05:48 -0000 1.15 +++ ssgContext.cxx 9 Sep 2002 09:08:29 -0000 1.16 @@ -44,7 +44,7 @@ makeCurrent () ; currentState = NULL ; basicState = NULL ; - orthographic = FALSE ; + //orthographic = FALSE ; cullFace = TRUE ; ovTexture = FALSE ; ovCullface = FALSE ; @@ -120,6 +120,17 @@ ovCullface = on_off ; } [...63 lines suppressed...] - float b = frustum -> getBot () ; - float t = frustum -> getTop () ; - float n = frustum -> getNear () ; - float f = frustum -> getFar () ; - - sgMakeIdentMat4 ( dst ) ; - dst[0][0] = 2.0f / ( r - l ) ; - dst[1][1] = 2.0f / ( t - b ) ; - dst[2][2] = -2.0f / ( f - n ) ; - - dst[3][0] = - ( r + l ) / ( r - l ) ; - dst[3][1] = - ( t + b ) / ( t - b ) ; - dst[3][2] = - ( f + n ) / ( f - n ) ; - } - else - frustum -> getMat4 ( dst ) ; + frustum -> getMat4 ( dst ) ; } void ssgContext::getModelviewMatrix ( sgMat4 dst ) Index: ssgEntity.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/ssg/ssgEntity.cxx,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- ssgEntity.cxx 2 Sep 2002 06:05:48 -0000 1.21 +++ ssgEntity.cxx 9 Sep 2002 09:08:29 -0000 1.22 @@ -221,10 +221,7 @@ tmp . orthoXform ( m ) ; - if ( _ssgCurrentContext->isOrtho() ) - return SSG_STRADDLE ; /* XXX Fix Me!! XXX */ - else - return (ssgCullResult) f -> contains ( &tmp ) ; + return (ssgCullResult) f -> contains ( &tmp ) ; } Index: ssgOptimiser.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/ssg/ssgOptimiser.cxx,v retrieving revision 1.27 retrieving revision 1.28 diff -u -d -r1.27 -r1.28 --- ssgOptimiser.cxx 2 Sep 2002 06:05:48 -0000 1.27 +++ ssgOptimiser.cxx 9 Sep 2002 09:08:29 -0000 1.28 @@ -802,8 +802,7 @@ if ( parent -> isAKindOf ( ssgTypeSelector () ) ) { /* cannot remove kids from selectors */ - static ssgInvisible empty ; - parent -> replaceKid ( old_kid, &empty ) ; + parent -> replaceKid ( old_kid, new ssgInvisible ) ; } else { |