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

Method updateState

tests/cpp-tests/Source/Camera3DTest/Camera3DTest.cpp:463–492  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

461 }
462}
463void Camera3DTestDemo::updateState(float elapsedTime)
464{
465 if (_mesh)
466 {
467 Vec3 curPos = _mesh->getPosition3D();
468 Vec3 curFaceDir;
469 _mesh->getNodeToWorldTransform().getForwardVector(&curFaceDir);
470 curFaceDir = -curFaceDir;
471 curFaceDir.normalize();
472 Vec3 newFaceDir = _targetPos - curPos;
473 newFaceDir.y = 0.0f;
474 newFaceDir.normalize();
475 float cosAngle = std::fabs(Vec3::dot(curFaceDir, newFaceDir) - 1.0f);
476 float dist = curPos.distanceSquared(_targetPos);
477 if (dist <= 4.0f)
478 {
479 if (cosAngle <= 0.01f)
480 _curState = State_Idle;
481 else
482 _curState = State_Rotate;
483 }
484 else
485 {
486 if (cosAngle > 0.01f)
487 _curState = State_Rotate | State_Move;
488 else
489 _curState = State_Move;
490 }
491 }
492}
493void Camera3DTestDemo::onTouchesEnded(const std::vector<Touch*>& touches, ax::Event* event)
494{
495 for (auto& item : touches)

Callers

nothing calls this directly

Calls 7

fabsFunction · 0.85
dotFunction · 0.50
getPosition3DMethod · 0.45
getForwardVectorMethod · 0.45
normalizeMethod · 0.45
distanceSquaredMethod · 0.45

Tested by

no test coverage detected