summaryrefslogtreecommitdiffstats
path: root/libdimension
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2009-06-13 22:55:32 +0000
committerTavian Barnes <tavianator@gmail.com>2009-06-13 22:55:32 +0000
commit042ef96e2c004a963451edc9efa7074316a360c4 (patch)
tree65140c2248010a79982226ae2ef75ceeae006a02 /libdimension
parent5e605e80937a02a55e2d2b94bce715ff937e0d26 (diff)
downloaddimension-042ef96e2c004a963451edc9efa7074316a360c4.tar.xz
Pass pointer to object in object callbacks.
Diffstat (limited to 'libdimension')
-rw-r--r--libdimension/dimension/object.h6
-rw-r--r--libdimension/sphere.c10
2 files changed, 10 insertions, 6 deletions
diff --git a/libdimension/dimension/object.h b/libdimension/dimension/object.h
index c79d62e..b9702f4 100644
--- a/libdimension/dimension/object.h
+++ b/libdimension/dimension/object.h
@@ -25,8 +25,10 @@
* Objects.
*/
-typedef dmnsn_array *dmnsn_object_intersections_fn(dmnsn_line line);
-typedef int dmnsn_object_inside_fn(dmnsn_vector point);
+typedef dmnsn_array *dmnsn_object_intersections_fn(const dmnsn_object *object,
+ dmnsn_line line);
+typedef int dmnsn_object_inside_fn(const dmnsn_object *object,
+ dmnsn_vector point);
typedef struct {
/* Generic pointer for object info */
diff --git a/libdimension/sphere.c b/libdimension/sphere.c
index a14070e..74f414d 100644
--- a/libdimension/sphere.c
+++ b/libdimension/sphere.c
@@ -22,8 +22,10 @@
#include <stdlib.h> /* For malloc */
#include <math.h> /* For sqrt */
-static dmnsn_array *dmnsn_sphere_intersections_fn(dmnsn_line line);
-static int dmnsn_sphere_inside_fn(dmnsn_vector point);
+static dmnsn_array *dmnsn_sphere_intersections_fn(const dmnsn_sphere *sphere,
+ dmnsn_line line);
+static int dmnsn_sphere_inside_fn(const dmnsn_sphere *sphere,
+ dmnsn_vector point);
dmnsn_object *
dmnsn_new_sphere()
@@ -43,7 +45,7 @@ dmnsn_delete_sphere(dmnsn_object *sphere)
}
static dmnsn_array *
-dmnsn_sphere_intersections_fn(dmnsn_line line)
+dmnsn_sphere_intersections_fn(const dmnsn_object *sphere, dmnsn_line line)
{
double a, b, c, t[2];
dmnsn_array *array = dmnsn_new_array(sizeof(double));
@@ -65,7 +67,7 @@ dmnsn_sphere_intersections_fn(dmnsn_line line)
}
static int
-dmnsn_sphere_inside_fn(dmnsn_vector point)
+dmnsn_sphere_inside_fn(const dmnsn_object *sphere, dmnsn_vector point)
{
return sqrt(point.x*point.x + point.y*point.y + point.z*point.z) < 1.0;
}