• 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Pawn] Dynamic Polygon Street Names
#1
Good evening all,

I'm currently setting up polygon areas for street names. Currently, I have it set as follows:

Code:
new area_StreetName;
new Float:Array_StreetName[] =
{
   x, y,
   x, y,
   x, y
};

I have about 20 of these so far, and to me, this seems really inefficient.

What I would like, is a float which contains the street name, and county, and then the points, like so...

Code:
new Float:StreetNames[][StreetInfo]
{ "StreetName", "TownName, CountyName", POINTS },

Code:
enum StreetInfo {
   StreetName_1[64],
   StreetName_2[64],
   Float:POINTS
};

Perhaps using an enum to store that information. But because the amount of points for a given street could be anything from 4 to 25 points, how would I go about storing this into an enum?

Thanks
  Reply
#2
I don't think that using dynamic areas for street names would be an good idea, take a look at this as it is already perfectly made, you can fork & edit it if you need to:

https://github.com/kristoisberg/samp-map...-zones.inc
Using Pawn.CMD?

If you're doing so, this is the very first sign that you absolutely shouldn't utilize your all powerful P-Code knowledge in any of the scripting discussion topics.
  Reply
#3
That wouldn't work with street names, as roads require more than 4 points, due to their shape and length.



I'm only covering Red County, not the entire map, so hopefully the amount of dynamic areas won't impact performance or cause issues. There is a way to do this which I've figured out with the help of somebody else. But Polygon areas is a must for this to work.
  Reply
#4
I don't think areas are the best way to go about this, but this is a hard algorithm problem to do efficiently. I strongly suspect that you need to do some serious computer science research I'm sure someone in acadaemia has done some work in this area to get a more efficient algorithm. The better bet is probably splitting roads up in to small straight-line segments and building up from there, but I don't know the most efficient way to organise those spatially, and I doubt anyone here does unfortunately.
  Reply
#5
3. ok "elitist"
  Reply
#6
1) Your benchmarking is wrong.



2) You don't need the square root, you only need to compare relative distances to find the closest.
  Reply
#7
You can have a network, where each node represents an intersection or point on a curve. Node connections would define roads. To find out what road you are , you just find out the nearest line segment and if the perpendicular distance to that road is bigger than road thickness, then you are not on a road.
[Image: github-samp-icon.png]
  Reply
#8
(2020-09-23, 11:53 AM)Y_Less Wrote: but I don't know the most efficient way to organise those spatially, and I doubt anyone here does unfortunately.

Quadtrees?
Always keep in mind that a lot of people are active on this forum in their spare time.

They are sacrificing time they could easily spend on things they would rather do, to help you instead.

  Reply
#9
Probably, yes. I was thinking of some custom data structure for specifically this data, but you're right. And they nest well, so any straight line segment that doesn't fit entirely within a block can just be put in the next square up. Plus you only need to search the closest blocks. I should have thought of that - it's how y_objects worked!
  Reply
#10
Thanks for the help, very interesting. I have however decided to move the server to Las Venturas, and for this reason, there's no way in hell I'll be doing street names here. Red County isn't too bad as the towns are small, but there's so many streets in the city it would take way to long to do something like this via script on it's own.



It would definitely be an interesting feature to have as perhaps an include or something, giving that element of GTA IV.
  Reply


Forum Jump: