Kaynağa Gözat

Update guiMissionArea.cpp

set a minimum size for the level bounds, this stops the mouse drag issue until it is sorted out properly
marauder2k7 2 ay önce
ebeveyn
işleme
4fc182444e

+ 23 - 2
Engine/source/gui/worldEditor/guiMissionArea.cpp

@@ -141,8 +141,6 @@ bool GuiMissionAreaCtrl::onWake()
    if(!Parent::onWake())
    if(!Parent::onWake())
       return(false);
       return(false);
 
 
-   updateLevelBitmap();
-
    // make sure mission area is clamped
    // make sure mission area is clamped
    setArea(getArea());
    setArea(getArea());
 
 
@@ -167,6 +165,11 @@ void GuiMissionAreaCtrl::onMouseUp(const GuiEvent & event)
    if(!bool(mMissionArea))
    if(!bool(mMissionArea))
       return;
       return;
 
 
+   //unlock the mouse
+   mouseUnlock();
+
+   mLastMousePoint = event.mousePoint;
+
    RectI box;
    RectI box;
    getScreenMissionArea(box);
    getScreenMissionArea(box);
    S32 hit = getHitHandles(event.mousePoint, box);
    S32 hit = getHitHandles(event.mousePoint, box);
@@ -188,6 +191,11 @@ void GuiMissionAreaCtrl::onMouseDown(const GuiEvent & event)
    if(!bool(mMissionArea))
    if(!bool(mMissionArea))
       return;
       return;
 
 
+   setFirstResponder();
+
+   // lock mouse
+   mouseLock();
+
    RectI box;
    RectI box;
    getScreenMissionArea(box);
    getScreenMissionArea(box);
 
 
@@ -354,6 +362,19 @@ void GuiMissionAreaCtrl::updateLevelBitmap()
       mLevelBounds.intersect(box);
       mLevelBounds.intersect(box);
    }
    }
 
 
+   const F32 minSize = 256.0f;
+
+   // Ensure the bounding box has a minimum size and is square
+   VectorF size = mLevelBounds.getExtents();
+   F32 maxExtent = getMax(getMax(size.x, size.y), minSize);
+
+   // Expand to make it square and centered
+   Point3F center = mLevelBounds.getCenter();
+
+   Point3F halfExtents(maxExtent * 0.5f, maxExtent * 0.5f, size.z * 0.5f);
+   mLevelBounds.minExtents = center - halfExtents;
+   mLevelBounds.maxExtents = center + halfExtents;
+
    GFXTransformSaver saver;
    GFXTransformSaver saver;
 
 
    // Calculate orthographic dimensions
    // Calculate orthographic dimensions