MCPcopy Create free account
hub / github.com/bulletphysics/bullet3 / main

Function main

examples/ExampleBrowser/main.cpp:49–112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

47#endif //_WIN32
48
49int main(int argc, char* argv[])
50{
51#ifndef _WIN32
52 struct sigaction action;
53 memset(&action, 0x0, sizeof(action));
54 action.sa_handler = cleanup;
55 static const int signos[] = {SIGHUP, SIGINT, SIGQUIT, SIGABRT, SIGSEGV, SIGPIPE, SIGTERM};
56 for (int ii(0); ii < sizeof(signos) / sizeof(*signos); ++ii)
57 {
58 if (0 != sigaction(signos[ii], &action, NULL))
59 {
60 err(EXIT_FAILURE, "signal %d", signos[ii]);
61 }
62 }
63#endif
64
65 {
66 b3CommandLineArgs args(argc, argv);
67 b3Clock clock;
68 args.GetCmdLineArgument("minUpdateTimeMicroSecs", gMinUpdateTimeMicroSecs);
69
70 ExampleEntriesAll examples;
71 examples.initExampleEntries();
72
73 OpenGLExampleBrowser* exampleBrowser = new OpenGLExampleBrowser(&examples);
74 sExampleBrowser = exampleBrowser; //for <CTRL-C> etc, cleanup shared memory
75 bool init = exampleBrowser->init(argc, argv);
76 exampleBrowser->registerFileImporter(".urdf", ImportURDFCreateFunc);
77 exampleBrowser->registerFileImporter(".sdf", ImportSDFCreateFunc);
78 exampleBrowser->registerFileImporter(".obj", ImportObjCreateFunc);
79 exampleBrowser->registerFileImporter(".stl", ImportSTLCreateFunc);
80 exampleBrowser->registerFileImporter(".bullet", SerializeBulletCreateFunc);
81
82 clock.reset();
83 if (init)
84 {
85 do
86 {
87 float deltaTimeInSeconds = clock.getTimeMicroseconds() / 1000000.f;
88 if (deltaTimeInSeconds > 0.1)
89 {
90 deltaTimeInSeconds = 0.1;
91 }
92 if (deltaTimeInSeconds < (gMinUpdateTimeMicroSecs / 1e6))
93 {
94 b3Clock::usleep(gMinUpdateTimeMicroSecs / 10.);
95 }
96 else
97 {
98 clock.reset();
99 exampleBrowser->update(deltaTimeInSeconds);
100 }
101 } while (!exampleBrowser->requestedExit() && !interrupted);
102 }
103 delete exampleBrowser;
104 }
105
106#ifdef BT_DEBUG_MEMORY_ALLOCATIONS

Callers

nothing calls this directly

Calls 10

btDumpMemoryLeaksFunction · 0.85
registerFileImporterMethod · 0.80
sigactionClass · 0.70
GetCmdLineArgumentMethod · 0.45
initExampleEntriesMethod · 0.45
initMethod · 0.45
resetMethod · 0.45
getTimeMicrosecondsMethod · 0.45
updateMethod · 0.45
requestedExitMethod · 0.45

Tested by

no test coverage detected