Ejemplo n.º 1
0
 public void Construct2()
 {
     Vector4I v = new Vector4I(new Vector2I(1, 2), 3, 4);
     Assert.AreEqual(1, v.X);
     Assert.AreEqual(2, v.Y);
     Assert.AreEqual(3, v.Z);
     Assert.AreEqual(4, v.W);
 }
Ejemplo n.º 2
0
 public void Construct1()
 {
     Vector4I v = new Vector4I(new Vector3I(1, 2, 3), 4);
     Assert.AreEqual(1, v.X);
     Assert.AreEqual(2, v.Y);
     Assert.AreEqual(3, v.Z);
     Assert.AreEqual(4, v.W);
 }
Ejemplo n.º 3
0
        public Vector4I[] CreateTextureIndices(List <MyMeshPartInfo> partInfos, int verticesNum, string contentPath)
        {
            Vector4I[] indices = new Vector4I[verticesNum];
            for (int i = 0; i < verticesNum; i++)
            {
                indices[i] = new Vector4I(DEFAULT_ARRAY_TEXTURE_INDEX, DEFAULT_ARRAY_TEXTURE_INDEX, DEFAULT_ARRAY_TEXTURE_INDEX, DEFAULT_ARRAY_TEXTURE_INDEX);
            }

            if (!MyRender11.Settings.UseGeometryArrayTextures) // system is disabled
            {
                return(indices);
            }

            foreach (MyMeshPartInfo partInfo in partInfos)
            {
                MyMaterialDescriptor materialDesc = partInfo.m_MaterialDesc;
                if (materialDesc == null)
                {
                    continue;
                }
                string cmTexture, ngTexture, extTexture, alphamaskTexture;
                if (!materialDesc.Textures.TryGetValue("ColorMetalTexture", out cmTexture))
                {
                    continue;
                }
                if (!materialDesc.Textures.TryGetValue("NormalGlossTexture", out ngTexture))
                {
                    continue;
                }
                materialDesc.Textures.TryGetValue("AddMapsTexture", out extTexture);
                materialDesc.Textures.TryGetValue("AlphamaskTexture", out alphamaskTexture);

                cmTexture        = MyResourceUtils.GetTextureFullPath(cmTexture, contentPath);
                ngTexture        = MyResourceUtils.GetTextureFullPath(ngTexture, contentPath);
                extTexture       = MyResourceUtils.GetTextureFullPath(extTexture, contentPath);
                alphamaskTexture = MyResourceUtils.GetTextureFullPath(alphamaskTexture, contentPath);

                Vector4I textureIndices = GetTextureIndices(cmTexture, ngTexture, extTexture, alphamaskTexture);

                foreach (var offset in partInfo.m_indices)
                {
                    indices[offset] = textureIndices;
                }
            }

            return(indices);
        }
Ejemplo n.º 4
0
        public void Add()
        {
            Vector4I v1 = new Vector4I(1, 2, 3, 4);
            Vector4I v2 = new Vector4I(4, 5, 6, 7);

            Vector4I v3 = v1 + v2;
            Assert.AreEqual(5, v3.X);
            Assert.AreEqual(7, v3.Y);
            Assert.AreEqual(9, v3.Z);
            Assert.AreEqual(11, v3.W);

            Vector4I v4 = v1.Add(v2);
            Assert.AreEqual(5, v4.X);
            Assert.AreEqual(7, v4.Y);
            Assert.AreEqual(9, v4.Z);
            Assert.AreEqual(11, v4.W);
        }
Ejemplo n.º 5
0
        public void Magnitude()
        {
            Vector4I v = new Vector4I(3, 4, 0, 0);
            Assert.AreEqual(25, v.MagnitudeSquared);
            Assert.AreEqual(5, v.Magnitude, 1e-14);

            v = new Vector4I(3, 0, 4, 0);
            Assert.AreEqual(25, v.MagnitudeSquared);
            Assert.AreEqual(5, v.Magnitude, 1e-14);

            v = new Vector4I(0, 3, 4, 0);
            Assert.AreEqual(25, v.MagnitudeSquared);
            Assert.AreEqual(5, v.Magnitude, 1e-14);

            v = new Vector4I(0, 0, 3, 4);
            Assert.AreEqual(25, v.MagnitudeSquared);
            Assert.AreEqual(5, v.Magnitude, 1e-14);
        }
Ejemplo n.º 6
0
            public static Color asColor(string data, Color defaultValue = new Color())
            {
                int count = data.Count(x => x == ',');

                if (count == 2)
                {
                    Vector3I vec = asVector(data, new Vector3I(defaultValue.R, defaultValue.G, defaultValue.B));
                    return(new Color(vec.X, vec.Y, vec.Z));
                }

                if (count == 3)
                {
                    Vector4I vec = asVector(data, new Vector4I(defaultValue.R, defaultValue.G, defaultValue.B, defaultValue.A));
                    return(new Color(vec.X, vec.Y, vec.Z, vec.W));
                }

                return(defaultValue);
            }
Ejemplo n.º 7
0
            public static Vector4I asVector(string data, Vector4I defaultValue = new Vector4I())
            {
                if (data != string.Empty)
                {
                    string[] parts = data.Split(',');
                    if (parts.Length == 4)
                    {
                        int x, y, z, w;
                        int.TryParse(parts[0], out x);
                        int.TryParse(parts[1], out y);
                        int.TryParse(parts[2], out z);
                        int.TryParse(parts[3], out w);

                        return(new Vector4I(x, y, z, w));
                    }
                }

                return(defaultValue);
            }
            public void Add(MatrixD worldMatrix, BoundingBox box, Vector4I id, MyVoxelBase voxel)
            {
                if (m_list.Count > 1900)
                {
                    m_list.ClearList();
                }

                voxel = voxel.RootVoxel;
                box.Translate(-voxel.SizeInMetresHalf);
                //box.Translate(voxel.StorageMin);


                m_list.Add(new PredictionInfo
                {
                    Id     = id,
                    Bounds = MyOrientedBoundingBoxD.Create((BoundingBoxD)box, voxel.WorldMatrix),
                    Body   = voxel
                });
            }
Ejemplo n.º 9
0
        public Vector4I GetOctreeNodeAt(Vector3D pos)
        {
            var rootCell = new Vector4I(Vector3I.Floor(pos / m_cubeSideMax), 0);

            var cell = rootCell;

            while (true)
            {
                var aabb         = GetNodeAABB(cell);
                var densityNoise = m_densityNoise.GetValue(aabb.Center) * m_depth;
                var depthDensity = (int)MyMath.Clamp((float)Math.Floor(densityNoise), 0, m_depth - 1);
                if (depthDensity <= cell.W)
                {
                    return(cell);
                }
                else
                {
                    var nx = (cell.X << 1) + (aabb.Center.X > pos.X ? 1 : 0);
                    var ny = (cell.Y << 1) + (aabb.Center.Y > pos.Y ? 1 : 0);
                    var nz = (cell.Z << 1) + (aabb.Center.Z > pos.Z ? 1 : 0);
                    cell = new Vector4I(nx, ny, nz, cell.W + 1);
                }
            }
        }
            public LoadingConstruction(ProceduralStationModule module, Vector4I cell, ProceduralConstructionSeed seed) : base(module)
            {
                m_cell        = cell;
                m_boundingBox = module.StationNoise.GetNodeAABB(cell);
                RaiseMoved();
                Seed = seed;

                m_creationQueued         = false;
                m_creationQueueSemaphore = new FastResourceLock();

                m_construction  = null;
                m_grids         = null;
                m_component     = null;
                base.OnRemoved += (x) =>
                {
                    var station = x as LoadingConstruction;
                    if (station == null)
                    {
                        return;
                    }
                    station.TimeRemoved = DateTime.UtcNow;
                    Module.Debug("Marking station entity for removal!");
                };
            }
Ejemplo n.º 11
0
        public Vector4I[] CreateTextureIndices(List <MyRuntimeSectionInfo> sectionInfos, List <int> indices, int verticesNum)
        {
            Vector4I defaultArrayTexIndex = new Vector4I(DEFAULT_ARRAY_TEXTURE_INDEX, DEFAULT_ARRAY_TEXTURE_INDEX, DEFAULT_ARRAY_TEXTURE_INDEX, DEFAULT_ARRAY_TEXTURE_INDEX);

            Vector4I[] texIndices = new Vector4I[verticesNum];
            for (int i = 0; i < verticesNum; i++)
            {
                texIndices[i] = defaultArrayTexIndex;
            }

            if (!MyRender11.Settings.UseGeometryArrayTextures) // system is disabled
            {
                return(texIndices);
            }

            foreach (MyRuntimeSectionInfo sectionInfo in sectionInfos)
            {
                MyMeshMaterialId material = MyMeshMaterials1.GetMaterialId(sectionInfo.MaterialName);
                MyRenderProxy.Assert(material != MyMeshMaterialId.NULL);
                if (!material.Info.GeometryTextureRef.IsUsed)
                {
                    continue;
                }
                Vector4I materialTexIndex = material.Info.GeometryTextureRef.TextureSliceIndices;

                for (int i = 0; i < sectionInfo.TriCount * 3; i++)
                {
                    int      index        = indices[i + sectionInfo.IndexStart];
                    Vector4I prevTexIndex = texIndices[index];
                    MyRenderProxy.Assert(defaultArrayTexIndex.CompareTo(prevTexIndex) == 0 || materialTexIndex.CompareTo(prevTexIndex) == 0, "Vertex is used with different material!");
                    texIndices[index] = materialTexIndex;
                }
            }

            return(texIndices);
        }
Ejemplo n.º 12
0
        public void Multiply()
        {
            Vector4I v1 = new Vector4I(1, 2, 3, 4);

            Vector4I v2 = v1 * 5;
            Assert.AreEqual(5, v2.X);
            Assert.AreEqual(10, v2.Y);
            Assert.AreEqual(15, v2.Z);
            Assert.AreEqual(20, v2.W);

            Vector4I v3 = 5 * v1;
            Assert.AreEqual(5, v3.X);
            Assert.AreEqual(10, v3.Y);
            Assert.AreEqual(15, v3.Z);
            Assert.AreEqual(20, v3.W);

            Vector4I v4 = v1.Multiply(5);
            Assert.AreEqual(5, v4.X);
            Assert.AreEqual(10, v4.Y);
            Assert.AreEqual(15, v4.Z);
            Assert.AreEqual(20, v4.W);
        }
Ejemplo n.º 13
0
 public LoadingConstruction InstanceAt(Vector4I octreeNode)
 {
     return(m_instances.GetValueOrDefault(octreeNode));
 }
Ejemplo n.º 14
0
        public void Subtract()
        {
            Vector4I v1 = new Vector4I(1, 2, 3, 4);
            Vector4I v2 = new Vector4I(4, 5, 6, 7);

            Vector4I v3 = v1 - v2;
            Assert.AreEqual(-3, v3.X);
            Assert.AreEqual(-3, v3.Y);
            Assert.AreEqual(-3, v3.Z);
            Assert.AreEqual(-3, v3.W);

            Vector4I v4 = v1.Subtract(v2);
            Assert.AreEqual(-3, v4.X);
            Assert.AreEqual(-3, v4.Y);
            Assert.AreEqual(-3, v4.Z);
            Assert.AreEqual(-3, v4.W);
        }
Ejemplo n.º 15
0
        public void MultiplyComponents()
        {
            Vector4I v1 = new Vector4I(1, 2, 3, 4);
            Vector4I v2 = new Vector4I(4, 8, 12, 16);

            Assert.AreEqual(new Vector4I(4, 16, 36, 64), v1.MultiplyComponents(v2));
        }
Ejemplo n.º 16
0
        public void Dot()
        {
            Vector4I a = new Vector4I(1, 2, 3, 4);
            Vector4I b = new Vector4I(4, 5, 6, 7);

            double dot = a.Dot(b);
            Assert.AreEqual(1 * 4 + 2 * 5 + 3 * 6 + 4 * 7, dot, 1e-14);
        }
Ejemplo n.º 17
0
 private string FormatWorkTracked(Vector4I workStats)
 {
     return(String.Format("{0:D3}/{1:D3}/{2:D3}/{3:D3}", workStats.X, workStats.Y, workStats.Z, workStats.W));
 }
Ejemplo n.º 18
0
 public void XY()
 {
     Vector4I a = new Vector4I(1, 2, 3, 4);
     Vector2I xy = a.XY;
     Assert.AreEqual(1, xy.X);
     Assert.AreEqual(2, xy.Y);
 }
        public override IEnumerable <ProceduralObject> Generate(BoundingSphereD include, BoundingSphereD?exclude)
        {
            var root        = Vector3D.Transform(include.Center, m_invTransform);
            var excludeRoot = exclude.HasValue
                ? Vector3D.Transform(exclude.Value.Center, m_invTransform)
                : default(Vector3D);

            var minLocal = root - include.Radius;
            var maxLocal = root + include.Radius;

            minLocal = Vector3D.Max(minLocal, Shape.RelevantArea.Min);
            maxLocal = Vector3D.Min(maxLocal, Shape.RelevantArea.Max);
            for (var i = 0; i < m_layers.Length; i++)
            {
                var layer = m_layers[i];
                var includePaddedSquared = include.Radius + layer.AsteroidSpacing * 2;
                includePaddedSquared *= includePaddedSquared;
                var excludePaddedSquared = exclude.HasValue ? exclude.Value.Radius - layer.AsteroidSpacing * 2 : 0;
                excludePaddedSquared *= excludePaddedSquared;

                var minPos = Vector3I.Floor(minLocal / layer.AsteroidSpacing);
                var maxPos = Vector3I.Ceiling(maxLocal / layer.AsteroidSpacing);
                for (var itr = new Vector3I_RangeIterator(ref minPos, ref maxPos); itr.IsValid(); itr.MoveNext())
                {
                    var seed     = new Vector4I(itr.Current.X, itr.Current.Y, itr.Current.Z, i);
                    var localPos = ((Vector3D)itr.Current + 0.5) * layer.AsteroidSpacing;

                    // Very quick, include/exclude.
                    if (Vector3D.DistanceSquared(root, localPos) > includePaddedSquared)
                    {
                        continue;
                    }
                    if (exclude.HasValue && Vector3D.DistanceSquared(excludeRoot, localPos) < excludePaddedSquared)
                    {
                        continue;
                    }
                    var localWeight = Shape.Weight(localPos) + layer.UsableRegion - 1;
                    if (1 - layer.AsteroidDensity > localWeight)
                    {
                        continue;
                    }

                    var densityNoise = Math.Abs(m_noise.GetValue(localPos + Math.PI)) * localWeight;
                    if (1 - layer.AsteroidDensity > densityNoise)
                    {
                        continue;
                    }

                    localPos.X += 0.45 * m_noise.GetValue(localPos) * layer.AsteroidSpacing;
                    localPos.Y += 0.45 * m_noise.GetValue(localPos) * layer.AsteroidSpacing;
                    localPos.Z += 0.45 * m_noise.GetValue(localPos) * layer.AsteroidSpacing;

                    localPos.X += 0.35 * Shape.WarpSize.X * m_noiseWarp.GetValue(localPos);
                    localPos.Y += 0.35 * Shape.WarpSize.Y * m_noiseWarp.GetValue(localPos);
                    localPos.Z += 0.05 * Shape.WarpSize.Z * m_noiseWarp.GetValue(localPos);

                    var worldPos = Vector3D.Transform(localPos, m_transform);
                    ProceduralAsteroid procAst;
                    if (!m_asteroids.TryGetValue(seed, out procAst))
                    {
                        var size = m_noise.GetValue(worldPos) * (layer.AsteroidMaxSize - layer.AsteroidMinSize) +
                                   layer.AsteroidMinSize;
                        m_asteroids[seed] = procAst = new ProceduralAsteroid(this, seed, worldPos, size, m_layers[i]);
                    }

                    procAst.SpawnIfNeeded((procAst.m_boundingBox.Center - include.Center).LengthSquared());
                    yield return(procAst);
                }
            }
        }
Ejemplo n.º 20
0
 public void ToVector4H()
 {
     Vector4I a = new Vector4I(1, 2, 3, 4);
     Vector4H sA = a.ToVector4H();
     Assert.AreEqual((Half)1, sA.X, 1e-7);
     Assert.AreEqual((Half)2, sA.Y, 1e-7);
     Assert.AreEqual((Half)3, sA.Z, 1e-7);
     Assert.AreEqual((Half)4, sA.W, 1e-7);
 }
Ejemplo n.º 21
0
 public void ToVector4F()
 {
     Vector4I a = new Vector4I(1, 2, 3, 4);
     Vector4F sA = a.ToVector4F();
     Assert.AreEqual(1.0f, sA.X, 1e-7);
     Assert.AreEqual(2.0f, sA.Y, 1e-7);
     Assert.AreEqual(3.0f, sA.Z, 1e-7);
     Assert.AreEqual(4.0f, sA.W, 1e-7);
 }
Ejemplo n.º 22
0
        public void TestEquals()
        {
            Vector4I a = new Vector4I(1, 2, 3, 4);
            Vector4I b = new Vector4I(4, 5, 6, 7);
            Vector4I c = new Vector4I(1, 2, 3, 4);

            Assert.IsTrue(a.Equals(c));
            Assert.IsTrue(c.Equals(a));
            Assert.IsTrue(a == c);
            Assert.IsTrue(c == a);
            Assert.IsFalse(c != a);
            Assert.IsFalse(c != a);
            Assert.IsFalse(a.Equals(b));
            Assert.IsFalse(b.Equals(a));
            Assert.IsFalse(a == b);
            Assert.IsFalse(b == a);
            Assert.IsTrue(a != b);
            Assert.IsTrue(b != a);

            object objA = a;
            object objB = b;
            object objC = c;

            Assert.IsTrue(a.Equals(objA));
            Assert.IsTrue(a.Equals(objC));
            Assert.IsFalse(a.Equals(objB));

            Assert.IsTrue(objA.Equals(objC));
            Assert.IsFalse(objA.Equals(objB));

            Assert.IsFalse(a.Equals(null));
            Assert.IsFalse(a.Equals(5));
        }
Ejemplo n.º 23
0
        public void Negate()
        {
            Vector4I a = new Vector4I(1, 2, 3, 4);
            Vector4I negatedA1 = a.Negate();
            Assert.AreEqual(-1, negatedA1.X, 1e-14);
            Assert.AreEqual(-2, negatedA1.Y, 1e-14);
            Assert.AreEqual(-3, negatedA1.Z, 1e-14);
            Assert.AreEqual(-4, negatedA1.W, 1e-14);
            Vector4I negatedA2 = -a;
            Assert.AreEqual(-1, negatedA2.X, 1e-14);
            Assert.AreEqual(-2, negatedA2.Y, 1e-14);
            Assert.AreEqual(-3, negatedA2.Z, 1e-14);
            Assert.AreEqual(-4, negatedA2.W, 1e-14);

            Vector4I b = new Vector4I(-1, -2, -3, -4);
            Vector4I negatedB1 = b.Negate();
            Assert.AreEqual(1, negatedB1.X, 1e-14);
            Assert.AreEqual(2, negatedB1.Y, 1e-14);
            Assert.AreEqual(3, negatedB1.Z, 1e-14);
            Assert.AreEqual(4, negatedB1.W, 1e-14);
            Vector4I negatedB2 = -b;
            Assert.AreEqual(1, negatedB2.X, 1e-14);
            Assert.AreEqual(2, negatedB2.Y, 1e-14);
            Assert.AreEqual(3, negatedB2.Z, 1e-14);
            Assert.AreEqual(4, negatedB2.W, 1e-14);
        }
Ejemplo n.º 24
0
 public Vector4I asVector(int index, Vector4I defaultValue = new Vector4I()) => Configuration.asVector(this[index], defaultValue);
Ejemplo n.º 25
0
 public void XYZ()
 {
     Vector4I a = new Vector4I(1, 2, 3, 4);
     Vector3I xyz = a.XYZ;
     Assert.AreEqual(1, xyz.X);
     Assert.AreEqual(2, xyz.Y);
     Assert.AreEqual(3, xyz.Z);
 }
Ejemplo n.º 26
0
 protected void SetUniform4(int pos, Vector4I val)
 {
     GL.Uniform4(pos, val.X, val.Y, val.Z, val.W);
 }
Ejemplo n.º 27
0
        public void MostOrthogonalAxis()
        {
            Vector4I v1 = new Vector4I(1, 2, 3, 4);
            Assert.AreEqual(Vector4I.UnitX, v1.MostOrthogonalAxis);

            Vector4I v2 = new Vector4I(-3, -1, -2, -4);
            Assert.AreEqual(Vector4I.UnitY, v2.MostOrthogonalAxis);

            Vector4I v3 = new Vector4I(3, 2, 1, 4);
            Assert.AreEqual(Vector4I.UnitZ, v3.MostOrthogonalAxis);

            Vector4I v4 = new Vector4I(3, 2, 4, 1);
            Assert.AreEqual(Vector4I.UnitW, v4.MostOrthogonalAxis);
        }
Ejemplo n.º 28
0
 public void TileSizeMarginUniform(Vector4I val)
 {
     SetUniform4(base[Uniforms.tileSizeMargin], val);
 }
Ejemplo n.º 29
0
        public void Divide()
        {
            Vector4I v1 = new Vector4I(10, 20, 30, 40);

            Vector4I v2 = v1 / 5;
            Assert.AreEqual(2, v2.X);
            Assert.AreEqual(4, v2.Y);
            Assert.AreEqual(6, v2.Z);
            Assert.AreEqual(8, v2.W);

            Vector4I v3 = v1.Divide(5);
            Assert.AreEqual(2, v3.X);
            Assert.AreEqual(4, v3.Y);
            Assert.AreEqual(6, v3.Z);
            Assert.AreEqual(8, v3.W);
        }
Ejemplo n.º 30
0
 public void ToVector4B()
 {
     Vector4I a = new Vector4I(1, 0, 0, 1);
     Vector4B sA = a.ToVector4B();
     Assert.IsTrue(sA.X);
     Assert.IsFalse(sA.Y);
     Assert.IsFalse(sA.Z);
     Assert.IsTrue(sA.W);
 }
Ejemplo n.º 31
0
        public void TestGetHashCode()
        {
            Vector4I a = new Vector4I(1, 2, 3, 4);
            Vector4I b = new Vector4I(4, 5, 6, 7);
            Vector4I c = new Vector4I(1, 2, 3, 4);

            Assert.AreEqual(a.GetHashCode(), c.GetHashCode());
            Assert.AreNotEqual(a.GetHashCode(), b.GetHashCode());
        }
        private void CreateTriangles(ref Vector3I coord0, int cubeIndex, ref Vector3I tempVoxelCoord0)
        {
            MyVoxelVertex tmpVertex = new MyVoxelVertex();
            int           g         = MyVoxelConstants.GEOMETRY_CELL_SIZE_IN_VOXELS;
            Vector3I      edge      = new Vector3I(coord0.X, coord0.Y, coord0.Z);

            for (int i = 0; MyMarchingCubesConstants.TriangleTable[cubeIndex, i] != -1; i += 3)
            {
                //  Edge indexes inside the cube
                int edgeIndex0 = MyMarchingCubesConstants.TriangleTable[cubeIndex, i + 0];
                int edgeIndex1 = MyMarchingCubesConstants.TriangleTable[cubeIndex, i + 1];
                int edgeIndex2 = MyMarchingCubesConstants.TriangleTable[cubeIndex, i + 2];

                MyEdge edge0 = m_edges[edgeIndex0];
                MyEdge edge1 = m_edges[edgeIndex1];
                MyEdge edge2 = m_edges[edgeIndex2];


                //  Edge indexes inside the cell
                Vector4I edgeConversion0 = MyMarchingCubesConstants.EdgeConversion[edgeIndex0];
                Vector4I edgeConversion1 = MyMarchingCubesConstants.EdgeConversion[edgeIndex1];
                Vector4I edgeConversion2 = MyMarchingCubesConstants.EdgeConversion[edgeIndex2];

                MyEdgeVertex edgeVertex0 = m_edgeVertex[edge.X + edgeConversion0.X][edge.Y + edgeConversion0.Y][edge.Z + edgeConversion0.Z][edgeConversion0.W];
                MyEdgeVertex edgeVertex1 = m_edgeVertex[edge.X + edgeConversion1.X][edge.Y + edgeConversion1.Y][edge.Z + edgeConversion1.Z][edgeConversion1.W];
                MyEdgeVertex edgeVertex2 = m_edgeVertex[edge.X + edgeConversion2.X][edge.Y + edgeConversion2.Y][edge.Z + edgeConversion2.Z][edgeConversion2.W];


                MyVoxelVertex compressedVertex0 = new MyVoxelVertex();
                compressedVertex0.Position = edge0.Position;
                MyVoxelVertex compressedVertex1 = new MyVoxelVertex();
                compressedVertex1.Position = edge1.Position;
                MyVoxelVertex compressedVertex2 = new MyVoxelVertex();
                compressedVertex2.Position = edge2.Position;

                //  We want to skip all wrong triangles, those that have two vertex at almost the same location, etc.
                //  We do it simply, by calculating triangle normal and then checking if this normal has length large enough
                if (IsWrongTriangle(ref compressedVertex0, ref compressedVertex1, ref compressedVertex2) == true)
                {
                    continue;
                }

                //  Vertex at edge 0
                if (edgeVertex0.CalcCounter != m_edgeVertexCalcCounter)
                {
                    //  If vertex at edge0 wasn't calculated for this cell during this precalc, we need to add it

                    //  Short overflow check
                    System.Diagnostics.Debug.Assert(m_resultVerticesCounter <= ushort.MaxValue);

                    edgeVertex0.CalcCounter = m_edgeVertexCalcCounter;
                    edgeVertex0.VertexIndex = (ushort)m_resultVerticesCounter;

                    tmpVertex.Position      = edge0.Position;
                    tmpVertex.Normal        = edge0.Normal;
                    tmpVertex.Ambient       = edge0.Ambient;
                    tmpVertex.Material      = edge0.Material;
                    tmpVertex.PositionMorph = edge0.Position;
                    m_resultVertices[m_resultVerticesCounter] = tmpVertex;

                    m_resultVerticesCounter++;
                }

                //  Vertex at edge 1
                if (edgeVertex1.CalcCounter != m_edgeVertexCalcCounter)
                {
                    //  If vertex at edge1 wasn't calculated for this cell during this precalc, we need to add it

                    //  Short overflow check
                    System.Diagnostics.Debug.Assert(m_resultVerticesCounter <= ushort.MaxValue);

                    edgeVertex1.CalcCounter = m_edgeVertexCalcCounter;
                    edgeVertex1.VertexIndex = (ushort)m_resultVerticesCounter;

                    tmpVertex.Position      = edge1.Position;
                    tmpVertex.Normal        = edge1.Normal;
                    tmpVertex.Ambient       = edge1.Ambient;
                    tmpVertex.Material      = edge1.Material;
                    tmpVertex.PositionMorph = edge1.Position;
                    m_resultVertices[m_resultVerticesCounter] = tmpVertex;

                    m_resultVerticesCounter++;
                }

                //  Vertex at edge 2
                if (edgeVertex2.CalcCounter != m_edgeVertexCalcCounter)
                {
                    //  If vertex at edge2 wasn't calculated for this cell during this precalc, we need to add it

                    //  Short overflow check
                    System.Diagnostics.Debug.Assert(m_resultVerticesCounter <= ushort.MaxValue);

                    edgeVertex2.CalcCounter = m_edgeVertexCalcCounter;
                    edgeVertex2.VertexIndex = (ushort)m_resultVerticesCounter;

                    tmpVertex.Position      = edge2.Position;
                    tmpVertex.Normal        = edge2.Normal;
                    tmpVertex.Ambient       = edge2.Ambient;
                    tmpVertex.Material      = edge2.Material;
                    tmpVertex.PositionMorph = edge2.Position;
                    tmpVertex.Cell          = coord0;
                    ;
                    m_resultVertices[m_resultVerticesCounter] = tmpVertex;

                    m_resultVerticesCounter++;
                }

                //  Triangle
                m_resultTriangles[m_resultTrianglesCounter].VertexIndex0 = edgeVertex0.VertexIndex;
                m_resultTriangles[m_resultTrianglesCounter].VertexIndex1 = edgeVertex1.VertexIndex;
                m_resultTriangles[m_resultTrianglesCounter].VertexIndex2 = edgeVertex2.VertexIndex;

                Debug.Assert(edgeVertex0.VertexIndex < m_resultVerticesCounter);
                Debug.Assert(edgeVertex1.VertexIndex < m_resultVerticesCounter);
                Debug.Assert(edgeVertex2.VertexIndex < m_resultVerticesCounter);

                m_resultTrianglesCounter++;
            }
        }
Ejemplo n.º 33
0
 public void TestToString()
 {
     CultureInfo originalCulture = Thread.CurrentThread.CurrentCulture;
     try
     {
         Thread.CurrentThread.CurrentCulture = new CultureInfo("tr-TR");
         Vector4I a = new Vector4I(1, 2, 3, 4);
         Assert.AreEqual("(1, 2, 3, 4)", a.ToString());
     }
     finally
     {
         Thread.CurrentThread.CurrentCulture = originalCulture;
     }
 }