summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnthony LaTorre <tlatorre9@gmail.com>2011-06-19 18:29:27 -0400
committerAnthony LaTorre <tlatorre9@gmail.com>2011-06-19 18:29:27 -0400
commita149f96a766c4d8d63919535cc468c539036165e (patch)
treefa6eece7b811e098e58fc4aa53d97a8c3dc1885e /src
parentad56515169bab5f069344e960d9582412c3672f4 (diff)
downloadchroma-a149f96a766c4d8d63919535cc468c539036165e.tar.gz
chroma-a149f96a766c4d8d63919535cc468c539036165e.tar.bz2
chroma-a149f96a766c4d8d63919535cc468c539036165e.zip
reverse the face orientation on all triangles in the stl files exported from sketchup.
Diffstat (limited to 'src')
-rw-r--r--src/intersect.h2
-rw-r--r--src/kernel.cu2
2 files changed, 2 insertions, 2 deletions
diff --git a/src/intersect.h b/src/intersect.h
index bfde782..0b713c8 100644
--- a/src/intersect.h
+++ b/src/intersect.h
@@ -60,7 +60,7 @@ __device__ bool intersect_triangle(const float3 &origin, const float3 &direction
`direction` must be normalized. */
__device__ int get_color(const float3 &direction, const float3 &v0, const float3& v1, const float3 &v2, const int base_color=0xFFFFFFFF)
{
- float scale = dot(normalize(cross(v1-v0,v2-v0)),-direction);
+ float scale = dot(normalize(cross(v1-v0,v2-v1)),-direction);
unsigned int r = 0xFF & (base_color >> 16);
unsigned int g = 0xFF & (base_color >> 8);
diff --git a/src/kernel.cu b/src/kernel.cu
index b7dadfa..6c3ef1b 100644
--- a/src/kernel.cu
+++ b/src/kernel.cu
@@ -267,7 +267,7 @@ __global__ void propagate(int nthreads, float3 *positions, float3 *directions, f
int material_out_index = tex1Dfetch(material2_lookup, last_hit_triangle);
int surface_index = tex1Dfetch(surface_lookup, last_hit_triangle);
- float3 surface_normal = cross(v1-v0,v2-v0);
+ float3 surface_normal = cross(v1-v0,v2-v1);
surface_normal /= norm(surface_normal);
Material material1, material2;