Closed Jarred-Sumner closed 3 years ago
It is safe to remove it. It represents the "worldOffset". However, I don't always use the world offset so if I do, I add it later on (before use of the vertex).
It's also there to remind me that the -0.5
shouldn't be there at all.
The equation should be simply v[0] = c + x + s * v[0];
(vertexPosition = positionOfChunkInWorld + positionOfCurrentBlockInChunk + interpolationMultiplier * vertexPositionInBlock
).
Because my grid values are sampled at the centre of the block, but are recorded as the values at the corner of the block, I need to offset by +0.5
(I'm not 100% sure this is the reason, I'm guessing based on my limited knowledge of SurfaceNets).
Due to needing to generate the mesh for an extra block on all sides to resolve seams in the mesh, I need to subtract 1 from the mesh (turning +0.5
into -0.5
).
I've somehow accidentally deleted the credit header... that's bad. I didn't write this code from scratch, I copied it from Mikola Lysenko's JavaScript code. I've re-added them + the comments I also deleted
I've documented everything and it seems to make sense (to me) so I'm closing this
I was looking at your SurfaceNets implementation as an example implementation in use that works, and noticed you're adding 0 here: https://github.com/Cadiboo/NoCubes/blob/95c67559fc22169d1bccf0ba843b02932c9016f3/src/main/java/io/github/cadiboo/nocubes/mesh/SurfaceNets.java#L217-L219
I'm not super familiar with Java, but it's likely safe to remove that (assuming this isn't a way of doing type casting)