NewtonCreateHeightFieldCollision Option

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

NewtonCreateHeightFieldCollision Option

Postby Andy Price » Wed Sep 17, 2008 10:45 am

Hi,

I've been using the CreateHeightFieldCollision for a large terrain and it can be created so quickly that I'm able to use it for streaming even large regions of world geometry. My problem is that, it can only generate the height map based on splitting each square across either one of two diagonals. Is it possible to have the option of splitting based on a diamond shape? Basically this means alternating the direction of the diagonal between each 'tile'.

This image shows what I mean (ignore the numbered vertices):
Image

A lot of people generally arrange terrain vertices this way as it gives far better "curves" and makes terrain features symmetrical along X or Z axis (which isn't possible with all diagonals going the same way).

This might be well implemeted by changing the "diagonal" in the CreateHeightFieldCollision to accept constants as oppose to just an int (although these might already exist somewhere the only values that seem to have effect are '0' or '1'.
Andy Price
 
Posts: 26
Joined: Mon Sep 18, 2006 11:45 pm

Re: NewtonCreateHeightFieldCollision Option

Postby Julio Jerez » Wed Sep 17, 2008 12:15 pm

It is any good reason for doing that, the diamond shape is a very bad way of doing the triangulation.
The reason why is bad, is that by doing the triangulation to favor a ground of triangle while penalizing the other you have a larger accumulating error.

One way to test what I said is by making a terrain for a know shape, A parabolic surface or a hemisphere.

- calculating the volume under the surface foe the implicit equation.
-calculting the volume of the diamond shape triangulation
-calcualtion the volume of the even shape triangulation
-compare the tw0 volumes to the exact volume. You will find that the even triangulation approximate much better the exact volume that the diamond shape.

The reason for that comes from a Mathematic optimization but since I have experiment dealing with this I can explain to you that geometrically it can be integrator like this.

You are optimizing a set of variable, each time you have a variable that is close to the goal corretion those variables even more will only lead to a small improvement proportional to the error for that variable to the goal, but the error is already small.

If instead you correct the variable that is far away for the goal, since the error is large you will be making a bigger coronation because the error is large.

The same happen in eth terrain the diamond shape favor the triangulation of a set of variable that are already close to the surface while leaving other have large error, you can see that by notice the vertex point where you end up with vertex with 8 subdivision and while neighbor vertex only get 4.
Julio Jerez
Moderator
Moderator
 
Posts: 11154
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: NewtonCreateHeightFieldCollision Option

Postby Andy Price » Wed Sep 17, 2008 1:33 pm

Thanks for the reply.
So I think you'tre saying the physics would be inaccurate on this shape because of the inconsistancy of a vertice having 8 neighbours and some of the others only having 4?

It's a shame since graphically this method is very common, being able to use a diamond shape makes things look much better and you can actually get decent shapes.

Trying to make a single 'point' with the current system is impossible, it'll end up as a six sided shape with 2 right angled corners or, trying to make a + shape will end up with two of the corners being filled and the other two not.

Just a side note: there's a bug in that the debug geometry newton gives out doesn't match the heightmap it's using. It gives out the opposite diagonal facing to the one you're actually using.
Andy Price
 
Posts: 26
Joined: Mon Sep 18, 2006 11:45 pm

Re: NewtonCreateHeightFieldCollision Option

Postby Julio Jerez » Wed Sep 17, 2008 2:42 pm

It have nothong to do wiet teh physics,, it is wi teh visual quality of the mesh.
The diagmond shape is is less smoth that the regular one.

While what you said is true for a single cells terrain, I do not know many people making terrains of a single cell.
I donot know of many poeple using the diagmond layout for terrains because it produces more discontinuess edges on the vertex that only have 4 adjecent faces on large terrains.
The regular triangulation have 6 adjacent tringles on each point, that lead to better terrains.

I thing the debug display is correctt, check ou the demo the demo, maybe you can show me the error is? if you do that I will fix it.
Julio Jerez
Moderator
Moderator
 
Posts: 11154
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: NewtonCreateHeightFieldCollision Option

Postby Andy Price » Wed Sep 17, 2008 3:28 pm

I don't know what terrain demos you've been looking at but using diamond shapes is extremely popular in things like CLOD and ROAM. Everyone makes their terrain out of single cells.. using a grid like structure is very common and then simplifying it at runtime to get better performance is the way practically everyone does this so, I'm not sure what you're saying there.

Just in case I've not communicated well this is the kind of shape I mean by using diamonds:
Image

Using a dimaond shape leads to a smoother overall terrain (with filtering) and it's rare in my experience for someone to have uniform diagonals because they are graphically inferior. Having 6 adjacent triangles causes problems because it means no single point can be raised lowered without creating 2 right angled squares. This means no diagonal coast lines, no properly formed hills etc.

This is what I mean when I say it creates right angles:
Image
There's no way of filling that so it's an octagon, if you want a diagonal line, you can't get one, the only result is a staggerred line which looks really bad.

I'll double check the debug display.. as far as I can tell it seems wrong compared to the triangles Newton is giving me, there seems to be holes at certain points - is there any constraint for maximum size of triangles (ie maximum height change between vertices) on a heightfield? Edit - After playing abround a bit more I can now generate a heightmap with holes in.. although I'm not sure how, simply by reversing the "diagonals" parameter between 0 and 1. Setting 1 creates holes at random points and setting 0 makes triangles face the wrong way compared to the debug display.
Andy Price
 
Posts: 26
Joined: Mon Sep 18, 2006 11:45 pm

Re: NewtonCreateHeightFieldCollision Option

Postby Aphex » Fri Sep 19, 2008 3:07 am

Andy Price wrote:Just a side note: there's a bug in that the debug geometry newton gives out doesn't match the heightmap it's using. It gives out the opposite diagonal facing to the one you're actually using.


Ah this would explain why I appear to get holey bits in my mesh :roll:
Aphex
 
Posts: 144
Joined: Fri Jun 18, 2004 6:08 am
Location: UK

Re: NewtonCreateHeightFieldCollision Option

Postby Julio Jerez » Fri Sep 19, 2008 7:51 am

A way to test it is bu makin a small terrian with a very pronound edge and see if the diginal edeg is wrong.
I spent lots of time making sure it is right. I could be a bug, I will check

also since there are only two ways to ste the diagonal, you can try pasing the digonal flag to the othe value and the bug should go away.
Julio Jerez
Moderator
Moderator
 
Posts: 11154
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: NewtonCreateHeightFieldCollision Option

Postby Aphex » Fri Sep 19, 2008 4:26 pm

After some experimentation, it seems like:
a) my vehicle collides with the opposite triangulation to that specified.
b) rays hit this 'fake' triangulation, but the hit normal has vals of -1.#IND000

so... something screwy is going on.
Aphex
 
Posts: 144
Joined: Fri Jun 18, 2004 6:08 am
Location: UK

Re: NewtonCreateHeightFieldCollision Option

Postby Julio Jerez » Fri Sep 19, 2008 5:14 pm

are you running in double? It is possible that teher is a bug there
can you send me a test demo that I can check?
Julio Jerez
Moderator
Moderator
 
Posts: 11154
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: NewtonCreateHeightFieldCollision Option

Postby Aphex » Fri Sep 19, 2008 5:35 pm

Hmm sent PM but it's stuck in my outbox...
Are you receptive to testing this using my whole game? It would be quite hard to extract a test case for it... :shock:
Aphex
 
Posts: 144
Joined: Fri Jun 18, 2004 6:08 am
Location: UK

Re: NewtonCreateHeightFieldCollision Option

Postby Julio Jerez » Fri Sep 19, 2008 7:40 pm

I got the PM.
Julio Jerez
Moderator
Moderator
 
Posts: 11154
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: NewtonCreateHeightFieldCollision Option

Postby Julio Jerez » Sat Sep 20, 2008 1:27 pm

Dude Holly smoking, I was not expecting anything like this. :shock: :shock:
This is awesome, how long had you being working on this? :mrgreen: :mrgreen:
I could not play teh executable because it di no hav eany of teh missing dll, so I dolowded the full version.
I sill have a problem because teh game is in full screeen mode, and I can nor debug teh code liek that.

hwo can I run in windows mode?
Julio Jerez
Moderator
Moderator
 
Posts: 11154
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: NewtonCreateHeightFieldCollision Option

Postby Aphex » Sat Sep 20, 2008 2:33 pm

heh, been working on that baby for quite a while indeed :shock: Hopefully finish it some day... should be a good showcase for Newton ;)

You can run in windowed mode (and change other stuff like resolution) by editing the config.ini file (set 'Windowed = 1')
Press Ctrl+D while running and tick the 'Physics Geometry' box to show Newtons collision polys. (See controls.txt for more debug stuff.)
You can also run the 'DebugView.exe' app in the same directory that will let you set various dev mode things (turn on Physics->Debug->ShowIslandCollision)
It might actually be useful for you as a testbed for some Newton stuff :twisted:
Aphex
 
Posts: 144
Joined: Fri Jun 18, 2004 6:08 am
Location: UK

Re: NewtonCreateHeightFieldCollision Option

Postby Julio Jerez » Mon Sep 22, 2008 10:44 am

Ok I am running in window mode.
when I start I see teh craarir and a small millty bote to teh right.
With there array key I start moving toward the island. I can shoot,
after about 30 secund the game crash and teh vido is all wack, My impresion is that is was a video driver related bug.
Is that how the bug shows up, if so hwo can I expose it?
is what do I have to do to reproduce the bug?
Julio Jerez
Moderator
Moderator
 
Posts: 11154
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: NewtonCreateHeightFieldCollision Option

Postby Aphex » Mon Sep 22, 2008 11:31 am

That's interesting: never had a video crash before - probably the main joy of PC dev - untested hardware config :(
The bug is one of:
a) Newton debug collision geometry of island doesn't match what the vehicle is colliding with (the build you have - triangulation param set to '1')
b) Debug collision geometry of island matches the island mesh, but vehicle appears to get stuck in holes (needs triangulation param set to '0' - maybe you can hardwire this in your code?)

In both cases, I get normal values of -1.#IND0000 for Newton rayCasts that hit the island geometry.

Might be easier if I send some game saves showing the problem later actually... do you have an email address I can send to?
Aphex
 
Posts: 144
Joined: Fri Jun 18, 2004 6:08 am
Location: UK

Next

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 2 guests

cron