projects
/
vg.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
44847e6
)
allow option for backfaces in ray_triangle
author
hgn
<hgodden00@gmail.com>
Mon, 11 Dec 2023 16:03:31 +0000
(16:03 +0000)
committer
hgn
<hgodden00@gmail.com>
Mon, 11 Dec 2023 16:03:31 +0000
(16:03 +0000)
vg_m.h
patch
|
blob
|
history
diff --git
a/vg_m.h
b/vg_m.h
index 68e2304a339c13013eae62c3dd3644a62ae6118e..2de095eb544c3508af92b147dddafdbdc2c5eae6 100644
(file)
--- a/
vg_m.h
+++ b/
vg_m.h
@@
-2017,7
+2017,7
@@
int ray_aabb1( boxf box, v3f co, v3f dir_inv, f32 dist )
/* Time of intersection with ray vs triangle */
static int ray_tri( v3f tri[3], v3f co,
/* Time of intersection with ray vs triangle */
static int ray_tri( v3f tri[3], v3f co,
- v3f dir, f32 *dist )
+ v3f dir, f32 *dist
, int backfaces
)
{
f32 const kEpsilon = 0.00001f;
{
f32 const kEpsilon = 0.00001f;
@@
-2033,7
+2033,7
@@
static int ray_tri( v3f tri[3], v3f co,
v3_cross( dir, v1, h );
v3_cross( v0, v1, n );
v3_cross( dir, v1, h );
v3_cross( v0, v1, n );
- if(
v3_dot( n, dir ) > 0.0f
) /* Backface culling */
+ if(
(v3_dot( n, dir ) > 0.0f) && !backfaces
) /* Backface culling */
return 0;
/* Parralel */
return 0;
/* Parralel */
@@
-2171,7
+2171,7
@@
static int spherecast_triangle( v3f tri[3],
f32 t_min = INFINITY,
t1;
f32 t_min = INFINITY,
t1;
- if( ray_tri( sum, co, dir, &t1 ) ){
+ if( ray_tri( sum, co, dir, &t1
, 0
) ){
t_min = vg_minf( t_min, t1 );
hit = 1;
}
t_min = vg_minf( t_min, t1 );
hit = 1;
}