From 46dbce888e7c3eff8969f1ddbe22e144410b67f4 Mon Sep 17 00:00:00 2001
From: Normand Briere <nbriere@noware.ca>
Date: Sun, 07 Jul 2019 10:20:06 -0400
Subject: [PATCH] Put back serial IDs for cone and torus.

---
 ObjEditor.java |   91 ++++++++++++++++++++++++++++++++++++---------
 1 files changed, 72 insertions(+), 19 deletions(-)

diff --git a/ObjEditor.java b/ObjEditor.java
index 1779397..5d7d1bb 100644
--- a/ObjEditor.java
+++ b/ObjEditor.java
@@ -449,7 +449,7 @@
 // TEXTAREA           infoarea.setLineWrap(true);
 // TEXTAREA           infoarea.setWrapStyleWord(true);
         infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
-        //infoPanel.setPreferredSize(new Dimension(50, 200));
+        infoPanel.setPreferredSize(new Dimension(1, 1));
         infoPanel.setName("Info");
         //infoPanel.setLayout(new BorderLayout());
         //infoPanel.add(createTextPane());
@@ -1494,7 +1494,7 @@
 //        objectPanel.add(north);
         objectPanel.add(editPanel);
         
-        if (Globals.ADVANCED)
+        //if (Globals.ADVANCED)
             objectPanel.add(infoPanel);
         
         objectPanel.add(toolboxPanel);
@@ -1979,8 +1979,9 @@
             // 3D models
             if (filename.endsWith(".3ds") || filename.endsWith(".3DS"))
             {
-                lastConverter = new com.jmex.model.converters.MaxToJme();
-                LoadFile(filename, lastConverter);
+                //lastConverter = new com.jmex.model.converters.MaxToJme();
+                //LoadFile(filename, lastConverter);
+                LoadObjFile(filename); // New 3ds loader
                 continue;
             }
             if (filename.endsWith(".dae") || filename.endsWith(".DAE"))
@@ -2706,6 +2707,7 @@
                 LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2);
                 LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2);
             }
+            
             //cJME.count++;
             //cJME.count %= 12;
             if (gc)
@@ -2889,6 +2891,7 @@
             }
         }
     }
+    
     cFileSystemPane FSPane;
 
     void SetMaterial(cMaterial mat, Object3D.cVector2[] others)
@@ -2942,6 +2945,7 @@
                 }
             }
         }
+        
         freezematerial = false;
     }
 
@@ -3201,10 +3205,6 @@
         {
             ToggleAnimation();
             return;
-        } else if (event.getSource() == archiveItem)
-        {
-            cTools.Archive(frame);
-            return;
         } else if (event.getSource() == flipVCB)
         {
             copy.flipV ^= true;
@@ -3425,6 +3425,10 @@
         {
             generatePOV();
             //return true;
+        } else if (event.getSource() == archiveItem)
+        {
+            cTools.Archive(frame);
+            return;
         } else if (source == zBufferItem)
         {
             try
@@ -3566,6 +3570,28 @@
     
     public void Save()
     {
+        // Default reduces the probability of heuristics errors.
+        Save(true);
+    }
+    
+    private boolean Equal(byte[] compress, byte[] name)
+    {
+        if (compress.length != name.length)
+        {
+            return false;
+        }
+        
+        for (int i=compress.length; --i>=0;)
+        {
+            if (compress[i] != name[i])
+                return false;
+        }
+        
+        return true;
+    }
+
+    public boolean Save(boolean user)
+    {
         System.err.println("Save");
         
         cRadio tab = GetCurrentTab();
@@ -3576,18 +3602,31 @@
         copy.ExtractBigData(hashtable);
         
         byte[] compress = Compress(copy);
-        
-        //EditorFrame.m_MainFrame.requestFocusInWindow();
-        tab.graphs[tab.undoindex++] = compress;
-
-        copy.RestoreBigData(hashtable);
 
         CameraPane.SWITCH = temp;
         
+        boolean thesame = false;
+        
+        // Quick heuristic using length. Works only when stream is compressed.
+        if (tab.undoindex > 0 && tab.graphs[tab.undoindex-1] != null && Equal(compress, tab.graphs[tab.undoindex-1]))
+        {
+            thesame = true;
+        }
+        
+        //EditorFrame.m_MainFrame.requestFocusInWindow();
+        if (!thesame)
+        {
+            tab.user[tab.undoindex] = user;
+            tab.graphs[tab.undoindex++] = compress;
+        }
+
+        copy.RestoreBigData(hashtable);
+
         //assert(hashtable.isEmpty());
         
         for (int i = tab.undoindex; i < tab.graphs.length; i++)
         {
+            tab.user[i] = false;
             tab.graphs[i] = null;
         }
 
@@ -3611,6 +3650,8 @@
                 e.printStackTrace();
             }
         }
+        
+        return !thesame;
     }
 
     void CopyChanged(Object3D obj)
@@ -3667,7 +3708,7 @@
         redoButton.setEnabled(tab.graphs[tab.undoindex + 1] != null);
     }
     
-    public void Undo()
+    public boolean Undo()
     {
         System.err.println("Undo");
         
@@ -3676,18 +3717,27 @@
         if (tab.undoindex == 0)
         {
             java.awt.Toolkit.getDefaultToolkit().beep();
-            return;
+            return false;
         }
 
-        if (tab.graphs[tab.undoindex] == null)
+        if (tab.graphs[tab.undoindex] == null || !tab.user[tab.undoindex])
         {
-            Save();
-            tab.undoindex -= 1;
+            if (Save(false))
+                tab.undoindex -= 1;
+            else
+            {
+                if (tab.undoindex <= 0)
+                    return false;
+                else
+                    tab.undoindex -= 1;
+            }
         }
 
         tab.undoindex -= 1;
 
         CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
+        
+        return true;
     }
 
     public void Redo()
@@ -3703,6 +3753,9 @@
         tab.undoindex += 1;
 
         CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
+        
+        if (!tab.user[tab.undoindex])
+            tab.graphs[tab.undoindex] = null;
     }
 
         void ImportGFD()
@@ -5035,7 +5088,7 @@
     CheckboxMenuItem toggleSwitchItem;
     CheckboxMenuItem toggleRootItem;
     CheckboxMenuItem animationItem;
-    CheckboxMenuItem archiveItem;
+    MenuItem archiveItem;
     CheckboxMenuItem toggleHandleItem;
     CheckboxMenuItem togglePaintItem;
     JSplitPane mainPanel;

--
Gitblit v1.6.2