Building a voxels field from a Texture2D

First i apologize if my english is bad, i’m gonna try to do the least mistakes as possible.
Hello i’m a student and relatively new to c++, here i’m trying to build a voxels field from a Texture2D(the Texture2D is always in two colors, black (R=0,G=0,B=0,A=255) and white (R=255,G=255,B=255,A=255)), I want my code to be able to detect where he is on the texture and to generate the least possible mesh in my scene, for this i read the texture2D and if the pixel is black then i generate his front face, if his left neighbour is black then i don’t generate his left side, same for right side,top and down side, i never generate the back side because we never need to see it. Actually it work for small image but it instantly crash when image is bigger and i don’t understand why, i need help thx in advance, if you need any information or any question ask and i will answer.

Here is the .c++, .h, the build, the error, the base image and the image i want him to take after

Some suggestions:

  • That crash log is useless. In the Epic Launcher, select your UE4 installation options and install “debug symbols” so you get a proper call stack with function names in your crash logs in order to have at least some idea of where it crashed
  • Provide a lot more information if you want actual help. How are people supposed to tell what is causing a crash without seeing your code? An access violation means you are writing to areas of memory that aren’t allocated, could be an out of bounds array or trying to use an non-initialized pointer or a deleted pointer.