Jump to content
  • Advertisement

uza

Member
  • Content Count

    15
  • Joined

  • Last visited

Community Reputation

138 Neutral

About uza

  • Rank
    Member
  1. uza

    Box stacking

    Dirk,   I'm actually using both of the ways that you described. First I calculate the tangent from relative velocity and dot product it with itself, if it is smaller than epsilon, I switch to orthonormalBasis function. I just tried completely ignoring the relative velocity and build an orthonormal basis with the contact normal each time, and the stack is stable. I clamp each tangent individually but I will have a look at spherical clamping.   Uza
  2. uza

    Box stacking

    Alright, just figured out the problem. I was calculating the new tangents for every contact in pre-step function, including warm-started contacts and others.   I changed it like this;   * If a contact is warm started, use the tangents in the contact data. Do not calculate new tangents.   I can now stack 10 boxes with 10 iterations without any problems. There is a slight problem though, when I knock down the stack, some boxes bounce kinda unrealistic. It doesn't always happen but when it happens the box bounces exaggeratedly in place. By the way, I don't use any coefficient of restitution. I will try to upload a video if I cannot solve it.   Thank you for all the help.   Uza
  3. uza

    Box stacking

    Thanks Irlan, I will have a look at those engines.
  4. uza

    Box stacking

      I start them at rest, when I drop them on top of each other, they slightly bounce and get out of the alignment but not completely fall down.
  5. uza

    Box stacking

    Current limit of the engine is 4 boxes with 10 iteration, the solver converges at some point and they don't move at all, beyond that is shaky. The bias factor is 0.1, allowed penetration 0.01 and iteration count is 10. I'm not projecting the last friction impulse onto the new friction directions, but pre-applying them along with the normal impulse. I don't track contact features as in box2d, instead I'm using a simple proximity check to generate contact manifolds.
  6. uza

    Box stacking

    I see, then there are still holes in my code. I will try to figure them out.   Thanks
  7. uza

    Box stacking

      I mean without additional tricks and fixes, what is the expected behaviour? Just with warm starting.
  8. uza

    Box stacking

    Hey guys,   I fixed the problem, I was using temporary objects at multiple places to save from memory and looks like that caused hard to track bugs, so I replaced them with fresh objects. It is stable now with warm starting.   I can stack 10 boxes up to 30 minutes with 10 iterations now. After 30 minutes the stack falls down due to instability. Is this an expected behaviour? Should it stay stable infinitely?
  9. uza

    Box stacking

    I just tried stacking spheres and it was extremely stable. No problem there, so is this an indication that the source of the problem is in the contact manifold generation for boxes?
  10. uza

    Box stacking

    I think I'm doing it wrong. Do I need to copy tangents along with impulses when caching contact data?
  11. uza

    Box stacking

    Irlan, the inertia tensor for the ground is a zero matrix. Warm starting seems to be correct but I just saw this post of Dirk http://www.gamedev.net/topic/613945-sequential-impulse-bias-velocities/#entry4878940 where he mentions projecting the last friction impulse onto the new friction directions. I don't do this. This might be the source of the problem?
  12. uza

    Box stacking

    Hi guys,   I'm trying to get stable box stacking with my physics engine. I use an accumulated impulse model but I dont pre-apply last accumulated impulse at the beginning of each timestep, basically I don't have a preStep function as in box2d lite. Actually, I tried to implement it but it made the simulation totally unstable. I create persistent contact manifolds by checking contact proximity at each step, I use something like; if (contact.position.distanceToSquared(contacts[i].position) <= 0.004) {       // Use previous contact impulses } My allowed penetration is 0.01 and bias is 0.1, iteration 10.   At each iteration I calculate impulses like this; // Normal Impulse deltaNormalImpulse = c.massNormal * (-vn + c.bias) oldImpulse = c.normalImpulse; c.normalImpulse = Math.max(oldImpulse + deltaNormalImpulse, 0.0); deltaNormalImpulse = c.normalImpulse - oldImpulse; // I use the same approach for calculating the tangent and binormal impulses deltaTangentImpulse = c.massTangent * (-vt); maxTangentImpulse = 0.6 * c.normalImpulse; oldTangentImpulse = c.tangentImpulse; c.tangentImpulse = clamp(oldTangentImpulse + deltaTangentImpulse, -maxTangentImpulse, +maxTangentImpulse); deltaTangentImpulse = c.tangentImpulse - oldTangentImpulse; deltaBinormalImpulse = c.massBinormal * (-vb); maxBinormalImpulse = 0.6 * c.normalImpulse; oldBinormalImpulse = c.binormalImpulse; c.binormalImpulse = clamp(oldBinormalImpulse + deltaBinormalImpulse, -maxBinormalImpulse, +maxBinormalImpulse); deltaBinormalImpulse = c.binormalImpulse - oldBinormalImpulse;  and here is the result;   https://vimeo.com/135466972 (Watch on vimeo for HD version)     Box stacking is not stable, they fall down in the long run. By the way, sleeping is not enabled in this demo, but I think it should be stable without sleeping, isn't it?   Waiting for your tips.   Thanks, Uza
  13. I went ahead and simplified the calculations to R(inverseInertia)R-1 to get the inverse of world inertia tensor. Since RT and R-1 equivalent, now I'm using R(inverseInertia)RT (Right to left) which makes sense.
  14. Hi guys,   After long hours of debugging and sleepless nights, I finally found the issue. I checked the contact data, penetration depths, normals and everything else was correct. The problem was in the calculation of inverse inertia tensor world.   Previously I was calculating inverse inertia tensor world like this;   * Create a rotation matrix from the rotation quaternion of the rigid body. * Multiply this matrix with the inertia tensor and then invert.   After checking some other people's code I changed it like this;   * Get the inverse of the transform matrix. (M1) * Copy its transpose into some other temp matrix. (M2) * Multiply the result with the inertia tensor. (M2(inertiaTensor)) * Inverse inertia tensor world =  (M1(M2(inertiaTensor))))^-1   Thanks for all the replies, I knew there was a problem in the inertia tensor calculation.   Uza
  15. Hi,   I'm trying to put together a small physics engine by following some tutorials that I've found on the net. It is using the impulse-based method.   The result is good for spheres but boxes keep bouncing infinitely. I've no idea why this might be happening. Looks like when computing the angular velocity for boxes some energy is being added to the system. I've not yet added the frictional impulse but I'm manually adding some damping to the linear and angular velocities when integrating. Here is a screen recording showing the problem;    https://vimeo.com/134880633   I'm generating one-shot multiple contacts by using Sutherland-Hodgman clipping along with SAT.   Does anyone know why this might be happening? Is this a known problem in the impulse-based method?   Thanks
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!