0
0
Fork 0
mirror of https://git.code.sf.net/p/quake/quakeforge synced 2025-03-22 18:31:27 +00:00

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.
This commit is contained in:
Bill Currie 2011-11-12 21:30:45 +09:00
parent 8cc320b7ef
commit 0cf5dec5bb
2 changed files with 79 additions and 9 deletions
libs/models

View file

@ -145,10 +145,66 @@ hull_t hull_step1 = {
{0, 0, 0},
};
// 2
// 0
// eee|eee
// 0,32+--- 1
// eee|sss
// ---+sss 2
// ss0,0ss
mclipnode_t clipnodes_step2[] = {
{ 0, { 1, 2}},
{ 1, {CONTENTS_EMPTY, CONTENTS_SOLID}},
{ 2, {CONTENTS_EMPTY, CONTENTS_SOLID}},
};
mplane_t planes_step2[] = {
{{1, 0, 0}, 0, 0, 0},
{{0, 0, 1}, 32, 2, 0},
{{0, 0, 1}, 0, 2, 0},
};
hull_t hull_step2 = {
clipnodes_step2,
planes_step2,
0,
2,
{0, 0, 0},
{0, 0, 0},
};
// 0
// eee|eee
// 2---+0,32
// sss|eee
// sss+--- 1
// ss0,0ss
mclipnode_t clipnodes_step3[] = {
{ 0, { 1, 2}},
{ 1, {CONTENTS_EMPTY, CONTENTS_SOLID}},
{ 2, {CONTENTS_EMPTY, CONTENTS_SOLID}},
};
mplane_t planes_step3[] = {
{{1, 0, 0}, 0, 0, 0},
{{0, 0, 1}, 0, 2, 0},
{{0, 0, 1}, 32, 2, 0},
};
hull_t hull_step3 = {
clipnodes_step3,
planes_step3,
0,
2,
{0, 0, 0},
{0, 0, 0},
};
// 3 2
// s|e|eee
// 4-+e|-20,40
// e|e|eee
// 0,32+--- 1
// eee|sss
// ---+--- 0
// ss0,0ss
mclipnode_t clipnodes_covered_step[] = {
@ -256,11 +312,18 @@ test_t tests[] = {
{"Box, Covered Step", &box, &hull_covered_step,
{ -24, 0, 8}, {-24, 0, 72}, { 0.375, 0, 0, 1, 0}},
{"Box, Covered Step", &box, &hull_covered_step,
{ -24, 0, 8}, {8, 0, 72}, { 0.375, 0, 0, 1, 0}},
// {"Box, Covered Step", &box, &hull_covered_step,
// { -16, 0, 8}, {0, 0, 72}, { 1, 0, 0, 1, 0}},
{ -25, 0, 8}, {7, 0, 72}, { 0.375, 0, 0, 1, 0}},
{"Box, Covered Step", &box, &hull_covered_step,
{ -8, 0, 40}, {-16, 0, 40}, { 0.5, 0, 0, 1, 0}},
{"Box, Covered Step", &box, &hull_covered_step,
{ -17, 0, 8}, {-1, 0, 72}, { 1, 0, 0, 1, 0}},
{"Box, Covered Step", &box, &hull_covered_step,
{ -8, 0, 40}, {8, 0, 72}, { 1, 0, 0, 1, 0}},
{"Box, Step 2", &box, &hull_step2,
{ 0, 0, 64}, {0, 0, 0}, { 0.375, 0, 0, 1, 0}},
{"Box, Step 3", &box, &hull_step3,
{ 0, 0, 64}, {0, 0, 0}, { 0.375, 0, 0, 1, 0}},
};
#define num_tests (sizeof (tests) / sizeof (tests[0]))

View file

@ -208,11 +208,18 @@ MOD_TraceLine (hull_t *hull, int num,
// cross the plane
side = start_dist < 0;
frac[0] = (start_dist + offset) / (start_dist - end_dist);
frac[1] = (start_dist - offset) / (start_dist - end_dist);
frac[0] = bound (0, frac[0], 1);
frac[1] = bound (0, frac[1], 1);
if (start_dist < offset && end_dist < offset
&& start_dist >= -offset && end_dist >= end_dist) {
side = 0;
frac[0] = 1;
frac[1] = 0;
} else {
side = start_dist < offset;
frac[0] = (start_dist + offset) / (start_dist - end_dist);
frac[1] = (start_dist - offset) / (start_dist - end_dist);
frac[0] = bound (0, frac[0], 1);
frac[1] = bound (0, frac[1], 1);
}
tstack->num = num;
tstack->side = side;