//This is the function to get the next frame without restriction and removing balls from game //This function calls the function "proceed_dt_only" to get the next frame just with simple movement from speed and rotation speed. //It uses recursive call to generate the exact frame without penetration. //It calculates the wall_collision and ball_ball_collision part mainly //Called Functions : proceed_dt_only, calc_wall_collision_time, calc_ball_collision_time, ball_wall_interaction, ball_ball_interaction, // proceed_dt_euler, wall_dv_pos, ball_dv_pos //Return Value : null. private static void proceed_dt_euler(Frame frame, int border_type, float dt, int depth) /* this one does not remove fallen balls */ { const int COLLTYPE_WALL = 1; const int COLLTYPE_BALL = 2; const int COLLTYPE_NONE = 0; float dt1; float dtmin = 0.0f; int i, j; int colltype = COLLTYPE_NONE; int collnr = -1; int collnr2 = -1; if (depth == 0) { logtime = dt; } else { logtime += dt; } /* move all balls */ proceed_dt_only(frame, dt); /* checks */ for (i = 0; i < 16; i++) { //if(frame.Balls[i].in_game){ /* check wall collisions */ for (j = 0; j < Borders.GetBorderNum(Borders.BORDERS_8GAME); j++) { dt1 = calc_wall_collision_time(frame.Balls[i], Borders.GetBorder(Borders.BORDERS_8GAME, j)); if (dt1 < dtmin && dt1 > -dt) { if (!wall_dv_pos(frame.Balls[i], Borders.GetBorder(Borders.BORDERS_8GAME, j), -dt * 1.0f)) /* dont strobe apart */ { dtmin = dt1; colltype = COLLTYPE_WALL; collnr = j; collnr2 = i; } } } /* check ball collisions */ for (j = 0; j < 16; j++) { if (j != i) { dt1 = calc_ball_collision_time(frame.Balls[i], frame.Balls[j]); /* dt1 should be negative */ if (dt1 < dtmin && dt1 > -dt) { if (!ball_dv_pos(frame.Balls[j], frame.Balls[i], -dt * 1.0f)) /* dont strobe apart */ { dtmin = dt1; colltype = COLLTYPE_BALL; collnr = j; collnr2 = i; } } } } //} } switch (colltype) { case COLLTYPE_WALL: logtime += dtmin; proceed_dt_only(frame, dtmin); ball_wall_interaction(frame.Balls[collnr2], Borders.GetBorder(Borders.BORDERS_8GAME, collnr)); BallEvents.collide_wall++; BallEvents.record_move_log_event(EventType0.BALL_WALL, collnr, frame.Balls[collnr2].nr, frame, frame.time); frame.ballwallcollisionvolume = (Maths.vec_abs(frame.Balls[collnr2].v)) * 0.05f; // MonoBehaviour.print(frame.ballwallcollisionvolume); proceed_dt_euler(frame, border_type, -dtmin, depth + 1); break; case COLLTYPE_BALL: logtime += dtmin; proceed_dt_only(frame, dtmin); ball_ball_interaction(frame.Balls[collnr], frame.Balls[collnr2]); BallEvents.record_move_log_event(EventType0.BALL_BALL, frame.Balls[collnr].nr, frame.Balls[collnr2].nr, frame, frame.time); frame.ballballcollisionvolume = (Maths.vec_abs(frame.Balls[collnr].v) + Maths.vec_abs(frame.Balls[collnr2].v)) * 0.05f; proceed_dt_euler(frame, border_type, -dtmin, depth + 1); break; } }