-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upgrade to PhysX 5 #183
Merged
Merged
Upgrade to PhysX 5 #183
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This doesn't actually emit anything because AFAICT there are no functions we would actually want to call in PhysX as they are mostly just math functions that can be done in Rust instead
Jake-Shadle
force-pushed
the
update/physx5
branch
2 times, most recently
from
March 2, 2023 16:53
b236964
to
8a065d2
Compare
Jake-Shadle
force-pushed
the
update/physx5
branch
from
March 2, 2023 17:11
8a065d2
to
76d6a10
Compare
Ok, all platforms that we care about are about are compiling and working again, I'll merge this tomorrow. It's time to go and drink heavily. |
@Jake-Shadle Sounds good. I'll leave you to override the merge so you don't get raced by the bot. |
Nice work, guys! |
This was referenced Mar 4, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
pxbind
This ports pxbind from C++ using libclang -> rust using clang's AST JSON output. The port includes adding snapshot testing of the output of pxbind + structgen both to validate the port as well as (hopefully) making any changes easier in the future. This initial port is mostly a 1 to 1 conversion with 3 notable exceptions.
enums
improvedflags
improvedcore types
improvedmethods
structs/classes
templates - Unfortunately more templates have crept into the public API of PhysX, to a degree where it feels like we need to support at least some of them.enums
In the current pxbind, enums are outputted like this.
This makes them cumbersome to use from Rust. In the new pxbind they are outputted like this.
This allows regular usage from Rust, and the Rust enum can be used on the FFI boundary since it is guaranteed to be the same size as the underlying integer type in C++.
flags
Many enums in PhysX also have a bitflags version using
PxFlags<_enum_type_, _integer_type_>
.typedef PxFlags<PxShapeFlag::Enum,PxU8> PxShapeFlags;
In the current pxbind, they are outputted like this.
In the new pxbind they are outputted like this.
Like the regular enums, this allows easy and typesafe usage from Rust that can be passed transparently through FFI. Since the enum that is paired with the bitflags are always emitted before the flags we elide the comments on the individual constants.
Core Types
PxVec3, PxVec4, PxVec3Padded, PxQuat, PxMat33, PxMat44, and PxTransform now use the equivalentglam
types on FFI since they all already match the layout of the PhysX pod types. This means we also skip generating FFI bindings for the various math functions related to those types as that can just be done in pure Rust without needing to go back and forth. This was also done because PhysX now makes all of these types into templates, which makes everything more annoying, especially since the f64 versions are...never actually used. But future proof!I've changed the core types back to non-templated versions, there is no reason to keep that baggage. EmbarkStudios/PhysX-5@87ee3fa
physx-sys
Since physx-sys just exposes the raw bindings generated by pxbind/structgen the breaking changes are mostly the same as those in the underlying sdk, eg things like constructors in core types like PxTransform now take defaults, removing 1 or more constructor bindings which can cause direct use to be incorrect due to how constructors are named with a number suffix to disambiguate the FFI functions. There were also types that were completely removed such as PxArticulation and so forth.
physx
In addition to the aforementioned changes in physx-sys, probably the biggest change in physx is that we no longer have to manually recreate bit flags and do the conversion to/from the FFI type since most bitfields (there are a few exceptions) are now automatically generated by pxbind.
Resolves: #175