Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I first thought the problem could come from the change of slope between two adjacent segments, but since on a flat surface of polygons you still have bumps I think the problem is rather hitting the corner of a polygon.</p> <p>I don't know if you can set two sets of polygons, overlapping each other ? Just use the same interpolation calculations and generate a second set of polygons just like in the diagram hereafter : you have the red set of polygons built and add the green set by setting the left vertices of a green polygon in the middle of a red polygon, and its right vertices in the middle of the next red polygon.</p> <p>![diagram][1]</p> <p>This should work on concave curves and... well you should be flying over the convex ones anyway.</p> <p>If this doesn't work try setting a big number of polygons to build the slope. Use a tenth of the circle's radius for the polygon's width, maybe even less. That should reduce your slope discontinuities.</p> <h2>-- Edit</h2> <p>In Box2D.js line 5082 (in <a href="http://code.google.com/searchframe#fbVL2fD7rV0/trunk/Box2D.js" rel="nofollow">this repo</a> at least) you have the PreSolve(contact, manifold) function that you can override to check if the manifolds (directions in which the snowball are impulsed when colliding the polygons) are correct.</p> <p>To do so, you would need to recover the manifold vector and compare it to the normal of the curve. It should look like that (maybe not exactly) : </p> <pre><code>Box2D.Dynamics.b2ContactListener.prototype.PreSolve = function (contact, oldManifold) { // contact instanceof Box2D.Dynamics.Contacts.b2Contact == true var localManifold, worldManifold, xA, xB, man_vect, curve_vect, normal_vect, angle; localManifold = contact.GetManifold(); if(localManifold.m_pointCount == 0) return; // or raise an exception worldManifold = new Box2D.Collision.b2WorldManifold(); contact.GetWorldManifold( worldManifold ); // deduce the impulse direction from the manifold points man_vect = worldManifold.m_normal.Copy(); // we need two points close to &amp; surrounding the collision to compute the normal vector // not sure this is the right order of magnitude xA = worldManifold.m_points[0].x - 0.1; xB = worldManifold.m_points[0].x + 0.1; man_vect.Normalize(); // now we have the abscissas let's get the ordinate of these points on the curve // the subtraction of these two points will give us a vector parallel to the curve var SmoothConfig; SmoothConfig = { params: { method: 'cubic', clip: 'mirror', cubicTension: 0, deepValidation: false }, options: { averageLineLength: .5 } } // get the points, smooth and smooth config stuff here smooth = Smooth(global_points,SmoothConfig); curve_vect = new Box2D.Common.Math.b2Vec2(xB, smooth(xB)[1]); curve_vect.Subtract(new Box2D.Common.Math.b2Vec2(xA, smooth(xA)[1])); // now turn it to have a normal vector, turned upwards normal_vect = new Box2D.Common.Math.b2Vec2(-curve_vect.y, curve_vect.x); if(normal_vect.y &gt; 0) normal_vect.NegativeSelf(); normal_vect.Normalize(); worldManifold.m_normal = normal_vect.Copy(); // and finally compute the angle between the two vectors angle = Box2D.Common.Math.b2Math.Dot(man_vect, normal_vect); $('#angle').text("" + Math.round(Math.acos(angle)*36000/Math.PI)/100 + "°"); // here try to raise an exception if the angle is too big (maybe after a few ms) // with different thresholds on the angle value to see if the bumps correspond // to a manifold that's not normal enough to your curve }; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload