123456789101112131415161718 |
- <!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=edge"><![endif]--><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="Asciidoctor 1.5.4"><meta name="keywords" content="documentation, physics, threading"><title>Multithreading Bullet Physics in jme3</title><link rel="stylesheet" href="./asciidoctor.css">
- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css">
- <link rel="stylesheet" href="./coderay-asciidoctor.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/docsearch.js/2/docsearch.min.css"></head><body class="article toc2 toc-left"><div id="header"><div id="toolbar"><a href="https://github.com/jMonkeyEngine/wiki/edit/master/src/docs/asciidoc/jme3/advanced/bullet_multithreading.adoc"><i class="fa fa-pencil-square" aria-hidden="true"></i></a><a href="https://github.com/jMonkeyEngine/wiki/new/master/src/docs/asciidoc/jme3/advanced/"><i class="fa fa-plus-square" aria-hidden="true"></i></a><input dir="auto" style="position: relative; vertical-align: top;" spellcheck="false" autocomplete="off" class="searchbox__input aa-input" id="doc-search" name="search" placeholder="Search in the doc" required="required" type="search"></div><h1>Multithreading Bullet Physics in jme3</h1><div class="details"><span class="author" id="author"></span><br><span id="revnumber">version ,</span> <span id="revdate">2016/03/17 20:48</span></div><div id="toc" class="toc2"><div id="toctitle">Table of Contents</div><ul class="sectlevel1"><li><a href="#introduction">Introduction</a></li><li><a href="#how-is-it-handled-in-jme3-and-bullet">How is it handled in jme3 and bullet?</a></li></ul></div></div><div id="content"><div class="sect1"><h2 id="introduction">Introduction</h2><div class="sectionbody"><div class="paragraph"><p>Since bullet is not (yet) multithreaded or GPU accelerated, the jME3 implementation allows to run each physics space on a separate thread that is executed in parallel to rendering.</p></div></div></div>
- <div class="sect1"><h2 id="how-is-it-handled-in-jme3-and-bullet">How is it handled in jme3 and bullet?</h2><div class="sectionbody"><div class="paragraph"><p>A SimpleApplication with a BulletAppState allows setting the threading type via</p></div>
- <div class="listingblock"><div class="content"><pre class="CodeRay highlight"><code>setThreadingType(ThreadingType type);</code></pre></div></div>
- <div class="literalblock"><div class="content"><pre>where ThreadingType can be either SEQUENTIAL or PARALLEL. By default, it's SEQUENTIAL.</pre></div></div>
- <div class="paragraph"><p>You can activate PARALLEL threading in the simpleInitApp() method:</p></div>
- <div class="listingblock"><div class="content"><pre class="CodeRay highlight"><code data-lang="java">bulletAppState = <span class="keyword">new</span> BulletAppState();
- bulletAppState.setThreadingType(BulletAppState.ThreadingType.PARALLEL);
- stateManager.attach(bulletAppState);</code></pre></div></div>
- <div class="paragraph"><p>Now the physics update happens in parallel to render(), that is, after the user’s changes in the update() call have been applied. During update() the physics update loop pauses. This way the loop logic is still maintained: the user can set and change values in physics and scenegraph objects before render() and physicsUpdate() are called in parallel. This allows you to use physics methods in update() as if it was single-threaded.</p></div>
- <table class="tableblock frame-all grid-all spread"><colgroup><col style="width: 50%;"><col style="width: 50%;"></colgroup><thead><tr><th class="tableblock halign-left valign-top">PARALLEL</th><th class="tableblock halign-left valign-top">SEQUENTIAL</th></tr></thead><tbody><tr><td class="tableblock halign-left valign-top"><div><div class="olist arabic"><ol class="arabic"><li><p>update(), 2. render() and physics update().</p></li></ol></div></div></td><td class="tableblock halign-left valign-top"><div><div class="olist arabic"><ol class="arabic"><li><p>update(), 2. render(), 3. physics update().</p></li></ol></div></div></td></tr><tr><td class="tableblock halign-left valign-top"><div><div class="paragraph"><p>Physics Debug View is rendered inaccurately (out of sync)</p></div></div></td><td class="tableblock halign-left valign-top"><div><div class="paragraph"><p>Physics Debug View is rendered accurately.</p></div></div></td></tr></tbody></table>
- <div class="admonitionblock tip"><table><tr><td class="icon"><i class="fa icon-tip" title="Tip"></i></td><td class="content"><div class="paragraph"><p>You can add more physics spaces by using multiple PARALLEL bulletAppStates. You would do that if you have sets physical objects that never collide (for example, underground bolders and flying cannon balls above ground), so you put those into separate physics spaces, which improves performances (less collisions to check!).</p></div></td></tr></table></div></div></div></div><div id="footer"><div id="footer-text">Version <br>Last updated 2016-07-22 07:15:15 UTC</div></div><script type="text/javascript" src="https://cdn.jsdelivr.net/docsearch.js/2/docsearch.min.js"></script><script>docsearch({
- apiKey: 'a736b6d93de805e26ec2f49b55013fbd',
- indexName: 'jmonkeyengine',
- inputSelector: '#doc-search',
- debug: false // Set debug to true if you want to inspect the dropdown
- });</script></body></html>
|