diff --git a/nodes/spatial/random_points_on_mesh.py b/nodes/spatial/random_points_on_mesh.py index 9f9e5c56f4debd293ec73e8bf6792c40586f7937..bd5673da4ca4609cdfa3c5b649664ebe86333b34 100644 --- a/nodes/spatial/random_points_on_mesh.py +++ b/nodes/spatial/random_points_on_mesh.py @@ -148,22 +148,22 @@ def random_points_on_edges(verts: List[List[float]], edges_dir = v_edges[:, 1] - v_edges[:, 0] weights = get_weights(edges_dir, input_weights, proportional) np.random.seed(seed) - - chosen_edges = np.random.choice(np.arange(len(edges)), + indices = np.arange(len(edges)) + chosen_edges = np.random.choice(indices, random_points_total, replace=True, p=weights) edges_with_points, points_total_per_edge = np.unique(chosen_edges, return_counts=True) - t_s = np.random.uniform(low=0, high=1, size=random_points_total) direc = np.repeat(edges_dir[edges_with_points], points_total_per_edge, axis=0) orig = np.repeat(v_edges[edges_with_points, 0], points_total_per_edge, axis=0) + chosen_indices = np.repeat(indices[edges_with_points], points_total_per_edge, axis=0) random_points = orig + direc * t_s[:, np.newaxis] return (random_points if out_np[0] else random_points.tolist(), - chosen_edges if out_np[1] else chosen_edges.tolist()) + chosen_indices if out_np[1] else chosen_indices.tolist()) class TriangulatedMesh: @@ -313,11 +313,11 @@ class TriangulatedMesh: class SvRandomPointsOnMesh(bpy.types.Node, SverchCustomTreeNode): """ - Triggers: random points vertices + Triggers: Random points on mesh Tooltip: distribute points on given mesh """ bl_idname = 'SvRandomPointsOnMesh' - bl_label = 'Random points on mesh' + bl_label = 'Populate Mesh' sv_icon = 'SV_RANDOM_NUM_GEN' viewer_map = [