2
0
mirror of https://github.com/rehlds/rehlds.git synced 2024-12-29 08:05:50 +03:00

BoxOnPlaneSide was fixed and covered by the flight tests

Added missed mathlib unit tests
This commit is contained in:
asmodai 2016-02-08 23:08:55 +03:00
parent 0d6a95093f
commit 2e270cb4ad
2 changed files with 86 additions and 9 deletions

View File

@ -93,10 +93,10 @@ void BOPS_Error(void)
Sys_Error("BoxOnPlaneSide: Bad signbits");
}
#ifdef REHLDS_FIXES
#ifdef REHLDS_OPT_PEDANTIC
int BoxOnPlaneSide(vec_t *emins, vec_t *emaxs, mplane_t *p)
{
float dist1, dist2;
double dist1, dist2;
int sides = 0;
__m128 emin = _mm_loadu_ps(emins);
@ -123,17 +123,17 @@ int BoxOnPlaneSide(vec_t *emins, vec_t *emaxs, mplane_t *p)
d2[1] = emaxs[1];
break;
case 3:
_mm_store_ps(d1, emax);
_mm_store_ps(d2, emin);
d1[2] = emins[2];
d2[2] = emaxs[2];
break;
case 4:
_mm_store_ps(d1, emin);
_mm_store_ps(d2, emax);
d1[2] = emaxs[2];
d2[2] = emins[2];
break;
case 4:
_mm_store_ps(d1, emax);
_mm_store_ps(d2, emin);
d1[2] = emins[2];
d2[2] = emaxs[2];
break;
case 5:
_mm_store_ps(d1, emin);
_mm_store_ps(d2, emax);

View File

@ -254,4 +254,81 @@ TEST(VectorAnglesTest, MathLib, 1000) {
cpuinfo.sse4_1 = 0;
}
}
}
TEST(VectorCompareTest, MathLib, 1000)
{
struct testdata_t {
vec4_t v1;
vec4_t v2;
int res;
};
testdata_t testdata[4] = {
{{41.5f, 7.32f, -9.22f, -16.1f}, {41.5f, 7.32f, -9.22f, -16.1009f}, 1},
{{41.5f, 7.32f, -9.22f, -16.1f}, {41.5f, 7.32f, -9.220002f, -16.1f}, 0},
{{41.5f, 7.32f, -9.22f, -16.1f}, {41.49f, 7.32f, -9.22f, -16.1f}, 0},
{{41.5f, 7.32001f, -9.22f, -16.1f}, {41.5f, 7.32f, -9.22f, -16.1f}, 0}
};
for (int i = 0; i < ARRAYSIZE(testdata); i++) {
int res = VectorCompare(testdata[i].v1, testdata[i].v2);
LONGS_EQUAL("VectorCompare mismatch", testdata[i].res, res);
}
}
TEST(VectorMATest, MathLib, 1000) {
struct testdata_t {
vec3_t a;
vec3_t m;
float s;
vec3_t res;
};
testdata_t testdata[2] = {
{{41.5f, 7.32f, -9.22f}, {-16.1f, -0.09f, 1.2f}, 42.14063f, {-636.964111f, 3.527344f, 41.348755f}},
{{0.96204f, 0.16969f, -0.21374f}, {347.65839f, 10.00326f, 0.0f}, 16.10025f, {5598.349121f, 161.224670f, -0.213740f}}
};
for (int i = 0; i < ARRAYSIZE(testdata); i++) {
vec3_t out;
VectorMA(testdata[i].a, testdata[i].s, testdata[i].m, out);
DOUBLES_EQUAL("VectorMA[0] mismatch", testdata[i].res[0], out[0], 0.00001);
DOUBLES_EQUAL("VectorMA[1] mismatch", testdata[i].res[1], out[1], 0.00001);
DOUBLES_EQUAL("VectorMA[2] mismatch", testdata[i].res[2], out[2], 0.00001);
}
}
TEST(R_ConcatTransformsTest, MathLib, 1000) {
struct testdata_t {
vec4_t in1[3];
vec4_t in2[3];
vec4_t res[3];
};
testdata_t testdata = {
{{0.41f, 13.34f, 41.69f, 14.78f}, {34.67f, 15.00f, 7.24f, 43.58f}, {19.62f, 7.05f, 32.81f, 49.61f}},
{{44.64f, 31.45f, 18.27f, 4.91f}, {29.95f, 48.27f, 23.91f, 39.02f}, {19.42f, 4.36f, 46.04f, 1.53f}},
{{1227.455200f, 838.584717f, 2245.857666f, 601.105591f}, {2137.519531f, 1845.987793f, 1325.400513f, 810.186890f}, {1724.154541f, 1100.404175f, 2037.595459f, 471.234528f}}
};
vec4_t out[3];
R_ConcatTransforms(testdata.in1, testdata.in2, out);
DOUBLES_EQUAL("R_ConcatTransformsTest[0][0] mismatch", testdata.res[0][0], out[0][0], 0.001);
DOUBLES_EQUAL("R_ConcatTransformsTest[0][1] mismatch", testdata.res[0][1], out[0][1], 0.001);
DOUBLES_EQUAL("R_ConcatTransformsTest[0][2] mismatch", testdata.res[0][2], out[0][2], 0.001);
DOUBLES_EQUAL("R_ConcatTransformsTest[0][3] mismatch", testdata.res[0][3], out[0][3], 0.001);
DOUBLES_EQUAL("R_ConcatTransformsTest[1][0] mismatch", testdata.res[1][0], out[1][0], 0.001);
DOUBLES_EQUAL("R_ConcatTransformsTest[1][1] mismatch", testdata.res[1][1], out[1][1], 0.001);
DOUBLES_EQUAL("R_ConcatTransformsTest[1][2] mismatch", testdata.res[1][2], out[1][2], 0.001);
DOUBLES_EQUAL("R_ConcatTransformsTest[1][3] mismatch", testdata.res[1][3], out[1][3], 0.001);
DOUBLES_EQUAL("R_ConcatTransformsTest[2][0] mismatch", testdata.res[2][0], out[2][0], 0.001);
DOUBLES_EQUAL("R_ConcatTransformsTest[2][1] mismatch", testdata.res[2][1], out[2][1], 0.001);
DOUBLES_EQUAL("R_ConcatTransformsTest[2][2] mismatch", testdata.res[2][2], out[2][2], 0.001);
DOUBLES_EQUAL("R_ConcatTransformsTest[2][3] mismatch", testdata.res[2][3], out[2][3], 0.001);
}