Search Unity

Question BoundingVolumeHierarchy switched to internal in 1.0

Discussion in 'Physics for ECS' started by mcapdegelle, Nov 20, 2022.

  1. mcapdegelle

    mcapdegelle

    Joined:
    Nov 7, 2014
    Posts:
    30
    Hello,

    I see BoundingVolumeHierarchy switched from public to internal class in the 1.0 version. Why change that? It may be useful for custom collision handling.

    As a matter of fact, I was using it for a bullet collision system :
    • Bullet to Physics collision detection is handled by ray/sphere casts
    • Bullet to Bullet is handled by a custom algorithm to get precise impact position & time (within the frame)
    I used the BoundingVolumeHierarchy to feed potentially intersecting bullet pairs to this Bullet/Bullet algorithm.
     
  2. kdchabuk

    kdchabuk

    Joined:
    Feb 7, 2019
    Posts:
    52
  3. mcapdegelle

    mcapdegelle

    Joined:
    Nov 7, 2014
    Posts:
    30
  4. Spy-Master

    Spy-Master

    Joined:
    Aug 4, 2022
    Posts:
    638
    Their suggestion means to create an asmref targeting the physics asmdef. You can then add a file with InternalsVisibleToAttribute for the assemblies you need to use that type from. This is pretty common practice when dealing with unexpected API surface changes. (The user seems to be suggesting putting code interfacing with that type in the original assembly, which is another way you can go about it).
     
    kdchabuk likes this.
  5. kdchabuk

    kdchabuk

    Joined:
    Feb 7, 2019
    Posts:
    52
    asmref (notice it's ref, not def) lets you add to an existing assembly, so internal is accessible. I have done this with Unity.Collections and it works.
    I have not used that attribute, but it looks ideal to handle this situation.
     
  6. mcapdegelle

    mcapdegelle

    Joined:
    Nov 7, 2014
    Posts:
    30
    Awesome thanks :)