Jump to content
shadowst17

Alternatives to using promote to detail

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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!

Share this post


Link to post
Share on other sites

just tested theese solutions, and none of them are faster than the for-each, think this needs a new iteration

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

If you're using H17, there's a much easier approach that's also a lot faster than the other solutions - just turn on the Use Piece Attribute toggle on Attrib Promote

example_fix_03.hip

  • Like 1
  • Thanks 3

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×