JmeCloneable related changes to TerrainQuad and TerrainPatch. Fixed
something I missed in NormalRecalcControl.
This commit is contained in:
parent
eda92656dd
commit
7b29c58fe0
@ -69,6 +69,9 @@ public class NormalRecalcControl extends AbstractControl {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called internally by com.jme3.util.clone.Cloner. Do not call directly.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Object jmeClone() {
|
public Object jmeClone() {
|
||||||
NormalRecalcControl control = (NormalRecalcControl)super.jmeClone();
|
NormalRecalcControl control = (NormalRecalcControl)super.jmeClone();
|
||||||
@ -76,6 +79,14 @@ public class NormalRecalcControl extends AbstractControl {
|
|||||||
return control;
|
return control;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called internally by com.jme3.util.clone.Cloner. Do not call directly.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void cloneFields( Cloner cloner, Object original ) {
|
||||||
|
this.terrain = cloner.clone(terrain);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Control cloneForSpatial(Spatial spatial) {
|
public Control cloneForSpatial(Spatial spatial) {
|
||||||
NormalRecalcControl control = new NormalRecalcControl(terrain);
|
NormalRecalcControl control = new NormalRecalcControl(terrain);
|
||||||
|
@ -50,6 +50,7 @@ import com.jme3.scene.mesh.IndexBuffer;
|
|||||||
import com.jme3.terrain.geomipmap.TerrainQuad.LocationHeight;
|
import com.jme3.terrain.geomipmap.TerrainQuad.LocationHeight;
|
||||||
import com.jme3.terrain.geomipmap.lodcalc.util.EntropyComputeUtil;
|
import com.jme3.terrain.geomipmap.lodcalc.util.EntropyComputeUtil;
|
||||||
import com.jme3.util.BufferUtils;
|
import com.jme3.util.BufferUtils;
|
||||||
|
import com.jme3.util.clone.Cloner;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.Buffer;
|
import java.nio.Buffer;
|
||||||
import java.nio.FloatBuffer;
|
import java.nio.FloatBuffer;
|
||||||
@ -955,6 +956,33 @@ public class TerrainPatch extends Geometry {
|
|||||||
return clone;
|
return clone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called internally by com.jme3.util.clone.Cloner. Do not call directly.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void cloneFields( Cloner cloner, Object original ) {
|
||||||
|
|
||||||
|
this.stepScale = cloner.clone(stepScale);
|
||||||
|
this.offset = cloner.clone(offset);
|
||||||
|
|
||||||
|
this.leftNeighbour = null;
|
||||||
|
this.topNeighbour = null;
|
||||||
|
this.rightNeighbour = null;
|
||||||
|
this.bottomNeighbour = null;
|
||||||
|
|
||||||
|
// Don't feel like making geomap cloneable tonight
|
||||||
|
// so I'll copy the old logic.
|
||||||
|
this.geomap = new LODGeomap(size, geomap.getHeightArray());
|
||||||
|
Mesh m = geomap.createMesh(stepScale, Vector2f.UNIT_XY, offset, offsetAmount, totalSize, false);
|
||||||
|
this.setMesh(m);
|
||||||
|
|
||||||
|
// In this case, we always clone material even if the cloner is setup
|
||||||
|
// not to clone it. Terrain uses mutable textures and stuff so it's important
|
||||||
|
// to clone it. (At least that's my understanding and is evidenced by the old
|
||||||
|
// clone code specifically cloning material.) -pspeed
|
||||||
|
this.material = material.clone();
|
||||||
|
}
|
||||||
|
|
||||||
protected void ensurePositiveVolumeBBox() {
|
protected void ensurePositiveVolumeBBox() {
|
||||||
if (getModelBound() instanceof BoundingBox) {
|
if (getModelBound() instanceof BoundingBox) {
|
||||||
if (((BoundingBox)getModelBound()).getYExtent() < 0.001f) {
|
if (((BoundingBox)getModelBound()).getYExtent() < 0.001f) {
|
||||||
|
@ -55,6 +55,7 @@ import com.jme3.terrain.geomipmap.picking.BresenhamTerrainPicker;
|
|||||||
import com.jme3.terrain.geomipmap.picking.TerrainPickData;
|
import com.jme3.terrain.geomipmap.picking.TerrainPickData;
|
||||||
import com.jme3.terrain.geomipmap.picking.TerrainPicker;
|
import com.jme3.terrain.geomipmap.picking.TerrainPicker;
|
||||||
import com.jme3.util.TangentBinormalGenerator;
|
import com.jme3.util.TangentBinormalGenerator;
|
||||||
|
import com.jme3.util.clone.Cloner;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -1807,6 +1808,24 @@ public class TerrainQuad extends Node implements Terrain {
|
|||||||
return quadClone;
|
return quadClone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called internally by com.jme3.util.clone.Cloner. Do not call directly.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void cloneFields( Cloner cloner, Object original ) {
|
||||||
|
this.stepScale = cloner.clone(stepScale);
|
||||||
|
this.offset = cloner.clone(offset);
|
||||||
|
|
||||||
|
// This was not cloned before... I think that's a mistake.
|
||||||
|
this.affectedAreaBBox = cloner.clone(affectedAreaBBox);
|
||||||
|
|
||||||
|
// picker is not cloneable and not cloned. This also seems like
|
||||||
|
// a mistake if you ever load the same terrain twice.
|
||||||
|
// this.picker = cloner.clone(picker);
|
||||||
|
|
||||||
|
// neighbourFinder is also not cloned. Maybe that's ok.
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setParent(Node parent) {
|
protected void setParent(Node parent) {
|
||||||
super.setParent(parent);
|
super.setParent(parent);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user