How to copy btTypedConstraint ?

Post Reply
papaonn
Posts: 41
Joined: Wed Nov 20, 2013 4:14 pm

How to copy btTypedConstraint ?

Post by papaonn »

Hi community,

I come across a step that i want to copy btTypedConstraint in my program which i use the normal assignment operator =,
but the compiler said that it is a private function which doesn't allow for a replicate.

I tried looking into the library and seems like there is no way to assign a copy to it.

May i know if there is any alternative in resolving this problem?


Thanks.
Antonz
Posts: 16
Joined: Wed Nov 17, 2010 10:57 am

Re: How to copy btTypedConstraint ?

Post by Antonz »

Of course you should not be able to copy such complex object because it's assigned in btDiscreteWorld and also binds one or two btRigidBody'es, has internal runtime state etc... so allowing copying semantic for them will be dangerous. That's why copy constructor and assignment operators are disabled (made private and undefined) for this object (as well as most "big" objects in Bullet).

If you want to have just another constraint with same properties you must create your own "Clone" function, where you create another btTypedConstraint using "new" operator, copy properties that you need from previous, assign copied constraint to rigid bodies and to world. But why you need this at all? Having two same constraints linking same two rigid bodies is not a common scenario and likely will cause a lot of problems.
Post Reply