From 4113164b3be1e50251ac40d6fd65660f0a6c2e63 Mon Sep 17 00:00:00 2001 From: Normand Briere <nbriere@noware.ca> Date: Tue, 11 Jun 2019 18:46:21 -0400 Subject: [PATCH] Compressed undo stack. --- Object3D.java | 104 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 103 insertions(+), 1 deletions(-) diff --git a/Object3D.java b/Object3D.java index 8205153..5c5d71f 100644 --- a/Object3D.java +++ b/Object3D.java @@ -14,11 +14,15 @@ import //weka.core. matrix.Matrix; +import java.util.UUID; + //import net.sourceforge.sizeof.SizeOf; public class Object3D extends Vector<Object3D> implements java.io.Serializable, iSendInfo //, aurelienribon.tweenengine.TweenAccessor<Object3D> { //static final long serialVersionUID = -607422624994562685L; static final long serialVersionUID = 5022536242724664900L; + + private UUID uuid = UUID.randomUUID(); ScriptNode scriptnode; @@ -156,6 +160,67 @@ blockloop = true; child.RestoreSupports(); blockloop = false; + } +} + +void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable) +{ + if (hashtable.containsKey(GetUUID())) + { + Object3D o = hashtable.get(GetUUID()); + + assert(this.bRep == o.bRep); + if (this.bRep != null) + assert(this.bRep.support == o.transientrep); + + return; + } + + Object3D o = new Object3D(); + o.bRep = this.bRep; + if (this.bRep != null) + { + o.transientrep = this.bRep.support; + o.bRep.support = null; + } + +// o.support = this.support; +// o.fileparent = this.fileparent; +// if (this.bRep != null) +// o.bRep = this.bRep.support; + + hashtable.put(GetUUID(), o); + + this.bRep = null; +// if (this.bRep != null) +// this.bRep.support = null; +// this.support = null; +// this.fileparent = null; + + for (int i=0; i<Size(); i++) + { + get(i).ExtractBigData(hashtable); + } +} + +void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable) +{ + if (!hashtable.containsKey(GetUUID())) + return; + + Object3D o = hashtable.get(GetUUID()); + + this.bRep = o.bRep; + if (this.bRep != null) + this.bRep.support = o.transientrep; +// this.support = o.support; +// this.fileparent = o.fileparent; + + hashtable.remove(GetUUID()); + + for (int i=0; i<Size(); i++) + { + get(i).RestoreBigData(hashtable); } } @@ -5371,6 +5436,43 @@ } } + UUID GetUUID() + { + if (uuid == null) + { + // Serial + uuid = UUID.randomUUID(); + } + + return uuid; + } + + Object3D GetObject(UUID uid) + { + if (blockloop) + return null; + + if (GetUUID().equals(uid)) + return this; + + int nb = Size(); + for (int i = 0; i < nb; i++) + { + Object3D child = (Object3D) get(i); + + if (child == null) + continue; + + blockloop = true; + Object3D obj = child.GetObject(uid); + blockloop = false; + if (obj != null) + return obj; + } + + return null; + } + void SetBumpTexture(String tex) { if (GetTextures() == null) @@ -7526,7 +7628,7 @@ /*transient*/ cVector2[] projectedVertices = new cVector2[0]; Object3D /*Composite*/ parent; - Object3D /*Composite*/ fileparent; + Object3D /*Composite*/ fileparent; // In the case of FileObject double[][] toParent; // dynamic matrix double[][] fromParent; -- Gitblit v1.6.2