PHYSICS!!!



This isn't particularly impressive looking because I couldn't be bothered to record a video, but it is proof that there's physics now. Or at least potentially.

Long time followers might remember one of the more tedious "B" plots of this blog, my occasional failed attempts to install a physics library into my homebrew engine. The 2D games I've done have tolerably okay homebrewed physics, but the 3D games have never had anything that advanced far enough to be functional. Every so often I'd download some library and try to get it working, but as with most publicly available gamedev libraries they would:

  1. Be so lacking in basic function as to be useless (my favorite example was multiple audio libraries that did not have the ability to change the pitch of a sound) or be so enormously heavyweight that my application is supposed to run as a thread within the library.
  2. Be based on some dev's personal design pattern fetish, resulting in it being overwritten to the point of unusability.
  3. Have ceased development sometime during George W. Bush's presidency.
  4. Be smugly unavailable on Windows.
  5. Some mindblowing combination of 1 through 4.

The current thing I'm noodling at with Unsafe is the ability to "land" the ship on stations or planets, by which I mean that the ship approaches some target on your HUD and then some canned animations will play to transition to a UI where you could like, buy and sell items from a station or whatever you usually do in space games. For that to work, we need to detect that the player's ship has intersected with the target. I could just do some manual checks, but this was just making me feel like it was about time to bite the bullet and figure out what I was doing for physics, since we do need to keep the player from clipping through stuff after all.

I did some googling, asked an LLM or two, poked at a couple of different options, generally encountering the usual 1-4, But I did eventually find a link to something called qu3e. It offers box shapes that can be aggregated for dynamics, there is discrete (not continuous) collision detection, you can do phantom detection and raycasts and such, and that's it.

It's very simple -- arguably simpler than one might hope, because checking collisions against spheres and arbitrary shapes would be kinda nice. But on the other hand, I downloaded it, I ran cmake which created the Visual Studio projects without complaint, I loaded the project and hit build and it built all the linkable libraries without complaint, I linked them into my project and hacked some code into a test scene and... it Just Worked.

Existence has a quality all its own, you know, so I'm going to give this a shot. However, I would need to do a fair amount of work to have a proper physics component that communicates back and forth with my engine, so that'll be some effort. Conceivably I could only go part of the way and simply use this to create phantom objects, detecting overlaps and reacting manually, but I doubt that'll save me much time in the end. As always, we shall see.

Leave a comment

Log in with itch.io to leave a comment.