You are browsing as a guest. Sign up (or log in) to start making projects!

Open comments for this post

3h 2m 17s logged

Devlog - 02 - Before Shabbos
Since the last blogpost I have been working on cleaning up the existing codebase, improving some APIs and laying down the groundwork for electrostatic movement.

I spent over an hour splitting the GUI rendering process into multiple independent files that are each much smaller than the monolithic “graphical.cpp” from before, which allowed for a cleaner structure which enabled me to think about the code more cleanly and refactor it further.

I created a generic Holder struct which runs some function when constructed (and can receive arguments for that function when constructed) and calls another function when it goes out of scope. This is useful in ImGui because very often you have stuff like ImGui::BeginGroup() which must be followed with ImGui::EndGroup() which can easily be forgotten and also leads to unclean and spaghetti code.
Instead, All that needs to be done now is a declaration of a GroupHolder variable, and then ImGui::EndGroup() is automatically called when that variable goes out of scope.

I moved a bunch of constants from graphical.cpp to a PSimImpl namespace which allows them to be accessed from anywhere without polluting the global namespace.

Additionally, I spent some time laying down the groundwork for electrostatic movement, which includes a Force type, which is a strongly typed wrapper around Vec2. I need these to be strongly typed so Force cannot be accidentally converted to Position or Velocity, but I also wanted to be able to explicitly (or implicitly) convert a Vec2 to one of its wrappers. This took a while to get right and eventually lead to the line of code in the screenshot.

One more thing: I noticed that currently this website has no way to actually find the GitHub page for other people’s projects, so here’s the link to mine: https://etaiami09-cmd/PSimUltimate
Enjoy!

0
2

Comments 0

No comments yet. Be the first!