Physics for streaming terrain

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Physics for streaming terrain

Postby Leadwerks » Mon Feb 10, 2020 6:07 am

I am working on a streaming terrain system. The engine will dynamically load height and color textures as the camera moves around, in order to simulate terrains that are much larger than would otherwise be possible in memory. The game "Fuel" is a good example of what I am planning:



For physics I plan to dynamically stream in patches of the heightmap in the area of any moving physics body. Most of the terrain will not have objects rolling around on it, so we can simulate physics everywhere with a small amount of memory. (A 64-bit build can be used to prevent floating point precision problems.)

If terrain data is being downloaded from an online database there may be delays before the height data becomes available. I am not sure how to "pause" physics in an area to prevent objects from falling through the terrain before it is loaded. I plan on supporting round terrains (planets) as well as general static object collision, so simply checking the Y position of a falling object once terrain is loaded is not sufficient.

Any suggestions on how to handle this?
User avatar
Leadwerks
 
Posts: 569
Joined: Fri Oct 27, 2006 2:54 pm

Re: Physics for streaming terrain

Postby Julio Jerez » Mon Feb 10, 2020 12:54 pm

There is an unlimited plane collision in the SDK demos.
You can check that out.
Basically you make an empty polygonal mesh with a very large aabb,
The for each object touching the aabb you get a callback that you use to populate the polygon of the terrain.
People has used it for game like the block octree that was popular few years back.
Is not difficult to implement.

You can use the large aabb to partitionn your map for streaming stuff however you like.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Physics for streaming terrain

Postby Leadwerks » Tue Feb 11, 2020 10:18 am

Yes, I understand that. The problem I am trying to solve it what to do if the terrain height data for a section does not load immediately, and the object falls through the terrain because it has not been loaded yet. Is it possible to somehow pause the physics of a single object? The data will be downloaded from the web asynchronously.
User avatar
Leadwerks
 
Posts: 569
Joined: Fri Oct 27, 2006 2:54 pm

Re: Physics for streaming terrain

Postby Julio Jerez » Tue Feb 11, 2020 12:23 pm

There is a function that remove a body from the simulation.
Not sure if still works, I will check out.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Physics for streaming terrain

Postby Leadwerks » Tue Feb 11, 2020 3:18 pm

I suppose I could also set the body's mass to zero and then when the loading is complete, set it back to what it was and restore the velocity to the previous value.
User avatar
Leadwerks
 
Posts: 569
Joined: Fri Oct 27, 2006 2:54 pm

Re: Physics for streaming terrain

Postby JoeJ » Tue Feb 11, 2020 3:57 pm

Additionally it might be little work to add hight map mips?
So lower LOD could be kept in memory, and after the details are loaded it could interpolate to get a smooth transition eventually. Though, ofc. bodies could start rolling, stacks might tumble, etc.
Would need some work to compensate velocities caused from morphing terrain to deal with this.

I wonder if such things are done in some games? LOD seems not really a hot topic for physics for most.
User avatar
JoeJ
 
Posts: 1453
Joined: Tue Dec 21, 2010 6:18 pm

Re: Physics for streaming terrain

Postby Julio Jerez » Tue Feb 11, 2020 4:15 pm

setting the mass to zero, will make bodies with joint malfunction.
these are the functions for deativation a body from the simulation.
Code: Select all
int NewtonBodyGetSimulationState(const NewtonBody* const body);
void NewtonBodySetSimulationState(const NewtonBody* const bodyPtr, const int state);
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Physics for streaming terrain

Postby Leadwerks » Wed Feb 12, 2020 10:43 am

Perfect, thank you.
User avatar
Leadwerks
 
Posts: 569
Joined: Fri Oct 27, 2006 2:54 pm


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 14 guests

cron