<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
	<link rel="self" type="application/atom+xml" href="https://pybullet.org/Bullet/phpBB3/app.php/feed/topic/11075" />

	<title>Real-Time Physics Simulation Forum</title>
	
	<link href="https://pybullet.org/Bullet/phpBB3/index.php" />
	<updated>2016-08-15T03:36:29+00:00</updated>

	<author><name><![CDATA[Real-Time Physics Simulation Forum]]></name></author>
	<id>https://pybullet.org/Bullet/phpBB3/app.php/feed/topic/11075</id>

		<entry>
		<author><name><![CDATA[co2]]></name></author>
		<updated>2016-08-15T03:36:29+00:00</updated>

		<published>2016-08-15T03:36:29+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=38013#p38013</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=38013#p38013"/>
		<title type="html"><![CDATA[Re: Proper way to keep networked physics states in-sync?]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=38013#p38013"><![CDATA[
<blockquote class="uncited"><div><blockquote class="uncited"><div>If someone is considering using bullet physics for a game with networked physics I'd recommend against it.</div></blockquote>I think that statement needs qualification.  Bullet might not be suitable for the <strong class="text-strong">Deterministic Lockstep</strong> method for networked physics, but that is only one of three that Glenn Fiedler discusses in his series on networked physics.  The other two are: <strong class="text-strong">Snapshots and Interpolation</strong> and <strong class="text-strong">State Synchronization</strong>.</div></blockquote>Both the solutions he proposes are only functional when updates can be sent faster than divergences happen.  His example uses 25kbps of bandwidth for a very simple simulation with some blocks.  25kbps for such a simple simulation isn't practical for many applications.  Build a more complex simulation or have more clients that need synchronization and you can easily exceed bandwidth limits, at which point in time you will have massive discontinuity issues in each separate simulation.<br><br>For the application that I am working on I can only send updates once every second or two.  Even if I send updates faster (say 5 times a second) there is still noticeable lag, even with smoothing.  I found a workaround though, but it requires completely resetting bullet physics each cycle on both the server-side and client-side which is not pretty and certainly not efficient.<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=11655">co2</a> — Mon Aug 15, 2016 3:36 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[co2]]></name></author>
		<updated>2016-03-24T16:28:03+00:00</updated>

		<published>2016-03-24T16:28:03+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=37214#p37214</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=37214#p37214"/>
		<title type="html"><![CDATA[Re: Proper way to keep networked physics states in-sync?]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=37214#p37214"><![CDATA[
<blockquote class="uncited"><div>Is it possible to sync only game logic?  <br><br>Let the server rule all the game logic, and let clients use physic engine only for cosmetic.<br><br>Even if Bullet can sync the physic engine, sync-ing the whole state of Bullet between 2 computers is too harsh. (more data-flow)<br><br>I have not found any real-time games that can sync physic of 2 computers.  They can only fake it, I guess.</div></blockquote>Yeah, the way many games solve the problem is to avoid having to sync the physics in the first place.  The problem arises when the physics is integral to the game logic.  Suppose a racing game like Mario Kart, for example.  As to whether or not it is possible, I've successfully implemented two multiplayer game engines that utilize physics, both different kinds of games that utilize the physics in different ways.  So it definitely is possible.<br><br>It would be a lot easier if implemented properly in Bullet Physics and if some proper documentation were added, and the code was cleaned up a bit (rename ambiguous classes like "btMotionState" to "btGraphicsState" or something similar).<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=11655">co2</a> — Thu Mar 24, 2016 4:28 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[hyyou]]></name></author>
		<updated>2016-03-24T10:58:54+00:00</updated>

		<published>2016-03-24T10:58:54+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=37208#p37208</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=37208#p37208"/>
		<title type="html"><![CDATA[Re: Proper way to keep networked physics states in-sync?]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=37208#p37208"><![CDATA[
Is it possible to sync only game logic?  <br><br>Let the server rule all the game logic, and let clients use physic engine only for cosmetic.<br><br>Even if Bullet can sync the physic engine, sync-ing the whole state of Bullet between 2 computers is too harsh. (more data-flow)<br><br>I have not found any real-time games that can sync physic of 2 computers.  They can only fake it, I guess.<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=11659">hyyou</a> — Thu Mar 24, 2016 10:58 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[co2]]></name></author>
		<updated>2016-03-23T20:36:05+00:00</updated>

		<published>2016-03-23T20:36:05+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=37206#p37206</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=37206#p37206"/>
		<title type="html"><![CDATA[Re: Proper way to keep networked physics states in-sync?]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=37206#p37206"><![CDATA[
<blockquote class="uncited"><div><blockquote class="uncited"><div>If someone is considering using bullet physics for a game with networked physics I'd recommend against it.</div></blockquote>I think that statement needs qualification.  Bullet might not be suitable for the <strong class="text-strong">Deterministic Lockstep</strong> method for networked physics, but that is only one of three that Glenn Fiedler discusses in his series on networked physics.  The other two are: <strong class="text-strong">Snapshots and Interpolation</strong> and <strong class="text-strong">State Synchronization</strong>.</div></blockquote>There are several reasons I wouldn't recommend bullet for a multiplayer game at this point:<br><br>1.  Two Bullet Physics states initialized in the same exact way with every change applied to them in the same way (in the same order and on the same fixed time-steps), will still diverge.  That shouldn't happen.<br><br>2.  The documentation is poor, and portions of the code are extremely misleading.  I lost a bunch of time just to figure out that motion states aren't passed their actual positions with setWorldTransform, even though getWorldTransform requires the actual position, for example.<br><br>3.  The functionality to save/load the physics state isn't well implemented or even functional.  I should be able to call a single function that populates a buffer with a snapshot of the physics state (either a portion or the whole thing).  I should then be able to load that in a separate / reset physics state by calling a single function and continue the simulation exactly as it would have in the original simulation from the point of that snapshot.<br><br>I was really impressed up to this point.  These are some serious shortcomings and people should know about them before they get caught in the awkward position I find myself in.<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=11655">co2</a> — Wed Mar 23, 2016 8:36 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[drleviathan]]></name></author>
		<updated>2016-03-21T02:21:17+00:00</updated>

		<published>2016-03-21T02:21:17+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=37185#p37185</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=37185#p37185"/>
		<title type="html"><![CDATA[Re: Proper way to keep networked physics states in-sync?]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=37185#p37185"><![CDATA[
<blockquote class="uncited"><div>If someone is considering using bullet physics for a game with networked physics I'd recommend against it.</div></blockquote>I think that statement needs qualification.  Bullet might not be suitable for the <strong class="text-strong">Deterministic Lockstep</strong> method for networked physics, but that is only one of three that Glenn Fiedler discusses in his series on networked physics.  The other two are: <strong class="text-strong">Snapshots and Interpolation</strong> and <strong class="text-strong">State Synchronization</strong>.<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=11033">drleviathan</a> — Mon Mar 21, 2016 2:21 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[co2]]></name></author>
		<updated>2016-03-21T01:25:02+00:00</updated>

		<published>2016-03-21T01:25:02+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=37184#p37184</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=37184#p37184"/>
		<title type="html"><![CDATA[Re: Proper way to keep networked physics states in-sync?]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=37184#p37184"><![CDATA[
<blockquote class="uncited"><div>I looked through the code and found some randomization happening in the constraint solver classes, however, as far as I can tell relevant behavior flags are not set by default, so the randomization feature should be bypassed. The constraint solvers are used (I think) to solve the contact points so maybe you could try to make sure you are not falling into that randomization code.</div></blockquote>Thanks!  Are you referring to the btSequentialConstraintSolver class?  I found that as well, and synchronizing the random state from it didn't help.  <br><br>I was able to get things to sync up by completely resetting bullet physics every cycle on both the server and all the clients.  I made a list of all the collision objects, deleted the dynamics world, constraint solver etc and re-allocated them, then added all the objects back in.  Prior to now I wasn't entirely sure the problem was with bullet physics but at this point I am highly confident it is.  There is something in there that causes things not to stay in sync.<br><br>If someone is considering using bullet physics for a game with networked physics I'd recommend against it.  If you are already committed / find yourself in a similar situation I'd highly recommend staying away from any of the built-in serialization code, and be sure to use btRigidBody::getWorldTransform() rather than what's passed to the motion states.  Fix your timestep and make sure everything happens on the same cycle and in the same order across all the simulations, and reset bullet physics every cycle.<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=11655">co2</a> — Mon Mar 21, 2016 1:25 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[drleviathan]]></name></author>
		<updated>2016-03-20T14:25:43+00:00</updated>

		<published>2016-03-20T14:25:43+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=37180#p37180</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=37180#p37180"/>
		<title type="html"><![CDATA[Re: Proper way to keep networked physics states in-sync?]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=37180#p37180"><![CDATA[
I looked through the code and found some randomization happening in the constraint solver classes, however, as far as I can tell relevant behavior flags are not set by default, so the randomization feature should be bypassed.  The constraint solvers are used (I think) to solve the contact points so maybe you could try to make sure you are not falling into that randomization code.<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=11033">drleviathan</a> — Sun Mar 20, 2016 2:25 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[co2]]></name></author>
		<updated>2016-03-16T18:56:53+00:00</updated>

		<published>2016-03-16T18:56:53+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=37167#p37167</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=37167#p37167"/>
		<title type="html"><![CDATA[Re: Proper way to keep networked physics states in-sync?]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=37167#p37167"><![CDATA[
<blockquote class="uncited"><div>Can you make the Bullet simulation exactly the same server and client?<br><br>The short answer: no, not for server-client situation where the clients may be running entirely different hardware than the server.<br><br>The long answer: you should read these articles:  <a href="http://gafferongames.com/networked-physics/introduction-to-networked-physics/" class="postlink">http://gafferongames.com/networked-phys ... d-physics/</a></div></blockquote>Thanks!  I've already implemented those methods, and the server/client are being run on the same computer.  The physics state should be identical given those conditions but it isn't.  Changes are sent from my server to the client and incorporated on the same time-step and in the same order, and once the changes are applied the two states will be identical until a contact is generated, at which point in time the two states diverge, radically.<br><br>E.g., bullet physics is somehow generating differing contacts despite identical simulations on the same machine.<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=11655">co2</a> — Wed Mar 16, 2016 6:56 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[drleviathan]]></name></author>
		<updated>2016-03-15T19:00:07+00:00</updated>

		<published>2016-03-15T19:00:07+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=37158#p37158</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=37158#p37158"/>
		<title type="html"><![CDATA[Re: Proper way to keep networked physics states in-sync?]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=37158#p37158"><![CDATA[
Can you make the Bullet simulation exactly the same server and client?<br><br>The short answer: no, not for server-client situation where the clients may be running entirely different hardware than the server.<br><br>The long answer: you should read these articles:  <a href="http://gafferongames.com/networked-physics/introduction-to-networked-physics/" class="postlink">http://gafferongames.com/networked-phys ... d-physics/</a><p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=11033">drleviathan</a> — Tue Mar 15, 2016 7:00 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[co2]]></name></author>
		<updated>2016-03-14T16:05:13+00:00</updated>

		<published>2016-03-14T16:05:13+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=37150#p37150</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=37150#p37150"/>
		<title type="html"><![CDATA[Proper way to keep networked physics states in-sync?]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=37150#p37150"><![CDATA[
Hello!<br><br>I am implementing an MMO game that uses Bullet Physics and I am having issues keeping the networked physics states in-sync.  <br><br>The server simulates things server-side, and the client simulates things client-side.  When the server-side state changes (such as a character moving a rock represented as a rigid body) the changes are sent to all the clients which incorporate them into their states and then continue the simulation on their own from there.  The clients basically run the simulation and wait for updates from the server to verify that their simulation is correct, and if they differ they update to what the server has provided.<br><br>The problem that I am having is that everything stays in sync until a collision happens (such as two boxes colliding).  I've verified that up until that point the physics states are identical, but after the contact is made the collision object array (acquired from btDiscreteDynamicsWorld::getCollisionObjectArray) is different, and after that cycle the linear and angular velocities can differ, as well as world transformations etc.<br><br>I've been looking everywhere for some answers to this question (forums, wiki etc).  I'm quite desperate at this point.  I was hoping that maybe someone has dealt with a similar issue before and/or there is some documentation somewhere that specifies the proper way to synchronize bullet physics states across the network.<br><br>I update my game-state at fixed time-steps and all the changes that happen on the server are incorporated on the same cycles and in the same order on the client(s) as they were applied on the server.  I apply changes to rigid bodies like so:<br><div class="codebox"><p>Code: </p><pre><code>rigidBody-&gt;setWorldTransform(t);motionState-&gt;setWorldTransform(t);rigidBody-&gt;setInterpolationWorldTransform(t);rigidBody-&gt;activate();rigidBody-&gt;clearForces();rigidBody-&gt;setLinearVelocity(btVector3(info.linearVelocity[0], info.linearVelocity[1], info.linearVelocity[2]));rigidBody-&gt;setAngularVelocity(btVector3(info.angularVelocity[0], info.angularVelocity[1], info.angularVelocity[2]));rigidBody-&gt;setInterpolationLinearVelocity(btVector3(info.linearVelocity[0], info.linearVelocity[1], info.linearVelocity[2]));rigidBody-&gt;setInterpolationAngularVelocity(btVector3(info.angularVelocity[0], info.angularVelocity[1], info.angularVelocity[2]));</code></pre></div>The world transform is acquired by calling btRigidBody::getWorldTransform() and the same for the linear/angular velocities.  After these changes are applied, the physics state will be identical, unless a contact was generated this cycle.<br><br>Is there anything that I can do to make the Bullet Physics states identical?<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=11655">co2</a> — Mon Mar 14, 2016 4:05 pm</p><hr />
]]></content>
	</entry>
	</feed>
