Seams in terrain

Hey,

after updating to the current hudson build my terrain got “seams” in it:



Has this to do with the grid orientation flipping of the new svn commit?

hi,



it can depend on the material you are using. HeightBasedTerrain.j3md is known to have these artifacts, I’m still working on it.

I’m using the standard terrain material and I’ve playing with the terrain for weeks now and hadn’t this problem yesterday…

Fixed in SVN.

The normals weren’t being set to update through a new constructor I made.

I have occasionaly this Exception since your fix :

GRAVE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
java.lang.NullPointerException
at com.jme3.bounding.BoundingBox.intersects(BoundingBox.java:588)
at com.jme3.terrain.geomipmap.TerrainQuad.fixNormals(TerrainQuad.java:1379)
at com.jme3.terrain.geomipmap.TerrainQuad.fixNormals(TerrainQuad.java:1380)
at com.jme3.terrain.geomipmap.TerrainQuad.fixNormals(TerrainQuad.java:1380)
at com.jme3.terrain.geomipmap.TerrainQuad.updateNormals(TerrainQuad.java:209)
at com.jme3.terrain.geomipmap.NormalRecalcControl.controlUpdate(NormalRecalcControl.java:62)
at com.jme3.scene.control.AbstractControl.update(AbstractControl.java:86)
at com.jme3.scene.Spatial.runControlUpdate(Spatial.java:516)
at com.jme3.scene.Spatial.updateLogicalState(Spatial.java:634)
at com.jme3.scene.Node.updateLogicalState(Node.java:146)
at com.jme3.scene.Node.updateLogicalState(Node.java:153)
at com.jme3.scene.Node.updateLogicalState(Node.java:153)
at com.jme3.app.SimpleApplication.update(SimpleApplication.java:256)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:144)
at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:185)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:218)
at java.lang.Thread.run(Unknown Source)


Edit: could be my fault, don't waste too much time with it ;)

Are you using TerrainGrid when you get that ozonegrif?

It is saying that one of the Quads doesn’t have a bounding box. Maybe it wasn’t generated on creation.



I can put in a safety check for that, but I think it is revealing a larger problem about the quad you are using. Let me know if you find the problem.

Just wanted to say that the problem got resolved with the fix, thx Sploreg. Ozonegrif, your problem has to be somewhere else :slight_smile:

@Sploreg :



Remember when you told me I can detach Patches ? :wink:

Well I can indeed Detach Patches, but then it generates problems when I adjust Terrain’s height.

I can fix it on my side by reattaching all the missing parts, adjust the heights, then detach them again.

What sort of problems?

Problem = The Exception.

I improved my code and it occurs way less often (or not)… It obviously happens when I detach a Patch.

I will investigate and tell you my conclusions soon :slight_smile:

Ok, keep me posted. If I can tighten up the TerrainQuad to help I will try.

Sorry… I’ve been working for hours on this problem, and I don’t find a solution… :frowning:

If I detach some Patches then reattach them later, and change the terrain’s height… it will crash randomly in the intersect() method while calculating normals.

I added :

[java]

if ( bounding == null ) return false;

[/java]

and if solves my problem… but I don’t find the origin. Why does child.getWorldBounds() returns null ?

You can probably get around this by calling updateModelBound() on the root terrain quad whenever you re-attach a patch.

Nope, tried this already and everywhere without success.

I also tried to force an updateWorldBounds… no more help.

Is all of the attaching and detaching you are doing on the render thread?

It is done through the TerrainGridListener interface.

tileAttached detaches a Patch from another TerrainQuad.

tileDetached attaches (a previously detached) Patch to that other TerrainQuad

Whenever “random” happens, the culprit is most likely threads.

There are some thread safety issues around the TerrainGridListener.tileLoaded() method, at least when called from TerrainGrid’s UpdateQuadCache thread. If anything is done to the scene graph in that method, then things can get messed up.

We will have to work with @anthyon on this one.



I tried pushing that method call back onto the render thread but it killed my framerate.

I will have a look at the problem later today. Just have a short trip ahead of me. :slight_smile:

A short question to sort things out: do you attach/detach patches on the render thread or right inside TerrainGridListener?

Right inside TerrainGridListener ; which is the update loop if I am not mistaken ?

You have to change the height of the Quad you detached a Patch too, to force a normals refresh and trigger the Exception.