diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2014-09-03 15:55:19 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2015-10-25 11:03:56 -0400 |
commit | b554b20c8d59d6046bdcec7c79fb61cd0e65811c (patch) | |
tree | a6c6f257cfaffcec953be7c0cce180f7a8855c68 /libdimension/bvh | |
parent | b2cf35c26d5263f3079480208429e3a1d7dd2373 (diff) | |
download | dimension-b554b20c8d59d6046bdcec7c79fb61cd0e65811c.tar.xz |
math: Make vectors have an array instead of different fields.
Diffstat (limited to 'libdimension/bvh')
-rw-r--r-- | libdimension/bvh/bvh.c | 14 | ||||
-rw-r--r-- | libdimension/bvh/prtree.c | 24 |
2 files changed, 19 insertions, 19 deletions
diff --git a/libdimension/bvh/bvh.c b/libdimension/bvh/bvh.c index eab2c28..9f460a2 100644 --- a/libdimension/bvh/bvh.c +++ b/libdimension/bvh/bvh.c @@ -186,7 +186,7 @@ dmnsn_optimize_ray(dmnsn_ray ray) { dmnsn_optimized_ray optray = { .x0 = ray.x0, - .n_inv = dmnsn_new_vector(1.0/ray.n.x, 1.0/ray.n.y, 1.0/ray.n.z) + .n_inv = dmnsn_new_vector(1.0/ray.n.X, 1.0/ray.n.Y, 1.0/ray.n.Z) }; return optray; } @@ -202,20 +202,20 @@ dmnsn_ray_box_intersection(dmnsn_optimized_ray optray, dmnsn_aabb box, double t) // or tmax == -inf, while rays inside the box will have tmin and tmax // unchanged. - double tx1 = (box.min.x - optray.x0.x)*optray.n_inv.x; - double tx2 = (box.max.x - optray.x0.x)*optray.n_inv.x; + double tx1 = (box.min.X - optray.x0.X)*optray.n_inv.X; + double tx2 = (box.max.X - optray.x0.X)*optray.n_inv.X; double tmin = dmnsn_min(tx1, tx2); double tmax = dmnsn_max(tx1, tx2); - double ty1 = (box.min.y - optray.x0.y)*optray.n_inv.y; - double ty2 = (box.max.y - optray.x0.y)*optray.n_inv.y; + double ty1 = (box.min.Y - optray.x0.Y)*optray.n_inv.Y; + double ty2 = (box.max.Y - optray.x0.Y)*optray.n_inv.Y; tmin = dmnsn_max(tmin, dmnsn_min(ty1, ty2)); tmax = dmnsn_min(tmax, dmnsn_max(ty1, ty2)); - double tz1 = (box.min.z - optray.x0.z)*optray.n_inv.z; - double tz2 = (box.max.z - optray.x0.z)*optray.n_inv.z; + double tz1 = (box.min.Z - optray.x0.Z)*optray.n_inv.Z; + double tz2 = (box.max.Z - optray.x0.Z)*optray.n_inv.Z; tmin = dmnsn_max(tmin, dmnsn_min(tz1, tz2)); tmax = dmnsn_min(tmax, dmnsn_max(tz1, tz2)); diff --git a/libdimension/bvh/prtree.c b/libdimension/bvh/prtree.c index c8e4e54..84fca58 100644 --- a/libdimension/bvh/prtree.c +++ b/libdimension/bvh/prtree.c @@ -74,48 +74,48 @@ enum { static int dmnsn_xmin_comp(const void *l, const void *r) { - double lval = (*(const dmnsn_colored_prnode **)l)->node->aabb.min.x; - double rval = (*(const dmnsn_colored_prnode **)r)->node->aabb.min.x; + double lval = (*(const dmnsn_colored_prnode **)l)->node->aabb.min.X; + double rval = (*(const dmnsn_colored_prnode **)r)->node->aabb.min.X; return (lval > rval) - (lval < rval); } static int dmnsn_ymin_comp(const void *l, const void *r) { - double lval = (*(const dmnsn_colored_prnode **)l)->node->aabb.min.y; - double rval = (*(const dmnsn_colored_prnode **)r)->node->aabb.min.y; + double lval = (*(const dmnsn_colored_prnode **)l)->node->aabb.min.Y; + double rval = (*(const dmnsn_colored_prnode **)r)->node->aabb.min.Y; return (lval > rval) - (lval < rval); } static int dmnsn_zmin_comp(const void *l, const void *r) { - double lval = (*(const dmnsn_colored_prnode **)l)->node->aabb.min.z; - double rval = (*(const dmnsn_colored_prnode **)r)->node->aabb.min.z; + double lval = (*(const dmnsn_colored_prnode **)l)->node->aabb.min.Z; + double rval = (*(const dmnsn_colored_prnode **)r)->node->aabb.min.Z; return (lval > rval) - (lval < rval); } static int dmnsn_xmax_comp(const void *l, const void *r) { - double lval = (*(const dmnsn_colored_prnode **)l)->node->aabb.max.x; - double rval = (*(const dmnsn_colored_prnode **)r)->node->aabb.max.x; + double lval = (*(const dmnsn_colored_prnode **)l)->node->aabb.max.X; + double rval = (*(const dmnsn_colored_prnode **)r)->node->aabb.max.X; return (lval < rval) - (lval > rval); } static int dmnsn_ymax_comp(const void *l, const void *r) { - double lval = (*(const dmnsn_colored_prnode **)l)->node->aabb.max.y; - double rval = (*(const dmnsn_colored_prnode **)r)->node->aabb.max.y; + double lval = (*(const dmnsn_colored_prnode **)l)->node->aabb.max.Y; + double rval = (*(const dmnsn_colored_prnode **)r)->node->aabb.max.Y; return (lval < rval) - (lval > rval); } static int dmnsn_zmax_comp(const void *l, const void *r) { - double lval = (*(const dmnsn_colored_prnode **)l)->node->aabb.max.z; - double rval = (*(const dmnsn_colored_prnode **)r)->node->aabb.max.z; + double lval = (*(const dmnsn_colored_prnode **)l)->node->aabb.max.Z; + double rval = (*(const dmnsn_colored_prnode **)r)->node->aabb.max.Z; return (lval < rval) - (lval > rval); } |