Jump to content

Runtime add surfaces on static/skinned mesh


photo

Recommended Posts

Hi,

 

When you add function addMeshSurface, it must be done with unique flag, when create ObjectMeshStatic/Skinned in constructor and do it only in main thread, becouse on the end of frame, engine send this mesh to graphic card.

 

I try on 2.5 call addMeshSurface function on ObjectMeshSkinned created in init function with unique flag to set true via Async class and on end call flushMesh function in unigine script.

It works, the target mesh get added surafces and engine render it fine.

 

So i have some question for confirm how addMeshSurface work now.

 

Questions:

1) Must be created ObjectMeshStatic/Skinned (loaded from Node file) with unique flag = true in main thread or can be create in sync thread or async thread?

2) It save call addMeshSurface on ObjectMeshStatic/Skinned in sync thread or async thread?

3) When i should call flushMesh on ObjectMeshStatic/Skinned?

 

I try move working with surfaces on mesh outside of main thread for optimalization fps.

 

Thanks for answers.

Honya

 

 

Link to comment

Hi,

 

First of all, you are correct in a call sequence: ctor with unique flag, addMeshSurface, flushMesh. FlushMesh flushes the geometry on gpu and it must be called manually if geometry was edited.

 

Unfortunately neither of these 3 methods are thread save.

- Node::ctor can be called from within the main thread, but to be rendered, you must call setEnabled(1) in main thread.

- AddMeshSurface is not thread save, and may lead to undefined behavior (because it adds surface instance while render can read it)

- FlushMesh can only be called from main thread because of single threaded gpu context.

Link to comment
×
×
  • Create New...