Example #1
0
        private void AddVertexToBuffer(SingleMaterialHelper materialHelper, ref MyVoxelVertex vertex,
                                       VertexInBatchLookup inBatchLookup, ushort srcVertexIdx, uint matInfo)
        {
            if (!inBatchLookup.IsInBatch(srcVertexIdx))
            {
                int tgtVertexIdx = materialHelper.VertexCount;

                //  Short overflow check
                Debug.Assert(tgtVertexIdx <= ushort.MaxValue);

                materialHelper.Vertices[tgtVertexIdx].Position      = vertex.Position;
                materialHelper.Vertices[tgtVertexIdx].PositionMorph = vertex.PositionMorph;
                materialHelper.Vertices[tgtVertexIdx].Ambient       = vertex.Ambient;
                materialHelper.Vertices[tgtVertexIdx].AmbientMorph  = vertex.AmbientMorph;
                materialHelper.Vertices[tgtVertexIdx].Normal        = vertex.Normal;
                materialHelper.Vertices[tgtVertexIdx].NormalMorph   = vertex.NormalMorph;

                // NOTE: I don't know C#, so I am not sure if this is OK performance wise
                materialHelper.Vertices[tgtVertexIdx].MaterialInfo = new VRageMath.PackedVector.Byte4(matInfo);


                inBatchLookup.PutToBatch(srcVertexIdx, (ushort)tgtVertexIdx);

                materialHelper.VertexCount++;
            }
        }
        private void AddVertexToBuffer(SingleMaterialHelper materialHelper, ref MyVoxelVertex vertex,
                                       VertexInBatchLookup inBatchLookup, short srcVertexIdx)
        {
            if (!inBatchLookup.IsInBatch(srcVertexIdx))
            {
                int tgtVertexIdx = materialHelper.VertexCount;

                //  Short overflow check
                Debug.Assert(tgtVertexIdx <= short.MaxValue);

                materialHelper.Vertices[tgtVertexIdx].Position      = vertex.Position;
                materialHelper.Vertices[tgtVertexIdx].PositionMorph = vertex.PositionMorph;
                materialHelper.Vertices[tgtVertexIdx].Ambient       = vertex.Ambient;
                materialHelper.Vertices[tgtVertexIdx].Normal        = vertex.Normal;
                materialHelper.Vertices[tgtVertexIdx].NormalMorph   = vertex.NormalMorph;

                inBatchLookup.PutToBatch(srcVertexIdx, (short)tgtVertexIdx);

                materialHelper.VertexCount++;
            }
        }
        private void AddVertexToBuffer(SingleMaterialHelper materialHelper, ref MyVoxelVertex vertex,
            VertexInBatchLookup inBatchLookup, ushort srcVertexIdx)
        {
            if (!inBatchLookup.IsInBatch(srcVertexIdx))
            {
                int tgtVertexIdx = materialHelper.VertexCount;

                //  Short overflow check
                Debug.Assert(tgtVertexIdx <= ushort.MaxValue);

                materialHelper.Vertices[tgtVertexIdx].Position = vertex.Position;
                materialHelper.Vertices[tgtVertexIdx].PositionMorph = vertex.PositionMorph;
                materialHelper.Vertices[tgtVertexIdx].Ambient = vertex.Ambient;
                materialHelper.Vertices[tgtVertexIdx].AmbientMorph = vertex.AmbientMorph;
                materialHelper.Vertices[tgtVertexIdx].Normal = vertex.Normal;
                materialHelper.Vertices[tgtVertexIdx].NormalMorph = vertex.NormalMorph;

                inBatchLookup.PutToBatch(srcVertexIdx, (ushort)tgtVertexIdx);

                materialHelper.VertexCount++;
            }
        }