Search Unity

Question RigidBody struct size & layout

Discussion in 'Physics for ECS' started by Selmar, Jan 25, 2023.

  1. Selmar

    Selmar

    Joined:
    Sep 13, 2011
    Posts:
    59
    Code (CSharp):
    1. /// <summary>   An instance of a collider in a physics world. </summary>
    2. /// Using StructLayout to handle for an issue where there can be a mismatch between struct sizes for RigidBody in separate jobs
    3. [System.Runtime.InteropServices.StructLayout(System.Runtime.InteropServices.LayoutKind.Explicit, Pack = 1, Size = 56)]
    4. public struct RigidBody : ICollidable, IAspectQueryable
    5. {
    6.     ...
    7. }
    I found this in RigidBody.cs. It scared me a little, while at the same time piquing my curiosity.

    What could cause this kind of struct size mismatch?
     
    Matt-Ostgard likes this.