Future Work

There are a few things in particular that I could improve with my solution, but as I see as out of scope for this project. I don't like that some parameters in the code is hard-coded. Far from everything is hard-coded and I think I have managed to use design-patterns to separate classes rather well in general. However, since I wrote the code somewhat hastily, there are a bit too many parameters hard-coded to make it "work". Something that could have been fixed early on is to not have tiny coordinates, such that there is a huge gap between the x-values x == 1 and x == 2. This caused me to multiply certain values in other parts of the code by a constant in order for them to scale. Also, the OBJ-file which is used for rendering a fox was downloaded for free legally on the internet, but it seems to be made by a hobbyist that made the local vertex coordinates sloppily. Usually OBJ vertex coordinates are between -1 and 1. But these vertices can go to about from 20 to -20. A tip is to only use OBJ files with a common coordinate system in order to have consistency in the code.

Another big thing that should be fixed is how gravitational forces are handled. Each individual particle of an object gets gravitational forces applied to it, which sums up to a rather big value. When two objects collide vertically the gravitational force is much larger than the force from the few particles that collide, so even if an object appears to be still, it's velocity is increasing faster and faster since the gravity accumulates. This causes a bug to happen that the object sinks into the object below due to it's very high speed. When an object collides with the floor I decided to implement a cheat such that the vertical velocity is halved on each contact. This makes it appear realistic, and the goal of this simulation is to fool the viewer and not necessarily have a completely realistic physics simulation.

I could "fix" this by adding a very large repulsive force on impact, but it looks kind of goofy if all the objects bounce all the time.

The source code for this project is freely available on GitHub under the MIT license here.

Kommentarer

Populära inlägg i den här bloggen

Collisions

Optimizing Particles With VBO

Particle Generation