本文整理汇总了C++中dtAssert函数的典型用法代码示例。如果您正苦于以下问题:C++ dtAssert函数的具体用法?C++ dtAssert怎么用?C++ dtAssert使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dtAssert函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: adjusted
/**
@par
Behavior:
- The movement is constrained to the surface of the navigation mesh.
- The corridor is automatically adjusted (shorted or lengthened) in order to remain valid.
- The new target will be located in the adjusted corridor's last polygon.
The expected use case is that the desired target will be 'near' the current corridor. What is considered 'near' depends on local polygon density, query search extents, etc.
The resulting target will differ from the desired target if the desired target is not on the navigation mesh, or it can't be reached using a local search.
*/
bool dtPathCorridor::moveTargetPosition(const float* npos, dtNavMeshQuery* navquery, const dtQueryFilter* filter)
{
dtAssert(m_path);
dtAssert(m_npath);
// Move along navmesh and update new position.
float result[3];
static const int MAX_VISITED = 16;
dtPolyRef visited[MAX_VISITED];
int nvisited = 0;
dtStatus status = navquery->moveAlongSurface(m_path[m_npath-1], m_target, npos, filter,
result, visited, &nvisited, MAX_VISITED);
if (dtStatusSucceed(status))
{
m_npath = dtMergeCorridorEndMoved(m_path, m_npath, m_maxPath, visited, nvisited);
// TODO: should we do that?
// Adjust the position to stay on top of the navmesh.
/* float h = m_target[1];
navquery->getPolyHeight(m_path[m_npath-1], result, &h);
result[1] = h;*/
dtVcopy(m_target, result);
return true;
}
return false;
}
示例2: 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;
}
示例3: dtAssert
/**
@par
Inaccurate locomotion or dynamic obstacle avoidance can force the agent position significantly outside the
original corridor. Over time this can result in the formation of a non-optimal corridor. This function will use a
local area path search to try to re-optimize the corridor.
The more inaccurate the agent movement, the more beneficial this function becomes. Simply adjust the frequency of
the call to match the needs to the agent.
*/
bool dtPathCorridor::optimizePathTopology(dtNavMeshQuery* navquery, const dtQueryFilter* filter)
{
dtAssert(navquery);
dtAssert(filter);
dtAssert(m_path);
if (m_npath < 3)
return false;
static const int MAX_ITER = 32;
static const int MAX_RES = 32;
dtPolyRef res[MAX_RES];
int nres = 0;
navquery->initSlicedFindPath(m_path[0], m_path[m_npath-1], m_pos, m_target, filter);
navquery->updateSlicedFindPath(MAX_ITER, 0);
dtStatus status = navquery->finalizeSlicedFindPathPartial(m_path, m_npath, res, &nres, MAX_RES);
if (dtStatusSucceed(status) && nres > 0)
{
m_npath = dtMergeCorridorStartShortcut(m_path, m_npath, m_maxPath, res, nres);
return true;
}
return false;
}
示例4: getFlags
inline unsigned char getFlags(dtPolyRef ref)
{
dtAssert(m_nav);
dtAssert(m_ntiles);
// Assume the ref is valid, no bounds checks.
unsigned int salt, it, ip;
m_nav->decodePolyId(ref, salt, it, ip);
return m_tiles[it].flags[ip];
}
示例5: setFlags
inline void setFlags(dtPolyRef ref, unsigned char flags)
{
dtAssert(m_nav);
dtAssert(m_ntiles);
// Assume the ref is valid, no bounds checks.
unsigned int salt, it, ip;
m_nav->decodePolyId(ref, salt, it, ip);
m_tiles[it].flags[ip] = flags;
}
示例6: dtAssert
/// @par
///
/// The current corridor position is expected to be within the first polygon in the path. The target
/// is expected to be in the last polygon.
///
/// @warning The size of the path must not exceed the size of corridor's path buffer set during #init().
void dtPathCorridor::setCorridor(const float* target, const dtPolyRef* path, const int npath)
{
dtAssert(m_path);
dtAssert(npath > 0);
dtAssert(npath < m_maxPath);
dtVcopy(m_target, target);
memcpy(m_path, path, sizeof(dtPolyRef)*npath);
m_npath = npath;
}
示例7: m_heap
dtNodeQueue::dtNodeQueue(int n) :
m_heap(0),
m_capacity(n),
m_size(0)
{
dtAssert(m_capacity > 0);
m_heap = (dtNode**)dtAlloc(sizeof(dtNode*)*(m_capacity+1), DT_ALLOC_PERM);
dtAssert(m_heap);
}
示例8: dtBuildTileCacheDistanceField
dtStatus dtBuildTileCacheDistanceField(dtTileCacheAlloc* alloc, dtTileCacheLayer& layer, dtTileCacheDistanceField& dfield)
{
dtAssert(alloc);
const int w = (int)layer.header->width;
const int h = (int)layer.header->height;
dfield.data = (unsigned short*)alloc->alloc(w*h*sizeof(unsigned short));
if (!dfield.data)
{
return DT_FAILURE | DT_OUT_OF_MEMORY;
}
dtTileCacheDistanceField tmpField;
tmpField.data = (unsigned short*)alloc->alloc(w*h*sizeof(unsigned short));
if (!tmpField.data)
{
return DT_FAILURE | DT_OUT_OF_MEMORY;
}
calculateDistanceField(layer, dfield.data, dfield.maxDist);
if (boxBlur(layer, 1, dfield.data, tmpField.data) != dfield.data)
{
dtSwap(dfield.data, tmpField.data);
}
alloc->free(tmpField.data);
return DT_SUCCESS;
}
示例9: addToPathQueue
static int addToPathQueue(dtCrowdAgent* newag, dtCrowdAgent** agents, const int nagents, const int maxAgents)
{
// Insert neighbour based on greatest time.
int slot = 0;
if (!nagents)
{
slot = nagents;
}
else if (newag->targetReplanTime <= agents[nagents-1]->targetReplanTime)
{
if (nagents >= maxAgents)
return nagents;
slot = nagents;
}
else
{
int i;
for (i = 0; i < nagents; ++i)
if (newag->targetReplanTime >= agents[i]->targetReplanTime)
break;
const int tgt = i+1;
const int n = dtMin(nagents-i, maxAgents-tgt);
dtAssert(tgt+n <= maxAgents);
if (n > 0)
memmove(&agents[tgt], &agents[i], sizeof(dtCrowdAgent*)*n);
slot = i;
}
agents[slot] = newag;
return dtMin(nagents+1, maxAgents);
}
示例10: decodePolyId
const dtOffMeshConnection* dtNavMesh::getOffMeshConnectionByRef(dtPolyRef ref) const
{
unsigned int salt, it, ip;
if (!ref)
return 0;
// Get current polygon
decodePolyId(ref, salt, it, ip);
if (it >= (unsigned int)m_maxTiles)
return 0;
if (m_tiles[it].salt != salt || m_tiles[it].header == 0)
return 0;
const dtMeshTile* tile = &m_tiles[it];
if (ip >= (unsigned int)tile->header->polyCount)
return 0;
if (ip >= (unsigned int)tile->header->polyCount) return 0;
const dtPoly* poly = &tile->polys[ip];
// Make sure that the current poly is indeed off-mesh link.
if (poly->getType() != DT_POLYTYPE_OFFMESH_CONNECTION)
return 0;
const unsigned int idx = ip - tile->header->offMeshBase;
dtAssert(idx < (unsigned int)tile->header->offMeshConCount);
return &tile->offMeshCons[idx];
}
示例11: 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;
}
示例12: adjusted
/**
@par
Behavior:
- The movement is constrained to the surface of the navigation mesh.
- The corridor is automatically adjusted (shorted or lengthened) in order to remain valid.
- The new position will be located in the adjusted corridor's first polygon.
The expected use case is that the desired position will be 'near' the current corridor. What is considered 'near'
depends on local polygon density, query search extents, etc.
The resulting position will differ from the desired position if the desired position is not on the navigation mesh,
or it can't be reached using a local search.
*/
void dtPathCorridor::movePosition(const float* npos, dtNavMeshQuery* navquery, const dtQueryFilter* filter)
{
dtAssert(m_path);
dtAssert(m_npath);
// Move along navmesh and update new position.
float result[3];
static const int MAX_VISITED = 16;
dtPolyRef visited[MAX_VISITED];
int nvisited = 0;
navquery->moveAlongSurface(m_path[0], m_pos, npos, filter,
result, visited, &nvisited, MAX_VISITED);
m_npath = dtMergeCorridorStartMoved(m_path, m_npath, m_maxPath, visited, nvisited);
// Adjust the position to stay on top of the navmesh.
float h = m_pos[1];
navquery->getPolyHeight(m_path[0], result, &h);
result[1] = h;
dtVcopy(m_pos, result);
}
示例13: be
/**
@par
This is the function used to plan local movement within the corridor. One or more corners can be
detected in order to plan movement. It performs essentially the same function as #dtNavMeshQuery::findStraightPath.
Due to internal optimizations, the maximum number of corners returned will be (@p maxCorners - 1)
For example: If the buffers are sized to hold 10 corners, the function will never return more than 9 corners.
So if 10 corners are needed, the buffers should be sized for 11 corners.
If the target is within range, it will be the last corner and have a polygon reference id of zero.
*/
int dtPathCorridor::findCorners(float* cornerVerts, unsigned char* cornerFlags,
dtPolyRef* cornerPolys, const int maxCorners,
dtNavMeshQuery* navquery, const dtQueryFilter* /*filter*/,
int options )
{
dtAssert(m_path);
dtAssert(m_npath);
static const float MIN_TARGET_DIST = 0.01f;
int ncorners = 0;
navquery->findStraightPath(m_pos, m_target, m_path, m_npath,
cornerVerts, cornerFlags, cornerPolys, &ncorners, maxCorners, options);
// Prune points in the beginning of the path which are too close.
while (ncorners)
{
if ((cornerFlags[0] & DT_STRAIGHTPATH_OFFMESH_CONNECTION) ||
dtVdist2DSqr(&cornerVerts[0], m_pos) > dtSqr(MIN_TARGET_DIST))
break;
ncorners--;
if (ncorners)
{
memmove(cornerFlags, cornerFlags+1, sizeof(unsigned char)*ncorners);
memmove(cornerPolys, cornerPolys+1, sizeof(dtPolyRef)*ncorners);
memmove(cornerVerts, cornerVerts+3, sizeof(float)*3*ncorners);
}
}
// Prune points after an off-mesh connection.
/*for (int i = 0; i < ncorners; ++i)
{
if (cornerFlags[i] & DT_STRAIGHTPATH_OFFMESH_CONNECTION)
{
ncorners = i+1;
break;
}
}*/
return ncorners;
}
示例14: dtAssert
void dtPathCorridor::pruneOffmeshConenction(dtPolyRef offMeshConRef)
{
dtAssert(m_path);
dtAssert(m_npath);
// Advance the path up to and over the off-mesh connection.
dtPolyRef polyRef = m_path[0];
int npos = 0;
while (npos < m_npath && polyRef != offMeshConRef)
{
polyRef = m_path[npos];
npos++;
}
// Prune path
if (npos != m_npath)
{
for (int i = npos; i < m_npath; ++i)
m_path[i - npos] = m_path[i];
m_npath -= npos;
}
}
示例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);
}