Skip to content

Terrain could not picked. #1261

@huliqing

Description

@huliqing

I test the problem on jme3.3 alpha5

1.First edit the terrain and then save is as j3o.
2.Use assetManager.loadModel(...terrain.j3o);
3.Use ray to test collide but not success in some terrain patch.

terrain.collideWith(ray, results);

I think maybe is the problem of the code of TerrainQuad.

private TerrainPicker picker = new BresenhamTerrainPicker(this);

When assetManager load the terrain. It will clone the TerrainQuad.

if (obj instanceof CloneableSmartAsset) {
	clone = registerAndCloneSmartAsset(key, clone, proc, cache);
}

But the TerrainPicker was not cloned, so the picker will link to anthor old TerrainQuad.
I use the old code can fix my pick problem. But I'm not sure is the right way.

private int collideWithRay(Ray ray, CollisionResults results) {
    if (picker == null) {
        picker = new BresenhamTerrainPicker(this);
    }
    return picker.getTerrainIntersection(ray, results);
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions