X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=rigidbody.h;h=01734e8f2d74760ab32659165a1a51c633a4785c;hb=eb6573694ca9292baaefee233dedb0b79f3ddc2e;hp=4318d8c1f294d117622c5421b840b239b2b74134;hpb=fa76acdf613baf7991fbceecbdbd7138620647f8;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/rigidbody.h b/rigidbody.h index 4318d8c..01734e8 100644 --- a/rigidbody.h +++ b/rigidbody.h @@ -3,13 +3,15 @@ * qu3e - Randy Gaul */ +#include "vg/vg.h" +static void rb_tangent_basis( v3f n, v3f tx, v3f ty ); + #ifndef RIGIDBODY_H #define RIGIDBODY_H #define RB_DEPR -#include "vg/vg.h" -#include "scene.h" +#include "world.h" #define k_rb_delta (1.0f/60.0f) @@ -106,7 +108,7 @@ static void rb_tangent_basis( v3f n, v3f tx, v3f ty ) v3_cross( n, tx, ty ); } -static void rb_build_manifold( rigidbody *rb, scene *sc ) +static void rb_build_manifold( rigidbody *rb ) { v3f *box = rb->bbx; v3f pts[8]; @@ -140,12 +142,16 @@ static void rb_build_manifold( rigidbody *rb, scene *sc ) struct contact *ct = &rb->manifold[rb->manifold_count]; v3f surface; - v3_copy( point, surface ); + surface[1] += 4.0f; ray_hit hit; - bvh_scene_sample( sc, surface, &hit ); + hit.dist = INFINITY; + if( !ray_world( surface, (v3f){0.0f,-1.0f,0.0f}, &hit )) + continue; + v3_copy( hit.normal, ct->n ); + v3_copy( hit.pos, surface ); float p = vg_minf( surface[1] - point[1], 1.0f );