@@ -21,6 +21,7 @@ of this software and associated documentation files (the "Software"), to deal
2121 */
2222package testjoltjni .app .samples ;
2323
24+ import com .beust .jcommander .JCommander ;
2425import com .github .stephengold .joltjni .*;
2526import com .github .stephengold .joltjni .enumerate .EPhysicsUpdateError ;
2627import com .github .stephengold .joltjni .std .OfStream ;
@@ -47,14 +48,6 @@ of this software and associated documentation files (the "Software"), to deal
4748 * @author Stephen Gold sgold@sonic.net
4849 */
4950final public class SmokeTestAll {
50- // *************************************************************************
51- // constants
52-
53- /**
54- * default number of physics steps to simulate during each invocation of
55- * {@code smokeTest()}
56- */
57- final private static int defaultNumSteps = 66 ;
5851 // *************************************************************************
5952 // fields
6053
@@ -78,19 +71,33 @@ final public class SmokeTestAll {
7871 * allocator shared by all physics test objects
7972 */
8073 private static TempAllocator tempAllocator ;
74+ /**
75+ * parameters parsed from the command line
76+ */
77+ final private static TestParameters globalParameters = new TestParameters ();
8178 // *************************************************************************
8279 // new methods exposed
8380
8481 /**
8582 * Main entry point for the SmokeTestAll application.
8683 *
87- * @param arguments array of command-line arguments (not {@code null})
84+ * @param arguments the command-line arguments (not {@code null})
8885 */
8986 public static void main (String ... arguments ) {
90- //TestUtils.traceAllocations = true;
87+ // Parse the command-line arguments:
88+ JCommander jCommander = new JCommander (globalParameters );
89+ jCommander .parse (arguments );
90+ jCommander .setProgramName ("SmokeTestAll" );
91+ if (globalParameters .helpOnly ()) {
92+ jCommander .usage ();
93+ System .exit (0 );
94+ }
95+
96+ TestUtils .traceAllocations = globalParameters .traceAllocations ();
9197 TestUtils .loadNativeLibrary ();
9298 TestUtils .initializeNativeLibrary ();
9399
100+ // Log the configuration:
94101 System .out .println (Jolt .getConfigurationString ());
95102 System .out .print (" built-in compute systems:" );
96103 System .out .print (Jolt .implementsComputeCpu () ? " CPU" : "" );
@@ -219,7 +226,7 @@ private static PhysicsSystem newPhysicsSystem(int maxBodies) {
219226 * @param test the Test object to use (not {@code null})
220227 */
221228 private static void smokeTest (Test test ) {
222- smokeTest (test , defaultNumSteps );
229+ smokeTest (test , globalParameters . numSteps () );
223230 }
224231
225232 /**
@@ -259,16 +266,29 @@ private static void smokeTest(Test test, int numSteps) {
259266 test .Initialize ();
260267
261268 // Single-step the physics numSteps times:
262- for (int i = 0 ; i < numSteps ; ++i ) {
269+ for (int stepIndex = 1 ; stepIndex <= numSteps ; ++stepIndex ) {
270+ if (globalParameters .verboseLogging ()) {
271+ System .out .printf (
272+ "---- step #%d%n pre-update%n" , stepIndex );
273+ System .out .flush ();
274+ }
263275 PreUpdateParams params = new PreUpdateParams ();
264276 params .mDeltaTime = 0.02f ;
265277 test .PrePhysicsUpdate (params );
266278
279+ if (globalParameters .verboseLogging ()) {
280+ System .out .printf (" update%n" );
281+ System .out .flush ();
282+ }
267283 int collisionSteps = 1 ;
268284 int errors = physicsSystem .update (params .mDeltaTime , collisionSteps ,
269285 tempAllocator , jobSystem );
270286 assert errors == EPhysicsUpdateError .None : errors ;
271287
288+ if (globalParameters .verboseLogging ()) {
289+ System .out .printf (" post-update%n" );
290+ System .out .flush ();
291+ }
272292 test .PostPhysicsUpdate (params .mDeltaTime );
273293 }
274294
0 commit comments