Navigation.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508
  1. //
  2. // Copyright (c) 2008-2017 the Urho3D project.
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to deal
  6. // in the Software without restriction, including without limitation the rights
  7. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. // copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. // THE SOFTWARE.
  21. //
  22. #include <Urho3D/Core/CoreEvents.h>
  23. #include <Urho3D/Engine/Engine.h>
  24. #include <Urho3D/Graphics/AnimatedModel.h>
  25. #include <Urho3D/Graphics/Camera.h>
  26. #include <Urho3D/Graphics/DebugRenderer.h>
  27. #include <Urho3D/Graphics/Graphics.h>
  28. #include <Urho3D/Graphics/Light.h>
  29. #include <Urho3D/Graphics/Material.h>
  30. #include <Urho3D/Graphics/Octree.h>
  31. #include <Urho3D/Graphics/Renderer.h>
  32. #include <Urho3D/Graphics/Zone.h>
  33. #include <Urho3D/Input/Input.h>
  34. #include <Urho3D/Navigation/Navigable.h>
  35. #include <Urho3D/Navigation/NavigationMesh.h>
  36. #include <Urho3D/Resource/ResourceCache.h>
  37. #include <Urho3D/Scene/Scene.h>
  38. #include <Urho3D/UI/Font.h>
  39. #include <Urho3D/UI/Text.h>
  40. #include <Urho3D/UI/UI.h>
  41. #include "Navigation.h"
  42. #include <Urho3D/DebugNew.h>
  43. URHO3D_DEFINE_APPLICATION_MAIN(Navigation)
  44. Navigation::Navigation(Context* context) :
  45. Sample(context),
  46. drawDebug_(false),
  47. useStreaming_(false),
  48. streamingDistance_(2)
  49. {
  50. }
  51. void Navigation::Start()
  52. {
  53. // Execute base class startup
  54. Sample::Start();
  55. // Create the scene content
  56. CreateScene();
  57. // Create the UI content
  58. CreateUI();
  59. // Setup the viewport for displaying the scene
  60. SetupViewport();
  61. // Hook up to the frame update and render post-update events
  62. SubscribeToEvents();
  63. // Set the mouse mode to use in the sample
  64. Sample::InitMouseMode(MM_RELATIVE);
  65. }
  66. void Navigation::CreateScene()
  67. {
  68. auto* cache = GetSubsystem<ResourceCache>();
  69. scene_ = new Scene(context_);
  70. // Create octree, use default volume (-1000, -1000, -1000) to (1000, 1000, 1000)
  71. // Also create a DebugRenderer component so that we can draw debug geometry
  72. scene_->CreateComponent<Octree>();
  73. scene_->CreateComponent<DebugRenderer>();
  74. // Create scene node & StaticModel component for showing a static plane
  75. Node* planeNode = scene_->CreateChild("Plane");
  76. planeNode->SetScale(Vector3(100.0f, 1.0f, 100.0f));
  77. auto* planeObject = planeNode->CreateComponent<StaticModel>();
  78. planeObject->SetModel(cache->GetResource<Model>("Models/Plane.mdl"));
  79. planeObject->SetMaterial(cache->GetResource<Material>("Materials/StoneTiled.xml"));
  80. // Create a Zone component for ambient lighting & fog control
  81. Node* zoneNode = scene_->CreateChild("Zone");
  82. auto* zone = zoneNode->CreateComponent<Zone>();
  83. zone->SetBoundingBox(BoundingBox(-1000.0f, 1000.0f));
  84. zone->SetAmbientColor(Color(0.15f, 0.15f, 0.15f));
  85. zone->SetFogColor(Color(0.5f, 0.5f, 0.7f));
  86. zone->SetFogStart(100.0f);
  87. zone->SetFogEnd(300.0f);
  88. // Create a directional light to the world. Enable cascaded shadows on it
  89. Node* lightNode = scene_->CreateChild("DirectionalLight");
  90. lightNode->SetDirection(Vector3(0.6f, -1.0f, 0.8f));
  91. auto* light = lightNode->CreateComponent<Light>();
  92. light->SetLightType(LIGHT_DIRECTIONAL);
  93. light->SetCastShadows(true);
  94. light->SetShadowBias(BiasParameters(0.00025f, 0.5f));
  95. // Set cascade splits at 10, 50 and 200 world units, fade shadows out at 80% of maximum shadow distance
  96. light->SetShadowCascade(CascadeParameters(10.0f, 50.0f, 200.0f, 0.0f, 0.8f));
  97. // Create some mushrooms
  98. const unsigned NUM_MUSHROOMS = 100;
  99. for (unsigned i = 0; i < NUM_MUSHROOMS; ++i)
  100. CreateMushroom(Vector3(Random(90.0f) - 45.0f, 0.0f, Random(90.0f) - 45.0f));
  101. // Create randomly sized boxes. If boxes are big enough, make them occluders
  102. const unsigned NUM_BOXES = 20;
  103. for (unsigned i = 0; i < NUM_BOXES; ++i)
  104. {
  105. Node* boxNode = scene_->CreateChild("Box");
  106. float size = 1.0f + Random(10.0f);
  107. boxNode->SetPosition(Vector3(Random(80.0f) - 40.0f, size * 0.5f, Random(80.0f) - 40.0f));
  108. boxNode->SetScale(size);
  109. auto* boxObject = boxNode->CreateComponent<StaticModel>();
  110. boxObject->SetModel(cache->GetResource<Model>("Models/Box.mdl"));
  111. boxObject->SetMaterial(cache->GetResource<Material>("Materials/Stone.xml"));
  112. boxObject->SetCastShadows(true);
  113. if (size >= 3.0f)
  114. boxObject->SetOccluder(true);
  115. }
  116. // Create Jack node that will follow the path
  117. jackNode_ = scene_->CreateChild("Jack");
  118. jackNode_->SetPosition(Vector3(-5.0f, 0.0f, 20.0f));
  119. auto* modelObject = jackNode_->CreateComponent<AnimatedModel>();
  120. modelObject->SetModel(cache->GetResource<Model>("Models/Jack.mdl"));
  121. modelObject->SetMaterial(cache->GetResource<Material>("Materials/Jack.xml"));
  122. modelObject->SetCastShadows(true);
  123. // Create a NavigationMesh component to the scene root
  124. auto* navMesh = scene_->CreateComponent<NavigationMesh>();
  125. // Set small tiles to show navigation mesh streaming
  126. navMesh->SetTileSize(32);
  127. // Create a Navigable component to the scene root. This tags all of the geometry in the scene as being part of the
  128. // navigation mesh. By default this is recursive, but the recursion could be turned off from Navigable
  129. scene_->CreateComponent<Navigable>();
  130. // Add padding to the navigation mesh in Y-direction so that we can add objects on top of the tallest boxes
  131. // in the scene and still update the mesh correctly
  132. navMesh->SetPadding(Vector3(0.0f, 10.0f, 0.0f));
  133. // Now build the navigation geometry. This will take some time. Note that the navigation mesh will prefer to use
  134. // physics geometry from the scene nodes, as it often is simpler, but if it can not find any (like in this example)
  135. // it will use renderable geometry instead
  136. navMesh->Build();
  137. // Create the camera. Limit far clip distance to match the fog
  138. cameraNode_ = scene_->CreateChild("Camera");
  139. auto* camera = cameraNode_->CreateComponent<Camera>();
  140. camera->SetFarClip(300.0f);
  141. // Set an initial position for the camera scene node above the plane and looking down
  142. cameraNode_->SetPosition(Vector3(0.0f, 50.0f, 0.0f));
  143. pitch_ = 80.0f;
  144. cameraNode_->SetRotation(Quaternion(pitch_, yaw_, 0.0f));
  145. }
  146. void Navigation::CreateUI()
  147. {
  148. auto* cache = GetSubsystem<ResourceCache>();
  149. auto* ui = GetSubsystem<UI>();
  150. // Create a Cursor UI element because we want to be able to hide and show it at will. When hidden, the mouse cursor will
  151. // control the camera, and when visible, it will point the raycast target
  152. auto* style = cache->GetResource<XMLFile>("UI/DefaultStyle.xml");
  153. SharedPtr<Cursor> cursor(new Cursor(context_));
  154. cursor->SetStyleAuto(style);
  155. ui->SetCursor(cursor);
  156. // Set starting position of the cursor at the rendering window center
  157. auto* graphics = GetSubsystem<Graphics>();
  158. cursor->SetPosition(graphics->GetWidth() / 2, graphics->GetHeight() / 2);
  159. // Construct new Text object, set string to display and font to use
  160. auto* instructionText = ui->GetRoot()->CreateChild<Text>();
  161. instructionText->SetText(
  162. "Use WASD keys to move, RMB to rotate view\n"
  163. "LMB to set destination, SHIFT+LMB to teleport\n"
  164. "MMB or O key to add or remove obstacles\n"
  165. "Tab to toggle navigation mesh streaming\n"
  166. "Space to toggle debug geometry"
  167. );
  168. instructionText->SetFont(cache->GetResource<Font>("Fonts/Anonymous Pro.ttf"), 15);
  169. // The text has multiple rows. Center them in relation to each other
  170. instructionText->SetTextAlignment(HA_CENTER);
  171. // Position the text relative to the screen center
  172. instructionText->SetHorizontalAlignment(HA_CENTER);
  173. instructionText->SetVerticalAlignment(VA_CENTER);
  174. instructionText->SetPosition(0, ui->GetRoot()->GetHeight() / 4);
  175. }
  176. void Navigation::SetupViewport()
  177. {
  178. auto* renderer = GetSubsystem<Renderer>();
  179. // Set up a viewport to the Renderer subsystem so that the 3D scene can be seen
  180. SharedPtr<Viewport> viewport(new Viewport(context_, scene_, cameraNode_->GetComponent<Camera>()));
  181. renderer->SetViewport(0, viewport);
  182. }
  183. void Navigation::SubscribeToEvents()
  184. {
  185. // Subscribe HandleUpdate() function for processing update events
  186. SubscribeToEvent(E_UPDATE, URHO3D_HANDLER(Navigation, HandleUpdate));
  187. // Subscribe HandlePostRenderUpdate() function for processing the post-render update event, during which we request
  188. // debug geometry
  189. SubscribeToEvent(E_POSTRENDERUPDATE, URHO3D_HANDLER(Navigation, HandlePostRenderUpdate));
  190. }
  191. void Navigation::MoveCamera(float timeStep)
  192. {
  193. // Right mouse button controls mouse cursor visibility: hide when pressed
  194. auto* ui = GetSubsystem<UI>();
  195. auto* input = GetSubsystem<Input>();
  196. ui->GetCursor()->SetVisible(!input->GetMouseButtonDown(MOUSEB_RIGHT));
  197. // Do not move if the UI has a focused element (the console)
  198. if (ui->GetFocusElement())
  199. return;
  200. // Movement speed as world units per second
  201. const float MOVE_SPEED = 20.0f;
  202. // Mouse sensitivity as degrees per pixel
  203. const float MOUSE_SENSITIVITY = 0.1f;
  204. // Use this frame's mouse motion to adjust camera node yaw and pitch. Clamp the pitch between -90 and 90 degrees
  205. // Only move the camera when the cursor is hidden
  206. if (!ui->GetCursor()->IsVisible())
  207. {
  208. IntVector2 mouseMove = input->GetMouseMove();
  209. yaw_ += MOUSE_SENSITIVITY * mouseMove.x_;
  210. pitch_ += MOUSE_SENSITIVITY * mouseMove.y_;
  211. pitch_ = Clamp(pitch_, -90.0f, 90.0f);
  212. // Construct new orientation for the camera scene node from yaw and pitch. Roll is fixed to zero
  213. cameraNode_->SetRotation(Quaternion(pitch_, yaw_, 0.0f));
  214. }
  215. // Read WASD keys and move the camera scene node to the corresponding direction if they are pressed
  216. if (input->GetKeyDown(KEY_W))
  217. cameraNode_->Translate(Vector3::FORWARD * MOVE_SPEED * timeStep);
  218. if (input->GetKeyDown(KEY_S))
  219. cameraNode_->Translate(Vector3::BACK * MOVE_SPEED * timeStep);
  220. if (input->GetKeyDown(KEY_A))
  221. cameraNode_->Translate(Vector3::LEFT * MOVE_SPEED * timeStep);
  222. if (input->GetKeyDown(KEY_D))
  223. cameraNode_->Translate(Vector3::RIGHT * MOVE_SPEED * timeStep);
  224. // Set destination or teleport with left mouse button
  225. if (input->GetMouseButtonPress(MOUSEB_LEFT))
  226. SetPathPoint();
  227. // Add or remove objects with middle mouse button, then rebuild navigation mesh partially
  228. if (input->GetMouseButtonPress(MOUSEB_MIDDLE) || input->GetKeyPress(KEY_O))
  229. AddOrRemoveObject();
  230. // Toggle debug geometry with space
  231. if (input->GetKeyPress(KEY_SPACE))
  232. drawDebug_ = !drawDebug_;
  233. }
  234. void Navigation::SetPathPoint()
  235. {
  236. Vector3 hitPos;
  237. Drawable* hitDrawable;
  238. auto* navMesh = scene_->GetComponent<NavigationMesh>();
  239. if (Raycast(250.0f, hitPos, hitDrawable))
  240. {
  241. Vector3 pathPos = navMesh->FindNearestPoint(hitPos, Vector3(1.0f, 1.0f, 1.0f));
  242. if (GetSubsystem<Input>()->GetQualifierDown(QUAL_SHIFT))
  243. {
  244. // Teleport
  245. currentPath_.Clear();
  246. jackNode_->LookAt(Vector3(pathPos.x_, jackNode_->GetPosition().y_, pathPos.z_), Vector3::UP);
  247. jackNode_->SetPosition(pathPos);
  248. }
  249. else
  250. {
  251. // Calculate path from Jack's current position to the end point
  252. endPos_ = pathPos;
  253. navMesh->FindPath(currentPath_, jackNode_->GetPosition(), endPos_);
  254. }
  255. }
  256. }
  257. void Navigation::AddOrRemoveObject()
  258. {
  259. // Raycast and check if we hit a mushroom node. If yes, remove it, if no, create a new one
  260. Vector3 hitPos;
  261. Drawable* hitDrawable;
  262. if (!useStreaming_ && Raycast(250.0f, hitPos, hitDrawable))
  263. {
  264. // The part of the navigation mesh we must update, which is the world bounding box of the associated
  265. // drawable component
  266. BoundingBox updateBox;
  267. Node* hitNode = hitDrawable->GetNode();
  268. if (hitNode->GetName() == "Mushroom")
  269. {
  270. updateBox = hitDrawable->GetWorldBoundingBox();
  271. hitNode->Remove();
  272. }
  273. else
  274. {
  275. Node* newNode = CreateMushroom(hitPos);
  276. updateBox = newNode->GetComponent<StaticModel>()->GetWorldBoundingBox();
  277. }
  278. // Rebuild part of the navigation mesh, then recalculate path if applicable
  279. auto* navMesh = scene_->GetComponent<NavigationMesh>();
  280. navMesh->Build(updateBox);
  281. if (currentPath_.Size())
  282. navMesh->FindPath(currentPath_, jackNode_->GetPosition(), endPos_);
  283. }
  284. }
  285. Node* Navigation::CreateMushroom(const Vector3& pos)
  286. {
  287. auto* cache = GetSubsystem<ResourceCache>();
  288. Node* mushroomNode = scene_->CreateChild("Mushroom");
  289. mushroomNode->SetPosition(pos);
  290. mushroomNode->SetRotation(Quaternion(0.0f, Random(360.0f), 0.0f));
  291. mushroomNode->SetScale(2.0f + Random(0.5f));
  292. auto* mushroomObject = mushroomNode->CreateComponent<StaticModel>();
  293. mushroomObject->SetModel(cache->GetResource<Model>("Models/Mushroom.mdl"));
  294. mushroomObject->SetMaterial(cache->GetResource<Material>("Materials/Mushroom.xml"));
  295. mushroomObject->SetCastShadows(true);
  296. return mushroomNode;
  297. }
  298. bool Navigation::Raycast(float maxDistance, Vector3& hitPos, Drawable*& hitDrawable)
  299. {
  300. hitDrawable = nullptr;
  301. auto* ui = GetSubsystem<UI>();
  302. IntVector2 pos = ui->GetCursorPosition();
  303. // Check the cursor is visible and there is no UI element in front of the cursor
  304. if (!ui->GetCursor()->IsVisible() || ui->GetElementAt(pos, true))
  305. return false;
  306. auto* graphics = GetSubsystem<Graphics>();
  307. auto* camera = cameraNode_->GetComponent<Camera>();
  308. Ray cameraRay = camera->GetScreenRay((float)pos.x_ / graphics->GetWidth(), (float)pos.y_ / graphics->GetHeight());
  309. // Pick only geometry objects, not eg. zones or lights, only get the first (closest) hit
  310. PODVector<RayQueryResult> results;
  311. RayOctreeQuery query(results, cameraRay, RAY_TRIANGLE, maxDistance, DRAWABLE_GEOMETRY);
  312. scene_->GetComponent<Octree>()->RaycastSingle(query);
  313. if (results.Size())
  314. {
  315. RayQueryResult& result = results[0];
  316. hitPos = result.position_;
  317. hitDrawable = result.drawable_;
  318. return true;
  319. }
  320. return false;
  321. }
  322. void Navigation::FollowPath(float timeStep)
  323. {
  324. if (currentPath_.Size())
  325. {
  326. Vector3 nextWaypoint = currentPath_[0]; // NB: currentPath[0] is the next waypoint in order
  327. // Rotate Jack toward next waypoint to reach and move. Check for not overshooting the target
  328. float move = 5.0f * timeStep;
  329. float distance = (jackNode_->GetPosition() - nextWaypoint).Length();
  330. if (move > distance)
  331. move = distance;
  332. jackNode_->LookAt(nextWaypoint, Vector3::UP);
  333. jackNode_->Translate(Vector3::FORWARD * move);
  334. // Remove waypoint if reached it
  335. if (distance < 0.1f)
  336. currentPath_.Erase(0);
  337. }
  338. }
  339. void Navigation::ToggleStreaming(bool enabled)
  340. {
  341. auto* navMesh = scene_->GetComponent<NavigationMesh>();
  342. if (enabled)
  343. {
  344. int maxTiles = (2 * streamingDistance_ + 1) * (2 * streamingDistance_ + 1);
  345. BoundingBox boundingBox = navMesh->GetBoundingBox();
  346. SaveNavigationData();
  347. navMesh->Allocate(boundingBox, maxTiles);
  348. }
  349. else
  350. navMesh->Build();
  351. }
  352. void Navigation::UpdateStreaming()
  353. {
  354. // Center the navigation mesh at the jack
  355. auto* navMesh = scene_->GetComponent<NavigationMesh>();
  356. const IntVector2 jackTile = navMesh->GetTileIndex(jackNode_->GetWorldPosition());
  357. const IntVector2 numTiles = navMesh->GetNumTiles();
  358. const IntVector2 beginTile = VectorMax(IntVector2::ZERO, jackTile - IntVector2::ONE * streamingDistance_);
  359. const IntVector2 endTile = VectorMin(jackTile + IntVector2::ONE * streamingDistance_, numTiles - IntVector2::ONE);
  360. // Remove tiles
  361. for (HashSet<IntVector2>::Iterator i = addedTiles_.Begin(); i != addedTiles_.End();)
  362. {
  363. const IntVector2 tileIdx = *i;
  364. if (beginTile.x_ <= tileIdx.x_ && tileIdx.x_ <= endTile.x_ && beginTile.y_ <= tileIdx.y_ && tileIdx.y_ <= endTile.y_)
  365. ++i;
  366. else
  367. {
  368. navMesh->RemoveTile(tileIdx);
  369. i = addedTiles_.Erase(i);
  370. }
  371. }
  372. // Add tiles
  373. for (int z = beginTile.y_; z <= endTile.y_; ++z)
  374. for (int x = beginTile.x_; x <= endTile.x_; ++x)
  375. {
  376. const IntVector2 tileIdx(x, z);
  377. if (!navMesh->HasTile(tileIdx) && tileData_.Contains(tileIdx))
  378. {
  379. addedTiles_.Insert(tileIdx);
  380. navMesh->AddTile(tileData_[tileIdx]);
  381. }
  382. }
  383. }
  384. void Navigation::SaveNavigationData()
  385. {
  386. auto* navMesh = scene_->GetComponent<NavigationMesh>();
  387. tileData_.Clear();
  388. addedTiles_.Clear();
  389. const IntVector2 numTiles = navMesh->GetNumTiles();
  390. for (int z = 0; z < numTiles.y_; ++z)
  391. for (int x = 0; x <= numTiles.x_; ++x)
  392. {
  393. const IntVector2 tileIdx = IntVector2(x, z);
  394. tileData_[tileIdx] = navMesh->GetTileData(tileIdx);
  395. }
  396. }
  397. void Navigation::HandleUpdate(StringHash eventType, VariantMap& eventData)
  398. {
  399. using namespace Update;
  400. // Take the frame time step, which is stored as a float
  401. float timeStep = eventData[P_TIMESTEP].GetFloat();
  402. // Move the camera, scale movement with time step
  403. MoveCamera(timeStep);
  404. // Make Jack follow the Detour path
  405. FollowPath(timeStep);
  406. // Update streaming
  407. auto* input = GetSubsystem<Input>();
  408. if (input->GetKeyPress(KEY_TAB))
  409. {
  410. useStreaming_ = !useStreaming_;
  411. ToggleStreaming(useStreaming_);
  412. }
  413. if (useStreaming_)
  414. UpdateStreaming();
  415. }
  416. void Navigation::HandlePostRenderUpdate(StringHash eventType, VariantMap& eventData)
  417. {
  418. // If draw debug mode is enabled, draw navigation mesh debug geometry
  419. if (drawDebug_)
  420. scene_->GetComponent<NavigationMesh>()->DrawDebugGeometry(true);
  421. if (currentPath_.Size())
  422. {
  423. // Visualize the current calculated path
  424. auto* debug = scene_->GetComponent<DebugRenderer>();
  425. debug->AddBoundingBox(BoundingBox(endPos_ - Vector3(0.1f, 0.1f, 0.1f), endPos_ + Vector3(0.1f, 0.1f, 0.1f)),
  426. Color(1.0f, 1.0f, 1.0f));
  427. // Draw the path with a small upward bias so that it does not clip into the surfaces
  428. Vector3 bias(0.0f, 0.05f, 0.0f);
  429. debug->AddLine(jackNode_->GetPosition() + bias, currentPath_[0] + bias, Color(1.0f, 1.0f, 1.0f));
  430. if (currentPath_.Size() > 1)
  431. {
  432. for (unsigned i = 0; i < currentPath_.Size() - 1; ++i)
  433. debug->AddLine(currentPath_[i] + bias, currentPath_[i + 1] + bias, Color(1.0f, 1.0f, 1.0f));
  434. }
  435. }
  436. }