Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #4976. Node "Voronoi on Solid" produce incorrect results. #4977

Merged

Conversation

satabol
Copy link
Collaborator

@satabol satabol commented Aug 13, 2023

fix #4976. Update node "Voronoi on Solid":

  • update using Voronoi. Get new cells for border cells.
  • update parameter inset (now it use distance. Before was percent.)

Description of fix:

Source algorithm of node "Voronoi on Solid" try to use closed cells of voronoi (1) for source sites but not all sites are closed. So old algorithm add bounding box points to sites (2):
image
This produce closed sites that was opened but this is produce some disturbing actions to source sites and some areas of bounding box are still opened. This can produce some glitches:
image

In other cases it can produce other glitches (view of Voronoi sites):
image
Result look unpredictable:
image

So I have a proposal:

  1. Do not use inset as percentage
  2. Modify algorithm of getting voronoi closed cells to get cells that fill bounding box of source solid

Combine 1 and 2 with function voronoi_on_mesh_bmesh. Bounding box exceed solid bounding box for 1 in all directions:
image

and now results looks good.

- update using Voronoi. Get new cells for border cells.
- update parameter inset (now it use distance. Before was percent.)
@satabol satabol requested a review from portnov August 13, 2023 13:26
('MEAN', "Barycenter", "Scale each region relative to it's barycenter, i.e. average location of it's vertices", 1)
]

scale_center : EnumProperty(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not used anymore as far as I understand?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not used anymore as far as I understand?

Yes. It is not used more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed


def draw_buttons_ext(self, context, layout):
self.draw_buttons(context, layout)
layout.prop(self, 'scale_center')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and this also.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed. removed.

layout.prop(self, 'scale_center')
layout.prop(self, 'accuracy')

def scale_cells(self, verts, sites, insets, precision):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed. scale_center removed.

y_min, y_max = box.YMin - clipping, box.YMax + clipping
z_min, z_max = box.ZMin - clipping, box.ZMax + clipping
bounds = list(itertools.product([x_min,x_max], [y_min, y_max], [z_min, z_max]))
verts, edges, faces = voronoi_on_mesh_bmesh(bounds, [ [0,1,3,2], [2,3,7,6], [6,7,5,4], [4,5,1,0], [2,6,4,0], [7,3,1,5] ], len(sites), sites, spacing=inset, mode='VOLUME' )
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

numbers in brackets look magic :)
I'd suggest to assign them to a separate variable and add a comment about what is this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What brackets? If an argument for voronoi_on_mesh_bmesh then it is a cube faces that is a bounding box.

@satabol
Copy link
Collaborator Author

satabol commented Aug 13, 2023

Description of fix:

image

1. remove unused elements
2. fix exception in a case with no fragments (cites)
@satabol satabol force-pushed the fix_4976_node_voronoi_on_solid_produce_incorrect_result branch from 9f3875c to d17d373 Compare August 13, 2023 15:01
@portnov
Copy link
Collaborator

portnov commented Aug 13, 2023

now it's ok with me :)

@satabol satabol merged commit c8e0c4b into master Aug 13, 2023
2 checks passed
@satabol satabol deleted the fix_4976_node_voronoi_on_solid_produce_incorrect_result branch August 13, 2023 15:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Node "Voronoi on Solid" produce incorrect results.
2 participants