示例#1
0
            // 仮想メッシュ頂点ごと
            public void Execute(int vindex)
            {
                // 計算フラグ頂点のみ
                var vflag = virtualVertexFlagList[vindex];

                if (vflag == 0)
                {
                    return;
                }

                //uint info = virtualVertexInfoList[vindex];
                // 使用頂点のみ
                //if ((info & 0xffff) == 0)
                if (virtualVertexUseList[vindex] == 0)
                {
                    return;
                }

                // このメッシュの使用をチェック
                //int mindex = DataUtility.Unpack16Hi(info);
                int mindex  = virtualVertexMeshIndexList[vindex];
                var m_minfo = virtualMeshInfoList[mindex - 1]; // (-1)するので注意!

                if (m_minfo.IsUse() == false)
                {
                    return;
                }

                var s_minfo  = sharedVirtualMeshInfoList[m_minfo.sharedVirtualMeshIndex];
                int s_vstart = s_minfo.vertexChunk.startIndex;
                int i        = vindex - m_minfo.vertexChunk.startIndex;
                int m_tstart = m_minfo.triangleChunk.startIndex;

                uint pack     = sharedVirtualVertexToTriangleInfoList[s_vstart + i];
                int  s_tcnt   = DataUtility.Unpack8_24Hi(pack);
                int  s_tstart = DataUtility.Unpack8_24Low(pack);

                if (s_tcnt == 0)
                {
                    return;
                }
                s_tstart += s_minfo.vertexToTriangleChunk.startIndex;

                float3 nor = 0;
                float3 tan = 0;

                for (int j = 0; j < s_tcnt; j++)
                {
                    int tindex = sharedVirtualVertexToTriangleIndexList[s_tstart + j] + m_tstart;

                    nor += virtualTriangleNormalList[tindex];
                    tan += virtualTriangleTangentList[tindex];
                }
                nor = math.normalize(nor);
                tan = math.normalize(tan);
                virtualRotList[vindex] = quaternion.LookRotation(nor, tan);
            }