Just wondering if you guys use number wrappers in your code to facilitate passing by reference, to help simulate c++ style method calls, especially for physics and collision. Do you think this is too drastic of a measure to have all vector objects composed of number wrappers?
I use that technique sparingly in its raw form. In general I’ll not pass in wrappers for three floats, I’ll pass in some sort of actual WriteableVector3f for example. It’s all a bit of a shortcoming in the design of Java.
I have a suspicion that a JVM these days will actually be no slower if you actually construct and return a Vector3f anyway.
Ok, I figured as much.
I’ve been studying projected rectangle collision on YouTube from this video, but the examples are in C++ and a lot of the methods he writes are pass by reference, which throws a monkey wrench in everything i’ve been doing up to now. I use Point classes to track anything that is an x, y pair, e.g. game object coordinates, screen scroll, etc. So if I introduce wrappers into those classes it affects about five other components. I tested it and it’s not a big deal, but it’s pretty gnarly looking when i have to reference something like scroll.x.num instead of scroll.x, especially when passing by reference isn’t necessary.
But these collision algorithms are all pass by reference and use all this physics, so I kind of need wrappers for certain things. I guess I will try to isolate the use of wrappers to those specific use cases so I don’t make all my other code look crappy.