Пример #1
0
        private void GetRegionAtLocalOffset_(
            int localOffset,
            out IShardedList <T> region,
            out int regionOffset,
            out int regionIndex)
        {
            Asserts.Assert(localOffset >= 0, "Tried to access a negative offset!");
            Asserts.Assert(localOffset < this.Length,
                           "Tried to access beyond the end of the region!");

            var currentRegionOffset = 0;

            for (var i = 0; i < this.regions_.Count; ++i)
            {
                var currentRegion    = this.regions_[i];
                var nextRegionOffset = currentRegionOffset + currentRegion.Length;
                if (localOffset >= currentRegionOffset &&
                    localOffset < nextRegionOffset)
                {
                    region       = currentRegion;
                    regionOffset = currentRegionOffset;
                    regionIndex  = i;
                    return;
                }
                currentRegionOffset = nextRegionOffset;
            }

            region       = this;
            regionOffset = -1;
            regionIndex  = -1;
            Asserts.Fail("Failed to find a matching region, this should not happen.");
        }
Пример #2
0
        protected override void PopulateImpl(ZFiles zFiles, FileNode root)
        {
            var modelsNode = root.AddChild("Actor models");

            foreach (var model in zFiles.Objects)
            {
                modelsNode.AddChild(model);
            }

            var actorCodeNode = root.AddChild("Actor code");

            foreach (var code in zFiles.ActorCode)
            {
                actorCodeNode.AddChild(code);
            }

            var scenesNode = root.AddChild("Scenes");

            foreach (var scene in zFiles.Scenes)
            {
                var sceneNode = scenesNode.AddChild(scene);

                foreach (var map in Asserts.Assert(scene.Maps))
                {
                    sceneNode.AddChild(map);
                }
            }

            var othersNode = root.AddChild("Others");

            foreach (var other in zFiles.Others)
            {
                othersNode.AddChild(other);
            }
        }
Пример #3
0
        // TODO: Debounce this method.
        private void Filter_()
        {
            var filterText = this.filterTextBox_.Text.ToLower();

            this.ResetMatchPercentages_();

            this.betterTreeView_.BeginUpdate();

            if (string.IsNullOrEmpty(filterText))
            {
                this.betterTreeView_.Root.ResetChildrenRecursively();

                this.betterTreeView_.Comparer = null;
            }
            else
            {
                const float matchPercentage = 20;

                var matches = this.filterImpl_.Search(filterText, matchPercentage);

                this.PropagateMatchPercentages_(matches);
                this.betterTreeView_.Root.ResetChildrenRecursively(
                    betterTreeNode
                    => Asserts.Assert(betterTreeNode.AssociatedData).MatchPercentage >=
                    matchPercentage);

                this.betterTreeView_.Comparer =
                    this.betterTreeView_.Comparer ?? new FuzzyTreeComparer();
            }

            this.betterTreeView_.EndUpdate();
        }
Пример #4
0
        public ShardedList <T> Shard(int localOffset, int length)
        {
            Asserts.Assert(length > 0, "Tried to shard a region of size 0!");
            Asserts.Assert(localOffset + length <= this.Length,
                           "Tried to shard a region that extends beyond the size of this shard!");

            if (localOffset == 0 && length == this.Length)
            {
                return(this);
            }

            this.GetRegionAtLocalOffset_(localOffset,
                                         out var region,
                                         out var regionOffset,
                                         out var regionIndex);

            var spanRegion = region as SpanShardedList;

            Asserts.Assert(spanRegion != null,
                           "Tried to shard a previously sharded region.");

            var regionLocalOffset = localOffset - regionOffset;

            Asserts.Assert(regionLocalOffset + length <= region.Length,
                           "New shard spans multiple regions.");

            var beforeLength    = regionLocalOffset;
            var newRegionLength = length;
            var afterLength     = region.Length - (beforeLength + newRegionLength);

            this.regions_.RemoveAt(regionIndex);

            var regionImpl = spanRegion !.Impl;

            if (afterLength > 0)
            {
                var afterSpan =
                    regionImpl.Sub(beforeLength + newRegionLength, afterLength);
                this.regions_.Insert(regionIndex,
                                     new SpanShardedList(this, afterSpan));
            }

            var newRegionSpan = regionImpl.Sub(beforeLength, newRegionLength);
            var newRegion     = new ShardedList <T>(this, newRegionSpan);

            this.regions_.Insert(regionIndex, newRegion);

            if (beforeLength > 0)
            {
                var beforeSpan = regionImpl.Sub(0, beforeLength);
                this.regions_.Insert(regionIndex,
                                     new SpanShardedList(this, beforeSpan));
            }

            this.UpdateLength_();

            //this.MergeNeighboringRawRegions_();

            return(newRegion);
        }
Пример #5
0
        /*private void MergeNeighboringRawRegions_() {
         * var didMerge = false;
         *
         * var previousRegion = this.regions_[0];
         * for (var i = 1; i < this.regions_.Count; ++i) {
         *  var currentRegion = this.regions_[i];
         *
         *  if (previousRegion is RawShardedList rawPreviousRegion &&
         *      currentRegion is RawShardedList rawCurrentRegion) {
         *    didMerge = true;
         *
         *    var mergedImpl = new T[previousRegion.Length + currentRegion.Length];
         *
         *    rawPreviousRegion.Impl.CopyTo(mergedImpl, 0);
         *    rawCurrentRegion.Impl.CopyTo(mergedImpl, previousRegion.Length);
         *
         *    var mergedRegion = new RawShardedList(this, mergedImpl);
         *
         *    this.regions_.RemoveAt(i);
         *    this.regions_.RemoveAt(i - 1);
         *
         *    this.regions_.Insert(i - 1, mergedRegion);
         *
         *    break;
         *  }
         *
         *  previousRegion = currentRegion;
         * }
         *
         * if (didMerge) {
         *  this.MergeNeighboringRawRegions_();
         * }
         * }*/

        public void Resize(int newLength)
        {
            Asserts.Assert(this.regions_.Count == 1,
                           "Attempted to resize a sharded list with multiple regions!");

            var spanRegion = this.regions_[0] as SpanShardedList;

            if (spanRegion != null)
            {
                var spanRegionImpl = spanRegion !.Impl;

                var regionImpl = new T[newLength];
                var copyLength = Math.Min(spanRegionImpl.Length, newLength);
                for (var i = 0; i < copyLength; ++i)
                {
                    regionImpl[i] = spanRegionImpl[i];
                }

                this.regions_[0] = new RawShardedList(this, regionImpl);
            }
            else
            {
                this.regions_[0].Resize(newLength);
            }

            this.UpdateLength_();
        }
Пример #6
0
    void Awake()
    {
        track = transform.parent.GetComponent <Track>();
        Asserts.Assert(track != null);

        branch.startLength = 0.0f;
        branch.mask        = mask;

        Asserts.Assert(startToken != null && endToken != null);
        Token tok = startToken;

        while (tok != endToken)
        {
            branch.AddToken(tok);
            Asserts.Assert(1 == tok.nextLinks.Count);
            tok = tok.nextLinks[0];
        }
        branch.AddToken(tok);

        Token firstToken = branch[0],
              lastToken  = branch[branch.Count - 1];

        noThrough = (0 == lastToken.nextLinks.Count);

        bool loopAtStart = (firstToken.prevLinks.IndexOf(lastToken) >= 0),
             loopAtEnd   = (lastToken.nextLinks.IndexOf(firstToken) >= 0);

        Asserts.Assert((loopAtStart && loopAtEnd) || (!loopAtStart && !loopAtEnd) || noThrough); // TODO CHIEDERE AD ALEX
        loop = loopAtStart && loopAtEnd;
    }
Пример #7
0
    void Awake()
    {
        Asserts.Assert(null == instance);
        instance = this;

        rootTransform = gameObject.transform;
    }
Пример #8
0
        public float GetTrackPosition(Token token, float longitudinal)
        {
            Asserts.Assert(this == token.TrackBranch);
            BranchToken branchToken = branchTokens[token.TrackBranchIndex];

            return(startLength + (branchToken.startLength + token.Length * longitudinal) * lenScale);
        }
Пример #9
0
 public void ProjectNormal(
     ref double normalX,
     ref double normalY,
     ref double normalZ)
 => GlMatrixUtil.Project(Asserts.Assert(this.current_),
                         ref normalX,
                         ref normalY,
                         ref normalZ,
                         0);
Пример #10
0
        public static float ParseFloat(XMLNode element)
        {
            if (element == null)
            {
                Asserts.Assert(false);//, "Invalid node name: " + element.Name + " in: " + element.ParentNode.Name);
                return(float.NaN);
            }

            return(float.Parse(element.innerText));//, CultureInfo.InvariantCulture);
        }
Пример #11
0
        public static int ParseInt(XMLNode element)
        {
            if (element == null)
            {
                Asserts.Assert(false);//, "Invalid node name: " + element.tagName + " in: " + element.parentNode.tagName);
                return(0);
            }

            return(int.Parse(element.innerText));//, CultureInfo.InvariantCulture);
        }
Пример #12
0
            public Span(ISpannable <T> parent, int offset, int length)
            {
                Asserts.Assert(offset >= 0, "Spanned with a negative offset!");
                Asserts.Assert(length >= 0, "Spanned with a negative length!");
                Asserts.Assert(offset + length <= parent.Length,
                               "Spanned beyond the length of the parent!");

                this.parent_ = parent;
                this.Offset  = offset;
                this.Length  = length;
            }
Пример #13
0
    void Awake()
    {
        Asserts.Assert(null == instance);
        instance = this;

#if UNITY_IPHONE && !UNITY_EDITOR
        deviceMusicPlaying = UtilsBindings.IsMusicPlaying();
#endif
        musicOn  = PlayerPrefs.GetInt("sm_mu", 1) == 1;
        soundsOn = PlayerPrefs.GetInt("sm_sf", 1) == 1;
    }
Пример #14
0
        public void Populate(ZFiles zFiles)
        {
            this.betterTreeView_.BeginUpdate();

            var root = this.betterTreeView_.Root;

            var modelsNode = root.Add("Actor models");

            this.AddZFileNodeFor(null, modelsNode);
            foreach (var model in zFiles.Objects)
            {
                var modelNode = modelsNode.Add(model.BetterFileName !);
                this.AddZFileNodeFor(model, modelNode);
            }

            var actorCodeNode = root.Add("Actor code");

            this.AddZFileNodeFor(null, actorCodeNode);
            foreach (var code in zFiles.ActorCode)
            {
                var codeNode = actorCodeNode.Add(code.BetterFileName !);
                this.AddZFileNodeFor(code, codeNode);
            }

            var scenesNode = root.Add("Scenes");

            this.AddZFileNodeFor(null, scenesNode);
            foreach (var scene in zFiles.Scenes)
            {
                var sceneNode = scenesNode.Add(scene.BetterFileName !);
                this.AddZFileNodeFor(scene, sceneNode);

                foreach (var map in Asserts.Assert(scene.Maps))
                {
                    var mapNode = sceneNode.Add(map.BetterFileName !);
                    this.AddZFileNodeFor(map, mapNode);
                }
            }

            var othersNode = root.Add("Others");

            this.AddZFileNodeFor(null, othersNode);
            foreach (var other in zFiles.Others)
            {
                var otherNode = othersNode.Add(other.BetterFileName !);
                this.AddZFileNodeFor(other, otherNode);
            }

            this.InitializeAutocomplete_();

            this.betterTreeView_.EndUpdate();
        }
Пример #15
0
    void Awake()
    {
        Asserts.Assert(null == instance);
        instance = this;

        appIsPaused  = false;
        appIsFocused = true;

        masterSource = new TimeSource();

        sources = new List <TimeSource>();
        sources.Add(masterSource);
    }
Пример #16
0
    void Awake()
    {
        Asserts.Assert(null == instance);
        instance = this;

        tokens = GameObject.FindObjectsOfType(typeof(Token)) as Token[];
#if UNITY_EDITOR
        foreach (Token tok in tokens)
        {
            LevelObject levelObj = tok.gameObject.GetComponent <LevelObject>();
            Asserts.Assert(levelObj != null && "tokens" == levelObj.category);
        }
#endif
    }
        private void LoadBankAndSelectFirstAnimation_()
        {
            this.Animations = null;

            var limbCount             = this.limbs_?.Count ?? 0;
            var selectedAnimationBank = this.SelectedAnimationBank;

            if (limbCount > 0 && selectedAnimationBank != null)
            {
                // Inline
                if (selectedAnimationBank.Bank == null)
                {
                    this.Animations =
                        this.animationReader_.GetCommonAnimations(
                            RamBanks.ZFileBuffer,
                            limbCount,
                            this.animationsListBox_);
                }
                else
                {
                    if (selectedAnimationBank.Name == "link_animetion")
                    {
                        this.Animations = this.animationReader_.GetLinkAnimations(
                            RamBanks.GameplayKeep,
                            limbCount,
                            selectedAnimationBank.Bank,
                            this.animationsListBox_);
                    }
                    else
                    {
                        this.Animations = this.animationReader_.GetCommonAnimations(
                            selectedAnimationBank.Bank,
                            limbCount,
                            this.animationsListBox_);
                    }
                }
            }

            if (this.Animations != null)
            {
                Asserts.Assert(this.Animations.Count > 0);
                this.animationsListBox_.SelectedIndex = 0;
            }
            else
            {
                this.animationsListBox_.SelectedIndex = -1;
                this.TriggerAnimationSelectedEvent_();
            }
        }
Пример #18
0
        public static float[] ParseFloatArray(XMLNode element)
        {
            if (element == null)
            {
                Asserts.Assert(false);//, "Invalid node name: " + element.Name + " in: " + element.ParentNode.Name);
                return(null);
            }
            char[]   delimeters = { ',' };
            string[] parts      = element.innerText.Split(delimeters, StringSplitOptions.RemoveEmptyEntries);

            float[] result = new float[parts.Length];
            for (int i = 0; i < result.Length; i++)
            {
                result[i] = float.Parse(parts[i]);//, CultureInfo.InvariantCulture);
            }
            return(result);
        }
Пример #19
0
        public static SBSVector3 ParseVector3(XMLNode element)
        {
            if (element == null)
            {
                Asserts.Assert(false);//, "Invalid node name: " + element.Name + " in: " + element.ParentNode.Name);
                return(SBSVector3.zero);
            }
            char[]   delimeters = { ',' };
            string[] parts      = element.innerText.Split(delimeters, StringSplitOptions.RemoveEmptyEntries);
            if (parts.Length < 3)
            {
                Asserts.Assert(false);       //, "Invalid Vector3 param length node: " + element.Name + " in: " + element.ParentNode.Name);
            }
            float x = float.Parse(parts[0]); //, CultureInfo.InvariantCulture);
            float y = float.Parse(parts[1]); //, CultureInfo.InvariantCulture);
            float z = float.Parse(parts[2]); //, CultureInfo.InvariantCulture);

            return(new SBSVector3(x, y, z));
        }
Пример #20
0
        /// <summary>
        ///   Shamelessly copied from GLideN64's source.
        /// </summary>
        private void LoadTile32b_(
            ref TileDescriptor tileDescriptor,
            TimgArgs timgArgs)
        {
            var uls = tileDescriptor.ULS;
            var ult = tileDescriptor.ULT;
            var lrs = tileDescriptor.LRS;
            var lrt = tileDescriptor.LRT;

            var width  = lrs - uls + 1;
            var height = lrt - ult + 1;

            var line  = tileDescriptor.LineSize << 2;
            var tbase = tileDescriptor.TmemOffset << 2;

            IoUtil.SplitAddress(timgArgs.Address, out var bank, out var offset);

            var targetBank = Asserts.Assert(RamBanks.GetBankByIndex(bank));

            var timgWidth = timgArgs.Width;

            for (var j = 0; j < height; ++j)
            {
                var tline  = tbase + line * j;
                var s      = ((j + ult) * timgWidth) + uls;
                var xorval = (j & 1) != 0 ? 3 : 1;

                for (var i = 0; i < width; ++i)
                {
                    var addr = offset + s + i;
                    var c    = IoUtil.ReadUInt32(targetBank, (uint)(4 * addr));

                    var ptr = ((tline + i) ^ xorval) & 0x3ff;

                    var offset1 = 2 * ptr;
                    IoUtil.WriteInt16(targetBank, ref offset1, (ushort)(c >> 16));

                    var offset2 = 2 * (ptr | 0x400);
                    IoUtil.WriteInt16(targetBank, ref offset2, (ushort)(c & 0xffff));
                }
            }
        }
Пример #21
0
        public static IDisplayListInstruction?FindLinkedCommand(
            N64DisplayList DL,
            byte Command,
            int StartIndex)
        {
            var commands = Asserts.Assert(DL.Commands);

            for (var i = 0; i < commands.Length; ++i)
            {
                var command = commands[i];
                if (command.CMDParams[0] == Command)
                {
                    return(command);
                }

                if (i > StartIndex && command.CMDParams[0] == (int)F3DZEX.VTX)
                {
                    return(null);
                }
            }
            return(null);
        }
Пример #22
0
        public void PassValuesToShader()
        {
            if (this.Params.EnableCombiner)
            {
                Gl.glUniform1f(this.timeLocation_, (float)Time.Current);
                var camera = Asserts.Assert(Camera.Instance);
                Gl.glUniform3f(this.cameraPositionLocation_,
                               (float)camera.X,
                               (float)camera.Y,
                               (float)camera.Z);

                Gl.glUniform1f(this.lightingEnabledLocation_,
                               this.Params.EnableLighting ? 1 : 0);
                Gl.glUniform1f(this.sphericalUvEnabledLocation_,
                               this.Params.EnableSphericalUv ? 1 : 0);
                Gl.glUniform1f(this.linearUvEnabledLocation_,
                               this.Params.EnableLinearUv ? 1 : 0);

                Gl.glUniform4fv(this.envColorLocation_,
                                1,
                                this.Params.EnvironmentColor);
                Gl.glUniform4fv(this.primColorLocation_, 1, this.Params.PrimColor);
                Gl.glUniform4fv(this.blendLocation_, 1, this.Params.BlendColor);
                Gl.glUniform1f(this.primColorLodLocation_, this.Params.PrimColorLOD);

                Gl.glUniform1i(this.texture0Location_, 0);
                Gl.glUniform1i(this.texture1Location_, 1);
                this.TextureParams0.Bind();
                this.TextureParams1.Bind();
            }
            else
            {
                Gl.glDisable(Gl.GL_FRAGMENT_PROGRAM_ARB);
                Gl.glEnable(Gl.GL_LIGHTING);
                Gl.glEnable(Gl.GL_NORMALIZE);
                this.Params.MultiTexture   = false;
                this.Params.EnableLighting = true;
            }
        }
Пример #23
0
        public static void CopyTo <T>(
            T[] src,
            int srcOffset,
            T[] dst,
            int dstOffset,
            int count)
        {
            Asserts.Assert(srcOffset >= 0,
                           "Attempted to access a negative offset in src!");
            Asserts.Assert(dstOffset >= 0,
                           "Attempted to access a negative offset in src!");

            Asserts.Assert(count >= 0,
                           "Attempted to copy a negatively-sized region!");

            Asserts.Assert(srcOffset + count <= src.Length,
                           "Attempted to pull from block past length of dst!");
            Asserts.Assert(dstOffset + count <= dst.Length,
                           "Attempted to copy block past length of dst!");

            Array.ConstrainedCopy(src, srcOffset, dst, dstOffset, count);
        }
Пример #24
0
 void OnDestroy()
 {
     Asserts.Assert(this == instance);
     instance = null;
 }
Пример #25
0
 public void ProjectVertex(ref double x, ref double y, ref double z)
 => GlMatrixUtil.Project(Asserts.Assert(this.current_),
                         ref x,
                         ref y,
                         ref z,
                         1);
Пример #26
0
 public T this[int localOffset] {
     get {
         Asserts.Assert(localOffset >= 0, "Accessed a negative offset!");
         Asserts.Assert(localOffset < this.Length,
                        "Accessed past the bounds of the span!");
         return(this.parent_ ![this.Offset + localOffset]);
        // TODO: Remove combo box input.
        public static int ReadInDL(
            DlManager dlManager,
            uint address,
            ComboBox dListSelection)
        {
            IoUtil.SplitAddress(address, out var bank, out var offset);
            var data = Asserts.Assert(RamBanks.GetBankByIndex(bank));

            try {
                if (offset < data.Count)
                {
                    // TODO: This jumps into the lowest level DL, but the 0xDE command (DL)
                    // actually allows returning back up and calling more DLs. So this seems
                    // like it will sometimes overlook any DLs that follow.
                    // This should just be deleted and replaced w/ emulating in
                    // F3DEX2_Parser.
                    if (data[(int)offset] == 0xDE)
                    {
                        while (data[(int)offset] == 0xDE)
                        {
                            offset = IoUtil.ReadUInt24(data, (uint)(offset + 5L));
                        }
                    }

                    int index       = dlManager.Count;
                    var displayList = new N64DisplayList();
                    dlManager.Add(displayList);
                    uint EPLoc = offset;
                    dListSelection.Items.Add((index + 1).ToString() +
                                             ". " +
                                             Conversion.Hex(offset));
                    displayList.StartPos        = new ZSegment();
                    displayList.StartPos.Offset = offset;
                    displayList.StartPos.Bank   = data.Segment;
                    displayList.Skip            = false;

                    PickerUtil.NextRgb(out var r, out var g, out var b);
                    displayList.PickCol = new Color3UByte {
                        r = r, g = g, b = b
                    };

                    do
                    {
                        var commands = displayList.Commands;
                        Array.Resize(ref commands, displayList.CommandCount + 1);
                        displayList.Commands = commands;
                        displayList.Commands[displayList.CommandCount] =
                            new DLCommand(data, EPLoc);
                        if (data[(int)EPLoc] == (int)F3DZEX.ENDDL | EPLoc >= data.Count)
                        {
                            EPLoc = (uint)(EPLoc + 8L);
                            break;
                        }

                        EPLoc = (uint)(EPLoc + 8L);
                        displayList.CommandCount += 1;
                    } while (true);
                    return((int)EPLoc);
                }
            } catch (Exception ex) {
                Interaction.MsgBox("Error reading in display list: " + ex.Message,
                                   MsgBoxStyle.Critical,
                                   "Exception");
                return(default);
Пример #28
0
 public int Compare(
     IBetterTreeNode <FileNode> lhs,
     IBetterTreeNode <FileNode> rhs)
 => - Asserts.Assert(lhs.Data)
 .MatchPercentage.CompareTo(
     Asserts.Assert(rhs.Data).MatchPercentage);
Пример #29
0
        /// <summary>
        ///   Parses a limb hierarchy according to the following spec:
        ///   https://wiki.cloudmodding.com/oot/Animation_Format#Hierarchy
        /// </summary>
        public static IList <Limb>?GetHierarchies(
            IBank Data,
            bool isLink,
            DlManager dlManager,
            StaticDlModel model,
            ComboBox dListSelection)
        {
            uint limbIndexAddress;

            model.Reset();
            int j = 0;

            for (int i = 0, loopTo = Data.Count - 8; i <= loopTo; i += 4)
            {
                limbIndexAddress = IoUtil.ReadUInt32(Data, (uint)i);
                IoUtil.SplitAddress(limbIndexAddress,
                                    out var limbIndexBank,
                                    out var limbIndexOffset);
                uint limbCount = Data[i + 4];
                uint limbAddress;

                // Link has an extra set of values for each limb that define LOD model
                // display lists.
                uint limbSize;
                if (isLink)
                {
                    limbSize = 16U;
                }
                else
                {
                    limbSize = 12U;
                }

                if (RamBanks.IsValidBank((byte)limbIndexBank) & limbCount > 0L)
                {
                    var limbIndexBankBuffer = RamBanks.GetBankByIndex(limbIndexBank);

                    if (limbIndexBankBuffer != null &&
                        limbIndexOffset + 4L * limbCount < limbIndexBankBuffer.Count)
                    {
                        byte firstChild;
                        byte nextSibling;
                        bool isValid          = true;
                        bool somethingVisible = false;
                        var  loopTo1          = (int)(limbCount - 1L);
                        for (j = 0; j <= loopTo1; j++)
                        {
                            limbAddress = IoUtil.ReadUInt32(limbIndexBankBuffer,
                                                            (uint)(limbIndexOffset + j * 4));

                            IoUtil.SplitAddress(limbAddress,
                                                out var limbBank,
                                                out var limbOffset);

                            if (!RamBanks.IsValidBank(limbBank))
                            {
                                isValid = false;
                                goto badLimbIndexOffset;
                            }

                            var limbBankBuffer = RamBanks.GetBankByIndex(limbBank);
                            if (limbBankBuffer == null)
                            {
                                isValid = false;
                                goto badLimbIndexOffset;
                            }

                            if (limbOffset + limbSize >= limbBankBuffer.Count)
                            {
                                isValid = false;
                                goto badLimbIndexOffset;
                            }

                            firstChild  = limbBankBuffer[(int)(limbOffset + 6L)];
                            nextSibling = limbBankBuffer[(int)(limbOffset + 7L)];
                            if (firstChild == j | nextSibling == j)
                            {
                                isValid = false;
                                goto badLimbIndexOffset;
                            }

                            var displayListAddress =
                                IoUtil.ReadUInt32(limbBankBuffer, (uint)(limbOffset + 8L));
                            IoUtil.SplitAddress(displayListAddress,
                                                out var displayListBank,
                                                out var displayListOffset);

                            if (displayListBank != 0L)
                            {
                                somethingVisible = true;
                            }

                            if (displayListBank != 0L &
                                !RamBanks.IsValidBank((byte)displayListBank))
                            {
                                isValid = false;
                                goto badLimbIndexOffset;
                            }
                        }

badLimbIndexOffset:

                        if (isValid)
                        {
                            var tmpHierarchy = new Limb[(int)(limbCount - 1L + 1)];
                            for (int k = 0, loopTo2 = (int)(limbCount - 1L);
                                 k <= loopTo2;
                                 k++)
                            {
                                limbAddress = IoUtil.ReadUInt32(limbIndexBankBuffer,
                                                                (uint)(limbIndexOffset +
                                                                       4 * k));
                                IoUtil.SplitAddress(limbAddress,
                                                    out var limbBank,
                                                    out var limbOffset);
                                var limbBankBuffer =
                                    Asserts.Assert(RamBanks.GetBankByIndex(limbBank));

                                {
                                    var limbData =
                                        FinMarshal.Deserialize <LimbData>(
                                            limbBankBuffer,
                                            (int)limbOffset,
                                            true);

                                    var limb = tmpHierarchy[k] = new Limb(limbData);

                                    var displayListAddress = limbData.displayListAddress;
                                    IoUtil.SplitAddress(displayListAddress,
                                                        out var displayListBank,
                                                        out var displayListOffset);

                                    model.AddLimb(limb.Visible,
                                                  limb.x,
                                                  limb.y,
                                                  limb.z,
                                                  limb.firstChild,
                                                  limb.nextSibling);

                                    if (displayListBank != 0L)
                                    {
                                        var displayListBankBuffer =
                                            RamBanks.GetBankByIndex(displayListBank);
                                        DisplayListReader.ReadInDL(dlManager,
                                                                   displayListAddress,
                                                                   dListSelection);
                                    }

                                    // Far model display list (i.e. LOD model). Only used for Link.
                                    // If Data(tmpLimbOff + 12) = Bank Then
                                    // .DisplayListLow = ReadUInt24(Data, tmpLimbOff + 13)
                                    // ReDim Preserve N64DList(N64DList.Length)
                                    // ReadInDL(Data, N64DList, .DisplayListLow, N64DList.Length - 1)
                                    // Else

                                    // End If
                                    PickerUtil.NextRgb(out var r, out var g, out var b);
                                    limb.r = r;
                                    limb.g = g;
                                    limb.b = b;
                                }
                            }

                            if (isValid & !somethingVisible)
                            {
                                throw new NotSupportedException(
                                          "model format is not rendering a valid model!");
                            }

                            return(tmpHierarchy);
                        }
                    }
                }
            }

            return(null);
        }
Пример #30
0
 private void UpdateCurrent_()
 => this.current_ = Asserts.Assert(this.stack_.Last.Value.Matrix);