Commit Graph

244 Commits

Author SHA1 Message Date
Bill Currie dadfb78992 Split out the hull data so it can be used in other tests. 2011-12-03 20:23:42 +09:00
Bill Currie 9ad298a716 Check whether the portal and box intersect.
Now on to creating tests for MOD_HullContents :)
2011-12-03 19:59:12 +09:00
Bill Currie d9a641c600 Avoid a segfault when the hull hasn't been portalized.
Serves me right for forgetting to test the main engine :P
2011-12-03 09:06:57 +09:00
Bill Currie 27642a080a Avoid infinite recursion. 2011-12-01 12:57:06 +09:00
Bill Currie f9d56f2941 Add MOD_HullContents().
If trace is null or point type, or the hull doesn't have portals, or the
first node is a leaf, MOD_HullContents operates in point mode (exactly the
same way as SV_HullPointContents()). However, in box mode, all leafs
touched by the trace are checked for their contents. The contents field of
trace (a bit field) will indicate the contents type of all touched leafs.
The returned contents value indicates the most important contents:

    solid > lava > slime > water > empty

The one's complement value of the contents type is the bit number of the
contents bit field. I'm not sure how useful this will be as getting the
amount of overlap is currently not supported.
2011-12-01 12:26:33 +09:00
Bill Currie 7ee31dd475 Allow the trace start to be in multiple leafs.
This fixes a couple of in-solid tests, but something better is needed.
2011-11-28 20:56:21 +09:00
Bill Currie 13d37f4838 Add a bunch of in-solid tests.
Tests where the box is only partially in a solid tend to fail (particularly
when the solid is on the back side of the split plane).
2011-11-28 20:56:21 +09:00
Bill Currie 50b08c98fa Add some snug-fit tests and fix the uncovered bugs.
The tests involve the box fitting into a hole with zero slop (this would be
impossible with point clipping).
2011-11-28 20:56:21 +09:00
Bill Currie 985667ecba Fix plane touching box backsideness.
Because a box has size, even when touching a plane, the side on which the
box is can be determined (unlike a point).
2011-11-28 20:56:21 +09:00
Bill Currie 869cd19260 Box traces can now graze a corner. 2011-11-28 20:56:21 +09:00
Bill Currie 45d55d7e9a Test the simple wedge. 2011-11-28 20:56:21 +09:00
Bill Currie 2c9b07b257 Scale the box edge vectors.
Now they represent the lengths of the edges as expected by the edge/polygon
code.
2011-11-28 20:56:20 +09:00
Bill Currie 60dbc0e342 Fix the last few bugs breaking the distance code.
The code itself seems to work now. There are still some problems: the box
faces are using unit vectors for the edges, or I should go back to unit
vectors for the portal edges; starting in a solid corner won't always work;
etc. However, that's just mopping up: the main algorithm seems to be
working.
2011-11-28 20:56:20 +09:00
Bill Currie 996859c367 Correct the projection code.
That needed to be the intersection of two coplanar lines.
2011-11-28 20:56:20 +09:00
Bill Currie ab2ec644d6 Clip the portals when running the test cases.
When the portals are too big, floats break down and break the tests. This
might not be much of an issue in real maps, but my tests use "infinite"
planes.
2011-11-28 20:56:20 +09:00
Bill Currie 2abff68089 Fix some more silly bugs.
The target test now works, but some others have broken due to getting
negative fractions.
2011-11-28 20:56:20 +09:00
Bill Currie a1da8ecdd0 Fix some silly errors that broke most of the box tests.
Uninitialized variables and crossed signs. Oops :/
2011-11-28 20:56:20 +09:00
Bill Currie 8fc99566ab Add code to clip the motion of the box to the leaf's portals.
Unfortunately, something is broken (all box tests fail due to 0 fraction).
2011-11-28 20:56:20 +09:00
Bill Currie 5ee552ea5b Don't normalize the portal edge vectors.
This simplifies the collision handling code.
2011-11-28 20:56:20 +09:00
Bill Currie 174f381125 Add some more tests for the ramp.
These tests pass, but show the basic polygon testing working (just not the
collision handling and thus fraction determination).
2011-11-28 20:56:20 +09:00
Bill Currie 750b5ba0ed Be a little more lenient with float comparisons.
Unfortunately, Pythagorus and binary don't play well together, so rounding
errors are inevetible when testing with a slope. However, 1e-6 seems to be
a good epsilon (printf's %g hides it nicely :).
2011-11-28 20:56:20 +09:00
Bill Currie 73b93ffd74 Clean up the in_leaf test line. 2011-11-28 20:54:35 +09:00
Bill Currie e3d8394b7a Use the split_plane for the in-leaf test.
This seems to work better (all previously working tests pass again), but
the target test is still broken.
2011-11-28 20:54:35 +09:00
Bill Currie 7b59eaf0cd Use the correct vector for the plane distance.
Oops :)
2011-11-28 20:54:35 +09:00
Bill Currie cde0bbb807 For now, don't use box clipping for point traces.
Until I figure out how I want to handle zero sized boxes, don't test them.
2011-11-28 20:54:35 +09:00
Bill Currie fd5aee1d5e Use the portals to check leaf validity.
If the trace hits a portal on the plane that brought us to the leaf, then
we actually are in the leaf (otherwise, we shouldn't be here and thus
should ignore the leaf). At least, that's my thinking.

Many point tests fail (but they're really using box clipping with a zero
sized box) and two box tests fail.
2011-11-28 20:54:35 +09:00
Bill Currie 297275e3de Create edge information for the portals. 2011-11-28 20:54:35 +09:00
Bill Currie 662c04dfdc Add a function to obtain the unit vectors of a winding's edges. 2011-11-28 20:54:35 +09:00
Bill Currie e41da2f579 Store the start fraction and position in the right stack slot.
Oops. Yay, valgrind.
2011-11-28 20:54:35 +09:00
Bill Currie d61cb25a44 Add code to rebuild the bsp brushes.
Names and locations of declarations are still up in the air, but things
seem to be working assuming my test code is correct.
2011-11-28 20:54:35 +09:00
Bill Currie 853bf13d9e Move the winding code into libQFmodels. 2011-11-28 20:54:35 +09:00
Bill Currie 91e65b6c80 Rename mplane_t to plane_t and clean up the mess.
I got rather tired of there being multiple definitions of mostly compatible
plane types (and I need a common type anyway). dplane_t still exists for
now because I want to be careful when messing with the actual bsp format.
2011-11-28 20:54:34 +09:00
Bill Currie 2f23cfa4d0 Add a new (failing) test case.
This one demonstrates the need for more information in the bsp tree
(surface polygons). When the box collides with a corner where one side is
flat and the other angled, but there's a partition plane cutting the two,
the box can instead collide with the angled side before it hits the corner.
2011-11-28 20:54:34 +09:00
Bill Currie 7a1faee460 Bail out when the trace advances past the nearest collision. 2011-11-28 20:54:34 +09:00
Bill Currie a943cdf2c4 Handle dual collisions.
When the trace collides with something on both sides of a plane, the nearer
collision is required. The code now correctly checks both sides and keeps
the nearer collision.
2011-11-28 20:54:34 +09:00
Bill Currie 0cf5dec5bb Fix the covered step tests.
However,  there is still a problem with moves where the box is always cut
by the plane: both sides need to be tested (done), but when the first side
checked allows longer motion than the second, but still collides, only the
first side is checked. The shorter motion is required.
2011-11-28 20:54:34 +09:00
Bill Currie 8cc320b7ef Move the start point to the near side of the crossed plane.
I'm not sure the end point needs to be moved at all, but I'll leave it
alone for now. I have a couple of failing test cases that seem to be caused
by not handling moves where the box is always cut by the plane.
2011-11-28 20:54:34 +09:00
Bill Currie fa6390a46a Correct the sign for the shift in frac.
However, this is not entirely correct as the new start point when testing
the other side of the plane also needs to be calculated.
2011-11-28 20:54:34 +09:00
Bill Currie b82d9f5894 Another test, another bug.
Fix an incorrect test using offset (forgot to negate).
2011-11-28 20:54:34 +09:00
Bill Currie 9984a2e87a Fix some missing usages of offset.
This fixes my one failing box clip test. Now I need to find more broken
cases. At least now, they should be real tests.
2011-11-28 20:54:33 +09:00
Bill Currie 9d63298032 Tweak a fixme comment.
The code is potentially slow, especially on big maps, but I haven't noticed
any issues yet.
2011-11-28 20:54:33 +09:00
Bill Currie 03abb3b27d Add support for ellipsoids.
Not that boxes work yet, but the fix is the same.
2011-11-28 20:54:33 +09:00
Bill Currie b4da9241f6 Make a fresh start on box clipping.
I even have a failing test to fix :)
2011-11-28 20:54:33 +09:00
Bill Currie 940476dce1 Do some renaming to make things a little clearer. 2011-10-02 15:07:36 +09:00
Bill Currie a356ce6572 Assume the trace will be allsolid.
Rather than setting allsolid when the trace fails to leave solid space,
clear it when the trace enters non-solid space. This is necessary because
the trace might visit only one node and thus the failure to leave solid
space will not be detected. This fixes the problem with hipnotic's bobbing
water.
2011-09-27 17:14:42 +09:00
Bill Currie 9c6693d567 Correct hull3 and its tests.
I'd gotten the solid/empty parts backwards.
2011-09-27 17:11:57 +09:00
Bill Currie 3e74aa5303 Add trace-qf-bad.c to Makefile.am and testclip.c. 2011-09-27 17:09:04 +09:00
Bill Currie e23ee07b6f Ensure id's trace is properly initialized. 2011-09-27 15:38:28 +09:00
Bill Currie 32ff639bf3 Add an old qf version of trace.c
This version is broken (it's the one "fixed" by commit 981622f9), but it
does behave correctly for hipnotic's bobbing water. The question is, why?
2011-09-27 13:00:19 +09:00
Bill Currie 9daa0b7bde Rename the empty and solid flags, and use them correctly.
seen_empty and seen_solid much better reflect their meanings, and also use
them correctly (eg, visiting an empty node does not clear seen_solid).
Hipnotic's bobbing water is still broken, though.
2011-09-27 12:33:50 +09:00