本文整理汇总了C++中dtAlloc函数的典型用法代码示例。如果您正苦于以下问题:C++ dtAlloc函数的具体用法?C++ dtAlloc怎么用?C++ dtAlloc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dtAlloc函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: dtAssert
bool dtProximityGrid::init(const int poolSize, const float cellSize)
{
dtAssert(poolSize > 0);
dtAssert(cellSize > 0.0f);
m_cellSize = cellSize;
m_invCellSize = 1.0f / m_cellSize;
// Allocate hashs buckets
m_bucketsSize = dtNextPow2(poolSize);
m_buckets = (unsigned short*)dtAlloc(sizeof(unsigned short)*m_bucketsSize, DT_ALLOC_PERM);
if (!m_buckets)
return false;
// Allocate pool of items.
m_poolSize = poolSize;
m_poolHead = 0;
m_pool = (Item*)dtAlloc(sizeof(Item)*m_poolSize, DT_ALLOC_PERM);
if (!m_pool)
return false;
clear();
return true;
}
开发者ID:DevonJWells,项目名称:recastnavigation,代码行数:25,代码来源:DetourProximityGrid.cpp
示例2: init
bool init(const dtNavMesh* nav)
{
m_ntiles = nav->getMaxTiles();
if (!m_ntiles)
return true;
m_tiles = (TileFlags*)dtAlloc(sizeof(TileFlags)*m_ntiles, DT_ALLOC_TEMP);
if (!m_tiles)
{
return false;
}
memset(m_tiles, 0, sizeof(TileFlags)*m_ntiles);
// Alloc flags for each tile.
for (int i = 0; i < nav->getMaxTiles(); ++i)
{
const dtMeshTile* tile = nav->getTile(i);
if (!tile->header) continue;
TileFlags* tf = &m_tiles[i];
tf->nflags = tile->header->polyCount;
tf->base = nav->getPolyRefBase(tile);
if (tf->nflags)
{
tf->flags = (unsigned char*)dtAlloc(tf->nflags, DT_ALLOC_TEMP);
if (!tf->flags)
return false;
memset(tf->flags, 0, tf->nflags);
}
}
m_nav = nav;
return false;
}
开发者ID:Alex-G,项目名称:MuOnline,代码行数:33,代码来源:OgreRecastNavmeshPruner.cpp
示例3: BotSaveOffMeshConnections
void BotSaveOffMeshConnections( NavData_t *nav )
{
char mapname[ MAX_QPATH ];
char filePath[ MAX_QPATH ];
fileHandle_t f = 0;
Cvar_VariableStringBuffer( "mapname", mapname, sizeof( mapname ) );
Com_sprintf( filePath, sizeof( filePath ), "maps/%s-%s.navcon", mapname, nav->name );
f = FS_FOpenFileWrite( filePath );
if ( !f )
{
return;
}
int conCount = nav->process.con.offMeshConCount;
OffMeshConnectionHeader header;
header.version = LittleLong( NAVMESHCON_VERSION );
header.numConnections = LittleLong( conCount );
FS_Write( &header, sizeof( header ), f );
size_t size = sizeof( float ) * 6 * conCount;
float *verts = ( float * ) dtAlloc( size, DT_ALLOC_TEMP );
memcpy( verts, nav->process.con.verts, size );
SwapArray( verts, conCount * 6 );
FS_Write( verts, size, f );
dtFree( verts );
size = sizeof( float ) * conCount;
float *rad = ( float * ) dtAlloc( size, DT_ALLOC_TEMP );
memcpy( rad, nav->process.con.rad, size );
SwapArray( rad, conCount );
FS_Write( rad, size, f );
dtFree( rad );
size = sizeof( unsigned short ) * conCount;
unsigned short *flags = ( unsigned short * ) dtAlloc( size, DT_ALLOC_TEMP );
memcpy( flags, nav->process.con.flags, size );
SwapArray( flags, conCount );
FS_Write( flags, size, f );
dtFree( flags );
FS_Write( nav->process.con.areas, sizeof( unsigned char ) * conCount, f );
FS_Write( nav->process.con.dirs, sizeof( unsigned char ) * conCount, f );
size = sizeof( unsigned int ) * conCount;
unsigned int *userids = ( unsigned int * ) dtAlloc( size, DT_ALLOC_TEMP );
memcpy( userids, nav->process.con.userids, size );
SwapArray( userids, conCount );
FS_Write( userids, size, f );
dtFree( userids );
FS_FCloseFile( f );
}
开发者ID:Gireen,项目名称:Unvanquished,代码行数:54,代码来源:bot_load.cpp
示例4: memcpy
dtStatus dtTileCache::init(const dtTileCacheParams* params,
dtTileCacheAlloc* talloc,
dtTileCacheCompressor* tcomp,
dtTileCacheMeshProcess* tmproc)
{
m_talloc = talloc;
m_tcomp = tcomp;
m_tmproc = tmproc;
m_nreqs = 0;
memcpy(&m_params, params, sizeof(m_params));
// Alloc space for obstacles.
m_obstacles = (dtTileCacheObstacle*)dtAlloc(sizeof(dtTileCacheObstacle)*m_params.maxObstacles, DT_ALLOC_PERM);
if (!m_obstacles)
return DT_FAILURE | DT_OUT_OF_MEMORY;
memset(m_obstacles, 0, sizeof(dtTileCacheObstacle)*m_params.maxObstacles);
m_nextFreeObstacle = 0;
for (int i = m_params.maxObstacles-1; i >= 0; --i)
{
m_obstacles[i].salt = 1;
m_obstacles[i].next = m_nextFreeObstacle;
m_nextFreeObstacle = &m_obstacles[i];
}
// Init tiles
m_tileLutSize = dtNextPow2(m_params.maxTiles/4);
if (!m_tileLutSize) m_tileLutSize = 1;
m_tileLutMask = m_tileLutSize-1;
m_tiles = (dtCompressedTile*)dtAlloc(sizeof(dtCompressedTile)*m_params.maxTiles, DT_ALLOC_PERM);
if (!m_tiles)
return DT_FAILURE | DT_OUT_OF_MEMORY;
m_posLookup = (dtCompressedTile**)dtAlloc(sizeof(dtCompressedTile*)*m_tileLutSize, DT_ALLOC_PERM);
if (!m_posLookup)
return DT_FAILURE | DT_OUT_OF_MEMORY;
memset(m_tiles, 0, sizeof(dtCompressedTile)*m_params.maxTiles);
memset(m_posLookup, 0, sizeof(dtCompressedTile*)*m_tileLutSize);
m_nextFreeTile = 0;
for (int i = m_params.maxTiles-1; i >= 0; --i)
{
m_tiles[i].salt = 1;
m_tiles[i].next = m_nextFreeTile;
m_nextFreeTile = &m_tiles[i];
}
// Init ID generator values.
m_tileBits = dtIlog2(dtNextPow2((unsigned int)m_params.maxTiles));
// Only allow 31 salt bits, since the salt mask is calculated using 32bit uint and it will overflow.
m_saltBits = dtMin((unsigned int)31, 32 - m_tileBits);
if (m_saltBits < 10)
return DT_FAILURE | DT_INVALID_PARAM;
return DT_SUCCESS;
}
开发者ID:RandomDeveloperM,项目名称:UE4_Hairworks,代码行数:54,代码来源:DetourTileCache.cpp
示例5: m_nodes
dtNodePool::dtNodePool(int maxNodes, int hashSize) :
m_nodes(0),
m_first(0),
m_next(0),
m_maxNodes(maxNodes),
m_hashSize(hashSize),
m_nodeCount(0)
{
m_nodes = (dtNode*)dtAlloc(sizeof(dtNode)*m_maxNodes, DT_ALLOC_PERM);
m_next = (unsigned short*)dtAlloc(sizeof(unsigned short)*m_maxNodes, DT_ALLOC_PERM);
m_first = (unsigned short*)dtAlloc(sizeof(unsigned short)*hashSize, DT_ALLOC_PERM);
memset(m_first, 0xff, sizeof(unsigned short)*m_hashSize);
memset(m_next, 0xff, sizeof(unsigned short)*m_maxNodes);
}
开发者ID:1414648814,项目名称:OpenglESGame,代码行数:15,代码来源:DetourNode.cpp
示例6: dtAllocNavMesh
dtNavMesh* dtAllocNavMesh()
{
void* mem = dtAlloc(sizeof(dtNavMesh), DT_ALLOC_PERM);
if (!mem)
return 0;
return new(mem) dtNavMesh;
}
开发者ID:Baeumchen,项目名称:SkyFireEMU,代码行数:7,代码来源:DetourNavMesh.cpp
示例7: m_heap
dtNodeQueue::dtNodeQueue(int n) :
m_heap(0),
m_capacity(n),
m_size(0)
{
m_heap = (dtNode**)dtAlloc(sizeof(dtNode*)*(m_capacity+1), DT_ALLOC_PERM);
}
开发者ID:1414648814,项目名称:OpenglESGame,代码行数:7,代码来源:DetourNode.cpp
示例8: purge
/// @par
///
/// May be called more than once to purge and re-initialize the crowd.
bool dtCrowd::init(const unsigned maxAgents, const float maxAgentRadius, dtNavMesh* nav)
{
purge();
m_disp = (float**) dtAlloc(sizeof(float*) * maxAgents, DT_ALLOC_PERM);
for (unsigned i = 0; i < maxAgents; ++i)
m_disp[i] = (float*) dtAlloc(sizeof(float) * 3, DT_ALLOC_PERM);
// Creation of the crowd query
void* mem = (dtCrowdQuery*) dtAlloc(sizeof(dtCrowdQuery), DT_ALLOC_PERM);
if (!mem)
return false;
m_agentsEnv = (dtCrowdAgentEnvironment*) dtAlloc(sizeof(dtCrowdAgentEnvironment) * maxAgents, DT_ALLOC_PERM);
if (!m_agentsEnv)
return false;
for (unsigned i = 0; i < maxAgents; ++i)
new(&m_agentsEnv[i]) dtCrowdAgentEnvironment();
m_maxAgents = maxAgents;
m_maxAgentRadius = maxAgentRadius;
m_nbActiveAgents = 0;
m_agentsToUpdate = (unsigned*) dtAlloc(sizeof(int) * maxAgents, DT_ALLOC_PERM);
if (!m_agentsToUpdate)
return false;
for (unsigned i = 0; i < m_maxAgents; ++i)
m_agentsToUpdate[i] = i;
m_agents = (dtCrowdAgent*)dtAlloc(sizeof(dtCrowdAgent) * m_maxAgents, DT_ALLOC_PERM);
if (!m_agents)
return false;
m_crowdQuery = new(mem) dtCrowdQuery(maxAgents, m_agents, m_agentsEnv);
if (dtStatusFailed(m_crowdQuery->getNavMeshQuery()->init(nav, m_maxCommonNodes)))
return false;
m_activeAgents = (dtCrowdAgent**)dtAlloc(sizeof(dtCrowdAgent*) * m_maxAgents, DT_ALLOC_PERM);
if (!m_activeAgents)
return false;
for (unsigned i = 0; i < m_maxAgents; ++i)
{
new(&m_agents[i]) dtCrowdAgent();
m_agents[i].active = 0;
m_agents[i].id = i;
m_agents[i].behavior = 0;
m_agents[i].userData = 0;
}
m_crowdQuery->getQueryExtents()[0] = m_maxAgentRadius * 2.0f;
m_crowdQuery->getQueryExtents()[1] = m_maxAgentRadius * 1.5f;
m_crowdQuery->getQueryExtents()[2] = m_maxAgentRadius * 2.0f;
return true;
}
开发者ID:MrMagne,项目名称:recastdetour,代码行数:63,代码来源:DetourCrowd.cpp
示例9: dtAssert
bool dtObstacleAvoidanceDebugData::init(const int maxSamples)
{
dtAssert(maxSamples);
m_maxSamples = maxSamples;
m_vel = (float*)dtAlloc(sizeof(float)*3*m_maxSamples, DT_ALLOC_PERM);
if (!m_vel)
return false;
m_pen = (float*)dtAlloc(sizeof(float)*m_maxSamples, DT_ALLOC_PERM);
if (!m_pen)
return false;
m_ssize = (float*)dtAlloc(sizeof(float)*m_maxSamples, DT_ALLOC_PERM);
if (!m_ssize)
return false;
m_vpen = (float*)dtAlloc(sizeof(float)*m_maxSamples, DT_ALLOC_PERM);
if (!m_vpen)
return false;
m_vcpen = (float*)dtAlloc(sizeof(float)*m_maxSamples, DT_ALLOC_PERM);
if (!m_vcpen)
return false;
m_spen = (float*)dtAlloc(sizeof(float)*m_maxSamples, DT_ALLOC_PERM);
if (!m_spen)
return false;
m_tpen = (float*)dtAlloc(sizeof(float)*m_maxSamples, DT_ALLOC_PERM);
if (!m_tpen)
return false;
return true;
}
开发者ID:Orav,项目名称:kbengine,代码行数:29,代码来源:DetourObstacleAvoidance.cpp
示例10: memset
bool dtObstacleAvoidanceQuery::init(const int maxCircles, const int maxSegments)
{
m_maxCircles = maxCircles;
m_ncircles = 0;
m_circles = (dtObstacleCircle*)dtAlloc(sizeof(dtObstacleCircle)*m_maxCircles, DT_ALLOC_PERM);
if (!m_circles)
return false;
memset(m_circles, 0, sizeof(dtObstacleCircle)*m_maxCircles);
m_maxSegments = maxSegments;
m_nsegments = 0;
m_segments = (dtObstacleSegment*)dtAlloc(sizeof(dtObstacleSegment)*m_maxSegments, DT_ALLOC_PERM);
if (!m_segments)
return false;
memset(m_segments, 0, sizeof(dtObstacleSegment)*m_maxSegments);
return true;
}
开发者ID:Orav,项目名称:kbengine,代码行数:18,代码来源:DetourObstacleAvoidance.cpp
示例11: dtAlloc
dtCollisionAvoidance* dtCollisionAvoidance::allocate(unsigned nbMaxAgents)
{
void* mem = dtAlloc(sizeof(dtCollisionAvoidance), DT_ALLOC_PERM);
if (mem)
return new(mem) dtCollisionAvoidance(nbMaxAgents);
return 0;
}
开发者ID:LEgregius,项目名称:recastdetour,代码行数:9,代码来源:DetourCollisionAvoidance.cpp
示例12: memcpy
dtStatus dtNavMesh::init(const dtNavMeshParams* params)
{
memcpy(&m_params, params, sizeof(dtNavMeshParams));
dtVcopy(m_orig, params->orig);
m_tileWidth = params->tileWidth;
m_tileHeight = params->tileHeight;
// Init tiles
m_maxTiles = params->maxTiles;
m_tileLutSize = dtNextPow2(params->maxTiles/4);
if (!m_tileLutSize) m_tileLutSize = 1;
m_tileLutMask = m_tileLutSize-1;
m_tiles = (dtMeshTile*)dtAlloc(sizeof(dtMeshTile)*m_maxTiles, DT_ALLOC_PERM);
if (!m_tiles)
return DT_FAILURE | DT_OUT_OF_MEMORY;
m_posLookup = (dtMeshTile**)dtAlloc(sizeof(dtMeshTile*)*m_tileLutSize, DT_ALLOC_PERM);
if (!m_posLookup)
return DT_FAILURE | DT_OUT_OF_MEMORY;
memset(m_tiles, 0, sizeof(dtMeshTile)*m_maxTiles);
memset(m_posLookup, 0, sizeof(dtMeshTile*)*m_tileLutSize);
m_nextFree = 0;
for (int i = m_maxTiles-1; i >= 0; --i)
{
m_tiles[i].salt = 1;
m_tiles[i].next = m_nextFree;
m_nextFree = &m_tiles[i];
}
/*// Init ID generator values.
m_tileBits = dtIlog2(dtNextPow2((unsigned int)params->maxTiles));
m_polyBits = dtIlog2(dtNextPow2((unsigned int)params->maxPolys));
// Only allow 31 salt bits, since the salt mask is calculated using 32bit uint and it will overflow.
m_saltBits = dtMin((unsigned int)31, 32 - m_tileBits - m_polyBits);
if (m_saltBits < 10)
return DT_FAILURE | DT_INVALID_PARAM;*/
// modified for CMaNGOS
m_tileBits = STATIC_TILE_BITS;
m_polyBits = STATIC_POLY_BITS;
m_saltBits = STATIC_SALT_BITS;
return DT_SUCCESS;
}
开发者ID:AnthoDevMoP,项目名称:mangos4,代码行数:44,代码来源:DetourNavMesh.cpp
示例13: dtAssert
/// @par
///
/// @warning Cannot be called more than once.
bool dtPathCorridor::init(const int maxPath)
{
dtAssert(!m_path);
m_path = (dtPolyRef*)dtAlloc(sizeof(dtPolyRef)*maxPath, DT_ALLOC_PERM);
if (!m_path)
return false;
m_npath = 0;
m_maxPath = maxPath;
return true;
}
开发者ID:Unix4ever,项目名称:engine,代码行数:13,代码来源:DetourPathCorridor.cpp
示例14: fopen
dtNavMesh* Sample_TileMesh::loadAll(const char* path)
{
FILE* fp = fopen(path, "rb");
if (!fp) return 0;
// Read header.
NavMeshSetHeader header;
fread(&header, sizeof(NavMeshSetHeader), 1, fp);
if (header.magic != NAVMESHSET_MAGIC)
{
fclose(fp);
return 0;
}
if (header.version != NAVMESHSET_VERSION)
{
fclose(fp);
return 0;
}
dtNavMesh* mesh = dtAllocNavMesh();
if (!mesh)
{
fclose(fp);
return 0;
}
dtStatus status = mesh->init(&header.params);
if (dtStatusFailed(status))
{
fclose(fp);
return 0;
}
// Read tiles.
for (int i = 0; i < header.numTiles; ++i)
{
NavMeshTileHeader tileHeader;
fread(&tileHeader, sizeof(tileHeader), 1, fp);
if (!tileHeader.tileRef || !tileHeader.dataSize)
break;
unsigned char* data = (unsigned char*)dtAlloc(tileHeader.dataSize, DT_ALLOC_PERM);
if (!data) break;
memset(data, 0, tileHeader.dataSize);
fread(data, tileHeader.dataSize, 1, fp);
mesh->addTile(data, tileHeader.dataSize, DT_TILE_FREE_DATA, tileHeader.tileRef, 0);
}
fclose(fp);
return mesh;
}
开发者ID:Bootz,项目名称:WCell,代码行数:52,代码来源:Sample_TileMesh.cpp
示例15: m_nodes
dtNodePool::dtNodePool(int maxNodes, int hashSize) :
m_nodes(0),
m_first(0),
m_next(0),
m_maxNodes(maxNodes),
m_hashSize(hashSize),
m_nodeCount(0)
{
dtAssert(dtNextPow2(m_hashSize) == (unsigned int)m_hashSize);
dtAssert(m_maxNodes > 0);
m_nodes = (dtNode*)dtAlloc(sizeof(dtNode)*m_maxNodes, DT_ALLOC_PERM);
m_next = (dtNodeRef*)dtAlloc(sizeof(dtNodeRef)*m_maxNodes, DT_ALLOC_PERM);
m_first = (dtNodeRef*)dtAlloc(sizeof(dtNodeRef)*hashSize, DT_ALLOC_PERM);
dtAssert(m_nodes);
dtAssert(m_next);
dtAssert(m_first);
memset(m_first, 0xff, sizeof(dtNodeRef)*m_hashSize);
memset(m_next, 0xff, sizeof(dtNodeRef)*m_maxNodes);
}
开发者ID:675492062,项目名称:meshReader,代码行数:22,代码来源:DetourNode.cpp
示例16: resize
void resize(int n)
{
if (n > m_cap)
{
if (!m_cap) m_cap = n;
while (m_cap < n) m_cap *= 2;
dtPolyRef* newData = (dtPolyRef*)dtAlloc(m_cap*sizeof(dtPolyRef), DT_ALLOC_TEMP);
if (m_size && newData) memcpy(newData, m_data, m_size*sizeof(dtPolyRef));
dtFree(m_data);
m_data = newData;
}
m_size = n;
}
开发者ID:Alex-G,项目名称:MuOnline,代码行数:13,代码来源:OgreRecastNavmeshPruner.cpp
示例17: memcpy
dtStatus dtNavMesh::init(const dtNavMeshParams* params)
{
memcpy(&m_params, params, sizeof(dtNavMeshParams));
dtVcopy(m_orig, params->orig);
m_tileWidth = params->tileWidth;
m_tileHeight = params->tileHeight;
// Init tiles
m_maxTiles = params->maxTiles;
m_tileLutSize = dtNextPow2(params->maxTiles/4);
if (!m_tileLutSize) m_tileLutSize = 1;
m_tileLutMask = m_tileLutSize-1;
m_tiles = (dtMeshTile*)dtAlloc(sizeof(dtMeshTile)*m_maxTiles, DT_ALLOC_PERM);
if (!m_tiles)
return DT_FAILURE | DT_OUT_OF_MEMORY;
m_posLookup = (dtMeshTile**)dtAlloc(sizeof(dtMeshTile*)*m_tileLutSize, DT_ALLOC_PERM);
if (!m_posLookup)
return DT_FAILURE | DT_OUT_OF_MEMORY;
memset(m_tiles, 0, sizeof(dtMeshTile)*m_maxTiles);
memset(m_posLookup, 0, sizeof(dtMeshTile*)*m_tileLutSize);
m_nextFree = 0;
for (int i = m_maxTiles-1; i >= 0; --i)
{
m_tiles[i].salt = 1;
m_tiles[i].next = m_nextFree;
m_nextFree = &m_tiles[i];
}
// Init ID generator values.
m_tileBits = STATIC_TILE_BITS; //dtIlog2(dtNextPow2((unsigned int)params->maxTiles));
m_polyBits = STATIC_POLY_BITS; //dtIlog2(dtNextPow2((unsigned int)params->maxPolys));
m_saltBits = STATIC_SALT_BITS; //sizeof(dtPolyRef)*8 - m_tileBits - m_polyBits;
//if (m_saltBits < SALT_MIN_BITS)
//return DT_FAILURE | DT_INVALID_PARAM;
return DT_SUCCESS;
}
开发者ID:Baeumchen,项目名称:SkyFireEMU,代码行数:38,代码来源:DetourNavMesh.cpp
示例18: memcpy
bool dtNavMesh::init(const dtNavMeshParams* params)
{
memcpy(&m_params, params, sizeof(dtNavMeshParams));
dtVcopy(m_orig, params->orig);
m_tileWidth = params->tileWidth;
m_tileHeight = params->tileHeight;
// Init tiles
m_maxTiles = params->maxTiles;
m_tileLutSize = dtNextPow2(params->maxTiles/4);
if (!m_tileLutSize) m_tileLutSize = 1;
m_tileLutMask = m_tileLutSize-1;
m_tiles = (dtMeshTile*)dtAlloc(sizeof(dtMeshTile)*m_maxTiles, DT_ALLOC_PERM);
if (!m_tiles)
return false;
m_posLookup = (dtMeshTile**)dtAlloc(sizeof(dtMeshTile*)*m_tileLutSize, DT_ALLOC_PERM);
if (!m_posLookup)
return false;
memset(m_tiles, 0, sizeof(dtMeshTile)*m_maxTiles);
memset(m_posLookup, 0, sizeof(dtMeshTile*)*m_tileLutSize);
m_nextFree = 0;
for (int i = m_maxTiles-1; i >= 0; --i)
{
m_tiles[i].salt = 1;
m_tiles[i].next = m_nextFree;
m_nextFree = &m_tiles[i];
}
// Init ID generator values.
m_tileBits = dtMax((unsigned int)1, dtIlog2(dtNextPow2((unsigned int)params->maxTiles)));
m_polyBits = dtMax((unsigned int)1, dtIlog2(dtNextPow2((unsigned int)params->maxPolys)));
m_saltBits = 32 - m_tileBits - m_polyBits;
if (m_saltBits < 10)
return false;
return true;
}
开发者ID:Denominator13,项目名称:NeoCore,代码行数:38,代码来源:DetourNavMesh.cpp
示例19: GetNavMesh
void CCollideInterface::LoadNavMeshTile(uint32 mapId, uint32 tileX, uint32 tileY)
{
NavMeshData* nav = GetNavMesh(mapId);
if(nav == NULL)
return;
char filename[1024];
sprintf(filename, "mmaps/%03i%02i%02i.mmtile", mapId, tileX, tileY);
FILE* f = fopen(filename, "rb");
if(f == NULL)
{
//printf("Failed to load: %s\n", filename);
return;
}
MmapTileHeader header;
fread(&header, sizeof(MmapTileHeader), 1, f);
if(header.mmapMagic != MMAP_MAGIC || header.mmapVersion != MMAP_VERSION)
{
sLog.Debug("NavMesh", "Load failed (%u %u %u): tile headers incorrect", mapId, tileX, tileY);
//printf("Load failed (%u %u %u): tile headers incorrect\n", mapId, tileX, tileY);
fclose(f);
return;
}
uint8* data = (uint8*)dtAlloc(header.size, DT_ALLOC_PERM);
if(data == NULL)
{
//printf("Load failed (%u %u %u): data incorrect\n", mapId, tileX, tileY);
fclose(f);
return;
}
fread(data, 1, header.size, f);
fclose(f);
dtTileRef dtref;
nav->mesh->addTile(data, header.size, DT_TILE_FREE_DATA, 0, &dtref);
nav->tilelock.Acquire();
nav->tilerefs.insert(std::make_pair(tileX | (tileY << 16), dtref));
nav->tilelock.Release();
}
开发者ID:Desch,项目名称:Edge-of-Chaos,代码行数:49,代码来源:CollideInterface.cpp
示例20: purge
bool dtCollisionAvoidance::init(unsigned maxCircles, unsigned maxSegments)
{
purge();
m_maxCircles = maxCircles;
m_ncircles = 0;
m_circles = (dtObstacleCircle*)dtAlloc(sizeof(dtObstacleCircle)*m_maxCircles, DT_ALLOC_PERM);
if (!m_circles)
return false;
memset(m_circles, 0, sizeof(dtObstacleCircle)*m_maxCircles);
m_maxSegments = maxSegments;
m_nsegments = 0;
m_segments = (dtObstacleSegment*)dtAlloc(sizeof(dtObstacleSegment)*m_maxSegments, DT_ALLOC_PERM);
if (!m_segments)
return false;
memset(m_segments, 0, sizeof(dtObstacleSegment)*m_maxSegments);
return true;
}
开发者ID:LEgregius,项目名称:recastdetour,代码行数:24,代码来源:DetourCollisionAvoidance.cpp
注:本文中的dtAlloc函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论