From 6266c8a4b2485b29a7d5bcb217460d7aad3e1c4a Mon Sep 17 00:00:00 2001 From: Normand Briere <nbriere@noware.ca> Date: Sun, 25 Aug 2019 20:58:10 -0400 Subject: [PATCH] Proto version slider. --- Object3D.java | 219 +++++++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 199 insertions(+), 20 deletions(-) diff --git a/Object3D.java b/Object3D.java index c1e3334..9d52cb0 100644 --- a/Object3D.java +++ b/Object3D.java @@ -40,6 +40,19 @@ ScriptNode scriptnode; + int VersionCount() + { + int count = 0; + + for (int i = versionlist.length; --i >= 0;) + { + if (versionlist[i] != null) + count++; + } + + return count; + } + void InitOthers() { if (projectedVertices == null || projectedVertices.length <= 2) @@ -271,6 +284,50 @@ // // 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) { @@ -524,11 +581,11 @@ } } - int memorysize; + transient int memorysize; // needs to be transient, dunno why int MemorySize() { - if (true) // memorysize == 0) + if (memorysize == 0) { try { @@ -643,7 +700,7 @@ { if (maxcount != 1) { - new Exception().printStackTrace(); + //new Exception().printStackTrace(); } toParentMarked = LA.newMatrix(); @@ -2325,11 +2382,6 @@ InitOthers(); - if (this instanceof Camera) - { - material.shift = 90; - } - material.multiply = multiply; if (multiply) @@ -3225,6 +3277,93 @@ blockloop = false; } + public void ResetTransform(int mask) + { + Object3D obj = this; + + if (mask == -1) + { + if (obj instanceof Camera) // jan 2014 + { + LA.matIdentity(obj.toParent); + LA.matIdentity(obj.fromParent); + } + else + { + obj.toParent = null; // jan 2014 LA.matIdentity(obj.toParent); + obj.fromParent = null; // LA.matIdentity(obj.fromParent); + } + return; + } + + if ((mask&2) != 0) // Scale/rotation + { + obj.toParent[0][0] = obj.toParent[1][1] = obj.toParent[2][2] = 1; + 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; + 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; + } + if ((mask&1) != 0) // Translation + { + if (obj.toParent != null) + { + obj.toParent[3][0] = obj.toParent[3][1] = obj.toParent[3][2] = 0; + obj.fromParent[3][0] = obj.fromParent[3][1] = obj.fromParent[3][2] = 0; + } + } + } + + public void TextureRatioTransform(int axis) + { + cTexture tex = GetTextures(); + + com.sun.opengl.util.texture.TextureData texturedata = null; + + try + { + texturedata = Globals.theRenderer.GetTextureData(tex, false, texres); + } + catch (Exception e) + { + System.err.println("FAIL TextureRatio: " + this); + } + + LA.matIdentity(Object3D.mat); + Object3D.mat[axis][axis] = (double)texturedata.getWidth() / texturedata.getHeight(); + + if (toParent == null) + { + toParent = LA.newMatrix(); + fromParent = LA.newMatrix(); + } + + ResetTransform(2); + + LA.matConcat(Object3D.mat, fromParent, fromParent); + LA.matInvert(fromParent, toParent); + } + + void TextureRatio(int axis) + { + if (blockloop) + return; + + blockloop = true; + + TextureRatioTransform(axis); + + for (int i=Size(); --i>=0;) + { + Object3D v = get(i); + + v.TextureRatio(axis); + } + + blockloop = false; + } + void TransformChildren() { if (toParent != null) @@ -3578,15 +3717,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) @@ -5898,6 +6069,11 @@ return parent.IsLive(); } + boolean IsDynamic() + { + return live && bRep != null; + } + void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) { Invariants(); // june 2013 @@ -5958,7 +6134,8 @@ if (support != null) support = support; - boolean usecalllists = !IsLive() && IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch); + boolean usecalllists = !IsDynamic() && + 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. @@ -7640,7 +7817,9 @@ scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance(); - if (modified || opposite) + // Modified could snap + if (//modified || + opposite) { //assert(false); /* @@ -7734,7 +7913,7 @@ if (modified) { - // Rotate 90 degrees + // Rotate 45 degrees angle /= (Math.PI / 4); angle = Math.floor(angle + 0.5); angle *= (Math.PI / 4); @@ -7820,7 +7999,7 @@ case 3: // '\001' if (modified || opposite) { - if (modified && opposite) + if (modified) // && opposite) LA.matScale(toParent, totalScale, totalScale, totalScale); else //LA.matScale(toParent, 1, hScale, vScale); @@ -7836,7 +8015,7 @@ case 2: // '\002' if (modified || opposite) { - if (modified && opposite) + if (modified) // && opposite) LA.matScale(toParent, totalScale, totalScale, totalScale); else //LA.matScale(toParent, hScale, 1, vScale); @@ -7850,7 +8029,7 @@ case 1: // '\003' if (modified || opposite) { - if (modified && opposite) + if (modified) // && opposite) LA.matScale(toParent, totalScale, totalScale, totalScale); else //LA.matScale(toParent, hScale, vScale, 1); @@ -8002,10 +8181,10 @@ } // + super.toString(); //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName(); - if (!Globals.ADVANCED) - return objname; +// if (!Globals.ADVANCED) +// return objname; - return objname + " " + System.identityHashCode(this); + return objname + " " + System.identityHashCode(this); // + GetUUID() } public int hashCode() -- Gitblit v1.6.2