Suspending Newton

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Suspending Newton

Postby misho » Thu Mar 08, 2018 7:58 pm

Hi everyone!

I have a specific case which involves user assembling objects by choosing them and linking them using hard links. Here is a workflow:

  1. Parent object [P] is resting in the scene, under gravity.
  2. User invokes an "assembly" menu with a choice of a number of child objects, to be attached.
  3. User chooses one child object [C], and that object is loaded from a server at a certain position in 3D space.
  4. User is presented with another menu, showing a number of attach points for object [C].
    (in the meantime, the object [C] starts falling under the influence of gravity)
  5. User chooses the attach point, and the object [C] is moved, oriented and attached to [P] at the chosen attach point.

The question is, when user invokes assembly menu, I would like to have all Newton dynamics suspended, so that all child objects are "hanging" in the air, until they are linked to the parent. While Newton dynamics are suspended, I would still like to have the ability of linking objects using hinges - something that seems not to be working, according to my tests so far.

Any ideas on how to go about this?

Selecting an object to determine what attach points it contains, but not actually loading it, won't work due to the architecture - I request objects from a server which is closed to me, and the only way to get details on the requested object is to fully load it.
Misho Katulic
CTO, FSX SpacePort
TerraBuilder
www.terrabuilder.com
misho
 
Posts: 673
Joined: Tue May 04, 2010 10:13 am

Re: Suspending Newton

Postby Julio Jerez » Thu Mar 08, 2018 8:09 pm

you can bypass island updates by setting the call back.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Suspending Newton

Postby misho » Thu Mar 08, 2018 8:14 pm

Julio Jerez wrote:you can bypass island updates by setting the call back.


Ok - basically, bypass

Code: Select all
void ApplyForceAndTorqueCallback (const NewtonBody* body, dFloat timestep, int threadIndex)


For all objects? I was going to go this route, but was unsure if there was a better way ;)
Misho Katulic
CTO, FSX SpacePort
TerraBuilder
www.terrabuilder.com
misho
 
Posts: 673
Joined: Tue May 04, 2010 10:13 am

Re: Suspending Newton

Postby Julio Jerez » Thu Mar 08, 2018 8:27 pm

no, no, there is a callback that if set the engine will skip the update of that island
Code: Select all
void NewtonSetIslandUpdateEvent (const NewtonWorld* const newtonWorld, NewtonIslandUpdate islandUpdate);
NewtonBody* NewtonIslandGetBody (const void* const island, int bodyIndex);
void NewtonIslandGetBodyAABB (const void* const island, int bodyIndex, dFloat* const p0, dFloat* const p1);

no sure if that is what you want.
It was made for cooling physics long time ago.
the engine is not set to not update anything that is part of and island separate.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Suspending Newton

Postby misho » Fri Mar 09, 2018 3:33 pm

Ok great, thanks, I'll dig deeper into this, and come back if I have more questions :wink:
Misho Katulic
CTO, FSX SpacePort
TerraBuilder
www.terrabuilder.com
misho
 
Posts: 673
Joined: Tue May 04, 2010 10:13 am

Re: Suspending Newton

Postby misho » Wed Mar 14, 2018 8:36 pm

Ok - I looked closely at the Wiki on this function, and:

"The application must not create, modify, or destroy bodies inside the callback"


which is precisely what I need to do (or even more precisely, I need to add/delete objects inside the suspended island), since my "assembly mode" creates objects and attaches them to other objects. Any thoughts on how else I could achieve this?

Misho
Misho Katulic
CTO, FSX SpacePort
TerraBuilder
www.terrabuilder.com
misho
 
Posts: 673
Joined: Tue May 04, 2010 10:13 am

Re: Suspending Newton

Postby JoeJ » Thu Mar 15, 2018 2:24 am

So you want to pause simulation, then the user adds a module to the spacestation?

You could (and should) do this outside of any callback, and even outside of physics update.
You would transform spacestation velocities to the new module so it's weight have no effect, and it should all work?
User avatar
JoeJ
 
Posts: 1453
Joined: Tue Dec 21, 2010 6:18 pm

Re: Suspending Newton

Postby misho » Thu Mar 15, 2018 3:13 pm

JoeJ wrote:So you want to pause simulation, then the user adds a module to the spacestation?


Precisely. Right now, I have a "pause" function which essentially stops time (passes zero for a time step). I need it because my core simulator has a pause function, and Newton engine has to stop as well.

It works - everything freezes, but I can still create and move objects. The problem is, when I link objects, the links are half-there, meaning, they are not rigidly attached (they fall through and off the parent), but their orientations mimic parent's, as if they were attached.

I need a robust function that will pause the sim, but still allow for creation/deletion/linking of bodies, and any other operation normally available in general, within reason. I based my code on the tutorial examples, so my methods are similar to those in there, including

Code: Select all
void AdvanceSimulation (int timeInMilisecunds, BOOL bSuspend)
unsigned GetTimeInMicroseconds(BOOL bSuspend)


JoeJ wrote:You could (and should) do this outside of any callback, and even outside of physics update.
You would transform spacestation velocities to the new module so it's weight have no effect, and it should all work?


I am doing that right now... it works while in orbit, where I insert a new object at some distance from parent and give it parent's velocity. Then I pick a docking port, align the object to parent, and connect the two.

However: On ground, If I have a stationary object on the launch pad, say, a core rocket stage, and I want to add a second stage on top, if I do the same operation as the one in orbit and add the second stage at some height above the core stage, the second stage starts to fall toward the core stage. I can quickly select the attachment port and everything works, but obviously that's not the solution. I want the object to be suspended, waiting for my selection.

There are a few solutions to this, but none are elegant. I could determine what attach point (port) I want to use before the object is created, but since I do not know the choices of attach point that object has before the object is created, I would have to have some kind of a copy of the object properties, and I don't want to go the way of duplicating any data.

So far, I was thinking of suspending gravity for the new object and let it just hang in place, but that's kind of kludgy as well.

Thanks for any insight!
Misho Katulic
CTO, FSX SpacePort
TerraBuilder
www.terrabuilder.com
misho
 
Posts: 673
Joined: Tue May 04, 2010 10:13 am

Re: Suspending Newton

Postby JernejL » Thu Mar 15, 2018 5:13 pm

If your problem are undesired collisions, you can easily prevent those via material contact callback, it's possible to discern bodies there and have completely arbitrary on/off for collisions between bodies, would that help? i can provide some pseudocode..

IF problem is bodies moving due to velocity, you can just freeze bodies you don't want to move (and then not apply force & torque to them)
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1578
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Suspending Newton

Postby JoeJ » Thu Mar 15, 2018 5:38 pm

misho wrote:So far, I was thinking of suspending gravity for the new object and let it just hang in place, but that's kind of kludgy as well.


This sounds good to me.

You could also use a kinematic joint to hold the object in place, and even to move it slowly to the target platform after selection. No need to change gravity.
(This would also be possible using control methods discussed in Networking thread, but that's more complicated.)

You could also just render the object, and create the physics only after selection.
User avatar
JoeJ
 
Posts: 1453
Joined: Tue Dec 21, 2010 6:18 pm

Re: Suspending Newton

Postby misho » Fri Mar 16, 2018 5:44 pm

JernejL wrote:If your problem are undesired collisions, you can easily prevent those via material contact callback, it's possible to discern bodies there and have completely arbitrary on/off for collisions between bodies, would that help? i can provide some pseudocode..

IF problem is bodies moving due to velocity, you can just freeze bodies you don't want to move (and then not apply force & torque to them)


Problem is not undesired collision - I'd like to freeze the body. How do I do that? If you are suggesting I bypass applying force and torque to it, that's exactly what I was suggesting - by cutting out gravity.
Misho Katulic
CTO, FSX SpacePort
TerraBuilder
www.terrabuilder.com
misho
 
Posts: 673
Joined: Tue May 04, 2010 10:13 am

Re: Suspending Newton

Postby misho » Fri Mar 16, 2018 5:46 pm

JoeJ wrote:
misho wrote:So far, I was thinking of suspending gravity for the new object and let it just hang in place, but that's kind of kludgy as well.


This sounds good to me.

You could also use a kinematic joint to hold the object in place, and even to move it slowly to the target platform after selection. No need to change gravity.
(This would also be possible using control methods discussed in Networking thread, but that's more complicated.)

You could also just render the object, and create the physics only after selection.


Thanks - I think just suspending gravity on per-object case would do the trick. I don't have any way of registering mouse hits on the 3D canvas, unfortunately (nor do I want to get into developing this functionality)
Misho Katulic
CTO, FSX SpacePort
TerraBuilder
www.terrabuilder.com
misho
 
Posts: 673
Joined: Tue May 04, 2010 10:13 am


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 18 guests