HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

how to get the rect a player is currently viewing?

12-07-2009, 04:26 PM#1
Tot
I need a method to get the rect a player is currently viewing

something like:
Collapse JASS:
function GetPlayerCurrentView takes player p returns rect
     local rect r
     //!!INSERT BRAIN HERE!!
     return r
endfunction

bye
12-07-2009, 05:28 PM#2
Seshiro
Only possible with RTC natives afaik
12-07-2009, 05:39 PM#3
Tot
I thaught it's possible with GetCameraTarget(), GetCameraEye(), GetCameraField(), I'm only too stupid to do it.
12-07-2009, 05:46 PM#4
DioD
its possible but data will be async only (cannot be used in multiplayer)
12-07-2009, 05:50 PM#5
Tot
Quote:
Originally Posted by DioD
its possible but data will be async only (cannot be used in multiplayer)

f***
12-07-2009, 05:55 PM#6
DioD
you always can play with sync, there is at least 3 systems to sync data, 1 have major chance of malfunction, 1 have delay and one uses units selections and interrupt controls.
12-08-2009, 07:48 AM#7
Anachron
Collapse JASS:
function getPlayerCameraRect takes player p returns rect
    local real minX   = 0.
    local real maxY   = 0.
    local real minY   = 0.
    local real maxY   = 0.
    local real curX   = 0.
    local real curY   = 0.
    local real curZ   = 0.

    if GetLocalPlayer() == p then
        set curX = GetCameraTargetPositionX()
        set curY = GetCameraTargetPositionY()
        set curZ = GetCameraTargetPositionZ()
        set minX = curX - curZ / 2
        set maxY = curX + curZ / 2
        set minY = curY - curZ / 2
        set maxY = curY + curZ / 2
    endif
    
    return Rect(minX, minY, maxX, maxY) 
endfunction
That would be the function. I don't know if it would cause desync, I just made it in a minute.

Can someone test my code? I don't remember if it was like that.
12-08-2009, 08:18 AM#8
Viikuna-
Well, you can get that rect and its no problem, but the thing is that syncing that data is slow, so it kinda limits its usability to asynchronous stuff.

You can still use it for asynchronous stuff, though. Like Opossum does in his RegionalFog -fog system thingy, for example.
12-08-2009, 08:23 AM#9
Anachron
Hmm, so what about my function? Will it return the correct value and will it desync?
12-08-2009, 08:54 AM#10
DioD
damn stupid question...

all players expect one wont create handle, will this desync?
12-08-2009, 01:05 PM#11
Anachron
Hm so now?
12-08-2009, 03:10 PM#12
Viikuna-
Well, it kinda depends.

Some handles are asynchronous, others are not. Create texttag for one player and it works, do same thing with unit and you desync.
12-08-2009, 03:15 PM#13
Anachron
Hmm I see. I wonder if blizzard could fix it?
12-08-2009, 03:15 PM#14
Rising_Dusk
That would desync in the case of you doing anything with the rect that requires sync'd data. For instance, enumerating units in the rect or spawning something in the rect. If that rect were only handled via asynchronous actions, it'd work fine.
12-08-2009, 03:18 PM#15
Anachron
I now officially hate blizzard.

Edit: To stay on topic:
What actions are asynchronous?