Permalink
Browse files

Merge branch 'master' into bddbullet

  • Loading branch information...
2 parents 0d34c1c + 5829e17 commit 9e404ac1ff50ce6a8f27d66ab5f448200ed38c24 @dwrensha dwrensha committed Dec 9, 2012
Showing with 59 additions and 25 deletions.
  1. +44 −12 examples/bddtestbed/game.sml
  2. +15 −1 examples/bddtestbed/types.sml
  3. +0 −4 sml-lib/bdd/dynamics-types.sml
  4. +0 −8 sml-lib/bdd/world.sml
@@ -91,7 +91,7 @@ struct
needs_resize = true}
val settings = {draw_contacts = ref false,
paused = ref false,
- profile = ref false}
+ profile = ref NONE}
in GS { test = test, mouse_joint = NONE, world = world,
view = view, settings = settings}
end
@@ -217,20 +217,49 @@ struct
val Test {tick = test_tick, ...} = test
val () = test_tick world
val () = dophysics world
- val () = if !(#profile settings)
- then
- let val {step, collide,
- solve, solve_toi, ...} = BDD.World.get_profile world
+ val () = case !(#profile settings) of
+ SOME {step_count, total, max} =>
+ let
+ val step_count' = step_count + 1
+ val {step, collide,
+ solve, solve_toi} = BDD.World.get_profile world
+ val total' = {step = Time.+(step, #step total),
+ collide = Time.+(collide, #collide total),
+ solve = Time.+(solve, #solve total),
+ solve_toi = Time.+(solve_toi, #solve_toi total)}
+ fun tMax (t1, t2) =
+ if Time.>(t1, t2) then t1 else t2
+ val max' = {step = tMax(step, #step max),
+ collide = tMax(collide, #collide max),
+ solve = tMax(solve, #solve max),
+ solve_toi = tMax(solve_toi, #solve_toi max)}
fun toString t = Real64.toString (1000.0 * (Time.toReal t))
+ fun totalString t = Real64.toString
+ (1000.0 * (Time.toReal t) /
+ Real64.fromInt step_count')
in
print "profile:\n";
- print ("step: " ^ toString (step) ^ " ");
- print ("collide: " ^ toString (collide) ^ " ");
- print ("solve: " ^ toString (solve) ^ " ");
- print ("solve_toi: " ^ toString (solve_toi) ^ "\n");
- ()
+ print ("step: " ^ toString (step) ^ " [");
+ print (totalString (#step total') ^ "] (");
+ print (toString (#step max') ^ ") ");
+
+ print ("collide: " ^ toString (collide) ^ " [");
+ print (totalString (#collide total') ^ "] (");
+ print (toString (#collide max') ^ ") ");
+
+ print ("solve: " ^ toString (solve) ^ " [");
+ print (totalString (#solve total') ^ "] (");
+ print (toString (#solve max') ^ ") ");
+
+ print ("solve_toi: " ^ toString (solve_toi) ^ " [");
+ print (totalString (#solve_toi total') ^ "] (");
+ print (toString (#solve_toi max') ^ ")\n");
+
+ (#profile settings) := (SOME {step_count = step_count',
+ total = total',
+ max = max' })
end
- else ()
+ | NONE => ()
in
SOME s
end
@@ -373,8 +402,11 @@ struct
| handle_event (SDL.E_KeyDown {sym = SDL.SDLK_t}) (s as GS {settings, ...}) =
let
val t = #profile settings
+ val t' = case !t of
+ NONE => SOME (new_profile_data ())
+ | _ => NONE
in
- t := not (!t);
+ t := t';
SOME s
end
| handle_event (SDL.E_KeyDown {sym = SDL.SDLK_s}) (s as GS {world, settings, ...}) =
@@ -22,10 +22,24 @@ datatype test = Test of
tick : BDD.world -> unit
}
+type profile_data = { step_count : int,
+ total : BDDDynamicsTypes.profile,
+ max : BDDDynamicsTypes.profile
+ }
+
+fun new_profile_data () =
+ let fun new_profile () = {step = Time.zeroTime,
+ collide = Time.zeroTime,
+ solve = Time.zeroTime,
+ solve_toi = Time.zeroTime}
+ in
+ {step_count = 0, total = new_profile(), max = new_profile()}
+ end
+
type settings =
{ draw_contacts : bool ref,
paused : bool ref,
- profile : bool ref
+ profile : profile_data option ref
}
type mouse_joint = {get_target : unit -> BDDMath.vec2,
@@ -118,10 +118,6 @@ struct
type profile = { step : Time.time,
collide : Time.time,
solve : Time.time,
- solve_init : Time.time,
- solve_velocity : Time.time,
- solve_position : Time.time,
- broad_phase : Time.time,
solve_toi : Time.time
}
@@ -158,10 +158,6 @@ struct
profile = { step = Time.zeroTime,
collide = Time.zeroTime,
solve = Time.zeroTime,
- solve_init = Time.zeroTime,
- solve_velocity = Time.zeroTime,
- solve_position = Time.zeroTime,
- broad_phase = Time.zeroTime,
solve_toi = Time.zeroTime },
broad_phase = BDDBroadPhase.broadphase (),
@@ -1073,10 +1069,6 @@ struct
{step = step_time,
collide = collide_time,
solve = solve_time,
- solve_init = Time.zeroTime,
- solve_velocity = Time.zeroTime,
- solve_position = Time.zeroTime,
- broad_phase = Time.zeroTime,
solve_toi = toi_time })
end

0 comments on commit 9e404ac

Please sign in to comment.