0

I'm using Houdini to create a dungeon generator and I've used Prim (I think) to calculate a Minimal Spanning Tree. Now I would like to introduce one or two loops to make it seem more natural. This is the code:

int pts[]  = expandpointgroup(0, 'unconnected_rooms');  

float dist_min = 100000;   
int pt_0 = -1;
int pt_1 = -1;

foreach(int pt; pts)
{
    vector pos = point(0, 'P', pt);
    int pt_near = nearpoint(0, '!unconnected_rooms', pos);  
    vector pos_near = point(0, 'P', pt_near);   
    float dist = distance(pos, pos_near);
    if(dist < dist_min) 
    {
        dist_min = dist;
        pt_0 = pt;
        pt_1 = pt_near;
    }
}

addprim(0, 'polyline', pt_0, pt_1);
setpointgroup(0, 'unconnected_rooms', pt_0, 0, 'set');

Image of nodes and example of generated paths in dungeon

1 Answers1

0

I've resolved by simply doing the same process with a subgroup of the points (so, basically, I selected a random amount of points) and merged it all together.