Skip to content
This repository has been archived by the owner on Jun 8, 2022. It is now read-only.

GRIM: heightcheck fix #842

Closed
wants to merge 1 commit into from

Conversation

tobiaspfaff
Copy link
Contributor

In Sector::getBridgesTo(), the height check is effectively disabled, as the iterator is not reset. This may lead Manny to jump from high platforms to lower ones. This is especially visible in the mouse mod, which makes use of walkTo more extensively, but is a general bug which is why I'm posting this here.

@tobiaspfaff
Copy link
Contributor Author

Actually, never mind. It seems the height check actually breaks stuff in some places. maybe put a comment in there, though.

@klusark
Copy link
Member

klusark commented Mar 8, 2014

Where does it break stuff? It does look like a bug to me, so if fixing that bug causes new bugs, we should probably fix those too.

@tobiaspfaff
Copy link
Contributor Author

Not all sectors connect with two overlapping, parallel lines; E.g. at the beaver dam next to the tar pit, there is a triangle sector on the way up, which connects to a square sector with the pointy end.
The code tries to match the sides of the triangle, which then obviously have a height difference.

@Akz-
Copy link
Contributor

Akz- commented Mar 8, 2014

The bridge building algorithm doesn't expect to find matching parallel lines on both sectors. It is enough that the sectors have intersecting area. In the above case the intersection would be the single point at the triangle sector's pointy end, and the correct bridge would be a line of length 0 at the intersection point. Sector.cpp:386 could be the problem, since it will discard any bridges that are less than 0.01 units wide.

@tobiaspfaff
Copy link
Contributor Author

Ah, interesting! I missed the fact that bridges are shortened to the intersecting area. Removing the bridge lengthcheck (386) indeed makes these triangle-quad intersections work with the enabled height check.
Is it safe to remove this check, and why is it even there?

@Akz-
Copy link
Contributor

Akz- commented Mar 10, 2014

I guess the check is supposed to prune unnecessary bridges at corners where two sectors are just barely touching. Considering the usual case where two sectors are connected by parallel edges the obvious bridge is the parallel edge, but if the length check is removed you will also get two almost zero length bridges at the corners. That is because the adjacent edges have one vertex overlapping the other sector, so the edges are then cut to the intersecting area and accepted as bridges.

The beaver dam case shows that such bridges can't always be considered unnecessary, though. Also the presence of any unnecessary bridges shouldn't affect the behavior of the pathfinding, so I think the check can be safely removed.

@somaen
Copy link
Member

somaen commented May 27, 2014

So, what's the conclusion on this?

@Akz-
Copy link
Contributor

Akz- commented May 27, 2014

This can't be merged as is, because as mentioned above it breaks the pathfinding in certain areas. Disabling the bridge length check fixes this, but it in turn causes the pathfinding to occasionally produce some weirdly zig-zaggy sub-optimal paths, because of bugs in the pathfinding code. I have a fix for this stashed somewhere but it requires a bit more testing. I can look into that sometime soon once I finish the animation stuff I'm currently working on for EMI.

@Akz- Akz- mentioned this pull request Jun 14, 2014
Akz- added a commit to Akz-/residual that referenced this pull request Jun 14, 2014
Akz- pushed a commit to Akz-/residual that referenced this pull request Jun 15, 2014
@klusark
Copy link
Member

klusark commented Jun 16, 2014

This commit was merged with modifications to it's commit message.

3ec2347

@klusark klusark closed this Jun 16, 2014
klusark added a commit to klusark/residualvm that referenced this pull request Dec 14, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants