Jump to content

Alternatives to using promote to detail


shadowst17

Recommended Posts

Hi guys, I was wondering if anyone had any suggestions on faster ways to get one attribute value to change a group of other attributes with the same name attribute. The usual method suggested is to use a for each node with the promote to detail set to max or min and then promote back to point. This is incredibly slow and the bottle neck for my setup. Anyone got suggestions on alternatives that are faster with the same outcome?

 

 

Edited by shadowst17
Link to comment
Share on other sites

Just now, bonsak said:

Why do you need to use a for each for this?

Seems to be the most common method for getting entire pieces when only a few points have been selected. Guess it's fine if it's a one off but I need a method that works efficiently on every frame.

Link to comment
Share on other sites

1 hour ago, bonsak said:

If you could set an attribute up stream to identify what parts of your geo you want to operate on, you might not need to use a for each.

-b

 I did think about that, I might try and have an array on each point of every other point that is in this piece.

1 hour ago, ThomasPara said:

do you have an example file?

Here you go, quickly cobbled it together.

example.hip

Edited by shadowst17
Link to comment
Share on other sites

Just use a point wrangle after "attribcreate1" with this: 

 

//list all points in the group
int hit[] = expandpointgroup(0,"group1");
@Cd = {0,0,0};

//run over points that ar not in the group so @hit = 0
if(@hit == 0){
    //do something for each element of the array hit[]
    foreach(int i; hit){
        //take ID of the current element array
        int grp_id = point(0,"ID",i);
        //if the ID of the point is the same ID of this element of the array then also this point is @hit = 1;
        if(grp_id == @ID){
            @Cd = {1,0,0};
            i@hit = 1;
        }
    }
}

 

Edited by Andrea
  • Thanks 1
Link to comment
Share on other sites

//set the wrangle to run over group1

int count = findattribvalcount(0,"point","id",i@id); //find how many points that have the same id

for(int i = 0;i<count;i++){ //run over the points and set the color or any attribute of your likeing
    int found = findattribval(0,"point","id",i@id,i); 
    vector color = set(1,0,0);
    setpointattrib(0,"Cd",found,color,"set");
    }

example_fix.hip

  • Thanks 1
Link to comment
Share on other sites

4 hours ago, Andrea said:

Just use a point wrangle after "attribcreate1" with this: 

 


//list all points in the group
int hit[] = expandpointgroup(0,"group1");
@Cd = {0,0,0};

//run over points that ar not in the group so @hit = 0
if(@hit == 0){
    //do something for each element of the array hit[]
    foreach(int i; hit){
        //take ID of the current element array
        int grp_id = point(0,"ID",i);
        //if the ID of the point is the same ID of this element of the array then also this point is @hit = 1;
        if(grp_id == @ID){
            @Cd = {1,0,0};
            i@hit = 1;
        }
    }
}

 

 

Just now, ThomasPara said:

//set the wrangle to run over group1

int count = findattribvalcount(0,"point","id",i@id); //find how many points that have the same id

for(int i = 0;i<count;i++){ //run over the points and set the color or any attribute of your likeing
    int found = findattribval(0,"point","id",i@id,i); 
    vector color = set(1,0,0);
    setpointattrib(0,"Cd",found,color,"set");
    }

example_fix.hip

Thanks guys these have been really helpful!

Link to comment
Share on other sites

Heres a version thats faster than the for-each, its some more nodes to make that happen. The wrangles "minimize_search", "find_unique", "set_search", and "set_color" has a combined time of around 1 sec, while the foreach is around 13 sec.

This runs over 5 mill points

image.png.22888e0f1ff9d95caf1fdfc1143bd3b6.png

example_fix_02.hip

Edited by ThomasPara
  • Thanks 1
Link to comment
Share on other sites

If you set the scatter to 30000 points for example, the wrangle is twice as fast as the for each node version.

-b

EDIT: This was when testing the example-fix.hip

Edited by bonsak
Link to comment
Share on other sites

35 minutes ago, ThomasPara said:

Heres a version thats faster than the for-each, its some more nodes to make that happen. The wrangles "minimize_search", "find_unique", "set_search", and "set_color" has a combined time of around 1 sec, while the foreach is around 13 sec.

This runs over 5 mill points

example_fix_02.hip

Excellent! This is even better, thank you.

Link to comment
Share on other sites

  • 1 year later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...