Results 1 to 6 of 6

Thread: For loop and boolean expression in it and other troubles..

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Why don't you simply trim the selection rectangle to camera rectangle boundaries.

    First make yourself a SelectionBox record similar like this:
    Code:
    RSelectionBox = record
      LeftBorder: Single;
      RightBorder: Single;
      TopBorder: Single;
      BottomBorder: Single;
    end;
    Then I also recomend making similar record for storing camera viewpoint boundaries:
    Code:
    RCameraViewpoint = record
      LeftBorder: Single;
      RightBorder: Single;
      TopBorder: Single;
      BottomBorder: Single;
    end;
    Finaly you simply check to see if selection borders are within camera viewpoint boundaries if not you modify them to be on camera viewpoint boundaries. Code would look something like this:
    Code:
    function TrimSelectionBox(SelectionBox: RSelectionBox; CameraViewpoint: RCameraViewpoint): RSelectionBox;
    begin
      if SelectionBox.LeftBorder < CameraViewpoint.Leftborder then Result.LeftBorder := CameraViewpoint.LeftBorder;
      if SelectionBox.RightBorder < CameraViewpoint.RightBorder then SelectionBox.RightBorder := CameraViewpoint.RightBorder;
      if SelectionBox.TopBorder < CameraViewpoint.TopBorder then SelectionBox.TopBorder := CameraViewpoint.TopBorder;
      if SelectionBox.BottomBorder < CameraViewpoint.BottomBorder then SelectionBox.BottomBorder := CameraViewpoint.BottomBorder;
      result := SelectionBox;
    end;

  2. #2
    Nice idea, but im not sure if it helps. I will try of course.
    I actually even got it to work for both left and right of X.
    But if i do negative selection with mouse, ex: from right to left. They still appear and limiting is buggy.
    So there are somewhere problems with negative numbers, either in rendering or limiting code, or in both..
    If selection goes from left to right, limiting works fine. Everywhere.

    There are just so many things to check for. Ex: if selection is negative or positive, how many selector blocks there are in total etc..

    Btw, the total nr of blocks that are selected do not depend on this "limitation". Its just visual thingy, If some of the selector blocks are outside the camera, these blocks will be taken into account anyway, just like in original editor. They just are not drawn. But the map array contents will be modified at this location anyway. Which is fine.

    Its just the visual side of things that must be "good".
    Here is the selectorblocks without left side limit:
    http://i.minus.com/ityQSjPUTELoh.JPG

    Here is the selectorblocks with left side limited, it means, i moved camera to the right for 1 step (column). Camera X incremented by 1.
    http://i.minus.com/igCMGYgji107s.JPG

    Because one column of blocks is outside the cameras left border, its now only 3 columns left.

    The blue "ER" tiles from word "DINER" are rendered for whole camera range. So blue tiles show exactly the camera viewport or drawing range.

    EDIT
    Ok, here is better view of "floating" selectorblocks: Look how its limited from left, but NOT from the BOTTOM.
    http://i.minus.com/ichfPhVMiUDbF.JPG


    This of course is Y coordinate, but anyway it shows clearly how bad it looks when it goes off the camera range.
    Last edited by hwnd; 30-11-2013 at 11:17 AM.

  3. #3
    Quote Originally Posted by hwnd View Post
    There are just so many things to check for. Ex: if selection is negative or positive, how many selector blocks there are in total etc..
    You can solve this easly by sorting X1 and X2 so that X1 is alyways lower. Same goes for Y1 and Y2.
    The number of selector blocks rendered only depends on trimmed selection dimensions.

  4. #4
    Ok, im kinda "hack and try" guy, of course i did a little bit of thinking and as result i got it almost working for X1 and X2.
    If all of the X1..X2 will work then its just copy paste for Y1..Y2 with few variable name changes. At least i hope so.

    But its late and im tired, my head hurts. Have to rest..


    But atm it works for every side, except if you negative select (from right to left) and move either up or down, then the right side is not "limited". All selector blocks just disappear without going away block by block like with other sides.

    But i know what piece of code is responsible for that, i will take a break, come back and try again.
    I already did so much today.

    And i cant get past of the selector blocks either, i want to make them working before moving on.
    Because all of the (ok 99% or so) map editing depends on them.
    Selector blocks must be pickable also by mouse, i tried this already and it seems to work (again credit goes to User137 and his excellent nxPascal), but i decided to first limit the rendering of the selector blocks.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •