com.jme3.util.clone.Cloner Java Examples
The following examples show how to use
com.jme3.util.clone.Cloner.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BatchNode.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Called internally by com.jme3.util.clone.Cloner. Do not call directly. */ @Override public void cloneFields(Cloner cloner, Object original) { super.cloneFields(cloner, original); this.batches = cloner.clone(batches); this.tmpFloat = cloner.clone(tmpFloat); this.tmpFloatN = cloner.clone(tmpFloatN); this.tmpFloatT = cloner.clone(tmpFloatT); HashMap<Geometry, Batch> newBatchesByGeom = new HashMap<Geometry, Batch>(); for (Map.Entry<Geometry, Batch> e : batchesByGeom.entrySet()) { newBatchesByGeom.put(cloner.clone(e.getKey()), cloner.clone(e.getValue())); } this.batchesByGeom = newBatchesByGeom; }
Example #2
Source File: TerrainQuad.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Called internally by com.jme3.util.clone.Cloner. Do not call directly. */ @Override public void cloneFields( Cloner cloner, Object original ) { super.cloneFields(cloner, 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); // Otherwise, picker would be cloned by reference and thus "this" would be wrong this.picker = new BresenhamTerrainPicker(this); // neighbourFinder is also not cloned. Maybe that's ok. }
Example #3
Source File: TerrainPatch.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Called internally by com.jme3.util.clone.Cloner. Do not call directly. */ @Override public void cloneFields( Cloner cloner, Object original ) { super.cloneFields(cloner, 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(); }
Example #4
Source File: AudioNode.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Called internally by com.jme3.util.clone.Cloner. Do not call directly. */ @Override public void cloneFields( Cloner cloner, Object original ) { super.cloneFields(cloner, original); this.direction=cloner.clone(direction); this.velocity=velocityFromTranslation?new Vector3f():cloner.clone(velocity); this.previousWorldTranslation=Vector3f.NAN.clone(); // Change in behavior: the filters were not cloned before meaning // that two cloned audio nodes would share the same filter instance. // While settings will only be applied when the filter is actually // set, I think it's probably surprising to callers if the values of // a filter change from one AudioNode when a different AudioNode's // filter attributes are updated. // Plus if they disable and re-enable the thing using the filter then // the settings get reapplied and it might be surprising to have them // suddenly be strange. // ...so I'll clone them. -pspeed this.dryFilter = cloner.clone(dryFilter); this.reverbFilter = cloner.clone(reverbFilter); }
Example #5
Source File: Spatial.java From jmonkeybuilder with Apache License 2.0 | 6 votes |
/** * @return Similar to Spatial.clone() except will create a deep clone of all * geometries' meshes. Normally this method shouldn't be used. Instead, use * Spatial.clone() * * @see Spatial#clone() */ public Spatial deepClone() { // Setup the cloner for the type of cloning we want to do. Cloner cloner = new Cloner(); // First, we definitely do not want to clone our own parent cloner.setClonedValue(parent, null); Spatial clone = cloner.clone(this); // Because we've nulled the parent out we need to make sure // the transforms and stuff get refreshed. clone.setTransformRefresh(); clone.setLightListRefresh(); clone.setMatParamOverrideRefresh(); return clone; }
Example #6
Source File: BitmapTextPage.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Called internally by com.jme3.util.clone.Cloner. Do not call directly. */ @Override public void cloneFields( Cloner cloner, Object original ) { Mesh originalMesh = this.mesh; super.cloneFields(cloner, original); // BitmapTextPage always requires a new mesh or different // BitmapText instances will clobber one another. // But if we were already deep cloning meshes then we don't // want to do it again... so we'll check first. if( this.mesh == originalMesh ) { this.mesh = mesh.deepClone(); } }
Example #7
Source File: BitmapText.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Called internally by com.jme3.util.clone.Cloner. Do not call directly. */ @Override public void cloneFields( Cloner cloner, Object original ) { super.cloneFields(cloner, original); textPages = textPages.clone(); for( int i = 0; i < textPages.length; i++ ) { textPages[i] = cloner.clone(textPages[i]); } // Cannot use the cloner to clone the StringBlock because it // is package private... so we'll forgo the (probably unnecessary) // reference fixup in this case and just clone it directly. //this.block = cloner.clone(block); this.block = block != null ? block.clone() : null; // Change in behavior: The 'letters' field was not cloned or recreated // before. I'm not sure how this worked and suspect BitmapText was just // not cloneable if you planned to change the text later. -pspeed this.letters = new Letters(font, block, letters.getQuad().isRightToLeft()); // Just noticed BitmapText is not even writable/readable really... // so I guess cloning doesn't come up that often. }
Example #8
Source File: DacLinks.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Callback from {@link com.jme3.util.clone.Cloner} to convert this * shallow-cloned control into a deep-cloned one, using the specified cloner * and original to resolve copied fields. * * @param cloner the cloner that's cloning this control (not null, modified) * @param original the control from which this control was shallow-cloned * (not null, unaffected) */ @Override public void cloneFields(Cloner cloner, Object original) { super.cloneFields(cloner, original); DacLinks originalDac = (DacLinks) original; boneLinkList = cloner.clone(boneLinkList); boneLinks = new HashMap<>(32); for (Map.Entry<String, BoneLink> entry : originalDac.boneLinks.entrySet()) { String boneName = entry.getKey(); BoneLink link = entry.getValue(); BoneLink copyLink = cloner.clone(link); boneLinks.put(boneName, copyLink); } skeleton = cloner.clone(skeleton); transformer = cloner.clone(transformer); torsoLink = cloner.clone(torsoLink); }
Example #9
Source File: WaterFilter.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void cloneFields(final Cloner cloner, final Object original) { this.normalTexture = cloner.clone(normalTexture); this.foamTexture = cloner.clone(foamTexture); this.causticsTexture = cloner.clone(causticsTexture); this.heightTexture = cloner.clone(heightTexture); this.targetLocation = cloner.clone(targetLocation); this.biasMatrix = cloner.clone(biasMatrix); this.textureProjMatrix = cloner.clone(textureProjMatrix); this.lightDirection = cloner.clone(lightDirection); this.lightColor = cloner.clone(lightColor); this.waterColor = cloner.clone(waterColor); this.deepWaterColor = cloner.clone(deepWaterColor); this.colorExtinction = cloner.clone(colorExtinction); this.foamExistence = cloner.clone(foamExistence); this.windDirection = cloner.clone(windDirection); }
Example #10
Source File: AnimControl.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void cloneFields( Cloner cloner, Object original ) { super.cloneFields(cloner, original); this.skeleton = cloner.clone(skeleton); // Note cloneForSpatial() never actually cloned the animation map... just its reference HashMap<String, Animation> newMap = new HashMap<>(); // animationMap is cloned, but only ClonableTracks will be cloned as they need a reference to a cloned spatial for( Map.Entry<String, Animation> e : animationMap.entrySet() ) { newMap.put(e.getKey(), cloner.clone(e.getValue())); } this.animationMap = newMap; }
Example #11
Source File: Animation.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void cloneFields( Cloner cloner, Object original ) { // There is some logic here that I'm copying but I'm not sure if // it's a mistake or not. If a track is not a CloneableTrack then it // isn't cloned at all... even though they all implement clone() methods. -pspeed SafeArrayList<Track> newTracks = new SafeArrayList<>(Track.class); for( Track track : tracks ) { if (track instanceof JmeCloneable) { newTracks.add(cloner.clone(track)); } else { // this is the part that seems fishy newTracks.add(track); } } this.tracks = newTracks; }
Example #12
Source File: Spatial.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * @return Similar to Spatial.clone() except will create a deep clone of all * geometries' meshes. Normally this method shouldn't be used. Instead, use * Spatial.clone() * * @see Spatial#clone() */ public Spatial deepClone() { // Setup the cloner for the type of cloning we want to do. Cloner cloner = new Cloner(); // First, we definitely do not want to clone our own parent cloner.setClonedValue(parent, null); Spatial clone = cloner.clone(this); // Because we've nulled the parent out we need to make sure // the transforms and stuff get refreshed. clone.setTransformRefresh(); clone.setLightListRefresh(); clone.setMatParamOverrideRefresh(); return clone; }
Example #13
Source File: AnimClip.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void cloneFields(Cloner cloner, Object original) { AnimTrack[] newTracks = new AnimTrack[tracks.length]; for (int i = 0; i < tracks.length; i++) { newTracks[i] = (cloner.clone(tracks[i])); } this.tracks = newTracks; }
Example #14
Source File: SkinningControl.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void cloneFields(Cloner cloner, Object original) { super.cloneFields(cloner, original); this.armature = cloner.clone(armature); // If the targets were cloned then this will clone them. If the targets // were shared then this will share them. this.targets = cloner.clone(targets); this.numberOfJointsParam = cloner.clone(numberOfJointsParam); this.jointMatricesParam = cloner.clone(jointMatricesParam); }
Example #15
Source File: Mesh.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Called internally by com.jme3.util.clone.Cloner. Do not call directly. */ @Override public void cloneFields(Cloner cloner, Object original) { // Probably could clone this now but it will get regenerated anyway. this.collisionTree = null; this.meshBound = cloner.clone(meshBound); this.buffersList = cloner.clone(buffersList); this.buffers = cloner.clone(buffers); this.lodLevels = cloner.clone(lodLevels); this.elementLengths = cloner.clone(elementLengths); this.modeStart = cloner.clone(modeStart); }
Example #16
Source File: InstancedGeometry.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Called internally by com.jme3.util.clone.Cloner. Do not call directly. */ @Override public void cloneFields( Cloner cloner, Object original ) { super.cloneFields(cloner, original); this.globalInstanceData = cloner.clone(globalInstanceData); this.transformInstanceData = cloner.clone(transformInstanceData); this.geometries = cloner.clone(geometries); }
Example #17
Source File: RadialParticleInfluencer.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Called internally by com.jme3.util.clone.Cloner. Do not call directly. */ @Override public void cloneFields( Cloner cloner, Object original ) { super.cloneFields(cloner, original); // Change in behavior: the old origin was not cloned -pspeed this.origin = cloner.clone(origin); }
Example #18
Source File: DefaultParticleInfluencer.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Called internally by com.jme3.util.clone.Cloner. Do not call directly. */ @Override public void cloneFields( Cloner cloner, Object original ) { this.initialVelocity = cloner.clone(initialVelocity); // Change in behavior: I'm cloning 'for real' the 'temp' field because // otherwise it will be shared across all clones. Note: if this is // ok because of how its used then it might as well be static and let // everything share it. // Note 2: transient fields _are_ cloned just like anything else so // thinking it wouldn't get cloned is also not right. // -pspeed this.temp = cloner.clone(temp); }
Example #19
Source File: PointLightShadowRenderer.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void cloneFields(final Cloner cloner, final Object original) { light = cloner.clone(light); init((int) shadowMapSize); frustums = null; super.cloneFields(cloner, original); }
Example #20
Source File: Joint.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void cloneFields(Cloner cloner, Object original) { this.children = cloner.clone(children); this.parent = cloner.clone(parent); this.attachedNode = cloner.clone(attachedNode); this.targetGeometry = cloner.clone(targetGeometry); this.localTransform = cloner.clone(localTransform); this.inverseModelBindMatrix = cloner.clone(inverseModelBindMatrix); }
Example #21
Source File: Armature.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void cloneFields(Cloner cloner, Object original) { this.rootJoints = cloner.clone(rootJoints); this.jointList = cloner.clone(jointList); this.skinningMatrixes = cloner.clone(skinningMatrixes); for (Joint joint : jointList) { instanciateJointModelTransform(joint); } }
Example #22
Source File: ParticleEmitter.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Called internally by com.jme3.util.clone.Cloner. Do not call directly. */ @Override public void cloneFields( Cloner cloner, Object original ) { super.cloneFields(cloner, original); this.shape = cloner.clone(shape); this.control = cloner.clone(control); this.faceNormal = cloner.clone(faceNormal); this.startColor = cloner.clone(startColor); this.endColor = cloner.clone(endColor); this.particleInfluencer = cloner.clone(particleInfluencer); // change in behavior: gravity was not cloned before -pspeed this.gravity = cloner.clone(gravity); // So, simply setting the mesh type will cause all kinds of things // to happen: // 1) the new mesh gets created. // 2) it is set to the Geometry // 3) the particles array is recreated because setNumParticles() // // ...so this should be equivalent but simpler than half of the old clone() // method. Note: we do not ever want to share particleMesh so we do not // clone it at all. setMeshType(meshType); // change in behavior: temp and lastPos were not cloned before... // perhaps because it was believed that 'transient' fields were exluded // from cloning? (they aren't) // If it was ok for these to be shared because of how they are used // then they could just as well be made static... else I think it's clearer // to clone them. this.temp = cloner.clone(temp); this.lastPos = cloner.clone(lastPos); }
Example #23
Source File: Spatial.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Called internally by com.jme3.util.clone.Cloner. Do not call directly. */ @Override @SuppressWarnings("unchecked") public void cloneFields(Cloner cloner, Object original) { // Clone all of the fields that need fix-ups and/or potential // sharing. this.parent = cloner.clone(parent); this.worldBound = cloner.clone(worldBound); this.worldLights = cloner.clone(worldLights); this.localLights = cloner.clone(localLights); this.worldTransform = cloner.clone(worldTransform); this.localTransform = cloner.clone(localTransform); this.worldOverrides = cloner.clone(worldOverrides); this.localOverrides = cloner.clone(localOverrides); this.controls = cloner.clone(controls); // Cloner doesn't handle maps on its own just yet. // Note: this is more advanced cloning than the old clone() method // did because it just shallow cloned the map. In this case, we want // to avoid all of the nasty cloneForSpatial() fixup style code that // used to inject stuff into the clone's user data. By using cloner // to clone the user data we get this automatically. if (userData != null) { userData = (HashMap<String, Savable>) userData.clone(); for (Map.Entry<String, Savable> e : userData.entrySet()) { Savable value = e.getValue(); if (value instanceof Cloneable) { // Note: all JmeCloneable objects are also Cloneable so this // catches both cases. e.setValue(cloner.clone(value)); } } } }
Example #24
Source File: AssetLinkNode.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Called internally by com.jme3.util.clone.Cloner. Do not call directly. */ @Override public void cloneFields( Cloner cloner, Object original ) { super.cloneFields(cloner, original); // This is a change in behavior because the old version did not clone // this list... changes to one clone would be reflected in all. // I think that's probably undesirable. -pspeed this.assetLoaderKeys = cloner.clone(assetLoaderKeys); this.assetChildren = new HashMap<ModelKey, Spatial>(); }
Example #25
Source File: Node.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Called internally by com.jme3.util.clone.Cloner. Do not call directly. */ @Override public void cloneFields(Cloner cloner, Object original) { super.cloneFields(cloner, original); this.children = cloner.clone(children); // Only the outer cloning thing knows whether this should be nulled // or not... after all, we might be cloning a root node in which case // cloning this list is fine. this.updateList = cloner.clone(updateList); }
Example #26
Source File: Geometry.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Called internally by com.jme3.util.clone.Cloner. Do not call directly. */ @Override public void cloneFields(Cloner cloner, Object original) { super.cloneFields(cloner, original); // If this is a grouped node and if our group node is // also cloned then we'll grab its reference. if (groupNode != null) { if (cloner.isCloned(groupNode)) { // Then resolve the reference this.groupNode = cloner.clone(groupNode); } else { // We are on our own now this.groupNode = null; this.startIndex = -1; } // The above is based on the fact that if we were // cloning the hierarchy that contained the parent // group then it would have been shallow cloned before // this child. Can't really be otherwise. } this.cachedWorldMat = cloner.clone(cachedWorldMat); // See if we are doing a shallow clone or a deep mesh clone boolean shallowClone = (cloner.getCloneFunction(Mesh.class) instanceof IdentityCloneFunction); // See if we clone the mesh using the special animation // semi-deep cloning if (shallowClone && mesh != null && mesh.getBuffer(Type.BindPosePosition) != null) { // Then we need to clone the mesh a little deeper this.mesh = mesh.cloneForAnim(); } else { // Do whatever the cloner wants to do about it this.mesh = cloner.clone(mesh); } this.material = cloner.clone(material); }
Example #27
Source File: CameraNode.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Called internally by com.jme3.util.clone.Cloner. Do not call directly. */ @Override public void cloneFields( Cloner cloner, Object original ) { super.cloneFields(cloner, original); // A change in behavior... I think previously CameraNode was probably // not really cloneable... or at least its camControl would be pointing // to the wrong control. -pspeed this.camControl = cloner.clone(camControl); }
Example #28
Source File: Spatial.java From jmonkeybuilder with Apache License 2.0 | 5 votes |
/** * Called internally by com.jme3.util.clone.Cloner. Do not call directly. */ @Override public void cloneFields( Cloner cloner, Object original ) { // Clone all of the fields that need fix-ups and/or potential // sharing. this.parent = cloner.clone(parent); this.worldBound = cloner.clone(worldBound); this.worldLights = cloner.clone(worldLights); this.localLights = cloner.clone(localLights); this.worldTransform = cloner.clone(worldTransform); this.localTransform = cloner.clone(localTransform); this.worldOverrides = cloner.clone(worldOverrides); this.localOverrides = cloner.clone(localOverrides); this.controls = cloner.clone(controls); // Cloner doesn't handle maps on its own just yet. // Note: this is more advanced cloning than the old clone() method // did because it just shallow cloned the map. In this case, we want // to avoid all of the nasty cloneForSpatial() fixup style code that // used to inject stuff into the clone's user data. By using cloner // to clone the user data we get this automatically. if( userData != null ) { userData = (HashMap<String, Savable>)userData.clone(); for( Map.Entry<String, Savable> e : userData.entrySet() ) { Savable value = e.getValue(); if( value instanceof Cloneable ) { // Note: all JmeCloneable objects are also Cloneable so this // catches both cases. e.setValue(cloner.clone(value)); } } } }
Example #29
Source File: SkeletonDebugger.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void cloneFields(Cloner cloner, Object original) { super.cloneFields(cloner, original); this.wires = cloner.clone(wires); this.points = cloner.clone(points); this.interBoneWires = cloner.clone(interBoneWires); }
Example #30
Source File: LightNode.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Called internally by com.jme3.util.clone.Cloner. Do not call directly. */ @Override public void cloneFields( Cloner cloner, Object original ) { super.cloneFields(cloner, original); // A change in behavior... I think previously LightNode was probably // not really cloneable... or at least its lightControl would be pointing // to the wrong control. -pspeed this.lightControl = cloner.clone(lightControl); }