コード例 #1
0
 public void Initialize(ComponentGroup group, Vector3[] vertices, Vector3[] normals, NativeCounter.Concurrent counter)
 {
     _thicknesses = group.GetComponentDataArray <Thickness>();
     _lines       = group.GetComponentDataArray <Line>();
     _vertices    = UnsafeUtility.AddressOf(ref vertices[0]);
     _normals     = UnsafeUtility.AddressOf(ref normals[0]);
     _counter     = counter;
 }
コード例 #2
0
    public void ConcurrentIncrement()
    {
        var counter = new NativeCounter(Allocator.Temp);

        NativeCounter.Concurrent concurrentCounter = counter;
        Assert.AreEqual(0, counter.Count);
        concurrentCounter.Increment();
        Assert.AreEqual(1, counter.Count);
        concurrentCounter.Increment();
        concurrentCounter.Increment();
        Assert.AreEqual(3, counter.Count);
        counter.Dispose();
    }
コード例 #3
0
        static unsafe void AddQuadByDirection(int direction, Voxel.VoxelType data, VoxelLight voxelLight, float width, float height, int3 gridPosition, NativeCounter.Concurrent counter, NativeArray <float3> vertices, NativeArray <float3> normals, NativeArray <float4> uvs, NativeArray <Color> colors, NativeArray <int> indices)
        {
            int numFace = counter.Increment();

            int numVertices = numFace * 4;

            for (int i = 0; i < 4; i++)
            {
                float3 vertex;
                vertex = CubeVertices[CubeFaces[i + direction * 4]];
                vertex[DirectionAlignedX[direction]] *= width;
                vertex[DirectionAlignedY[direction]] *= height;

                int  atlasIndex    = (int)data * 6 + direction;
                int2 atlasPosition = new int2 {
                    x = atlasIndex % AtlasSize.x, y = atlasIndex / AtlasSize.x
                };

                float4 uv = new float4 {
                    x = CubeUVs[i].x * width, y = CubeUVs[i].y * height, z = atlasPosition.x, w = atlasPosition.y
                };

                colors[numVertices + i]   = new Color(0, 0, 0, voxelLight.ambient[i + direction * 4]);
                vertices[numVertices + i] = vertex + gridPosition;
                normals[numVertices + i]  = VoxelDirectionOffsets[direction];
                uvs[numVertices + i]      = uv;
            }

            int numindices = numFace * 6;

            for (int i = 0; i < 6; i++)
            {
                if (voxelLight.ambient[direction * 4] + voxelLight.ambient[direction * 4 + 3] < voxelLight.ambient[direction * 4 + 1] + voxelLight.ambient[direction * 4 + 2])
                {
                    indices[numindices + i] = CubeFlipedIndices[direction * 6 + i] + numVertices;
                }
                else
                {
                    indices[numindices + i] = CubeIndices[direction * 6 + i] + numVertices;
                }
            }
        }