float3 tri_a tri_n_a float3 tri_b tri_n_b float3 tri_c tri_n_c if ray_

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
{
float3 a = tri_a + tri_n_a;
float3 b = tri_b + tri_n_b;
float3 c = tri_c + tri_n_c;
if (ray_triangle_intersect(P,
dir,
FLT_MAX,
a,
b,
c,
&u, &v, &t)) {
handle_hit(min_hit, max_hit, P, dir, t, u, v, tri_a, tri_b, tri_c);
}
if (ray_triangle_intersect(P,
dir,
FLT_MAX,
tri_a,
tri_b,
tri_c,
&u, &v, &t)) {
handle_hit(min_hit, max_hit, P, dir, t, u, v, tri_a + tri_n_a, tri_b + tri_n_b, tri_c + tri_n_c);
}
}
// side a, b
{
float3 a = tri_a;
float3 b = tri_b;
float3 c = tri_a + tri_n_a;
if (ray_triangle_intersect(P,
dir,
FLT_MAX,
a,
b,
c,
&u, &v, &t)) {
handle_hit(min_hit, max_hit, P, dir, t, u, v, a, b, c);
} else {
float3 a = tri_a + tri_n_a;
float3 b = tri_b;
float3 c = tri_b + tri_n_b;
if (ray_triangle_intersect(P,
dir,
FLT_MAX,
a,
b,
c,
&u, &v, &t)) {
handle_hit(min_hit, max_hit, P, dir, t, u, v, a, b, c);
}
}
}
// side b, c
{
float3 a = tri_b;
float3 b = tri_c;
float3 c = tri_b + tri_n_b;
if (ray_triangle_intersect(P,
dir,
FLT_MAX,
a,
b,
c,
&u, &v, &t)) {
handle_hit(min_hit, max_hit, P, dir, t, u, v, a, b, c);
} else {
float3 a = tri_b + tri_n_b;
float3 b = tri_c;
float3 c = tri_c + tri_n_c;
if (ray_triangle_intersect(P,
dir,
FLT_MAX,
a,
b,
c,
&u, &v, &t)) {
handle_hit(min_hit, max_hit, P, dir, t, u, v, a, b, c);
}
}
}
// // side c, a
{
float3 a = tri_c;
float3 b = tri_a;
float3 c = tri_c + tri_n_c;
if (ray_triangle_intersect(P,
dir,
FLT_MAX,
a,
b,
c,
&u, &v, &t)) {
handle_hit(min_hit, max_hit, P, dir, t, u, v, a, b, c);
} else {
float3 a = tri_c + tri_n_c;
float3 b = tri_a;
float3 c = tri_a + tri_n_a;
if (ray_triangle_intersect(P,
dir,
FLT_MAX,
a,
b,
c,
&u, &v, &t)) {
handle_hit(min_hit, max_hit, P, dir, t, u, v, a, b, c);
}
}
}