From c8bb659043bfa0ccf9436d7cbbc49255b4c82402 Mon Sep 17 00:00:00 2001 From: Normand Briere <nbriere@noware.ca> Date: Tue, 03 Sep 2019 22:31:10 -0400 Subject: [PATCH] Paste expand. --- Object3D.java | 272 ++++++++++++++++++++++++++++++++++++------------------ 1 files changed, 182 insertions(+), 90 deletions(-) diff --git a/Object3D.java b/Object3D.java index b8c4bc0..f53b360 100644 --- a/Object3D.java +++ b/Object3D.java @@ -33,12 +33,84 @@ String skyboxname; String skyboxext; - Object3D versionlist[]; + Object3D[] versionlist; int versionindex = -1; java.util.Hashtable<java.util.UUID, Object3D> versiontable; // = new java.util.Hashtable<java.util.UUID, Object3D>(); ScriptNode scriptnode; + + void deepCopyNode(Object3D other) + { + other.skyboxname = skyboxname; + other.skyboxext = skyboxext; + + if (toParent != null) + { + other.toParent = LA.newMatrix(); + other.fromParent = LA.newMatrix(); + LA.matCopy(toParent, other.toParent); + LA.matCopy(fromParent, other.fromParent); + if (toParentMarked != null) + { + other.toParentMarked = LA.newMatrix(); + other.fromParentMarked = LA.newMatrix(); + LA.matCopy(toParentMarked, other.toParentMarked); + LA.matCopy(fromParentMarked, other.fromParentMarked); + } + } + else + { + if (other.toParent == null) +// assert(other.toParent == null); +// new Exception().printStackTrace(); + System.err.println("null parent: " + other); + } + + /* + double ident[][] = LA.newMatrix(); + if (bRep == null) + other.bRep = null; + else + other.bRep = new BoundaryRep(bRep, ident); + */ + // Really new... + //other.editWindow = null; + if (name == null) + other.name = null; + else + other.name = new String(name); + + if (material != null) + { + other.material = new cMaterial(material); + } else + { + other.material = null; + } + + other.GetTextures().name = GetTextures().name; + + CopyExtraMaterial(other); + + other.touched = touched; + other.softtouched = softtouched; + + other.random = random; + other.link2master = link2master; + other.transformcount = transformcount; + other.marked = marked; + other.skip = skip; + other.count = count; + other.flipV = flipV; + other.live = live; + other.rewind = rewind; + other.hide = hide; + other.texres = texres; + other.speedup = speedup; + other.height = height; + other.depth = depth; + } int VersionCount() { @@ -190,8 +262,39 @@ } } + boolean HasBigData() + { + if (blockloop) + return false; + + if (bRep != null) + { + return true; + } + + blockloop = true; + + for (int i = 0; i < Size(); i++) + { + Object3D child = (Object3D) get(i); + if (child == null) + continue; + if (child.HasBigData()) + { + blockloop = false; + return true; + } + } + + blockloop = false; + return false; + } + void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable) { + if (blockloop) + return; + Object3D o; boolean isnew = false; @@ -215,7 +318,7 @@ hashtable.put(GetUUID(), o); } - if (!blockloop) + //if (!blockloop) { blockloop = true; @@ -227,7 +330,7 @@ blockloop = false; } - if (isnew) + //if (isnew) ExtractBigData(o); } @@ -338,15 +441,15 @@ void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable) { + if (blockloop) + return; + if (!hashtable.containsKey(GetUUID())) return; Object3D o = hashtable.get(GetUUID()); RestoreBigData(o); - - if (blockloop) - return; blockloop = true; @@ -363,6 +466,7 @@ void RestoreBigData(Object3D o) { //System.err.println("RestoreBigData : " + this + " <-- " + o); + Grafreed.Assert(this.bRep == null); this.bRep = o.bRep; if (this.support != null && o.transientrep != null) @@ -1199,8 +1303,10 @@ // will share the geometry assert (!(this instanceof Composite)); - return deepCopy(); // Never called for Composite - + + Object3D obj = deepCopy(); // Never called for Composite + obj.count = 2; + return obj; } boolean HasLoops() @@ -1278,78 +1384,16 @@ return; blockloop = true; + + other.parent = parent; + //System.out.println("COPY " + this + " to " + other); //new Exception().printStackTrace(); + deepCopyNode(other); - other.parent = parent; - if (toParent != null) - { - other.toParent = LA.newMatrix(); - other.fromParent = LA.newMatrix(); - LA.matCopy(toParent, other.toParent); - LA.matCopy(fromParent, other.fromParent); - if (toParentMarked != null) - { - other.toParentMarked = LA.newMatrix(); - other.fromParentMarked = LA.newMatrix(); - LA.matCopy(toParentMarked, other.toParentMarked); - LA.matCopy(fromParentMarked, other.fromParentMarked); - } - } - else - { - if (other.toParent == null) -// assert(other.toParent == null); -// new Exception().printStackTrace(); - System.err.println("null parent: " + other); - } - /* - double ident[][] = LA.newMatrix(); - if (bRep == null) - other.bRep = null; - else - other.bRep = new BoundaryRep(bRep, ident); - */ - // Really new... other.bRep = bRep; // Share the geometry other.support = support; // Share the support - - //other.editWindow = null; - if (name == null) - other.name = null; - else - other.name = new String(name); - - if (material != null) - { - other.material = new cMaterial(material); - } else - { - other.material = null; - } - - other.GetTextures().name = GetTextures().name; - - CopyExtraMaterial(other); - - other.touched = touched; - other.softtouched = softtouched; - - other.random = random; - other.link2master = link2master; - other.transformcount = transformcount; - other.marked = marked; - other.skip = skip; - other.count = count; - other.flipV = flipV; - other.live = live; - other.rewind = rewind; - other.hide = hide; - other.texres = texres; - other.speedup = speedup; - other.height = height; - other.depth = depth; // aout 2013 if (/*displaylist != -1 &&*/other.displaylist != displaylist) // { @@ -1405,17 +1449,24 @@ if ((mask & GEOMETRY) != 0) { if (bRep != null) - bRep.overwriteThis(other.bRep==null?other.transientrep:other.bRep); - else - assert(other.bRep == null); - - if (bRep != null) { + bRep.overwriteThis(other.bRep==null?other.transientrep:other.bRep); CameraPane.RemoveList(bRep.displaylist); bRep.displaylist = 0; // june 2013 -1; } else - bRep = bRep; + { + //assert(other.bRep == null); + bRep = other.bRep; + } + +// if (bRep != null) +// { +// CameraPane.RemoveList(bRep.displaylist); +// bRep.displaylist = 0; // june 2013 -1; +// } +// else +// bRep = bRep; } /* Use a MASK = GEO/MAT @@ -3324,6 +3375,18 @@ } } + public void Scale(int scale) + { + Object3D obj = this; + + obj.toParent[0][0] = obj.toParent[1][1] = obj.toParent[2][2] = scale; + obj.toParent[0][1] = obj.toParent[1][0] = obj.toParent[2][0] = 0; + obj.toParent[0][2] = obj.toParent[1][2] = obj.toParent[2][1] = 0; + obj.fromParent[0][0] = obj.fromParent[1][1] = obj.fromParent[2][2] = 1/scale; + obj.fromParent[0][1] = obj.fromParent[1][0] = obj.fromParent[2][0] = 0; + obj.fromParent[0][2] = obj.fromParent[1][2] = obj.fromParent[2][1] = 0; + } + public void TextureRatioTransform(int axis) { cTexture tex = GetTextures(); @@ -4216,9 +4279,9 @@ max = new cVector(); } - for (int i = 0; i<size(); i++) + for (int i = 0; i<Size(); i++) { - Object3D child = (Object3D) reserve(i); + Object3D child = (Object3D) get(i); //reserve(i); if (child == null) continue; @@ -4237,14 +4300,14 @@ if (child.hide && !(child instanceof Merge) || child.skip) //if (child.hide) { - release(i); + //release(i); continue; } blockloop = true; child.getBounds(min, max, true); // xform); blockloop = false; - release(i); + //release(i); MinMax(minima, maxima); } @@ -6313,6 +6376,20 @@ { drawSelf(display, root, selected, blocked); } + +// if (!(this instanceof Composite)) +// { +// for (int i = 0; i < size(); i++) +// { +// Object3D child = (Object3D) reserve(i); +// if (child == null) +// continue; +// +// child.draw(display, root, selected, blocked); +// +// release(i); +// } +// } } else { /* @@ -6351,7 +6428,7 @@ } catch (Exception e) { - System.err.println("FAILED: " + this); + // System.err.println("FAILED: " + this); failedPigment = true; } @@ -6381,6 +6458,20 @@ assert(bRep.displaylist != 0); display.CallList(bRep.displaylist); // june 2013 drawSelf(display, root, selected); + } + } + + assert (!(this instanceof Composite)); + { + for (int i = 0; i < size(); i++) + { + Object3D child = (Object3D) reserve(i); + if (child == null) + continue; + + child.draw(display, root, selected, blocked); + + release(i); } } } @@ -6435,16 +6526,17 @@ void CallList(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) { - if (GetBRep() == null) - { - drawSelf(display, root, selected, blocked); - } else + if (GetBRep() != null) { DrawNode(display, root, selected); if (this instanceof BezierPatch) { //drawSelf(display, root, selected); } + } + else + { + drawSelf(display, root, selected, blocked); } } @@ -8193,7 +8285,7 @@ // if (!Globals.ADVANCED) // return objname; - return objname + " " + System.identityHashCode(this); // + GetUUID() + return objname; // + " " + System.identityHashCode(this); // + GetUUID() } public int hashCode() -- Gitblit v1.6.2