Search Unity

Dozen of questions about 3d physics

Discussion in 'Physics' started by Danua, Sep 15, 2017.

  1. Danua

    Danua

    Joined:
    Feb 20, 2015
    Posts:
    197
    1 Is Box collider just a mesh collider with box form on it, or box collider much faster and calculate by another formulas this crucial for us big sized project with a lot of static mesh colliders on props and dynamic convex mesh collider at the car.

    2 If Create a scene of 200 static cubes, for 100 of them we assign Mesh Collider without Convex, on the other 100 cubes - Box Collider. What will work faster? In our project on props (for example, at home) there are Mesh Collider, which need for calculate bulletholes effect from hits of bullets.


    3 If the static colliders are on different layers, but intersect in some places as far as it is critical? Or if they are in different layers and are excluded from the matrix of physics from each other, then they do not see each other and everything is fine?

    4 If you wake the kinematics of Rigid Body in runtime, all physics will be recalculated, which will hit hard on performance?

    5 Is there a recalculation of physics when the (SetActive) object is turned off with Rigidbody?

    6 When the collider does not fall into the area of the game chamber, does it not exist for the physical engine? If we have static colliders inside LOD0 then when LOD1 is turned on, do the colliders within LOD0 be cut from memory? And when we see LOD0 again, and, accordingly, the colliders inside it, will this not cause a malfunction and a recalculation of physics?

    7 Culling (Umbra3d built-in Unity3d) can cut off the physics calculations?

    8 If I am at point A, and at point B 600 meters away from me the fence containing Rigidbody breaks, Unity3d will still calculate it for me? Does Unity3d have a chanky system or something like that for physics?

    9 We have a cars that consists a lot of parts that shootingback, and off when the explosion, on each piece there is a mesh collider with a convex and Trigger option on, without rigidbody.

    On the root object of the car assign RigidBody, the driving script and the health script so on.

    The question is whether the colliders are children inside the hierarchy of the parent object with RigidBody Will the child collider be a dynamic colliders or they are static, and how do we know how to move static colliders is very dangerous for performance?
     
  2. Plystire

    Plystire

    Joined:
    Oct 30, 2016
    Posts:
    142
    1) Primitive colliders have shortcut formulas that are used.

    2) I suggest actually trying this.

    3) Physics layers that are excluded in the matrix ignore each other when performing collision calculations.

    4) I've no idea of the details you have in mind for this. You might as well try it.

    5) When it's turned off? Doubt it. Unity loves to do things in batches.

    6) IIRC, LOD is purely visual, and does not effect physics. That said, if you're experiencing physics performance issues you should sleep as many rigidbodies as you can that are too far away to be of concern. Unity will do this automatically if the bodies are moving slow enough (practically stopped).

    7) Culling is also purely visual.

    8) Reference #6

    9) Only the rigidbody is effected by physics, and the colliders determine how that rigidbody should be effected. If your children colliders need to interact with the world separately from each other, then they should have their own rigidbodies.

    Honestly, you can set up test harnesses to test all of these questions. Just go set it up and find out. Surely that's faster than waiting for someone to respond on the forum with an answer that may or may not help.
    If you're testing performance, set up a whole scene that will demonstrate the problem you're envisioning. Try it with tons of objects, try it with a few objects, try it with difference circumstances.

    Test harnessing is a huge part of development. ;)
     
  3. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,512
    It's much faster and uses different formulas. The same happens with the other basic colliders: box, sphere, capsule.

    Box Collider

    Your guess is correct. Colliders excluded from collision via collision matrix "do not see" each other. It doesn't mater whether they intersect or not.

    No. The rigidbody will just be included in the physics calculations in the next physics step.

    Same answer as the previous question. Disabling a rigidbody will just ignore it when performing the next physic calculation. The "SetActive" call won't trigger any physic calculation itself.

    All active colliders in the scene are considered by the physics engine, regardless the position of the player, the camera, etc. The physics engine uses AABB intersections for optimizing the collisions. Thus, it's typically a good idea to split large colliders into smaller parts. If LOD disables some collider, then it won't be considered for the calculations in the next physics step.

    I had heard something in this direction some time ago, but as far as I know the culling information is not used by the physics.

    All Rigidbodies in the scene are calculated unless those that are sleeping. Rigidbodies enter the Sleep state when their velocity is slower than a threshold. Sleeping bodies are not calculated until they are waken up because of a collision or a force.

    More information on rigidbody sleeping here:
    https://docs.unity3d.com/Manual/RigidbodiesOverview.html

    The Rigidbody component simply modifies the position and rotation of its Transform based on the physics simulation. All children colliders belong to it. They are dynamic collilders as they belong to a Rigidbody.

    If there's a child Rigidbody then it will modify its own transform and will behave independently to its parent Rigidbody. All further children colliders behave to this Rigidbody, not to the parent.

    Modifying the dynamic colliders of a Rigidbody may have a significant performance impact because some parameters may have to be recalculated (ej. Center of Mass, Inertia Tensor). This is more important in vehicles, where modifying the rigidbody parameters cause expensive recalculations.

    A collider is a "static collider" when it doesn't have a Rigidbody component in its GameObject nor any of its ancestors. Moving a static collider has not a significant performance penalty (it was very expensive prior to Unity 5).
     
    chelnok likes this.
  4. Danua

    Danua

    Joined:
    Feb 20, 2015
    Posts:
    197
    Describe another problem here.
    We invent bullethole system for our project. here is it
    We have our mesh with, Phys_collider which is mesh collider without convex tick on layer physics collider that exclude from bullethole collider layer
    We have sepperate meshcollider also without convex tick for every materialtype. When raycast shoot in this props, he get name of the mesh, and call pooling in point of target bullethole effect, and we get nice bullethole right on mesh without error and gap between them.
    So now the question if we will be use a lot of box collider for represent and approximate our geometry for example i think it takes bettween 100-400 box collider on props is it will be faster than use just single mesh collider? But howmuch ass pain butthurt i'll get within create this damn box colliders isn't really calculate, i've became mad when I need create for our cars just 40 box colliders.

     
  5. Danua

    Danua

    Joined:
    Feb 20, 2015
    Posts:
    197