From: hgn Date: Fri, 10 Feb 2023 10:56:22 +0000 (+0000) Subject: going crazy X-Git-Url: https://harrygodden.com/git/?a=commitdiff_plain;h=964a1608fd269bda5fc632a618a861a527c6f868;p=carveJwlIkooP6JGAAIwe30JlM.git going crazy --- diff --git a/common.h b/common.h index 6bb6951..49d2c99 100644 --- a/common.h +++ b/common.h @@ -111,7 +111,8 @@ VG_STATIC float k_steer_air = 3.6f, k_steer_air_lerp = 0.3f, k_pump_force = 0.0f, - k_downforce = 5.0f, + k_downforce = 0.0f, + k_escape_velocity = 1.0f, k_walk_downforce = 8.0f, k_jump_charge_speed = (1.0f/1.0f), k_jump_force = 5.0f, @@ -134,7 +135,10 @@ VG_STATIC float k_spring_dampener = 5.0f, k_grind_spring = 100.0f, - k_grind_dampener = 1.0f; + k_grind_dampener = 1.0f, + k_board_spring = 2.0f, + k_board_dampener = 0.2f, + k_board_interia = 8.0f; VG_STATIC float @@ -174,6 +178,9 @@ VG_STATIC void common_var_temp(void) VG_VAR_F32( k_grind_dampener ); VG_VAR_F32( k_grind_spring ); + VG_VAR_F32( k_board_spring ); + VG_VAR_F32( k_board_dampener ); + VG_VAR_F32( k_board_interia ); VG_VAR_F32( k_walkspeed ); VG_VAR_F32( k_stopspeed ); @@ -199,6 +206,7 @@ VG_STATIC void common_var_temp(void) VG_VAR_F32( k_cog_damp ); VG_VAR_F32( k_cog_mass_ratio ); + VG_VAR_F32( k_escape_velocity ); VG_VAR_F32( k_downforce ); VG_VAR_F32( k_spring_force ); diff --git a/maps_src/mp_gridmap.mdl b/maps_src/mp_gridmap.mdl index 676155a..e20369b 100644 Binary files a/maps_src/mp_gridmap.mdl and b/maps_src/mp_gridmap.mdl differ diff --git a/player.c b/player.c index 5c9f8cf..d86c8c8 100644 --- a/player.c +++ b/player.c @@ -222,7 +222,7 @@ VG_STATIC void player__pre_render( player_instance *player ) { skeleton_lerp_pose( sk, res.pose, player->holdout_pose, player->holdout_time, res.pose ); - player->holdout_time -= vg.frame_delta * 4.0f; + player->holdout_time -= vg.frame_delta * 2.0f; } skeleton_apply_pose( sk, res.pose, k_anim_apply_defer_ik ); diff --git a/player_skate.c b/player_skate.c index 8777763..eb4e27e 100644 --- a/player_skate.c +++ b/player_skate.c @@ -44,6 +44,8 @@ VG_STATIC int skate_collide_smooth( player_instance *player, man[i].rbb = NULL; } + return len; + rb_manifold_filter_coplanar( man, len, 0.05f ); if( len > 1 ) @@ -170,7 +172,9 @@ VG_STATIC int skate_grind_scansq( player_instance *player, v3f ra ) m3x3_copy( player->rb.to_world, mtx ); v3_copy( pos, mtx[3] ); +#if 0 debug_sphere( mtx, r, VG__CYAN ); +#endif bh_iter it; bh_iter_init( 0, &it ); @@ -180,7 +184,8 @@ VG_STATIC int skate_grind_scansq( player_instance *player, v3f ra ) { v2f co; v2f normal; - v3f normal3; + v3f normal3, + centroid; } samples[48]; @@ -229,6 +234,10 @@ VG_STATIC int skate_grind_scansq( player_instance *player, v3f ra ) v3_copy( normal, sample->normal3 ); /* normalize later if we want to us it */ + v3_muls( tri[0], 1.0f/3.0f, sample->centroid ); + v3_muladds( sample->centroid, tri[1], 1.0f/3.0f, sample->centroid ); + v3_muladds( sample->centroid, tri[2], 1.0f/3.0f, sample->centroid ); + v2_normalize( sample->normal ); sample_count ++; @@ -264,29 +273,38 @@ VG_STATIC int skate_grind_scansq( player_instance *player, v3f ra ) sj = &samples[j]; - if( v2_dist2( si->co, sj->co ) <= (0.01f*0.01f) && - v2_dot( si->normal, sj->normal ) < 0.7f ) - { - /* TODO: Filter concave */ + /* non overlapping */ + if( v2_dist2( si->co, sj->co ) >= (0.01f*0.01f) ) + continue; - v3f p0; - v3_muls( support_axis, sj->co[0], p0 ); - p0[1] += sj->co[1]; + /* not sharp angle */ + if( v2_dot( si->normal, sj->normal ) >= 0.7f ) + continue; - v3_add( average_position, p0, average_position ); - - v3f n0, n1, dir; - v3_copy( si->normal3, n0 ); - v3_copy( sj->normal3, n1 ); - v3_cross( n0, n1, dir ); - v3_normalize( dir ); + /* not convex */ + v3f v0; + v3_sub( sj->centroid, si->centroid, v0 ); + if( v3_dot( v0, si->normal3 ) >= 0.0f || + v3_dot( v0, sj->normal3 ) <= 0.0f ) + continue; - /* make sure the directions all face a common hemisphere */ - v3_muls( dir, vg_signf(v3_dot(dir,plane)), dir ); + v3f p0; + v3_muls( support_axis, sj->co[0], p0 ); + p0[1] += sj->co[1]; - v3_add( average_direction, dir, average_direction ); - passed_samples ++; - } + v3_add( average_position, p0, average_position ); + + v3f n0, n1, dir; + v3_copy( si->normal3, n0 ); + v3_copy( sj->normal3, n1 ); + v3_cross( n0, n1, dir ); + v3_normalize( dir ); + + /* make sure the directions all face a common hemisphere */ + v3_muls( dir, vg_signf(v3_dot(dir,plane)), dir ); + + v3_add( average_direction, dir, average_direction ); + passed_samples ++; } } @@ -305,6 +323,7 @@ VG_STATIC int skate_grind_scansq( player_instance *player, v3f ra ) v3_muladds( average_position, average_direction, -0.35f, p1 ); vg_line( p0, p1, VG__PINK ); +#if 0 if( passed_samples ) { v3f displacement, dir; @@ -335,6 +354,9 @@ VG_STATIC int skate_grind_scansq( player_instance *player, v3f ra ) /* Constraint based */ } +#endif + + return passed_samples; } /* @@ -589,8 +611,10 @@ VG_STATIC void skate_apply_grind_model( player_instance *player, player->input_js1v->axis.value }; v2_normalize_clamp( steer ); +#if 0 s->state.steery -= steer[0] * k_steer_air * k_rb_delta; s->state.steerx += steer[1] * s->state.reverse * k_steer_air * k_rb_delta; +#endif #if 0 v4f rotate; @@ -720,7 +744,7 @@ VG_STATIC void skate_apply_air_model( player_instance *player ) limiter *= limiter; limiter = 1.0f-limiter; - if( fabsf(angle) < 0.99f ) + if( fabsf(angle) < 0.9999f ) { v4f correction; q_axis_angle( correction, axis, @@ -733,9 +757,11 @@ VG_STATIC void skate_apply_air_model( player_instance *player ) player->input_js1v->axis.value }; v2_normalize_clamp( steer ); +#if 0 s->state.steery -= steer[0] * k_steer_air * VG_TIMESTEP_FIXED; s->state.steerx += steer[1] * s->state.reverse * k_steer_air * limiter * k_rb_delta; +#endif s->land_dist = time_to_impact; v3_copy( target_normal, s->land_normal ); } @@ -1062,7 +1088,23 @@ VG_STATIC void skate_apply_friction_model( player_instance *player ) steer = input * (1.0f-(s->state.jump_charge+grab)*0.4f), steer_scaled = vg_signf(steer) * powf(steer,2.0f) * k_steer_ground; - s->state.steery -= steer_scaled * k_rb_delta; + v3f steer_axis; + v3_muls( player->rb.to_world[1], -vg_signf( steer_scaled ), steer_axis ); + + float current = v3_dot( player->rb.to_world[1], player->rb.w ), + addspeed = (steer_scaled * -1.0f) - current, + maxaccel = 26.0f * k_rb_delta, + accel = vg_clampf( addspeed, -maxaccel, maxaccel ); + + v3_muladds( player->rb.w, player->rb.to_world[1], accel, player->rb.w ); + + +#if 0 + player_accelerate( player->rb.w, steer_axis, + fabsf(steer_scaled) * 1.0f, 30.0f ); + + //s->state.steery -= steer_scaled * k_rb_delta; +#endif } VG_STATIC void skate_apply_jump_model( player_instance *player ) @@ -1117,9 +1159,11 @@ VG_STATIC void skate_apply_jump_model( player_instance *player ) player->input_js1v->axis.value }; v2_normalize_clamp( steer ); +#if 0 float maxspin = k_steer_air * k_rb_delta * k_spin_boost; s->state.steery_s = -steer[0] * maxspin; s->state.steerx = s->state.steerx_s; +#endif s->state.lift_frames ++; /* FIXME audio events */ @@ -1219,20 +1263,24 @@ VG_STATIC void skate_collision_response( player_instance *player, { struct contact *ct = &manifold[i]; - v3f dv, delta; + v3f rv, delta; v3_sub( ct->co, player->rb.co, delta ); - v3_cross( player->rb.w, delta, dv ); - v3_add( player->rb.v, dv, dv ); + v3_cross( player->rb.w, delta, rv ); + v3_add( player->rb.v, rv, rv ); + + v3f raCn; + v3_cross( delta, ct->n, raCn ); - float vn = -v3_dot( dv, ct->n ); - vn += ct->bias; + float normal_mass = 1.0f / (1.0f + v3_dot(raCn,raCn)); + float vn = v3_dot( rv, ct->n ); + float lambda = normal_mass * ( -vn + ct->bias ); float temp = ct->norm_impulse; - ct->norm_impulse = vg_maxf( temp + vn, 0.0f ); - vn = ct->norm_impulse - temp; + ct->norm_impulse = vg_maxf( temp + lambda, 0.0f ); + lambda = ct->norm_impulse - temp; v3f impulse; - v3_muls( ct->n, vn, impulse ); + v3_muls( ct->n, lambda, impulse ); if( fabsf(v3_dot( impulse, player->rb.to_world[2] )) > 10.0f || fabsf(v3_dot( impulse, player->rb.to_world[1] )) > 50.0f ) @@ -1252,13 +1300,18 @@ VG_STATIC void skate_collision_response( player_instance *player, * components. */ - float wy = v3_dot( player->rb.to_world[1], impulse ) * 0.8f, + float wy = v3_dot( player->rb.to_world[1], impulse ) * 1.0f, wx = v3_dot( player->rb.to_world[0], impulse ) * 1.0f, - wz = v3_dot( player->rb.to_world[2], impulse ) * 2.0f; + wz = v3_dot( player->rb.to_world[2], impulse ) * 1.0f; v3_muladds( player->rb.w, player->rb.to_world[1], wy, player->rb.w ); v3_muladds( player->rb.w, player->rb.to_world[0], wx, player->rb.w ); v3_muladds( player->rb.w, player->rb.to_world[2], wz, player->rb.w ); + + + v3_cross( player->rb.w, delta, rv ); + v3_add( player->rb.v, rv, rv ); + vn = v3_dot( rv, ct->n ); } } } @@ -1274,15 +1327,23 @@ VG_STATIC void skate_integrate( player_instance *player ) v3_muladds( player->rb.co, player->rb.v, k_rb_delta, player->rb.co ); #endif - float decay_rate = 0.5f*0.125f; + float decay_rate = 1.0f - (k_rb_delta * 3.0f); +#if 0 if( s->state.activity == k_skate_activity_air ) { float dist = 1.0f-(s->land_dist/4.0f); decay_rate = 0.5f * vg_maxf( dist*dist, 0.0f ); } +#endif + + float wx = v3_dot( player->rb.w, player->rb.to_world[0] ) * decay_rate, + wy = v3_dot( player->rb.w, player->rb.to_world[1] ), + wz = v3_dot( player->rb.w, player->rb.to_world[2] ) * decay_rate; - v3_lerp( player->rb.w, (v3f){0.0f,0.0f,0.0f}, decay_rate, player->rb.w ); + v3_muls( player->rb.to_world[0], wx, player->rb.w ); + v3_muladds( player->rb.w, player->rb.to_world[1], wy, player->rb.w ); + v3_muladds( player->rb.w, player->rb.to_world[2], wz, player->rb.w ); #ifndef SKATE_CCD if( v3_length2( player->rb.w ) > 0.0f ) @@ -1299,6 +1360,7 @@ VG_STATIC void skate_integrate( player_instance *player ) #endif /* integrate steering velocities */ +#if 0 v4f rotate; float l = (s->state.activity == k_skate_activity_air)? 0.04f: 0.24f; @@ -1313,6 +1375,7 @@ VG_STATIC void skate_integrate( player_instance *player ) s->state.steerx = 0.0f; s->state.steery = 0.0f; +#endif s->state.flip_time += s->state.flip_rate * k_rb_delta; rb_update_transform( &player->rb ); @@ -1346,6 +1409,17 @@ VG_STATIC void player__skate_pre_update( player_instance *player ) return; } + if( vg_input_button_down( player->input_reset ) ) + { + player->rb.co[1] += 2.0f; + s->state.cog[1] += 2.0f; + q_axis_angle( player->rb.q, (v3f){1.0f,0.0f,0.0f}, VG_PIf * 0.25f ); + v3_zero( player->rb.w ); + v3_zero( player->rb.v ); + + rb_update_transform( &player->rb ); + } + int trick_id; if( (s->state.lift_frames > 0) && (trick_id = player_skate_trick_input( player )) ) @@ -1404,6 +1478,7 @@ VG_STATIC void player__skate_update( player_instance *player ) float l = k_board_length, w = 0.13f; +#if 0 v3f wheel_positions[] = { { -w, 0.0f, -l }, @@ -1411,22 +1486,40 @@ VG_STATIC void player__skate_update( player_instance *player ) { -w, 0.0f, l }, { w, 0.0f, l }, }; +#else + v3f wheel_positions[] = + { + { 0.0f, 0.0f, -l }, + { 0.0f, 0.0f, l }, + }; +#endif + + u32 wheel_colours[] = + { + VG__RED, VG__GREEN, VG__BLUE, VG__YELOW + }; int wheel_states[] = { 1, 1, 1, 1 }; + const int wheel_count = 2; + if( skate_grind_scansq( player, (v3f){ 0.0f, 0.0f, -l } ) ) { +#if 0 wheel_states[0] = 0; wheel_states[1] = 0; +#endif } if( skate_grind_scansq( player, (v3f){ 0.0f, 0.0f, l } ) ) { +#if 0 wheel_states[2] = 0; wheel_states[3] = 0; +#endif } rb_sphere collider; @@ -1434,18 +1527,23 @@ VG_STATIC void player__skate_update( player_instance *player ) s->substep = k_rb_delta; - for( int i=0; i<4; i++ ) + + int substep_count = 0; + +begin_collision:; + + + for( int i=0; irb.to_world, mtx ); m4x3_mulv( player->rb.to_world, wheel_positions[i], mtx[3] ); - debug_sphere( mtx, collider.radius, wheel_states[i]? VG__WHITE: - VG__BLACK ); + debug_sphere( mtx, collider.radius, + (u32[]){ VG__BLACK, VG__WHITE, + wheel_colours[i] }[ wheel_states[i] ]); } -begin_collision:; - #ifdef SKATE_CCD /* calculate transform one step into future */ @@ -1468,9 +1566,9 @@ begin_collision:; /* calculate the minimum time we can move */ float max_time = s->substep, - cast_radius = collider.radius - 0.05f; + cast_radius = collider.radius - k_penetration_slop*1.2f; - for( int i=0; i<4; i++ ) + for( int i=0; isubstep ); + float rate_lock = substep_count; + rate_lock *= k_rb_delta * 0.1f; + rate_lock *= rate_lock; + + max_time = vg_maxf( max_time, rate_lock ); s->substep_delta = max_time; /* integrate */ @@ -1532,7 +1634,7 @@ begin_collision:; rb_ct *cmanifold = manifold; - for( int i=0; i<4; i++ ) + for( int i=0; istate.activity == k_skate_activity_air) && @@ -1586,10 +1692,14 @@ begin_collision:; int grind_len = skate_grind_collide( player, cmanifold ); manifold_len += grind_len; +#endif + + int grind_len = 0; + + v3f surface_normal = {0.0f,0.0f,0.0f}; for( int i=0; ibias = -0.2f * (s->substep_delta * 3600.0f) @@ -1598,16 +1708,136 @@ begin_collision:; ct->norm_impulse = 0.0f; ct->tangent_impulse[0] = 0.0f; ct->tangent_impulse[1] = 0.0f; -#else - rb_prepare_contact( &manifold[i] ); + + v3_add( ct->n, surface_normal, surface_normal ); + } + + if( manifold_len ) + { + v3_muls( surface_normal, 1.0f/(float)manifold_len, surface_normal ); + + float a = v3_dot( player->rb.to_world[1], surface_normal ); + + if( a <= 0.9999f ) + { + v3f axis; + v3_cross( surface_normal, player->rb.to_world[1], axis ); + + float Fs = -a * k_board_spring, + Fd = -v3_dot( player->rb.w, axis ) * k_board_dampener; + + v3_muladds( player->rb.w, axis, (Fs+Fd) * s->substep_delta, + player->rb.w ); + } + } + + v3f extent = { w, 0.1f, k_board_length }; + float ex2 = k_board_interia*extent[0]*extent[0], + ey2 = k_board_interia*extent[1]*extent[1], + ez2 = k_board_interia*extent[2]*extent[2]; + + float mass = 2.0f * (extent[0]*extent[1]*extent[2]); + float inv_mass = 1.0f/mass; + + v3f I; + I[0] = ((1.0f/12.0f) * mass * (ey2+ez2)); + I[1] = ((1.0f/12.0f) * mass * (ex2+ez2)); + I[2] = ((1.0f/12.0f) * mass * (ex2+ey2)); + + m3x3f iI; + m3x3_identity( iI ); + iI[0][0] = I[0]; + iI[1][1] = I[1]; + iI[2][2] = I[2]; + m3x3_inv( iI, iI ); + + m3x3f iIw; + m3x3_mul( iI, player->rb.to_local, iIw ); + m3x3_mul( player->rb.to_world, iIw, iIw ); + + for( int j=0; j<10; j++ ) + { + for( int i=0; ico, player->rb.co, delta ); + v3_cross( player->rb.w, delta, rv ); + v3_add( player->rb.v, rv, rv ); + + v3f raCn; + v3_cross( delta, ct->n, raCn ); + + v3f raCnI, rbCnI; + m3x3_mulv( iIw, raCn, raCnI ); + + float normal_mass = 1.0f / (inv_mass + v3_dot(raCn,raCnI)); + float vn = v3_dot( rv, ct->n ); + + + + + float lambda = normal_mass * ( -vn + ct->bias ); + + float temp = ct->norm_impulse; + ct->norm_impulse = vg_maxf( temp + lambda, 0.0f ); + lambda = ct->norm_impulse - temp; + + v3f impulse; + v3_muls( ct->n, lambda, impulse ); + +#if 0 + if( fabsf(v3_dot( impulse, player->rb.to_world[2] )) > 10.0f || + fabsf(v3_dot( impulse, player->rb.to_world[1] )) > 50.0f ) + { + player__dead_transition( player ); + return; + } #endif + + v3_muladds( player->rb.v, impulse, inv_mass, player->rb.v ); + v3_cross( delta, impulse, impulse ); + m3x3_mulv( iIw, impulse, impulse ); + v3_add( impulse, player->rb.w, player->rb.w ); + + v3_cross( player->rb.w, delta, rv ); + v3_add( player->rb.v, rv, rv ); + vn = v3_dot( rv, ct->n ); + + } } - skate_collision_response( player, manifold, manifold_len ); + + + + + + + substep_count ++; + if( s->substep >= 0.0001f ) goto begin_collision; + + + for( int i=0; irb.to_world, mtx ); + m4x3_mulv( player->rb.to_world, wheel_positions[i], mtx[3] ); + debug_sphere( mtx, collider.radius, + (u32[]){ VG__BLACK, VG__WHITE, + wheel_colours[i] }[ wheel_states[i] ]); + } + + + + + + + skate_apply_grind_model( player, &manifold[manifold_interface], grind_len ); skate_apply_interface_model( player, manifold, manifold_interface ); @@ -1669,9 +1899,11 @@ VG_STATIC void player__skate_im_gui( player_instance *player ) "k_skate_activity_ground", "k_skate_activity_grind }" } [s->state.activity] ); +#if 0 player__debugtext( 1, "steer_s: %5.2f %5.2f [%.2f %.2f]", s->state.steerx_s, s->state.steery_s, k_steer_ground, k_steer_air ); +#endif player__debugtext( 1, "flip: %.4f %.4f", s->state.flip_rate, s->state.flip_time ); player__debugtext( 1, "trickv: %.2f %.2f %.2f", @@ -1915,11 +2147,12 @@ VG_STATIC void player__skate_animate( player_instance *player, /* transform */ rb_extrapolate( &player->rb, dest->root_co, dest->root_q ); - v3_muladds( dest->root_co, player->rb.to_world[1], -0.28f, dest->root_co ); + v3_muladds( dest->root_co, player->rb.to_world[1], -0.1f, dest->root_co ); + float substep = vg_clampf( vg.accumulator / VG_TIMESTEP_FIXED, 0.0f, 1.0f ); +#if 0 v4f qresy, qresx, qresidual; m3x3f mtx_residual; - float substep = vg_clampf( vg.accumulator / VG_TIMESTEP_FIXED, 0.0f, 1.0f ); q_axis_angle( qresy, player->rb.to_world[1], s->state.steery_s*substep ); q_axis_angle( qresx, player->rb.to_world[0], s->state.steerx_s*substep ); @@ -1927,6 +2160,7 @@ VG_STATIC void player__skate_animate( player_instance *player, q_normalize( qresidual ); q_mul( dest->root_q, qresidual, dest->root_q ); q_normalize( dest->root_q ); +#endif v4f qflip; if( (s->state.activity == k_skate_activity_air) && @@ -1984,10 +2218,12 @@ VG_STATIC void player__skate_clear_mechanics( player_instance *player ) s->state.jump_charge = 0.0f; s->state.lift_frames = 0; s->state.flip_rate = 0.0f; +#if 0 s->state.steery = 0.0f; s->state.steerx = 0.0f; s->state.steery_s = 0.0f; s->state.steerx_s = 0.0f; +#endif s->state.reverse = 0.0f; s->state.slip = 0.0f; v3_copy( player->rb.co, s->state.prev_pos ); diff --git a/player_skate.h b/player_skate.h index 6ace410..24e9ab9 100644 --- a/player_skate.h +++ b/player_skate.h @@ -18,10 +18,10 @@ struct player_skate activity, activity_prev; - float steery, + float /* steery, steerx, steery_s, - steerx_s, + steerx_s, */ reverse, slip; diff --git a/player_walk.c b/player_walk.c index 0a6a485..0b84ef1 100644 --- a/player_walk.c +++ b/player_walk.c @@ -729,7 +729,7 @@ VG_STATIC void player__walk_animate( player_instance *player, v4_copy( dest->root_q, player->rb.q ); v3_muladds( dest->root_co, player->rb.to_world[1], - -0.28f * dop_t, dest->root_co ); + -0.1f * dop_t, dest->root_co ); skeleton_copy_pose( sk, dest->pose, player->holdout_pose ); player->holdout_time = 1.0f; @@ -739,7 +739,7 @@ VG_STATIC void player__walk_animate( player_instance *player, else { v3_muladds( dest->root_co, player->rb.to_world[1], - -0.28f * outro_t, dest->root_co ); + -0.1f * outro_t, dest->root_co ); skeleton_copy_pose( sk, dest->pose, player->holdout_pose ); player->holdout_time = 1.0f; diff --git a/rigidbody.h b/rigidbody.h index 3cb601d..58b416e 100644 --- a/rigidbody.h +++ b/rigidbody.h @@ -1365,7 +1365,7 @@ VG_STATIC int rb_sphere__triangle( m4x3f mtxA, rb_sphere *b, float d2 = v3_length2( delta ), r = b->radius; - if( d2 < r*r ) + if( d2 <= r*r ) { rb_ct *ct = buf; @@ -1499,7 +1499,7 @@ VG_STATIC int rb_sphere__scene( m4x3f mtxA, rb_sphere *b, int count = 0; - float r = b->radius; + float r = b->radius + 0.1f; boxf box; v3_sub( mtxA[3], (v3f){ r,r,r }, box[0] ); v3_add( mtxA[3], (v3f){ r,r,r }, box[1] );