summaryrefslogtreecommitdiff
path: root/src/mesh.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesh.h')
-rw-r--r--src/mesh.h40
1 files changed, 18 insertions, 22 deletions
diff --git a/src/mesh.h b/src/mesh.h
index c6ef8f6..734ab92 100644
--- a/src/mesh.h
+++ b/src/mesh.h
@@ -12,11 +12,11 @@
less than `min_distance`, return true, else return false. */
__device__ bool
intersect_node(const float3 &origin, const float3 &direction,
- Geometry *geometry, const int &i, float min_distance=-1.0f)
+ Geometry *g, int i, float min_distance=-1.0f)
{
/* assigning these to local variables is faster for some reason */
- float3 lower_bound = geometry->lower_bounds[i];
- float3 upper_bound = geometry->upper_bounds[i];
+ float3 lower_bound = g->lower_bounds[i];
+ float3 upper_bound = g->upper_bounds[i];
float distance_to_box;
@@ -42,17 +42,15 @@ intersect_node(const float3 &origin, const float3 &direction,
the intersection and return the index of the triangle which the ray
intersected, else return -1. */
__device__ int
-intersect_mesh(const float3 &origin, const float3& direction,
- Geometry *geometry, float &min_distance,
- int last_hit_triangle = -1)
+intersect_mesh(const float3 &origin, const float3& direction, Geometry *g,
+ float &min_distance, int last_hit_triangle = -1)
{
int triangle_index = -1;
float distance;
min_distance = -1.0f;
- if (!intersect_node(origin, direction, geometry, geometry->start_node,
- min_distance))
+ if (!intersect_node(origin, direction, g, g->start_node, min_distance))
return -1;
unsigned int stack[STACK_SIZE];
@@ -60,25 +58,24 @@ intersect_mesh(const float3 &origin, const float3& direction,
unsigned int *head = &stack[0];
unsigned int *node = &stack[1];
unsigned int *tail = &stack[STACK_SIZE-1];
- *node = geometry->start_node;
+ *node = g->start_node;
unsigned int i;
do
{
- unsigned int first_child = geometry->node_map[*node];
- unsigned int stop = geometry->node_map_end[*node];
+ unsigned int first_child = g->node_map[*node];
+ unsigned int stop = g->node_map_end[*node];
- while (*node >= geometry->first_node && stop == first_child+1) {
+ while (*node >= g->first_node && stop == first_child+1) {
*node = first_child;
- first_child = geometry->node_map[*node];
- stop = geometry->node_map_end[*node];
+ first_child = g->node_map[*node];
+ stop = g->node_map_end[*node];
}
- if (*node >= geometry->first_node) {
+ if (*node >= g->first_node) {
for (i=first_child; i < stop; i++) {
- if (intersect_node(origin, direction, geometry, i,
- min_distance)) {
+ if (intersect_node(origin, direction, g, i, min_distance)) {
*node = i;
node++;
}
@@ -92,10 +89,9 @@ intersect_mesh(const float3 &origin, const float3& direction,
if (last_hit_triangle == i)
continue;
- Triangle triangle = get_triangle(geometry, i);
+ Triangle t = get_triangle(g, i);
- if (intersect_triangle(origin, direction, triangle,
- distance)) {
+ if (intersect_triangle(origin, direction, t, distance)) {
if (triangle_index == -1) {
triangle_index = i;
min_distance = distance;
@@ -145,7 +141,7 @@ distance_to_mesh(int nthreads, float3 *_origin, float3 *_direction,
__global__ void
color_solids(int first_triangle, int nthreads, int *solid_id_map,
- bool *solid_hit, unsigned int *solid_colors, Geometry *geometry)
+ bool *solid_hit, unsigned int *solid_colors, Geometry *g)
{
int id = blockIdx.x*blockDim.x + threadIdx.x;
@@ -155,7 +151,7 @@ color_solids(int first_triangle, int nthreads, int *solid_id_map,
int triangle_id = first_triangle + id;
int solid_id = solid_id_map[triangle_id];
if (solid_hit[solid_id])
- geometry->colors[triangle_id] = solid_colors[solid_id];
+ g->colors[triangle_id] = solid_colors[solid_id];
}
} // extern "C"