X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=physics_test.h;h=243de364933859c3d08881c5584fcf9295cfba08;hb=be5e25dee2c54c2a22ca3bbb5bbe0eb6149343be;hp=8187b914ab39c5ddf5e19c6fed7a28b33212b946;hpb=84a7ae83a25966e0004a1a4b409dbb3d49fae286;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/physics_test.h b/physics_test.h index 8187b91..243de36 100644 --- a/physics_test.h +++ b/physics_test.h @@ -1,3 +1,7 @@ +/* + * Copyright (C) 2021-2022 Mt.ZERO Software, Harry Godden - All Rights Reserved + */ + #ifndef PHYSICS_TEST_H #define PHYSICS_TEST_H @@ -9,6 +13,36 @@ rigidbody ground = { .type = k_rb_shape_box, .co = {0.0f, 0.0f, 0.0f}, .q = {0.0f,0.0f,0.0f,1.0f}, .is_world = 1 }; + +rigidbody blocky = + { + .type = k_rb_shape_box, + .bbx = {{-2.0f,-1.0f,-3.0f},{2.0f,1.0f,2.0f}}, + .co = {30.0f,2.0f,30.0f}, + .q = {0.0f,0.0f,0.0f,1.0f}, + .is_world = 1 + }; + +rigidbody marko = +{ + .type = k_rb_shape_box, + .bbx = {{-0.5f,-0.5f,-0.5f},{0.5f,0.5f,0.5f}}, + .co = {-36.0f,8.0f,-36.0f}, + .q = {0.0f,0.0f,0.0f,1.0f}, + .is_world = 0 +}; + +scene epic_scene; + +rigidbody epic_scene_rb = +{ + .type = k_rb_shape_scene, + .co = {0.0f,0.0f,0.0f}, + .q = {0.0f,0.0f,0.0f,1.0f}, + .is_world = 1, + .inf.scene = { .pscene = &epic_scene } +}; + rigidbody funnel[4] = { { .type = k_rb_shape_box, @@ -36,30 +70,84 @@ rigidbody funnel[4] = { } }; +rigidbody jeff1 = { .type = k_rb_shape_capsule, + .inf.capsule = { .radius = 0.75f, .height = 3.0f }, + .co = {30.0f, 4.0f, 30.0f }, + .q = {1.0f,0.0f,0.0f,0.0f} +}; rigidbody ball = { .type = k_rb_shape_sphere, .inf.sphere = { .radius = 2.0f }, - .co = {0.0f,6.0f,0.0f}, + .co = {0.0f,20.0f,2.0f}, .q = {0.0f,0.0f,0.0f,1.0f}}, ball1= { .type = k_rb_shape_sphere, - .inf.sphere = { .radius = 1.0f }, - .co = {0.1f,9.0f,0.2f}, + .inf.sphere = { .radius = 2.0f }, + .co = {0.1f,25.0f,0.2f}, .q = {0.0f,0.0f,0.0f,1.0f}}; +rigidbody jeffs[16]; + +static void reorg_jeffs(void) +{ + for( int i=0; inode_count; i++ ) + { + mdl_node *pnode = mdl_node_from_id( mdl, i ); + + for( int j=0; jsubmesh_count; j++ ) + { + mdl_submesh *sm = mdl_node_submesh( mdl, pnode, j ); + scene_add_submesh( &epic_scene, mdl, sm, transform ); + } + } + + vg_free( mdl ); + scene_bh_create( &epic_scene ); + + rb_init( &epic_scene_rb ); + rb_init( &marko ); } static void physics_test_update(void) @@ -67,45 +155,119 @@ static void physics_test_update(void) player_freecam(); player_camera_update(); - { + for( int i=0; i<4; i++ ) + rb_debug( &funnel[i], 0xff0060e0 ); + rb_debug( &ground, 0xff00ff00 ); + rb_debug( &ball, 0xffe00040 ); + rb_debug( &ball1, 0xff00e050 ); - rb_iter( &ball ); - rb_iter( &ball1 ); + rb_debug( &blocky, 0xffcccccc ); + rb_debug( &jeff1, 0xff00ffff ); + + rb_debug( &epic_scene_rb, 0xffcccccc ); + rb_debug( &marko, 0xffffcc00 ); + + { rb_solver_reset(); for( int i=0; i<4; i++ ) { - rb_contact_count += rb_sphere_vs_box( &ball, &funnel[i], rb_global_ct()); - rb_contact_count += rb_sphere_vs_box( &ball1, &funnel[i], rb_global_ct()); + rigidbody *fn = &funnel[i]; + rb_collide( &ball, fn ); + rb_collide( &ball1, fn ); + rb_collide( &jeff1, fn ); + + for( int i=0; i