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

	<title>Real-Time Physics Simulation Forum</title>
	
	<link href="https://pybullet.org/Bullet/phpBB3/index.php" />
	<updated>2012-04-03T16:24:59+00:00</updated>

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

		<entry>
		<author><name><![CDATA[Knn0N]]></name></author>
		<updated>2012-04-03T16:24:59+00:00</updated>

		<published>2012-04-03T16:24:59+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=27571#p27571</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=27571#p27571"/>
		<title type="html"><![CDATA[Re: Collisions between Characters Controllers]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=27571#p27571"><![CDATA[
ops!  <img class="smilies" src="https://pybullet.org/Bullet/phpBB3/images/smilies/icon_redface.gif" width="15" height="15" alt=":oops:" title="Embarassed"> <br><br>sorry. I've been moved to the right sub forum.<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=9226">Knn0N</a> — Tue Apr 03, 2012 4:24 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[bone]]></name></author>
		<updated>2012-04-03T16:11:38+00:00</updated>

		<published>2012-04-03T16:11:38+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=27568#p27568</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=27568#p27568"/>
		<title type="html"><![CDATA[Re: Collisions between Characters Controllers]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=27568#p27568"><![CDATA[
You might want to go back to the main forum page and read the <span style="color:#FF0000">red</span> text regarding this sub-forum.<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=1626">bone</a> — Tue Apr 03, 2012 4:11 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Knn0N]]></name></author>
		<updated>2012-04-03T13:36:16+00:00</updated>

		<published>2012-04-03T13:36:16+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=27567#p27567</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=27567#p27567"/>
		<title type="html"><![CDATA[Re: Collisions between Characters controllers]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=27567#p27567"><![CDATA[
Any ideas?!??!<br><br>Am I in a wrong way??<br><br>Should I change the functionality of my triggers??<br><br>thanks!<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=9226">Knn0N</a> — Tue Apr 03, 2012 1:36 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Knn0N]]></name></author>
		<updated>2012-04-03T14:01:50+00:00</updated>

		<published>2012-04-02T14:44:34+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=27552#p27552</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=27552#p27552"/>
		<title type="html"><![CDATA[Collisions between Characters Controllers]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=27552#p27552"><![CDATA[
(collisions between btPairCachingGhostObject)<br><br>Hi everybody,<br><br>Me and my team are currently developing a game using bullet physics. The genre of the is basically a tower defense. Well, I'm trying to use characters controllers for IA purposes, because using only rigidBody makes unstable behavior between IA's and the world.<br>I thought in configure the world to avoid this penetrations between rigid bodies, etc.<br><br>But finally I decided to use the KinematicCharacterController class. It works fine, but this is my problem:<br><br>-Before I take this decision, I implemented triggers for the game purposes using btPairCachingGhostObject. This works like a charm when I was using ridigBodies, the behavior was the expected. But well, when I change the IA physic part from rigidBodies to characterController (it uses internally a btPairCachingGhostObject, too), the behavior wasn't the expected.<br><br>After this little introduction I ask now:<br>-Is the collision between btPairCachingGhostObject provided?<br><br>Basically I'm using the next methods to detect the collision when a body joins into the trigger:<div class="codebox"><p>Code: </p><pre><code>//---------------------------------------------------------void CManualTrigger::TriggerTick(){    btDiscreteDynamicsWorld* m_dynamicsWorld = CPhysicEngine::Ref().GetbtSoftDynamicWorld();    //Retrives the content from all ghost objects in the world and call ProcessObectsInsideGhostObjects(...) for each.    if ( m_dynamicsWorld )    {        btAlignedObjectArray &lt; btCollisionObject* &gt; objsInsidePairCachingGhostObject;// We might want this to be a member variable...        btAlignedObjectArray &lt; btCollisionObject* &gt;* pObjsInsideGhostObject = NULL;// We will store a reference of the current array in this pointer        const btAlignedObjectArray &lt; btCollisionObject* &gt;&amp; objs = m_dynamicsWorld-&gt;getCollisionObjectArray();        for (int i=0,sz=objs.size();i&lt;sz;i++)        {            btCollisionObject* o = objs[i];            btGhostObject* go = btGhostObject::upcast(o);            if (go)            {                objsInsidePairCachingGhostObject.resize(0);                btPairCachingGhostObject* pgo = dynamic_cast &lt; btPairCachingGhostObject* &gt; (go);// No upcast functionality...                if (pgo)                {                    GetCollidingObjectsInsidePairCachingGhostObject(static_cast &lt; btDiscreteDynamicsWorld* &gt; (m_dynamicsWorld),pgo,objsInsidePairCachingGhostObject);                    pObjsInsideGhostObject = &amp;objsInsidePairCachingGhostObject;                }                else                 {                    // It's better not to try and copy the whole array, but to keep a reference to it!                    pObjsInsideGhostObject = &amp;go-&gt;getOverlappingPairs();                                        // Side Note: (at the moment) makes my program crash on my system...                    //btAlignedObjectArray &lt; btCollisionObject* &gt; objs = go-&gt;getOverlappingPairs();                     // Nevermind, that was the wrong way of doing it:                     //btAlignedObjectArray &lt; btCollisionObject* &gt;&amp; objs2 = go-&gt;getOverlappingPairs();                     //is much better.                }                // Here pObjsInsideGhostObject should be valid.                ProcessObectsInsideGhostObjects(*pObjsInsideGhostObject, pgo);            }        }    }}//---------------------------------------------------------// This static method is useful for the demo only. It's called by "void GhostObjectsDemo::clientMoveAndDisplay()".// Basically we must find a way to "display" the objects inside ghost objects to the user.// We choose to apply a vertical impulse to them (just because it's easier).// (The strength of the impulse is different depending on the type of ghost object)void CManualTrigger::ProcessObectsInsideGhostObjects(btAlignedObjectArray &lt; btCollisionObject* &gt;&amp; objs, const bool isPairCachingGhostObject){    //Primer paso: Comprobando colisiones e insertando los nuevos objetos que no estaban ya insertados en el mapa de colisiones.    for (int j=0,jsz=objs.size();j&lt;jsz;j++)     {        btPairCachingGhostObject* b = dynamic_cast &lt; btPairCachingGhostObject* &gt;(objs[j]);        //This line was the original one, before I change by the line above.        //btRigidBody* c = btRigidBody::upcast(objs[j]);        if (b)         {            //Obtenemos la informacion que relaciona bullet con la logica (TActorInfo).            TActorInfo *info = (TActorInfo *)b-&gt;getUserPointer();            //Obtenemos el componente entidad fisica al que pertenece el rigidBody 'b'.            CPhysicEntity *physicEntity = reinterpret_cast&lt;CPhysicEntity*&gt; (info-&gt;pPhysicObj-&gt;userData);            //Obtenemos la entidad logica que contiene el componente anterior.            CEntity *entityCollisioned = physicEntity-&gt;getEntity();                        if (entityCollisioned-&gt;getType() == "StuffedAnimal" ||  entityCollisioned-&gt;getType() == "Player")             {                                //Primero comprobamos que el objeto no conste ya en el mapa de objetos colisionados con el trigger.                _it = _objectsColliding.find(b);                if (_it == _objectsColliding.end())                 {                    //Si no estuviera, lo insertamos.                    _objectsColliding.insert(std::pair&lt;btCollisionObject*,bool&gt;(b, true));                    //Y mandamos el mensaje oportuno.                    //Dependiendo de la trampa, habrá un comportamiento u otro.                    doAction(entityCollisioned);                }            }        }    }    //Si hay algo en contacto con el trigger.    if (objs.size() &gt; 0)    {        //Segundo paso: Marcando en el mapa de colisiones los objetos que ya no esten colisionando con el trigger.        for (_it = _objectsColliding.begin(); _it != _objectsColliding.end(); ++_it)         {            //Si la busqueda devuelve un entero igual al tamanyo del map objs, es que no se ha encontrado el elemento.            if ( objs.findLinearSearch(_it-&gt;first) == objs.size() )            {                _it-&gt;second = false;            }        }        //Tercer paso: Notificar a las entidades que ya no estan colisionando con el trigger con su correspondiente mensaje.        notifyingOnExitEntities();    }}//---------------------------------------------------------// Portable static method: prerequisite call: m_dynamicsWorld-&gt;getBroadphase()-&gt;getOverlappingPairCache()-&gt;setInternalGhostPairCallback(new btGhostPairCallback()); void CManualTrigger::GetCollidingObjectsInsidePairCachingGhostObject(btDiscreteDynamicsWorld* m_dynamicsWorld,                                                                    btPairCachingGhostObject* m_pairCachingGhostObject,                                                                    btAlignedObjectArray&lt;btCollisionObject*&gt;&amp; collisionArrayOut){    collisionArrayOut.resize(0);    if (!m_pairCachingGhostObject || !m_dynamicsWorld)         return;    // With "false" things don't change much, and the code is a bit faster and cleaner...    const bool addOnlyObjectsWithNegativeDistance(true);        btBroadphasePairArray&amp; collisionPairs = m_pairCachingGhostObject-&gt;getOverlappingPairCache()-&gt;getOverlappingPairArray();    const intnumObjects=collisionPairs.size();    static btManifoldArraym_manifoldArray;    bool added;    for(int i=0;i&lt;numObjects;i++)    {        m_manifoldArray.resize(0);        added = false;        for (int j=0;j&lt;m_manifoldArray.size();j++)        {            btPersistentManifold* manifold = m_manifoldArray[j];            // Here we are in the narrowphase, but can happen that manifold-&gt;getNumContacts()==0:            if (addOnlyObjectsWithNegativeDistance)            {                for (int p=0,numContacts=manifold-&gt;getNumContacts();p&lt;numContacts;p++)                {                    const btManifoldPoint&amp;pt = manifold-&gt;getContactPoint(p);                    if (pt.getDistance() &lt; 0.0)                     {                        // How can I be sure that the colObjs are all distinct ? I use the "added" flag.                        collisionArrayOut.push_back((btCollisionObject*) (manifold-&gt;getBody0() == m_pairCachingGhostObject ? manifold-&gt;getBody1() : manifold-&gt;getBody0()));                        added = true;                        break;                    }                }                if (added)                     break;            }            else if (manifold-&gt;getNumContacts()&gt;0)             {                collisionArrayOut.push_back((btCollisionObject*) (manifold-&gt;getBody0() == m_pairCachingGhostObject ? manifold-&gt;getBody1() : manifold-&gt;getBody0()));                break;            }        }    }}</code></pre></div><br><br>So, Is this possible?, I mean, Can we detect collision between characters controllers (between GhostObjects)?. This would be useful too, to avoid the overlapping between two or more btKinematicCharacterControllers.<br><br>Thanks!<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=9226">Knn0N</a> — Mon Apr 02, 2012 2:44 pm</p><hr />
]]></content>
	</entry>
	</feed>
