1
This commit is contained in:
parent
eec0c16a72
commit
b74a7709cf
@ -1,5 +1,7 @@
|
||||
#include "precompile.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include "DetourCommon.h"
|
||||
|
||||
#include "mapinstance.h"
|
||||
@ -43,6 +45,11 @@ struct NavMeshTileHeader
|
||||
int dataSize;
|
||||
};
|
||||
|
||||
static float frand()
|
||||
{
|
||||
return (float)rand()/(float)RAND_MAX;
|
||||
}
|
||||
|
||||
void MapInstance::Init()
|
||||
{
|
||||
current_map_block_uniid_ = MAP_BLOCK_START_ID;
|
||||
@ -750,6 +757,35 @@ int MapInstance::FindRandomPointAroundCircle(int layer,
|
||||
unsigned int max_points,
|
||||
float max_radius)
|
||||
{
|
||||
dtQueryFilter filter;
|
||||
filter.setIncludeFlags(0xffff);
|
||||
filter.setExcludeFlags(0);
|
||||
|
||||
dtPolyRef startRef = INVALID_NAVMESH_POLYREF;
|
||||
|
||||
const float extents[3] = {2.f, 4.f, 2.f};
|
||||
float nearestPt[3];
|
||||
|
||||
float center[3];
|
||||
center[0] = center_pos.x;
|
||||
center[1] = center_pos.y;
|
||||
center[2] = center_pos.z;
|
||||
|
||||
navmesh_query_->findNearestPoly(center, extents, &filter, &startRef, nearestPt);
|
||||
if (!startRef) {
|
||||
return NAV_ERROR_NEARESTPOLY;
|
||||
}
|
||||
|
||||
dtPolyRef randomRef = INVALID_NAVMESH_POLYREF;
|
||||
float randomPt[3];
|
||||
navmesh_query_->findRandomPointAroundCircle(startRef,
|
||||
center,
|
||||
max_radius,
|
||||
&filter,
|
||||
frand,
|
||||
&randomRef,
|
||||
randomPt);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user