From e4e8db586ac5f3b1c8eb8ba38a8699fd50ddfa59 Mon Sep 17 00:00:00 2001 From: xemuth Date: Thu, 13 Aug 2020 15:03:51 +0000 Subject: [PATCH] SurfaceCtrl: quick update git-svn-id: svn://ultimatepp.org/upp/trunk@14813 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- bazaar/SurfaceCtrl/BoundingBox.h | 2 +- bazaar/SurfaceCtrl/MagicCamera.h | 5 ++++- bazaar/SurfaceCtrl/SurfaceCtrl.cpp | 11 +++++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/bazaar/SurfaceCtrl/BoundingBox.h b/bazaar/SurfaceCtrl/BoundingBox.h index d388afb45..d66c0014f 100644 --- a/bazaar/SurfaceCtrl/BoundingBox.h +++ b/bazaar/SurfaceCtrl/BoundingBox.h @@ -68,7 +68,7 @@ class BoundingBox { loaded = copy.loaded; min = copy.min; max = copy.max; - BoundingBoxVertices.Append(copy.BoundingBoxVertices); //This line make all things crash + BoundingBoxVertices.Append(copy.BoundingBoxVertices); //This line make the program crash during (clone() function) BoundingBoxVAO = copy.BoundingBoxVAO; BoundingBoxVBO = copy.BoundingBoxVBO; return *this; diff --git a/bazaar/SurfaceCtrl/MagicCamera.h b/bazaar/SurfaceCtrl/MagicCamera.h index b10e60d4d..fc989fc8e 100644 --- a/bazaar/SurfaceCtrl/MagicCamera.h +++ b/bazaar/SurfaceCtrl/MagicCamera.h @@ -186,7 +186,8 @@ namespace Upp{ MagicCamera& CenterFocus(const Vector& selectedObj){ if(selectedObj.GetCount() > 0){ - glm::vec3 center = selectedObj[0]->GetBoundingBoxTransformed().GetCenter(); // The crash is occuring here, During copy operator, the Append function on vector make things crash + glm::vec3 center = selectedObj[0]->GetBoundingBoxTransformed().GetCenter(); // The crash is occuring here, During copy operator, + //the Append function on vector make things crash if(selectedObj.GetCount() > 1){ for(int e = 1; e < selectedObj.GetCount(); e++){ glm::vec3 center2 = selectedObj[e]->GetBoundingBoxTransformed().GetCenter(); @@ -194,6 +195,8 @@ namespace Upp{ } } focus = center; + }else{ + focus = glm::vec3(0.0f,0.0f,0.0f); } return *this; } diff --git a/bazaar/SurfaceCtrl/SurfaceCtrl.cpp b/bazaar/SurfaceCtrl/SurfaceCtrl.cpp index 1075889ea..3837c0fbe 100644 --- a/bazaar/SurfaceCtrl/SurfaceCtrl.cpp +++ b/bazaar/SurfaceCtrl/SurfaceCtrl.cpp @@ -120,18 +120,22 @@ bool SurfaceCtrl::Key(dword key,int count){ if( key == K_Z){ for(Object3D* obj : SelectedObject) obj->GetTransform().Move(obj->GetTransform().GetUp()); + camera.CenterFocus(SelectedObject); } if( key == K_S){ for(Object3D* obj : SelectedObject) obj->GetTransform().Move(-(obj->GetTransform().GetUp())); + camera.CenterFocus(SelectedObject); } if( key == K_Q){ for(Object3D* obj : SelectedObject) obj->GetTransform().Move(-(obj->GetTransform().GetRight())); + camera.CenterFocus(SelectedObject); } if( key == K_D){ for(Object3D* obj : SelectedObject) obj->GetTransform().Move(obj->GetTransform().GetRight()); + camera.CenterFocus(SelectedObject); } if( key == K_R){ /* float data[] = { 230.0f/255.0f, 140.0f/255.0f, 30.0f/255.0f}; @@ -269,7 +273,14 @@ void SurfaceCtrl::LeftDown(Point p, dword){ SelectedObject.Add(obj); } camera.CenterFocus(SelectedObject); + }else{ + for(Object3D* obj : SelectedObject){ + obj->ShowBoundingBox(false); + } + SelectedObject.Clear(); + camera.ResetFocus(); } + Refresh(); } void SurfaceCtrl::LeftUp(Point p, dword){