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

Perihelion

  • 22 Devlogs
  • 72 Total hours

This is basically going to be the game Universe Sandbox, but on the web! Basically you can play around with a simulated solar system, seeing what happens if you replace the sun with a black hole, or anything you want! It will simulate gravity using real physics defined by Newton himself!

Open comments for this post

2h 6m 25s logged

What would happen if a second Sun randomly spawned in our solar system? Well clearly chaos according to my simulation.


So previously, I made a button that automatically sets a velocity so that one object orbits another object, allowing you to easily make planet-moon systems.

However, what if you wanted to create gravity systems where objects are similar masses, like binary stars, or something like the Pluto-Charon system where clearly they orbit a point outside of each other?

This is what I set out to implement in this devlog, other than fixing a bug in the spacetime curvature grid where it would jitter around.

So I’m gonna be honest here, I did basically get AI to do this part for me, that’s not to say I didn’t try at all because I really did. But it turns out this stuff is way outside of high school physics and goes into orbital mechanics.

I wrote a simple solution which I thought might work, but it didn’t quite.

So I tried to watch this video to understand how to do it, but couldn’t understand what kind of vector math he was doing. So I basically gave up and got Claude to do it.

Looking at Claude’s solution, it seems kind of simple in that it’s not using crazy long equations to do things, but at the same time, I don’t think I would have been able to come up with those on my own, so ig it was a good use of AI to speed things up.

0
0
16
Open comments for this post

3h 25m 19s logged

I’m back after 2 weeks!!! First I’ll explain why I took a break and then go over what I did in these 3.5 hours.

Why I was gone for 2 weeks

Basically, I was previously trying to force out 3.5 hours a day to get the FW13 laptop, along with trying to finish this online course so I can get my driver’s license (spending 2 hours a day on that). On top of that I had tuition classes so I can get ahead for next year’s chemistry and math curriculum (probably ~2 hours a day on that). This makes for 8 hours a day of scheduled work. Oh yeah and I wanted to do all of this while still maintaining my health (like going out for a walk everyday and things).

Obviously, this is a lot of time to commit, but I went ahead with it, thinking of it as a way for me to learn better time management, so that grade 12 will be easy for me.

However, it turned out to not go the way I thought it would in my mind. You see, no matter what I tried, I just couldn’t get all three of my priorities met. It’s not like a 9-5 job, where you really just have to stay at the office for that timeframe, but then only like 3-4 hours of that is actual focused work. This plan was demanding a full on 8 hours of high focus everyday, which is probably just not possible, without sacrificing too much in my opinion.

I also realized this was getting in the way my driver’s license and prepping for grade 12, which were probably more important.

Don’t get me wrong, Stardance is pretty cool and important, but the other 2 things are more important, I think.

The breaking point came when I finally did reach two of my priorities for 2 days (Stardance and driver’s course). But, it was a very grueling 2 days, and it wasn’t even including anything from tuition. I quickly realized that this was going need a lot more sacrifices than I bargained for.

So yeah, I took a break. I finished the online course, now I have to do in-car lessons, but the bottleneck for that is now the driving instructor’s availability, now mine. I also tried catching up to the tuition hw (yeah tbh, that didn’t go too well). And I still didn’t touch any of my projects for a bit after that because I was genuinely burnt out.

But now I’m back! I’m not fully quitting Stardance at all, but now I will work at a slower pace than before. A pace that feels natural to me, rather than forced. Honestly, it might turn out to be the same amount of time as before, just because a bunch of my time has been freed up by finished that driver’s course. But whatever happens, I will finish all of my projects in a way that isn’t so taxing to me mentally and physically.

What I actually did in this devlog

So for this devlog, I made it so you can edit the velocity using polar coordinates (basically change it via longitude/latitude), as an alternative to x/y/z.

I initially tried to do this myself by stitching together some math formulas from Reddit, but it didn’t work because I didn’t understand the physics behind them.

This stuff goes under a field called spherical trigonometry, which is something they don’t usually teach until university math, so I definitely didn’t learn it in grade 11.

Eventually I gave up and just used Claude to implement the rougher details. However, I have decided to learn a bit of this stuff myself, since it seems like just high school trig but in 3d. Also, because why not!

0
0
6
Open comments for this post

6h 22m 55s logged

Now you can change the velocity and lock it to a specific axis!! Also I upgraded to C++23 from C++20.

Yeah that feature was a real nightmare to implement, with loads of bugs. That stupid float vs double thing came back to bite me again!!!! I swear bro these things annoy me a lot.

How do I do this?

I also initially had like no idea how this feature should be implemented, I was sitting there thinking and trying code out for a long time. I eventually decided to change the way velocities are changed entirely, now instead of just clicking and dragging, you press V on the keyboard and click with the mouse to confirm.

Even after that I had a dilemma about how exactly this axis locking feature should be implemented. I was initially going to cast a ray from the mouse and figure out where it is closest to the axis, however it turns out that is math that goes outside of high school altogether, so I had to scrap that.

Then I decided to open up Blender and see how it does it’s axis locking when you drag 3D objects around. From Blender I got inspiration for how it works in my program.

So now once you are editing the velocity, you can press X,Y, or Z to change the velocity going in those respective axes if you want. I also figured a much simpler way than that first method I thought of because of the testing with Blender.

AI disclaimer

Obviously there had to be some bugs with my code. After having spent a bunch of time struggling through writing the code only to reach some weird bugs, I gave up and did turn to AI.

I carefully supervised it while it tried to fix my code (I do NOT believe in vibe-coding) and it was actually able to fix it alright. I made a suggestion to edit the code to be cleaner and it listened.

The ultimate plot twist

I then asked it to add that sky-blue line thing. Now here’s the ultimate plot twist, so you know that float vs double precision error that keeps coming back to me? Well in every previous devlog where it happened, it was Claude who pointed out the issue. Well guess what? This time it was me who found it! The issue was with that line and how it was drawn on screen.

So yeah. That took a very long time, but it was worth it.

0
0
31
Open comments for this post

3h 23m 32s logged

So now you can add objects and change velocities going up and down in the y-axis using up/down arrow keys!! It also shows the flat grid temporarily for these.

The only thing is that I will probably change how the velocity y-value thing works, because I don’t like it. It’s ironic because that was the thing that took the most amount of time as well.

0
0
11
Open comments for this post

2h 41m 39s logged

Here’s what I’ve done:

  • Made it possible to move the flat grid up and down
  • Implemented custom camera controls so that I can better control the experience. This was very difficult at first… until I realized I could just copy paste the code from the library I’m using and just edit that instead 🤦.
    • With this new camera system, I added a feature where you can hold shift and it will slow down for you.
  • More internal refactoring!!! If you’ve been reading my devlogs, you’ll realize that this is like the 5th time or something that I did internal refactoring. To explain, this is my flagship project, as in I’m trying to reach like ~150 hours on this project so that I can get the Framework 13, so I want to take it slowly, so that I can be sure that I can build the features I want to build in an enjoyable manner. This is why I do these things occasionally.
0
0
5
Open comments for this post

2h 41m 11s logged

So I added an easy button to make celestial objects orbit another object. To demonstrate this, I recorded a video of me adding 2 moons to Jupiter!

I also added a reverse velocity button which is self-explanatory, I didn’t include it in the video because I forgot.

I also made it easier to add objects in a previous devlog, but I forgot to include it there.

0
0
18
Open comments for this post

3h 59m 42s logged

In these 4 hours, I have made the overall experience of switching between objects better by doing these things:

  • Made the camera turn with constant angular speed. Previously, it would sort turn instantly if it needed to make a 180, and then freeze.
  • The camera position is now smoothed out with an easing function instead of linearly moving it
  • Made the grid in the background not jitter when viewing a single planet
  • Set up debugging to work

    The reason this took this long was because for some reason, I was previously using the frame count and a decimal calculated framerate to time out the animations.

    Obviously, mixing decimal numbers with whole numbers wasn’t going to work well, so I had some really weird bugs that sometimes happened and sometimes didn’t. This was literally the motivation for me to setup the debugger!

    Initially I tried to work with the system as it was, but it became tedious fairly quickly, with a lot of if statements, etc. So, I swapped to just using the system time, and it literally just fixed itself almost instantly! That and the code for it ended up being simpler than before!

    The only thing I don’t really like is the grid, and how it kind of jitters, although that will a future problem to solve.
0
0
6
Open comments for this post

3h 59m 25s logged

Here’s what I did yesterday:

  • Added a settings editor
  • Added tooltips everywhere
  • Added an intuitive button to deselect the current object
0
0
6
Open comments for this post

8h 11m 13s logged

You might be thinking: “So there’s 8 hours in this devlog, surely there are some major visual changes, right?” Well unfortunately no. I meant to post a smaller devlog the day before yesterday, but I forgot about it yesterday. Now here I am cleaning up that mess.


I basically did just the following 3 things:

Added Nerd Font icons to the UI. This took waaay too long (like 2 hours) since I was spending so much time figuring out how to scale specifically those icons, and nothing else and when I did figure it out, they were all of a sudden misaligned, towards the top left compared to regular text, so I had to realign them to be proper. After all of that, it seems like I might need to make my own font icons, since Nerd Font is mainly designed to be put in a coding IDE, not a random app like this. There are some space things which I want icons for, but aren’t available in Nerd Fonts. Oh well, that’s a problem for future me.

Now here’s the real timesink that made this devlog 8 hours: so I went on a long sidequest to basically implement CSS position property in this C++ UI library. This was mainly so that it would be way easier to position new UI elements. The next devlog will most likely be about adding new settings UI. Along with that, I also wrote a bunch of helper functions to make it even easier to write new UI components. So basically, the UI got a full refactor.

And finally, using that UI refactor from above, I added a playback controller at the bottom and moved the object selector to the top.


Yes, it is an embarrassingly small amount of user facing changes coming out of this 8 hour devlog, but at least my UI code is easier to maintain!

0
0
15
Open comments for this post

2h 3m 2s logged

Huzzah! I added a skybox (basically the background image). I will admit that this part was basically AI’d, but it was really hard to do it by myself, since it would have required learning GLSL myself, which I didn’t want to do.

1
0
52
Open comments for this post

4h 3m 37s logged

So I decided to spend a lot of time refining the velocity changing with the mouse. Also did a smaller refactor to make the code look cleaner.

The main issue I had previously was that it was jittery when the object was far from coordinates (0, 0, 0). It turns out it was another stupid float vs double precision problem in C++. Yes, very similar to what I faced earlier in this project.

I will admit that I did use AI to find these bugs and fix them, but I was supervising it very closely and testing it thoroughly. I am also starting to see the limits of AI. Claude now decided to flag a bug which didn’t exist, and when I asked it to refactor, it made the code look worse ironically. I ended up having to do that part myself.

However, AI was still more of a help than a hindrance, so I will still use it throughout this project. If you are curious, the git commits have more detail about these and they are here.

0
0
17
Open comments for this post

4h 25m 34s logged

So I made it very easy to change the velocity of objects, you can just drag from the cone anywhere now!

Surprisingly, the hardest part about this was just getting the arrow to draw and also tuning how big it is so that it looks good, but once it was there, it was actually pretty easy to just hook up a click detection.

Funnily, this 3D library I’m using (Raylib if you’re curious) doesn’t have a builtin “DrawCone()” function. It turns out that to draw a cone, you are supposed to use the DrawCylinder() function and set one of the radiuses to 0! That was really weird to find out.

0
0
5
Open comments for this post

1h 48m 24s logged

HEEELP!!!! I added a panel to edit the properties of objects, so I decided to add a bunch of mass to Mercury for fun, now the Sun is orbiting Mercury! This is so trippy especially how much it warped spacetime.

0
0
34
Open comments for this post

4h 32m 3s logged

So I fixed some bugs with the warped spacetime grid, and also added a way to add objects to the scene. I haven’t added collision detection yet, so it kind of looks weird but I’ll do that later.

The reason this took so long is because adding objects kind required a lot of refactoring. Basically, I had to write code for when my objects get copied around, because adding an element to a list in C++ might mean copying it around. This was difficult because raylib is a bit too high level for how it handles these GPU textures and models.

Now I will add an edit panel to make the new object changeable.

0
0
18
Open comments for this post

3h 44m 25s logged

I have just made the grid in the background warp, representing the curvature of spacetime!

You will probably notice that the grid is smaller and follows you around if you watch the video. This is because I had to. The grid needs to be about this small, otherwise performance is bad. I could make it bigger by making it more spaced out, only if that’s something people would want though.

This took waaaaaaay too long since I made a very stupid mistake and C++ decided to harshly punish me for it. Well I did promise not to use AI in the next devlog, but I was dealing with a really weird issue with it for like 1.5 hours and I gave up and asked Claude code about it. So you see that screenshot right (you might need to click the next image button)? That was the solution!!!!! Just add = 0 to that line.

So basically in C++, if you don’t initialize a variable to a value, as I did there, the value of that variable will then basically be whatever happens to be at that memory address, which will initially be some random number. But as the function runs again and again, it will use that previous value, and later on I was doing y += ... so the y-coordinates of the grid were continuously increasing.

Visually, it looked like the grid wasn’t being drawn, since the y-value instantly went to a huge number.

Btw that was the only AI help I got for this part, except for the mathematical formula, which I got from Claude as you can see in the background of the screenshot.

0
0
17
Open comments for this post

1h 41m 29s logged

tbh, I haven’t been working on this a lot over the last few days because of other projects, but now I have.

Here’s what I got done:

  1. A major refactor on the codebase which will make it easier to later add a preset selection screen.
  2. A better selector for celestial objects at the bottom of the screen.

    I’ll be honest, I did write most of the code for these with AI (yeah bummer ik, but really, who likes refactoring code on their own?). Although, I was closely inspecting everything it wrote.

    Now the next thing I will do is make the grid warp with the gravitational field strength to represent space-time getting bent.
0
0
32
Open comments for this post

1h 39m 18s logged

For this update, I have done 3 things:

  • Added a small outline circle to distant objects so that they are more visible.
  • made it so you can click inside of these circles or on the planet to zoom into it
  • Added a trail behind each planet.
2
0
14
Open comments for this post

2h 29m 11s logged

These past ~2.5 hours have been spent on some quality of life features for the app. Mainly these 3:

  1. Made every object 5x bigger than its real life size because it turns out the solar system is such a big place, that you kind of have to. Otherwise everything looks too small.
  2. Made it so when you switch between planet it has a quick transition period.
  3. Added textures to every planet and the sun. This was actually the hardest part, I had to play around with the settings because it would usually apply the texture sideways, or distort it but I got it working anyways.
0
0
3
Open comments for this post

3h 36m 16s logged

So in this devlog I’ve done quite a few things to make the overall experience nicer:

  • Added a way to pin one object to the center of the screen.
  • Added the Moon and the rest of the planets in the solar system
  • Switched from using light minutes to light seconds for distance measurements because the light minutes values were WAY too small

Another annoying bug I had to fix:

So there was this bug where the moon would pretty much always just fly out into the abyss as if there was zero gravity applied to it. It was pretty annoying to find out that it because I was using C++‘s float type instead of double.

What’s the difference? Well basically float gives about 7 decimal points of precision, while double gives about 15. I initially started with float because it is half the memory size of double and in my experience, float gets the job done like 99% of the time.

However, it turns out I did need more than 7 decimal points. This is because the gravitational force experienced by the Moon is very small, like around 10^-12 (thats 0.(eleven zeroes…)1). Since float can’t hold that value, it just rounded it to zero, causing the moon to fly out in a straight line forever. I’ll be honest, it wasn’t me who figured that out, it was Gemini who did, but pretty much everything else in this devlog was made by me.

It’s crazy how such a small difference of like 10^-12 can make on a physics engine like this! I hope I don’t have to then switch to C++‘s long double, which has even more precision, that would be insane if I had to go that extreme. I probably would have had to if I didn’t switch from light minutes to light seconds lol.

0
0
4
Open comments for this post

3h 0m 44s logged

I got gravity simulation working! Now the Earth is spinning around the Sun!

I know you can’t see it in the video I posted, but the Earth is there, it’s just that this simulation is drawn to scale, the Earth would actually barely be visible if you were looking from a spacecraft that far away.

This took quite a while because of this one really stupid bug: basically I store all the distance values in light minutes rather than kilometers or miles because otherwise those values would be too big. However, the physics equations that I’m using expect the values to be in meters, not light minutes.

So basically, I forgot to convert from light minutes to meters when calculating the gravity acceleration, so those values were too small to change the velocity of the Earth, causing it to go in a straight line forever.

But now that that is done, I will start adding the rest of the planets and maybe their moons as well to this simulation, then I can look purely at quality of life improvements to improve the interactivity of it.

This project is turning out to be easier than I expected! Hopefully another challenge doesn’t pop up…

0
0
8
Open comments for this post

31m 18s logged

So I got this cool C library called adjust.h setup for hot code reloading. This means that I can update the code while it’s running, and the changes show up in real time! I know that I am making this a web app, but because the module doesn’t work on web, I will prototype the app on desktop for now.

0
0
5
Open comments for this post

1h 28m 31s logged

So in this devlog, I have set up the project with all of its dependencies, it really can take that long when you’re using C++! Right now I just have a basic testing window, but I will quickly fill it in with a preset of the solar system soon, then I’ll be writing physics code for a while.

0
0
6

Delete project?

Are you sure you want to permanently delete this project? This action cannot be undone.

All devlogs, followers, and associated data will be removed.

Followers

Loading…