add logs for fall off reason
[carveJwlIkooP6JGAAIwe30JlM.git] / testing.c
1 #pragma once
2 #include "vg/vg_m.h"
3 #include "vg/vg_rigidbody.h"
4 #include "scene_rigidbody.h"
5
6 struct {
7 rigidbody rb;
8 boxf box;
9 }
10 static baller = {
11 .rb.q = { 0,0,0,1 },
12 .box = {{ -0.1f, -0.2f, -0.1f },
13 { 0.1f, 1.0f, 0.1f }},
14 };
15
16 static void testing_update(void){
17 if( vg_getkey( SDLK_9 ) ){
18 v3_add( localplayer.rb.co, (v3f){0,1,0}, baller.rb.co );
19 v3_zero( baller.rb.w );
20 v3_zero( baller.rb.v );
21 q_identity( baller.rb.q );
22 rb_update_matrices( &baller.rb );
23 }
24
25 if( vg_getkey( SDLK_8 ) ){
26 localplayer.have_glider = 1;
27 localplayer.glider_orphan = 0;
28 player_glide.t = -1.0f;
29 }
30
31 vg_line_boxf_transformed( baller.rb.to_world, baller.box, VG__RED );
32
33 world_instance *world = world_current_instance();
34
35 rigidbody _null = {0};
36 _null.inv_mass = 0.0f;
37 m3x3_zero( _null.iI );
38
39 rb_solver_reset();
40 rb_ct *buf = rb_global_buffer();
41 rb_contact_count += rb_box__scene( baller.rb.to_world, baller.box,
42 NULL, world->geo_bh, buf,
43 k_material_flag_ghosts );
44 for( u32 j=0; j<rb_contact_count; j++ ){
45 buf[j].rba = &baller.rb;
46 buf[j].rbb = &_null;
47 }
48
49 rb_presolve_contacts( rb_contact_buffer, rb_contact_count );
50
51 for( u32 i=0; i<8; i ++ )
52 rb_solve_contacts( rb_contact_buffer, rb_contact_count );
53
54 rb_iter( &baller.rb );
55 rb_update_matrices( &baller.rb );
56 }
57
58 static void testing_init(void){
59 rb_setbody_box( &baller.rb, baller.box, 8.0f, 1.0f );
60 }