本文整理汇总了C++中dtVset函数的典型用法代码示例。如果您正苦于以下问题:C++ dtVset函数的具体用法?C++ dtVset怎么用?C++ dtVset使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dtVset函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: dtVset
bool dtCrowd::updateAgentPosition(unsigned id, const float* position)
{
if (id < m_maxAgents)
{
dtCrowdAgent& ag = m_agents[id];
dtPolyRef ref = 0;
float nearestPosition[] = {0, 0, 0};
if (dtStatusFailed(m_crowdQuery->getNavMeshQuery()->findNearestPoly(position, m_crowdQuery->getQueryExtents(), m_crowdQuery->getQueryFilter(), &ref, nearestPosition)))
return false;
// If no polygons have been found, it's a failure
if (ref == 0)
return false;
dtVset(ag.desiredVelocity, 0, 0, 0);
dtVset(ag.velocity, 0, 0, 0);
dtVcopy(ag.position, nearestPosition);
ag.state = DT_CROWDAGENT_STATE_WALKING;
return true;
}
return false;
}
开发者ID:MrMagne,项目名称:recastdetour,代码行数:26,代码来源:DetourCrowd.cpp
示例2: updateAgentParameters
/// @par
///
/// The agent's position will be constrained to the surface of the navigation mesh.
int dtCrowd::addAgent(const float* pos, const dtCrowdAgentParams* params)
{
// Find empty slot.
int idx = -1;
for (int i = 0; i < m_maxAgents; ++i)
{
if (!m_agents[i].active)
{
idx = i;
break;
}
}
if (idx == -1)
return -1;
dtCrowdAgent* ag = &m_agents[idx];
updateAgentParameters(idx, params);
// Find nearest position on navmesh and place the agent there.
float nearest[3];
dtPolyRef ref = 0;
dtVcopy(nearest, pos);
dtStatus status = m_navquery->findNearestPoly(pos, m_ext, &m_filters[ag->params.queryFilterType], &ref, nearest);
if (dtStatusFailed(status))
{
dtVcopy(nearest, pos);
ref = 0;
}
ag->corridor.reset(ref, nearest);
ag->boundary.reset();
ag->partial = false;
ag->topologyOptTime = 0;
ag->targetReplanTime = 0;
ag->nneis = 0;
dtVset(ag->dvel, 0,0,0);
dtVset(ag->nvel, 0,0,0);
dtVset(ag->vel, 0,0,0);
dtVcopy(ag->npos, nearest);
ag->desiredSpeed = 0;
if (ref)
ag->state = DT_CROWDAGENT_STATE_WALKING;
else
ag->state = DT_CROWDAGENT_STATE_INVALID;
ag->targetState = DT_CROWDAGENT_TARGET_NONE;
ag->active = true;
// Clockwork: added to fix illegal memory access when ncorners is queried before the agent has updated
ag->ncorners = 0;
return idx;
}
开发者ID:ElishaMcNutt,项目名称:Clockwork,代码行数:62,代码来源:DetourCrowd.cpp
示例3: updateAgentFilter
/// @par
///
/// The agent's position will be constrained to the surface of the navigation mesh.
int dtCrowd::addAgent(const float* pos, const dtCrowdAgentParams* params, const dtQueryFilter* filter)
{
// Find empty slot.
int idx = -1;
for (int i = 0; i < m_maxAgents; ++i)
{
if (!m_agents[i].active)
{
idx = i;
break;
}
}
if (idx == -1)
return -1;
dtCrowdAgent* ag = &m_agents[idx];
// [UE4] multiple filter support
const bool bStoredFilter = updateAgentFilter(idx, filter);
if (!bStoredFilter)
{
return -1;
}
// Find nearest position on navmesh and place the agent there.
float nearest[3];
dtPolyRef ref;
m_navquery->updateLinkFilter(params->linkFilter);
m_navquery->findNearestPoly(pos, m_ext, &m_filters[ag->params.filter], &ref, nearest);
ag->corridor.reset(ref, nearest);
ag->boundary.reset();
updateAgentParameters(idx, params);
ag->topologyOptTime = 0;
ag->targetReplanTime = 0;
ag->nneis = 0;
ag->ncorners = 0;
dtVset(ag->dvel, 0,0,0);
dtVset(ag->nvel, 0,0,0);
dtVset(ag->vel, 0,0,0);
dtVcopy(ag->npos, nearest);
ag->desiredSpeed = 0;
if (ref)
ag->state = DT_CROWDAGENT_STATE_WALKING;
else
ag->state = DT_CROWDAGENT_STATE_INVALID;
ag->targetState = DT_CROWDAGENT_TARGET_NONE;
ag->active = 1;
return idx;
}
开发者ID:1vanK,项目名称:AHRUnrealEngine,代码行数:61,代码来源:DetourCrowd.cpp
示例4: dtVset
bool dtCrowd::resetAgentVelocity(const int idx)
{
if (idx < 0 || idx > m_maxAgents)
return false;
dtCrowdAgent* ag = &m_agents[idx];
dtVset(ag->nvel, 0, 0, 0);
dtVset(ag->vel, 0, 0, 0);
dtVset(ag->dvel, 0, 0, 0);
return true;
}
开发者ID:1vanK,项目名称:AHRUnrealEngine,代码行数:11,代码来源:DetourCrowd.cpp
示例5: updateAgentParameters
int dtCrowd::addAgent(const float* pos, const dtCrowdAgentParams* params)
{
// Find empty slot.
int idx = -1;
for (int i = 0; i < m_maxAgents; ++i)
{
if (!m_agents[i].active)
{
idx = i;
break;
}
}
if (idx == -1)
return -1;
dtCrowdAgent* ag = &m_agents[idx];
// Find nearest position on navmesh and place the agent there.
float nearest[3];
dtPolyRef ref;
m_navquery->findNearestPoly(pos, m_ext, &m_filter, &ref, nearest);
if (!ref)
{
// Could not find a location on navmesh.
return -1;
}
ag->corridor.reset(ref, nearest);
ag->boundary.reset();
updateAgentParameters(idx, params);
ag->topologyOptTime = 0;
ag->nneis = 0;
dtVset(ag->dvel, 0,0,0);
dtVset(ag->nvel, 0,0,0);
dtVset(ag->vel, 0,0,0);
dtVcopy(ag->npos, nearest);
ag->desiredSpeed = 0;
ag->t = 0;
ag->var = (rand() % 10) / 9.0f;
ag->state = DT_CROWDAGENT_STATE_WALKING;
ag->active = 1;
return idx;
}
开发者ID:120pulsations,项目名称:SDK,代码行数:49,代码来源:DetourCrowd.cpp
示例6: integrate
static void integrate(dtCrowdAgent* ag, const float dt)
{
if (dtVlen(ag->velocity) > EPSILON)
dtVmad(ag->position, ag->position, ag->velocity, dt);
else
dtVset(ag->velocity,0,0,0);
}
开发者ID:MrMagne,项目名称:recastdetour,代码行数:7,代码来源:DetourCrowd.cpp
示例7: calcSmoothSteerDirection
static void calcSmoothSteerDirection(const dtCrowdAgent* ag, float* dir)
{
if (!ag->ncorners)
{
dtVset(dir, 0,0,0);
return;
}
const int ip0 = 0;
const int ip1 = dtMin(1, ag->ncorners-1);
const float* p0 = &ag->cornerVerts[ip0*3];
const float* p1 = &ag->cornerVerts[ip1*3];
float dir0[3], dir1[3];
dtVsub(dir0, p0, ag->npos);
dtVsub(dir1, p1, ag->npos);
dir0[1] = 0;
dir1[1] = 0;
float len0 = dtVlen(dir0);
float len1 = dtVlen(dir1);
if (len1 > 0.001f)
dtVscale(dir1,dir1,1.0f/len1);
dir[0] = dir0[0] - dir1[0]*len0*0.5f;
dir[1] = 0;
dir[2] = dir0[2] - dir1[2]*len0*0.5f;
dtVnormalize(dir);
}
开发者ID:Craz3dBanana,项目名称:recastnavigation,代码行数:30,代码来源:DetourCrowd.cpp
示例8: getAgentIndex
void dtCrowd::updateStepOffMeshAnim(const float dt, dtCrowdAgentDebugInfo*)
{
for (int i = 0; i < m_numActiveAgents; ++i)
{
dtCrowdAgent* ag = m_activeAgents[i];
const int agentIndex = getAgentIndex(ag);
dtCrowdAgentAnimation* anim = &m_agentAnims[agentIndex];
if (!anim->active)
continue;
anim->t += dt;
if (anim->t > anim->tmax)
{
// Reset animation
anim->active = 0;
// Prepare agent for walking.
ag->state = DT_CROWDAGENT_STATE_WALKING;
// UE4: m_keepOffmeshConnections support
if (m_keepOffmeshConnections)
{
ag->corridor.pruneOffmeshConenction(anim->polyRef);
}
continue;
}
// Update position
const float ta = anim->tmax*0.15f;
const float tb = anim->tmax;
if (anim->t < ta)
{
const float u = tween(anim->t, 0.0, ta);
dtVlerp(ag->npos, anim->initPos, anim->startPos, u);
}
else
{
const float u = tween(anim->t, ta, tb);
dtVlerp(ag->npos, anim->startPos, anim->endPos, u);
}
// Update velocity.
dtVset(ag->vel, 0, 0, 0);
dtVset(ag->dvel, 0, 0, 0);
}
}
开发者ID:1vanK,项目名称:AHRUnrealEngine,代码行数:47,代码来源:DetourCrowd.cpp
示例9: m_nsegs
dtLocalBoundary::dtLocalBoundary() :
m_nsegs(0),
m_npolys(0)
{
dtVset(m_center, FLT_MAX,FLT_MAX,FLT_MAX);
// Urho3D: initialize all class members
memset(&m_segs, 0, sizeof(m_segs));
memset(&m_polys, 0, sizeof(m_polys));
}
开发者ID:03050903,项目名称:Urho3D,代码行数:10,代码来源:DetourLocalBoundary.cpp
示例10: calcStraightSteerDirection
static void calcStraightSteerDirection(const dtCrowdAgent* ag, float* dir)
{
if (!ag->ncorners)
{
dtVset(dir, 0,0,0);
return;
}
dtVsub(dir, &ag->cornerVerts[0], ag->npos);
dir[1] = 0;
dtVnormalize(dir);
}
开发者ID:Craz3dBanana,项目名称:recastnavigation,代码行数:11,代码来源:DetourCrowd.cpp
示例11: prepare
int dtObstacleAvoidanceQuery::sampleVelocityGrid(const float* pos, const float rad, const float vmax,
const float* vel, const float* dvel, float* nvel,
const dtObstacleAvoidanceParams* params,
dtObstacleAvoidanceDebugData* debug)
{
prepare(pos, dvel);
memcpy(&m_params, params, sizeof(dtObstacleAvoidanceParams));
m_invHorizTime = 1.0f / m_params.horizTime;
m_vmax = vmax;
m_invVmax = vmax > 0 ? 1.0f / vmax : FLT_MAX;
dtVset(nvel, 0,0,0);
if (debug)
debug->reset();
const float cvx = dvel[0] * m_params.velBias;
const float cvz = dvel[2] * m_params.velBias;
const float cs = vmax * 2 * (1 - m_params.velBias) / (float)(m_params.gridSize-1);
const float half = (m_params.gridSize-1)*cs*0.5f;
float minPenalty = FLT_MAX;
int ns = 0;
for (int y = 0; y < m_params.gridSize; ++y)
{
for (int x = 0; x < m_params.gridSize; ++x)
{
float vcand[3];
vcand[0] = cvx + x*cs - half;
vcand[1] = 0;
vcand[2] = cvz + y*cs - half;
if (dtSqr(vcand[0])+dtSqr(vcand[2]) > dtSqr(vmax+cs/2)) continue;
const float penalty = processSample(vcand, cs, pos,rad,vel,dvel, minPenalty, debug);
ns++;
if (penalty < minPenalty)
{
minPenalty = penalty;
dtVcopy(nvel, vcand);
}
}
}
return ns;
}
开发者ID:Orav,项目名称:kbengine,代码行数:48,代码来源:DetourObstacleAvoidance.cpp
示例12: dtVset
bool dtCrowd::resetMoveTarget(const int idx)
{
if (idx < 0 || idx >= m_maxAgents)
return false;
dtCrowdAgent* ag = &m_agents[idx];
// Initialize request.
ag->targetRef = 0;
dtVset(ag->targetPos, 0,0,0);
ag->targetPathqRef = DT_PATHQ_INVALID;
ag->targetReplan = false;
ag->targetState = DT_CROWDAGENT_TARGET_NONE;
return true;
}
开发者ID:Craz3dBanana,项目名称:recastnavigation,代码行数:16,代码来源:DetourCrowd.cpp
示例13: integrate
static void integrate(dtCrowdAgent* ag, const float dt)
{
// Fake dynamic constraint.
const float maxDelta = ag->params.maxAcceleration * dt;
float dv[3];
dtVsub(dv, ag->nvel, ag->vel);
float ds = dtVlen(dv);
if (ds > maxDelta)
dtVscale(dv, dv, maxDelta/ds);
dtVadd(ag->vel, ag->vel, dv);
// Integrate
if (dtVlen(ag->vel) > 0.0001f)
dtVmad(ag->npos, ag->npos, ag->vel, dt);
else
dtVset(ag->vel,0,0,0);
}
开发者ID:Craz3dBanana,项目名称:recastnavigation,代码行数:17,代码来源:DetourCrowd.cpp
示例14: prepare
void dtObstacleAvoidanceQuery::sampleVelocityGrid(const float* pos, const float rad, const float vmax,
const float* vel, const float* dvel,
float* nvel, const int gsize,
dtObstacleAvoidanceDebugData* debug)
{
prepare(pos, dvel);
dtVset(nvel, 0,0,0);
if (debug)
debug->reset();
const float cvx = dvel[0] * m_velBias;
const float cvz = dvel[2] * m_velBias;
const float cs = vmax * 2 * (1 - m_velBias) / (float)(gsize-1);
const float half = (gsize-1)*cs*0.5f;
float minPenalty = FLT_MAX;
for (int y = 0; y < gsize; ++y)
{
for (int x = 0; x < gsize; ++x)
{
float vcand[3];
vcand[0] = cvx + x*cs - half;
vcand[1] = 0;
vcand[2] = cvz + y*cs - half;
if (dtSqr(vcand[0])+dtSqr(vcand[2]) > dtSqr(vmax+cs/2)) continue;
const float penalty = processSample(vcand, cs, pos,rad,vmax,vel,dvel, debug);
if (penalty < minPenalty)
{
minPenalty = penalty;
dtVcopy(nvel, vcand);
}
}
}
}
开发者ID:Sandshroud,项目名称:Sandshroud-Prodigy,代码行数:39,代码来源:DetourObstacleAvoidance.cpp
示例15: dtVscale
void dtSeekBehavior::applyForce(const dtCrowdAgent* oldAgent, dtCrowdAgent* newAgent, float* force, float dt)
{
float tmpForce[] = {0, 0, 0};
float newVelocity[] = {0, 0, 0};
const dtCrowdAgent* target = m_agentParams[oldAgent->id]->targetID;
const float distance = m_agentParams[oldAgent->id]->seekDistance;
// Adapting the force to the dt and the previous velocity
dtVscale(tmpForce, force, dt);
dtVadd(newVelocity, oldAgent->vel, tmpForce);
float currentSpeed = dtVlen(oldAgent->vel);
// Required distance to reach nil speed according to the acceleration and current speed
float slowDist = currentSpeed * (currentSpeed - 0) / oldAgent->params.maxAcceleration;
float distToObj = dtVdist(oldAgent->npos, target->npos) - oldAgent->params.radius - target->params.radius - distance;
// If we have reached the target, we stop
if (distToObj <= EPSILON)
{
dtVset(newVelocity, 0, 0, 0);
newAgent->desiredSpeed = 0.f;
}
// If the have to slow down
else if (distToObj < slowDist)
{
float slowDownRadius = distToObj / slowDist;
dtVscale(newVelocity, newVelocity, slowDownRadius);
newAgent->desiredSpeed = dtVlen(newVelocity);
}
// Else, we move as fast as possible
else
newAgent->desiredSpeed = oldAgent->params.maxSpeed;
// Check for maximal speed
dtVclamp(newVelocity, dtVlen(newVelocity), oldAgent->params.maxSpeed);
dtVcopy(newAgent->dvel, newVelocity);
}
开发者ID:Conglang,项目名称:recastdetour,代码行数:38,代码来源:DetourSeekBehavior.cpp
示例16: dtVset
void dtLocalBoundary::update(dtPolyRef ref, const float* pos, const float collisionQueryRange,
dtNavMeshQuery* navquery, const dtQueryFilter* filter)
{
static const int MAX_SEGS_PER_POLY = DT_VERTS_PER_POLYGON*3;
if (!ref)
{
dtVset(m_center, FLT_MAX,FLT_MAX,FLT_MAX);
m_nsegs = 0;
m_npolys = 0;
return;
}
dtVcopy(m_center, pos);
// First query non-overlapping polygons.
navquery->findLocalNeighbourhood(ref, pos, collisionQueryRange,
filter, m_polys, 0, &m_npolys, MAX_LOCAL_POLYS);
// Secondly, store all polygon edges.
m_nsegs = 0;
float segs[MAX_SEGS_PER_POLY*6];
int nsegs = 0;
for (int j = 0; j < m_npolys; ++j)
{
navquery->getPolyWallSegments(m_polys[j], filter, segs, 0, &nsegs, MAX_SEGS_PER_POLY);
for (int k = 0; k < nsegs; ++k)
{
const float* s = &segs[k*6];
// Skip too distant segments.
float tseg;
const float distSqr = dtDistancePtSegSqr2D(pos, s, s+3, tseg);
if (distSqr > dtSqr(collisionQueryRange))
continue;
addSegment(distSqr, s);
}
}
}
开发者ID:03050903,项目名称:Torque3D,代码行数:38,代码来源:DetourLocalBoundary.cpp
示例17: dtCreateNavMeshData
//.........这里部分代码省略.........
if (j == 2) t[3] |= (1<<0);
if (j == nv-1) t[3] |= (1<<4);
tbase++;
}
}
}
// Store and create BVtree.
if (params->buildBvTree)
{
createBVTree(params->verts, params->vertCount, params->polys, params->polyCount, nvp,
navDMeshes, navDVerts, navDTris, params->bmin,
params->cs, params->ch, params->polyCount*2, navBvtree);
}
// Store Off-Mesh connections.
n = 0;
nseg = 0;
for (int i = 0; i < params->offMeshConCount; ++i)
{
const dtOffMeshLinkCreateParams& offMeshCon = params->offMeshCons[i];
// Only store connections which start from this tile.
if (offMeshConClass[i*2+0] == 0xff)
{
if (offMeshCon.type & DT_OFFMESH_CON_POINT)
{
dtOffMeshConnection* con = &offMeshCons[n];
con->poly = (unsigned short)(offMeshPolyBase + n);
// Copy connection end-points.
dtVcopy(&con->pos[0], &offMeshCon.vertsA0[0]);
dtVcopy(&con->pos[3], &offMeshCon.vertsB0[0]);
con->rad = offMeshCon.snapRadius;
con->height = offMeshCon.snapHeight;
con->setFlags(offMeshCon.type);
con->side = offMeshConClass[i*2+1] == 0xff ? DT_CONNECTION_INTERNAL : offMeshConClass[i*2+1];
if (offMeshCon.userID)
con->userId = offMeshCon.userID;
n++;
}
else
{
dtOffMeshSegmentConnection* con = &offMeshSegs[nseg];
dtVcopy(con->startA, &offMeshCon.vertsA0[0]);
dtVcopy(con->endA, &offMeshCon.vertsA1[0]);
dtVcopy(con->startB, &offMeshCon.vertsB0[0]);
dtVcopy(con->endB, &offMeshCon.vertsB1[0]);
con->rad = offMeshCon.snapRadius;
con->height = offMeshCon.snapHeight;
con->setFlags(offMeshCon.type);
if (offMeshCon.userID)
con->userId = offMeshCon.userID;
nseg++;
}
}
}
dtFree(offMeshConClass);
// Store clusters
if (params->polyClusters)
{
memcpy(polyClusters, params->polyClusters, sizeof(unsigned short)*params->polyCount);
}
for (int i = 0; i < params->clusterCount; i++)
{
dtCluster& cluster = clusters[i];
cluster.firstLink = DT_NULL_LINK;
cluster.numLinks = 0;
dtVset(cluster.center, 0.f, 0.f, 0.f);
// calculate center point: take from first poly
for (int j = 0; j < params->polyCount; j++)
{
if (polyClusters[j] != i)
{
continue;
}
const dtPoly* poly = &navPolys[j];
float c[3] = { 0.0f, 0.0f, 0.0f };
for (int iv = 0; iv < poly->vertCount; iv++)
{
dtVadd(c, c, &navVerts[poly->verts[iv] * 3]);
}
dtVmad(cluster.center, cluster.center, c, 1.0f / poly->vertCount);
break;
}
}
*outData = data;
*outDataSize = dataSize;
return true;
}
开发者ID:johndpope,项目名称:UE4,代码行数:101,代码来源:DetourNavMeshBuilder.cpp
示例18: m_nsegs
dtLocalBoundary::dtLocalBoundary() :
m_nsegs(0),
m_npolys(0)
{
dtVset(m_center, FLT_MAX,FLT_MAX,FLT_MAX);
}
开发者ID:03050903,项目名称:Torque3D,代码行数:6,代码来源:DetourLocalBoundary.cpp
示例19: integrate
void dtCrowd::updateStepMove(const float dt, dtCrowdAgentDebugInfo*)
{
// Integrate.
for (int i = 0; i < m_numActiveAgents; ++i)
{
dtCrowdAgent* ag = m_activeAgents[i];
if (ag->state != DT_CROWDAGENT_STATE_WALKING)
continue;
integrate(ag, dt);
}
// Handle collisions.
static const float COLLISION_RESOLVE_FACTOR = 0.7f;
for (int iter = 0; iter < 4; ++iter)
{
for (int i = 0; i < m_numActiveAgents; ++i)
{
dtCrowdAgent* ag = m_activeAgents[i];
const int idx0 = getAgentIndex(ag);
if (ag->state != DT_CROWDAGENT_STATE_WALKING)
continue;
dtVset(ag->disp, 0, 0, 0);
float w = 0;
for (int j = 0; j < ag->nneis; ++j)
{
const dtCrowdAgent* nei = &m_agents[ag->neis[j].idx];
const int idx1 = getAgentIndex(nei);
float diff[3];
dtVsub(diff, ag->npos, nei->npos);
diff[1] = 0;
float dist = dtVlenSqr(diff);
if (dist > dtSqr(ag->params.radius + nei->params.radius))
continue;
dist = sqrtf(dist);
float pen = (ag->params.radius + nei->params.radius) - dist;
if (dist < 0.0001f)
{
// m_activeAgents on top of each other, try to choose diverging separation directions.
if (idx0 > idx1)
dtVset(diff, -ag->dvel[2], 0, ag->dvel[0]);
else
dtVset(diff, ag->dvel[2], 0, -ag->dvel[0]);
pen = 0.01f;
}
else
{
pen = (1.0f / dist) * (pen*0.5f) * COLLISION_RESOLVE_FACTOR;
}
dtVmad(ag->disp, ag->disp, diff, pen);
w += 1.0f;
}
if (w > 0.0001f)
{
const float iw = 1.0f / w;
dtVscale(ag->disp, ag->disp, iw);
}
}
for (int i = 0; i < m_numActiveAgents; ++i)
{
dtCrowdAgent* ag = m_activeAgents[i];
if (ag->state != DT_CROWDAGENT_STATE_WALKING)
continue;
dtVadd(ag->npos, ag->npos, ag->disp);
}
}
}
开发者ID:1vanK,项目名称:AHRUnrealEngine,代码行数:78,代码来源:DetourCrowd.cpp
示例20: purge
/// @par
///
/// May be called more than once to purge and re-initialize the crowd.
bool dtCrowd::init(const int maxAgents, const float maxAgentRadius, dtNavMesh* nav)
{
purge();
m_maxAgents = maxAgents;
m_maxAgentRadius = maxAgentRadius;
m_numActiveAgents = 0;
dtVset(m_ext, m_maxAgentRadius*2.0f,m_maxAgentRadius*1.5f,m_maxAgentRadius*2.0f);
m_grid = dtAllocProximityGrid();
if (!m_grid)
return false;
if (!m_grid->init(m_maxAgents*4, maxAgentRadius*3))
return false;
// [UE4] moved avoidance query init to separate function
// Allocate temp buffer for merging paths.
m_maxPathResult = 256;
m_pathResult = (dtPolyRef*)dtAlloc(sizeof(dtPolyRef)*m_maxPathResult, DT_ALLOC_PERM);
if (!m_pathResult)
return false;
if (!m_pathq.init(m_maxPathResult, MAX_PATHQUEUE_NODES, nav))
return false;
m_agents = (dtCrowdAgent*)dtAlloc(sizeof(dtCrowdAgent)*m_maxAgents, DT_ALLOC_PERM);
if (!m_agents)
return false;
m_activeAgents = (dtCrowdAgent**)dtAlloc(sizeof(dtCrowdAgent*)*m_maxAgents, DT_ALLOC_PERM);
if (!m_activeAgents)
return false;
m_agentAnims = (dtCrowdAgentAnimation*)dtAlloc(sizeof(dtCrowdAgentAnimation)*m_maxAgents, DT_ALLOC_PERM);
if (!m_agentAnims)
return false;
for (int i = 0; i < m_maxAgents; ++i)
{
new(&m_agents[i]) dtCrowdAgent();
m_agents[i].active = 0;
if (!m_agents[i].corridor.init(m_maxPathResult))
return false;
}
for (int i = 0; i < m_maxAgents; ++i)
{
m_agentAnims[i].active = 0;
}
for (int i = 0; i < DT_MAX_AREAS; i++)
{
m_raycastFilter.setAreaCost(i, DT_UNWALKABLE_POLY_COST);
}
// The navquery is mostly used for local searches, no need for large node pool.
m_navquery = dtAllocNavMeshQuery();
if (!m_navquery)
return false;
if (dtStatusFailed(m_navquery->init(nav, MAX_COMMON_NODES)))
return false;
return true;
}
开发者ID:1vanK,项目名称:AHRUnrealEngine,代码行数:69,代码来源:DetourCrowd.cpp
注:本文中的dtVset函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论