A place to discuss everything related to Newton Dynamics.
Moderators: Sascha Willems, walaber
by Olee » Sun Jul 04, 2010 4:51 pm
Hi, I'm very new to Newton but still everything worked fine.
But as I am working with joints now I have a problem:
When I delete a joint-parent, Newton seems to delete the joint-child as well.
But this causes an access-violation when my engine wants to delete the NewtonBody of the child afterwards.
Is it really like that and is there no other way than storing the joint-information and deleting it before destroying the parent/child bodys of it?
I hope you can help me there.
-
Olee
-
- Posts: 11
- Joined: Sun Jul 04, 2010 12:55 pm
by Julio Jerez » Mon Jul 05, 2010 12:57 am
if you delete a body, all joints connected to that body are deleted.
if you delete a joint, it does not delete any of the bodies the jointlink together.
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by Olee » Mon Jul 05, 2010 7:42 am
Yea I know that all joints will be deletet.
But what about the other bodies that are connected to the joint?
So if I delete a body which is the parent of a hinge-joint, does the child-body of the joint get deleted as well?
The problem is the following:
I create two objects in my engine - each with a newton-body assigned.
This runs without an error.
But when I connect those two bodies with a hinge-joint there appear some problems:
When the engine gets destroyed, the parent-body gets deleted.
Till that point everything is the same as without the joint.
But when I call NewtonDestroyBody for the child-body Newton generates an access-violation!
So it seems to me that when I delete one body connected to a joint the other body gets deleted as well.
Is it really like that?
-
Olee
-
- Posts: 11
- Joined: Sun Jul 04, 2010 12:55 pm
by Julio Jerez » Mon Jul 05, 2010 8:38 am
Olee wrote:So if I delete a body which is the parent of a hinge-joint, does the child-body of the joint get deleted as well?
no
The problem is the following:
Olee wrote:When the engine gets destroyed, the parent-body gets deleted.
no that should not happen, It has never happened in the past, you must have a bug.
you can set an body destructor callback, that's always a good practice, then you can check is when you destroy one body, the other do not get destroyed.
you can also set the destructot callback for the hinge and verify that when you destroy one body, you get call to the hinge destructor and to the body destructor but not to the other body.
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by Olee » Mon Jul 05, 2010 8:59 am
I found the problem!
My engine uses a script-engine calles RUTIS I wrote.
There I added an external functon to create the joint.
But I made a mistake and so parent and child were the same for the joint.
Now there is no ore problem.
But I have another question.
How can I sove things like lifts and so on - so things which are move by the program and not the physics?
If I move them by code, they just go through other objects, although I set an aproxim. velocity for them.
-
Olee
-
- Posts: 11
- Joined: Sun Jul 04, 2010 12:55 pm
by ledahut » Thu Jul 15, 2010 3:23 am
To create a lift, create two bodies [one static like the floor, and one dynamic].
Create a Slider joint between these bodies;
In the NewtonApplyForceAndTorque use NewtonBodyGetVelocity and NewtonBodySetForce[up or down].
Like that:
- Code: Select all
liftspeed:=10;
NewtonBodyGetVelocity(liftbody,velocityVector)
if velocityVector[1]>liftspeed then
NewtonBodySetForce(liftbody,0)
else
NewtonBodySetForce(liftbody,forceUPvector)
-
ledahut
-
- Posts: 98
- Joined: Mon Jun 21, 2010 8:03 am
- Location: France
by kallaspriit » Thu Jul 15, 2010 2:20 pm
If you want to control the
position, not
velocity of the lift, you should be able to use linear row to force the lift to wanted position. You can additionally set max/min friction to limit the amount of weight the lift can move

-
kallaspriit
-
- Posts: 216
- Joined: Sun Aug 14, 2005 6:31 pm
Return to General Discussion
Who is online
Users browsing this forum: No registered users and 1 guest