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

	<title>Real-Time Physics Simulation Forum</title>
	
	<link href="https://pybullet.org/Bullet/phpBB3/index.php" />
	<updated>2016-01-21T19:22:14+00:00</updated>

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

		<entry>
		<author><name><![CDATA[Pipirongu]]></name></author>
		<updated>2016-01-21T19:22:14+00:00</updated>

		<published>2016-01-21T19:22:14+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=36937#p36937</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=36937#p36937"/>
		<title type="html"><![CDATA[Re: Collision response - solver, penetration recovery]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=36937#p36937"><![CDATA[
<blockquote class="uncited"><div>Looks good! I would add friction next. <img class="smilies" src="https://pybullet.org/Bullet/phpBB3/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"></div></blockquote>I'll take a look at iterations(accumulating impulses), warmstart and friction.<br>I can let go of the clipping part for now. Using the clipped polygon for the next clipping make sense to me, thanks Dirk.<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=11558">Pipirongu</a> — Thu Jan 21, 2016 7:22 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Dirk Gregorius]]></name></author>
		<updated>2016-01-21T19:09:23+00:00</updated>

		<published>2016-01-21T19:09:23+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=36936#p36936</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=36936#p36936"/>
		<title type="html"><![CDATA[Re: Collision response - solver, penetration recovery]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=36936#p36936"><![CDATA[
Looks good! I would add friction next. <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=14">Dirk Gregorius</a> — Thu Jan 21, 2016 7:09 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Pipirongu]]></name></author>
		<updated>2016-01-21T18:13:55+00:00</updated>

		<published>2016-01-21T18:13:55+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=36935#p36935</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=36935#p36935"/>
		<title type="html"><![CDATA[Re: Collision response - solver, penetration recovery]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=36935#p36935"><![CDATA[
<blockquote class="uncited"><div>Yes, you clip the clipped polygon with the next planes. <br><br>I am not sure about the last picture. Looks wrong to me, but again it is difficult to tell. Try a 45 degrees rotated box and if you get 8 vertices.</div></blockquote>Yep, I get 8 vertices.<br><br><img src="http://i.imgur.com/aCsI22r.png" class="postimage" alt="Image"><br><br><img src="http://i.imgur.com/8h17jA8.png" class="postimage" alt="Image"><p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=11558">Pipirongu</a> — Thu Jan 21, 2016 6:13 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Dirk Gregorius]]></name></author>
		<updated>2016-01-21T17:53:51+00:00</updated>

		<published>2016-01-21T17:53:51+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=36934#p36934</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=36934#p36934"/>
		<title type="html"><![CDATA[Re: Collision response - solver, penetration recovery]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=36934#p36934"><![CDATA[
Yes, you clip the clipped polygon with the next planes. <br><br>I am not sure about the last picture. Looks wrong to me, but again it is difficult to tell. Try a 45 degrees rotated box and if you get 8 vertices.<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=14">Dirk Gregorius</a> — Thu Jan 21, 2016 5:53 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Pipirongu]]></name></author>
		<updated>2016-01-21T16:37:40+00:00</updated>

		<published>2016-01-21T16:37:40+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=36931#p36931</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=36931#p36931"/>
		<title type="html"><![CDATA[Re: Collision response - solver, penetration recovery]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=36931#p36931"><![CDATA[
Okay, so it looks pretty good now. I first clip the incident face vertices and then use the result from the first clipping in the second clipping. I do the same for the other side planes. This also makes sense to me. A point might be behind a sideplane but still needs to be tested on the others. Reminds me of broadphase collision test with sort and sweep.<br><br>I still can't stack cubes though. They are stacked for awhile before they slide off. When they start to slide off, I get 5-6 contact points.<br><br>This is my solver and I use baumgarte otherwise they will sink into the ground. I'm not sure how iterations(accumulating impulses) work so I have to research more there.<br>Is warmstart something I should look into as well?<br><br>Second picture is when the cubes are sliding off.<br><div class="codebox"><p>Code: </p><pre><code>void RenderScene::ProcessContact(Contact* contact, float&amp; Pn, Vector3&amp;vel1, Vector3&amp; ang_vel1, Vector3&amp;vel2, Vector3&amp; ang_vel2){const float k_allowedPenetration = 0.01f;float BAUMGARTE = 0.2f;//BAUMGARTEfloat bias = -BAUMGARTE * 1.f/this-&gt;physics_timestep * std::min(0.0f, -contact-&gt;penetration + k_allowedPenetration);RigidBody* ent1 = contact-&gt;one;RigidBody* ent2 = contact-&gt;two;const float e = std::min(ent1-&gt;restitution, ent2-&gt;restitution);Vector3 contactPoint = contact-&gt;position;Vector3 contactNormal = contact-&gt;normal;Vector3 rA = contactPoint - ent1-&gt;position;Vector3 rB = contactPoint - ent2-&gt;position;Vector3 kA = Vector3::Cross(rA, contactNormal);Vector3 kB = Vector3::Cross(rB, contactNormal);Vector3 uA = ent1-&gt;inverse_inertia_tensor_world_space*kA;Vector3 uB = ent2-&gt;inverse_inertia_tensor_world_space*kB;float normalMass = ent1-&gt;inverse_mass + ent2-&gt;inverse_mass;if (!ent1-&gt;is_kinematic){normalMass += Vector3::Dot(kA, uA);}if (!ent2-&gt;is_kinematic){normalMass += Vector3::Dot(kB, uB);}// Relative velocity at contactVector3 relativeVel = (ent2-&gt;velocity + Vector3::Cross(ent2-&gt;angular_velocity, rB)) - (ent1-&gt;velocity + Vector3::Cross(ent1-&gt;angular_velocity, rA));float numer = -(1 + e)*Vector3::Dot(relativeVel, contactNormal) + bias;float f = numer / normalMass;float Pn0 = contact-&gt;accumulated_impulse;contact-&gt;accumulated_impulse = std::fmax(Pn0 + f, 0.0f);f = contact-&gt;accumulated_impulse - Pn0;Vector3 impulse = f*contactNormal;contact-&gt;one-&gt;velocity -= impulse*ent1-&gt;inverse_mass;contact-&gt;two-&gt;velocity += impulse*ent2-&gt;inverse_mass;contact-&gt;one-&gt;angular_velocity -= f*uA;contact-&gt;two-&gt;angular_velocity += f*uB;}</code></pre></div><img src="http://i.imgur.com/22MBEAU.png" class="postimage" alt="Image"><br><br><img src="http://i.imgur.com/33lMR0g.png" class="postimage" alt="Image"><p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=11558">Pipirongu</a> — Thu Jan 21, 2016 4:37 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Pipirongu]]></name></author>
		<updated>2016-01-21T02:01:29+00:00</updated>

		<published>2016-01-21T02:01:29+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=36927#p36927</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=36927#p36927"/>
		<title type="html"><![CDATA[Re: Collision response - solver, penetration recovery]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=36927#p36927"><![CDATA[
<blockquote class="uncited"><div>Hmm, against how many side planes are you clipping? It should be four not two.</div></blockquote>Yes, it's against four. <br>Should I clip the incident face vertices first, and then use the resulting points from the first clipping in the second clipping?<br><div class="codebox"><p>Code: </p><pre><code>std::vector&lt;Contact&gt; contacts;this-&gt;ClipFaceToSidePlane(incident_face, -1 * normal1, neg_offset1, contacts);this-&gt;ClipFaceToSidePlane(incident_face, normal1, pos_offset1, contacts);this-&gt;ClipFaceToSidePlane(incident_face, -1 * normal2, neg_offset2, contacts);this-&gt;ClipFaceToSidePlane(incident_face, normal2, pos_offset2, contacts);</code></pre></div><div class="codebox"><p>Code: </p><pre><code>void RenderScene::ClipFaceToSidePlane(const Vector3* face, const Vector3&amp; normal, float plane_offset, std::vector&lt;Contact&gt; &amp;contacts){Vector3 Vertex1 = face[3]; //start edge forms from endvertex-&gt;startvertexfloat Distance1 = Vector3::Dot(Vertex1, normal) - plane_offset;for (int i = 0; i &lt; 4; i++){Vector3 Vertex2 = face[i];float Distance2 = Vector3::Dot(Vertex2, normal) - plane_offset;if (Distance1 &lt;= 0.0f &amp;&amp; Distance2 &lt;= 0.0f){// Both vertices are behind the plane - keep vertex2Contact contact1;contact1.position = Vertex2;contacts.push_back(contact1);}else if (Distance1 &lt;= 0.0f &amp;&amp; Distance2 &gt; 0.0f){// Vertex1 is behind the plane, vertex2 is in front -&gt; intersection pointfloat Fraction = Distance1 / (Distance1 - Distance2);Vector3 Position = Vertex1 + Fraction * (Vertex2 - Vertex1);// Keep intersection pointContact contact1;contact1.position = Position;contacts.push_back(contact1);}else if (Distance2 &lt;= 0.0f &amp;&amp; Distance1 &gt; 0){// Vertex2 is behind the plane, vertex1 is in front -&gt; intersection pointfloat Fraction = Distance1 / (Distance1 - Distance2);Vector3 Position = Vertex1 + Fraction * (Vertex2 - Vertex1);// Keep intersection point Contact contact1;contact1.position = Position;contacts.push_back(contact1);// And also keep vertex2Contact contact2;contact2.position = Vertex2;contacts.push_back(contact2);}// Keep vertex2 as starting vertex for next edgeVertex1 = Vertex2;Distance1 = Distance2;}}</code></pre></div><p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=11558">Pipirongu</a> — Thu Jan 21, 2016 2:01 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Dirk Gregorius]]></name></author>
		<updated>2016-01-21T01:48:52+00:00</updated>

		<published>2016-01-21T01:48:52+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=36926#p36926</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=36926#p36926"/>
		<title type="html"><![CDATA[Re: Collision response - solver, penetration recovery]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=36926#p36926"><![CDATA[
Hmm, against how many side planes are you clipping? It should be four not two.<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=14">Dirk Gregorius</a> — Thu Jan 21, 2016 1:48 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Pipirongu]]></name></author>
		<updated>2016-01-20T21:13:35+00:00</updated>

		<published>2016-01-20T21:13:35+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=36925#p36925</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=36925#p36925"/>
		<title type="html"><![CDATA[Re: Collision response - solver, penetration recovery]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=36925#p36925"><![CDATA[
<blockquote class="uncited"><div>It is difficult to tell from your picture, but I *think* (if I interpret the image correctly) that the two left vertices are wrong as well and the normal clipping code would handle this. There is no additional filtering necessary. You should debug your clipping code. E.g. draw the clip planes (a simple quad per edge) with the normal at the center of the edge making sure it is oriented correctly. Draw the incident face vertices. Make sure that they are all in the right space (world space would be the easiest initially). Also make sure that the normals are unit length before constructing the clip planes.<br><br>Regarding my example code I posted on Gamedev the assumption is that the normals of the clip planes point outside (e.g. clip_plane.normal = cross(edge_direction, reference_plane.normal). <br><br>HTH,<br>-Dirk</div></blockquote>Ok so I rendered the reference plane normals and I've checked the incident face vertices before and they seem right. If i just filter against the reference plane. Shouldn't all these points be considered valid because they are on the plane? And if I clip against the red and blue side planes they should be filtered?<br><br>EDIT: Hmm I think they shouldn't even be there after clipping against the reference sideplanes<br><br><img src="http://i.imgur.com/oovANcQ.png" class="postimage" alt="Image"><br><img src="http://i.imgur.com/7oB3T4w.png" class="postimage" alt="Image"><br><br>This is my side planes creation code. I looked at box2d lite for it. I use my oriented bounding box rotation axes as normals.<div class="codebox"><p>Code: </p><pre><code>void RenderScene::CreateReferenceSidePlanes(RigidBody* reference_body, int &amp;axis_number, Vector3&amp; normal1, Vector3&amp; normal2, float&amp; neg_offset1, float&amp; pos_offset1, float&amp; neg_offset2, float&amp; pos_offset2){switch (axis_number){case 0: //Reference face is on the x axis so we create side planes for the other axes{normal1 = reference_body-&gt;obb-&gt;rot[1];normal2 = reference_body-&gt;obb-&gt;rot[2];float y = Vector3::Dot(reference_body-&gt;obb-&gt;pos, normal1);float z = Vector3::Dot(reference_body-&gt;obb-&gt;pos, normal2);neg_offset1 = -y + reference_body-&gt;obb-&gt;half_extent[1];pos_offset1 = y + reference_body-&gt;obb-&gt;half_extent[1];neg_offset2 = -z + reference_body-&gt;obb-&gt;half_extent[2];pos_offset2 = z + reference_body-&gt;obb-&gt;half_extent[2];this-&gt;DrawSidePlanes(normal1, normal2, reference_body-&gt;obb-&gt;pos, 1, 2, reference_body-&gt;obb-&gt;half_extent);}break;case 1: //Reference face is on the y axis so we create side planes for the other axes{normal1 = reference_body-&gt;obb-&gt;rot[0];normal2 = reference_body-&gt;obb-&gt;rot[2];float x = Vector3::Dot(reference_body-&gt;obb-&gt;pos, normal1);float z = Vector3::Dot(reference_body-&gt;obb-&gt;pos, normal2);neg_offset1 = -x + reference_body-&gt;obb-&gt;half_extent[0];pos_offset1 = x + reference_body-&gt;obb-&gt;half_extent[0];neg_offset2 = -z + reference_body-&gt;obb-&gt;half_extent[2];pos_offset2 = z + reference_body-&gt;obb-&gt;half_extent[2];this-&gt;DrawSidePlanes(normal1, normal2, reference_body-&gt;obb-&gt;pos, 0, 2, reference_body-&gt;obb-&gt;half_extent);}break;case 2: //Reference face is on the z axis so we create side planes for the other axes{normal1 = reference_body-&gt;obb-&gt;rot[0];normal2 = reference_body-&gt;obb-&gt;rot[1];float x = Vector3::Dot(reference_body-&gt;obb-&gt;pos, normal1);float y = Vector3::Dot(reference_body-&gt;obb-&gt;pos, normal2);neg_offset1 = -x + reference_body-&gt;obb-&gt;half_extent[0];pos_offset1 = x + reference_body-&gt;obb-&gt;half_extent[0];neg_offset2 = -y + reference_body-&gt;obb-&gt;half_extent[1];pos_offset2 = y + reference_body-&gt;obb-&gt;half_extent[1];this-&gt;DrawSidePlanes(normal1, normal2, reference_body-&gt;obb-&gt;pos, 0, 1, reference_body-&gt;obb-&gt;half_extent);}break;}}</code></pre></div><p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=11558">Pipirongu</a> — Wed Jan 20, 2016 9:13 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Dirk Gregorius]]></name></author>
		<updated>2016-01-20T18:05:32+00:00</updated>

		<published>2016-01-20T18:05:32+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=36924#p36924</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=36924#p36924"/>
		<title type="html"><![CDATA[Re: Collision response - solver, penetration recovery]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=36924#p36924"><![CDATA[
It is difficult to tell from your picture, but I *think* (if I interpret the image correctly) that the two left vertices are wrong as well and the normal clipping code would handle this. There is no additional filtering necessary. You should debug your clipping code. E.g. draw the clip planes (a simple quad per edge) with the normal at the center of the edge making sure it is oriented correctly. Draw the incident face vertices. Make sure that they are all in the right space (world space would be the easiest initially). Also make sure that the normals are unit length before constructing the clip planes.<br><br>Regarding my example code I posted on Gamedev the assumption is that the normals of the clip planes point outside (e.g. clip_plane.normal = cross(edge_direction, reference_plane.normal). <br><br>HTH,<br>-Dirk<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=14">Dirk Gregorius</a> — Wed Jan 20, 2016 6:05 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Pipirongu]]></name></author>
		<updated>2016-01-20T14:15:11+00:00</updated>

		<published>2016-01-20T14:15:11+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=36921#p36921</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=36921#p36921"/>
		<title type="html"><![CDATA[Re: Collision response - solver, penetration recovery]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=36921#p36921"><![CDATA[
<blockquote class="uncited"><div>Do you use Sutherland-Hodgman clipping?</div></blockquote>Yes, I followed your example here: <a href="http://www.gamedev.net/topic/667499-3d-sat-problem/#entry5224015" class="postlink">http://www.gamedev.net/topic/667499-3d- ... try5224015</a><p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=11558">Pipirongu</a> — Wed Jan 20, 2016 2:15 pm</p><hr />
]]></content>
	</entry>
	</feed>
