MCPcopy Create free account
hub / github.com/BoomingTech/Piccolo / SamplesApp

Method SamplesApp

engine/3rdparty/JoltPhysics/Samples/SamplesApp.cpp:313–499  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

311static constexpr uint cMaxContactConstraints = 10240;
312
313SamplesApp::SamplesApp()
314{
315 // Allocate temp memory
316#ifdef JPH_DISABLE_TEMP_ALLOCATOR
317 mTempAllocator = new TempAllocatorMalloc();
318#else
319 mTempAllocator = new TempAllocatorImpl(16 * 1024 * 1024);
320#endif
321
322 // Create job system
323 mJobSystem = new JobSystemThreadPool(cMaxPhysicsJobs, cMaxPhysicsBarriers, mMaxConcurrentJobs - 1);
324
325 // Create job system without extra threads for validating
326 mJobSystemValidating = new JobSystemThreadPool(cMaxPhysicsJobs, cMaxPhysicsBarriers, 0);
327
328 // Create UI
329 UIElement *main_menu = mDebugUI->CreateMenu();
330 mDebugUI->CreateTextButton(main_menu, "Select Test", [this]() {
331 UIElement *tests = mDebugUI->CreateMenu();
332 for (TestCategory &c : sAllCategories)
333 {
334 mDebugUI->CreateTextButton(tests, c.mName, [=]() {
335 UIElement *category = mDebugUI->CreateMenu();
336 for (uint j = 0; j < c.mNumTests; ++j)
337 mDebugUI->CreateTextButton(category, c.mTests[j].mName, [=]() { StartTest(c.mTests[j].mRTTI); });
338 mDebugUI->ShowMenu(category);
339 });
340 }
341 mDebugUI->ShowMenu(tests);
342 });
343 mTestSettingsButton = mDebugUI->CreateTextButton(main_menu, "Test Settings", [this](){
344 UIElement *test_settings = mDebugUI->CreateMenu();
345 mTest->CreateSettingsMenu(mDebugUI, test_settings);
346 mDebugUI->ShowMenu(test_settings);
347 });
348 mDebugUI->CreateTextButton(main_menu, "Restart Test (R)", [this]() { StartTest(mTestClass); });
349 mDebugUI->CreateTextButton(main_menu, "Run All Tests", [this]() { RunAllTests(); });
350 mNextTestButton = mDebugUI->CreateTextButton(main_menu, "Next Test (N)", [this]() { NextTest(); });
351 mNextTestButton->SetDisabled(true);
352 mDebugUI->CreateTextButton(main_menu, "Take Snapshot", [this]() { TakeSnapshot(); });
353 mDebugUI->CreateTextButton(main_menu, "Take And Reload Snapshot", [this]() { TakeAndReloadSnapshot(); });
354 mDebugUI->CreateTextButton(main_menu, "Physics Settings", [this]() {
355 UIElement *phys_settings = mDebugUI->CreateMenu();
356 mDebugUI->CreateSlider(phys_settings, "Max Concurrent Jobs", float(mMaxConcurrentJobs), 1, float(thread::hardware_concurrency()), 1, [this](float inValue) { mMaxConcurrentJobs = (int)inValue; });
357 mDebugUI->CreateSlider(phys_settings, "Gravity (m/s^2)", -mPhysicsSystem->GetGravity().GetY(), 0.0f, 20.0f, 1.0f, [this](float inValue) { mPhysicsSystem->SetGravity(Vec3(0, -inValue, 0)); });
358 mDebugUI->CreateSlider(phys_settings, "Update Frequency (Hz)", mUpdateFrequency, 7.5f, 120.0f, 2.5f, [this](float inValue) { mUpdateFrequency = inValue; });
359 mDebugUI->CreateSlider(phys_settings, "Num Collision Steps", float(mCollisionSteps), 1.0f, 4.0f, 1.0f, [this](float inValue) { mCollisionSteps = int(inValue); });
360 mDebugUI->CreateSlider(phys_settings, "Num Integration Sub Steps", float(mIntegrationSubSteps), 1.0f, 4.0f, 1.0f, [this](float inValue) { mIntegrationSubSteps = int(inValue); });
361 mDebugUI->CreateSlider(phys_settings, "Num Velocity Steps", float(mPhysicsSettings.mNumVelocitySteps), 0, 30, 1, [this](float inValue) { mPhysicsSettings.mNumVelocitySteps = int(round(inValue)); mPhysicsSystem->SetPhysicsSettings(mPhysicsSettings); });
362 mDebugUI->CreateSlider(phys_settings, "Num Position Steps", float(mPhysicsSettings.mNumPositionSteps), 0, 30, 1, [this](float inValue) { mPhysicsSettings.mNumPositionSteps = int(round(inValue)); mPhysicsSystem->SetPhysicsSettings(mPhysicsSettings); });
363 mDebugUI->CreateSlider(phys_settings, "Baumgarte Stabilization Factor", mPhysicsSettings.mBaumgarte, 0.01f, 1.0f, 0.05f, [this](float inValue) { mPhysicsSettings.mBaumgarte = inValue; mPhysicsSystem->SetPhysicsSettings(mPhysicsSettings); });
364 mDebugUI->CreateSlider(phys_settings, "Speculative Contact Distance (m)", mPhysicsSettings.mSpeculativeContactDistance, 0.0f, 0.1f, 0.005f, [this](float inValue) { mPhysicsSettings.mSpeculativeContactDistance = inValue; });
365 mDebugUI->CreateSlider(phys_settings, "Penetration Slop (m)", mPhysicsSettings.mPenetrationSlop, 0.0f, 0.1f, 0.005f, [this](float inValue) { mPhysicsSettings.mPenetrationSlop = inValue; });
366 mDebugUI->CreateSlider(phys_settings, "Min Velocity For Restitution (m/s)", mPhysicsSettings.mMinVelocityForRestitution, 0.0f, 10.0f, 0.1f, [this](float inValue) { mPhysicsSettings.mMinVelocityForRestitution = inValue; mPhysicsSystem->SetPhysicsSettings(mPhysicsSettings); });
367 mDebugUI->CreateSlider(phys_settings, "Time Before Sleep (s)", mPhysicsSettings.mTimeBeforeSleep, 0.1f, 1.0f, 0.1f, [this](float inValue) { mPhysicsSettings.mTimeBeforeSleep = inValue; mPhysicsSystem->SetPhysicsSettings(mPhysicsSettings); });
368 mDebugUI->CreateSlider(phys_settings, "Point Velocity Sleep Threshold (m/s)", mPhysicsSettings.mPointVelocitySleepThreshold, 0.01f, 1.0f, 0.01f, [this](float inValue) { mPhysicsSettings.mPointVelocitySleepThreshold = inValue; mPhysicsSystem->SetPhysicsSettings(mPhysicsSettings); });
369 mDebugUI->CreateCheckBox(phys_settings, "Constraint Warm Starting", mPhysicsSettings.mConstraintWarmStart, [this](UICheckBox::EState inState) { mPhysicsSettings.mConstraintWarmStart = inState == UICheckBox::STATE_CHECKED; mPhysicsSystem->SetPhysicsSettings(mPhysicsSettings); });
370 mDebugUI->CreateCheckBox(phys_settings, "Use Body Pair Contact Cache", mPhysicsSettings.mUseBodyPairContactCache, [this](UICheckBox::EState inState) { mPhysicsSettings.mUseBodyPairContactCache = inState == UICheckBox::STATE_CHECKED; mPhysicsSystem->SetPhysicsSettings(mPhysicsSettings); });

Callers

nothing calls this directly

Calls 15

Vec3Function · 0.85
ToLowerFunction · 0.85
StringToVectorFunction · 0.85
CreateMenuMethod · 0.80
CreateTextButtonMethod · 0.80
ShowMenuMethod · 0.80
SetDisabledMethod · 0.80
CreateSliderMethod · 0.80
GetGravityMethod · 0.80
SetGravityMethod · 0.80
SetPhysicsSettingsMethod · 0.80
CreateCheckBoxMethod · 0.80

Tested by

no test coverage detected