murathan altunsoy Posted January 13, 2017 Share Posted January 13, 2017 (edited) I'm making practice with vex code .I wrote short script but Its working very slow .Did i make mistake ? or Is this normal speed ? Also i did same thing wtih delete sop but I think Its not correct . backface_delete_2.hip Edited January 13, 2017 by murathan altunsoy Quote Link to comment Share on other sites More sharing options...
Skybar Posted January 13, 2017 Share Posted January 13, 2017 Well you are looping a lot, so yes it will be slow with that approach. Here's a simplified version I did quick: backface_delete_2_dv.hip 1 Quote Link to comment Share on other sites More sharing options...
f1480187 Posted January 13, 2017 Share Posted January 13, 2017 (edited) You don't need last cycle. It's repeating same thing N times. Delete it and everything will work fast. For the minor improvements, there is no need to expand all points into 0..@numpt range array simply to iterate over it. Use regular for loop. uzak doesn't need to be array to find minimum from it. Override existing minimum inside loop. float uzak = 1; for (int i = 0; i < npoints(1); i++) { vector pos = point(1, "P", i); float query = dot(@N, normalize(@P - pos)); uzak = min(uzak, query); } if (uzak > 0) removepoint(0, @ptnum); uzak.hipnc Edited January 13, 2017 by f1480187 1 Quote Link to comment Share on other sites More sharing options...
murathan altunsoy Posted January 13, 2017 Author Share Posted January 13, 2017 30 minutes ago, Skybar said: Well you are looping a lot, so yes it will be slow with that approach. Here's a simplified version I did quick: backface_delete_2_dv.hip thank you David .Your solution is differnt approach Quote Link to comment Share on other sites More sharing options...
murathan altunsoy Posted January 13, 2017 Author Share Posted January 13, 2017 18 minutes ago, f1480187 said: You don't need last cycle. It's repeating same thing N times. Delete it and everything will work fast. For the minor improvements, there is no need to expand all points into 0..@numpt range array simply to iterate over it. Use regular for loop. uzak doesn't need to be array to find minimum from it. Override existing minimum inside loop. float uzak = 1; for (int i = 0; i < npoints(1); i++) { vector pos = point(1, "P", i); float query = dot(@N, normalize(@P - pos)); uzak = min(uzak, query); } if (uzak > 0) removepoint(0, @ptnum); uzak.hipnc Thank you F1. This is really good answer. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.