Search Unity

Suggestion of utilities to add to DOTS physics eventually

Discussion in 'Physics for ECS' started by PhilSA, May 10, 2020.

  1. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
    I've been building a little collection of utilities that I often need in everyday game programming tasks and that I couldn't find in the existing DOTS packages. I'm presenting that list - and more - here as suggestions of static utilities (should all be usable from jobs) that I think would help people work more quickly in DOTS Physics, and that could maybe be added to the packages eventually. I see people complaining about the lack of some of these quite often in the forums/discord/etc so I'm sure these additions would be welcome and would help with the adoption of DOTS in general

    I know some of these are already planned, but I'll list them anyway just to "add my vote":
    • IsBodyDynamic(in PhysicsWorld physicsWorld, int rigidbodyIndex)
    • IsBodyKinematic(...)
    • IsBodyStatic(...)
    • IsTrigger(...)
    • GetAngularVelocityForMoveRotation(quaternion from, quaternion to, float dt)
    • GetFaceNormal(RigidBody hitBody, ColliderKey colliderKey) // returns the normal of the triangle. Useful to know if this is a backface hit
    • Find ways to make it as easy & intuitive as possible to:
      • Get physics material
      • Create & assign a new physics material to a collider (especially for changing collision filters)
      • Create & assign a unique copy of a collider (at runtime, by code. When you don't necessarily need ALL colliders to be unique, but have a few variants for example)
      • Resize primitive colliders
      • get mesh UV at hit position (although maybe that's not physics's responsibility? But maybe some thought should be give into how this would work, if not done already)
    • Easy Collision/Trigger event systems that tell you if it's an Enter/Exit/Stay event, and don't require you to create an IEventJob (example)
    • Missing math utils in Unity.Mathematics that are very often needed
      • float3.up, float3.forward, float3.right
      • ProjectOnPlane(...)
      • Project(...)
      • slerp(float3 a, float3 b, float t) // right now, only quaternions have slerp
      • FromToRotation(quaternion from, quaternion to)
      • AngleRadians(float3 from, float3 to)
      • SignedAngleRadians(float3 from, float3 to, float3 axis)
      • AngleRadiansBetween(quaternion from, quaternion to)
      • ClampVectorMagnitude()
      • GetClosestPointOnLine(...)
      • GetClosestPointOnSegment(...)
    • Quick raycast closest hit functions that initialize their own collector, with option to hit triggers or not, and hit backfaces or not
      • RaycastClosest(...)
      • BoxCastClosest(...)
      • SphereCastClosest(...)
      • CapsuleCastClosest(...)
      • ColliderCastClosest(...) // ignores self
    • Quick calcDistance closest hit functions that initialize their own collector, with option to hit triggers or not, and hit backfaces or not
      • PointDistanceClosest(...)
      • BoxDistanceClosest(...)
      • SphereDistanceClosest(...)
      • CapsuleDistanceClosest(...)
      • ColliderDistanceClosest(...) // ignores self
    • Quick raycast all hits functions that initialize their own collector, with option to hit triggers or not, and hit backfaces or not
      • RaycastAll(ref NativeList hits, ...)
      • BoxCastAll(ref NativeList hits, ...)
      • SphereCastAll(ref NativeList hits, ...)
      • CapsuleCastAll(ref NativeList hits, ...)
      • ColliderCastAll(ref NativeList hits, ...) // ignores self
    • Quick calcDistance all hits functions that initialize their own collector, with option to hit triggers or not, and hit backfaces or not
      • PointDistanceAll(ref NativeList hits, ...)
      • BoxDistanceAll(ref NativeList hits, ...)
      • SphereDistanceAll(ref NativeList hits, ...)
      • CapsuleDistanceAll(ref NativeList hits, ...)
      • ColliderDistanceAll(ref NativeList hits, ...) // ignores self

    Also feel free to add more suggestions in thread
     
    Last edited: May 11, 2020
  2. Dale_Kim

    Dale_Kim

    Unity Technologies

    Joined:
    May 8, 2019
    Posts:
    56
    • float3.up, float3.forward, float3.right
    • ProjectOnPlane(...)
    • Project(...)
    These three are already implemented in the master branch of Unity.Mathematics, but is unreleased at the moment. The rest of your list for Mathematics are strong candidates for being implemented at a future time (many people have asked for them) but we haven't yet prioritized all those requests. Keep an eye out for updates!
     
  3. Extrys

    Extrys

    Joined:
    Oct 25, 2017
    Posts:
    345
    im slowly creating these extensions to make DOTS Physics and maths easier
    https://github.com/Extrys/EZ-DOTS-Extensions it still WIP maybe i can add some of your requested functions