From 0c7b833be7d86598a6813cd1c6db0ca9e1b17966 Mon Sep 17 00:00:00 2001 From: Normand Briere <nbriere@noware.ca> Date: Wed, 21 Aug 2019 23:22:47 -0400 Subject: [PATCH] Clear versions. --- Object3D.java | 253 +++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 198 insertions(+), 55 deletions(-) diff --git a/Object3D.java b/Object3D.java index b4b1eb5..5df575e 100644 --- a/Object3D.java +++ b/Object3D.java @@ -22,6 +22,7 @@ //static final long serialVersionUID = -607422624994562685L; static final long serialVersionUID = 5022536242724664900L; + // Use GetUUID for backward compatibility with null. private UUID uuid = UUID.randomUUID(); // TEMPORARY for mocap undo. No need to be transient. @@ -29,9 +30,14 @@ Object3D saveskeleton; // - byte[] versions[]; + String skyboxname; + String skyboxext; + + Object3D versionlist[]; int versionindex = -1; + java.util.Hashtable<java.util.UUID, Object3D> versiontable; // = new java.util.Hashtable<java.util.UUID, Object3D>(); + ScriptNode scriptnode; void InitOthers() @@ -219,7 +225,7 @@ // o.bRep.support = null; // } o.selection = this.selection; - o.versions = this.versions; + o.versionlist = this.versionlist; o.versionindex = this.versionindex; if (this.support != null) @@ -241,6 +247,73 @@ // this.bRep.support = null; // this.support = null; // this.fileparent = null; + } + +// Object3D GetObject(java.util.UUID uuid) +// { +// if (this.uuid.equals(uuid)) +// return this; +// +// if (blockloop) +// return null; +// +// blockloop = true; +// +// for (int i=0; i<Size(); i++) +// { +// Object3D o = get(i).GetObject(uuid); +// +// if (o != null) +// return o; +// } +// +// blockloop = false; +// +// return null; +// } + + transient boolean tag; + + void TagObjects(Object3D o, boolean tag) + { + if (blockloop) + return; + + o.tag = tag; + + if (o == this) + return; + + blockloop = true; + + for (int i=0; i<Size(); i++) + { + get(i).TagObjects(o, tag); + } + + blockloop = false; + } + + boolean HasTags() + { + if (blockloop) + return false; + + blockloop = true; + + boolean hasTags = false; + + for (int i=0; i<Size(); i++) + { + hasTags |= get(i).tag || get(i).HasTags(); + + if (hasTags) + break; + } + + blockloop = false; + + return hasTags; } void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable) @@ -277,7 +350,7 @@ this.selection = o.selection; - this.versions = o.versions; + this.versionlist = o.versionlist; this.versionindex = o.versionindex; // July 2019 if (this.bRep != null) // this.bRep.support = o.transientrep; @@ -1011,6 +1084,9 @@ if (material == null || material.multiply) return true; + + if (projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000) + return false; // Transparent objects are dynamic because we have to sort the triangles. return material.opacity > 0.99; @@ -2438,6 +2514,11 @@ else { //((ObjEditor)editWindow).SetupUI2(null); + if (objectUI != null) + ((ObjEditor)objectUI).pinButton.setSelected(pinned); + else + //new Exception().printStackTrace(); + System.err.println("objectUI is null"); } } @@ -3541,15 +3622,47 @@ void ClearMaterials() { + if (blockloop) + return; + + blockloop = true; + ClearMaterial(); - for (int i = 0; i < size(); i++) + for (int i = 0; i < Size(); i++) { - Object3D child = (Object3D) reserve(i); + Object3D child = (Object3D) get(i); if (child == null) continue; child.ClearMaterials(); - release(i); } + + blockloop = false; + } + + void ClearVersionList() + { + this.versionlist = null; + this.versionindex = -1; + this.versiontable = null; + } + + void ClearVersions() + { + if (blockloop) + return; + + blockloop = true; + + ClearVersionList(); + for (int i = 0; i < Size(); i++) + { + Object3D child = (Object3D) get(i); + if (child == null) + continue; + child.ClearVersions(); + } + + blockloop = false; } void FlipV(boolean flip) @@ -5539,6 +5652,11 @@ if (fullname == null) return ""; + if (fullname.pigment != null) + { + return fullname.pigment; + } + // System.out.println("Fullname = " + fullname); // Does not work on Windows due to C: @@ -5551,7 +5669,7 @@ if (split.length == 0) { - return ""; + return fullname.pigment = ""; } if (split.length <= 2) @@ -5559,22 +5677,27 @@ if (fullname.name.endsWith(":")) { // Windows - return fullname.name.substring(0, fullname.name.length()-1); + return fullname.pigment = fullname.name.substring(0, fullname.name.length()-1); } - return split[0]; + return fullname.pigment = split[0]; } // Windows assert(split.length == 4); - return split[0] + ":" + split[1]; + return fullname.pigment = split[0] + ":" + split[1]; } static String GetBump(cTexture fullname) { if (fullname == null) return ""; + + if (fullname.bump != null) + { + return fullname.bump; + } // System.out.println("Fullname = " + fullname); // Does not work on Windows due to C: @@ -5586,12 +5709,12 @@ if (split.length == 0) { - return ""; + return fullname.bump = ""; } if (split.length == 1) { - return ""; + return fullname.bump = ""; } if (split.length == 2) @@ -5599,16 +5722,16 @@ if (fullname.name.endsWith(":")) { // Windows - return ""; + return fullname.bump = ""; } - return split[1]; + return fullname.bump = split[1]; } // Windows assert(split.length == 4); - return split[2] + ":" + split[3]; + return fullname.bump = split[2] + ":" + split[3]; } String GetPigmentTexture() @@ -5691,6 +5814,9 @@ texname = ""; GetTextures().name = texname + ":" + GetBump(GetTextures()); + + GetTextures().pigment = null; + Touch(); } @@ -5763,6 +5889,8 @@ texname = ""; GetTextures().name = Object3D.GetPigment(GetTextures()) + ":" + texname; + + GetTextures().bump = null; Touch(); } @@ -5906,8 +6034,10 @@ if (support != null) support = support; - //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch); - boolean usecalllists = false; //!IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch); + boolean usecalllists = !IsLive() && IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch); + //boolean usecalllists = false; //!IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch); + + //usecalllists &= display.DrawMode() == display.DEFAULT; // Don't compute list in shadow pass. if (!usecalllists && bRep != null && bRep.displaylist > 0) { @@ -5917,8 +6047,9 @@ // usecalllists &= !(parent instanceof RandomNode); // usecalllists = false; - if (GetBRep() != null) - usecalllists = usecalllists; + if (display.DrawMode() == display.SHADOW) + //GetBRep() != null) + usecalllists = !!usecalllists; //System.out.println("draw " + this); //new Exception().printStackTrace(); @@ -5940,7 +6071,7 @@ if (!(this instanceof Composite)) touched = false; //if (displaylist == -1 && usecalllists) - if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013 + if (bRep.displaylist <= 0 && usecalllists) // && display.DrawMode() == display.DEFAULT) // june 2013 { bRep.displaylist = display.GenList(); assert(bRep.displaylist != 0); @@ -5951,7 +6082,7 @@ //System.out.println("\tnew list " + list); //gl.glDrawBuffer(gl.GL_NONE); - if (usecalllists) + if (usecalllists && bRep.displaylist > 0) { // System.err.println("new list " + bRep.displaylist + " for " + this); display.NewList(bRep.displaylist); @@ -5960,7 +6091,7 @@ CallList(display, root, selected, blocked); // compiled = true; - if (usecalllists) + if (usecalllists && bRep.displaylist > 0) { // System.err.println("end list " + bRep.displaylist + " for " + this); display.EndList(); @@ -7364,7 +7495,7 @@ boundary.y = spot.y - 30; boundary.width = spot.width + 60; boundary.height = spot.height + 60; - clickInfo.g.setColor(Color.red); + clickInfo.g.setColor(Color.white); int spotw = spot.x + spot.width; int spoth = spot.y + spot.height; clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height); @@ -7384,7 +7515,29 @@ // { // CameraPane.Ymax = spoth; // } - spot.translate(32, 32); +// if (CameraPane.Xmin > spot.x) +// { +// CameraPane.Xmin = spot.x; +// } +// if (CameraPane.Xmax < spotw) +// { +// CameraPane.Xmax = spotw; +// } +// if (CameraPane.Ymin > spot.y) +// { +// CameraPane.Ymin = spot.y; +// } +// if (CameraPane.Ymax < spoth) +// { +// CameraPane.Ymax = spoth; +// } + // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15 + //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15 + spot.translate(32, 0); + clickInfo.g.setColor(Color.yellow); + clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height); + + spot.translate(32, 64); spotw = spot.x + spot.width; spoth = spot.y + spot.height; clickInfo.g.setColor(Color.cyan); @@ -7405,28 +7558,7 @@ // { // CameraPane.Ymax = spoth; // } - // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15 - //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15 - spot.translate(0, -32); - clickInfo.g.setColor(Color.yellow); - clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height); clickInfo.g.setColor(Color.green); -// if (CameraPane.Xmin > spot.x) -// { -// CameraPane.Xmin = spot.x; -// } -// if (CameraPane.Xmax < spotw) -// { -// CameraPane.Xmax = spotw; -// } -// if (CameraPane.Ymin > spot.y) -// { -// CameraPane.Ymin = spot.y; -// } -// if (CameraPane.Ymax < spoth) -// { -// CameraPane.Ymax = spoth; -// } clickInfo.g.drawArc(boundary.x + clickInfo.DX, boundary.y + clickInfo.DY, (int)(boundary.width * clickInfo.W), (int)(boundary.height * clickInfo.W), 0, 360); //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360); @@ -7485,12 +7617,14 @@ retval = true; } spot.translate(0, 32); + spot.translate(32, 0); + spot.translate(0, 32); if (spot.contains(clickInfo.x, clickInfo.y)) { hitSomething = hitScale; double scale = 0.005f * clickInfo.camera.Distance(); - double hScale = (double) (clickInfo.x /*- centerPt.x*/) / 32; + double hScale = (double) (clickInfo.x - centerPt.x) / 64; double sign = 1; if (hScale < 0) { @@ -7502,7 +7636,7 @@ //hScale = 0.01; } - double vScale = (double) (clickInfo.y /*- centerPt.y*/) / 32; + double vScale = (double) (clickInfo.y - centerPt.y) / 64; sign = 1; if (vScale < 0) { @@ -7717,7 +7851,7 @@ break; case hitScale: // scale - double hScale = (double) (clickInfo.x /*- centerPt.x*/) / 32; + double hScale = (double) (clickInfo.x - centerPt.x) / 64; double sign = 1; if (hScale < 0) { @@ -7729,7 +7863,7 @@ //hScale = 0.01; } - double vScale = (double) (clickInfo.y /*- centerPt.y*/) / 32; + double vScale = (double) (clickInfo.y - centerPt.y) / 64; sign = 1; if (vScale < 0) { @@ -7762,21 +7896,27 @@ case 3: // '\001' if (modified || opposite) { + if (modified && opposite) + LA.matScale(toParent, totalScale, totalScale, totalScale); + else //LA.matScale(toParent, 1, hScale, vScale); - LA.matScale(toParent, totalScale, 1, 1); + LA.matScale(toParent, totalScale, 1, 1); } // vScale, 1); else { // EXCEPTION! - LA.matScale(toParent, totalScale, totalScale, totalScale); + LA.matScale(toParent, 1, totalScale, totalScale); } // vScale, 1); break; case 2: // '\002' if (modified || opposite) { - //LA.matScale(toParent, hScale, 1, vScale); - LA.matScale(toParent, 1, totalScale, 1); + if (modified && opposite) + LA.matScale(toParent, totalScale, totalScale, totalScale); + else + //LA.matScale(toParent, hScale, 1, vScale); + LA.matScale(toParent, 1, totalScale, 1); } else { LA.matScale(toParent, totalScale, 1, totalScale); @@ -7786,8 +7926,11 @@ case 1: // '\003' if (modified || opposite) { - //LA.matScale(toParent, hScale, vScale, 1); - LA.matScale(toParent, 1, 1, totalScale); + if (modified && opposite) + LA.matScale(toParent, totalScale, totalScale, totalScale); + else + //LA.matScale(toParent, hScale, vScale, 1); + LA.matScale(toParent, 1, 1, totalScale); } else { LA.matScale(toParent, totalScale, totalScale, 1); -- Gitblit v1.6.2