#include "ent_skateshop.h"
#include "addon.h"
+#include "ent_tornado.c"
+
static void player__skate_bind(void){
struct skeleton *sk = &localplayer.skeleton;
rb_update_transform( &localplayer.rb );
inf->gravity = gravity;
v3_copy( launch_v, inf->v );
+ /* initial conditions */
+ v3f v;
+ v3_copy( launch_v, v );
+ v3_copy( launch_co, co1 );
+
for( int i=1; i<=50; i++ ){
- float t = (float)i * k_trace_delta;
+ f32 t = (f32)i * k_trace_delta;
- v3_muls( launch_v, t, co1 );
- co1[1] += -0.5f * gravity * t*t;
- v3_add( launch_co, co1, co1 );
+ /* integrate forces */
+ v3f a;
+ ent_tornado_forces( co1, v, a );
+ a[1] -= gravity;
- float launch_vy = launch_v[1];
+ /* position */
+ v3_muladds( co1, v, k_trace_delta, co1 );
+ v3_muladds( co1, a, 0.5f*k_trace_delta*k_trace_delta, co1 );
+
+ /* velocity */
+ v3_muladds( v, a, k_trace_delta, v );
int search_for_grind = 1;
if( grind_located ) search_for_grind = 0;
- if( launch_vy - gravity*t > 0.0f ) search_for_grind = 0;
+ if( v[1] > 0.0f ) search_for_grind = 0;
/* REFACTOR */
}
if( search_for_grind ){
- v3f ve;
- v3_copy( launch_v, ve );
- ve[1] += -gravity * t;
-
- if( skate_grind_scansq( closest, ve, 0.5f, &grind ) ){
+ if( skate_grind_scansq( closest, v, 0.5f, &grind ) ){
/* check alignment */
- v2f v0 = { ve[0], ve[2] },
+ v2f v0 = { v[0], v[2] },
v1 = { grind.dir[0], grind.dir[2] };
v2_normalize( v0 );
a_min = cosf( VG_PIf * 0.05f );
/* check speed */
- if( (fabsf(v3_dot( ve, grind.dir ))>=k_grind_axel_min_vel) &&
+ if( (fabsf(v3_dot( v, grind.dir ))>=k_grind_axel_min_vel) &&
(a >= a_min) &&
(fabsf(grind.dir[1]) < 0.70710678118654752f))
{
world_tri_index_surface( trace_world, tri[0] );
inf->type = k_prediction_land;
-
- v3f ve;
- v3_copy( launch_v, ve );
- ve[1] += -gravity * t;
-
- inf->score = -v3_dot( ve, inf->n );
+ inf->score = -v3_dot( v, inf->n );
inf->land_dist = t + k_trace_delta * t1;
/* Bias prediction towords ramps */
f32 lat = k_friction_lat;
if( fabsf(axis_state(k_sraxis_skid)) > 0.1f ){
- lat = k_friction_lat * 2.0f;
+ if( (player_skate.surface == k_surface_prop_snow) ||
+ (player_skate.surface == k_surface_prop_sand) ){
+ lat *= 8.0f;
+ }
+ else
+ lat *= 1.5f;
}
- vel[0] += vg_cfrictf( vel[0], k_friction_lat * k_rb_delta );
+ if( player_skate.surface == k_surface_prop_snow )
+ lat *= 0.5f;
+ else if( player_skate.surface == k_surface_prop_sand )
+ lat *= 0.6f;
+
+ vel[0] += vg_cfrictf( vel[0], lat * k_rb_delta );
vel[2] += vg_cfrictf( vel[2], k_friction_resistance * k_rb_delta );
/* Pushing additive force */
if( button_down(k_srbind_use) && (v3_length2(state->trick_vel) < 0.01f) ){
localplayer.subsystem = k_player_subsystem_walk;
+ if( state->activity <= k_skate_activity_air_to_grind ){
+ localplayer.subsystem = k_player_subsystem_glide;
+ player__begin_holdout( (v3f){0,0,0} );
+ return;
+ }
+
v3f angles;
v3_copy( localplayer.cam.angles, localplayer.angles );
localplayer.angles[2] = 0.0f;
player__begin_holdout( offset );
player__walk_transition( state->activity <= k_skate_activity_air_to_grind?
0: 1, state->trick_euler[0] );
+
return;
}
skate_apply_trick_model();
skate_apply_pump_model();
+ ent_tornado_debug();
+ v3f a;
+ ent_tornado_forces( localplayer.rb.co, localplayer.rb.v, a );
+ v3_muladds( localplayer.rb.v, a, k_rb_delta, localplayer.rb.v );
+
begin_collision:;
/*
static void player__skate_effects( void *_animator, m4x3f *final_mtx,
struct player_board *board,
struct player_effects_data *effect_data ){
-
struct skeleton *sk = &localplayer.skeleton;
struct player_skate_animator *animator = _animator;
- if( animator->grind > 0.5f ){
- v3f vp0, vp1, vpc;
- if( board ){
- v3_copy((v3f){0.0f,0.02f, board->truck_positions[0][2]}, vp1 );
- v3_copy((v3f){0.0f,0.02f, board->truck_positions[1][2]}, vp0 );
- }
- else{
- v3_zero( vp0 );
- v3_zero( vp1 );
- }
+ v3f vp0, vp1, vpc;
+ if( board ){
+ v3_copy((v3f){0.0f,0.02f, board->truck_positions[0][2]}, vp1 );
+ v3_copy((v3f){0.0f,0.02f, board->truck_positions[1][2]}, vp0 );
+ }
+ else{
+ v3_zero( vp0 );
+ v3_zero( vp1 );
+ }
- v3f *board_mtx = final_mtx[ localplayer.id_board ];
- m4x3_mulv( board_mtx, vp0, vp0 );
- m4x3_mulv( board_mtx, vp1, vp1 );
- v3_add( vp0, vp1, vpc );
- v3_muls( vpc, 0.5f, vpc );
+ v3f *board_mtx = final_mtx[ localplayer.id_board ];
+ m4x3_mulv( board_mtx, vp0, vp0 );
+ m4x3_mulv( board_mtx, vp1, vp1 );
+ v3_add( vp0, vp1, vpc );
+ v3_muls( vpc, 0.5f, vpc );
+ if( animator->surface == k_surface_prop_sand ){
+ if( (animator->slide>0.4f) && (v3_length2(animator->root_v)>4.0f*4.0f) ){
+ v3f v, co;
+ v3_muls( animator->root_v, 0.5f, v );
+ v3_lerp( vp0, vp1, vg_randf64(&vg.rand), co );
+
+ effect_data->sand.colour = 0xff8ec4e6;
+ effect_spark_apply( &effect_data->sand, co, v, vg.time_delta * 8.0 );
+ }
+ }
+
+ if( animator->grind > 0.5f ){
int back = 0, front = 0, mid = 0;
if( animator->activity == k_skate_activity_grind_5050 ){