"Remove parent" on a rigidbody problem

Hi!

I have a problem and I don’t find the solution anywhere after some searching on google. Here is the setup:

-Create 2 cube and make it rigidbody in physic tab
-Create a plane above the 2cube for the floor
-Press “P” to see if all going fine.
-Make cube1 child of cube2 with “compound” enable on both of them.
-On cube1,make a keyboard sensor and a parent actuator set to “remove parent” for when you press SpaceBar.
-Press “P” to run the game.

I don’t know if the samething happen for all of you but for me all working fine until I press the SpaceBar. The child is removed from is parent but lost all is rigidbody properties. It’s stay fixed with no collision for other rigidbody like a Static object in Ghost mode.

Somebody can tell me what I doing wrong or if not, a workaround is possible in logic brick or python?

One solution is to make a complete replacement child object with “rigid body” physics. When you unparent the child, switch the child object out completely using endObject and addObject. This gets rid of the child object that has the issues and replaces it with a completely new object that behaves exactly as you want it to. I know this is a bit of a brute force workaround and there may be alternatives, but it should work.

From my experience the physics related to child objects is a bit dodgy in several areas. Personally, I’d say that the root cause of this is the historical lack of people that use advanced areas of the game engine (such as specific uses of the physics engine). Since not many people have used this extensively there may be features that are missing or poorly implemented.

Having said this, recent improvements in the game engine physics are pretty inspiring. The recent patch (I think by moerdn?) for support of collision groups is one example of this.

Ok , if I understand this parent problem is a knowing bug.

Replace the object is not my better choice but if nobody know a better issue for that…

hummm I see a problem with the “make parent” of the “parent” actuator.
This logic brick node don’t really work.

Probably samething if I did it with python?

Looking at your original issue again, perhaps you could do what you want using rigid body joints instead of parenting? Instead of unparenting the objects, sever the rigid body joint.

To achieve the same effect as parenting you’d need to use a 6DoF joint with all degrees of freedom limited to 0.

You can remove a constraint during the game is playing in python?
I know how to create Bullet Contraints in python and remove it but the choice of 6DOF is not there in
this python module.6DOF only in the blender interface constraint panel when the game is stopped.

This page contains info for creating 6DoF constraints along with all the parameters that are available such as limits, springs and motors using the setParam() method of the constraint.

This page contains info and example scripts for removing constraints.

I don’t think the contents of these pages is available in the official documentation for some reason and when working on my ragdolls addon this was the only place on the net that I could find this information (it took quite a bit of digging and some creative search strings to find it ;)). I think the pages were originally written for Blender 2.49b so the script examples might require some modification, but the parameters and the enums (eg. 12 for 6DoF) all work just the same in Blender 2.59. One thing that will need to change in the scripts is changing the deprecated “PhysicsConstraints” module for “bge.constraints”. Another is to change “GameLogic” for “bge.logic”. With these two modifications the scripts should work in 2.59.

Looking at the api documentation, I think the 6DoF constraint might now be called pointtopoint or angular constraint? Regardless, if you use the number 12 for the constraint type, it will create a 6DoF constraint just like in those example pages.

I think the api documentation is auto-generated in some way so I’m not sure how to update it, but this part of the api definately needs documenting.

Wow thank a lot for this pages !

I already know the bge.constraint and I play a bit with it. With removecontraint() and getConstraintId() , you can remove the constraint when you want. How many other constraints type is hided like this ? :wink:

I script my own spring constraint in python with the help of this page :
http://en.myinventions.pl/index.php?page=BlenderSpringsAndDampers

and I make this script and this video with it:


But did all this math in python make my simulation really slow when I have a lot of object. My goal is not to get a realtime simulation , but a precalculed/baked one with less time as possible.

I did some test and already existing bullet constraint is 20times faster then my spring python constraint. Okay okay … I need to make some work on it to optimize it too but … python is slower (interpreted language) and don’t use multitread processor, just one.

but again … thank a lot. I test it and I let’s you know if it what I’m searching for about a couples of days.:eyebrowlift:

FunkyWyrm: Nice , I try it and I think it’s exactly what a want. It’s increase constraint possibility more wider.

FunkyWyrm or somedyelse know if setLinearAirDamping or setSolverDamping work ? I set any value and I see nothing changed. Or a way to create damping with this constraints because the 6DOF spring bounce for ever or for a very long time?

okay … I hope nobody see my last post …
I feel a bit idiot after I see the damping option in the physic tab of the rigidbody object :o

but it’s could be cool if the airdamping works for all constraint in the scene too.

Ahh… Yes, the essential setParam function is not documented at all on blender.org as it looks. That kind of explain why rigid body constraints are used so little. To me they beat animation in all ways for stuff like opening doors etc.

I miss damping to… It’s not sure we want a rigid body object to have the same damping when it’s not constrained and we can’t change the damping on the object run-time what I know. Replacing the object with end/add object is a bit tedious.

It can be solved by using the motor to crate damping but usually the motor parameter have to be changed every frame so the python code have to run every frame. That a bit expensive but work as long it not to many objects with damping.

I’ve not played with it yet, but the spring looks like it could be made to act as damping.

The spring parameter has a “stiffness” value and a “reset” value. “Reset” defines whether the spring returns to it’s original position. If this is set to False then the spring will not return to the original position, but should still have the “stiffness”. “Stiffness” without “reset” might act like damping? It’s the last parameter listed on the page I linked before, just above the last code example. Link

LaH : yes … damping on the object itself is not really good and i’m a bit sad if you cannot change it during game. The best thing is to have access to a constraint damping.

FunkyWyrm : Damping and stiffness is not the same thing , with or without the reset options. Damping is a resistance , a “friction” on the constraints. In the case of a spring , is make the spring lost in force over time to prevent too much bouncing and you can have access to how much “friction” you want. In my spring constraint python script , I make a damp parameter and it’s working fine. The stiffness without reset option look like more of a clay you push and stiffness act like how firm is you clay. Your rigidbody never return to it’s original position and go farter each time you push it. Yes it’s act like a damper … but without spring. What I need in this case is a slider controlling the weight between “Reset to position” and " Not reset to Position ". Not just a On and Off.

I don’t know if you see my video but to explain the “reset” option : If I did the same setup with the bullet 6dof spring constraint with the reset option at ON , my cube probably giggle like jello for a long time. If I put it at Off , it’s just bump and ply keeping it’s deformation like clay. Damping it’s a weight between this two state.

Yes - no reset is a ‘plastic’ option.

If we write a wishlist here i put up.

Setting the springs rest position (not necessarily the initial position and it would be nice to be able to change it ‘in action’).

Setting the exponent on both spring and damping.

And the mere existence of damping of course

Edit: And position/angle motor servo. Bit complicated as it takes three parameters (position/angle, max speed, max force)

A good wishlist :slight_smile:

setLinearAirDamping is documented but not implemented yet

I read somehere integration of bullet in blender is not multithread but work only on one processor :frowning:

I know rendering is multithread , but what others parts of blender is not ?

Today , with all multi-core/multi-processor computer has a standard on the market (Even my parents have a multiprocessors/cores computer :wink: ) , it’s a big issue for a software to don’t have all is features multithreaded I think. Blender need this to “multi-kick” the *** of autodesk ! :yes:

As far as I know it’s only the rendering that’s multithreaded in Blender.

Blender’s Python isn’t thread safe and allowing scripts to run on a separate thread would be great. Also, bge is about 10 years old although recent updates have done much to improve it. Multithreading support for the game engine would really give it a boost even if only the physics was on a separate thread. With increased demand for realism in games physics engines have possibly recieved the biggest improvements after rendering, but much of the rendering is offloaded to graphics cards so the biggest boost to the game engine could be enabling multiprocessor support for physics. (I understand that there are differences between multithreading and multiprocessing, but both would be nice. ;))

did you already try to multithread python script ?
I read a bit on this and it’s seam to be not really easy and gain is not impressive.

Okay … I remake my script with bullet constraint and it’s 2-3times mores faster then my own scripted constraint but I cannot
go more then 16 000 molecules in BGE because the memory go too high.

I’m limited to the number ob object in BGE , rigidbody or not , constraint or not , real-object or instance because it’s consume too much memory for what I want to continue:
http://www.youtube.com/watch?v=nLUfw…eature=related

I’m consider now to forget BGE and Bullet physic and check to did it with particles.