~ogre-team/testogre/soc09-samples

« back to all changes in this revision

Viewing changes to PlugIns/OctreeZone/src/OgreTerrainZoneRenderable.cpp

  • Committer: sinbad
  • Date: 2009-09-27 15:34:47 UTC
  • Revision ID: svn-v4:8631bf8a-c64b-0410-883c-f3eb003322f7:branches/soc09-samples:9120
Merged trunk changes to r9109 into soc09-samples so that we can perform platform tests & refine
Once again a staged commit because of crappy server performance

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
(Object-oriented Graphics Rendering Engine)
5
5
For the latest info, see http://www.ogre3d.org/
6
6
 
7
 
Copyright (c) 2000-2006 Torus Knot Software Ltd
8
 
Also see acknowledgements in Readme.html
9
 
 
10
 
This program is free software; you can redistribute it and/or modify it under
11
 
the terms of the GNU Lesser General Public License as published by the Free Software
12
 
Foundation; either version 2 of the License, or (at your option) any later
13
 
version.
14
 
 
15
 
This program is distributed in the hope that it will be useful, but WITHOUT
16
 
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17
 
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
18
 
 
19
 
You should have received a copy of the GNU Lesser General Public License along with
20
 
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21
 
Place - Suite 330, Boston, MA 02111-1307, USA, or go to
22
 
http://www.gnu.org/copyleft/lesser.txt.
23
 
 
24
 
You may alternatively use this source under the terms of a specific version of
25
 
the OGRE Unrestricted License provided you have obtained such a license from
26
 
Torus Knot Software Ltd.
 
7
Copyright (c) 2000-2009 Torus Knot Software Ltd
 
8
 
 
9
Permission is hereby granted, free of charge, to any person obtaining a copy
 
10
of this software and associated documentation files (the "Software"), to deal
 
11
in the Software without restriction, including without limitation the rights
 
12
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 
13
copies of the Software, and to permit persons to whom the Software is
 
14
furnished to do so, subject to the following conditions:
 
15
 
 
16
The above copyright notice and this permission notice shall be included in
 
17
all copies or substantial portions of the Software.
 
18
 
 
19
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
20
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
21
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 
22
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 
23
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 
24
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 
25
THE SOFTWARE.
27
26
-----------------------------------------------------------------------------
28
27
TerrainZoneRenderable.cpp  -  based on OgreTerrainZoneRenderable.cpp from Ogre3d 
29
28
 
111
110
 
112
111
        if ( mOptions->maxGeoMipMapLevel != 0 )
113
112
        {
114
 
            int i = ( int ) 1 << ( mOptions->maxGeoMipMapLevel - 1 ) ;
 
113
            unsigned int i = ( unsigned int ) 1 << ( mOptions->maxGeoMipMapLevel - 1 ) ;
115
114
 
116
115
            if ( ( i + 1 ) > mOptions->tileSize )
117
116
            {
341
340
 
342
341
        mRenderLevel = -1;
343
342
 
344
 
        for ( int i = 0; i < mOptions->maxGeoMipMapLevel; i++ )
 
343
        for ( unsigned int i = 0; i < mOptions->maxGeoMipMapLevel; i++ )
345
344
        {
346
345
            if ( mMinLevelDistSqr[ i ] > L )
347
346
            {
468
467
 
469
468
        int i, j;
470
469
 
471
 
        for ( int level = 1; level < mOptions->maxGeoMipMapLevel; level++ )
 
470
        for ( unsigned int level = 1; level < mOptions->maxGeoMipMapLevel; level++ )
472
471
        {
473
472
            mMinLevelDistSqr[ level ] = 0;
474
473
 
475
474
            int step = 1 << level;
476
475
            // The step of the next higher LOD
477
 
            int higherstep = step >> 1;
 
476
//            int higherstep = step >> 1;
478
477
 
479
478
            float* pDeltas = 0;
480
479
            if (mOptions->lodMorph)
486
485
                    mDeltaBuffers[level - 1]->lock(HardwareBuffer::HBL_NORMAL));
487
486
            }
488
487
 
489
 
            for ( j = 0; j < mOptions->tileSize - step; j += step )
 
488
            for ( j = 0; j < (int) mOptions->tileSize - step; j += step )
490
489
            {
491
 
                for ( i = 0; i < mOptions->tileSize - step; i += step )
 
490
                for ( i = 0; i < (int) mOptions->tileSize - step; i += step )
492
491
                {
493
492
                    /* Form planes relating to the lower detail tris to be produced
494
493
                    For tri lists and even tri strip rows, they are this shape:
521
520
                    }
522
521
 
523
522
                    // include the bottommost row of vertices if this is the last row
524
 
                    int zubound = (j == (mOptions->tileSize - step)? step : step - 1);
 
523
                    int zubound = (j == ((int) mOptions->tileSize - step)? step : step - 1);
525
524
                    for ( int z = 0; z <= zubound; z++ )
526
525
                    {
527
526
                        // include the rightmost col of vertices if this is the last col
528
 
                        int xubound = (i == (mOptions->tileSize - step)? step : step - 1);
 
527
                        int xubound = (i == ((int) mOptions->tileSize - step)? step : step - 1);
529
528
                        for ( int x = 0; x <= xubound; x++ )
530
529
                        {
531
 
                            int fulldetailx = i + x;
532
 
                            int fulldetailz = j + z;
 
530
                            unsigned int fulldetailx = i + x;
 
531
                            unsigned int fulldetailz = j + z;
533
532
                            if ( fulldetailx % step == 0 && 
534
533
                                fulldetailz % step == 0 )
535
534
                            {
600
599
 
601
600
 
602
601
        // Post validate the whole set
603
 
        for ( i = 1; i < mOptions->maxGeoMipMapLevel; i++ )
 
602
        for ( i = 1; i < (int) mOptions->maxGeoMipMapLevel; i++ )
604
603
        {
605
604
 
606
605
            // Make sure no LOD transition within the tile
624
623
        int lastIndex = 0;
625
624
        for (i = mOptions->maxGeoMipMapLevel - 1; i >= 0; --i)
626
625
        {
627
 
            if (i == mOptions->maxGeoMipMapLevel - 1)
 
626
            if (i == (int) mOptions->maxGeoMipMapLevel - 1)
628
627
            {
629
628
                // Last one is always 0
630
629
                lastIndex = i;
731
730
        float x_pt = x_pct * ( float ) ( mOptions->tileSize - 1 );
732
731
        float z_pt = z_pct * ( float ) ( mOptions->tileSize - 1 );
733
732
 
734
 
        int x_index = ( int ) x_pt;
735
 
        int z_index = ( int ) z_pt;
 
733
        unsigned int x_index = ( int ) x_pt;
 
734
        unsigned int z_index = ( int ) z_pt;
736
735
 
737
736
        // If we got to the far right / bottom edge, move one back
738
737
        if (x_index == mOptions->tileSize - 1)
1002
1001
    IndexData* TerrainZoneRenderable::generateTriStripIndexes(unsigned int stitchFlags)
1003
1002
    {
1004
1003
        // The step used for the current level
1005
 
        int step = 1 << mRenderLevel;
 
1004
        unsigned int step = 1 << mRenderLevel;
1006
1005
        // The step used for the lower level
1007
 
        int lowstep = 1 << (mRenderLevel + 1);
 
1006
        unsigned int lowstep = 1 << (mRenderLevel + 1);
1008
1007
 
1009
1008
        int numIndexes = 0;
1010
1009
 
1030
1029
            HardwareBuffer::HBL_DISCARD));
1031
1030
 
1032
1031
        // Stripified mesh
1033
 
        for ( int j = 0; j < mOptions->tileSize - 1; j += step )
 
1032
        for ( unsigned int j = 0; j < mOptions->tileSize - 1; j += step )
1034
1033
        {
1035
 
            int i;
 
1034
            unsigned int i;
1036
1035
            // Forward strip
1037
1036
            // We just do the |/ here, final | done after
1038
1037
            for ( i = 0; i < mOptions->tileSize - 1; i += step )
1222
1221
            HardwareBuffer::HBL_DISCARD));
1223
1222
 
1224
1223
        // Do the core vertices, minus stitches
1225
 
        for ( int j = north; j < mOptions->tileSize - 1 - south; j += step )
 
1224
        for ( unsigned int j = north; j < mOptions->tileSize - 1 - south; j += step )
1226
1225
        {
1227
 
            for ( int i = west; i < mOptions->tileSize - 1 - east; i += step )
 
1226
            for ( unsigned int i = west; i < mOptions->tileSize - 1 - east; i += step )
1228
1227
            {
1229
1228
                //triangles
1230
1229
                *pIdx++ = _index( i, j + step ); numIndexes++; // original order: 2
1349
1348
 
1350
1349
        // Work out the starting points and sign of increments
1351
1350
        // We always work the strip clockwise
1352
 
        int startx, starty, endx, rowstep;
1353
 
        bool horizontal;
 
1351
        int startx = 0, starty = 0, endx = 0, rowstep = 0;
 
1352
        bool horizontal = false;
1354
1353
        switch(neighbor)
1355
1354
        {
1356
1355
        case NORTH:
1386
1385
            halfsuperstep = -halfsuperstep;
1387
1386
            horizontal = false;
1388
1387
            break;
 
1388
        case HERE:
 
1389
            break;
1389
1390
        };
1390
1391
 
1391
1392
        int numIndexes = 0;