stephengold / Minie

Integrate Bullet Physics and V-HACD into jMonkeyEngine projects (code has New BSD license)
https://stephengold.github.io/Minie/minie/overview.html
Other
122 stars 22 forks source link

Consider having pure getter/setter methods #39

Open tonihele opened 6 months ago

tonihele commented 6 months ago

Consider having pure getter/setter methods. For example in PhysicsCharacter.java, getUpDirection and setUp (I assume these are a pair despite the difference in naming), the getter actually takes in a parameter. With pure getter/setter I mean a getter is parameterless and returns the type whereas a setter takes one parameter of the type returning void. I also assume that in this example case getUpDirection takes a parameter as an optimization and it could be just omitted with a parameterless overload. Another example in this said class is get/setGravity.

This request comes from the jMonkeyEngine SDK, so it probably doesn't have any relation to actual usage in simulations/games. The SDK allows the user to modify object values in visual editors. These editors are based on basic Java Bean (?) properties.

PhysicsCharacter

stephengold commented 6 months ago

Thanks for the suggestion.

stephengold commented 5 months ago

@tonihele: I've given this a lot of thought.

I want to support the SDK's scene explorer interfacing with Minie. Being unfamiliar with scene-explorer internals, I don't actually know how difficult it is for it to handle non-pure getters. I am assuming it's difficult, since if it were easy you wouldn't have opened this issue.

From the standpoint of maintaining Minie, adding redundant API would be a step in the wrong direction, not an optimization.

Minie has many vector parameters. I don't know the exact number ... a hundred, perhaps? Some of them already have both single- and double-precision getters. I can imagine how adding a few pure getters might eventually create an expectation that every Minie parameter should have pure getters, both for single and double precision. However, I doubt the SDK will ever need or use so many getters.

I assume the SDK is interested only in a fraction of the available vector parameters. You would know better than I which ones those are. To save needless guesswork, please enumerate them here.