Remove constraint by @P.y not working
4837 11 1- seeplus
- Member
- 33 posts
- Joined: Nov. 2019
- Offline
Hi,
thanks for reading my post,
I'm trying to remove constraints when they reach a certain position like (@P.y). I'm using the rbd bullet solver sop. It seems that @P for constraints not updating from frame to frame but it only reads the initial position. I'm attaching a hip file.
This is my code:
if (@P.y > 2) {
removeprim(0,@primnum,0);
}
Thanks for your precious help
thanks for reading my post,
I'm trying to remove constraints when they reach a certain position like (@P.y). I'm using the rbd bullet solver sop. It seems that @P for constraints not updating from frame to frame but it only reads the initial position. I'm attaching a hip file.
This is my code:
if (@P.y > 2) {
removeprim(0,@primnum,0);
}
Thanks for your precious help
Edited by seeplus - March 17, 2021 16:49:28
- mrCatfish
- Member
- 734 posts
- Joined: Dec. 2006
- Offline
I'm not sure why it doesn't work... it seems to be evaluting only at the first frame. I unlocked it and put your code here and it works:
EDIT: Ooops... used a pop wrangle instead of point wrangle, but it works anyway.
EDIT: Ooops... used a pop wrangle instead of point wrangle, but it works anyway.
Edited by mrCatfish - March 18, 2021 11:40:35
Sean Lewkiw
CG Supervisor
Machine FX - Cinesite MTL
CG Supervisor
Machine FX - Cinesite MTL
- seeplus
- Member
- 33 posts
- Joined: Nov. 2019
- Offline
mrCatfish
I'm not sure why it doesn't work... it seems to be evaluting only at the first frame. I unlocked it and put your code here and it works:
EDIT: Ooops... used a pop wrangle instead of point wrangle, but it works anyway.
Thanks of your valued help, mrCatfish. I've tried to do as you prescribed but it removes primitive and constraints but I need to delete only the constraints.
What I exactly need is when a constraint reaches a position > remove it.
Edited by seeplus - March 18, 2021 16:20:10
- mrCatfish
- Member
- 734 posts
- Joined: Dec. 2006
- Offline
- seeplus
- Member
- 33 posts
- Joined: Nov. 2019
- Offline
mrCatfish
I don't understand... by removing the primitive, you are removing the constraint. I played it and it seemed to work, maybe I don't understand what you're trying to do.
I really appreciate your reply. I'm sorry I wasn't clear and I think I'm not doing it the right way. I'm attaching the updated hip file. You can notice the constraints are removed but the geo returns to its initial position.
Edited by seeplus - March 20, 2021 07:25:00
- mrCatfish
- Member
- 734 posts
- Joined: Dec. 2006
- Offline
- Noboru
- Member
- 6 posts
- Joined: May 2021
- Offline
I wanted to do something similar with the RBD SOP wrapper only I wanted to delete constraints with an animated bounding sphere. This works in a custom network but I'm having trouble getting it to work with the RBD tools. I tried going into the constraint solver node in that same screenshot you posted. How can I art direct deleting constraint primitives directly in the RBD wrapper?
I was able to fix it.
I was able to fix it.
Edited by Noboru - Oct. 15, 2021 12:55:42
- tamte
- Member
- 8853 posts
- Joined: July 2007
- Online
Noboruideally you would not need to dive in or modify internals of Bullet Solver SOP
How can I art direct deleting constraint primitives directly in the RBD wrapper?
you should be able to do a lot using VEXpression in Constraints/Breaking Thresholds tab
you can check the dropdown presets, one of them is Delete In Proximity Of SOP Geometry for example
Tomas Slancik
FX Supervisor
Method Studios, NY
FX Supervisor
Method Studios, NY
- IvanGN
- Member
- 3 posts
- Joined: July 2014
- Offline
- npetit
- Staff
- 417 posts
- Joined: Feb. 2008
- Offline
seeplus
I'm trying to remove constraints when they reach a certain position like (@P.y). I'm using the rbd bullet solver sop. It seems that @P for constraints not updating from frame to frame but it only reads the initial position. I'm attaching a hip file.
This is my code:
if (@P.y > 2) {
removeprim(0,@primnum,0);
}
You're right, while the visualisers transform the constraints in order to help make sense of the constraints and how they relate to the RBD pieces, constraint geometry positions don't get updated during the sim which is why using @P.y in your case doesn't work as you'd expect.
You may want to instead lookup the constrained piece's positions in order to get the updated positions.
int pts[] = primpoints(0, @primnum); string name1 = point(0, "name", pts[0]); string name2 = point(0, "name", pts[1]); int pt1 = findattribval(1, "point", "name", name1); int pt2 = findattribval(1, "point", "name", name2); vector P1 = point(1, "P", pt1); vector P2 = point(1, "P", pt2); vector pos = (P1 + P2) * 0.5; if (pos > 2) removeprim(0, @primnum, 1);
Noboru
I wanted to do something similar with the RBD SOP wrapper only I wanted to delete constraints with an animated bounding sphere.
The RBD Bullet Solver's input constraints are assigned a __primid int attribute and the 4th input to the wrangle which runs the VEXpressions points to that input constraint geometry. This allows you to lookup the input constraints using this __primid attribute to read animated attributes if needed.
To delete constraints with an animated bounding sphere you can do it by using an attrib transfer to transfer an attribute onto the constraints that you can then lookup to delete the constraints - to do this for example, updating a Cd prim attribute:
int primnum = findattribval(3, "prim", "__primid", i@__primid); @Cd = prim(3, "Cd", primnum); if (@Cd.x > 0) removeprim(0, @primnum, 1);
You can also do it by using the SOP geometry directly. In order to do this, make sure the VEXpression SOP Path parameter points to the SOP geometry you want to evaluate, then in the VEXpression snippet
float maxdistance = 0.3; int pt = nearpoint(2, @P); vector P = point(2, "P", pt); if (distance(P, @P) < maxdistance) removeprim(0, @primnum, 1);
Here's a hip file with the various examples.
- npetit
- Staff
- 417 posts
- Joined: Feb. 2008
- Offline
The RBD Bullet Solver in 19.0 now gives access to both the pre-solve and post-solve in the embedded editable subnet. This allows you to fully customise it without having to edit the HDA.
We've also added a macro to create a SOP solver which is configured to edit both the geometry and constraint geometry at the same time. Hit tab > SOP Solver (constraint geometry). This simplifies setting up the SOP Solver using the "Invoke Compiled Block" option to target multiple outputs at the same time.
Here's an example of using a SOP solver to delete the constraints when they drop below 0. Select the RBD Bullet Solver and hit enter to dive inside.
We've also added a macro to create a SOP solver which is configured to edit both the geometry and constraint geometry at the same time. Hit tab > SOP Solver (constraint geometry). This simplifies setting up the SOP Solver using the "Invoke Compiled Block" option to target multiple outputs at the same time.
Here's an example of using a SOP solver to delete the constraints when they drop below 0. Select the RBD Bullet Solver and hit enter to dive inside.
- IvanGN
- Member
- 3 posts
- Joined: July 2014
- Offline
-
- Quick Links