Jump to content

primgroup in xyzdist() issue


Juraj

Recommended Posts

Hello,
I am trying to remove overlapping polygons - I want to do so by computing distance to other polygons using xyzdist(). So I want to specify primgroup which will contain all, but current primitive, so that It is not returning distance to itself. According to documentation, I should pass group string which matches general SOP syntax. So for polygon number 240, primgroup parameter should be "* ^240". When I pass this parameter to the function, it returns -1 in found primitive - no primitive found.

I think that the error is causing by this primgroup parameter. If I pass for example "*", then there is also no primitive found. How can I use patterns to define group inside this function? Like 0-50, *, ...

 

This is from the docs:

The name of a primitive group or a pattern to generate a primitive group. Uses the same semantics as a SOP group, so empty strings will match all primitives. 

 

Any ideas how to make this pattern working?

 

Juraj

Link to comment
Share on other sites

For now I did it another way, since it is only in 2d, I achieved it with this code.

 

int primnum = pointprims(0, @ptnum)[0];

float offset = 0.00001;
float dist;
int prim;
vector uv;

int myself = 1;

dist = xyzdist(0, v@P + set(offset, 0, 0), prim, uv);
if (prim != primnum) myself = 0;
dist = xyzdist(0, v@P + set(-offset, 0, 0), prim, uv);
if (prim != primnum) myself = 0;
dist = xyzdist(0, v@P + set(0, 0, offset), prim, uv);
if (prim != primnum) myself = 0;
dist = xyzdist(0, v@P + set(0, 0, -offset), prim, uv);
if (prim != primnum) myself = 0;

if (!myself) {
    //v@Cd = {1,0,0};
    i@inside = 1;
}

 

I then promote inside attribute to primitives (using minimum operation) and then blast primitives with inside == 1

But still curious, how to make it working with primgroup option.

Link to comment
Share on other sites

Hi, thanks! It works.

int prim;
vector uv;
int firstPt = primpoint(0, @primnum, 0);
vector firstPtP = point(0, "P", firstPt);
string grp = "!* ^"+itoa(@primnum);
float dist = xyzdist(0, grp, firstPtP, prim, uv, 0.0000001);

if (prim != -1) v@Cd = {1,0,0};

However performance is much slower then the previous way. Instant cook vs 4 seconds in this case, maybe using this primgroup parameter is not that efficient.

 

I am still curious about this syntax !* ^240 - how would you explain it?
* ^240 means: check against everything, but primitive 240
! means inversion, like in blast sop: delete non selected, so wouldnt it negate the * symbol? Like that:  !* == (nothing)
However, if I leave out !*, then it doesn't work.  Hmm...
 

Link to comment
Share on other sites

On 2/9/2017 at 8:07 AM, Juraj said:

...

I am still curious about this syntax !* ^240 - how would you explain it?
* ^240 means: check against everything, but primitive 240
! means inversion, like in blast sop: delete non selected, so wouldnt it negate the * symbol? Like that:  !* == (nothing)
However, if I leave out !*, then it doesn't work.  Hmm...
 

using !* is dangerous as what it really means is 'all primitives that are not in any group', so if you have any primitive groups, it will automatically break for your case

so instead of !* ^240

just use !240

Edited by anim
  • Like 1
Link to comment
Share on other sites

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...