rigidbody math corrections & ragdoll tweaks for stability
[carveJwlIkooP6JGAAIwe30JlM.git] / testing.c
1 #include "rigidbody.h"
2
3 static rb_object baller = {
4 .type = k_rb_shape_box,
5 .rb.bbx = {{ -0.1f, -0.2f, -0.1f },
6 { 0.1f, 1.0f, 0.1f }},
7 .rb.q = { 0,0,0,1 },
8 };
9
10 static void testing_update(void){
11 if( vg_getkey( SDLK_9 ) ){
12 v3_add( localplayer.rb.co, (v3f){0,1,0}, baller.rb.co );
13 v3_zero( baller.rb.w );
14 v3_zero( baller.rb.v );
15 q_identity( baller.rb.q );
16 rb_update_transform( &baller.rb );
17 }
18 rb_object_debug( &baller, VG__RED );
19
20 world_instance *world = world_current_instance();
21
22 rb_solver_reset();
23 rb_ct *buf = rb_global_buffer();
24 rb_contact_count += rb_box__scene( baller.rb.to_world, baller.rb.bbx,
25 NULL, &world->rb_geo.inf.scene, buf,
26 k_material_flag_ghosts );
27 for( u32 j=0; j<rb_contact_count; j++ ){
28 buf[j].rba = &baller.rb;
29 buf[j].rbb = &world->rb_geo.rb;
30 }
31
32 rb_presolve_contacts( rb_contact_buffer, rb_contact_count );
33
34 for( u32 i=0; i<8; i ++ )
35 rb_solve_contacts( rb_contact_buffer, rb_contact_count );
36
37 rb_iter( &baller.rb );
38 rb_update_transform( &baller.rb );
39 }
40
41 static void testing_init(void){
42 rb_init_object( &baller, 1.0f );
43 }