Skip to content
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

Include generic for world.createJoint #36

Closed
alestiago opened this issue Mar 3, 2022 · 2 comments
Closed

Include generic for world.createJoint #36

alestiago opened this issue Mar 3, 2022 · 2 comments
Assignees

Comments

@alestiago
Copy link
Collaborator

alestiago commented Mar 3, 2022

Problem to solve

Avoid casting when doing something as:

PrismaticJoint prismaticJoint = world.createJoint(prismaticJointDef) as PrismaticJoint

Proposal

Use of generics to avoid casting:

PrismaticJoint prismaticJoint = world.createJoint<PrismaticJoint>(prismaticJointDef)

More information

Possible solutions

  1. Updating function signature to T createJoint<T extends Joint>(JointDef def) and return to return joint as T; (Simplest Solution)
  2. Refactoring joint.dart to perhaps benefit from OOP and simplify static method static Joint create(World world, JointDef def)
  3. Open to further suggestions

I'm interested in working on a PR for this.

@erickzanardo
Copy link
Member

Sounds good to me! Feel free to put a PR for it 🚀

@spydon
Copy link
Member

spydon commented Mar 3, 2022

Sounds good to me too, there are a lot of these things that have been passed along through all the ports from C++. I assigned you to the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants