<?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/9588" />

	<title>Real-Time Physics Simulation Forum</title>
	
	<link href="https://pybullet.org/Bullet/phpBB3/index.php" />
	<updated>2013-11-29T14:22:07+00:00</updated>

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

		<entry>
		<author><name><![CDATA[Karrok]]></name></author>
		<updated>2013-11-29T14:22:07+00:00</updated>

		<published>2013-11-29T14:22:07+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=32286#p32286</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=32286#p32286"/>
		<title type="html"><![CDATA[Compound Objects: Get colliding child-shape's userdata.]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=32286#p32286"><![CDATA[
Hi All,<br><br>I have a compound shape with a bunch of child shapes, for each child-shape I also attach a small user data object containing some specific data for that child shape.<br><br>As an (simplified..) example , imagine a compound shape made out of 4 tiles. Each tiles has some user data value giving a certain amount of points:<br><div class="codebox"><p>Code: </p><pre><code>------------------------------|             ||             |     | userData{4} || userData{1} ||             ||             |--------------++-----------------------------++---------------|             ||             |     | userData{5} || userData{7} ||             ||             |-------------------------------</code></pre></div>And per frame I check the dispatchers manifolds whether something is colliding with 1 or more of the tiles.<br>At the moment, say a ball, collides with 1 of the subshapes of the compound shape I need to get the userdata of that child-shape.<br><br>Q: how do I get that child-shape user data back from the collision manifolds?<br><br>ie:<br><div class="codebox"><p>Code: </p><pre><code>int numManifolds = m_collisionWorld-&gt;getDispatcher()-&gt;getNumManifolds();    for (int i=0;i&lt;numManifolds;i++)    {      btPersistentManifold* contactManifold = m_collisionWorld-&gt;getDispatcher()-&gt;getManifoldByIndexInternal(i);      int numContacts = contactManifold-&gt;getNumContacts();      btCollisionObject* object_A = static_cast&lt;btCollisionObject*&gt;(contactManifold-&gt;getBody0());      // somehow get the childshape making the actual collision      // get userdata from childshape.      // do stuff with userdata    }</code></pre></div>edit: While it might be obvious for some readers that it would be easier to simply create 4 completely seperate boxes instead of a compound shape of boxes, for my application that won't fly sadly.<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=8150">Karrok</a> — Fri Nov 29, 2013 2:22 pm</p><hr />
]]></content>
	</entry>
	</feed>
