**optimisation**

This idea is so simple, soooo logical. I have not seen this in other patches, so it might be usefull for you as well…

after all, it makes deworm some 30% easier for CPU.

Let me explain this using one example.

Let’s say we have 100 sections of deworm. Each section is made of 20 vertices. Total slice count is 6000 (20*100*3)

Each section has to be rotated and positioned, so we are rotating and moving groups of 20 vertices by the same values.

We have two spreads, one with Pitch, Yaw, Roll rotation vectors and one with translation vectors. Each with 300 slices (100*3)

Since we have to use the same rotation and position vectors for groups of 20 vertices we need to resample those vector spreads so to rotate and translate each vertex.

Something like this:

This works and it is not so bad for simple translation. But think about rotation. We would have to create 2000 transformations (that are 16 slices matrices) before we could apply them to the spread of vertices.

It seems so obvious to me now that it is much better to rearrange the spread of vertices and use minimal number of transformations that would cycle through new spread. We need to reorder the spread so to have: vertex 1, vertex 21, vertex 41… through 81, then vertex 2, 22, 42… and so on.

After we apply transformations we have to reorder the spread of vertices back to original order.

Here it is:

I might have discovered that ‘the earth is not flat’ here. Nevertheless it is OK to have this method documented.

o_0!