System.Collections.Generic.List.Add(hkcdStaticTreeCodec3Axis6)

Here are the examples of the csharp api System.Collections.Generic.List.Add(hkcdStaticTreeCodec3Axis6) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1 Examples 7

19 View Source File : BVH.cs
License : MIT License
Project Creator : katalash

public List<hkcdStaticTreeCodec3Axis6> BuildAxis6Tree()
        {
            var ret = new List<hkcdStaticTreeCodec3Axis6>();

            void CompressNode(BVNode node, Vector3 pbbmin, Vector3 pbbmax, bool root = false)
            {
                var currindex = ret.Count();
                var compressed = new hkcdStaticTreeCodec3Axis6();
                ret.Add(compressed);

                // Compress the bounding box
                compressed.m_xyz_0 = CompressDim(node.Min.X, node.Max.X, pbbmin.X, pbbmax.X);
                compressed.m_xyz_1 = CompressDim(node.Min.Y, node.Max.Y, pbbmin.Y, pbbmax.Y);
                compressed.m_xyz_2 = CompressDim(node.Min.Z, node.Max.Z, pbbmin.Z, pbbmax.Z);

                // Read back the decompressed bounding box to use as reference for next compression
                var min = compressed.DecompressMin(pbbmin, pbbmax);
                var max = compressed.DecompressMax(pbbmin, pbbmax);

                if (node.IsLeaf)
                {
                    uint data = (uint)(node.Primitive);
                    compressed.m_loData = (ushort)(data & 0xFFFF);
                    compressed.m_hiData = (byte)((data >> 16) & 0x7F);
                }
                else
                {
                    // Add the left as the very next node
                    CompressNode(node.Left, min, max);

                    // Encode the index of the right then add it. The index should
                    // always be even
                    ushort data = (ushort)((ret.Count() - currindex) / 2);
                    compressed.m_loData = (ushort)(data & 0xFFFF);
                    compressed.m_hiData = (byte)(((data >> 16) & 0x7F) | 0x80);

                    // Now encode the right
                    CompressNode(node.Right, min, max);
                }
                if (root)
                {
                    compressed.m_xyz_0 = 0;
                    compressed.m_xyz_1 = 0;
                    compressed.m_xyz_2 = 0;
                }
            }

            CompressNode(this, Min, Max, true);
            return ret;
        }