Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Poirier <theeth@yahoo.com>2008-06-09 21:50:21 +0400
committerMartin Poirier <theeth@yahoo.com>2008-06-09 21:50:21 +0400
commitd5c80a3a1b05a184ab9dbf9e8b7be31f00c3461c (patch)
tree0e402c2100f226b5a38ef4ac9d13299c9397af21 /source/blender/blenkernel/intern/object.c
parentccc78eebdee6b019e485d94f8524daf0567d50a0 (diff)
Revision 14929 partial merged from apricot
(partial because I'll merge all snap code in one fell swoop after the libs are done) ---------------------------------- object: ray - boundbox intersection test
Diffstat (limited to 'source/blender/blenkernel/intern/object.c')
-rw-r--r--source/blender/blenkernel/intern/object.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 4f901ba7216..125243bc56f 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -2380,3 +2380,31 @@ int give_obdata_texspace(Object *ob, int **texflag, float **loc, float **size, f
}
return 1;
}
+
+/*
+ * Test a bounding box for ray intersection
+ * assumes the ray is already local to the boundbox space
+ */
+int ray_hit_boundbox(struct BoundBox *bb, float ray_start[3], float ray_normal[3])
+{
+ static int triangle_indexes[12][3] = {{0, 1, 2}, {0, 2, 3},
+ {3, 2, 6}, {3, 6, 7},
+ {1, 2, 6}, {1, 6, 5},
+ {5, 6, 7}, {4, 5, 7},
+ {0, 3, 7}, {0, 4, 7},
+ {0, 1, 5}, {0, 4, 5}};
+ int result = 0;
+ int i;
+
+ for (i = 0; i < 12 && result == 0; i++)
+ {
+ float lambda;
+ int v1, v2, v3;
+ v1 = triangle_indexes[i][0];
+ v2 = triangle_indexes[i][1];
+ v3 = triangle_indexes[i][2];
+ result = RayIntersectsTriangle(ray_start, ray_normal, bb->vec[v1], bb->vec[v2], bb->vec[v3], &lambda, NULL);
+ }
+
+ return result;
+}