Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

skinThickness depending on AABB size #18

Closed
Omegapol opened this issue Jul 26, 2020 · 1 comment
Closed

skinThickness depending on AABB size #18

Omegapol opened this issue Jul 26, 2020 · 1 comment

Comments

@Omegapol
Copy link

Any reason in particular why skinThickness depends on actual AABB size?

I'm asking about this code:

        // Fatten the AABB.
        for (unsigned int i=0;i<dimension;i++)
        {
            nodes[node].aabb.lowerBound[i] -= skinThickness * size[i];
            nodes[node].aabb.upperBound[i] += skinThickness * size[i];
        }

For instance, when we have skinThickness of 1 and we insert AABB of size 100x10, insertParticle will result in inserting AABB with size of 300x30.

@lohedges
Copy link
Owner

Hi there. As mentioned in the source documentation...

 \param skinThickness_
    The skin thickness for fattened AABBs, as a fraction
    of the AABB base length.

...the skinThickness is a fraction of the AABB base length. For fixed skin thickness, this means that the size of the "fattened" region is always the same relative to that of the AABB. This also allows you to set meaningful default (here 5% is used) since you need to assume nothing about the scale of the AABBs used in the simulation, e.g. a size of 5 in some units might be useless is your AABBs were typically 100000 units wide. Your AABBs are massive since you are fattening them by 100% in each dimension! If you want to set a skin thickness as some size in the units of your simulation, then you simply need to work out the appropriate fraction, e.g. if you have AABBs with a base length of 100 in each dimension and want a thickness of 10, then set the skin thickness to 0.1.

Note that the skin thickness is only needed for dynamic simulations, where it is used to avoid frequent updates to the AABB tree. (See the section from the README copied below.) If you're performing a static calculation, i.e. just a one off overlap detection, then you can safely set it to zero.

You may be wondering why the AABBs shown in the previous animation are not the minimum enclosing bounding box for each disc. This is a trick that is used to avoid frequent updates of the AABB tree during dynamics (movement of the discs). Whenever an AABB changes position we need to delete it from the tree then reinsert the new one (at the updated position). This can be a costly operation. By "fattening" the AABBs a small amount it is possible to make many displacements of the objects before an update is triggered, i.e. when one of the discs moves outside of its fattened AABB.

Hope this helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants