Commit a30fc3ac499a74f73937e9d8c4b01db8603b22c5
Committed by
Gerrit Code Review
Merge "Added option to benchmark physics 2d example" into devel/master
Showing
1 changed file
with
32 additions
and
6 deletions
examples/benchmark-2dphysics/benchmark-2d-physics-controller.cpp
| ... | ... | @@ -27,6 +27,7 @@ |
| 27 | 27 | #include <cstdlib> |
| 28 | 28 | #include <iostream> |
| 29 | 29 | #include <string> |
| 30 | +#include <unistd.h> | |
| 30 | 31 | |
| 31 | 32 | using namespace Dali; |
| 32 | 33 | using namespace Dali::Toolkit::Physics; |
| ... | ... | @@ -74,8 +75,9 @@ enum BenchmarkType |
| 74 | 75 | class Physics2dBenchmarkController : public ConnectionTracker |
| 75 | 76 | { |
| 76 | 77 | public: |
| 77 | - Physics2dBenchmarkController(Application& app, int numberOfBalls) | |
| 78 | + Physics2dBenchmarkController(Application& app, BenchmarkType startType, int numberOfBalls) | |
| 78 | 79 | : mApplication(app), |
| 80 | + mType(startType), | |
| 79 | 81 | mBallNumber(numberOfBalls) |
| 80 | 82 | { |
| 81 | 83 | app.InitSignal().Connect(this, &Physics2dBenchmarkController::OnInit); |
| ... | ... | @@ -92,8 +94,6 @@ public: |
| 92 | 94 | mWindow.GetRootLayer().TouchedSignal().Connect(this, &Physics2dBenchmarkController::OnTouched); |
| 93 | 95 | mWindow.SetBackgroundColor(Color::DARK_SLATE_GRAY); |
| 94 | 96 | |
| 95 | - mType = BenchmarkType::ANIMATION; | |
| 96 | - | |
| 97 | 97 | CreateSimulation(); |
| 98 | 98 | |
| 99 | 99 | mTimer = Timer::New(ANIMATION_TIME); |
| ... | ... | @@ -201,6 +201,8 @@ public: |
| 201 | 201 | |
| 202 | 202 | void CreateAnimationSimulation() |
| 203 | 203 | { |
| 204 | + DALI_LOG_RELEASE_INFO("Creating animation simulation with %d balls\n", mBallNumber); | |
| 205 | + | |
| 204 | 206 | Window::WindowSize windowSize = mWindow.GetSize(); |
| 205 | 207 | mBallActors.resize(mBallNumber); |
| 206 | 208 | mBallVelocity.resize(mBallNumber); |
| ... | ... | @@ -331,6 +333,8 @@ public: |
| 331 | 333 | |
| 332 | 334 | void CreatePhysicsSimulation() |
| 333 | 335 | { |
| 336 | + DALI_LOG_RELEASE_INFO("Creating physics simulation with %d balls\n", mBallNumber); | |
| 337 | + | |
| 334 | 338 | Window::WindowSize windowSize = mWindow.GetSize(); |
| 335 | 339 | |
| 336 | 340 | // Map Physics space (origin bottom left, +ve Y up) |
| ... | ... | @@ -466,14 +470,36 @@ int DALI_EXPORT_API main(int argc, char** argv) |
| 466 | 470 | { |
| 467 | 471 | setenv("DALI_FPS_TRACKING", "5", 1); |
| 468 | 472 | Application application = Application::New(&argc, &argv); |
| 473 | + BenchmarkType startType = BenchmarkType::ANIMATION; | |
| 469 | 474 | |
| 470 | 475 | int numberOfBalls = DEFAULT_BALL_COUNT; |
| 471 | - if(argc > 1) | |
| 476 | + int opt=0; | |
| 477 | + optind=1; | |
| 478 | + while((opt=getopt(argc, argv, "ap")) != -1) | |
| 479 | + { | |
| 480 | + switch(opt) | |
| 481 | + { | |
| 482 | + case 'a': | |
| 483 | + startType = BenchmarkType::ANIMATION; | |
| 484 | + break; | |
| 485 | + case 'p': | |
| 486 | + startType = BenchmarkType::PHYSICS_2D; | |
| 487 | + break; | |
| 488 | + case 1: | |
| 489 | + // Should only trigger if optstring argument starts with "-", but check it anyway. | |
| 490 | + numberOfBalls = atoi(optarg); | |
| 491 | + break; | |
| 492 | + default: | |
| 493 | + fprintf(stderr, "Usage: %s [-p][-a] [n-balls]\n", argv[0]); | |
| 494 | + exit(1); | |
| 495 | + } | |
| 496 | + } | |
| 497 | + if(optind < argc) | |
| 472 | 498 | { |
| 473 | - numberOfBalls = atoi(argv[1]); | |
| 499 | + numberOfBalls = atoi(argv[optind]); | |
| 474 | 500 | } |
| 475 | 501 | |
| 476 | - Physics2dBenchmarkController controller(application, numberOfBalls); | |
| 502 | + Physics2dBenchmarkController controller(application, startType, numberOfBalls); | |
| 477 | 503 | application.MainLoop(); |
| 478 | 504 | return 0; |
| 479 | 505 | } | ... | ... |