10.10.2011, 20:17
Should also consider the Grid System. Think of it as standard location except much smaller. Example, X coordinates 0 through 100 is 0, 100 through 200 is 1. By setting the 8 grids surrounding each player for streaming, you could search through vehicles and stream the ones who Grid corresponds with grids set for streaming
Example:
v = Vehicle not streamed
V = Vehicle is streamed
P = Player
S = Streaming no vehicles
Using this, you don't have to determine distance, just stream the 8 grids around a player's grid
Example:
Player X,Y = 300,400
Convert X,Y = 300/100,400/100 //If X or Y coordinate is negative, subtract 1 for consistency
Grid X,Y = 3,4
So player grid = 3,4
just stream the surrounding grids
Streamed Grids:
2,3
2,4
2,5
3,3
3,4 -- Player's Grid
3,5
4,3
4,4
4,5
ADDITIONAL:
Also note that you only have to stream vehicles that players are not in, which means you only need to obtain their coordinates once a player has exited the vehicle or if the vehicle spawns.
I used this system to create a 3D Text streamer, worked flawlessly but was never able to stress test it properly
Example:
v = Vehicle not streamed
V = Vehicle is streamed
P = Player
S = Streaming no vehicles
Код:
5 [ ][ ][ ][ ][ ][ ][ ][ ][ ] 4 [S][S][S][ ][ ][ ][S][S][S] 3 [S][P][S][v][ ][ ][V][P][V] 2 [S][S][S][ ][ ][ ][S][P][S] y 1 [ ][ ][ ][ ][ ][ ][S][S][S] x 1 2 3 4 5 6 7 8 9
Example:
Player X,Y = 300,400
Convert X,Y = 300/100,400/100 //If X or Y coordinate is negative, subtract 1 for consistency
Grid X,Y = 3,4
So player grid = 3,4
just stream the surrounding grids
Код:
6 [ ][ ][ ][ ][ ] 5 [ ][S][S][S][ ] 4 [ ][S][P][S][ ] 3 [ ][S][S][S][ ] 2 [ ][ ][ ][ ][ ] y 1 [ ][ ][ ][ ][ ] x 1 2 3 4 5
2,3
2,4
2,5
3,3
3,4 -- Player's Grid
3,5
4,3
4,4
4,5
ADDITIONAL:
Also note that you only have to stream vehicles that players are not in, which means you only need to obtain their coordinates once a player has exited the vehicle or if the vehicle spawns.
I used this system to create a 3D Text streamer, worked flawlessly but was never able to stress test it properly