I have a pointer to a line (through an iterator). I want to as efficiently as possible check if another line connected to one of it's two vertices has the same angle/normal. How do I find the next or previous line?
(alternatively, some other way of achieving the goal is fine too)
[zscript] Finding the adjacent linedef
Moderator: GZDoom Developers
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Re: [zscript] Finding the adjacent linedef
I think your only option is to look at every single line, check if it shares a vertex, then check the angle.
But, depending on what you're doing, it might be good enough to only check the lines in the same two sectors as the first line. Or, check those two sectors and any neighboring sectors. That could still miss a few pairs of lines that are connected and have the same angle, but maybe those pairs of lines aren't important to you (if you're trying to figure out if you should put a decal there, or something like that, two adjacent lines not sharing a sector or in neighboring sectors might not matter to you).
If you really need to unconditionally find any neighbor lines with the same angle, it might be worth it to precompute all matching pairs when the level loads, or at map init time.
But, depending on what you're doing, it might be good enough to only check the lines in the same two sectors as the first line. Or, check those two sectors and any neighboring sectors. That could still miss a few pairs of lines that are connected and have the same angle, but maybe those pairs of lines aren't important to you (if you're trying to figure out if you should put a decal there, or something like that, two adjacent lines not sharing a sector or in neighboring sectors might not matter to you).
If you really need to unconditionally find any neighbor lines with the same angle, it might be worth it to precompute all matching pairs when the level loads, or at map init time.
Re: [zscript] Finding the adjacent linedef
How can I get neighboring sectors in a cheap way?Or, check those two sectors and any neighboring sectors.
What I want to do is only exclude lines that part of an unbroken segmented line from a particular function call.if you're trying to figure out if you should put a decal there, or something like that, two adjacent lines not sharing a sector or in neighboring sectors might not matter to you)
Since there doesn't seem to be a magic trick or something I've overlooked available, I'll probably do this.If you really need to unconditionally find any neighbor lines with the same angle, it might be worth it to precompute all matching pairs when the level loads, or at map init time.
Would be nice if the vertex struct contained pointers to any lines that connect to it!
Re: [zscript] Finding the adjacent linedef
You should be able to get the first two sectors by looking at the first line's sidedefs, and then get neighboring sectors by doing the same thing with all the lines in those two sectors. I think the only common thing this would miss would be something like two separate rooms sharing one corner, assuming you want to count angle and opposite angle as being the same.
- Graf Zahl
- Lead GZDoom+Raze Developer
- Posts: 49230
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: [zscript] Finding the adjacent linedef
The blockmap may be more efficient for finding an adjacent line. You only need to iterate through the block containing the vertex you want to check.
Re: [zscript] Finding the adjacent linedef
A blocklinesiterator centered on the vertex with some extremely low radius you mean?
Edit: yeah that works, but apparently you can't nest blockline iterators
Edit: yeah that works, but apparently you can't nest blockline iterators
