rigidbody math corrections & ragdoll tweaks for stability
[carveJwlIkooP6JGAAIwe30JlM.git] / testing.c
diff --git a/testing.c b/testing.c
new file mode 100644 (file)
index 0000000..b5b4cec
--- /dev/null
+++ b/testing.c
@@ -0,0 +1,43 @@
+#include "rigidbody.h"
+
+static rb_object baller = {
+   .type = k_rb_shape_box,
+   .rb.bbx = {{ -0.1f, -0.2f, -0.1f },
+              {  0.1f,  1.0f,  0.1f }},
+   .rb.q = { 0,0,0,1 },
+};
+
+static void testing_update(void){
+   if( vg_getkey( SDLK_9 ) ){
+      v3_add( localplayer.rb.co, (v3f){0,1,0}, baller.rb.co );
+      v3_zero( baller.rb.w );
+      v3_zero( baller.rb.v );
+      q_identity( baller.rb.q );
+      rb_update_transform( &baller.rb );
+   }
+   rb_object_debug( &baller, VG__RED );
+
+   world_instance *world = world_current_instance();
+
+   rb_solver_reset();
+   rb_ct *buf = rb_global_buffer();
+   rb_contact_count += rb_box__scene( baller.rb.to_world, baller.rb.bbx,
+                          NULL, &world->rb_geo.inf.scene, buf,
+                          k_material_flag_ghosts );
+   for( u32 j=0; j<rb_contact_count; j++ ){
+      buf[j].rba = &baller.rb;
+      buf[j].rbb = &world->rb_geo.rb;
+   }
+
+   rb_presolve_contacts( rb_contact_buffer, rb_contact_count );
+
+   for( u32 i=0; i<8; i ++ )
+      rb_solve_contacts( rb_contact_buffer, rb_contact_count );
+
+   rb_iter( &baller.rb );
+   rb_update_transform( &baller.rb );
+}
+
+static void testing_init(void){
+   rb_init_object( &baller, 1.0f );
+}