Ok, i have reached the point where my math skills no longer can support this project. and saying enough is enough, isn’t something to be afraid of.
the main problem lies within how planets are done. their size can basically be said to be e^planet x size. now if you dont know e^x is a stupid fast function, and world sizes are stupid big. approaching the limit of floating point numbers stupid² fast.
normally this wouldnt be this big of a problem since you can map everything around the player. but my code doesnt handle this case for travelling beetwen planets, and thats where the project is stumped right now.
fixing this would require a refactor so big that i might as well remake everything, and honestly i don’t want to do that.
so, that’s why this project wont develop anymore. as for the reason i post that here is so that it wont end up in a mechaenetia like situation where ill say ill develop on it but dont.
no matter, here is what ive learned that might help mechaenetia:
Handle travelling between planets as soon as possible. that stuff will bite you in the ass if you dont prepare.
make sure you start from the top of the planet and go inn, this avoids planets having the size of a googol but, this is a point you need to be extremely vary off so you dont rewrite everything.
i guarantee many things will be rewritten with this system, especially since no one has done this before, so if you do go forward, be prepared for a lot of rewriting
im probably forgetting something. anyways good luck forward on mechaenetia. But be prepared its gonna be helloffa ride.
wazzup, im back from the dead. and currently in the progress of rewritting this into a more simple have everything within a giant struct program. which i personally dont like, BUT daimn it makes everything so much simpler. no matter, here is a tiny progress update
Minor topology thing: If you’re using hexagons for a spherical planet you must have 12 pentagons to add the necessary curvature. However, if you use tori, you can have all hexagons, because donuts have no curvature
In my experience fighting the compiler offten means that you are trying to do something stupid. (and many times its not easily visible that in fact you are wrong) And in the case that you know you are trying to do something correct that the compiler does not understand you can use unsafe code.
I would really miss higher level constructs that C does not know. Perhaps C++ would be more understandable. C++ at least has generics, namespaces, classes and other organizational stuff. C is great for low level code that is small enough and simple enough that you can handle everything yourself, but the same can be said about assembly.
Sure, here’s the source: GitHub - Fyrstikkeske/fyrraria
like any code i write, its all super in development and this is the first time im doing opengl so many things might be wrong, or just done in a bad way.
Now to the fighting the compiler. Rust is to strict, zig is to new and c++ is to bloated.
I looked at the code a liitle bit. I found this piece of code where you are setting the block type to air (at the top) and then doing it again (the last line I coppied) with some code in between that has no effect on the second place where its set to air. Sure, its not an error, it will not cause problems with the program but also its useless.
for (int blockiter = 0; blockiter < chunksize * chunksize * chunksize; blockiter++) {
world[chunkiter][blockiter].type = air;
// Calculate chunk coordinates
int chunkx = chunkiter % Worldx;
int chunky = (chunkiter / Worldx) % Worldy;
int chunkz = chunkiter / (Worldx * Worldy);
// Calculate local block coordinates within the chunk
int localx = blockiter % chunksize;
int localy = (blockiter / chunksize) % chunksize;
int localz = blockiter / (chunksize * chunksize);
// Calculate global coordinates
int globalx = chunkx * chunksize + localx;
int globaly = chunky * chunksize + localy;
int globalz = chunkz * chunksize + localz;
world[chunkiter][blockiter].type = air;
...
About your “Rust is too strict”, maybe you are just not strict enough
So a friend asked what new happened in disktest, i told him i was struggling with rotations due to so much early prototyping stuff, which made the code hard to work with. But the day after his question just randomly popped into my thoughts. so i thought why not just try every combination until rotations finally worked. 3 hours of brute force later and we have this.
the 3d donut version is still being worked on, A new binary mesher has been added for chunks and lods are id say 20% done. theres a couple of issues yet to be figured out, but work is being done.
im not really good at working on the same codebase as other people(youve seen my spagetti first hand and survived), but math might work.
Now what im most having issues with at the moment regarding the 3d planets, is the artifacts coming from the curvature of the donut planet. blocks on the inner ring are much smaller than the outer ring. basically, theres 2 solutions, 1: make the worlds thin and long, this reduces the local curvature since its total is a constant i believe. 2: dynamically change the length of the world based on where the player is. This might also work due to there always being a select height of the world with minamal artifacts. Option 1 is the simplest personally since its the most bang for the buck when it comes to time to implement, and option being limited some other way. But Option 2 will be needed to make a decent build height.
This is the algorythm ive basically ended up with. The inputs are directly from their voxel map position.
Now, im not much of a math person so i dont know if there is a mapping with less artifacts. But from what i understand, there shouldnt be? but then again i reworked the 2d algorythms version 10 times until it worked like i wanted.
i just remembered the one thing that ive struggled with. A proper AABB algorythm for looping worlds which does not create subdivisions of boxes to solve the edge cases. imagine the world should loop in that box. now the to rectangles should in theory touch and push each other. But normal AABB doesnt handle these cases. ive tried a few modifications, but only had succes by dividing the rectangles into multiple rectangles to handle edge cases.
if you find a algorithm which can properly handle looping worlds without making multiple rectangles, id be a huge help.
can you explain it? When you deal with modular arithmetic you can not order numbers, less than or greater than makes no sense. Because modular arithmetic loops numbers, you take a piece of a number line and glue the ends together, then you can not say one number is less than the other, in a way all numbers will be less then all the other numbers (including the compared number) and also all number will be greater than all the other numbers. So for all numbers A and B, A < B and A > B at the same time and that is meaning less and useless.
I am not saying the thing you are saying
I am saying that you only need to check X > A and X < B, so if you check for
X>A and (if (B>M or B<A) then (X%M < B%M or X<M) else X<B)
it DOES work. (M is the boundary to modulo by)
(to be more clear, in your example you are comparing X to A twice, so its useless regardless of modulo as it can never return true ever…)