0
$\begingroup$

I have 2 different meshes with roughtly the same amount of faces/verts. In the first case I only have 1 object in blend file, in second case around 80. This is the only difference I can think of, in both cases verts don't have any layers associated with them, and no other things I can think of.

I'm running a script on both, that add roughly the same amount of vertices. I was measuring only the calls to mesh.verts.new(), and the results were quite funny. In the first case creating roughly 200k verts took 3.5 seconds, in second case 45.5 seconds.

So the question is, what can cause such a huge difference in performance when doing something as basic as adding a vertex?


edit

The script is pretty straightforward, I'm grabbing a mesh by calling bmesh.from_edit_mesh(), then according to some logic (which is irrelevant, since I'm measuring only calls to mesh.verts.new) I call mesh.verts.new around 200k times, then I call bmesh.update_edit_mesh. So that's 1 update total. Basically it's a subdivide operator I wrote, because my mesh is a hexagonal grid and blender doesn't cope well with subdividing hexagons

$\endgroup$
  • $\begingroup$ Please show your script or some synopsis of how many times you are updating the screens in update() or by user operations. There are discussions here at BSE about performance related to updating the screen minimally. When performance is important and has degraded you may choose to switch you style of script to reduce updates to close to 1 update. You may need to inspect your python/algorithm for performance which might come in flavors of time proportional to N, N * N, N *lg(N), or other, where N is the number of vertices. $\endgroup$ – atomicbezierslinger Dec 27 '15 at 20:34
  • $\begingroup$ The script is pretty straightforward, I'm grabbing a mesh by calling bmesh.from_edit_mesh(), then according to some logic (which is irrelevant, since I'm measuring only calls to mesh.verts.new) I call mesh.verts.new around 200k times, then I call bmesh.update_edit_mesh. So that's 1 update total. Basically it's a subdivide operator I wrote, because my mesh is a hexagonal grid and blender doesn't cope well with subdividing hexagons $\endgroup$ – user1617735 Dec 27 '15 at 20:57
  • $\begingroup$ Straightforward is when it gets scary. $\endgroup$ – atomicbezierslinger Dec 27 '15 at 21:46
  • $\begingroup$ Can from_pydata be used for modifying an existing mesh, or only creating new one? $\endgroup$ – user1617735 Dec 28 '15 at 5:48
  • $\begingroup$ from_pydata expects an empty mesh. $\endgroup$ – zeffii Dec 28 '15 at 12:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.