<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Scary Vines</title>
	<atom:link href="http://toddvanderlin.com/2009/04/scary-vines/feed/" rel="self" type="application/rss+xml" />
	<link>http://toddvanderlin.com/2009/04/scary-vines/</link>
	<description>Design &#38; Technology</description>
	<lastBuildDate>Fri, 06 Aug 2010 19:09:08 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: monoflow</title>
		<link>http://toddvanderlin.com/2009/04/scary-vines/comment-page-1/#comment-200297</link>
		<dc:creator>monoflow</dc:creator>
		<pubDate>Sat, 04 Apr 2009 14:26:22 +0000</pubDate>
		<guid isPermaLink="false">http://toddvanderlin.com/?p=1160#comment-200297</guid>
		<description>Hi Todd,
i worked with JBox2D an has a similar problem. The only solution for me was to delete and create a new Shape in a Body on each Frame. The only Problem was that my instruction to delete and create was triggert in a moment when the World.Step() phase was in action an so I got crazy exceptions in irregular intervalls.
In my application I have 2 threads: on OpenGL Thread who triggers the World.step() method to update the simulation at the same intervall of the rendering and a second with my own code.
So i made a hack: I extend the org.jbox2d.dynamics.World class from the sources of JBox2D  with a method to get the m_lock variable.

 public Boolean getLock(){
    	return m_lock;
    }
If you look in line 458 (step() method) you see that this is a flag to lock a lot of functions while the solver is working. 
With this extension I&#039;m able to check in my code if the Physik-Engine is in a crucial phase and wait:
My code:

while(m_world.getLock()){
//nothing: 
	}
//go ahead
//now i set a custom lock-flag to stop the call of the World.step() Method because my OpenGL Thread triggers this
_lock= true;
//now i can create and delete some shape or Body in the Physic-engine
_lock= false;//release the flag. Now the Physic-engine gets updated.
.....
if(_lock==False){		m_world.step(_timeStep,_settings.iterationCount);
}

Cheers</description>
		<content:encoded><![CDATA[<p>Hi Todd,<br />
i worked with JBox2D an has a similar problem. The only solution for me was to delete and create a new Shape in a Body on each Frame. The only Problem was that my instruction to delete and create was triggert in a moment when the World.Step() phase was in action an so I got crazy exceptions in irregular intervalls.<br />
In my application I have 2 threads: on OpenGL Thread who triggers the World.step() method to update the simulation at the same intervall of the rendering and a second with my own code.<br />
So i made a hack: I extend the org.jbox2d.dynamics.World class from the sources of JBox2D  with a method to get the m_lock variable.</p>
<p> public Boolean getLock(){<br />
    	return m_lock;<br />
    }<br />
If you look in line 458 (step() method) you see that this is a flag to lock a lot of functions while the solver is working.<br />
With this extension I&#8217;m able to check in my code if the Physik-Engine is in a crucial phase and wait:<br />
My code:</p>
<p>while(m_world.getLock()){<br />
//nothing:<br />
	}<br />
//go ahead<br />
//now i set a custom lock-flag to stop the call of the World.step() Method because my OpenGL Thread triggers this<br />
_lock= true;<br />
//now i can create and delete some shape or Body in the Physic-engine<br />
_lock= false;//release the flag. Now the Physic-engine gets updated.<br />
&#8230;..<br />
if(_lock==False){		m_world.step(_timeStep,_settings.iterationCount);<br />
}</p>
<p>Cheers</p>
]]></content:encoded>
	</item>
</channel>
</rss>
