Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

SetCameraBounds + camera rotation bug

Discussion in 'The Lab' started by ANdROnIQ, Oct 12, 2019.

  1. ANdROnIQ

    ANdROnIQ

    Joined:
    Jul 24, 2007
    Messages:
    205
    Resources:
    3
    Icons:
    1
    Maps:
    2
    Resources:
    3
    So, today I came up with this crash function:

    Code (Text):

    function Crash takes nothing returns nothing
        call SetCameraField(CAMERA_FIELD_ROTATION, GetRandomReal(240, 300), 0.00)
        call SetCameraBounds(-1000, -1000, -1000, 1000, 1000, 1000, 1000, -1000) // just any bounds, even GetWorldBounds()
    endfunction
     
    If not the first call, then a half-dozen calls will 100% crash your WC3 TFT 1.31. However, angles between -50 (aka 310) degrees and 230 degrees seem quite safe. [Edit: -40 to 220. Probably the danger zone is 270 ± 45.]

    On a side note, SetCameraField(CAMERA_FIELD_ROTATION, ...) is in degrees, whereas GetCameraField(CAMERA_FIELD_ROTATION) returns radians. (What a hell...)

    Just wanted to share this if someone else is wondering why their camera operations crash. I encountered this when I introduced SetCameraBounds in my map where camera rotation is bound to Hero facing. (Heroes travel through different locations, and in each location the minimap shows only the current location, not the entire map; redraw of minimap works terrible, but it at least shows units properly.) So, now I'm going to rotate all Heroes from the danger zone [220..320] to the closest safe angle right before updating camera bounds.

    (I know that generally this is an overkill, because you EITHER lock the camera to a certain region OR lock it to a certain unit and follow its movement and rotation, but in my exact case, I needed both.)
     
    Last edited: Oct 13, 2019