MCPcopy Create free account
hub / github.com/axmolengine/axmol / moveAgents

Method moveAgents

tests/cpp-tests/Source/NavMeshTest/NavMeshTest.cpp:224–258  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

222}
223
224void NavMeshBaseTestDemo::moveAgents(const ax::Vec3& des)
225{
226 for (auto&& iter : _agents)
227 {
228 NavMeshAgent::MoveCallback callback = [](NavMeshAgent* agent, float totalTimeAfterMove) {
229 AgentUserData* data = static_cast<AgentUserData*>(agent->getUserData());
230 if (agent->isOnOffMeshLink())
231 {
232 agent->setAutoTraverseOffMeshLink(false);
233 agent->setAutoOrientation(false);
234 OffMeshLinkData linkdata = agent->getCurrentOffMeshLinkData();
235
236 agent->getOwner()->setPosition3D(
237 jump(&linkdata.startPosition, &linkdata.endPosition, 10.0f, data->time));
238 Vec3 dir = linkdata.endPosition - linkdata.startPosition;
239 dir.y = 0.0f;
240 dir.normalize();
241 Vec3 axes;
242 Vec3 refAxes = Vec3(-1.0f, 0.0f, 1.0f);
243 refAxes.normalize();
244 Vec3::cross(refAxes, dir, &axes);
245 float angle = Vec3::dot(refAxes, dir);
246 agent->getOwner()->setRotationQuat(Quaternion(axes, acosf(angle)));
247 data->time += 0.01f;
248 if (1.0f < data->time)
249 {
250 agent->completeOffMeshLink();
251 agent->setAutoOrientation(true);
252 data->time = 0.0f;
253 }
254 }
255 };
256 iter.first->move(des, callback);
257 }
258}
259
260void NavMeshBaseTestDemo::update(float delta)
261{

Callers

nothing calls this directly

Calls 15

jumpFunction · 0.85
isOnOffMeshLinkMethod · 0.80
setAutoOrientationMethod · 0.80
completeOffMeshLinkMethod · 0.80
Vec3Function · 0.50
crossFunction · 0.50
dotFunction · 0.50
QuaternionClass · 0.50
getUserDataMethod · 0.45
setPosition3DMethod · 0.45

Tested by

no test coverage detected