Advertisement
Lucas_3D

Untitled

Aug 10th, 2019
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.20 KB | None | 0 0
  1. fn growToVacantVerts=
  2. (
  3. clearListener()
  4. for vert in (getVertSelection theObj as array) do --for each currently selected vert check
  5. (
  6. if (findItem vacantArr vert != 0) do --if this is a vacant vert then:
  7. (
  8. deleteItem vacantArr (findItem vacantArr vert) --remove the vert from the vacantArr, every vert ultimately is either set as a nonVacant or a tip vert
  9. polyop.setVertSelection theObj vert --select the current vert
  10. initBitArr = #{vert}
  11. theObj.EditablePoly.GrowSelection() --grow the selection and subtract the current vert
  12. neighboursArr = ((getVertSelection $) - initBitArr) as array --select the neigbouring verts
  13. for n in neighboursArr do
  14. (
  15. if (findItem vacantArr n != 0) do --if a valid neigbouring vert is available to be moved into
  16. (
  17. appendIfUnique nonVacantArr vert --then the current vert is now a nonVacant vert and cannot be a tip vert")
  18. appendIfUnique validArr vert --we'll add the current vert to the validArr which we'll then grow off of next
  19. )
  20. )
  21. )
  22. )
  23. polyop.setVertSelection $ (validArr as bitArray)
  24. theObj.EditablePoly.GrowSelection()
  25. tmpArr = polyop.getVertSelection $ as array
  26. polyop.setVertSelection $ (tmpArr as bitArray - nonVacantArr as bitArray)
  27. validArr=#() --reset the arr for the next round
  28. --print some info:
  29. /*("--\n" + nonVacantArr.count as string + " non-vacancies\n" + \
  30. vacantArr.count as string + " Vacant Verts still untouched\n" + \
  31. (polyop.getVertSelection $ as array).count as string + " selected")*/
  32. )
  33. --
  34. theObj = $
  35. polyop.CollapseDeadStructs $
  36. vacantArr = #{1..(polyop.getNumVerts theObj)} as array
  37. nonVacantArr=#()
  38. validArr=#()
  39. closestVert
  40. theDist = 10000.0
  41. for i = 1 to polyop.getNumVerts theObj do
  42. (
  43. a = (polyop.getVerts $ i)[1].z
  44. b = $.min.z
  45. if (a-b) < theDist do
  46. (
  47. theDist = a-b
  48. closestVert = i
  49. )
  50. )
  51. select theObj
  52. max modify mode
  53. subobjectLevel = 1
  54. polyop.setVertSelection theObj closestVert
  55. --
  56. while vacantArr.count > 0 do with undo off with redraw off
  57. (
  58. growToVacantVerts()
  59. if keyboard.escPressed do
  60. (
  61. print "You pressed escape"
  62. exit
  63. )
  64. )
  65. try(polyop.setVertSelection $ (remainingArr = #{1..(polyop.getNumVerts theObj)} - (nonVacantArr as bitArray)))catch()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement