scopic Posted August 13, 2020 Share Posted August 13, 2020 Hello, I'm trying to use Unigine::Mesh and Unigine::ObjectMeshDynamic for generating procedural geometry which is supposed to be modified by the user by setting some parameters from UI. So I add surfaces and modify vertices/indices via Mesh class but seems that the drawback of this approach is that every time I do the geometry updates I need to transfer the mesh to ObjectMeshDynamic. The second approach, as I can see, is to submit geometry directly using ObjectMeshDynamic methods (addVertex, addIndex etc) that seem to be using/updating some internal mesh and the geometry update is triggered via flushVertex/Indices calls. My question is, assuming that I'm always building a geometry from scratch during each update, would there be a difference (performance wise) between: a) Modifying Unigine::Mesh and copying it to ObjectMeshDynamic using setMesh method and b) Modyfing mesh directly in ObjectMeshDynamic and triggering updates using flushVertices/Indices call? The only drawback I see so far is that I'm forced to reassign the material and intersection mask to ObjectMeshDynamic when I use the first approach. Material seems to get lost after setMesh call. Thanks in advance Link to comment
silent Posted August 14, 2020 Share Posted August 14, 2020 scopic The only difference between a) and b) is that steMesh is doing always a CPU copy of the mesh. If you don't need it, you can stick with the second approach. Both of them are totally fine for your use-case. Thanks! 1 How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
scopic Posted August 14, 2020 Author Share Posted August 14, 2020 Thanks for your response. What about re-assigning materials after setMesh call? Seems materials are always lost and needs to be assigned again but I guess it is not an expensive operation at all? Link to comment
silent Posted August 14, 2020 Share Posted August 14, 2020 scopic Materials are usually assigned to the mesh surfaces, so when you doing a setMesh you are rewriting the whole mesh data (including the surfaces information). So you need to save the required information and restore (if needed) later. Thanks! 1 How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
Recommended Posts