[extremely minor] Unnecessary addition in SurfaceNets
Jarred-Sumner opened this issue ยท 3 comments
I was looking at your SurfaceNets implementation as an example implementation in use that works, and noticed you're adding 0 here:
NoCubes/src/main/java/io/github/cadiboo/nocubes/mesh/SurfaceNets.java
Lines 217 to 219 in 95c6755
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)
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