http://bugs.winehq.org/show_bug.cgi?id=22918
--- Comment #13 from Henri Verbeet hverbeet@gmail.com 2010-07-16 04:26:03 --- (In reply to comment #12)
D3DXCreateCylinder done: http://github.com/misha680/wine/commit/2900a9cb2aad27c96e4100c6e741466c362cd...
I quickly looked it over, and I've got a couple of points:
- In the expression "sqrt(normal.x * normal.x + normal.y * normal.y) * delta_radius / length;", "sqrt(normal.x * normal.x + normal.y * normal.y)" should be equal to "radius", and "delta_radius / length" is constant for a given cylinder. I.e., conceptually you have "radius * normal_slope". - The code would probably benefit from having a proper structure for the vertex data. E.g.:
struct vertex_data { D3DXVECTOR3 position; D3DXVECTOR3 normal; };
- The caps calculations look a bit forced into the main loop. The code will probably be clearer if you simply calculate those outside the main loop, like you do for indices. Also, note that you can easily define a helper function to generate a ring of vertices with a certain radius, z position and z normal. - "radius_step = (radius2 - radius1) / stacks;" can be simplified to "radius_step = -delta_radius / stacks;". Perhaps it's just as easy to just define it as "delta_radius / stacks" and change "radius += radius_step;" to "radius -= radius_step;" though.