reverse skate into glider
[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 }
29
30 vg_line_boxf_transformed( baller.rb.to_world, baller.box, VG__RED );
31
32 world_instance *world = world_current_instance();
33
34 rigidbody _null = {0};
35 _null.inv_mass = 0.0f;
36 m3x3_zero( _null.iI );
37
38 rb_solver_reset();
39 rb_ct *buf = rb_global_buffer();
40 rb_contact_count += rb_box__scene( baller.rb.to_world, baller.box,
41 NULL, world->geo_bh, buf,
42 k_material_flag_ghosts );
43 for( u32 j=0; j<rb_contact_count; j++ ){
44 buf[j].rba = &baller.rb;
45 buf[j].rbb = &_null;
46 }
47
48 rb_presolve_contacts( rb_contact_buffer, rb_contact_count );
49
50 for( u32 i=0; i<8; i ++ )
51 rb_solve_contacts( rb_contact_buffer, rb_contact_count );
52
53 rb_iter( &baller.rb );
54 rb_update_matrices( &baller.rb );
55 }
56
57 static void testing_init(void){
58 rb_setbody_box( &baller.rb, baller.box, 8.0f, 1.0f );
59 }