1
This commit is contained in:
parent
d129fb5bb3
commit
24d221d934
@ -139,9 +139,6 @@ int NavMeshBuilder::RasterizeTileLayers(BuilderParams& builder_params,
|
||||
FastLZCompressor comp;
|
||||
RasterizationContext rc;
|
||||
|
||||
#if 1
|
||||
rcContext* ctx = nullptr;
|
||||
#endif
|
||||
const float* verts = builder_params.gemo->GetVerts();
|
||||
const int nverts = builder_params.gemo->GetVertCount();
|
||||
const rcChunkyTriMesh* chunkyMesh = builder_params.gemo->GetChunkyMesh();
|
||||
@ -168,7 +165,7 @@ int NavMeshBuilder::RasterizeTileLayers(BuilderParams& builder_params,
|
||||
if (!rc.solid) {
|
||||
return 0;
|
||||
}
|
||||
if (!rcCreateHeightfield(ctx, *rc.solid, tcfg.width, tcfg.height, tcfg.bmin, tcfg.bmax, tcfg.cs, tcfg.ch)) {
|
||||
if (!rcCreateHeightfield(builder_params.ctx, *rc.solid, tcfg.width, tcfg.height, tcfg.bmin, tcfg.bmax, tcfg.cs, tcfg.ch)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -177,7 +174,7 @@ int NavMeshBuilder::RasterizeTileLayers(BuilderParams& builder_params,
|
||||
// and array which can hold the max number of triangles you need to process.
|
||||
rc.triareas = new unsigned char[chunkyMesh->maxTrisPerChunk];
|
||||
if (!rc.triareas) {
|
||||
ctx->log(RC_LOG_ERROR, "buildNavigation: Out of memory 'm_triareas' (%d).", chunkyMesh->maxTrisPerChunk);
|
||||
builder_params.ctx->log(RC_LOG_ERROR, "buildNavigation: Out of memory 'm_triareas' (%d).", chunkyMesh->maxTrisPerChunk);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -198,11 +195,11 @@ int NavMeshBuilder::RasterizeTileLayers(BuilderParams& builder_params,
|
||||
const int ntris = node.n;
|
||||
|
||||
memset(rc.triareas, 0, ntris*sizeof(unsigned char));
|
||||
rcMarkWalkableTriangles(ctx, tcfg.walkableSlopeAngle,
|
||||
rcMarkWalkableTriangles(builder_params.ctx, tcfg.walkableSlopeAngle,
|
||||
verts, nverts, tris, ntris, rc.triareas,
|
||||
SAMPLE_AREAMOD_GROUND);
|
||||
|
||||
if (!rcRasterizeTriangles(ctx, verts, nverts, tris, rc.triareas, ntris, *rc.solid, tcfg.walkableClimb)) {
|
||||
if (!rcRasterizeTriangles(builder_params.ctx, verts, nverts, tris, rc.triareas, ntris, *rc.solid, tcfg.walkableClimb)) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -211,46 +208,46 @@ int NavMeshBuilder::RasterizeTileLayers(BuilderParams& builder_params,
|
||||
// remove unwanted overhangs caused by the conservative rasterization
|
||||
// as well as filter spans where the character cannot possibly stand.
|
||||
if (builder_params.kFilterLowHangingObstacles) {
|
||||
rcFilterLowHangingWalkableObstacles(ctx, tcfg.walkableClimb, *rc.solid);
|
||||
rcFilterLowHangingWalkableObstacles(builder_params.ctx, tcfg.walkableClimb, *rc.solid);
|
||||
}
|
||||
if (builder_params.kFilterLedgeSpans) {
|
||||
rcFilterLedgeSpans(ctx, tcfg.walkableHeight, tcfg.walkableClimb, *rc.solid);
|
||||
rcFilterLedgeSpans(builder_params.ctx, tcfg.walkableHeight, tcfg.walkableClimb, *rc.solid);
|
||||
}
|
||||
if (builder_params.kFilterWalkableLowHeightSpans) {
|
||||
rcFilterWalkableLowHeightSpans(ctx, tcfg.walkableHeight, *rc.solid);
|
||||
rcFilterWalkableLowHeightSpans(builder_params.ctx, tcfg.walkableHeight, *rc.solid);
|
||||
}
|
||||
|
||||
rc.chf = rcAllocCompactHeightfield();
|
||||
if (!rc.chf) {
|
||||
ctx->log(RC_LOG_ERROR, "buildNavigation: Out of memory 'chf'.");
|
||||
builder_params.ctx->log(RC_LOG_ERROR, "buildNavigation: Out of memory 'chf'.");
|
||||
return 0;
|
||||
}
|
||||
if (!rcBuildCompactHeightfield(ctx, tcfg.walkableHeight, tcfg.walkableClimb, *rc.solid, *rc.chf)) {
|
||||
ctx->log(RC_LOG_ERROR, "buildNavigation: Could not build compact data.");
|
||||
if (!rcBuildCompactHeightfield(builder_params.ctx, tcfg.walkableHeight, tcfg.walkableClimb, *rc.solid, *rc.chf)) {
|
||||
builder_params.ctx->log(RC_LOG_ERROR, "buildNavigation: Could not build compact data.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Erode the walkable area by agent radius.
|
||||
if (!rcErodeWalkableArea(ctx, tcfg.walkableRadius, *rc.chf)) {
|
||||
ctx->log(RC_LOG_ERROR, "buildNavigation: Could not erode.");
|
||||
if (!rcErodeWalkableArea(builder_params.ctx, tcfg.walkableRadius, *rc.chf)) {
|
||||
builder_params.ctx->log(RC_LOG_ERROR, "buildNavigation: Could not erode.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
// (Optional) Mark areas.
|
||||
const ConvexVolume* vols = builder_params.gemo->GetConvexVolumes();
|
||||
for (int i = 0; i < builder_params.gemo->GetConvexVolumeCount(); ++i) {
|
||||
rcMarkConvexPolyArea(ctx, vols[i].verts, vols[i].nverts,
|
||||
rcMarkConvexPolyArea(builder_params.ctx, vols[i].verts, vols[i].nverts,
|
||||
vols[i].hmin, vols[i].hmax,
|
||||
vols[i].areaMod, *rc.chf);
|
||||
}
|
||||
|
||||
rc.lset = rcAllocHeightfieldLayerSet();
|
||||
if (!rc.lset) {
|
||||
ctx->log(RC_LOG_ERROR, "buildNavigation: Out of memory 'lset'.");
|
||||
builder_params.ctx->log(RC_LOG_ERROR, "buildNavigation: Out of memory 'lset'.");
|
||||
return 0;
|
||||
}
|
||||
if (!rcBuildHeightfieldLayers(ctx, *rc.chf, tcfg.borderSize, tcfg.walkableHeight, *rc.lset)) {
|
||||
ctx->log(RC_LOG_ERROR, "buildNavigation: Could not build heighfield layers.");
|
||||
if (!rcBuildHeightfieldLayers(builder_params.ctx, *rc.chf, tcfg.borderSize, tcfg.walkableHeight, *rc.lset)) {
|
||||
builder_params.ctx->log(RC_LOG_ERROR, "buildNavigation: Could not build heighfield layers.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -303,6 +303,7 @@ struct BuilderParams
|
||||
MapInstance* map_instance = nullptr;
|
||||
InputGeom* gemo = nullptr;
|
||||
dtNavMesh* navmesh = nullptr;
|
||||
rcContext* ctx = nullptr;
|
||||
dtTileCache* tile_cache = nullptr;
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user