Very cool.
What kind of crashes do you mean though, as lua scripts shouldn't be able to crash LDCad in any way.
Some optimizations for you to consider:
- use bounding sphere tests
- avoid wrapper functions like your vsub and vcross etc, while being more readable it will cause more work for the scripting engine.
- use relative data (transform the test intersection line instead of the mesh data), this will avoid having to transform all mesh data and you only need to store information for unique meshes.
Some api extensions that might be useful:
- query mesh bounding information (this is known data inside LDCad and contains all min/max coords you are gathering I think).
- line intersects mesh test function (there is tons of intersection test code inside LDCad, these will also do a sphere/box test before looping all poly's)
What kind of crashes do you mean though, as lua scripts shouldn't be able to crash LDCad in any way.
Some optimizations for you to consider:
- use bounding sphere tests
- avoid wrapper functions like your vsub and vcross etc, while being more readable it will cause more work for the scripting engine.
- use relative data (transform the test intersection line instead of the mesh data), this will avoid having to transform all mesh data and you only need to store information for unique meshes.
Some api extensions that might be useful:
- query mesh bounding information (this is known data inside LDCad and contains all min/max coords you are gathering I think).
- line intersects mesh test function (there is tons of intersection test code inside LDCad, these will also do a sphere/box test before looping all poly's)