Add line, plane, ray and segments, split math unit test
Added some basic geometric primitives such as planes, rays, segments and lines (plus some extra functions like xProject, xBarycentric, Lerpf), as well as some intersection tests between them. Additionally, I split massive math test into smaller ones and tweaked unit test library (testing no longer stops after first failure).
This commit is contained in:
@@ -28,12 +28,20 @@ typedef int (*BH_UnitCallback)(void);
|
||||
if (BH_VERIFY_DELTA < 0.0) \
|
||||
BH_VERIFY_DELTA = -BH_VERIFY_DELTA; \
|
||||
if (BH_VERIFY_DELTA > (e)) { \
|
||||
printf("%s:%d\t%s (differs by %f)\n", __FILE__, __LINE__, #x " == " #y, BH_VERIFY_DELTA); \
|
||||
printf("%s:%d\t%s (differs by %f)\n", \
|
||||
__FILE__, __LINE__, #x " == " #y, BH_VERIFY_DELTA); \
|
||||
return -1; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
|
||||
#define BH_UNIT_TEST(name) \
|
||||
static int unit##name(void)
|
||||
|
||||
|
||||
#define BH_UNIT_ADD(name) \
|
||||
BH_UnitAdd(#name, unit##name)
|
||||
|
||||
|
||||
/**
|
||||
* Adds unit test \a cb with name \a name for the testing.
|
||||
|
||||
@@ -55,6 +55,7 @@ void BH_UnitAdd(const char *name, BH_UnitCallback cb)
|
||||
int BH_UnitRun(void)
|
||||
{
|
||||
BH_Unit *current;
|
||||
int result = 0;
|
||||
printf("Running tests...\n");
|
||||
|
||||
current = root;
|
||||
@@ -64,15 +65,16 @@ int BH_UnitRun(void)
|
||||
if (current->cb())
|
||||
{
|
||||
printf("\tFAIL\n");
|
||||
BH_UnitCleanup();
|
||||
return -1;
|
||||
result = -1;
|
||||
}
|
||||
printf("\tPASS\n");
|
||||
else
|
||||
printf("\tPASS\n");
|
||||
|
||||
fflush(stdout);
|
||||
current = current->next;
|
||||
}
|
||||
|
||||
BH_UnitCleanup();
|
||||
return 0;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user