We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.

Physics collision margin

Home Forums General Questions Physics collision margin

Viewing 15 posts - 1 through 15 (of 16 total)
  • Author
    Posts
  • #59607
    Thomas Fabini
    Customer

    Hi, I was wondering if you could help me out with this one:

    While detecting physics collisions I noticed that the space where the collisions are triggered is noticeable larger then the assigned collision mesh itself. This is really cumbersome with smaller objects where you need to get the collision with a specific object but multiple collisions are triggered.

    If I scale the whole scene up, the collision space around the mesh seems smaller (in relation to the upscaled mesh). But it seems I need to maintain the real world scale (1 Blender Unit – 1m) for VR.

    I tried to modify the value for “ccd swept sphere radius” in the physics “apply”-puzzle, with no visible difference.

    Is there maybe a setting you know of (puzzle or JS) which controls the margin which ammo.js takes in account around meshes (or standard collision objects box / sphere)?

    I would really-really appreciate any help or thought to point me in the right direction.

    Thank you,
    Thomas

    #59696

    Hi Thomas,

    There were indeed an issue in older versions of Verge3D (prior to 4.2) with physics collision radius. It should work in 4.2 though.

    Chief 3D Verger | LinkedIn | Twitter

    #60229
    Thomas Fabini
    Customer

    Hi Yuri,

    thank you very much for looking into this.

    I’m not entirely sure but I assume I was using already Verge3D to 4.2.0 at the time of posting, it seems I updated back in december.

    I noticed only after my initial post and further tests that only collision meshes are affected. The collision primitives like box, sphere, cylinder etc. seem to work as expected.

    With collision meshes it seems the margin is a constant value which doesn’t change with the scene size. It gets more visible when objects are smaller.

    I’ve attached a quick test, physics objects with collision meshes are the red ones.

    Thank you,
    Thomas

    Attachments:
    You must be logged in to view attached files.
    #60236
    kdv
    Participant

    In 4.0.1 mesh-mesh worked properly…

    P.S. As it appeared, in 4.0.1 the gap between meshes also exists )))

    With collision meshes it seems the margin is a constant value which doesn’t change with the scene size

    this margin for a dynamic body with a mesh collision shape is 0.03(9)m

    Puzzles and JS coding. Fast and expensive.

    If you don’t see the meaning in something it primarily means that you just don’t see it but not the absence of the meaning at all.

    #60269
    kdv
    Participant

    Zero gap between rigid bodies with any collision shape B-)
    https://v3d.net/f2r

    Puzzles and JS coding. Fast and expensive.

    If you don’t see the meaning in something it primarily means that you just don’t see it but not the absence of the meaning at all.

    #60377
    Thomas Fabini
    Customer

    Hi kdv,

    thanks for pointing out the details and the measurements ;-) – I actually forgot to test all interactions between collision primitives and against collision meshes.

    Do you like to fill us in on how you achieved the zero gap collision in your example? Maybe you could attach a working example?

    #60378
    kdv
    Participant

    how you achieved the zero gap collision in your example?

    patched puzzles.min.js. it’s a proprietary code.

    Puzzles and JS coding. Fast and expensive.

    If you don’t see the meaning in something it primarily means that you just don’t see it but not the absence of the meaning at all.

    #60382
    Thomas Fabini
    Customer

    Hi kdv,

    since you patched puzzles.min.js I assume you modified ammo.js rigid body initialization parameters in the methods which are used for the js output of the puzzles.

    Since I’m less of a developer – is geometry.setMargin(0) a possible solution to the problem (which could make it to a new version of Verge3D) or rather a quick fix?

    #60384
    kdv
    Participant

    is geometry.setMargin(0) a possible solution

    yes, it’s one of two variants. the margin can be set for a body’s geometry before creating (except sphere shapes) or it can be set for a body’s collision shape afterwards (for mesh shapes).

    Puzzles and JS coding. Fast and expensive.

    If you don’t see the meaning in something it primarily means that you just don’t see it but not the absence of the meaning at all.

    #60385
    Thomas Fabini
    Customer

    Nice find, thanks for having a look at this.
    Hope the devs might take a closer look, too.

    I’ve ran into these issues mainly with detecting collisions (“detect collision of”) to trigger further actions. They where triggering before the collision bodies where touching. So it was less about the visible margin around physics bodies which I observed only after.

    I’ll run some tests, I strongly assume the detection in between mesh collision objects will be more precise which the modified margin.

    #60386
    kdv
    Participant

    As for me, I’ve chosen the second variant.

    It doesn’t work with box and sphere shapes (and maybe with all other primitives) but those shapes already have zero margin )))

    Puzzles and JS coding. Fast and expensive.

    If you don’t see the meaning in something it primarily means that you just don’t see it but not the absence of the meaning at all.

    #60394
    Thomas Fabini
    Customer

    Yes, nice. Exactly that specific setting I went almost crazy looking for… ;-)
    If i had known it would magically appear today I might have burned less brain cells in the process…

    #60985
    Thomas Fabini
    Customer

    Hi kdv,
    when I tested your second variant, setting the zero margin for both, meshes and primitives seemed to affect collisions primitives in a negative way – meaning that physics objects with those collision primitives would sometimes fall through the floor while collision meshes where ok. Did you encounter this behavior, too?

    It’s why I went with your first variant, the patched zero margin setting for mesh collision bodies before they are generated.

    #60986
    kdv
    Participant

    I do not change margins for all shapes before creating dynamic rigid bodies. For primitives and static bodies it’s already zero, for meshes margins can be set to zero afterwards via settings. It’s actual for dynamic meshes only.

    Did you encounter this behavior, too?

    Only if the downward impulse was strong enough )))

    Puzzles and JS coding. Fast and expensive.

    If you don’t see the meaning in something it primarily means that you just don’t see it but not the absence of the meaning at all.

    #60997
    Thomas Fabini
    Customer

    I assume then I only found the part in the code where it affects all collision bodies together, not just the meshes…

    I guess it would be great if the devs could patch the output for the physics puzzles for collision meshes to have zero margins in a future version. Since primitives (and static bodies, as you stated) already are set up that way.

    Including a puzzle for margin settings would be another option, although I didn’t come across a specific scenario where I would want a non-zero margin. At least not yet.

Viewing 15 posts - 1 through 15 (of 16 total)
  • You must be logged in to reply to this topic.