-
Notifications
You must be signed in to change notification settings - Fork 63
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
Added AABB support #22
Conversation
Thats a good idea! How about a collider interface? Something in the way of: |
A couple things I don't like about that interface:
Speaking of Rays, whether at the function or struct level, we need to some to allow precomputed inverse directions to be used. Maybe something like this? |
It seems we're hitting the limits of what this package can do before its scope is "too big." Convex hull and other intersections test are incredibly useful, but I see them living in a higher level package. Ideally, I think the best way to organize this would be:
The benefit of that approach is that it would keep each library smaller in scope, which means it's easier to maintain and can be higher quality. It allows people to import only what they need. It also lets you add any kind of useful high level algorithm that fewer apps will need, but can be incredibly useful. I don't really see disadvantages in splitting AABB/intersection tests away from the low level Vec2/Vec3 types into separate packages. If you I would recommend you try to limit the scope of go-gl/mathgl as early as possible, and move the higher level algorithms that use mgl32.Vec2 or mgl64.Vec3 into another package. Back when I was using C++ as my primary language, my all time favorite library was http://www.geometrictools.com/LibMathematics/LibMathematics.html, as it had algorithms for all kinds of distance and intersection tests (between 2D, 3D lines, rectangles, spheres, OBBs, you name it). I would love it if one day all those algorithms are available as a native Go package. ConclusionIMO, I think it's best to try to limit the scope of go-gl/mathgl to be as small as possible. Its goal should be to provide the Vec2/Vec3/Vec4, Matrix, etc. primitives that all other math/physics algorithm packages can use, so that they're compatible. It would be a shame if some higher level packages use |
I see your point. To be totally honest, I was cribbing the initial method set from the linear algebra subpackage of Bullet (though I was gonna go a little tiny bit farther and add a couple more primitives than they have in the naked linalg package) -- I was planning on stopping at collision primitives; I had plans to add higher level stuff to mathgl, but under different package headers ( I haven't decided if making a separate repository or doing the subfolder thing is better -- I suppose go get gets the entire repository regardless so maybe an entirely separate one would be better. |
I essentially had one less degree of separation than you --
I see the utility in that extra degree of separation, but I'm not 100% on the exact point it should happen. (Though I would argue that at the very least, RENDERING primatives should be in the package scope, since it matches gluCylinder and the like). |
I don't want you to stop! :) But it's best to keep the higher level things separate, so they don't reduce the value of the lower level VecN primitives. I want there to be one Go de-facto standard to import for VecN types, and that's easiest to do when that package is as small as possible (in order to cater to as many people as possible). One other idea would be to keep the scope of mathgl/mgl* as is, but extract the lowest level types and their methods in a separate, smaller package. However, the problem with that approach is that users will then need to import both mathgl/mgl* AND lowlevel/* and they'll be forced to use different package names for the two (i.e., |
Hah, and I've just discovered exactly what I was afraid of: https://github.com/fzipp/geom Via github.com/errcw/glow/examples/cube. (/cc @errcw) Now there are some incompatible Vec2/Vec3 types, that, as far as I can imagine, probably try to solve the same problem. It doesn't seem to have a lot of importers, but godoc is not a very representative measure of importers. FWIW, mathgl doesn't have a lot of importers on godoc either. |
Well, I don't think we'll avoid packages that do the same thing, there are any number of 3D math packages in C and C++ (partially due to the great degree of NIH syndrome many game developers have). That said, we could consider a hypothetical 2.0 release with more package fragmentation. I'll open another issue for that |
FWIW, that cube example has started using |
I added basic support for axis-aligned bounding boxes. I may go slightly further into other simple intersection tests (capsule, sphere, possibly convex hull), but I'm not turning this into a 3D physics package or anything -- you're not going to see bounding volume hierarchies or anything like that. Intersection tests are very useful even for pure graphical applications.