Skip to content

Add support for is<T> #11

@PathogenDavid

Description

@PathogenDavid

PxBase has a template method named is<T> which can be used to identify the subtype of a PxBase object at runtime. It's not super commonly used, but it does come up every once and a while. It is currently untranslated because it's a template method.

Generally you can get a similar check using getConcreteType, but that only works if you know the specific type you're looking for. It does not work well when you want the ability to identify collection of types. (IE: PxRigidActor, which has multiple concrete variants PxRigidStatic, PxRigidDynamic, and PxAtriculationLink.) Doing a check similar to this requires using isKindOf, which is currently not translated as it is protected.

In theory we could use Biohazrd's template specialization to generate many is_Blah implementations, but I don't think that's a user-friendly approach here. We should instead implement our own variant of it using C# generics.

This also means we need to implement an equivalent of PxTypeInfo (also currently untranslated.) The C++ approach does not make sense for C# here. We should instead either A) use the default(T)+property trick we used in Mochi.DirectX for interface IIDs or B) use static abstract interfaces.

A is in theory slightly worse for performance, but B requires the use of preview features prior to .NET 7.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions