Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Physics Debugger Improvements

Discussion in 'Physics Previews' started by Augustinas-Simkus, Aug 17, 2021.

  1. Augustinas-Simkus

    Augustinas-Simkus

    Unity Technologies

    Joined:
    Mar 9, 2020
    Posts:
    84
    Hello,

    We've been reworking some of the UI/UX aspects of the built-in physics debugger lately, and I'd love to share some early progress with you on this thread. Here is a link to an experimental build that I've prepared: https://beta.unity3d.com/download/cd910d1ebf55/public_download.html

    Here is a short description of what has been addressed so far:
    • Split the Physics Debug window into Filtering, Rendering, Info, and Contacts tabs for easier access and space management

    • Moved the Rigidbody and Articulation Body info sections to the Info tab (and added some more info for debugging)

    • Added the option to visualize the center of mass or the inertia tensor of Rigidbodies or Articulation Bodies that are being tracked in the Info tab

    • Added Contact visualization that can be filtered by using settings in the Filtering tab



    Known limitations:
    • Changing filtering settings while stepping frame by frame during Play Mode will not take effect until the next simulation step

    • Turning on the Show All Contacts option during play mode will not show contacts of Colliders that have already been initialized.

    Things that are being considered:
    • In addition to being able to filter by Physics Scene, add an option to filter by Unity Scene.

    • Expose Rigidbody and Articulation Body velocity and acceleration accumulators. This could be employed to get an estimate of the total external force applied this frame

    Let me know what you think, can’t wait to hear any feedback.

    Augustinas
     
  2. Sab_Rango

    Sab_Rango

    Joined:
    Aug 30, 2019
    Posts:
    121
    Hello!
    Nice Job!
    But Inertia Tensor and Mass Gizmos becomes almost invisible when they are located inside a collider

    here transparency at the 0.5f
    inertiadebug.png



    here transparency close to zero: now they are almost invisible

    transparencyZero.png







    Moreover, Childs of articulation bodies Mass and inertia tensor Gizmos is not available
    childmass.png
     
    Last edited: Aug 18, 2021
    yant likes this.
  3. Augustinas-Simkus

    Augustinas-Simkus

    Unity Technologies

    Joined:
    Mar 9, 2020
    Posts:
    84
    Hmm, the transparency could definitely be bumped up here.


    Just checked this, and it seems to be working for me. Is the "Inertia Tensor" enum selected for the child?

    Thanks for the feedback!
     
  4. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    One of the things I saw requested way back when for this before you worked on it, was for visualisation of capsule and raycasts. In particular what gets people a bit confused are capsule casts, because the shape can be bigger than people expect.

    People think it's a bug when really they fail to visualise it properly and understand that beginning the cast inside an object will reject it. This will affect capsule cast the most (and swept shapes).

    Great job so far!
     
    yant likes this.
  5. Sab_Rango

    Sab_Rango

    Joined:
    Aug 30, 2019
    Posts:
    121

    Yep, all child Articularbodies are selected with the enum state, but no child ArtBody has a center of mass Gizmos.
     
  6. Augustinas-Simkus

    Augustinas-Simkus

    Unity Technologies

    Joined:
    Mar 9, 2020
    Posts:
    84
    Good idea and I don't think it would be difficult to implement. Thanks for the feedback!


    Weird, I'm still unable to reproduce the issue after following your screenshot as closely as possible. If this is an issue that you can consistently reproduce, could you provide the repro steps? I'm really curious why this is not working for you.
     
  7. yant

    yant

    Unity Technologies

    Joined:
    Jul 24, 2013
    Posts:
    596
    Thanks for your continued interest in physics!!! <3
     
    NotaNaN and hippocoder like this.
  8. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    <3

    Another bit of feedback: I would put the "Info" tab at the start or the end because it's the only tab with passive information and a miscellaneous meaning (it sits badly nested among tabs that can be interacted with which have strong meaning) and because it's likely the most commonly accessed tab now you've moved info from the RB component into another window, so you want to easily get to that Info.


    For a busy dev, that would be start or end - quickly and easily found / clicked with muscle memory.
     
    JuozasK, Edy, yant and 1 other person like this.
  9. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,508
    Great work!
    The contact impulses are per-contact, or the overall value calculated by Unity?

    Because currently only the overall value is exposed by Unity. A good and easy push in physics would be exposing the impulse per-contact, exactly as PhysX does (indeed, there's no such overall value in PhysX).
     
    yant and hippocoder like this.
  10. Augustinas-Simkus

    Augustinas-Simkus

    Unity Technologies

    Joined:
    Mar 9, 2020
    Posts:
    84
    Hi, this might be overdue but the per-contact impulses are now exposed and used in this build. This will also be included in the final product. Thanks for taking a look!
     
    Edy and Onigiri like this.
  11. yant

    yant

    Unity Technologies

    Joined:
    Jul 24, 2013
    Posts:
    596
    Just to refine on what Augustinas just said, per-point contact impulses is in a PR towards trunk now, expected to land sometime soon, and become available in a public alpha of 22.1. I can totally remember you asking about it since forever. :)
     
  12. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Unity Physx integration is fundamental to all the work we do, without it and these updates we'd have moved to Unreal because we really needed contact modification. Now there's also better visualisations as well! Please don't stop improving Unity's built in Physics.

    Can't wait for what's next. If it was me I'd definitely hire more to help out, seems like the team is small (and extremely hard working) for the amount of heavy lifting Physics does in Unity.
     
    JuozasK, yant, JoNax97 and 2 others like this.
  13. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,508
    Great to know that this is already on the way!
    You know you can pick another item from the list anytime :)
     
    yant and hippocoder like this.
  14. Augustinas-Simkus

    Augustinas-Simkus

    Unity Technologies

    Joined:
    Mar 9, 2020
    Posts:
    84
    Here's a new build with query visualization added:
    https://beta.unity3d.com/download/25827f979846/public_download.html.

    There is query visualization for check, overlap and cast query types, and the visualization can be filtered independently in the new "Query" tab. Here's a gif of the visualization in action:


    Also, the Info tab is now at the start of the row + some other minor fixes.
     
    NotaNaN, PaulMDev, Nirlah and 4 others like this.
  15. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Amazing progress :) I hope that the visualisations can be cleaned up later on (not important now obviously!)
     
  16. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,508
    hippocoder likes this.
  17. Augustinas-Simkus

    Augustinas-Simkus

    Unity Technologies

    Joined:
    Mar 9, 2020
    Posts:
    84
    At the moment, no. But definitely, a thing to look into. Thank you for your interest! <3
     
    yant and Edy like this.
  18. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    I guess the visualisation of a convex hull extruded along vector is going to need some shader fu to do properly (like stencils) !
     
  19. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,508
    That would be the best way, of course. But to me, simply drawing the wireframe of the collider(s) at the start and at the end with a raycast line connecting the center of masses would suffice.
     
    hippocoder likes this.
  20. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Indeed, and I feel the omission of swept shapes is an unfortunate one, even seeing it in the visualiser would encourage people to find out more about these useful functions.
     
    Edy likes this.
  21. yant

    yant

    Unity Technologies

    Joined:
    Jul 24, 2013
    Posts:
    596
    This is a quick note to let you know that the UI&UX rework that was described at the start of this thread has landed 2022.1.a10. The rest will come shortly afterwards.
     
    Edy and hippocoder like this.
  22. Augustinas-Simkus

    Augustinas-Simkus

    Unity Technologies

    Joined:
    Mar 9, 2020
    Posts:
    84
    Hey, a quick update: a second batch of this work has landed in 2022.1.0a14. It includes contact and query visualisation, support for multiple scene views, addressed the limitation:
    What's still in the queue:
    • Filtering by Unity Scene in addition to filtering by Physics Scene
    • Performance improvements to the contact and query visualisation
    • A getter for forces that have been accumulated by a Rigidbody or an Articulation Body
     
  23. goncalo09

    goncalo09

    Joined:
    Oct 26, 2017
    Posts:
    10
    Can you please also consider adding a way to enable the acceleration flag for joint drives?

    From the PhysX documentation: https://gameworksdocs.nvidia.com/PhysX/4.1/documentation/physxguide/Manual/Joints.html#drives
     
    Edy likes this.
  24. Augustinas-Simkus

    Augustinas-Simkus

    Unity Technologies

    Joined:
    Mar 9, 2020
    Posts:
    84
    Added a backlog entry for this.
     
    goncalo-vasconcelos and Edy like this.
  25. PaulMDev

    PaulMDev

    Joined:
    Feb 19, 2019
    Posts:
    72
    Wow this amazing !
    Visualising physics (especially raycast) can be really hard so thank you.

    So will this be available in 2022.1 ?
     
  26. Augustinas-Simkus

    Augustinas-Simkus

    Unity Technologies

    Joined:
    Mar 9, 2020
    Posts:
    84
    Yep, all of this is available from 2022.1 and newer.
     
    DragonCoder, PaulMDev and yant like this.
  27. Invertex

    Invertex

    Joined:
    Nov 7, 2013
    Posts:
    1,549
    This is a very welcome feature, it was a real pain to set up visualization of this before.
    Do you have any idea if and when this will be extended to the Physics2D casting methods?
     
  28. Augustinas-Simkus

    Augustinas-Simkus

    Unity Technologies

    Joined:
    Mar 9, 2020
    Posts:
    84
    I can only tag @MelvMay for this one.


    Done. Available from 2022.2.0a14 and up. Exposed the flag for Hinge and Configurable joints + equivalent flag for Articulation Body drives:
     
  29. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,455
    Not when but yes it will. For 2022.1 we landed a whole bunch of things that fully occupied the release. This certainly wasn't a priority. Ideally we'd like to see that in the follow-up release but no guarantees.
     
    Invertex likes this.
  30. THE2FUN

    THE2FUN

    Joined:
    Aug 25, 2015
    Posts:
    63
    If you don't see the debug visual even you clicked show all, there are 2 very dark and transparent boxes click on them.
    My eyes can't see them i have astigmatism i searched 2 days to find :D Anyway it's very useful thanks.


    upload_2022-10-23_10-31-44.png upload_2022-10-23_10-31-54.png
     
    JuozasK and goncalo09 like this.
  31. chen_fly

    chen_fly

    Joined:
    May 3, 2018
    Posts:
    3
    Hi, When close Physic Debug Tab, Then the effects in Scene will close too. Did have some selection for show Physic Debug Info even though close Physic Debug Tab?
     
  32. yant

    yant

    Unity Technologies

    Joined:
    Jul 24, 2013
    Posts:
    596
    You can make the debug physics window a tab indeed, and then it's fairly unobtrusive and will keep the Scene info present forever. Otherwise, once you close the window itself, the debug viz is gone I'm afraid.
     
    Augustinas-Simkus likes this.
  33. cherymagreen

    cherymagreen

    Joined:
    Dec 13, 2022
    Posts:
    2
    hello. how i can pin info panel back to rididbody component? like this:
     

    Attached Files:

    Last edited: Aug 14, 2023