0 votes

I create terrain segments (Mesh and ConcavePolygonShape) in separate worker threads and then assign them to MeshInstance and CollisionShape in scene tree in the main thread. I'm randomly getting these errors and weird problems that look threading-related:

E 0:00:00.571   get: Condition "!id_map.has(p_rid.get_data())" is true. Returned: __null
  <C++ Source>  ./core/rid.h:150 @ get()
E 0:00:00.571   shape_set_data: Condition "!shape" is true.
  <C++ Source>  modules/bullet/bullet_physics_server.cpp:138 @ shape_set_data()

This is what I do in the threads:

var collision_vertices = PoolVector3Array()
collision_vertices.resize(dimensions.x * dimensions.y * 6)

<set up geometry in collision_vectices array>

var shape = ConcavePolygonShape.new()
shape.set_faces(collision_vertices)

The shape is then passed to main thread using call_deferred() and assigned there to CollisionShape existing in scene tree. The errors appear even if I only create the shapes in the threads and don't use them anywhere.

It looks like this happens only if I use more than one worker thread. Documentation warned about accessing same resources from more than one thread but I don't see what is causing the problem here.

in Engine by (71 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.