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

	<title>Real-Time Physics Simulation Forum</title>
	
	<link href="https://pybullet.org/Bullet/phpBB3/index.php" />
	<updated>2013-08-01T00:37:11+00:00</updated>

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

		<entry>
		<author><name><![CDATA[Trioxin]]></name></author>
		<updated>2013-08-01T00:37:11+00:00</updated>

		<published>2013-08-01T00:37:11+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=31472#p31472</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=31472#p31472"/>
		<title type="html"><![CDATA[ContactTest tunneling]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=31472#p31472"><![CDATA[
Evening bullet forums,<br>I've recently encountered an issue when I implemented ContactTest into a kinematic object.<br>If the object is moving slow enough per frame, it will behave exactly as expected, except that the object will "sink" into the collision surface a little bit, but otherwise will be stopped from leaving the field.<br>However if it's moving fast enough it will pass right through.<br><br>Below is a snippet of code I'm using. I tried to keep it to the relevant parts, since the project is a little big to just dump it all here.<br><br>I've simulated throughout the code a 60 frames per second update.<br><div class="codebox"><p>Code: </p><pre><code>struct ContactSensorCallback : public btCollisionWorld::ContactResultCallback{btVector3 m_Contact;ContactSensorCallback(): btCollisionWorld::ContactResultCallback(){m_Contact = btVector3(0,0,0);}virtualbtScalaraddSingleResult(btManifoldPoint&amp; cp,const btCollisionObjectWrapper* colObj0Wrap,int partId0,int index0,const btCollisionObjectWrapper* colObj1Wrap,int partId1,int index1){btVector3 nor = cp.getPositionWorldOnB() - cp.getPositionWorldOnA();float dist = cp.getDistance();if (dist &lt; 0) {m_Contact -= nor * dist;}return 0;}};void KCC::update() {float DELTA = 1.0f/60;float SPEED = 60.0f;rotate();float t_Z = 0;if (m_Forward) t_Z = -SPEED; else if (m_Backward) t_Z = SPEED;Ogre::Vector3 t_Vec = Ogre::Vector3(0, 0, t_Z);t_Vec = m_YawNode-&gt;getOrientation() * t_Vec;btVector3 vel = btVector3(t_Vec.x, t_Vec.y, t_Vec.z) * DELTA;fallRigidBody-&gt;translate(vel);ContactSensorCallback collisions;Engine::getSingleton()-&gt;m_DynamicsWorld-&gt;contactTest(fallRigidBody, collisions);fallRigidBody-&gt;translate(collisions.m_Contact);((OgreMotionState*)fallRigidBody-&gt;getMotionState())-&gt;setKinematicPos(fallRigidBody-&gt;getWorldTransform());}</code></pre></div><br><br>if I set the SPEED variable to 5-10, everything goes relatively well, but setting it to about 15+ I get the tunnelling effect with increasing consistency the higher I set the speed.<br><br>I reckon it's due to a need to take into account current velocity, though I'm not entirely sure how to do that, particularly at super fast movement speeds.<br><br>I'm not really sure what to ask, specifically.<br>Does the test take into account only the objects position directly after a stepSimulation?<br>Is it independent and thus take its position exactly as held since the last translate()?<br>Is there a flag I need to set to implement some kind of kinematic CCD?<br>Is there a relatively simple method I'm overlooking somewhere?<br>is this unusual behaviour?<br>What is the meaning of life?<br><br>Any suggestions are welcome, thanks <img class="smilies" src="https://pybullet.org/Bullet/phpBB3/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=8636">Trioxin</a> — Thu Aug 01, 2013 12:37 am</p><hr />
]]></content>
	</entry>
	</feed>
