Browse Source

Update the consts implementation

weinand 9 years ago
parent
commit
d2aaec8ccc
1 changed files with 28 additions and 30 deletions
  1. 28 30
      Source/AtomicEditor/Editors/SceneEditor3D/SceneView3D.cpp

+ 28 - 30
Source/AtomicEditor/Editors/SceneEditor3D/SceneView3D.cpp

@@ -66,6 +66,13 @@ using namespace ToolCore;
 namespace AtomicEditor
 namespace AtomicEditor
 {
 {
 
 
+const int CAMERASNAP_TOP = 1;
+const int CAMERASNAP_BOTTOM = 2;
+const int CAMERASNAP_LEFT = 3;
+const int CAMERASNAP_RIGHT = 4;
+const int CAMERASNAP_FRONT = 5;
+const int CAMERASNAP_BACK = 6;
+
 SceneView3D ::SceneView3D(Context* context, SceneEditor3D *sceneEditor) :
 SceneView3D ::SceneView3D(Context* context, SceneEditor3D *sceneEditor) :
     UISceneView(context),
     UISceneView(context),
     yaw_(0.0f),
     yaw_(0.0f),
@@ -335,14 +342,12 @@ void SceneView3D::MoveCamera(float timeStep)
 
 
     }
     }
 
 
-    float currCameraZoom = camera_->GetZoom();
-
     if (camera_->IsOrthographic() && mouseInView && !orbitting)
     if (camera_->IsOrthographic() && mouseInView && !orbitting)
     {
     {
         if (input->GetMouseMoveWheel() > 0)
         if (input->GetMouseMoveWheel() > 0)
-            camera_->SetZoom(currCameraZoom + ZOOM_INCREMENT);
+            camera_->SetZoom(camera_->GetZoom() + ZOOM_INCREMENT);
         if (input->GetMouseMoveWheel() < 0)
         if (input->GetMouseMoveWheel() < 0)
-            camera_->SetZoom(currCameraZoom - ZOOM_INCREMENT);
+            camera_->SetZoom(camera_->GetZoom() - ZOOM_INCREMENT);
     }
     }
     else
     else
         camera_->SetZoom(DEFAULT_ZOOM);
         camera_->SetZoom(DEFAULT_ZOOM);
@@ -353,13 +358,6 @@ void SceneView3D::SnapCameraToView(int snapView)
     // the distance the camera snaps from the selected object
     // the distance the camera snaps from the selected object
     const int DISTANCE = 5;
     const int DISTANCE = 5;
 
 
-    const int TOP = 1;
-    const int BOTTOM = 2;
-    const int LEFT = 3;
-    const int RIGHT = 4;
-    const int FRONT = 5;
-    const int BACK = 6;
-
     fromOrthographic_ = true;
     fromOrthographic_ = true;
 
 
     // if no object is selected will snap to view relative to camera position
     // if no object is selected will snap to view relative to camera position
@@ -369,32 +367,32 @@ void SceneView3D::SnapCameraToView(int snapView)
 
 
         switch (snapView)
         switch (snapView)
         {
         {
-            case TOP:
+            case CAMERASNAP_TOP:
                 yaw_ = 0;
                 yaw_ = 0;
                 pitch_ = 90;
                 pitch_ = 90;
                 selectedNodePos.y_ += DISTANCE;
                 selectedNodePos.y_ += DISTANCE;
                 break;
                 break;
-            case BOTTOM:
+            case CAMERASNAP_BOTTOM:
                 yaw_ = 0;
                 yaw_ = 0;
                 pitch_ = -90;
                 pitch_ = -90;
                 selectedNodePos.y_ -= DISTANCE;
                 selectedNodePos.y_ -= DISTANCE;
                 break;
                 break;
-            case LEFT:
+            case CAMERASNAP_LEFT:
                 yaw_ = -90;
                 yaw_ = -90;
                 pitch_ = 0;
                 pitch_ = 0;
                 selectedNodePos.x_ += DISTANCE;
                 selectedNodePos.x_ += DISTANCE;
                 break;
                 break;
-            case RIGHT:
+            case CAMERASNAP_RIGHT:
                 yaw_ = 90;
                 yaw_ = 90;
                 pitch_ = 0;
                 pitch_ = 0;
                 selectedNodePos.x_ -= DISTANCE;
                 selectedNodePos.x_ -= DISTANCE;
                 break;
                 break;
-            case FRONT:
+            case CAMERASNAP_FRONT:
                 yaw_ = 0;
                 yaw_ = 0;
                 pitch_ = 0;
                 pitch_ = 0;
                 selectedNodePos.z_ -= DISTANCE;
                 selectedNodePos.z_ -= DISTANCE;
                 break;
                 break;
-            case BACK:
+            case CAMERASNAP_BACK:
                 yaw_ = 180;
                 yaw_ = 180;
                 pitch_ = 0;
                 pitch_ = 0;
                 selectedNodePos.z_ += DISTANCE;
                 selectedNodePos.z_ += DISTANCE;
@@ -411,27 +409,27 @@ void SceneView3D::SnapCameraToView(int snapView)
 
 
 void SceneView3D::SelectView()
 void SceneView3D::SelectView()
 {
 {
-    Input* input = GetSubsystem<Input>();
-
-    int snapView = 0;
-
     if (MouseInView())
     if (MouseInView())
     {
     {
+        Input* input = GetSubsystem<Input>();
+
+        int snapView = 0;
+
         if (!camera_->IsOrthographic() && !fromOrthographic_)
         if (!camera_->IsOrthographic() && !fromOrthographic_)
             SavePerspectiveCameraPosition();
             SavePerspectiveCameraPosition();
 
 
         if (input->GetKeyPress(KEY_1))
         if (input->GetKeyPress(KEY_1))
-            snapView = 1;
+            snapView = CAMERASNAP_TOP;
         if (input->GetKeyPress(KEY_2))
         if (input->GetKeyPress(KEY_2))
-            snapView = 2;
+            snapView = CAMERASNAP_BOTTOM;
         if (input->GetKeyPress(KEY_3))
         if (input->GetKeyPress(KEY_3))
-            snapView = 3;
+            snapView = CAMERASNAP_LEFT;
         if (input->GetKeyPress(KEY_4))
         if (input->GetKeyPress(KEY_4))
-            snapView = 4;
+            snapView = CAMERASNAP_RIGHT;
         if (input->GetKeyPress(KEY_5))
         if (input->GetKeyPress(KEY_5))
-            snapView = 5;
+            snapView = CAMERASNAP_FRONT;
         if (input->GetKeyPress(KEY_6))
         if (input->GetKeyPress(KEY_6))
-            snapView = 6;
+            snapView = CAMERASNAP_BACK;
 
 
         if (snapView != 0)
         if (snapView != 0)
             SnapCameraToView(snapView);
             SnapCameraToView(snapView);
@@ -461,9 +459,9 @@ void SceneView3D::SelectView()
 
 
 void SceneView3D::SavePerspectiveCameraPosition()
 void SceneView3D::SavePerspectiveCameraPosition()
 {
 {
-        perspectCamPosition_ = cameraNode_->GetPosition();
-        perspectivePitch_ = pitch_;
-        perspectiveYaw_ = yaw_;
+    perspectCamPosition_ = cameraNode_->GetPosition();
+    perspectivePitch_ = pitch_;
+    perspectiveYaw_ = yaw_;
 }
 }
 
 
 Ray SceneView3D::GetCameraRay()
 Ray SceneView3D::GetCameraRay()