示例#1
0
        public void Clear(int id)
        {
            if (id < 0)
            {
                logger.LogError("Invalid Id {}", id);
                return;
            }
            var offsetInArray = GetOffSet(id);

            if (offsetInArray + structSize > binaryArray.Count)
            {
                Debug.Assert(false);
                return;
            }
            rwLock.EnterReadLock();
            var array = binaryArray.GetInternalArray();

            Array.Clear(array, offsetInArray, structSize);
            rwLock.ExitReadLock();
        }
            /// <summary>
            /// To the helix mesh with bones.
            /// </summary>
            /// <param name="mesh">The mesh.</param>
            /// <returns></returns>
            protected virtual BoneSkinnedMeshGeometry3D OnCreateHelixMeshWithBones(Mesh mesh)
            {
                var m                = OnCreateHelixMesh(mesh);
                var vertBoneIds      = new FastList <BoneIds>(Enumerable.Repeat(new BoneIds(), m.Positions.Count));
                var vertBoneInternal = vertBoneIds.GetInternalArray();
                var accumArray       = new int[m.Positions.Count];
                var boneMesh         = new BoneSkinnedMeshGeometry3D(m)
                {
                    VertexBoneIds = vertBoneIds
                };

                for (var j = 0; j < mesh.BoneCount; ++j)
                {
                    if (mesh.Bones[j].HasVertexWeights)
                    {
                        for (var i = 0; i < mesh.Bones[j].VertexWeightCount; ++i)
                        {
                            var vWeight = mesh.Bones[j].VertexWeights[i];
                            if (vWeight.VertexID >= accumArray.Length)
                            {
                                logger.LogWarning("Bone weight index is out of range. Num verts: {}; Bone vert index: {}",
                                                  accumArray.Length, vWeight.VertexID);
                                continue;
                            }
                            var     currIdx = accumArray[vWeight.VertexID]++;
                            ref var id      = ref vertBoneInternal[vWeight.VertexID];
                            switch (currIdx)
                            {
                            case 0:
                                id.Bone1     = j;
                                id.Weights.X = vWeight.Weight;
                                break;

                            case 1:
                                id.Bone2     = j;
                                id.Weights.Y = vWeight.Weight;
                                break;

                            case 2:
                                id.Bone3     = j;
                                id.Weights.Z = vWeight.Weight;
                                break;

                            case 3:
                                id.Bone4     = j;
                                id.Weights.W = vWeight.Weight;
                                break;
                            }
                        }
                    }
                }