Skip to content

Instantly share code, notes, and snippets.

@Memresable
Memresable / rotational-dynamics.md
Last active August 20, 2025 05:37
Demystifying Rotational Dynamics in Rigid Bodies

Demystifying Rotational Dynamics in Rigid Bodies

Rigid bodies mainly have 6 degrees of freedom in 3 dimensions (3 translational and 3 rotational), you can represent the particles as rigid bodies with only 3 translational degrees which is straightforward and their equations of motion aren't difficult to formalize, but what if you want to extend from particles to much more than that? Say... system of particles connected to each other to create a whole body!

First, let's suppose you have two particles, one that has an infinite mass which cannot represent motion unless an infinite force is applied, and the other one which has some finite amount of mass which is able to move around, but now let's actually link them together by a massless rigid rod or an infinitely stiff spring like so

rigid-rod

Here because the rigid rod is infinitely stiff and

@Memresable
Memresable / gizmo.md
Last active June 25, 2025 19:51
A Simple And Intuitive Explanation of How Gizmos Work In 3D Space

A Simple And Intuitive Explanation of How Gizmos Work In 3D Space

If you've ever used a 3D editor, then you've most likely used a certain thing called "Gizmo", Gizmos are essentially transformation modifiers that's within a world, they let you modify the object's position, orientation and scale. The implementation of a Gizmo is actually fairly straightforward for the most part (or may not be depending on how your application handles things internally, but at the fundamental level it's simple).

This article would only cover Translations and Rotations, Scaling is very easy to implement after understanding how the first two work. And also this may give you a hint into how Blender's robust implementation of Gizmo works as well!

box-gizmo


@Memresable
Memresable / binary_file_trees.md
Last active December 29, 2024 05:19
Binary file construction with trees

A different approach to binary file construction with trees

Lately I've been struggling creating custom file formats for my game, and every time i wanted to create a file format i would have gone through the same design process that's tedious and boring, usually i become selective on whether it should be binary/XML/JSON etc, there's so many options to do the same exact thing but they all have tradeoffs, it heavily depends on what i'm storing

Take renderable objects as an example, meshes usually have arbitrary primitives that are not constant in count size, and so jumping around and putting next_offset and previous_offset variables with magic numbers everywhere manually is extremely annoying, and they sometimes describe scenes of sub renderables as well and so you would have to somehow store the transform components along how many children a node currently has (which is unknown!) and so on

@Memresable
Memresable / randy_gaul_obb.md
Last active December 23, 2024 13:58
A look at Randy Gaul's 3D OBB-OBB collision detection & resolution

UPDATE

The article seems to have a really bad tune, it was back then me writing this and i learned a whole lot later on, i don't find this to be a decent article to follow through and i wouldn't recommend it anymore per se, i'm thinking of doing a complete rewrite of this with my own simplified implementation of it (which isn't perfect and contains errors, but would be quite good for understanding), it still contains some useful information however in case you're interested.

And the little rant has been removed since I've found it to be distracting and not helpful, i've learned that they have a good use for some other things, I still don't recommend the GJK + EPA combination however, but they have some useful uses.

Some helpful resources for the time being:

Dirk Gregorius, The Seperating Axis Test

@Memresable
Memresable / win32_page_merging.md
Last active November 14, 2024 18:20
Combining Memory Pages in Windows

WARNING

This may contain tons of errors, I have not carefully checked if the method used here is fully correct/safe, read the docs!

Also this is a very old gist, I'm thinking of doing a modernaized version of this for fun at some point

Combined Pages

So lately i've been playing around the idea of merging pages together to be a single linear writable memory, I've searched through the web a lot and i've never seen anyone actually doing it in a way i did, the reason behind researching around this topic was i was curious, but also it seemed useful to just merge stuff together and eliminate memory fragmentation by merging multiple chunks together to form one contigues memory you can write to

what i basically need to do is create a file mapping object that is multiple of 64KB pages of total size, each file map created is an object returned by the OS that is a "file" but can be treated as a regular memory that can be written to as well, then i allocate a virtual memory that is "reserved" to be replaced by ma