| 964 | } |
| 965 | |
| 966 | void TerrCell::cullCells( const SceneRenderState *state, |
| 967 | const Point3F &objLodPos, |
| 968 | Vector<TerrCell*> *outCells ) |
| 969 | { |
| 970 | // If we have a VB and no children then just add |
| 971 | // ourselves to the results and return. |
| 972 | if ( mVertexBuffer.isValid() && !mChildren[0] ) |
| 973 | { |
| 974 | outCells->push_back( this ); |
| 975 | return; |
| 976 | } |
| 977 | |
| 978 | const F32 screenError = mTerrain->getScreenError(); |
| 979 | const BitVector &zoneState = state->getCullingState().getZoneVisibilityFlags(); |
| 980 | |
| 981 | for ( U32 i = 0; i < 4; i++ ) |
| 982 | { |
| 983 | TerrCell *cell = mChildren[i]; |
| 984 | |
| 985 | // Test cell visibility for interior zones. |
| 986 | |
| 987 | const bool visibleInside = !cell->getZoneOverlap().empty() ? zoneState.testAny( cell->getZoneOverlap() ) : false; |
| 988 | |
| 989 | // Test cell visibility for outdoor zone, but only |
| 990 | // if we need to. |
| 991 | |
| 992 | bool visibleOutside = false; |
| 993 | if( !mIsInteriorOnly && !visibleInside ) |
| 994 | { |
| 995 | U32 outdoorZone = SceneZoneSpaceManager::RootZoneId; |
| 996 | visibleOutside = !state->getCullingState().isCulled( cell->mOBB, &outdoorZone, 1 ); |
| 997 | } |
| 998 | |
| 999 | // Skip cell if neither visible indoors nor outdoors. |
| 1000 | |
| 1001 | if( !visibleInside && !visibleOutside ) |
| 1002 | continue; |
| 1003 | |
| 1004 | // Lod based on screen error... |
| 1005 | // If far enough, just add this child cells vb ( skipping its children ). |
| 1006 | F32 dist = cell->getDistanceTo( objLodPos ); |
| 1007 | F32 errorMeters = ( cell->mSize / smMinCellSize ) * mTerrain->getSquareSize(); |
| 1008 | U32 errorPixels = mCeil( state->projectRadius( dist, errorMeters ) ); |
| 1009 | |
| 1010 | if ( errorPixels < screenError ) |
| 1011 | { |
| 1012 | if ( cell->mVertexBuffer.isValid() ) |
| 1013 | outCells->push_back( cell ); |
| 1014 | } |
| 1015 | else |
| 1016 | cell->cullCells( state, objLodPos, outCells ); |
| 1017 | } |
| 1018 | } |
| 1019 | |
| 1020 | void TerrCell::getRenderPrimitive( GFXPrimitive *prim, |
| 1021 | GFXVertexBufferHandleBase *vertBuff, |
no test coverage detected