flame-engine / forge2d

A Dart port of Box2D
BSD 3-Clause "New" or "Revised" License
181 stars 26 forks source link

feat!: Use sensible fixture defaults #57

Closed spydon closed 1 year ago

spydon commented 2 years ago

Description

In #54 the friction was set to 0, but I realized it is much more useful to have it set to some value like 0.2 that gives a more wanted result in most of the time (since everything obviously just slides around with 0).

Checklist

Breaking Change

Related Issues

alestiago commented 2 years ago

@spydon I think this is not the optimal solution. I think we should look into providing something to the "world" that changes the defaults of Defs.

For example, in my use case, it makes sense to have Friction to 0. It becomes redundant always setting the friction to 0. I imagine, for you, this is the same but with 0.2. This reminds me of this.

The defaults change from use case to use case so I believe instead of changing these there should be a global default that the user can override for convenience.

Wdyt?

spydon commented 2 years ago

@spydon I think this is not the optimal solution. I think we should look into providing something to the "world" that changes the defaults of Defs.

Yeah, that sounds like a good idea.

For example, in my use case, it makes sense to have Friction to 0. It becomes redundant always setting the friction to 0. I imagine, for you, this is the same but with 0.2.

I think that use case is much less common than having some friction though? Just like in the real world.

This reminds me of this.

Haha at least we can see each other painting.

alestiago commented 2 years ago

@spydon would you like to work on these generic defaults? Or shall I try investigating the possibilities of this?

spydon commented 2 years ago

@spydon would you like to work on these generic defaults? Or shall I try investigating the possibilities of this?

Missed your comment here, please go ahead if you have time! :)

alestiago commented 2 years ago

@spydon the only solutions I can think of are:

None of these ideas convince me yet. If I can think of other solutions I let you know.

If we already plan to remove Def this is not a major concern for me.

The solution I like the most is encouraging developers to subclass, so instead of FixtureDef they can use FooFixtureDef. So for example, in pinball, it would be PinballFixtureDef over FixtureDef and the subclass sets some defaults accordingly to the desired outcome.

Let me know from the above solutions which one you prefer.