| 04-06-2009, 05:25 AM | #1 |
Can someone advice me the best way performance wise to do this: i want to make an effective performance wise way to register when a unit has moved to a new wc3 terrain section (128x128 polygon). Im planning to create 8 rects around the unit and move them as the unit progress toward the rects. So ill always have 8 rects around each unit in the map. But if tere are too many units then this will cause bad performance (8 loop each unit). Or i can do a heavy init, to create rects of 128x128 all over. But then dunno if this is slow since tere are too many rects to register event for. 3rd alternative is wat i wouldnt wanna do, but who knows maybe u guys know its faster. It is to repeatedly check the units positions... Some may suggest to use this method but only when unit recieve move order. But i want this to work with SetUnitX/SetUnitY too so ye... this wont work. EDIT: ive figured a great way to do it with method 3. But id still wanna hear people out |
| 04-06-2009, 05:37 AM | #2 |
Make 2 'checkerboarded' regions (Only requires ~10 handles -.-) And store current one : reset when set x/y may need 3 4 depending on how wc diagonal movement works ( 232323 414141 232323 414141 ) |
| 04-06-2009, 05:39 AM | #3 |
wat do u mean Im planning to use unit leave region... |
| 04-06-2009, 05:43 AM | #4 |
rect = square region = lot of squares so you do this: a = region 1 b = region 2 ababababab bababababa and so on; do register enter region for both regions when event fires get square based on x/y pos ? |
| 04-06-2009, 06:49 AM | #5 |
Clever. I think if the diagonal motion case is screwball you'll need four colors. One possible tile: Code:
4 3 2 1 Four is the minimum since all the blocks of a 2x2 tile are in contact with each other. |
| 04-07-2009, 12:54 AM | #6 |
Ive been thinking and this doesnt solve my problem... cus i dont only wanna detect the displacement of 128x128 square. I want a cube 128x128x128... So i need to detect when a unit's flying height changes. |
| 04-07-2009, 01:44 AM | #7 |
Then do the check when you update their movement if you have that loop running anyways. |
| 04-07-2009, 07:12 AM | #8 |
Why are you interested in discretized Z position? |
| 04-07-2009, 02:44 PM | #9 |
z ruins it. You'll have to stick with method 3. |
