VG_STATIC void rb_register_cvar(void)
{
- vg_var_push( (struct vg_var){
- .name = "k_limit_bias", .data = &k_limit_bias,
- .data_type = k_var_dtype_f32, .opt_f32 = {.clamp = 0}, .persistent = 1
- });
-
- vg_var_push( (struct vg_var){
- .name = "k_joint_bias", .data = &k_joint_bias,
- .data_type = k_var_dtype_f32, .opt_f32 = {.clamp = 0}, .persistent = 1
- });
-
- vg_var_push( (struct vg_var){
- .name = "k_joint_correction", .data = &k_joint_correction,
- .data_type = k_var_dtype_f32, .opt_f32 = {.clamp = 0}, .persistent = 1
- });
-
- vg_var_push( (struct vg_var){
- .name = "k_joint_impulse", .data = &k_joint_impulse,
- .data_type = k_var_dtype_f32, .opt_f32 = {.clamp = 0}, .persistent = 1
- });
+ VG_VAR_F32( k_limit_bias, flags=VG_VAR_CHEAT );
+ VG_VAR_F32( k_joint_bias, flags=VG_VAR_CHEAT );
+ VG_VAR_F32( k_joint_correction, flags=VG_VAR_CHEAT );
+ VG_VAR_F32( k_joint_impulse, flags=VG_VAR_CHEAT );
}
/*
typedef struct rb_capsule rb_capsule;
typedef struct rb_scene rb_scene;
-struct rb_sphere
-{
+struct rb_sphere{
float radius;
};
-struct rb_capsule
-{
+struct rb_capsule{
float height, radius;
};
-struct rb_scene
-{
+struct rb_scene{
bh_tree *bh_scene;
};
-struct rigidbody
-{
+struct rigidbody{
v3f co, v, w;
v4f q;
};
/* simple objects */
-struct rb_object
-{
+struct rb_object{
rigidbody rb;
enum rb_shape{
k_rb_shape_box = 0,
}
type;
- union
- {
+ union{
struct rb_sphere sphere;
struct rb_capsule capsule;
struct rb_scene scene;
inf;
};
-VG_STATIC struct contact
-{
+VG_STATIC struct contact{
rigidbody *rba, *rbb;
v3f co, n;
v3f t[2];
typedef struct rb_constr_pos rb_constr_pos;
typedef struct rb_constr_swingtwist rb_constr_swingtwist;
-struct rb_constr_pos
-{
+struct rb_constr_pos{
rigidbody *rba, *rbb;
v3f lca, lcb;
};
-struct rb_constr_swingtwist
-{
+struct rb_constr_swingtwist{
rigidbody *rba, *rbb;
v4f conevx, conevy; /* relative to rba */
float tangent_mass, axis_mass;
};
-struct rb_constr_spring
-{
+struct rb_constr_spring{
int nothing;
};
VG_STATIC void rb_tangent_basis( v3f n, v3f tx, v3f ty )
{
/* Compute tangent basis (box2d) */
- if( fabsf( n[0] ) >= 0.57735027f )
- {
+ if( fabsf( n[0] ) >= 0.57735027f ){
tx[0] = n[1];
tx[1] = -n[0];
tx[2] = 0.0f;
}
- else
- {
+ else{
tx[0] = 0.0f;
tx[1] = n[2];
tx[2] = -n[1];
v3f p1;
v3_muladds( ct->co, ct->n, 0.05f, p1 );
- if( ct->type == k_contact_type_default )
- {
+ if( ct->type == k_contact_type_default ){
vg_line_pt3( ct->co, 0.0125f, 0xff0000ff );
vg_line( ct->co, p1, 0xffffffff );
}
- else if( ct->type == k_contact_type_edge )
- {
+ else if( ct->type == k_contact_type_edge ){
vg_line_pt3( ct->co, 0.0125f, 0xff00ffc0 );
vg_line( ct->co, p1, 0xffffffff );
}
lx = { 0.0f, radius, 0.0f },
lz = { 0.0f, 0.0f, radius };
- for( int i=0; i<16; i++ )
- {
+ for( int i=0; i<16; i++ ){
float t = ((float)(i+1) * (1.0f/16.0f)) * VG_PIf * 2.0f,
s = sinf(t),
c = cosf(t);
vg_line( a0, a1, colour );
vg_line( b0, b1, colour );
- for( int i=0; i<16; i++ )
- {
+ for( int i=0; i<16; i++ ){
float t = ((float)(i+1) * (1.0f/16.0f)) * VG_PIf * 2.0f,
s1 = sinf(t)*radius,
c1 = cosf(t)*radius;
vg_line( a0, a1, colour );
vg_line( b0, b1, colour );
- if( c0 < 0.0f )
- {
+ if( c0 < 0.0f ){
v3_add( p0, e2, a0 );
v3_add( p0, e3, a1 );
v3_add( p0, e4, b0 );
v3_add( p0, e5, b1 );
}
- else
- {
+ else{
v3_add( p1, e2, a0 );
v3_add( p1, e3, a1 );
v3_add( p1, e4, b0 );