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

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

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

		<entry>
		<author><name><![CDATA[Pacha]]></name></author>
		<updated>2013-11-21T23:08:24+00:00</updated>

		<published>2013-11-21T23:08:24+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=32210#p32210</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=32210#p32210"/>
		<title type="html"><![CDATA[Kinematic cc bug standing on 2 bodies at the same time]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=32210#p32210"><![CDATA[
Hello everyone.<br><br>I implemented the stock character controller in my game and it works alright, except when my ghost object is on top of 2 or more bodies at the same time. It flickers and moves a lot. Explanation gif:<br><br><a href="http://bigchannel.org/recording-42.gif" class="postlink">http://bigchannel.org/recording-42.gif</a><br><img src="http://bigchannel.org/recording-42.gif" class="postimage" alt="Image"><br><br>I tried to modify the code that comes with bullet, but I am not really good at it and I created a lot of bugs. Here is the function that is in charge of collision detection:<br><div class="codebox"><p>Code: </p><pre><code>bool btKinematicCharacterController::recoverFromPenetration ( btCollisionWorld* collisionWorld){// Here we must refresh the overlapping paircache as the penetrating movement itself or the// previous recovery iteration might have used setWorldTransform and pushed us into an object// that is not in the previous cache contents from the last timestep, as will happen if we// are pushed into a new AABB overlap. Unhandled this means the next convex sweep gets stuck.//// Do this by calling the broadphase's setAabb with the moved AABB, this will update the broadphase// paircache and the ghostobject's internal paircache at the same time.    /BWbtVector3 minAabb, maxAabb;m_convexShape-&gt;getAabb(m_ghostObject-&gt;getWorldTransform(), minAabb,maxAabb);collisionWorld-&gt;getBroadphase()-&gt;setAabb(m_ghostObject-&gt;getBroadphaseHandle(),  minAabb,  maxAabb,  collisionWorld-&gt;getDispatcher()); bool penetration = false;collisionWorld-&gt;getDispatcher()-&gt;dispatchAllCollisionPairs(m_ghostObject-&gt;getOverlappingPairCache(), collisionWorld-&gt;getDispatchInfo(), collisionWorld-&gt;getDispatcher());m_currentPosition = m_ghostObject-&gt;getWorldTransform().getOrigin();btScalar maxPen = btScalar(0.0);for (int i = 0; i &lt; m_ghostObject-&gt;getOverlappingPairCache()-&gt;getNumOverlappingPairs(); i++){m_manifoldArray.resize(0);btBroadphasePair* collisionPair = &amp;m_ghostObject-&gt;getOverlappingPairCache()-&gt;getOverlappingPairArray()[i];if (collisionPair-&gt;m_algorithm)collisionPair-&gt;m_algorithm-&gt;getAllContactManifolds(m_manifoldArray);for (int j=0;j&lt;m_manifoldArray.size();j++){btPersistentManifold* manifold = m_manifoldArray[j];btScalar directionSign = manifold-&gt;getBody0() == m_ghostObject ? btScalar(-1.0) : btScalar(1.0);for (int p=0;p&lt;manifold-&gt;getNumContacts();p++){const btManifoldPoint&amp;pt = manifold-&gt;getContactPoint(p);btScalar dist = pt.getDistance();if (dist &lt; 0.0){if (dist &lt; maxPen){maxPen = dist;m_touchingNormal = pt.m_normalWorldOnB * directionSign;//??}/*static int updateCounter = 0;if (mJumpHorizontalHelper.length() != 0){updateCounter++;if (updateCounter &gt; 25){mJumpHorizontalHelper = btVector3(0, 0, 0);}}else{updateCounter = 0;}*///mJumpHorizontalHelper = btVector3(0, 0, 0);m_currentPosition += pt.m_normalWorldOnB * directionSign * dist * btScalar(0.2);penetration = true;} else {//printf("touching %f\n", dist);}}//manifold-&gt;clearManifold();}}btTransform newTrans = m_ghostObject-&gt;getWorldTransform();newTrans.setOrigin(m_currentPosition);m_ghostObject-&gt;setWorldTransform(newTrans);//printf("m_touchingNormal = %f,%f,%f\n",m_touchingNormal[0],m_touchingNormal[1],m_touchingNormal[2]);return penetration;}</code></pre></div>Could someone help me out, please? Thanks.<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=10282">Pacha</a> — Thu Nov 21, 2013 11:08 pm</p><hr />
]]></content>
	</entry>
	</feed>
