NVIDIA PhysX 2.8.1
Thursday, May 15th, 2008So they released a new PhysX version, and this time the character controller (CCT) source code is included. Partially. For various reasons they decided not to release the source code for the actual sweep tests (box-vs-box, capsule-vs-capsule, capsule-vs-mesh, etc). So the SDK exposes them as utility functions and the CCT code just accesses them through the NxUtility interface. However all the code for the CCT logic has been released.
I originally wrote the CCT as part of ICE, for Konoko Payne. It was many years ago, before I joined Novodex. Then I integrated it to the Novodex SDK, it got rewritten, refactored to use the NX math classes, etc. Then for some reasons it got moved outside of the SDK, in its own NxCharacter DLL. Then filtering callbacks were removed because of the Ageia hardware (the original plan was to move the CCT to HW, so callbacks were forbidden.) Then fixes sent to us by various customers got integrated. Then I rewrote it for “large worlds”, using doubles for positions. Then this feature was dropped, a decision I’m still bitter about. Then the code got modified by various people over the years. Then the code was rewritten again to remove the sweep tests, which got exposed as NxUtility functions instead. And then the final code was released, probably because they got tired of modifying the CCT for each individual customer (they always want something a little bit different).
Looking at it again today, I have mixed feelings. One one hand it still does its job more or less correctly. On the other hand, it’s a bit in a sad state by now:
- It’s a bit bloated, with some useless code that could be dropped.
- It has O(n^2) parts to deal with character-character interactions and it misses an incremental SAP to support “sleeping characters” (to avoid testing all of them each frame). This is because the SDK didn’t expose its SAP interface directly to users.
- It doesn’t support large worlds even though the code structure is ready for it (relocating everything around the player’s position instead of working in world-space, etc).
- It’s probably not as fast as it could be, since the CCT was never a big priority for Ageia (sometimes I had the feeling nobody cared about it. It wasn’t HW accelerated so it wasn’t important. Sigh.)
The current CCT used in KP is basically the same. But without the problems. That’s because a single person touched the code, and no political reason ever motivated a code change. It’s a bit sad that the code I produce alone in my free time (Opcode, Flexporter, etc) often ends up in a better shape and faster than the code produced within a company, where N people with different mindsets and sometimes conflicting views are allowed to change it. It worked great within Novodex because we were only 2 people, “owning” clearly defined parts of the code: Adam was in charge of the solver & joints, I was in charge of the collision detection. We never stepped on each-other’s steps, as far as I can remember. Within Ageia… let’s just say things were different.