Jump to content

Bullet - dynamic constraint creation

Recommended Posts

Hi guys,

It's been a while since I had to use constraints and I was hoping somebody can help me out here :)
I'm trying to dynamically fracture 2 boxes that are constraint to 2 static boxes. I then want to delete the old constraints on the fly (that part works but for some reason it happens one frame too late, why?) and constrain the new frags to each other. This part doesn't work at all :) I'm using the technique described in the file above, but for some reason my constraints go haywire.
I hard-coded the first box to refracture on frame #30, the second box does the same on frame #60.

Hip file and screenshots are attached, thanks so much for taking a look!






Share this post

Link to post
Share on other sites

1. the 1f offset may have something to do with evaluation of the constraints if they are nor attached to an object, which is once per dopnet substep

if you want it more precisely (during Bullet substeps) you will need to check Attach Internal Constraint to object and connect it just after object, but then you will have to have your active and passive rbds part of a single object, so a bit of rearranging the setup, but regardles at least it sort of works

2. seems like intrinsic transform is not reliable way to assume the initial pose, so I'd go back to using p@orient and v@pivot attributes as described at the beginning of this thread

something like this:

int found_pt = findattribval(1, "point", "name", s@name);
if(found_pt != -1){    
    vector pivot = point(1, "pivot", found_pt);
    vector P = point(1, "P", found_pt);
    vector4 orient = point(1, "orient", found_pt);
    orient = qinvert(orient);
    v@P = qrotate(orient, v@P - P) + pivot;
    p@orient = orient;

also I made sure @restlength is initialized and computed in your file as it's necessary for spring constraint

and switched f@strength attrib to prim as it's per constraint

and also added switch to Soft constraint if you want to use that instead and tweak strength maybe as its much more stable than spring and has greater range of stiffness (I included f@stiffness prim attrib that controls it instead of f@strength which controls spring one)

I may have changed something else while playing (I temprarily replaced your primcenter HDA as it was not embedded)




- alternatively you can also have the fragments glued together from the beginning and have the spring or soft constraints set as secondary constraints (s@next_constraint_name and s@next_constraint_type), then just break the glue when you need or with impacts and it should switch to secondary ones even during substeps 

  • Like 2
  • Thanks 1

Share this post

Link to post
Share on other sites

Hey Thomas,

Good to hear from you and thanks for chiming in!
I really appreciate you taking the time to answer this, that was a huge help. And also thanks for the additional pieces of information, I was not aware of the s@next_constraint_name and s@next_constraint_type attributes.

Hope things are well in NY!

All the best,


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