SceneView3D.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681
  1. // Portions Copyright (c) 2008-2015 the Urho3D project.
  2. //
  3. // Copyright (c) 2014-2016 THUNDERBEAST GAMES LLC
  4. //
  5. // Permission is hereby granted, free of charge, to any person obtaining a copy
  6. // of this software and associated documentation files (the "Software"), to deal
  7. // in the Software without restriction, including without limitation the rights
  8. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. // copies of the Software, and to permit persons to whom the Software is
  10. // furnished to do so, subject to the following conditions:
  11. //
  12. // The above copyright notice and this permission notice shall be included in
  13. // all copies or substantial portions of the Software.
  14. //
  15. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21. // THE SOFTWARE.
  22. //
  23. #include <Atomic/IO/Log.h>
  24. #include <Atomic/Core/CoreEvents.h>
  25. #include <Atomic/Scene/SceneEvents.h>
  26. #include <Atomic/Scene/Scene.h>
  27. #include <Atomic/Scene/PrefabComponent.h>
  28. #include <Atomic/Graphics/Camera.h>
  29. #include <Atomic/Graphics/Graphics.h>
  30. #include <Atomic/Graphics/DebugRenderer.h>
  31. #include <Atomic/Graphics/Viewport.h>
  32. #include <Atomic/Graphics/Octree.h>
  33. #include <Atomic/Graphics/Material.h>
  34. #include <Atomic/Atomic3D/Model.h>
  35. #include <Atomic/Atomic3D/StaticModel.h>
  36. #include <Atomic/Atomic3D/AnimatedModel.h>
  37. #include <Atomic/Atomic3D/AnimationController.h>
  38. #include <Atomic/Input/Input.h>
  39. #include <Atomic/IO/FileSystem.h>
  40. #include <Atomic/Resource/ResourceCache.h>
  41. #include <Atomic/Resource/XMLFile.h>
  42. #include <Atomic/Physics/PhysicsWorld.h>
  43. #include <Atomic/UI/UI.h>
  44. #include <Atomic/UI/UIEvents.h>
  45. #include <Atomic/Resource/ResourceEvents.h>
  46. #include <ToolCore/Assets/Asset.h>
  47. #include <ToolCore/Assets/AssetDatabase.h>
  48. #include "../../EditorMode/AEEditorEvents.h"
  49. #include "SceneView3D.h"
  50. #include "SceneEditor3D.h"
  51. #include "SceneEditor3DEvents.h"
  52. #include "SceneSelection.h"
  53. using namespace ToolCore;
  54. namespace AtomicEditor
  55. {
  56. SceneView3D ::SceneView3D(Context* context, SceneEditor3D *sceneEditor) :
  57. UISceneView(context),
  58. yaw_(0.0f),
  59. pitch_(0.0f),
  60. mouseLeftDown_(false),
  61. mouseMoved_(false),
  62. enabled_(true),
  63. cameraMove_(false)
  64. {
  65. sceneEditor_ = sceneEditor;
  66. ResourceCache* cache = GetSubsystem<ResourceCache>();
  67. scene_ = sceneEditor->GetScene();
  68. debugRenderer_ = scene_->GetComponent<DebugRenderer>();
  69. if (debugRenderer_.Null())
  70. {
  71. debugRenderer_ = scene_->CreateComponent<DebugRenderer>();
  72. debugRenderer_->SetTemporary(true);
  73. }
  74. octree_ = scene_->GetComponent<Octree>();
  75. if (octree_.Null())
  76. {
  77. LOGWARNING("Scene without an octree loaded");
  78. octree_ = scene_->CreateComponent<Octree>();
  79. }
  80. cameraNode_ = scene_->CreateChild("__atomic_sceneview3d_camera");
  81. cameraNode_->SetTemporary(true);
  82. camera_ = cameraNode_->CreateComponent<Camera>();
  83. debugRenderer_ = scene_->GetComponent<DebugRenderer>();
  84. assert(debugRenderer_.NotNull());
  85. octree_ = scene_->GetComponent<Octree>();
  86. assert(octree_.NotNull());
  87. cameraNode_->SetPosition(Vector3(0, 0, -10));
  88. SetView(scene_, camera_);
  89. SetAutoUpdate(false);
  90. SubscribeToEvent(E_UPDATE, HANDLER(SceneView3D, HandleUpdate));
  91. SubscribeToEvent(E_POSTRENDERUPDATE, HANDLER(SceneView3D, HandlePostRenderUpdate));
  92. SubscribeToEvent(E_MOUSEMOVE, HANDLER(SceneView3D,HandleMouseMove));
  93. SubscribeToEvent(this, E_DRAGENTERWIDGET, HANDLER(SceneView3D, HandleDragEnterWidget));
  94. SubscribeToEvent(this, E_DRAGEXITWIDGET, HANDLER(SceneView3D, HandleDragExitWidget));
  95. SubscribeToEvent(this, E_DRAGENDED, HANDLER(SceneView3D, HandleDragEnded));
  96. SubscribeToEvent(E_UIUNHANDLEDSHORTCUT, HANDLER(SceneView3D, HandleUIUnhandledShortcut));
  97. SubscribeToEvent(E_UIWIDGETFOCUSESCAPED, HANDLER(SceneView3D, HandleUIWidgetFocusEscaped));
  98. SetIsFocusable(true);
  99. }
  100. SceneView3D::~SceneView3D()
  101. {
  102. }
  103. void SceneView3D::Enable()
  104. {
  105. if (enabled_)
  106. return;
  107. enabled_ = true;
  108. }
  109. void SceneView3D::Disable()
  110. {
  111. if (!enabled_)
  112. return;
  113. enabled_ = false;
  114. }
  115. bool SceneView3D::GetOrbitting()
  116. {
  117. Input* input = GetSubsystem<Input>();
  118. return framedBBox_.defined_ && MouseInView() && input->GetKeyDown(KEY_ALT) && input->GetMouseButtonDown(MOUSEB_LEFT);
  119. }
  120. bool SceneView3D::GetZooming()
  121. {
  122. Input* input = GetSubsystem<Input>();
  123. return MouseInView() && input->GetKeyDown(KEY_ALT) && input->GetMouseMoveWheel();
  124. }
  125. void SceneView3D::MoveCamera(float timeStep)
  126. {
  127. if (!enabled_ && !GetFocus())
  128. return;
  129. Input* input = GetSubsystem<Input>();
  130. bool shiftDown = false;
  131. if (input->GetKeyDown(KEY_LSHIFT) || input->GetKeyDown(KEY_RSHIFT))
  132. shiftDown = true;
  133. bool mouseInView = MouseInView();
  134. bool orbitting = GetOrbitting();
  135. bool zooming = GetZooming();
  136. // Movement speed as world units per second
  137. float MOVE_SPEED = 20.0f;
  138. // Mouse sensitivity as degrees per pixel
  139. const float MOUSE_SENSITIVITY = 0.2f;
  140. if (shiftDown)
  141. MOVE_SPEED *= 3.0f;
  142. // Use this frame's mouse motion to adjust camera node yaw and pitch. Clamp the pitch between -90 and 90 degrees
  143. if ((mouseInView && input->GetMouseButtonDown(MOUSEB_RIGHT)) || orbitting)
  144. {
  145. SetFocus();
  146. IntVector2 mouseMove = input->GetMouseMove();
  147. yaw_ += MOUSE_SENSITIVITY * mouseMove.x_;
  148. pitch_ += MOUSE_SENSITIVITY * mouseMove.y_;
  149. pitch_ = Clamp(pitch_, -90.0f, 90.0f);
  150. }
  151. // Construct new orientation for the camera scene node from yaw and pitch. Roll is fixed to zero
  152. Quaternion q(pitch_, yaw_, 0.0f);
  153. if (!zooming)
  154. cameraNode_->SetRotation(q);
  155. if (orbitting)
  156. {
  157. BoundingBox bbox;
  158. sceneEditor_->GetSelection()->GetBounds(bbox);
  159. if (bbox.defined_)
  160. {
  161. Vector3 centerPoint = bbox.Center();
  162. Vector3 d = cameraNode_->GetWorldPosition() - centerPoint;
  163. cameraNode_->SetWorldPosition(centerPoint - q * Vector3(0.0, 0.0, d.Length()));
  164. }
  165. }
  166. if (zooming)
  167. {
  168. Ray ray = GetCameraRay();
  169. Vector3 wpos = cameraNode_->GetWorldPosition();
  170. wpos += ray.direction_ * (float (input->GetMouseMoveWheel()) * (shiftDown ? 0.6f : 0.2f));
  171. cameraNode_->SetWorldPosition(wpos);
  172. }
  173. #ifdef ATOMIC_PLATFORM_WINDOWS
  174. bool superdown = input->GetKeyDown(KEY_LCTRL) || input->GetKeyDown(KEY_RCTRL);
  175. #else
  176. bool superdown = input->GetKeyDown(KEY_LGUI) || input->GetKeyDown(KEY_RGUI);
  177. #endif
  178. if (!orbitting && mouseInView && !superdown && input->GetMouseButtonDown(MOUSEB_RIGHT)) {
  179. // Read WASD keys and move the camera scene node to the corresponding direction if they are pressed
  180. // Use the Translate() function (default local space) to move relative to the node's orientation.
  181. if (input->GetKeyDown(KEY_W))
  182. {
  183. SetFocus();
  184. cameraNode_->Translate(Vector3::FORWARD * MOVE_SPEED * timeStep);
  185. }
  186. if (input->GetKeyDown(KEY_S))
  187. {
  188. SetFocus();
  189. cameraNode_->Translate(Vector3::BACK * MOVE_SPEED * timeStep);
  190. }
  191. if (input->GetKeyDown(KEY_A))
  192. { SetFocus();
  193. cameraNode_->Translate(Vector3::LEFT * MOVE_SPEED * timeStep);
  194. }
  195. if (input->GetKeyDown(KEY_D))
  196. {
  197. SetFocus();
  198. cameraNode_->Translate(Vector3::RIGHT * MOVE_SPEED * timeStep);
  199. }
  200. if (input->GetKeyDown(KEY_E))
  201. {
  202. SetFocus();
  203. cameraNode_->Translate(Vector3::UP * MOVE_SPEED * timeStep);
  204. }
  205. if (input->GetKeyDown(KEY_Q))
  206. {
  207. SetFocus();
  208. cameraNode_->Translate(Vector3::DOWN * MOVE_SPEED * timeStep);
  209. }
  210. }
  211. if (cameraMove_)
  212. {
  213. cameraMoveTime_ += timeStep * 3.0f;
  214. if (cameraMoveTime_ > 1.0f)
  215. {
  216. cameraMove_ = false;
  217. cameraMoveTime_ = 1.0f;
  218. }
  219. Vector3 pos = cameraMoveStart_.Lerp(cameraMoveTarget_, cameraMoveTime_);
  220. cameraNode_->SetWorldPosition(pos);
  221. }
  222. }
  223. Ray SceneView3D::GetCameraRay()
  224. {
  225. Ray camRay;
  226. Input* input = GetSubsystem<Input>();
  227. IntVector2 cpos = input->GetMousePosition();
  228. IntRect rect = GetRect();
  229. if (!rect.Width() || !rect.Height())
  230. return camRay;
  231. int x = rect.left_;
  232. int y = rect.top_;
  233. GetInternalWidget()->ConvertToRoot(x, y);
  234. return camera_->GetScreenRay(float(cpos.x_ - x) / rect.Width(),
  235. float(cpos.y_ - y) / rect.Height());
  236. }
  237. bool SceneView3D::MouseInView()
  238. {
  239. if (!GetInternalWidget())
  240. return false;
  241. if (!TBWidget::hovered_widget || TBWidget::hovered_widget->GetDelegate() != this)
  242. return false;
  243. Input* input = GetSubsystem<Input>();
  244. IntVector2 pos = input->GetMousePosition();
  245. IntRect rect = GetRect();
  246. GetInternalWidget()->ConvertToRoot(rect.left_, rect.top_);
  247. GetInternalWidget()->ConvertToRoot(rect.right_, rect.bottom_);
  248. return rect.IsInside(pos);
  249. }
  250. void SceneView3D::HandleUIUnhandledShortcut(StringHash eventType, VariantMap& eventData)
  251. {
  252. if (!enabled_)
  253. return;
  254. unsigned id = eventData[UIUnhandledShortcut::P_REFID].GetUInt();
  255. if (id == TBIDC("undo"))
  256. sceneEditor_->Undo();
  257. else if (id == TBIDC("redo"))
  258. sceneEditor_->Redo();
  259. else if (id == TBIDC("copy"))
  260. sceneEditor_->Copy();
  261. else if (id == TBIDC("cut"))
  262. sceneEditor_->Cut();
  263. else if (id == TBIDC("paste"))
  264. sceneEditor_->Paste();
  265. return;
  266. }
  267. void SceneView3D::HandleUIWidgetFocusEscaped(StringHash eventType, VariantMap& eventData)
  268. {
  269. if (!enabled_)
  270. return;
  271. SetFocus();
  272. }
  273. void SceneView3D::HandlePostRenderUpdate(StringHash eventType, VariantMap& eventData)
  274. {
  275. if (!MouseInView() || GetOrbitting())
  276. return;
  277. Input* input = GetSubsystem<Input>();
  278. mouseLeftDown_ = false;
  279. bool shiftDown = input->GetKeyDown(KEY_LSHIFT) || input->GetKeyDown(KEY_RSHIFT);
  280. if (input->GetMouseButtonPress(MOUSEB_LEFT))
  281. {
  282. SetFocus();
  283. if (!mouseMoved_ && !sceneEditor_->GetGizmo()->Selected())
  284. {
  285. Ray camRay = GetCameraRay();
  286. PODVector<RayQueryResult> result;
  287. RayOctreeQuery query(result, camRay, RAY_TRIANGLE, camera_->GetFarClip(), DRAWABLE_GEOMETRY, 0x7fffffff);
  288. octree_->RaycastSingle(query);
  289. if (query.result_.Size())
  290. {
  291. const RayQueryResult& r = result[0];
  292. if (r.drawable_)
  293. {
  294. VariantMap neventData;
  295. Node* node = r.drawable_->GetNode();
  296. // if temporary, this is a prefab
  297. // TODO: if we use temporary for other stuff
  298. // fix this to look for prefab
  299. if (node->IsTemporary())
  300. node = node->GetParent();
  301. if (sceneEditor_->GetSelection()->Contains(node) && shiftDown)
  302. {
  303. sceneEditor_->GetSelection()->RemoveNode(node);
  304. }
  305. else
  306. {
  307. sceneEditor_->GetSelection()->AddNode(node, !shiftDown);
  308. }
  309. }
  310. }
  311. else
  312. {
  313. sceneEditor_->GetSelection()->Clear();
  314. }
  315. }
  316. mouseMoved_ = false;
  317. }
  318. else if (!input->GetMouseButtonDown(MOUSEB_LEFT))
  319. {
  320. Ray camRay = GetCameraRay();
  321. PODVector<RayQueryResult> result;
  322. mouseMoved_ = false;
  323. /*
  324. Array<int> pickModeDrawableFlags = {
  325. DRAWABLE_GEOMETRY,
  326. DRAWABLE_LIGHT,
  327. DRAWABLE_ZONE
  328. };
  329. */
  330. RayOctreeQuery query(result, camRay, RAY_TRIANGLE, camera_->GetFarClip(), DRAWABLE_GEOMETRY, 0x7fffffff);
  331. octree_->RaycastSingle(query);
  332. if (query.result_.Size())
  333. {
  334. const RayQueryResult& r = result[0];
  335. if (r.drawable_)
  336. {
  337. debugRenderer_->AddNode(r.drawable_->GetNode(), 1.0, false);
  338. r.drawable_->DrawDebugGeometry(debugRenderer_, false);
  339. }
  340. }
  341. }
  342. else
  343. {
  344. mouseLeftDown_ = true;
  345. if (Abs(input->GetMouseMoveX() > 3 || input->GetMouseMoveY() > 3))
  346. {
  347. mouseMoved_ = true;
  348. }
  349. }
  350. }
  351. bool SceneView3D::OnEvent(const TBWidgetEvent &ev)
  352. {
  353. if (ev.type == EVENT_TYPE_SHORTCUT)
  354. {
  355. if (ev.ref_id == TBIDC("close"))
  356. return false;
  357. }
  358. if (ev.type == EVENT_TYPE_KEY_UP)
  359. {
  360. if (ev.special_key == TB_KEY_ESC)
  361. {
  362. sceneEditor_->GetSelection()->Clear();
  363. }
  364. }
  365. return sceneEditor_->OnEvent(ev);
  366. }
  367. void SceneView3D::HandleUpdate(StringHash eventType, VariantMap& eventData)
  368. {
  369. // parent is the contentRoot for our tab, when tab isn't active it will not be visible
  370. if (!GetParent() || GetParent()->GetVisibility() != UI_WIDGET_VISIBILITY_VISIBLE)
  371. {
  372. Disable();
  373. return;
  374. }
  375. Enable();
  376. // Timestep parameter is same no matter what event is being listened to
  377. float timeStep = eventData[Update::P_TIMESTEP].GetFloat();
  378. MoveCamera(timeStep);
  379. QueueUpdate();
  380. if (preloadResourceScene_.NotNull())
  381. {
  382. if (preloadResourceScene_->GetAsyncProgress() == 1.0f)
  383. {
  384. ResourceCache* cache = GetSubsystem<ResourceCache>();
  385. XMLFile* xml = cache->GetResource<XMLFile>(dragAssetGUID_);
  386. if (dragNode_.NotNull())
  387. {
  388. dragNode_->LoadXML(xml->GetRoot());
  389. UpdateDragNode(0, 0);
  390. AnimationController* controller = dragNode_->GetComponent<AnimationController>();
  391. if (controller)
  392. {
  393. controller->PlayExclusive("Idle", 0, true);
  394. dragNode_->GetScene()->SetUpdateEnabled(true);
  395. }
  396. }
  397. preloadResourceScene_ = 0;
  398. dragAssetGUID_ = "";
  399. }
  400. }
  401. }
  402. void SceneView3D::UpdateDragNode(int mouseX, int mouseY)
  403. {
  404. if (dragNode_.Null())
  405. return;
  406. Ray ray = GetCameraRay();
  407. Vector3 pos = ray.origin_;
  408. pos += ray.direction_ * 10;
  409. dragNode_->SetWorldPosition(pos);
  410. }
  411. void SceneView3D::HandleMouseMove(StringHash eventType, VariantMap& eventData)
  412. {
  413. if (dragNode_.Null())
  414. return;
  415. Input* input = GetSubsystem<Input>();
  416. if (!input->IsMouseVisible())
  417. return;
  418. using namespace MouseMove;
  419. int x = eventData[P_X].GetInt();
  420. int y = eventData[P_Y].GetInt();
  421. UpdateDragNode(x, y);
  422. }
  423. void SceneView3D::HandleDragEnterWidget(StringHash eventType, VariantMap& eventData)
  424. {
  425. using namespace DragEnterWidget;
  426. UIWidget* widget = static_cast<UIWidget*>(eventData[P_WIDGET].GetPtr());
  427. if (widget != this)
  428. return;
  429. UIDragObject* dragObject = static_cast<UIDragObject*>(eventData[P_DRAGOBJECT].GetPtr());
  430. Object* object = dragObject->GetObject();
  431. if (!object)
  432. return;
  433. if (object->GetType() == Asset::GetTypeStatic())
  434. {
  435. Asset* asset = (Asset*) object;
  436. dragNode_ = asset->InstantiateNode(scene_, asset->GetName());
  437. if (dragNode_.NotNull())
  438. {
  439. Input* input = GetSubsystem<Input>();
  440. IntVector2 pos = input->GetMousePosition();
  441. UpdateDragNode(pos.x_, pos.y_);
  442. }
  443. //LOGINFOF("Dropped %s : %s on SceneView3D", asset->GetPath().CString(), asset->GetGUID().CString());
  444. }
  445. }
  446. void SceneView3D::HandleDragExitWidget(StringHash eventType, VariantMap& eventData)
  447. {
  448. if (preloadResourceScene_.NotNull())
  449. {
  450. preloadResourceScene_->StopAsyncLoading();
  451. preloadResourceScene_ = 0;
  452. }
  453. if (dragNode_.NotNull())
  454. {
  455. scene_->RemoveChild(dragNode_);
  456. }
  457. dragAssetGUID_ = "";
  458. dragNode_ = 0;
  459. }
  460. void SceneView3D::HandleDragEnded(StringHash eventType, VariantMap& eventData)
  461. {
  462. using namespace DragEnded;
  463. UIDragObject* dragObject = static_cast<UIDragObject*>(eventData[P_DRAGOBJECT].GetPtr());
  464. if (dragNode_.NotNull())
  465. {
  466. VariantMap nodeCreatedEvent;
  467. nodeCreatedEvent[SceneEditNodeCreated::P_NODE] = dragNode_;
  468. scene_->SendEvent(E_SCENEEDITNODECREATED, nodeCreatedEvent);
  469. }
  470. if (dragObject && dragObject->GetObject()->GetType() == ToolCore::Asset::GetTypeStatic())
  471. {
  472. Asset* asset = (ToolCore::Asset*) dragObject->GetObject();
  473. if (asset->GetImporterTypeName() == "MaterialImporter") {
  474. Material* material = GetSubsystem<ResourceCache>()->GetResource<Material>(asset->GetPath());
  475. if (material) {
  476. material = material;
  477. Ray camRay = GetCameraRay();
  478. PODVector<RayQueryResult> result;
  479. RayOctreeQuery query(result, camRay, RAY_TRIANGLE, camera_->GetFarClip(), DRAWABLE_GEOMETRY, 0x7fffffff);
  480. octree_->RaycastSingle(query);
  481. if (query.result_.Size())
  482. {
  483. const RayQueryResult& r = result[0];
  484. if (r.drawable_ && (r.drawable_->GetType() == StaticModel::GetTypeStatic() || r.drawable_->GetType() == AnimatedModel::GetTypeStatic()))
  485. {
  486. ((StaticModel*)r.drawable_)->SetMaterial(material);
  487. }
  488. }
  489. }
  490. }
  491. }
  492. dragAssetGUID_ = "";
  493. dragNode_ = 0;
  494. }
  495. void SceneView3D::FrameSelection()
  496. {
  497. BoundingBox bbox;
  498. sceneEditor_->GetSelection()->GetBounds(bbox);
  499. if (!bbox.defined_)
  500. return;
  501. Sphere sphere(bbox);
  502. if (sphere.radius_ < .01f || sphere.radius_ > 512)
  503. return;
  504. framedBBox_ = bbox;
  505. cameraMoveStart_ = cameraNode_->GetWorldPosition();
  506. cameraMoveTarget_ = bbox.Center() - (cameraNode_->GetWorldDirection() * sphere.radius_ * 3);
  507. cameraMoveTime_ = 0.0f;
  508. cameraMove_ = true;
  509. }
  510. }