8187b914ab39c5ddf5e19c6fed7a28b33212b946
7 rigidbody ground
= { .type
= k_rb_shape_box
,
8 .bbx
= {{-100.0f
,-1.0f
,-100.0f
},{100.0f
,0.0f
,100.0f
}},
9 .co
= {0.0f
, 0.0f
, 0.0f
},
10 .q
= {0.0f
,0.0f
,0.0f
,1.0f
},
12 rigidbody funnel
[4] = {
14 .type
= k_rb_shape_box
,
15 .bbx
= {{-20.0f
,-1.0f
,-20.0f
},{20.0f
,1.0f
,20.0f
}},
16 .co
= {-10.0f
,5.0f
,0.0f
},
20 .type
= k_rb_shape_box
,
21 .bbx
= {{-20.0f
,-1.0f
,-20.0f
},{20.0f
,1.0f
,20.0f
}},
22 .co
= { 10.0f
,5.0f
,0.0f
},
26 .type
= k_rb_shape_box
,
27 .bbx
= {{-20.0f
,-1.0f
,-20.0f
},{20.0f
,1.0f
,20.0f
}},
28 .co
= { 0.0f
,5.0f
,10.0f
},
32 .type
= k_rb_shape_box
,
33 .bbx
= {{-20.0f
,-1.0f
,-20.0f
},{20.0f
,1.0f
,20.0f
}},
34 .co
= {0.0f
,5.0f
,-10.0f
},
40 rigidbody ball
= { .type
= k_rb_shape_sphere
,
41 .inf
.sphere
= { .radius
= 2.0f
},
42 .co
= {0.0f
,6.0f
,0.0f
},
43 .q
= {0.0f
,0.0f
,0.0f
,1.0f
}},
45 ball1
= { .type
= k_rb_shape_sphere
,
46 .inf
.sphere
= { .radius
= 1.0f
},
47 .co
= {0.1f
,9.0f
,0.2f
},
48 .q
= {0.0f
,0.0f
,0.0f
,1.0f
}};
50 static void physics_test_start(void)
52 q_axis_angle( funnel
[0].q
, (v3f
){1.0f
,0.0f
,0.0f
}, 0.3f
);
53 q_axis_angle( funnel
[1].q
, (v3f
){1.0f
,0.0f
,0.0f
}, -0.3f
);
54 q_axis_angle( funnel
[2].q
, (v3f
){0.0f
,0.0f
,1.0f
}, 0.3f
);
55 q_axis_angle( funnel
[3].q
, (v3f
){0.0f
,0.0f
,1.0f
}, -0.3f
);
57 for( int i
=0; i
<4; i
++ )
58 rb_init( &funnel
[i
] );
65 static void physics_test_update(void)
68 player_camera_update();
77 for( int i
=0; i
<4; i
++ )
79 rb_contact_count
+= rb_sphere_vs_box( &ball
, &funnel
[i
], rb_global_ct());
80 rb_contact_count
+= rb_sphere_vs_box( &ball1
, &funnel
[i
], rb_global_ct());
83 rb_contact_count
+= rb_sphere_vs_box( &ball
, &ground
, rb_global_ct() );
84 rb_contact_count
+= rb_sphere_vs_box( &ball1
, &ground
, rb_global_ct() );
85 rb_contact_count
+= rb_sphere_vs_sphere( &ball
, &ball1
, rb_global_ct() );
87 rb_presolve_contacts();
89 for( int i
=0; i
<5; i
++ )
92 rb_update_transform( &ball
);
93 rb_update_transform( &ball1
);
97 if(glfwGetKey( vg_window
, GLFW_KEY_L
))
99 v3_copy( player
.camera_pos
, ball
.co
);
104 for( int i
=0; i
<4; i
++ )
105 rb_debug( &funnel
[i
], 0xff0060e0 );
106 rb_debug( &ground
, 0xff00ff00 );
107 rb_debug( &ball
, 0xffe00040 );
108 rb_debug( &ball1
, 0xff00e050 );
111 static void physics_test_render(void)
114 m4x3_expand( player
.camera_inverse
, world_4x4
);
116 gpipeline
.fov
= freecam
? 60.0f
: 135.0f
; /* 120 */
117 m4x4_projection( vg_pv
, gpipeline
.fov
,
118 (float)vg_window_x
/ (float)vg_window_y
,
121 m4x4_mul( vg_pv
, world_4x4
, vg_pv
);
122 glEnable( GL_DEPTH_TEST
);
124 glDisable( GL_DEPTH_TEST
);
125 vg_lines_drawall( (float *)vg_pv
);
128 #endif /* PHYSICS_TEST_H */