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

	<title>Real-Time Physics Simulation Forum</title>
	
	<link href="https://pybullet.org/Bullet/phpBB3/index.php" />
	<updated>2006-10-14T19:03:18+00:00</updated>

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

		<entry>
		<author><name><![CDATA[Erwin Coumans]]></name></author>
		<updated>2006-10-14T19:03:18+00:00</updated>

		<published>2006-10-14T19:03:18+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=2144#p2144</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=2144#p2144"/>
		<title type="html"><![CDATA[Re: Collision notification]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=2144#p2144"><![CDATA[
<blockquote class="uncited"><div>Is there an ability to get notification (callback) when collision with particular object occurs?</div></blockquote>It depends what you want to do with this:<br><br>If you only want to know the contacts/bodies overlapping with a certain body, you can use the btDynamicsWorld (btCollisionWorld) and iterate over all contact points (btPersistentManifolds) and intercept the objects that you are interested in, and check wether there are at least one contact point. The details are in CollisionInterfaceDemo:<div class="codebox"><p>Code: </p><pre><code>int numManifolds = collisionWorld-&gt;getDispatcher()-&gt;getNumManifolds();for (i=0;i&lt;numManifolds;i++){btPersistentManifold* contactManifold = collisionWorld-&gt;getDispatcher()-&gt;getManifoldByIndexInternal(i);btCollisionObject* obA = static_cast&lt;btCollisionObject*&gt;(contactManifold-&gt;getBody0());btCollisionObject* obB = static_cast&lt;btCollisionObject*&gt;(contactManifold-&gt;getBody1());contactManifold-&gt;refreshContactPoints(obA-&gt;m_worldTransform,obB-&gt;m_worldTransform);int numContacts = contactManifold-&gt;getNumContacts();for (int j=0;j&lt;numContacts;j++){btManifoldPoint&amp; pt = contactManifold-&gt;getContactPoint(j);glBegin(GL_LINES);glColor3f(1, 0, 1);btVector3 ptA = pt.getPositionWorldOnA();btVector3 ptB = pt.getPositionWorldOnB();glVertex3d(ptA.x(),ptA.y(),ptA.z());glVertex3d(ptB.x(),ptB.y(),ptB.z());glEnd();}//you can un-comment out this line, and then all points are removed//contactManifold-&gt;clearManifold();}</code></pre></div><br>If you want to modify the friction/restitution of the contact points with that particular object, you can do that by enabling the CF_CUSTOM_MATERIAL_CALLBACK for the rigidbody, see ConcavePhysicsDemo for details:<div class="codebox"><p>Code: </p><pre><code>staticBody-&gt;m_collisionFlags |= btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK;</code></pre></div>Notice that there is only a callback for new contacts, not for existing contacts ( so a resting box on a surface gets 4 contact callbacks, unless contacts gets removed and added again when it is sliding).  A more user-friendly interface will probably be added, another todo.<br><br>Thanks,<br>Erwin<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=2">Erwin Coumans</a> — Sat Oct 14, 2006 7:03 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Jack]]></name></author>
		<updated>2006-10-14T09:09:11+00:00</updated>

		<published>2006-10-14T09:09:11+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=2136#p2136</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=2136#p2136"/>
		<title type="html"><![CDATA[Collision notification]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=2136#p2136"><![CDATA[
Is there an ability to get notification (callback) when collision with particular object occurs?<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=772">Jack</a> — Sat Oct 14, 2006 9:09 am</p><hr />
]]></content>
	</entry>
	</feed>
