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

PhysX 4.1 in Unity - experimental builds

Discussion in 'Physics Previews' started by yant, Feb 25, 2019.

  1. PierreTerdiman

    PierreTerdiman

    Joined:
    May 9, 2017
    Posts:
    15
    (PhysX dev here) We removed the trigger-trigger overlaps to make the code simpler and easier to maintain, not for performance reasons. As far as I know this change didn't make the code any faster (yet). However it does open the door to more refactoring which will hopefully make the "simulation controller" layer a lot easier to work with in the future. It is not for performance, the complexity of this layer is a constant source of subtle bugs and frustration. If you ask me, it's not just trigger-trigger interactions that must go: the whole concept of "trigger shape" should also vanish (I'm not saying we will do that anytime soon though).

    We did ask our users (including Unity) whether this specific change would be fine, years ago now. We first deprecate a feature for the lifetime of one PhysX version before actually removing it. In 3.4 the corresponding flag was explicitly called eDEPRECATED_TRIGGER_TRIGGER_REPORTS. With all due respect, it is a bit late to complain about it now....

    In any case I also posted a snippet in this thread showing how to emulate triggers with regular shapes, which not only gives back trigger-trigger interactions, but it also makes triggers work with CCD (which is otherwise a rather severe limitations of built-in triggers).

    So I think the clear solution to this problem is not to switch everything to overlap checks, but simply have Unity internally switch to the approach used in the new snippet (in their PhysX wrapper layer). It should be transparent for Unity users, as far as I can tell.
     
    Mnemotic and JoNax97 like this.
  2. segant

    segant

    Joined:
    May 3, 2017
    Posts:
    196
    There are lots of problem in android build. I can't release new update because of that. I have waited for skinned mesh batch in srp to be released and fixed. Now physics not working properly. This issue needs to be fixed.
    Code (JavaScript):
    1. [Physics.PhysX] BV4 midphase only supported on Intel platforms.
     
    Last edited: Sep 4, 2019
    entropicjoey1 likes this.
  3. pinkhair

    pinkhair

    Joined:
    Dec 17, 2010
    Posts:
    141
    Thank you for the details, they really are appreciated - and I don't think that anyone is against having the internals of how it works change so much as having nothing in place to replace it. Unity's docs have always been peppered with comments about avoiding the obvious alternatives to trigger-on-trigger collision, which is certainly not PhysX's fault.
     
  4. yant

    yant

    Unity Technologies

    Joined:
    Jul 24, 2013
    Posts:
    596
    Do you have a case reported for that? I believe I had this branch guarded, so that BVH was made available only on Desktop platforms, not on mobiles or consoles.
     
    entropicjoey1 and keeponshading like this.
  5. segant

    segant

    Joined:
    May 3, 2017
    Posts:
    196
    I found the problem. This is related to prebake collision meshes.
     
    entropicjoey1 likes this.
  6. yant

    yant

    Unity Technologies

    Joined:
    Jul 24, 2013
    Posts:
    596
    ...and I've just received a case regarding that.
     
  7. yant

    yant

    Unity Technologies

    Joined:
    Jul 24, 2013
    Posts:
    596
    Good ideas here.

    The way batched queries work is exactly how you guessed - there is a schedule call from C# that would split the currently configured batch into a set of jobs and schedule them with the job system. It happens within the native lands, so there's minimal overhead, no data is thrown back and forth over the fence.

    With uneasy feelings I have to confirm that only the single-result queries were made available in the batch mode, with others still in the plans for future. The main reason was basically NativeArray/NativeList complications. The current system was shipped out of a hackweek, and it relies on an input NativeArray that is as big as the commands buffer. This means one command will result in at most one hit. We tried to find a clear way to extend it so that commands returning arbitrary amount of results would be supported but various obstacles meant we couldn't really. I don't mean to say it's unsolvable problem, not at all, just hinting we had to make a decision whether to ship what was ready or ship nothing. There was lots of value in shipping what we had, as I learned, so there you go.
     
    Cynicat, brunocoimbra and Baste like this.
  8. corjn

    corjn

    Joined:
    Feb 6, 2014
    Posts:
    168
    Hey @yant,

    I'm testing unity 2019.3.0b3 with temporal Gauss Siedel, and in my project, some physics is broken with temporal but not with projected, so I think I have found a bug, or a regression :

    -Make a kinematic rigidbody, interpolated, move and rotate with script (rigidbody.moveposition and .moverotation, so it keeps the interpolation)
    -Connect a rigidbody chain (non kinematic and interpolated).

    With temporal solver it will break, no problem with the projected solver.


    I made a repro project you can download here

    Just open the "Debug_Kinematic_Joint" scene in scene folder. At runtime, try to move and rotate the mover, containing a script that will do what I explained above. Try to switch the solver to see the difference.


    Hope it will help you in the bêta debug process :)

    Have nice day,
    Jonathan
     
  9. yant

    yant

    Unity Technologies

    Joined:
    Jul 24, 2013
    Posts:
    596
    thanks Jonathan, I'll be forwarding this to QAs.
     
    corjn likes this.
  10. Kobix

    Kobix

    Joined:
    Jan 23, 2014
    Posts:
    146
    Second this, are PhysX 4 articulated joints available in Unity already? The information is hard to find about this.
     
  11. yant

    yant

    Unity Technologies

    Joined:
    Jul 24, 2013
    Posts:
    596
    No, they are not yet. We ran a series of experimental builds with the goal of finalising design and code for 19.3, but it didn't happen, so articulations were taken out. There will be another build shared once it's ready. Articulations are critical for a number of applications.
     
  12. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Have you reached a decision on when (if?) you will have trigger to trigger stuff working again in what beta version? I think I've read every reply since I posted but didn't notice a hard decision.
     
  13. yant

    yant

    Unity Technologies

    Joined:
    Jul 24, 2013
    Posts:
    596
    In the plan is to try Pierre's suggestions right next week. I want to figure a low footprint solution that enables trigger-trigger interaction. Currently the best I can is to make it so that every trigger collider would create two shapes under the hood automatically (or with a flag in the global properties - for those not willing to pay a higher price for trigger-trigger in the new physx)
     
  14. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Thanks!
     
  15. Kobix

    Kobix

    Joined:
    Jan 23, 2014
    Posts:
    146
    Thanks! Will focus on other things then, such as Jobs system, Burst and SIMD stuff. Came back to Unity after 1 year being idle, and there is lots of new stuff ;).
     
  16. entropicjoey1

    entropicjoey1

    Joined:
    Jun 1, 2014
    Posts:
    26
    Thanks you! have had this error on my android build for awhile and ive been scratching my head for a while ^^ i do have prebaked collision meshes in scene! thank you thank you, how did you figure that out in your case?
     
  17. Kobix

    Kobix

    Joined:
    Jan 23, 2014
    Posts:
    146
    Any idea when this may be ready? Thanks :)
     
  18. mvaandrager

    mvaandrager

    Joined:
    Apr 24, 2018
    Posts:
    3
    We're using Unity for Hardware in the Loop (HIL) testing automation for Offshore & factories. Think cranes, hydraulics, heavy machinery etc.

    We're really looking forward to reduced articulations and keeping a daily eye on this thread. A tentative release date is very welcome :)
     
  19. Prodigga

    Prodigga

    Joined:
    Apr 13, 2011
    Posts:
    1,123
    Clear communication, constant updates. Just wanted to say thank you very much @yant and Goodluck!
     
  20. nauticaldev

    nauticaldev

    Joined:
    Oct 2, 2019
    Posts:
    1
  21. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    2,361
    Functional link here.
     
  22. Kobix

    Kobix

    Joined:
    Jan 23, 2014
    Posts:
    146
    Tried the 2019.2.0b2 build, articulations act very very and very stable.

    I run simulation at 500 FPS, though!

    Two problems so far though:
    - Joints not moving to closest point (only one rotation path).
    - Once articulation sleeps, it's hard to wake it up. I hacked this with joint.AddForce(Vector3.zero).
     
    yant likes this.
  23. Kobix

    Kobix

    Joined:
    Jan 23, 2014
    Posts:
    146
    Nevermind, Joints are moving to closest point, it's just that I had to set Target beyond [-PI, +PI] range!
     
  24. Kobix

    Kobix

    Joined:
    Jan 23, 2014
    Posts:
    146
    Ok, I got into the weird stuff with articulations, the joints stop working based on some weird colliders as children being present or not.
     
  25. Kobix

    Kobix

    Joined:
    Jan 23, 2014
    Posts:
    146
    Playing with articulation further, it seems to break if the Anchor Rotation is changing down the chain, it seems.
     
  26. yant

    yant

    Unity Technologies

    Joined:
    Jul 24, 2013
    Posts:
    596
    @Kobix - I think there will be a new experimental build with articulations shared here in a week or two from now. I'm removing the old maximal coordinates articulations as looks few actually found those useful. ArticulationBody will become related to Rigidbody and follow some of the interfaces as expected (when it comes to AddForce/AddTorque for instance). There are more changes to be available later. This build will be based on 2020.1 though with an intention to ship a minimal viable set of components that can be extended over the course 20.x in a natural way.
     
  27. Kobix

    Kobix

    Joined:
    Jan 23, 2014
    Posts:
    146
    Hey, big thanks for info!

    To reply:
    - I never used the maximal coordinates articulations, so I suppose you are right.

    - I tested AddForce/AddTorque, but it doesn't work (no effect), I just used AddForce to block ArticulationBodies sleep (as mentioned before).

    - Now that you mentioned ArticulationBody related to RigidBody - does that mean it would be possible to simulate Graph Jointed (non-tree) structures, with base structure being tree (articulated body) and adding some classical joints?
     
  28. yant

    yant

    Unity Technologies

    Joined:
    Jul 24, 2013
    Posts:
    596
    Yes that's the intent here. An example could be a double wishbone car suspension which is currently not possible to model with articulations because of loops.
     
  29. Kobix

    Kobix

    Joined:
    Jan 23, 2014
    Posts:
    146
    Ok awesome, can't wait to test it out!
     
  30. Kobix

    Kobix

    Joined:
    Jan 23, 2014
    Posts:
    146
    Hi, hoping for build this week, it's gonna save my ass (demoing Unity to some ppl)
     
  31. interpol_kun

    interpol_kun

    Joined:
    Jul 28, 2016
    Posts:
    134
    Can you please elaborate on "trigger shape should also vanish"? I am curious what is the problem with triggers as concept.
     
  32. yant

    yant

    Unity Technologies

    Joined:
    Jul 24, 2013
    Posts:
    596
    I'm not Pierre, but as far as I understand a way forward for PhysX would be to say no triggers are supported at all, only contact notifications. Then, we get access to a chunk of contact pairs, sift through them to see which we think are triggers and flag PhysX forward regarding what needs to be computed for those pairs further on. The trigger concept would be specific to integration, and not to PhysX itself and will allow for plenty of customisations.

    Currently, there is a not so nice logical duplication of concepts within the SDK itself, where contacts are processed one way and triggers are processed the other way. It should really be a nice single interaction path right after computing the penetration distance for convexes (GJK).
     
  33. brunocoimbra

    brunocoimbra

    Joined:
    Sep 2, 2015
    Posts:
    679
    So is on the mid or long-term plan to change how the Triggers works? Seems like some performance benefits could come from those changes made by PhysX - or least make things less error-prone when integrating new features.

    To better understand my doubts:

    1. Should Unity users be prepared for a future where Trigger-Trigger interactions vanish and start thinking on the "right way" instead?
    2. OR will Unity work under the hood to maintain the Trigger-Trigger interactions on the foreseen long-term?

    I am asking that because I see the main reason of the Trigger-Trigger complains being that we didn't saw that breaking change coming - specially near a LTS release - but with proper communication and planing I can see that being acceptable (like for the 2021 release cycle or even 2020 release cycle).
     
  34. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    Several users including myself chimed in stating the importance of maintaining backward compatibility of trigger to trigger interaction, and the Unity dev said that he would be looking at it the following week and it should be fairly simple to put back in. That was several weeks ago.

    I've been watching this thread carefully and have seen no update on this from Unity though.
     
  35. brunocoimbra

    brunocoimbra

    Joined:
    Sep 2, 2015
    Posts:
    679
    Actually @yant has been working hard on it, take a look here: https://forum.unity.com/threads/ontriggerenter-not-fired.719165/page-2#post-5091077
     
  36. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
  37. brunocoimbra

    brunocoimbra

    Joined:
    Sep 2, 2015
    Posts:
    679
    In the linked post he mentions backport to 2019.3, so I think so.
     
  38. interpol_kun

    interpol_kun

    Joined:
    Jul 28, 2016
    Posts:
    134
    I mean what should replace trigger in PhysX. I don't quite understand how the physics system should determine should be there collisions on contact or not without the trigger concept.
     
  39. yant

    yant

    Unity Technologies

    Joined:
    Jul 24, 2013
    Posts:
    596
    PhysX will still remain the contact reporting mechanism. Nothing would replace trigger, the concept disappears completely. There would be user-land callbacks to determine how to process this particular pair - as a trigger contact or as a normal contact with full contact points generation pass. Most of that is already there if look at how the filter callbacks/filter shaders are set up in PhysX.
     
    brunocoimbra likes this.
  40. yant

    yant

    Unity Technologies

    Joined:
    Jul 24, 2013
    Posts:
    596
    But let me stress that I'm not a PhysX dev at all, that's only how I perceive a logical way forward for the SDK based on my understanding how Nvidia approaches generalisation in general. See how layer-based collision ignorance was replaced for custom callbacks for instance. See how OnTriggerStay has to be implemented in user lands since PhysX 3. Etc. Again, my just my personal POV - to have this stated clearly.
     
  41. Kobix

    Kobix

    Joined:
    Jan 23, 2014
    Posts:
    146
    Hey, how are articulations looking ?
     
  42. yant

    yant

    Unity Technologies

    Joined:
    Jul 24, 2013
    Posts:
    596
    I'm working hard on cleaning up the code, it's not exactly ready right as we speak. I can't share when exactly is it going to be available on forums, but I do hope that it's soon. Stay tuned.
     
    mvaandrager likes this.
  43. Kobix

    Kobix

    Joined:
    Jan 23, 2014
    Posts:
    146
    Ok big thanks for feedback! I will work on other stuff meanwhile; trying out articulations will be the juicy part.
     
  44. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    btw I've just noticed on 2020.1a9 if you have a monobehaviour with
    public void OnTriggerEnter(Collider other) and working correctly (meaning, the trigger should be called). It's all nice.
    The problem is that you can do a script.enabled=false; (disabling that script) and OnTriggerEnter will still be called, ignoring whether it's enabled or not.
     
  45. brunocoimbra

    brunocoimbra

    Joined:
    Sep 2, 2015
    Posts:
    679
    It was always like that, see the "Note" part in the API: https://docs.unity3d.com/ScriptReference/Collider.OnTriggerEnter.html
     
    yant likes this.
  46. yant

    yant

    Unity Technologies

    Joined:
    Jul 24, 2013
    Posts:
    596
    Actually, this was recognised as a serious problem just lately, somehow. Apparently, this would make it so that any pre-baked mesh colliders would be undetectable (missing) by physics on any non-desktop target. Fixed, it's in Unity 2019.3.0b11, the 2020.1 PR is going as we speak. Tracker link: https://issuetracker.unity3d.com/is...-platforms-appears-when-exporting-for-android
     
  47. yant

    yant

    Unity Technologies

    Joined:
    Jul 24, 2013
    Posts:
    596
    As to articulations, we're actually shipping a cleaned up version of what was available in the experimental builds of 2019.3 before. I'll let you know the dates, please stay tuned. The current plan is to ship what we already saw in this chat, and evolve it a bit further in the upcoming versions. anthony
     
    rz_0lento and Prodigga like this.
  48. Kobix

    Kobix

    Joined:
    Jan 23, 2014
    Posts:
    146
    Thanks for update.

    Also, would articulations be good for 6 DOF+ jointed structures?
     
    Last edited: Nov 14, 2019
  49. yant

    yant

    Unity Technologies

    Joined:
    Jul 24, 2013
    Posts:
    596
    The first iteration that we're shipping in 2020.1 is unlikely to allow connecting articulations and rigidbodies with regular joints. This will have to come later.
     
  50. Kobix

    Kobix

    Joined:
    Jan 23, 2014
    Posts:
    146
    Yes, I realized that, it's probably quite hard to do (if even possible). I am fine with that.

    But, last time I tried Articulations (the last experimental Unity build that had it), I had weird problems with Articulations, where if I added more and more joints - they broke down (stopped to move).