Eldemarkki / Marching-Cubes-Terrain

Marching Cubes terrain implementation in Unity using the Job System and the Burst compiler
MIT License
565 stars 80 forks source link

Unable to deform certain chunks #41

Closed ThisUserIsNobody closed 4 years ago

ThisUserIsNobody commented 4 years ago

After I switched the terrain to generate using 3D noise, I encountered deformation issues. Some chunks are not deformable. When I try to deform the chunk terrain becomes darker but nothing gets changed. They entire chuck seems like flickers or something. And other chunks works as they should. It's really strange..

issue

Eldemarkki commented 4 years ago

That is very strange indeed... did you change anything else anywhere in the code (or the scene) other than the CalculateVoxelData() function? Because changing that function should not break anything.

Eldemarkki commented 4 years ago

I've managed to reproduce a similar type of bug, and I believe that what you are seeing is caused by it. It happens when you repeatedly go back and forward between chunks, causing the generation of new chunks/removal of old chunks, but the new chunks don't get registered/old chunk's don't get removed visually.

Eldemarkki commented 4 years ago

I created a hotfix to the master branch that should fix this. Could you please try and see if you can still reproduce the bug after pulling the changes?

ThisUserIsNobody commented 4 years ago

Will take a look!

ThisUserIsNobody commented 4 years ago

After I updated the project I started to receive this error message whenever I would press play on both demo scenes (heightmap and procedural).

--

Unexpected exception Burst.Compiler.IL.CompilerException: Error while verifying module: Call parameter type does not match function signature! %26 = load i8, i8* %var.2 i32 call void @"$___check_bounds"(i8 %26, i32 256)

at Burst.Compiler.IL.NativeCompiler.Compile () [0x001d9] in <0a91b9ecc469494eb1ac29fa079c9115>:0 at Burst.Compiler.IL.Jit.JitCompiler.CompileMethodInternal (Burst.Compiler.IL.Jit.JitResult result, System.Collections.Generic.List`1[T] methodsToCompile, Burst.Compiler.IL.Jit.JitOptions jitOptions) [0x00224] in <0a91b9ecc469494eb1ac29fa079c9115>:0 at Burst.Compiler.IL.Jit.JitCompiler.CompileMethods (Mono.Cecil.MethodReference[] methodReferences, Burst.Compiler.IL.Jit.JitOptions jitOptions) [0x00254] in <0a91b9ecc469494eb1ac29fa079c9115>:0 at Burst.Compiler.IL.Jit.JitCompiler.CompileMethod (Mono.Cecil.MethodReference methodReference, Burst.Compiler.IL.Jit.JitOptions jitOptions) [0x0001c] in <0a91b9ecc469494eb1ac29fa079c9115>:0 at Burst.Compiler.IL.Jit.JitCompilerService+CompilerThreadContext.Compile (Burst.Compiler.IL.Jit.JitCompilerService+CompileJob job) [0x00396] in <0a91b9ecc469494eb1ac29fa079c9115>:0

While compiling job: System.Void Unity.Jobs.IJobParallelForExtensions/ParallelForJobStruct`1::Execute(T&,System.IntPtr,System.IntPtr,Unity.Jobs.LowLevel.Unsafe.JobRanges&,System.Int32) at :line 0

Eldemarkki commented 4 years ago

Uh oh. Could you post the CalculateVoxelData and OctaveNoise functions here? Also, did you do any other changes to the code (you can list the files that have changes using git diff --name-only)

I didn't get any errors when there are no changes.

ThisUserIsNobody commented 4 years ago

So I managed to fix this issue, by upgrading the burst package and re-importing the libraries. I'm not receiving any errors anymore. The burst package needed to be in version 1.3.3. It was required by the collection package which was imported by the jobs system.

I used the same noise settings and have generated a 3D terrain. Did some playtesting, but wasn't able to reproduce the previous deformation bug, so I believe it's fixed!

Eldemarkki commented 4 years ago

Good! Not sure why it didn't upgrade for you because in manifest.json the burst package is version 1.3.3. But everything seems to be ok now, so I'm closing the issue.