I created a new struct Arrow which holds a reference to a Mesh and a Vec3. It then rotates the mesh to point in the direction of the vector. In this video I made two Arrows with references to the mesh of an arrow and the velocity of the mesh of the arrow in turn making it point in the direction its mesh is moving. This took quite a bit of work since I had to fight with some linear algebra and also with the Rust lifetimes which after some research I decided would be best to ignore and use Unsafe since doing anything which made the compiler happy would either have been very ugly or very annoying to use. This does mean I have to be more careful with these arrows since they do contain raw pointers and will have to work around them in the future. I also did some refactoring to make things more organized and easier to navigate in the code base. I updated the physics update code to be compatible with the arrows and also likely quite a bit faster. I also updated my integrator for angular velocity to Rk4 which was introducing big errors due to using Euler’s method for integrating ω. I then also learned my energy calculation was wrong due to frame mismatch where my inertia tensor was in body space but ω was in world space as well as a slightly wrong interpretation of the formula for rotational energy. Outside of programming I did some linear algebra work to be able to better understand how future and currently implemented physics concepts work. I also added extra timing details for diagnostics so that I can actually ensure any optimizations I make are actually faster. Next I plan on improving the arrows some more, improving the rendering system, and soon starting work on Collision Detection and Resolution :)
Log in to leave a comment