A place to discuss everything related to Newton Dynamics.
Moderators: Sascha Willems, walaber
by godlike » Fri May 15, 2015 3:39 am
In some of the Newton demos I see the following scenario:
1. Create a newton scene collision
2. Append a number of sub-collisions to the scene collision
3. Create a body with the scene collision
What I've tried was to add sub-collisions after creating the body (do 2 after 3). It didn't work as I imagined. Adding sub-collisions after the body creation doesn't seem to do anything.
Is this expected?
-

godlike
-
- Posts: 58
- Joined: Sun Mar 16, 2014 3:48 am
-
by Julio Jerez » Fri May 15, 2015 9:25 am
yes that should work.
but you should get the collision form the body, CreateBody make a copy of the collision that you pass in, so adding to the shape ate to create the body, add the sub shape to the other scene.
your step should be
1. Create a newton scene collision
2. Destroy collision you passed to create body and Get Collision form the created body
3. Append a number of sub-collisions to the scene collision
4. Create a body with the scene collision
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by godlike » Fri May 15, 2015 10:47 am
Thanks for the response,
I am not sure I understand the lifetime of the bodies.
1. create initial scene collision "scene0"
2. add 10 sub-collisions to "scene0"
3. create a body "body0" with the "scene0"
4. destroy "scene0"
5. get the collision "scene1" from the "body0"
6. add 5 more sub-collisions to "scene1"
7. ?????
What should I do in step 7? Create a new body with "scene1" and destroy "body0"? Or something else?
-

godlike
-
- Posts: 58
- Joined: Sun Mar 16, 2014 3:48 am
-
by Julio Jerez » Fri May 15, 2015 10:55 am
that should work, you can add, remove or move sub shapes in step 7 without destroying the body.
has you implemented debug display
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by godlike » Mon May 18, 2015 2:54 pm
Thanks Julio! That worked fine.
-

godlike
-
- Posts: 58
- Joined: Sun Mar 16, 2014 3:48 am
-
by Julio Jerez » Mon May 18, 2015 3:04 pm
remember when you add or remove shape to a scene collision or a compound collision you have to do it from a BeginAddRemove / EndAddRemove block
if you do not it, it will added or remove the sub shape, but the broad phase will not be updated.
this is allow because some functionality like vehicle use a compound collision add move the sub shapes, but does no nee to update the broadphase because the body is dynamics.
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
Return to General Discussion
Who is online
Users browsing this forum: No registered users and 2 guests