minor changes to be on track with vg revision
[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_console.cheats )
18 return;
19
20 if( vg_getkey( SDLK_9 ) ){
21 v3_add( localplayer.rb.co, (v3f){0,1,0}, baller.rb.co );
22 v3_zero( baller.rb.w );
23 v3_zero( baller.rb.v );
24 q_identity( baller.rb.q );
25 rb_update_matrices( &baller.rb );
26 }
27
28 if( vg_getkey( SDLK_8 ) ){
29 localplayer.have_glider = 1;
30 localplayer.glider_orphan = 0;
31 player_glide.t = -1.0f;
32 }
33
34 vg_line_boxf_transformed( baller.rb.to_world, baller.box, VG__RED );
35
36 world_instance *world = world_current_instance();
37
38 rigidbody _null = {0};
39 _null.inv_mass = 0.0f;
40 m3x3_zero( _null.iI );
41
42 rb_solver_reset();
43 rb_ct *buf = rb_global_buffer();
44 rb_contact_count += rb_box__scene( baller.rb.to_world, baller.box,
45 NULL, world->geo_bh, buf,
46 k_material_flag_ghosts );
47 for( u32 j=0; j<rb_contact_count; j++ ){
48 buf[j].rba = &baller.rb;
49 buf[j].rbb = &_null;
50 }
51
52 rb_presolve_contacts( rb_contact_buffer, rb_contact_count );
53
54 for( u32 i=0; i<8; i ++ )
55 rb_solve_contacts( rb_contact_buffer, rb_contact_count );
56
57 rb_iter( &baller.rb );
58 rb_update_matrices( &baller.rb );
59 }
60
61 static void testing_init(void){
62 rb_setbody_box( &baller.rb, baller.box, 8.0f, 1.0f );
63 }