vg_compiler.name, uid, vg_compiler.build_dir );
}
+ if( vg_opt('p') || vg_long_opt("run") )
+ {
+ chdir( vg_compiler.build_dir );
+ vg_build_syscall( "./%s", vg_compiler.name );
+ chdir( "../../" );
+ }
+
if( vg_long_opt( "zip" ) || vg_opt( 'z' ) )
{
vg_build_syscall( "mkdir -p dist" );
#include "bvh.h"
VG_STATIC float
- k_walkspeed = 12.0f, /* no longer used */
+ k_walkspeed = 12.0f,
+ k_air_accelerate = 20.0f,
+
k_runspeed = 20.0f,
k_board_radius = 0.3f,
k_board_length = 0.45f,
});
vg_convar_push( (struct vg_convar){
- .name = "walk_speed",
+ .name = "gwalk_speed",
.data = &k_walkspeed,
.data_type = k_convar_dtype_f32,
.opt_f32 = { .clamp = 0 },
.persistent = 0
});
+ vg_convar_push( (struct vg_convar){
+ .name = "air_accelerate",
+ .data = &k_air_accelerate,
+ .data_type = k_convar_dtype_f32,
+ .opt_f32 = { .clamp = 0 },
+ .persistent = 0
+ });
+
vg_convar_push( (struct vg_convar){
.name = "run_speed",
.data = &k_runspeed,
v3f forward_dir = { sinf(player.angles[0]),0.0f,-cosf(player.angles[0]) };
v3f right_dir = { -forward_dir[2], 0.0f, forward_dir[0] };
+ v2f walk = { player.input_walkh->axis.value,
+ player.input_walkv->axis.value };
+
+ if( v2_length2(walk) > 0.001f )
+ v2_normalize_clamp( walk );
+
if( phys->in_air )
{
player_walk_update_collision();
rb_debug( rbf, 0xff0000ff );
rb_debug( rbb, 0xff0000ff );
+ /* allow player to accelerate a bit */
+ v3f walk_3d;
+ v3_muls( forward_dir, walk[1], walk_3d );
+ v3_muladds( walk_3d, right_dir, walk[0], walk_3d );
+
+ float current_vel = fabsf(v3_dot( walk_3d, phys->rb.v )),
+ new_vel = current_vel + VG_TIMESTEP_FIXED*k_air_accelerate,
+ clamped_new = vg_clampf( new_vel, 0.0f, k_walkspeed ),
+ vel_diff = vg_maxf( 0.0f, clamped_new - current_vel );
+
+ v3_muladds( phys->rb.v, right_dir, walk[0] * vel_diff, phys->rb.v );
+ v3_muladds( phys->rb.v, forward_dir, walk[1] * vel_diff, phys->rb.v );
+
+
len = 0;
len += rb_sphere_scene( rbf, &world.rb_geo, manifold+len );
len += rb_sphere_scene( rbb, &world.rb_geo, manifold+len );
}
else
{
- /* translate player */
- v2f walk = { player.input_walkh->axis.value,
- player.input_walkv->axis.value };
-
- if( v2_length2(walk) > 0.001f )
- v2_normalize_clamp( walk );
-
player.walk = v2_length( walk );
if( player.input_walk->button.value )
len += rb_sphere_scene( rbf, &world.rb_geo, manifold+len );
len += rb_sphere_scene( rbb, &world.rb_geo, manifold+len );
+ /*
+ * Preprocess collision points, and create a surface picture.
+ * we want contacts that are within our 'capsule's internal line to be
+ * clamped so that they face the line and do not oppose, to stop the
+ * player hanging up on stuff
+ */
+ for( int i=0; i<len; i++ )
+ {
+ v3f dfront, dback;
+ v3_sub( manifold[i].co, rbf->co, dfront );
+ v3_sub( manifold[i].co, rbb->co, dback );
+
+ if( (v3_dot( dfront, phys->rb.forward ) < -0.02f) &&
+ (v3_dot( dback, phys->rb.forward ) > 0.02f))
+ {
+ float p = v3_dot( manifold[i].n, phys->rb.forward );
+ v3_muladds( manifold[i].n, phys->rb.forward, -p, manifold[i].n );
+ v3_normalize( manifold[i].n );
+ }
+ }
+
rb_presolve_contacts( manifold, len );
v3f surface_avg = {0.0f, 0.0f, 0.0f};
vg_line( tri[1],tri[2],0x10ffffff );
vg_line( tri[2],tri[0],0x10ffffff );
- int hits = rb_sphere_triangle( rba, rbb, tri, buf+count );
+ int contact = rb_sphere_triangle( rba, rbb, tri, buf+count );
+
#ifdef RIGIDBODY_DYNAMIC_MESH_EDGES
- if( hits )
+ if( contact )
inf->collided = 1;
#endif
- count += hits;
+ count += contact;
if( count == 12 )
{
continue;
rb_ct *ct = buf+count;
-
+
v3_muls( inf_i->normal, c0, ct->n );
v3_muladds( ct->n, inf_j->normal, c1, ct->n );
v3_normalize( ct->n );
+++ /dev/null
-/*
- * Copyright (C) 2021-2022 Mt.ZERO Software, Harry Godden - All Rights Reserved
- */
-
-#define VG_CONFIG
-#include "vg/vg.h"
-
-VG_STATIC struct button_binding vg_button_binds[] =
-{
- { .name = "primary", .bind = GLFW_MOUSE_BUTTON_LEFT },
- { .name = "secondary", .bind = GLFW_MOUSE_BUTTON_RIGHT },
- { .name = "left", .bind = GLFW_KEY_A },
- { .name = "right", .bind = GLFW_KEY_D },
- { .name = "forward", .bind = GLFW_KEY_W },
- { .name = "back", .bind = GLFW_KEY_S },
- { .name = "up", .bind = GLFW_KEY_R },
- { .name = "reset", .bind = GLFW_KEY_R },
- { .name = "down", .bind = GLFW_KEY_F },
- { .name = "yawl", .bind = GLFW_KEY_Q },
- { .name = "yawr", .bind = GLFW_KEY_E },
- { .name = "jump", .bind = GLFW_KEY_SPACE },
- { .name = "kbdwalk/push", .bind = GLFW_KEY_LEFT_SHIFT },
- { .name = "switchmode", .bind = GLFW_KEY_E },
- { .name = "menu", .bind = GLFW_KEY_ESCAPE }
-};
-
-VG_STATIC struct button_binding vg_controller_binds[] =
-{
- { "jump", GLFW_GAMEPAD_BUTTON_A },
- { "break", GLFW_GAMEPAD_BUTTON_B },
- { "switchmode", GLFW_GAMEPAD_BUTTON_Y },
- { "reset", GLFW_GAMEPAD_BUTTON_LEFT_BUMPER },
- { "menu", GLFW_GAMEPAD_BUTTON_BACK }
-};
-
-VG_STATIC struct axis_binding vg_axis_binds[] =
-{
- { .name = "lookh", .axis = GLFW_GAMEPAD_AXIS_LEFT_X },
- { .name = "lookv", .axis = GLFW_GAMEPAD_AXIS_LEFT_Y },
- { .name = "grabh", .axis = GLFW_GAMEPAD_AXIS_RIGHT_X },
- { .name = "grabv", .axis = GLFW_GAMEPAD_AXIS_RIGHT_Y },
- { .name = "walk/push", .axis = GLFW_GAMEPAD_AXIS_LEFT_TRIGGER },
- { .name = "grab", .axis = GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER },
-};
-
-VG_STATIC struct vg_achievement vg_achievements[] =
-{
-};