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