-
Notifications
You must be signed in to change notification settings - Fork 5
Bindings for Extension Libraries
DART uses template member functions to construct Addon, BodyNode, and
Joint instances. dartpy works around this limitation by wrapping these
functions for a predefined set of template arguments. You need to register
your classes with dartpy for these methods to work on custom types.
For custom Joints:
JointTemplateRegistry::register_type<MyJoint1>();
JointTemplateRegistry::register_type<MyJoint2>();
// ...For custom BodyNodes:
BodyNodeTemplateRegistry::register_type<MyBodyNode1>();
BodyNodeTemplateRegistry::register_type<MyBodyNode2>();
BodyNodeTemplateRegistry::register_type<MyBodyNode3>();
// ...If you want to use the createJointAndBodyNodePair() method on Skeleton,
then you also need to register all pairs of BodyNode and Joint subclasses
that you intend to pass as template arguments. Typically, this includes:
- each custom
BodyNodepaired with each customJoint - each custom
BodyNodepaired with each defaultJoint - each default
BodyNodepaired with each customJoint
dartpy provides the register_all_types helper function to register the
cartesian product of two lists of types. You can register all of the above
combinations using the three lines of code:
using MyJointTypes = typelist<MyJoint1, MyJoint2 /* ... */>;
using MyBodyNodeTypes = typelist<MyBodyNode1, MyBodyNode2, MyBodyNode3 /* ... */>;
JointAndNodeTemplateRegistry::register_all_types<MyJointTypes, AllNodeTypes>();
JointAndNodeTemplateRegistry::register_all_types<AllJointTypes, MyBodyNodeTypes>();
JointAndNodeTemplateRegistry::register_all_types<MyJointTypes, MyBodyNodeTypes>();Note that this approach means that is is not generally possible to call
createJointAndBodyNodePair with BodyNode and Joint types defined in two
different extension libraries. If this is necessary, you need to modify one of
the libraries to call register_type on that pair of BodyNode and Joint
types.