jit.phys.body, cylinder shape, problem with scaling and AABB box

    Mar 12 2013 | 9:43 pm
    There seems to be a problem scaling the jit.phys.body when the shape is a cylinder. The first scalar seems to set the radius and the second the length rather than an x, y, z arrangement. This kind of works, but enforces circular cylinders and really causes problems with the AABB for collisions.
    Also, when making this test patch I had trouble using attributes in the 6dof object. I guess you need to start/initialize the rendering before sending the parameters? You can test for this by doing step "2. bang" before step "1. start."
    I tested this patch in both 6.0.8 and 6.1 in OS X 10.7.5
    Thanks much,

    • Mar 13 2013 | 1:24 pm
      … after some sleep and another look I think I could add a couple more details to my post.
      I can see now that the phys.body shapes are scaled by a different number of scalars according to geometry, for example the sphere by just the radius but the cube by three dimensions. However the cylinder scaling still has a problem with the AABB when the cylinder is shorter than the radius (i.e. disk shaped) such that the box doesn't bound the cylinder and many collisions are missed.
      If you give the above patch a test please give a moment for the disk to swing down into position.
    • Mar 13 2013 | 4:40 pm
      hi simon. thanks for the patch as you've discovered, scaling of simple physics shapes is not exactly analogous to scaling opengl shapes. each shape has different rules for scaling, and cylinder shapes use the x and y scale parameter to scale radius and length.
      however, there are obviously some issues with this, as demonstrated by the AABB inconsistencies. i believe i've seen this before, and it points to some issues with the cylinder shape implementation in the physics engine. i would recommend you use a convex hull for this, instead of a cylinder. the patch snippet below, taken from the phys.body help file matrix tab, shows how you can do this.
      the problems with initializing attributes before rendering starts, again, i think point to a bug in the physics engine, related to rotation singularities.
      however, you can alleviate those issues. it's generally best practice to position and rotate your physics bodies using their transform attributes, prior to adding them to a physics constraint, so that when they are added to the constraint they are already in the proper position and rotation.
      eg, for the cylinder shape in your patch, add the following transform attributes to your phys.body max box. @position 0 10 0 @rotatexyz 0 -90 0
      you should see that the physics body is not no longer forced to "jump" to the position/rotation dictated by the constraint.
      hope this helps.
    • Mar 13 2013 | 6:42 pm
      Thanks for the reply. I appreciate the confirmation of what I learned and the suggestions. I have given them a try and… great!
      One more question if I may. Is the wobble of the small sphere around the pivot point an expected result with a 6dof constraint that can be mediated with the strength attribute or eliminated with another constraint such as the hinge?
      Simon (it does help)
    • May 07 2013 | 11:27 am
      Is it expected that with jit.gl.physdraw the contact drawing is not affected by the @rgb attribute or the @color attribute? It can be modified by the @contactsize attribute.