smirnov.oleg Posted February 25, 2019 Share Posted February 25, 2019 Hi. So I'm trying to make a simple grass painting tool, using Image mask with ObjectGrass parented to global terrain object. First of all I load mask image using img->load("path") function, then in update() use img->set2D function of Image class to change the mask. And after that do: grass->setMaskImage(img, 0); grass->invalidate(); to regenerate or "update" grass. It works just as i expected, but sometimes it crashes at setMaskImage() or invalidate(). What am i doing wrong here? Code is attached ObjectGrass.zip Link to comment
smirnov.oleg Posted February 25, 2019 Author Share Posted February 25, 2019 In addition I tried ObjectMeshClutter. The same error "0xC0000005: Access violation reading location" is happening after of few minutes of 'painting'. Link to comment
andrey-kozlov Posted February 26, 2019 Share Posted February 26, 2019 Hello Oleg, ObjectGrass uses the mask in a separate thread when AppWorldLogic modifying it in the main thread that leads to a race condition. Consider a ping-pong scheme for a mask modification: one mask is set to ObjectGrass and the other one is in modification and the modification is applied by swapping. 1 Link to comment
smirnov.oleg Posted February 26, 2019 Author Share Posted February 26, 2019 Thanks Andrey. Swapping helped. Link to comment
Recommended Posts