IsoView::IsoView(AGWidget *parent,AGRect r,Pos3D p,AntargisMap *map): AntargisView(parent,r,p,false),MapListener(),mMap(map),mRain(r.w,r.h,0),shallUpdate(false),maxPos(0,0,0) { cdebug("IsoView-Rect:"<<r); inited=false; initTileCache(); }
bool OgreDetourTileCache::configure(InputGeom *inputGeom) { m_geom = inputGeom; // Reuse OgreRecast context for tiled navmesh building m_ctx = m_recast->m_ctx; if (!m_geom || m_geom->isEmpty()) { m_recast->m_pLog->logMessage("ERROR: OgreDetourTileCache::configure: No vertices and triangles."); return false; } if (!m_geom->getChunkyMesh()) { m_recast->m_pLog->logMessage("ERROR: OgreDetourTileCache::configure: Input mesh has no chunkyTriMesh built."); return false; } m_tmproc->init(m_geom); // Init cache bounding box const float* bmin = m_geom->getMeshBoundsMin(); const float* bmax = m_geom->getMeshBoundsMax(); // Navmesh generation params. // Use config from recast module m_cfg = m_recast->m_cfg; // Most params are taken from OgreRecast::configure, except for these: m_cfg.tileSize = m_tileSize; m_cfg.borderSize = (int) (m_cfg.walkableRadius + BORDER_PADDING); // Reserve enough padding. m_cfg.width = m_cfg.tileSize + m_cfg.borderSize*2; m_cfg.height = m_cfg.tileSize + m_cfg.borderSize*2; // Set mesh bounds rcVcopy(m_cfg.bmin, bmin); rcVcopy(m_cfg.bmax, bmax); // Also define navmesh bounds in recast component rcVcopy(m_recast->m_cfg.bmin, bmin); rcVcopy(m_recast->m_cfg.bmax, bmax); // Cell size navmesh generation property is copied from OgreRecast config m_cellSize = m_cfg.cs; // Determine grid size (number of tiles) based on bounding box and grid cell size int gw = 0, gh = 0; rcCalcGridSize(bmin, bmax, m_cellSize, &gw, &gh); // Calculates total size of voxel grid const int ts = m_tileSize; const int tw = (gw + ts-1) / ts; // Tile width const int th = (gh + ts-1) / ts; // Tile height m_tw = tw; m_th = th; Ogre::LogManager::getSingletonPtr()->logMessage("Total Voxels: "+Ogre::StringConverter::toString(gw) + " x " + Ogre::StringConverter::toString(gh)); Ogre::LogManager::getSingletonPtr()->logMessage("Tilesize: "+Ogre::StringConverter::toString(m_tileSize)+" Cellsize: "+Ogre::StringConverter::toString(m_cellSize)); Ogre::LogManager::getSingletonPtr()->logMessage("Tiles: "+Ogre::StringConverter::toString(m_tw)+" x "+Ogre::StringConverter::toString(m_th)); // Max tiles and max polys affect how the tile IDs are caculated. // There are 22 bits available for identifying a tile and a polygon. int tileBits = rcMin((int)dtIlog2(dtNextPow2(tw*th*EXPECTED_LAYERS_PER_TILE)), 14); if (tileBits > 14) tileBits = 14; int polyBits = 22 - tileBits; m_maxTiles = 1 << tileBits; m_maxPolysPerTile = 1 << polyBits; Ogre::LogManager::getSingletonPtr()->logMessage("Max Tiles: " + Ogre::StringConverter::toString(m_maxTiles)); Ogre::LogManager::getSingletonPtr()->logMessage("Max Polys: " + Ogre::StringConverter::toString(m_maxPolysPerTile)); // Tile cache params. memset(&m_tcparams, 0, sizeof(m_tcparams)); rcVcopy(m_tcparams.orig, bmin); m_tcparams.width = m_tileSize; m_tcparams.height = m_tileSize; m_tcparams.maxTiles = tw*th*EXPECTED_LAYERS_PER_TILE; m_tcparams.maxObstacles = MAX_OBSTACLES; // Max number of temp obstacles that can be added to or removed from navmesh // Copy the rest of the parameters from OgreRecast config m_tcparams.cs = m_cfg.cs; m_tcparams.ch = m_cfg.ch; m_tcparams.walkableHeight = (float) m_cfg.walkableHeight; m_tcparams.walkableRadius = (float) m_cfg.walkableRadius; m_tcparams.walkableClimb = (float) m_cfg.walkableClimb; m_tcparams.maxSimplificationError = m_cfg.maxSimplificationError; return initTileCache(); }