Guest User

Pseudocode

a guest
May 31st, 2020
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. Make a cube grid along the mesh of the model, the size of them
  2. being inverse proportion of vertex density times a constant
  3. (resolution chosen by user)
  4.  
  5.  
  6. 0 < t < number of threads
  7.  
  8. Choose t of the cubes, lock them as a in-use resource, assign them
  9. to a cube from the grid and project
  10. it to the mesh in a way that you get a single plane.
  11.  
  12. In the first iteration the grid can be moved to match better the first
  13. created plane
  14.  
  15. Now starts a loop that can be multithreaded:
  16.  
  17. For every edge of the original mesh that intercepts the plane,
  18. get the vector of the edge, and record it.
  19.  
  20. If two vertex have no direct path trough the plane:
  21. split the cube into smaller cubes, leaving the non-connected sub-groups
  22. in these smaller cubes, and leave those cubes for later iterations
  23.  
  24.  
  25. My approach would be to hash the xyz direction of the vector into a hashmap/array
  26. of 6 pre-defined groups (+x, -x, +y, -y, +z, -z) and make the
  27. arithmetic mean of the vectors that land in each position.
  28.  
  29. Once done, for each non-connected edge of the final mesh's edges,
  30. check every neighbour voxel:
  31.  
  32. If it already has a face:
  33. If the angle between the calculated vector and the ocupied face's closest
  34. edge is big enough (i guess greater than around -20º):
  35. extrude a new face
  36.  
  37. If the angle is not too big (i guess less than around 20º):
  38. connect the adjacent edges
  39.  
  40. Otherwise:
  41. If the distance between the edges is too small:
  42. merge them at center
  43. Otherwise:
  44. create a new face from the two edges
  45.  
  46. Otherwise, if there is no face nearby:
  47. Extrude the face
  48.  
  49.  
  50. Once you have a face created:
  51. unlock the in-use cube
  52. lock the nearest cube
  53. assign the new created face to that nearest cube
Advertisement
Add Comment
Please, Sign In to add comment