Jump to content

[SOLVED] Need help with ObjectGrass


photo

Recommended Posts

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

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.

  • Like 1
Link to comment
  • silent changed the title to [SOLVED] Need help with ObjectGrass
×
×
  • Create New...