本文整理汇总了C++中rcFreeHeightField函数的典型用法代码示例。如果您正苦于以下问题:C++ rcFreeHeightField函数的具体用法?C++ rcFreeHeightField怎么用?C++ rcFreeHeightField使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rcFreeHeightField函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: rcFreeHeightField
/**
* Cleanup recast stuff, not debug manualobjects.
**/
void OgreRecast::RecastCleanup()
{
if(m_triareas) delete [] m_triareas;
m_triareas = 0;
rcFreeHeightField(m_solid);
m_solid = 0;
rcFreeCompactHeightfield(m_chf);
m_chf = 0;
rcFreeContourSet(m_cset);
m_cset = 0;
rcFreePolyMesh(m_pmesh);
m_pmesh = 0;
rcFreePolyMeshDetail(m_dmesh);
m_dmesh = 0;
dtFreeNavMesh(m_navMesh);
m_navMesh = 0;
dtFreeNavMeshQuery(m_navQuery);
m_navQuery = 0 ;
if(m_ctx){
delete m_ctx;
m_ctx = 0;
}
}
开发者ID:arrian,项目名称:3d-engine,代码行数:29,代码来源:OgreRecast.cpp
示例2: rcFreeHeightField
void RecastInterface::recastClean()
{
if(_triangleAreas)
{
delete[] _triangleAreas;
_triangleAreas = nullptr;
}
rcFreeHeightField(_solid);
_solid = nullptr;
rcFreeCompactHeightfield(_compactHeightfield);
_compactHeightfield = nullptr;
rcFreeContourSet(_contourSet);
_contourSet = nullptr;
rcFreePolyMesh(_polyMesh);
_polyMesh = nullptr;
rcFreePolyMeshDetail(_detailMesh);
_detailMesh = nullptr;
if(_context)
{
delete _context;
_context = nullptr;
}
}
开发者ID:Dar13,项目名称:WastelandArchive,代码行数:29,代码来源:RecastInterface.cpp
示例3: rcFreeCompactHeightfield
IntermediateValues::~IntermediateValues()
{
rcFreeCompactHeightfield(compactHeightfield);
rcFreeHeightField(heightfield);
rcFreeContourSet(contours);
rcFreePolyMesh(polyMesh);
rcFreePolyMeshDetail(polyMeshDetail);
}
开发者ID:P-Kito,项目名称:InfinityCore,代码行数:8,代码来源:IntermediateValues.cpp
示例4: delete
NavBuildData::~NavBuildData()
{
delete(ctx_);
ctx_ = nullptr;
rcFreeHeightField(heightField_);
heightField_ = nullptr;
rcFreeCompactHeightfield(compactHeightField_);
compactHeightField_ = nullptr;
}
开发者ID:1vanK,项目名称:Urho3D,代码行数:9,代码来源:NavBuildData.cpp
示例5: rcFreeHeightField
void RecastTileBuilder::cleanup() {
delete[] m_triareas;
m_triareas = 0;
rcFreeHeightField(m_solid);
m_solid = 0;
rcFreeCompactHeightfield(m_chf);
m_chf = 0;
rcFreeContourSet(m_cset);
m_cset = 0;
rcFreePolyMesh(m_pmesh);
m_pmesh = 0;
rcFreePolyMeshDetail(m_dmesh);
m_dmesh = 0;
}
开发者ID:ModTheGalaxy,项目名称:mtgserver,代码行数:14,代码来源:RecastTileBuilder.cpp
示例6: rcFreeHeightField
void NavMeshGenerator::cleanup()
{
rcFreeHeightField(m_solid);
m_solid = 0;
rcFreeCompactHeightfield(m_chf);
m_chf = 0;
rcFreeContourSet(m_cset);
m_cset = 0;
rcFreePolyMesh(m_pmesh);
m_pmesh = 0;
rcFreePolyMeshDetail(m_dmesh);
m_dmesh = 0;
dtFreeNavMesh(m_navMesh);
m_navMesh = 0;
}
开发者ID:vincent-grosbois,项目名称:sfml_test,代码行数:15,代码来源:NavMeshGenerator.cpp
示例7: rcFreeHeightField
void Sample_TileMesh::cleanup()
{
delete [] m_triareaMasks;
m_triareaMasks = 0;
rcFreeHeightField(m_solid);
m_solid = 0;
rcFreeCompactHeightfield(m_chf);
m_chf = 0;
rcFreeContourSet(m_cset);
m_cset = 0;
rcFreePolyMesh(m_pmesh);
m_pmesh = 0;
rcFreePolyMeshDetail(m_dmesh);
m_dmesh = 0;
}
开发者ID:jswigart,项目名称:recastnavigation,代码行数:15,代码来源:Sample_TileMesh.cpp
示例8: rcFreeHeightField
void Sample_SoloMeshSimple::cleanup()
{
delete [] m_triareas;
m_triareas = 0;
rcFreeHeightField(m_solid);
m_solid = 0;
rcFreeCompactHeightfield(m_chf);
m_chf = 0;
rcFreeContourSet(m_cset);
m_cset = 0;
rcFreePolyMesh(m_pmesh);
m_pmesh = 0;
rcFreePolyMeshDetail(m_dmesh);
m_dmesh = 0;
dtFreeNavMesh(m_navMesh);
m_navMesh = 0;
}
开发者ID:wtfcolt,项目名称:MadMangos,代码行数:17,代码来源:Sample_SoloMeshSimple.cpp
示例9: rcFreeContourSet
void NavMeshCreator::freeIntermediateResults()
{
rcFreeContourSet(m_intermediateContourSet);
m_intermediateContourSet = 0;
rcFreePolyMesh(m_intermediatePolyMesh);
m_intermediatePolyMesh = 0;
rcFreeHeightField(m_intermediateHeightfield);
m_intermediateHeightfield = 0;
rcFreeCompactHeightfield(m_intermediateCompactHeightfield);
m_intermediateCompactHeightfield = 0;
rcFreePolyMeshDetail(m_intermediatePolyMeshDetail);
m_intermediatePolyMeshDetail = 0;
}
开发者ID:Conglang,项目名称:recastdetour,代码行数:17,代码来源:NavMeshCreator.cpp
示例10: rcFreeHeightField
void NavMesh::freeIntermediates(bool freeAll)
{
mNavMeshLock.lock();
rcFreeHeightField(hf); hf = NULL;
rcFreeCompactHeightfield(chf); chf = NULL;
if(!mSaveIntermediates || freeAll)
{
rcFreeContourSet(cs); cs = NULL;
rcFreePolyMesh(pm); pm = NULL;
rcFreePolyMeshDetail(pmd); pmd = NULL;
delete mInPolys;
mInPolys = NULL;
}
mNavMeshLock.unlock();
}
开发者ID:belzilep,项目名称:Torque3D,代码行数:18,代码来源:navMesh.cpp
示例11: rcVcopy
uint8* TileBuilder::BuildInstance( dtNavMeshParams& navMeshParams )
{
float* bmin = NULL, *bmax = NULL;
_Geometry->CalculateBoundingBox(bmin, bmax);
rcVcopy(InstanceConfig.bmax, bmax);
rcVcopy(InstanceConfig.bmin, bmin);
uint32 numVerts = _Geometry->Vertices.size();
uint32 numTris = _Geometry->Triangles.size();
float* vertices;
int* triangles;
uint8* areas;
_Geometry->GetRawData(vertices, triangles, areas);
// this sets the dimensions of the heightfield
rcCalcGridSize(InstanceConfig.bmin, InstanceConfig.bmax, InstanceConfig.cs, &InstanceConfig.width, &InstanceConfig.height);
rcHeightfield* hf = rcAllocHeightfield();
rcCreateHeightfield(Context, *hf, InstanceConfig.width, InstanceConfig.height, InstanceConfig.bmin, InstanceConfig.bmax, InstanceConfig.cs, InstanceConfig.ch);
rcClearUnwalkableTriangles(Context, InstanceConfig.walkableSlopeAngle, vertices, numVerts, triangles, numTris, areas);
rcRasterizeTriangles(Context, vertices, numVerts, triangles, areas, numTris, *hf, InstanceConfig.walkableClimb);
rcFilterLowHangingWalkableObstacles(Context, InstanceConfig.walkableClimb, *hf);
rcFilterLedgeSpans(Context, InstanceConfig.walkableHeight, InstanceConfig.walkableClimb, *hf);
rcFilterWalkableLowHeightSpans(Context, InstanceConfig.walkableHeight, *hf);
rcCompactHeightfield* chf = rcAllocCompactHeightfield();
rcBuildCompactHeightfield(Context, InstanceConfig.walkableHeight, InstanceConfig.walkableClimb, *hf, *chf);
rcErodeWalkableArea(Context, InstanceConfig.walkableRadius, *chf);
rcBuildDistanceField(Context, *chf);
rcBuildRegions(Context, *chf, InstanceConfig.borderSize, InstanceConfig.minRegionArea, InstanceConfig.minRegionArea);
rcContourSet* contours = rcAllocContourSet();
rcBuildContours(Context, *chf, InstanceConfig.maxSimplificationError, InstanceConfig.maxEdgeLen, *contours);
rcPolyMesh* pmesh = rcAllocPolyMesh();
rcBuildPolyMesh(Context, *contours, InstanceConfig.maxVertsPerPoly, *pmesh);
rcPolyMeshDetail* dmesh = rcAllocPolyMeshDetail();
rcBuildPolyMeshDetail(Context, *pmesh, *chf, InstanceConfig.detailSampleDist, InstanceConfig.detailSampleMaxError, *dmesh);
// Set flags according to area types (e.g. Swim for Water)
for (int i = 0; i < pmesh->npolys; i++)
{
if (pmesh->areas[i] == Constants::POLY_AREA_ROAD || pmesh->areas[i] == Constants::POLY_AREA_TERRAIN)
pmesh->flags[i] = Constants::POLY_FLAG_WALK;
else if (pmesh->areas[i] == Constants::POLY_AREA_WATER)
pmesh->flags[i] = Constants::POLY_FLAG_SWIM;
}
dtNavMeshCreateParams params;
memset(¶ms, 0, sizeof(params));
// PolyMesh data
params.verts = pmesh->verts;
params.vertCount = pmesh->nverts;
params.polys = pmesh->polys;
params.polyAreas = pmesh->areas;
params.polyFlags = pmesh->flags;
params.polyCount = pmesh->npolys;
params.nvp = pmesh->nvp;
// PolyMeshDetail data
params.detailMeshes = dmesh->meshes;
params.detailVerts = dmesh->verts;
params.detailVertsCount = dmesh->nverts;
params.detailTris = dmesh->tris;
params.detailTriCount = dmesh->ntris;
rcVcopy(params.bmin, pmesh->bmin);
rcVcopy(params.bmax, pmesh->bmax);
// General settings
params.ch = InstanceConfig.ch;
params.cs = InstanceConfig.cs;
params.walkableClimb = InstanceConfig.walkableClimb * InstanceConfig.ch;
params.walkableHeight = InstanceConfig.walkableHeight * InstanceConfig.ch;
params.walkableRadius = InstanceConfig.walkableRadius * InstanceConfig.cs;
params.tileX = X;
params.tileY = Y;
params.tileLayer = 0;
params.buildBvTree = true;
rcVcopy(params.bmax, bmax);
rcVcopy(params.bmin, bmin);
// Offmesh-connection settings
params.offMeshConCount = 0; // none for now
rcFreeHeightField(hf);
rcFreeCompactHeightfield(chf);
rcFreeContourSet(contours);
delete vertices;
delete triangles;
delete areas;
delete bmin;
delete bmax;
if (!params.polyCount || !params.polys || Constants::TilesPerMap * Constants::TilesPerMap == params.polyCount)
{
//.........这里部分代码省略.........
开发者ID:Exodius,项目名称:DeathCore,代码行数:101,代码来源:TileBuilder.cpp
示例12: Geometry
//.........这里部分代码省略.........
rcBuildCompactHeightfield(Context, Config.walkableHeight, Config.walkableClimb, *hf, *chf);
rcErodeWalkableArea(Context, Config.walkableRadius, *chf);
rcBuildDistanceField(Context, *chf);
rcBuildRegions(Context, *chf, Config.borderSize, Config.minRegionArea, Config.mergeRegionArea);
rcContourSet* contours = rcAllocContourSet();
rcBuildContours(Context, *chf, Config.maxSimplificationError, Config.maxEdgeLen, *contours);
rcPolyMesh* pmesh = rcAllocPolyMesh();
rcBuildPolyMesh(Context, *contours, Config.maxVertsPerPoly, *pmesh);
rcPolyMeshDetail* dmesh = rcAllocPolyMeshDetail();
rcBuildPolyMeshDetail(Context, *pmesh, *chf, Config.detailSampleDist, Config.detailSampleMaxError, *dmesh);
// Set flags according to area types (e.g. Swim for Water)
for (int i = 0; i < pmesh->npolys; i++)
{
if (pmesh->areas[i] == Constants::POLY_AREA_ROAD || pmesh->areas[i] == Constants::POLY_AREA_TERRAIN)
pmesh->flags[i] = Constants::POLY_FLAG_WALK;
else if (pmesh->areas[i] == Constants::POLY_AREA_WATER)
pmesh->flags[i] = Constants::POLY_FLAG_SWIM;
}
dtNavMeshCreateParams params;
memset(¶ms, 0, sizeof(params));
// PolyMesh data
params.verts = pmesh->verts;
params.vertCount = pmesh->nverts;
params.polys = pmesh->polys;
params.polyAreas = pmesh->areas;
params.polyFlags = pmesh->flags;
params.polyCount = pmesh->npolys;
params.nvp = pmesh->nvp;
// PolyMeshDetail data
params.detailMeshes = dmesh->meshes;
params.detailVerts = dmesh->verts;
params.detailVertsCount = dmesh->nverts;
params.detailTris = dmesh->tris;
params.detailTriCount = dmesh->ntris;
// General settings
params.ch = Config.ch;
params.cs = Config.cs;
params.walkableClimb = Config.walkableClimb * Config.ch;
params.walkableHeight = Config.walkableHeight * Config.ch;
params.walkableRadius = Config.walkableRadius * Config.cs;
params.tileX = X;
params.tileY = Y;
params.tileLayer = 0;
params.buildBvTree = true;
// Recalculate the bounds with the added geometry
float* bmin2 = NULL, *bmax2 = NULL;
CalculateTileBounds(bmin2, bmax2, navMeshParams);
bmin2[1] = bmin[1];
bmax2[1] = bmax[1];
rcVcopy(params.bmax, bmax2);
rcVcopy(params.bmin, bmin2);
// Offmesh-connection settings
params.offMeshConCount = 0; // none for now
rcFreeHeightField(hf);
rcFreeCompactHeightfield(chf);
rcFreeContourSet(contours);
delete vertices;
delete triangles;
delete areas;
delete bmin;
delete bmax;
if (!params.polyCount || !params.polys || Constants::TilesPerMap * Constants::TilesPerMap == params.polyCount)
{
// we have flat tiles with no actual geometry - don't build those, its useless
// keep in mind that we do output those into debug info
// drop tiles with only exact count - some tiles may have geometry while having less tiles
printf("[%02i, %02i] No polygons to build on tile, skipping.\n", X, Y);
rcFreePolyMesh(pmesh);
rcFreePolyMeshDetail(dmesh);
return NULL;
}
int navDataSize;
uint8* navData;
printf("[%02i, %02i] Creating the navmesh with %i vertices, %i polys, %i triangles!\n", X, Y, params.vertCount, params.polyCount, params.detailTriCount);
bool result = dtCreateNavMeshData(¶ms, &navData, &navDataSize);
rcFreePolyMesh(pmesh);
rcFreePolyMeshDetail(dmesh);
if (result)
{
printf("[%02i, %02i] NavMesh created, size %i!\n", X, Y, navDataSize);
DataSize = navDataSize;
return navData;
}
return NULL;
}
开发者ID:Exodius,项目名称:DeathCore,代码行数:101,代码来源:TileBuilder.cpp
示例13: printf
//.........这里部分代码省略.........
}
if (!rcBuildRegions(m_rcContext, *tile.chf, tileCfg.borderSize, tileCfg.minRegionArea, tileCfg.mergeRegionArea))
{
printf("%s Failed building regions! \n", tileString.c_str());
continue;
}
tile.cset = rcAllocContourSet();
if (!tile.cset || !rcBuildContours(m_rcContext, *tile.chf, tileCfg.maxSimplificationError, tileCfg.maxEdgeLen, *tile.cset))
{
printf("%s Failed building contours! \n", tileString.c_str());
continue;
}
// build polymesh
tile.pmesh = rcAllocPolyMesh();
if (!tile.pmesh || !rcBuildPolyMesh(m_rcContext, *tile.cset, tileCfg.maxVertsPerPoly, *tile.pmesh))
{
printf("%s Failed building polymesh! \n", tileString.c_str());
continue;
}
tile.dmesh = rcAllocPolyMeshDetail();
if (!tile.dmesh || !rcBuildPolyMeshDetail(m_rcContext, *tile.pmesh, *tile.chf, tileCfg.detailSampleDist, tileCfg.detailSampleMaxError, *tile.dmesh))
{
printf("%s Failed building polymesh detail! \n", tileString.c_str());
continue;
}
// free those up
// we may want to keep them in the future for debug
// but right now, we don't have the code to merge them
rcFreeHeightField(tile.solid);
tile.solid = NULL;
rcFreeCompactHeightfield(tile.chf);
tile.chf = NULL;
rcFreeContourSet(tile.cset);
tile.cset = NULL;
pmmerge[nmerge] = tile.pmesh;
dmmerge[nmerge] = tile.dmesh;
nmerge++;
}
}
iv.polyMesh = rcAllocPolyMesh();
if (!iv.polyMesh)
{
printf("%s alloc iv.polyMesh FAILED!\n", tileString.c_str());
delete[] pmmerge;
delete[] dmmerge;
delete[] tiles;
return;
}
rcMergePolyMeshes(m_rcContext, pmmerge, nmerge, *iv.polyMesh);
iv.polyMeshDetail = rcAllocPolyMeshDetail();
if (!iv.polyMeshDetail)
{
printf("%s alloc m_dmesh FAILED!\n", tileString.c_str());
delete[] pmmerge;
delete[] dmmerge;
delete[] tiles;
return;
}
开发者ID:Rastrian,项目名称:DeathCore_6.x-1,代码行数:67,代码来源:MapBuilder.cpp
示例14: cleanup
//.........这里部分代码省略.........
if (!m_keepInterResults)
{
delete [] m_triareas;
m_triareas = 0;
}
// Once all geometry is rasterized, we do initial pass of filtering to
// remove unwanted overhangs caused by the conservative rasterization
// as well as filter spans where the character cannot possibly stand.
if (m_filterLowHangingObstacles)
rcFilterLowHangingWalkableObstacles(m_ctx, m_cfg.walkableClimb, *m_solid);
if (m_filterLedgeSpans)
rcFilterLedgeSpans(m_ctx, m_cfg.walkableHeight, m_cfg.walkableClimb, *m_solid);
if (m_filterWalkableLowHeightSpans)
rcFilterWalkableLowHeightSpans(m_ctx, m_cfg.walkableHeight, *m_solid);
// Compact the heightfield so that it is faster to handle from now on.
// This will result more cache coherent data as well as the neighbours
// between walkable cells will be calculated.
m_chf = rcAllocCompactHeightfield();
if (!m_chf)
{
m_ctx->log(RC_LOG_ERROR, "buildNavigation: Out of memory 'chf'.");
return 0;
}
if (!rcBuildCompactHeightfield(m_ctx, m_cfg.walkableHeight, m_cfg.walkableClimb, *m_solid, *m_chf))
{
m_ctx->log(RC_LOG_ERROR, "buildNavigation: Could not build compact data.");
return 0;
}
if (!m_keepInterResults)
{
rcFreeHeightField(m_solid);
m_solid = 0;
}
// Erode the walkable area by agent radius.
if (!rcErodeWalkableArea(m_ctx, m_cfg.walkableRadius, *m_chf))
{
m_ctx->log(RC_LOG_ERROR, "buildNavigation: Could not erode.");
return 0;
}
// (Optional) Mark areas.
const ConvexVolume* vols = m_geom->getConvexVolumes();
for (int i = 0; i < m_geom->getConvexVolumeCount(); ++i)
rcMarkConvexPolyArea(m_ctx, vols[i].verts, vols[i].nverts, vols[i].hmin, vols[i].hmax, (unsigned char)vols[i].area, *m_chf);
// Partition the heightfield so that we can use simple algorithm later to triangulate the walkable areas.
// There are 3 martitioning methods, each with some pros and cons:
// 1) Watershed partitioning
// - the classic Recast partitioning
// - creates the nicest tessellation
// - usually slowest
// - partitions the heightfield into nice regions without holes or overlaps
// - the are some corner cases where this method creates produces holes and overlaps
// - holes may appear when a small obstacles is close to large open area (triangulation can handle this)
// - overlaps may occur if you have narrow spiral corridors (i.e stairs), this make triangulation to fail
// * generally the best choice if you precompute the nacmesh, use this if you have large open areas
// 2) Monotone partioning
// - fastest
// - partitions the heightfield into regions without holes and overlaps (guaranteed)
// - creates long thin polygons, which sometimes causes paths with detours
// * use this if you want fast navmesh generation
开发者ID:ArtStealer,项目名称:recastnavigation,代码行数:67,代码来源:Sample_TileMesh.cpp
示例15: rcVcopy
//.........这里部分代码省略.........
// as well as filter spans where the character cannot possibly stand.
rcFilterLowHangingWalkableObstacles(m_ctx, m_cfg.walkableClimb, *m_solid);
rcFilterLedgeSpans(m_ctx, m_cfg.walkableHeight, m_cfg.walkableClimb, *m_solid);
rcFilterWalkableLowHeightSpans(m_ctx, m_cfg.walkableHeight, *m_solid);
//
// Step 4. Partition walkable surface to simple regions.
//
// Compact the heightfield so that it is faster to handle from now on.
// This will result more cache coherent data as well as the neighbours
// between walkable cells will be calculated.
m_chf = rcAllocCompactHeightfield();
if (!m_chf)
{
m_pLog->logMessage("ERROR: buildNavigation: Out of memory 'chf'.");
return false;
}
if (!rcBuildCompactHeightfield(m_ctx, m_cfg.walkableHeight, m_cfg.walkableClimb, *m_solid, *m_chf))
{
m_pLog->logMessage("ERROR: buildNavigation: Could not build compact data.");
return false;
}
if (!m_keepInterResults)
{
rcFreeHeightField(m_solid);
m_solid = 0;
}
// Erode the walkable area by agent radius.
if (!rcErodeWalkableArea(m_ctx, m_cfg.walkableRadius, *m_chf))
{
m_pLog->logMessage("ERROR: buildNavigation: Could not erode walkable areas.");
return false;
}
// TODO implement
// (Optional) Mark areas.
//const ConvexVolume* vols = m_geom->getConvexVolumes();
//for (int i = 0; i < m_geom->getConvexVolumeCount(); ++i)
// rcMarkConvexPolyArea(m_ctx, vols[i].verts, vols[i].nverts, vols[i].hmin, vols[i].hmax, (unsigned char)vols[i].area, *m_chf);
// Prepare for region partitioning, by calculating distance field along the walkable surface.
if (!rcBuildDistanceField(m_ctx, *m_chf))
{
m_pLog->logMessage("ERROR: buildNavigation: Could not build distance field.");
return false;
}
// Partition the walkable surface into simple regions without holes.
if (!rcBuildRegions(m_ctx, *m_chf, m_cfg.borderSize, m_cfg.minRegionArea, m_cfg.mergeRegionArea))
{
m_pLog->logMessage("ERROR: buildNavigation: Could not build regions.");
return false;
}
开发者ID:arrian,项目名称:3d-engine,代码行数:66,代码来源:OgreRecast.cpp
示例16: cleanup
//.........这里部分代码省略.........
rcRasterizeTriangles(m_ctx, verts, nverts, tris, m_triareas, ntris, *m_solid, m_cfg.walkableClimb);
}
if (!m_keepInterResults)
{
delete [] m_triareas;
m_triareas = 0;
}
// Once all geometry is rasterized, we do initial pass of filtering to
// remove unwanted overhangs caused by the conservative rasterization
// as well as filter spans where the character cannot possibly stand.
rcFilterLowHangingWalkableObstacles(m_ctx, m_cfg.walkableClimb, *m_solid);
rcFilterLedgeSpans(m_ctx, m_cfg.walkableHeight, m_cfg.walkableClimb, *m_solid);
rcFilterWalkableLowHeightSpans(m_ctx, m_cfg.walkableHeight, *m_solid);
// Compact the heightfield so that it is faster to handle from now on.
// This will result more cache coherent data as well as the neighbours
// between walkable cells will be calculated.
m_chf = rcAllocCompactHeightfield();
if (!m_chf)
{
m_ctx->log(RC_LOG_ERROR, "buildNavigation: Out of memory 'chf'.");
return 0;
}
if (!rcBuildCompactHeightfield(m_ctx, m_cfg.walkableHeight, m_cfg.walkableClimb, *m_solid, *m_chf))
{
m_ctx->log(RC_LOG_ERROR, "buildNavigation: Could not build compact data.");
return 0;
}
if (!m_keepInterResults)
{
rcFreeHeightField(m_solid);
m_solid = 0;
}
// Erode the walkable area by agent radius.
if (!rcErodeWalkableArea(m_ctx, m_cfg.walkableRadius, *m_chf))
{
m_ctx->log(RC_LOG_ERROR, "buildNavigation: Could not erode.");
return false;
}
// (Optional) Mark areas.
const ConvexVolume* vols = m_geom->getConvexVolumes();
for (int i = 0; i < m_geom->getConvexVolumeCount(); ++i)
rcMarkConvexPolyArea(m_ctx, vols[i].verts, vols[i].nverts, vols[i].hmin, vols[i].hmax, (unsigned char)vols[i].area, *m_chf);
// Prepare for region partitioning, by calculating distance field along the walkable surface.
if (!rcBuildDistanceField(m_ctx, *m_chf))
{
m_ctx->log(RC_LOG_ERROR, "buildNavigation: Could not build distance field.");
return 0;
}
// Partition the walkable surface into simple regions without holes.
if (!rcBuildRegions(m_ctx, *m_chf, m_cfg.borderSize, m_cfg.minRegionArea, m_cfg.mergeRegionArea))
{
m_ctx->log(RC_LOG_ERROR, "buildNavigation: Could not build regions.");
return 0;
}
// Create contours.
m_cset = rcAllocContourSet();
if (!m_cset)
开发者ID:120239197a,项目名称:SingleCore,代码行数:67,代码来源:Sample_TileMesh.cpp
示例17: recast_destroyHeightfield
void recast_destroyHeightfield(struct recast_heightfield *heightfield)
{
rcFreeHeightField((rcHeightfield *) heightfield);
}
开发者ID:JasonWilkins,项目名称:blender-wayland,代码行数:4,代码来源:recast-capi.cpp
示例18: cleanup
//.........这里部分代码省略.........
//
// Step 3. Filter walkables surfaces.
//
// Once all geoemtry is rasterized, we do initial pass of filtering to
// remove unwanted overhangs caused by the conservative rasterization
// as well as filter spans where the character cannot possibly stand.
rcFilterLowHangingWalkableObstacles(m_ctx, m_cfg.walkableClimb, *m_solid);
rcFilterLedgeSpans(m_ctx, m_cfg.walkableHeight, m_cfg.walkableClimb, *m_solid);
rcFilterWalkableLowHeightSpans(m_ctx, m_cfg.walkableHeight, *m_solid);
//
// Step 4. Partition walkable surface to simple regions.
//
// Compact the heightfield so that it is faster to handle from now on.
// This will result more cache coherent data as well as the neighbours
// between walkable cells will be calculated.
m_chf = rcAllocCompactHeightfield();
if (!m_chf)
{
m_ctx->log(RC_LOG_ERROR, "buildNavigation: Out of memory 'chf'.");
return false;
}
if (!rcBuildCompactHeightfield(m_ctx, m_cfg.walkableHeight, m_cfg.walkableClimb, *m_solid, *m_chf))
{
m_ctx->log(RC_LOG_ERROR, "buildNavigation: Could not build compact data.");
return false;
}
if (!m_keepInterResults)
{
rcFreeHeightField(m_solid);
m_solid = 0;
}
// Erode the walkable area by agent radius.
if (!rcErodeWalkableArea(m_ctx, m_cfg.walkableRadius, *m_chf))
{
m_ctx->log(RC_LOG_ERROR, "buildNavigation: Could not erode.");
return false;
}
// (Optional) Mark areas.
const ConvexVolume* vols = m_geom->getConvexVolumes();
for (int i = 0; i < m_geom->getConvexVolumeCount(); ++i)
rcMarkConvexPolyArea(m_ctx, vols[i].verts, vols[i].nverts, vols[i].hmin, vols[i].hmax, (unsigned char)vols[i].area, *m_chf);
// Partition the heightfield so that we can use simple algorithm later to triangulate the walkable areas.
// There are 3 martitioning methods, each with some pros and cons:
// 1) Watershed partitioning
// - the classic Recast partitioning
// - creates the nicest tessellation
// - usually slowest
// - partitions the heightfield into nice regions without holes or overlaps
// - the are some corner cases where this method creates produces holes and overlaps
// - holes may appear when a small obstacles is close to large open area (triangulation can handle this)
// - overlaps may occur if you have narrow spiral corridors (i.e stairs), this make triangulation to fail
// * generally the best choice if you precompute the nacmesh, use this if you have large open areas
// 2) Monotone partioning
// - fastest
// - partitions the heightfield into regions without holes and overlaps (guaranteed)
// - creates long thin polygons, which sometimes causes paths with detours
// * use this if you want fast navmesh generation
开发者ID:21423236,项目名称:recastnavigation,代码行数:67,代码来源:Sample_SoloMesh.cpp
示例19: Geometry
//.........这里部分代码省略.........
rcPolyMesh** pmmerge = new rcPolyMesh*[Constants::TilesPerMap * Constants::TilesPerMap];
rcPolyMeshDetail** dmmerge = new rcPolyMeshDetail*[Constants::TilesPerMap * Constants::TilesPerMap];
int nmerge = 0;
for (int y = 0; y < Constants::TilesPerMap; ++y)
{
for (int x = 0; x < Constants::TilesPerMap; ++x)
{
// Calculate the per tile bounding box.
tileCfg.bmin[0] = Config.bmin[0] + float(x * Config.tileSize - Config.borderSize) * Config.cs;
tileCfg.bmin[2] = Config.bmin[2] + float(y * Config.tileSize - Config.borderSize) * Config.cs;
tileCfg.bmax[0] = Config.bmin[0] + float((x + 1) * Config.tileSize + Config.borderSize) * Config.cs;
tileCfg.bmax[2] = Config.bmin[2] + float((y + 1) * Config.tileSize + Config.borderSize) * Config.cs;
rcHeightfield* hf = rcAllocHeightfield();
rcCreateHeightfield(Context, *hf, tileCfg.width, tileCfg.height, tileCfg.bmin, tileCfg.bmax, tileCfg.cs, tileCfg.ch);
rcClearUnwalkableTriangles(Context, tileCfg.walkableSlopeAngle, vertices, numVerts, triangles, numTris, areas);
rcRasterizeTriangles(Context, vertices, numVerts, triangles, areas, numTris, *hf, Config.walkableClimb);
// Once all geometry is rasterized, we do initial pass of filtering to
// remove unwanted overhangs caused by the conservative rasterization
// as well as filter spans where the character cannot possibly stand.
rcFilterLowHangingWalkableObstacles(Context, Config.walkableClimb, *hf);
rcFilterLedgeSpans(Context, tileCfg.walkableHeight, tileCfg.walkableClimb, *hf);
rcFilterWalkableLowHeightSpans(Context, tileCfg.walkableHeight, *hf);
// Compact the heightfield so that it is faster to handle from now on.
// This will result in more cache coherent data as well as the neighbours
// between walkable cells will be calculated.
rcCompactHeightfield* chf = rcAllocCompactHeightfield();
rcBuildCompactHeightfield(Context, tileCfg.walkableHeight, tileCfg.walkableClimb, *hf, *chf);
rcFreeHeightField(hf);
// Erode the walkable area by agent radius.
rcErodeWalkableArea(Context, Config.walkableRadius, *chf);
// Prepare for region partitioning, by calculating distance field along the walkable surface.
rcBuildDistanceField(Context, *chf);
// Partition the walkable surface into simple regions without holes.
rcBuildRegions(Context, *chf, tileCfg.borderSize, tileCfg.minRegionArea, tileCfg.mergeRegionArea);
// Create contours.
rcContourSet* cset = rcAllocContourSet();
rcBuildContours(Context, *chf, tileCfg.maxSimplificationError, tileCfg.maxEdgeLen, *cset);
// Build polygon navmesh from the contours.
rcPolyMesh* pmesh = rcAllocPolyMesh();
rcBuildPolyMesh(Context, *cset, tileCfg.maxVertsPerPoly, *pmesh);
// Build detail mesh.
rcPolyMeshDetail* dmesh = rcAllocPolyMeshDetail();
rcBuildPolyMeshDetail(Context, *pmesh, *chf, tileCfg.detailSampleDist, tileCfg.detailSampleMaxError, *dmesh);
// Free memory
rcFreeCompactHeightfield(chf);
rcFreeContourSet(cset);
pmmerge[nmerge] = pmesh;
dmmerge[nmerge] = dmesh;
++nmerge;
}
}
rcPolyMesh* pmesh = rcAllocPolyMesh();
rcMergePolyMeshes(Context, pmmerge, nmerge, *pmesh);
开发者ID:Allowed,项目名称:SkyFire_5xx,代码行数:67,代码来源:TileBuilder.cpp
示例20: rcVcopy
//.........这里部分代码省略.........
//I know I put this option in the params, but...
if(!_recastParams.getKeepIntermediateResults())
{
delete[] _triangleAreas;
_triangleAreas = nullptr;
}
//Step 3 : Filter walkables surfaces
//Initial pass of filtering to remove unwanted overhangs caused
//by the conservative rasterization.
//Also filters spans where the character can't stand.
rcFilterLowHangingWalkableObstacles(_context,_config.walkableClimb,*_solid);
rcFilterLedgeSpans(_context,_config.walkableHeight,_config.walkableClimb,*_solid);
rcFilterWalkableLowHeightSpans(_context,_config.walkableHeight,*_solid);
//Step 4 : Partition walkable surface to simple regions
//Compact the heightfield so that it is faster to handle from now on.
_compactHeightfield = rcAllocCompactHeightfield();
if(!_compactHeightfield)
{
std::cout << "Error! Out of memory '_compactHeightfield'" << std::endl;
return false;
}
if(!rcBuildCompactHeightfield(_context,
_config.walkableHeight,_config.walkableClimb,
*_solid,*_compactHeightfield))
{
std::cout << "Error! BuildNav - Could not build compact data." << std::endl;
return false;
}
if(!_recastParams.getKeepIntermediateResults())
{
rcFreeHeightField(_solid);
_solid = nullptr;
}
//Erode walkable area by agent radius
if(!rcErodeWalkableArea(_context,_config.walkableRadius,*_compactHeightfield))
{
std::cout << "Error! BuildNav - Could not erode walkable areas." << std::endl;
return false;
}
//Prepare for region partitioning, generate distance field
if(!rcBuildDistanceField(_context,*_compactHeightfield))
{
std::cout << "Error! BuildNav - Could not build distance field." << std::endl;
return false;
}
//Partition the walkable surface into simple regions w/o holes
if(!rcBuildRegions(_context,*_compactHeightfield,
_config.borderSize,
_config.minRegionArea,_config.mergeRegionArea))
{
std::cout << "Error! BuildNav - Could not build regions." << std::endl;
return false;
}
//Step 5 : Trace and simplify region contours.
//create contours
_contourSet = rcAllocContourSet();
if(!_contourSet)
{
std::cout << "Error! BuildNav - Out of memory '_contourSet'" << std::endl;
开发者ID:Dar13,项目名称:WastelandArchive,代码行数:67,代码来源:RecastInterface.cpp
注:本文中的rcFreeHeightField函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论