Index: /OpenSceneGraph/trunk/src/osgPlugins/txp/ReaderWriterTXP.cpp
===================================================================
--- /OpenSceneGraph/trunk/src/osgPlugins/txp/ReaderWriterTXP.cpp (revision 10415)
+++ /OpenSceneGraph/trunk/src/osgPlugins/txp/ReaderWriterTXP.cpp (revision 11036)
@@ -52,5 +52,5 @@
             txpNode->setOptions(options->getOptionString());
         }
-        
+
 
         //modified by Brad Anderegg on May-27-08
@@ -120,23 +120,22 @@
         if(majorVersion ==2 && minorVersion >=1)
         {
-        // Version 2.1 and over
-        // The tile table only contains lod 0 and the children
-        // info are stored in its parent. SO if we do not want
-        // to be forced to reparse the parent we need to save that
-        // info. For now we just add it to the node name
-
-        if(childrenLoc.size() > 0)
-        {
-        asChildren = true;
-        createChildrenLocationString(childrenLoc, childrenInfoStr);
-        }
+            // Version 2.1 and over
+            // The tile table only contains lod 0 and the children
+            // info are stored in its parent. SO if we do not want
+            // to be forced to reparse the parent we need to save that
+            // info. For now we just add it to the node name
+
+            if(childrenLoc.size() > 0)
+            {
+                asChildren = true;
+                createChildrenLocationString(childrenLoc, childrenInfoStr);
+            }
         }
         else
         {
-        if (lod < (numLods-1))
-        asChildren = true;
-        }
-
-    if (asChildren)
+            if (lod < (numLods-1)) asChildren = true;
+        }
+
+        if (asChildren)
         {
             char pagedLODfile[1024];
@@ -219,22 +218,22 @@
             bool status = true;
             status = extractChildrenLocations(name, lod, locs, nbChild);
-        if(majorVersion >= TRPG_NOMERGE_VERSION_MAJOR && minorVersion >=TRPG_NOMERGE_VERSION_MINOR && archive->GetHeader()->GetIsMaster())
-        {
-        for(int idx=0;idx<nbChild;idx++)
-        {
-            //figure out the block row/col
-            int blockx,blocky;
-            unsigned int denom = (1 << locs[idx].lod); // this should work up to lod 31
-            blockx = locs[idx].x/denom;
-            blocky = locs[idx].y/denom;
-            locs[idx].addr.col = blockx;
-            locs[idx].addr.row = blocky;
-        }
-        }
+            if(majorVersion >= TRPG_NOMERGE_VERSION_MAJOR && minorVersion >=TRPG_NOMERGE_VERSION_MINOR && archive->GetHeader()->GetIsMaster())
+            {
+                for(int idx=0;idx<nbChild;idx++)
+                {
+                    //figure out the block row/col
+                    int blockx,blocky;
+                    unsigned int denom = (1 << locs[idx].lod); // this should work up to lod 31
+                    blockx = locs[idx].x/denom;
+                    blocky = locs[idx].y/denom;
+                    locs[idx].addr.col = blockx;
+                    locs[idx].addr.row = blocky;
+                }
+            }
 
             if(!status)
             {
-        ReaderWriterTXPERROR("ReaderWriterTXP::local_readNode()") << "'subtile' filename children parsing failed " << std::endl;
-        return ReadResult::ERROR_IN_READING_FILE;
+                ReaderWriterTXPERROR("ReaderWriterTXP::local_readNode()") << "'subtile' filename children parsing failed " << std::endl;
+                return ReadResult::ERROR_IN_READING_FILE;
             }
 
@@ -243,8 +242,8 @@
             header->GetTileOriginType(tileType);
 
-        TXPArchive::TileLocationInfo plInfo;
-        plInfo.x = x;
-        plInfo.y = y;
-        plInfo.lod = lod;
+            TXPArchive::TileLocationInfo plInfo;
+            plInfo.x = x;
+            plInfo.y = y;
+            plInfo.lod = lod;
             TXPArchive::TileInfo parentInfo;
             archive->getTileInfo(plInfo,parentInfo);
@@ -252,29 +251,29 @@
             for(int idx = 0; idx < nbChild; ++idx)
             {
-        std::vector<TXPArchive::TileLocationInfo> childrenChildLoc;
-               
-        TXPArchive::TileLocationInfo& loc = locs[idx];
-               
-        TXPArchive::TileInfo info;
-        if (!archive->getTileInfo(loc,info))
-            continue;
-
-        osg::ref_ptr<osg::Node> tileContent = getTileContent(info, loc, archive, childrenChildLoc);
-
-        tileContent->setName("TileContent");
-
-        if(childrenChildLoc.size() > 0)
-        {
-            std::string childInfoStr;
-            createChildrenLocationString(childrenChildLoc, childInfoStr);
-
-            char pagedLODfile[1024];
-            sprintf(pagedLODfile,"%s\\subtiles%d_%dx%d_%d%s.txp",
-                archive->getDir(),
-                loc.lod,
-                loc.x,
-                loc.y,
-                archive->getId(),
-                childInfoStr.c_str());
+                std::vector<TXPArchive::TileLocationInfo> childrenChildLoc;
+
+                TXPArchive::TileLocationInfo& loc = locs[idx];
+
+                TXPArchive::TileInfo info;
+                if (!archive->getTileInfo(loc,info))
+                    continue;
+
+                osg::ref_ptr<osg::Node> tileContent = getTileContent(info, loc, archive, childrenChildLoc);
+
+                tileContent->setName("TileContent");
+
+                if(childrenChildLoc.size() > 0)
+                {
+                    std::string childInfoStr;
+                    createChildrenLocationString(childrenChildLoc, childInfoStr);
+
+                    char pagedLODfile[1024];
+                    sprintf(pagedLODfile,"%s\\subtiles%d_%dx%d_%d%s.txp",
+                        archive->getDir(),
+                        loc.lod,
+                        loc.x,
+                        loc.y,
+                        archive->getId(),
+                        childInfoStr.c_str());
 
                     // there are tile sets which do not maintain the z extents in
@@ -290,149 +289,149 @@
                     }
 
-            osg::ref_ptr<TXPPagedLOD> pagedLOD = new TXPPagedLOD;
-                    // note: use maximum(info.maxRange,1e7) as just maxRange would result in some corner tiles from being culled out.
-            pagedLOD->addChild(tileContent.get(),info.minRange,osg::maximum(info.maxRange,1e7));
-            pagedLOD->setFileName(1,pagedLODfile);
-            pagedLOD->setRange(1,0,info.minRange);
-            pagedLOD->setCenter(info.center);
-            pagedLOD->setRadius(info.radius);
-            pagedLOD->setPriorityOffset(0,numLods - loc.lod);
-            pagedLOD->setPriorityScale(0,1.0f);
-            pagedLOD->setNumChildrenThatCannotBeExpired(1);
-            pagedLOD->setTileId(loc.x, loc.y, loc.lod);
-
-            if(tileType == trpgHeader::TileLocal)
-            {
-            osg::Vec3d center(info.center - parentInfo.bbox._min);
-            osg::Vec3d sw(info.bbox._min - parentInfo.bbox._min);
-            sw[2] = 0.0;
-            pagedLOD->setCenter(center - sw);
-            osg::Matrix offset;
-            offset.setTrans(sw);
-            osg::MatrixTransform *tform = new osg::MatrixTransform(offset);
-            tform->addChild(pagedLOD.get());
-            subtiles->addChild(tform);
-            }
-            else
-            subtiles->addChild(pagedLOD.get());
-            subtiles->setUserData(new TileIdentifier(loc.x, loc.y, loc.lod)); // is this really needed?
+                    osg::ref_ptr<TXPPagedLOD> pagedLOD = new TXPPagedLOD;
+                            // note: use maximum(info.maxRange,1e7) as just maxRange would result in some corner tiles from being culled out.
+                    pagedLOD->addChild(tileContent.get(),info.minRange,osg::maximum(info.maxRange,1e7));
+                    pagedLOD->setFileName(1,pagedLODfile);
+                    pagedLOD->setRange(1,0,info.minRange);
+                    pagedLOD->setCenter(info.center);
+                    pagedLOD->setRadius(info.radius);
+                    pagedLOD->setPriorityOffset(0,numLods - loc.lod);
+                    pagedLOD->setPriorityScale(0,1.0f);
+                    pagedLOD->setNumChildrenThatCannotBeExpired(1);
+                    pagedLOD->setTileId(loc.x, loc.y, loc.lod);
+
+                    if(tileType == trpgHeader::TileLocal)
+                    {
+                        osg::Vec3d center(info.center - parentInfo.bbox._min);
+                        osg::Vec3d sw(info.bbox._min - parentInfo.bbox._min);
+                        sw[2] = 0.0;
+                        pagedLOD->setCenter(center - sw);
+                        osg::Matrix offset;
+                        offset.setTrans(sw);
+                        osg::MatrixTransform *tform = new osg::MatrixTransform(offset);
+                        tform->addChild(pagedLOD.get());
+                        subtiles->addChild(tform);
+                    }
+                    else
+                        subtiles->addChild(pagedLOD.get());
+                        subtiles->setUserData(new TileIdentifier(loc.x, loc.y, loc.lod)); // is this really needed?
+                }
+                else
+                {
+                    subtiles->setUserData(new TileIdentifier(loc.x, loc.y, loc.lod));
+                    if(tileType == trpgHeader::TileLocal)
+                    {
+                        osg::Vec3d center(info.center - parentInfo.bbox._min);
+                        osg::Vec3d sw(info.bbox._min - parentInfo.bbox._min);
+                        sw[2] = 0.0;
+                        osg::Matrix offset;
+                        offset.setTrans(sw);
+                        osg::MatrixTransform *tform = new osg::MatrixTransform(offset);
+                        tform->addChild(tileContent.get());
+                        subtiles->addChild(tform);
+                    }
+                    else
+                        subtiles->addChild(tileContent.get());
+                }
+            }
         }
         else
         {
-            subtiles->setUserData(new TileIdentifier(loc.x, loc.y, loc.lod));
-            if(tileType == trpgHeader::TileLocal)
-            {
-            osg::Vec3d center(info.center - parentInfo.bbox._min);
-            osg::Vec3d sw(info.bbox._min - parentInfo.bbox._min);
-            sw[2] = 0.0;
-            osg::Matrix offset;
-            offset.setTrans(sw);
-            osg::MatrixTransform *tform = new osg::MatrixTransform(offset);
-            tform->addChild(tileContent.get());
-            subtiles->addChild(tform);
-            }
-            else
-            subtiles->addChild(tileContent.get());
-        }
-            }
-        }
-        else
-        {
-            
-        int sizeX, sizeY;
-        archive->getLODSize(lod+1,sizeX,sizeY);
-
-        const trpgHeader* header = archive->GetHeader();
-        trpgHeader::trpgTileType tileType;
-        header->GetTileOriginType(tileType);
-
-        TXPArchive::TileInfo parentInfo;
-        archive->getTileInfo(x,y,lod,parentInfo);
-
-        for (int ix = 0; ix < 2; ix++)
-        {
-        for (int iy = 0; iy < 2; iy++)
-        {
-            int tileX = x*2+ix;
-            int tileY = y*2+iy;
-            int tileLOD = lod+1;
-
-            TXPArchive::TileInfo info;
-            if (!archive->getTileInfo(tileX,tileY,tileLOD,info))
-            continue;
-
-            osg::ref_ptr<osg::Node> tileContent = getTileContent(info,tileX,tileY,tileLOD,archive, childrenLoc);
-
-            tileContent->setName("TileContent");
-
-            if (tileLOD < (numLods-1))
-            {
-            char pagedLODfile[1024];
-            sprintf(pagedLODfile,"%s\\subtiles%d_%dx%d_%d.txp",
-                archive->getDir(),
-                tileLOD,
-                tileX,
-                tileY,
-                archive->getId());
-
-            // there are tile sets which do not maintain the z extents in
-            // the tile table.  This attempt to address the issue by using
-            // the geometry bounding sphere.  The downside is that this is
-            // not coupled to the generation and may result in runtime cracks
-            if (info.center.z() == 0)
-            {
-                osg::BoundingSphere bSphere = tileContent->getBound();
-
-                info.center.z() = bSphere.center().z();
-                info.radius = bSphere.radius();
-            }
-
-            osg::ref_ptr<TXPPagedLOD> pagedLOD = new TXPPagedLOD;
-                        // note: use maximum(info.maxRange,1e7) as just maxRange would result in some corner tiles from being culled out.
-            pagedLOD->addChild(tileContent.get(),info.minRange,osg::maximum(info.maxRange,1e7));
-            pagedLOD->setFileName(1,pagedLODfile);
-            pagedLOD->setRange(1,0,info.minRange);
-            pagedLOD->setCenter(info.center);
-            pagedLOD->setRadius(info.radius);
-            pagedLOD->setPriorityOffset(0,numLods-lod);
-            pagedLOD->setPriorityScale(0,1.0f);
-            pagedLOD->setNumChildrenThatCannotBeExpired(1);
-            pagedLOD->setTileId(tileX,tileY,tileLOD);
-
-            if(tileType == trpgHeader::TileLocal)
-            {
-                osg::Vec3d center(info.center - parentInfo.bbox._min);
-                osg::Vec3d sw(info.bbox._min - parentInfo.bbox._min);
-                sw[2] = 0.0;
-                pagedLOD->setCenter(center - sw);
-                osg::Matrix offset;
-                offset.setTrans(sw);
-                osg::MatrixTransform *tform = new osg::MatrixTransform(offset);
-                tform->addChild(pagedLOD.get());
-                subtiles->addChild(tform);
-            }
-            else
-                subtiles->addChild(pagedLOD.get());
-            }
-            else
-            {
-            subtiles->setUserData(new TileIdentifier(tileX,tileY,tileLOD));
-            if(tileType == trpgHeader::TileLocal)
-            {
-                osg::Vec3d center(info.center - parentInfo.bbox._min);
-                osg::Vec3d sw(info.bbox._min - parentInfo.bbox._min);
-                sw[2] = 0.0;
-                osg::Matrix offset;
-                offset.setTrans(sw);
-                osg::MatrixTransform *tform = new osg::MatrixTransform(offset);
-                tform->addChild(tileContent.get());
-                subtiles->addChild(tform);
-            }
-            else
-                subtiles->addChild(tileContent.get());
-            }
-
-        }
-        }
+
+            int sizeX, sizeY;
+            archive->getLODSize(lod+1,sizeX,sizeY);
+
+            const trpgHeader* header = archive->GetHeader();
+            trpgHeader::trpgTileType tileType;
+            header->GetTileOriginType(tileType);
+
+            TXPArchive::TileInfo parentInfo;
+            archive->getTileInfo(x,y,lod,parentInfo);
+
+            for (int ix = 0; ix < 2; ix++)
+            {
+                for (int iy = 0; iy < 2; iy++)
+                {
+                    int tileX = x*2+ix;
+                    int tileY = y*2+iy;
+                    int tileLOD = lod+1;
+
+                    TXPArchive::TileInfo info;
+                    if (!archive->getTileInfo(tileX,tileY,tileLOD,info))
+                    continue;
+
+                    osg::ref_ptr<osg::Node> tileContent = getTileContent(info,tileX,tileY,tileLOD,archive, childrenLoc);
+
+                    tileContent->setName("TileContent");
+
+                    if (tileLOD < (numLods-1))
+                    {
+                        char pagedLODfile[1024];
+                        sprintf(pagedLODfile,"%s\\subtiles%d_%dx%d_%d.txp",
+                            archive->getDir(),
+                            tileLOD,
+                            tileX,
+                            tileY,
+                            archive->getId());
+
+                        // there are tile sets which do not maintain the z extents in
+                        // the tile table.  This attempt to address the issue by using
+                        // the geometry bounding sphere.  The downside is that this is
+                        // not coupled to the generation and may result in runtime cracks
+                        if (info.center.z() == 0)
+                        {
+                            osg::BoundingSphere bSphere = tileContent->getBound();
+
+                            info.center.z() = bSphere.center().z();
+                            info.radius = bSphere.radius();
+                        }
+
+                        osg::ref_ptr<TXPPagedLOD> pagedLOD = new TXPPagedLOD;
+                                    // note: use maximum(info.maxRange,1e7) as just maxRange would result in some corner tiles from being culled out.
+                        pagedLOD->addChild(tileContent.get(),info.minRange,osg::maximum(info.maxRange,1e7));
+                        pagedLOD->setFileName(1,pagedLODfile);
+                        pagedLOD->setRange(1,0,info.minRange);
+                        pagedLOD->setCenter(info.center);
+                        pagedLOD->setRadius(info.radius);
+                        pagedLOD->setPriorityOffset(0,numLods-lod);
+                        pagedLOD->setPriorityScale(0,1.0f);
+                        pagedLOD->setNumChildrenThatCannotBeExpired(1);
+                        pagedLOD->setTileId(tileX,tileY,tileLOD);
+
+                        if(tileType == trpgHeader::TileLocal)
+                        {
+                            osg::Vec3d center(info.center - parentInfo.bbox._min);
+                            osg::Vec3d sw(info.bbox._min - parentInfo.bbox._min);
+                            sw[2] = 0.0;
+                            pagedLOD->setCenter(center - sw);
+                            osg::Matrix offset;
+                            offset.setTrans(sw);
+                            osg::MatrixTransform *tform = new osg::MatrixTransform(offset);
+                            tform->addChild(pagedLOD.get());
+                            subtiles->addChild(tform);
+                        }
+                        else
+                            subtiles->addChild(pagedLOD.get());
+                    }
+                    else
+                    {
+                        subtiles->setUserData(new TileIdentifier(tileX,tileY,tileLOD));
+                        if(tileType == trpgHeader::TileLocal)
+                        {
+                            osg::Vec3d center(info.center - parentInfo.bbox._min);
+                            osg::Vec3d sw(info.bbox._min - parentInfo.bbox._min);
+                            sw[2] = 0.0;
+                            osg::Matrix offset;
+                            offset.setTrans(sw);
+                            osg::MatrixTransform *tform = new osg::MatrixTransform(offset);
+                            tform->addChild(tileContent.get());
+                            subtiles->addChild(tform);
+                        }
+                        else
+                            subtiles->addChild(tileContent.get());
+                    }
+
+                }
+            }
         }
 
