From bc829f47837b5a001f911542140b0b8e63c2bb0c Mon Sep 17 00:00:00 2001 From: Normand Briere <nbriere@noware.ca> Date: Sun, 14 Jul 2019 19:47:03 -0400 Subject: [PATCH] Fix extract big data. --- ObjEditor.java | 50 +++++++---- CameraPane.java | 53 ++++++------ Globals.java | 2 cRadio.java | 2 GroupEditor.java | 36 +++++++-- Mocap.java | 10 +- Object3D.java | 72 ++++++++++++----- 7 files changed, 143 insertions(+), 82 deletions(-) diff --git a/CameraPane.java b/CameraPane.java index 9699e8e..80b657b 100644 --- a/CameraPane.java +++ b/CameraPane.java @@ -11028,9 +11028,9 @@ gl.glMatrixMode(GL.GL_MODELVIEW); -//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); -//gl.glEnable(gl.GL_POLYGON_SMOOTH); -//gl.glEnable(gl.GL_MULTISAMPLE); +gl.glEnable(gl.GL_POLYGON_SMOOTH); +gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); +gl.glEnable(gl.GL_MULTISAMPLE); } else { //gl.glDisable(GL.GL_TEXTURE_2D); @@ -11041,7 +11041,7 @@ //System.out.println("BLENDING ON"); gl.glEnable(GL.GL_BLEND); gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA); - +// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE); gl.glMatrixMode(gl.GL_PROJECTION); gl.glLoadIdentity(); @@ -14297,12 +14297,12 @@ void GoDown(int mod) { MODIFIERS |= COMMAND; - /* + /**/ if((mod&SHIFT) == SHIFT) manipCamera.RotatePosition(0, -speed); else - manipCamera.BackForth(0, -speed*delta, getWidth()); - */ + manipCamera.BackForth(0, -speed*delta, 0); // getWidth()); + /**/ if ((mod & SHIFT) == SHIFT) { mouseMode = mouseMode; // VR?? @@ -14318,12 +14318,12 @@ void GoUp(int mod) { MODIFIERS |= COMMAND; - /* + /**/ if((mod&SHIFT) == SHIFT) manipCamera.RotatePosition(0, speed); else - manipCamera.BackForth(0, speed*delta, getWidth()); - */ + manipCamera.BackForth(0, speed*delta, 0); // getWidth()); + /**/ if ((mod & SHIFT) == SHIFT) { mouseMode = mouseMode; @@ -14339,12 +14339,12 @@ void GoLeft(int mod) { MODIFIERS |= COMMAND; - /* + /**/ if((mod&SHIFT) == SHIFT) - manipCamera.RotatePosition(speed, 0); - else manipCamera.Translate(speed*delta, 0, getWidth()); - */ + else + manipCamera.RotatePosition(speed, 0); + /**/ if ((mod & SHIFT) == SHIFT) { mouseMode = mouseMode; @@ -14360,12 +14360,12 @@ void GoRight(int mod) { MODIFIERS |= COMMAND; - /* + /**/ if((mod&SHIFT) == SHIFT) - manipCamera.RotatePosition(-speed, 0); - else manipCamera.Translate(-speed*delta, 0, getWidth()); - */ + else + manipCamera.RotatePosition(-speed, 0); + /**/ if ((mod & SHIFT) == SHIFT) { mouseMode = mouseMode; @@ -14946,7 +14946,9 @@ case 'E' : COMPACT ^= true; repaint(); break; - case 'W' : DEBUGHSB ^= true; + case 'W' : // Wide Window (fullscreen) + //DEBUGHSB ^= true; + ObjEditor.theFrame.ToggleFullScreen(); repaint(); break; case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break; @@ -14972,13 +14974,7 @@ repaint(); break; case 'l': - lightMode ^= true; - Globals.lighttouched = true; - manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera; - targetLookAt.set(manipCamera.lookAt); - repaint(); - break; - case 'L': + //case 'L': if (lightMode) { lightMode = false; @@ -15125,7 +15121,10 @@ // kompactbit = 6; // break; case ' ': - ObjEditor.theFrame.ToggleFullScreen(); + lightMode ^= true; + Globals.lighttouched = true; + manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera; + targetLookAt.set(manipCamera.lookAt); repaint(); break; //case '`' : diff --git a/Globals.java b/Globals.java index b46c997..2601880 100644 --- a/Globals.java +++ b/Globals.java @@ -10,7 +10,7 @@ public static boolean COMPUTESHADOWWHENLIVE = true; public static boolean RENDERSHADOW = true; - public static boolean SAVEONMAKE = false; // problems when auto-save (works with manual save) + public static boolean SAVEONMAKE = true; // problems when auto-save (works with manual save) public static boolean MOUSEDRAGGED = false; public static boolean TIMERRUNNING = false; diff --git a/GroupEditor.java b/GroupEditor.java index 84ed69e..ec26bdb 100644 --- a/GroupEditor.java +++ b/GroupEditor.java @@ -84,6 +84,10 @@ void CloneSelection(boolean supports) { + if (Globals.SAVEONMAKE) + Save(); + boolean keep = Globals.SAVEONMAKE; + Globals.SAVEONMAKE = false; // Object3D keep = GrafreeD.clipboard; //Object3D obj; for (int i=0; i<group.selection.size(); i++)// Enumeration e = group.selection.elements(); e.hasMoreElements();) @@ -94,6 +98,7 @@ makeSomething(clone, i==group.selection.size()-1); } + Globals.SAVEONMAKE = keep; } void CloneClipboard(boolean supports) @@ -380,14 +385,14 @@ shadowYItem.addActionListener(this); shadowZItem = menu.add(new MenuItem("Shadow Blue")); shadowZItem.addActionListener(this); + attributeItem = menu.add(new MenuItem("Attribute")); + attributeItem.addActionListener(this); if (Globals.ADVANCED) { menu.add("-"); linkerItem = menu.add(new MenuItem("Linker")); linkerItem.addActionListener(this); - attributeItem = menu.add(new MenuItem("Attribute")); - attributeItem.addActionListener(this); templateItem = menu.add(new MenuItem("Template")); templateItem.addActionListener(this); pointflowItem = menu.add(new MenuItem("Point Flow")); @@ -971,7 +976,7 @@ { cRadio radioButton = new cRadio(obj.name); - // Patch to avoid bug with transparency. + // June 2019. Patch to avoid bug with transparency. radioButton.hadMaterial = obj.material != null; if (!radioButton.hadMaterial) { @@ -1223,7 +1228,7 @@ // return; // } - String string = (String) object; + String string = object.toString(); // File path for Mac and Windows if (string.charAt(0) == '/' || string.charAt(1) == ':') @@ -1488,6 +1493,8 @@ reduce34MorphItem = menu.add(new MenuItem("Reduce Morphs (34)")); reduce34MorphItem.addActionListener(this); menu.add("-"); + menu.add(memoryItem = new MenuItem("Memory Usage")); + memoryItem.addActionListener(this); menu.add(computeAOItem = new MenuItem("Compute AO")); computeAOItem.addActionListener(this); @@ -1496,8 +1503,6 @@ mirrorItem = menu.add(new MenuItem("Mirror Poses")); mirrorItem.addActionListener(this); menu.add("-"); - menu.add(memoryItem = new MenuItem("Memory Usage")); - memoryItem.addActionListener(this); menu.add(analyzeItem = new MenuItem("Analyze")); analyzeItem.addActionListener(this); menu.add(dumpItem = new MenuItem("Print")); @@ -4833,8 +4838,8 @@ if (cut) { - if (Globals.SAVEONMAKE) - Save(); +// if (Globals.SAVEONMAKE) // Moved to the clipboard, no need to save. +// Save(); //int indices[] = jList.getSelectedIndices(); //for (int i = indices.length - 1; i >= 0; i--) //jList.remove(indices[i]); @@ -4937,6 +4942,10 @@ void paste(boolean expand) { + if (Globals.SAVEONMAKE) + Save(); + boolean keep = Globals.SAVEONMAKE; + Globals.SAVEONMAKE = false; // if (GrafreeD.clipboard == null) // return; boolean first = true; @@ -4996,6 +5005,7 @@ Grafreed.clipboard.get(0).parent = keepparent; } + Globals.SAVEONMAKE = keep; ResetModel(); refreshContents(); } @@ -5131,6 +5141,10 @@ void group(Object3D csg, boolean grab) { + if (Globals.SAVEONMAKE) + Save(); + boolean keep = Globals.SAVEONMAKE; + Globals.SAVEONMAKE = false; if (//false) // why?? !group.selection.isEmpty()) { @@ -5244,10 +5258,15 @@ //node.add(csg); //makeSomething(node); makeSomething(csg); + Globals.SAVEONMAKE = keep; } void Ungroup(Object3D g) { + if (Globals.SAVEONMAKE) + Save(); + boolean keep = Globals.SAVEONMAKE; + Globals.SAVEONMAKE = false; if (g instanceof HiddenObject) { HiddenObject h = (HiddenObject) g; @@ -5264,6 +5283,7 @@ objEditor.makeSomething(g.get(i), false); } } + Globals.SAVEONMAKE = keep; } void ungroup() diff --git a/Mocap.java b/Mocap.java index 545c82e..aa11165 100644 --- a/Mocap.java +++ b/Mocap.java @@ -261,6 +261,8 @@ // LA.matConcat(toParent, hip.get(0).toParent, toParent); + CameraPane.CreateSelectedPoint(); + CameraPane.debugpointG.toParent[3][0] = poship.x; CameraPane.debugpointG.toParent[3][1] = poship.y; CameraPane.debugpointG.toParent[3][2] = poship.z; @@ -649,8 +651,8 @@ { super.ExtractBigData(o); - o.bvh = this.bvh; - o.skeleton = this.skeleton; + o.savebvh = this.bvh; + o.saveskeleton = this.skeleton; this.bvh = null; this.skeleton = null; } @@ -659,8 +661,8 @@ { super.RestoreBigData(o); - this.bvh = o.bvh; - this.skeleton = o.skeleton; + this.bvh = o.savebvh; + this.skeleton = o.saveskeleton; } boolean smoothed; diff --git a/ObjEditor.java b/ObjEditor.java index 5d7d1bb..b1bbdf6 100644 --- a/ObjEditor.java +++ b/ObjEditor.java @@ -1174,10 +1174,11 @@ randomCB = AddCheckBox(setupPanel2, "Random", copy.random); randomCB.setToolTipText("Randomly Rewind (or Go back and forth)"); + link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master); + link2masterCB.setToolTipText("Attach to support"); + if (Globals.ADVANCED) { - link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master); - link2masterCB.setToolTipText("Attach to support"); speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup); speedupCB.setToolTipText("Option motion capture"); } @@ -3480,8 +3481,8 @@ try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); - java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos); - ObjectOutputStream out = new ObjectOutputStream(zstream); +// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos); + ObjectOutputStream out = new ObjectOutputStream(baos); //zstream); Object3D parent = o.parent; o.parent = null; @@ -3492,10 +3493,14 @@ out.flush(); - zstream.close(); + baos //zstream + .close(); out.close(); - return baos.toByteArray(); + byte[] bytes = baos.toByteArray(); + + System.out.println("save #bytes = " + bytes.length); + return bytes; } catch (Exception e) { System.err.println(e); @@ -3505,13 +3510,16 @@ static public Object Uncompress(byte[] bytes) { - System.out.println("#bytes = " + bytes.length); + System.out.println("restore #bytes = " + bytes.length); try { ByteArrayInputStream bais = new ByteArrayInputStream(bytes); - java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais); - ObjectInputStream in = new ObjectInputStream(istream); + //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais); + ObjectInputStream in = new ObjectInputStream(bais); // istream); Object obj = in.readObject(); + + bais //istream + .close(); in.close(); return obj; @@ -3570,7 +3578,6 @@ public void Save() { - // Default reduces the probability of heuristics errors. Save(true); } @@ -3616,8 +3623,13 @@ //EditorFrame.m_MainFrame.requestFocusInWindow(); if (!thesame) { - tab.user[tab.undoindex] = user; - tab.graphs[tab.undoindex++] = compress; + //tab.user[tab.undoindex] = user; + boolean increment = tab.graphs[tab.undoindex] == null; + + tab.graphs[tab.undoindex] = compress; + + if (increment) + tab.undoindex++; } copy.RestoreBigData(hashtable); @@ -3626,8 +3638,8 @@ for (int i = tab.undoindex; i < tab.graphs.length; i++) { - tab.user[i] = false; - tab.graphs[i] = null; + //tab.user[i] = false; + // tab.graphs[i] = null; } SetUndoStates(); @@ -3720,7 +3732,7 @@ return false; } - if (tab.graphs[tab.undoindex] == null || !tab.user[tab.undoindex]) + if (tab.graphs[tab.undoindex] == null) // || !tab.user[tab.undoindex]) { if (Save(false)) tab.undoindex -= 1; @@ -3754,8 +3766,8 @@ CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex])); - if (!tab.user[tab.undoindex]) - tab.graphs[tab.undoindex] = null; + //if (!tab.user[tab.undoindex]) + // tab.graphs[tab.undoindex] = null; } void ImportGFD() @@ -4718,8 +4730,8 @@ if (readobj != null) { - if (Globals.SAVEONMAKE) - Save(); + //if (Globals.SAVEONMAKE) // A new object cannot share meshes + // Save(); try { //readobj.deepCopySelf(copy); diff --git a/Object3D.java b/Object3D.java index 442b170..750acd4 100644 --- a/Object3D.java +++ b/Object3D.java @@ -24,9 +24,9 @@ private UUID uuid = UUID.randomUUID(); - // TEMPORARY for mocap undo - mocap.reader.BVHReader.BVHResult bvh; - Object3D skeleton; + // TEMPORARY for mocap undo. No need to be transient. + mocap.reader.BVHReader.BVHResult savebvh; + Object3D saveskeleton; // ScriptNode scriptnode; @@ -170,24 +170,35 @@ void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable) { + Object3D o; + if (hashtable.containsKey(GetUUID())) { - Object3D o = hashtable.get(GetUUID()); + o = hashtable.get(GetUUID()); Grafreed.Assert(this.bRep == o.bRep); - if (this.bRep != null) - assert(this.bRep.support == o.transientrep); + //if (this.bRep != null) + // assert(this.bRep.support == o.transientrep); + if (this.support != null) + assert(this.support.bRep == o.transientrep); + } + else + { + o = new Object3D("copy of " + this.name); - return; + hashtable.put(GetUUID(), o); } - Object3D o = new Object3D("copy of " + this.name); - - hashtable.put(GetUUID(), o); - - for (int i=0; i<Size(); i++) + if (!blockloop) { - get(i).ExtractBigData(hashtable); + blockloop = true; + + for (int i=0; i<Size(); i++) + { + get(i).ExtractBigData(hashtable); + } + + blockloop = false; } ExtractBigData(o); @@ -195,11 +206,23 @@ void ExtractBigData(Object3D o) { + if (o.bRep != null) + Grafreed.Assert(o.bRep == this.bRep); + o.bRep = this.bRep; - if (this.bRep != null) +// July 2019 if (this.bRep != null) +// { +// o.transientrep = this.bRep.support; +// o.bRep.support = null; +// } + + if (this.support != null) { - o.transientrep = this.bRep.support; - o.bRep.support = null; + if (o.transientrep != null) + Grafreed.Assert(o.transientrep == this.support.bRep); + + o.transientrep = this.support.bRep; + this.support.bRep = null; } // o.support = this.support; @@ -219,14 +242,14 @@ if (!hashtable.containsKey(GetUUID())) return; + Object3D o = hashtable.get(GetUUID()); + + RestoreBigData(o); + if (blockloop) return; blockloop = true; - - Object3D o = hashtable.get(GetUUID()); - - RestoreBigData(o); //hashtable.remove(GetUUID()); @@ -241,8 +264,12 @@ void RestoreBigData(Object3D o) { this.bRep = o.bRep; - if (this.bRep != null) - this.bRep.support = o.transientrep; + if (this.support != null && o.transientrep != null) + { + this.support.bRep = o.transientrep; + } +// July 2019 if (this.bRep != null) +// this.bRep.support = o.transientrep; // this.support = o.support; // this.fileparent = o.fileparent; } @@ -1374,6 +1401,7 @@ toParent = LA.newMatrix(); fromParent = LA.newMatrix(); } + LA.matCopy(other.toParent, toParent); LA.matCopy(other.fromParent, fromParent); diff --git a/cRadio.java b/cRadio.java index 03fab54..af43de0 100644 --- a/cRadio.java +++ b/cRadio.java @@ -36,7 +36,7 @@ } byte[] graphs[] = new byte[100][]; - boolean[] user = new boolean[100]; + //boolean[] user = new boolean[100]; int undoindex = 0; -- Gitblit v1.6.2