summaryrefslogtreecommitdiffstats
path: root/libdimension/bench
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2014-08-19 17:10:03 -0400
committerTavian Barnes <tavianator@tavianator.com>2015-10-25 11:03:56 -0400
commit7b09710392d35fb55b52031d447a542d99fc6b4b (patch)
tree270eb927ee8c52ceeb99926ebf4843704775a610 /libdimension/bench
parent200c86b91ea7063d35be3bffc11c5da53c054653 (diff)
downloaddimension-7b09710392d35fb55b52031d447a542d99fc6b4b.tar.xz
Modularize the libdimension codebase.
Diffstat (limited to 'libdimension/bench')
-rw-r--r--libdimension/bench/future.c6
-rw-r--r--libdimension/bench/geometry.c37
-rw-r--r--libdimension/bench/polynomial.c3
-rw-r--r--libdimension/bench/prtree.c20
-rw-r--r--libdimension/bench/triangle.c10
5 files changed, 39 insertions, 37 deletions
diff --git a/libdimension/bench/future.c b/libdimension/bench/future.c
index fd26363..c8fb529 100644
--- a/libdimension/bench/future.c
+++ b/libdimension/bench/future.c
@@ -17,9 +17,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
-#include "../platform.c"
-#include "../future.c"
-#include "../threads.c"
+#include "../platform/platform.c"
+#include "../concurrency/future.c"
+#include "../concurrency/threads.c"
#include <sandglass.h>
#include <stdlib.h>
diff --git a/libdimension/bench/geometry.c b/libdimension/bench/geometry.c
index 68c9885..59d27e3 100644
--- a/libdimension/bench/geometry.c
+++ b/libdimension/bench/geometry.c
@@ -17,17 +17,18 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
-#include "dimension.h"
+#include "dimension/math.h"
#include <sandglass.h>
#include <stdlib.h>
+#include <stdio.h>
int
main(void)
{
dmnsn_vector vector, vector2;
dmnsn_matrix matrix, matrix2;
- dmnsn_line line;
- dmnsn_bounding_box box;
+ dmnsn_ray ray;
+ dmnsn_aabb box;
double result;
sandglass_t sandglass;
@@ -74,19 +75,19 @@ main(void)
});
printf("dmnsn_rotation_matrix(): %ld\n", sandglass.grains);
- // dmnsn_new_line()
+ // dmnsn_new_ray()
vector2 = dmnsn_new_vector(3.0, 2.0, 1.0);
sandglass_bench_fine(&sandglass, {
- line = dmnsn_new_line(vector, vector2);
+ ray = dmnsn_new_ray(vector, vector2);
});
- printf("dmnsn_new_line(): %ld\n", sandglass.grains);
+ printf("dmnsn_new_ray(): %ld\n", sandglass.grains);
- // dmnsn_new_bounding_box()
+ // dmnsn_new_aabb()
vector2 = dmnsn_new_vector(3.0, 4.0, 5.0);
sandglass_bench_fine(&sandglass, {
- box = dmnsn_new_bounding_box(vector, vector2);
+ box = dmnsn_new_aabb(vector, vector2);
});
- printf("dmnsn_new_bounding_box(): %ld\n", sandglass.grains);
+ printf("dmnsn_new_aabb(): %ld\n", sandglass.grains);
// dmnsn_vector_add()
sandglass_bench_fine(&sandglass, {
@@ -175,23 +176,23 @@ main(void)
});
printf("dmnsn_transform_normal(): %ld\n", sandglass.grains);
- // dmnsn_transform_line()
+ // dmnsn_transform_ray()
sandglass_bench_fine(&sandglass, {
- line = dmnsn_transform_line(matrix, line);
+ ray = dmnsn_transform_ray(matrix, ray);
});
- printf("dmnsn_transform_line(): %ld\n", sandglass.grains);
+ printf("dmnsn_transform_ray(): %ld\n", sandglass.grains);
- // dmnsn_transform_bounding_box()
+ // dmnsn_transform_aabb()
sandglass_bench_fine(&sandglass, {
- box = dmnsn_transform_bounding_box(matrix, box);
+ box = dmnsn_transform_aabb(matrix, box);
});
- printf("dmnsn_transform_bounding_box(): %ld\n", sandglass.grains);
+ printf("dmnsn_transform_aabb(): %ld\n", sandglass.grains);
- // dmnsn_line_point()
+ // dmnsn_ray_point()
sandglass_bench_fine(&sandglass, {
- vector = dmnsn_line_point(line, result);
+ vector = dmnsn_ray_point(ray, result);
});
- printf("dmnsn_line_point(): %ld\n", sandglass.grains);
+ printf("dmnsn_ray_point(): %ld\n", sandglass.grains);
return EXIT_SUCCESS;
}
diff --git a/libdimension/bench/polynomial.c b/libdimension/bench/polynomial.c
index bf3d2b0..33fd390 100644
--- a/libdimension/bench/polynomial.c
+++ b/libdimension/bench/polynomial.c
@@ -17,7 +17,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
-#include "dimension.h"
+#define DMNSN_INLINE extern inline
+#include "../math/polynomial.c"
#include <sandglass.h>
#include <stdlib.h>
diff --git a/libdimension/bench/prtree.c b/libdimension/bench/prtree.c
index 6c5d3ef..6b5e7c1 100644
--- a/libdimension/bench/prtree.c
+++ b/libdimension/bench/prtree.c
@@ -17,19 +17,19 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
-#include "../platform.c"
-#include "../threads.c"
-#include "../future.c"
-#include "../bvh.c"
-#include "../prtree.c"
+#include "../platform/platform.c"
+#include "../concurrency/threads.c"
+#include "../concurrency/future.c"
+#include "../bvh/bvh.c"
+#include "../bvh/prtree.c"
#include <sandglass.h>
#include <stdlib.h>
static bool
-dmnsn_fake_intersection_fn(const dmnsn_object *object, dmnsn_line line,
+dmnsn_fake_intersection_fn(const dmnsn_object *object, dmnsn_ray ray,
dmnsn_intersection *intersection)
{
- intersection->t = (object->bounding_box.min.z - line.x0.z)/line.n.z;
+ intersection->t = (object->aabb.min.z - ray.x0.z)/ray.n.z;
intersection->normal = dmnsn_x;
return true;
}
@@ -40,7 +40,7 @@ dmnsn_fake_inside_fn(const dmnsn_object *object, dmnsn_vector point)
return true;
}
-static dmnsn_bounding_box
+static dmnsn_aabb
dmnsn_fake_bounding_fn(const dmnsn_object *object, dmnsn_matrix trans)
{
dmnsn_vector a, b;
@@ -53,7 +53,7 @@ dmnsn_fake_bounding_fn(const dmnsn_object *object, dmnsn_matrix trans)
b.y = 2.0*((double)rand())/RAND_MAX - 1.0;
b.z = 2.0*((double)rand())/RAND_MAX - 1.0;
- return dmnsn_new_bounding_box(dmnsn_vector_min(a, b), dmnsn_vector_max(a, b));
+ return dmnsn_new_aabb(dmnsn_vector_min(a, b), dmnsn_vector_max(a, b));
}
static dmnsn_object_vtable dmnsn_fake_vtable = {
@@ -99,7 +99,7 @@ main(void)
printf("dmnsn_new_bvh(DMNSN_BVH_PRTREE): %ld\n", sandglass.grains);
// dmnsn_bvh_intersection()
- dmnsn_line ray = dmnsn_new_line(
+ dmnsn_ray ray = dmnsn_new_ray(
dmnsn_new_vector( 1.0, 1.0, -2.0),
dmnsn_new_vector(-0.5, -0.5, 1.0)
);
diff --git a/libdimension/bench/triangle.c b/libdimension/bench/triangle.c
index b2b91d0..4a5a456 100644
--- a/libdimension/bench/triangle.c
+++ b/libdimension/bench/triangle.c
@@ -43,21 +43,21 @@ main(void)
dmnsn_object_precompute(triangle);
dmnsn_intersection intersection;
- dmnsn_line line;
+ dmnsn_ray ray;
bool intersected;
// Intersecting case
- line = dmnsn_new_line(dmnsn_new_vector(2.0, 1.0, -1.0), dmnsn_z);
+ ray = dmnsn_new_ray(dmnsn_new_vector(2.0, 1.0, -1.0), dmnsn_z);
sandglass_bench_fine(&sandglass, {
- intersected = dmnsn_object_intersection(triangle, line, &intersection);
+ intersected = dmnsn_object_intersection(triangle, ray, &intersection);
});
dmnsn_assert(intersected, "Didn't intersect");
printf("dmnsn_triangle_intersection(true): %ld\n", sandglass.grains);
// Non-intersecting case
- line = dmnsn_new_line(dmnsn_new_vector(3.0, 3.0, -1.0), dmnsn_z);
+ ray = dmnsn_new_ray(dmnsn_new_vector(3.0, 3.0, -1.0), dmnsn_z);
sandglass_bench_fine(&sandglass, {
- intersected = dmnsn_object_intersection(triangle, line, &intersection);
+ intersected = dmnsn_object_intersection(triangle, ray, &intersection);
});
dmnsn_assert(!intersected, "Intersected");
printf("dmnsn_triangle_intersection(false): %ld\n", sandglass.grains);