Ejemplo n.º 1
0
        //=========================================================================================
        /// <summary>
        /// パーティクルを1つ作成
        /// </summary>
        /// <param name="flag"></param>
        /// <param name="wpos"></param>
        /// <param name="wrot"></param>
        /// <param name="radius"></param>
        /// <param name="mass"></param>
        /// <param name="gravity"></param>
        /// <param name="drag"></param>
        /// <param name="depth"></param>
        /// <param name="maxVelocity"></param>
        /// <param name="target"></param>
        /// <returns></returns>
        public ChunkData CreateParticle(
            uint flag,
            int team,
            float3 wpos, quaternion wrot,
            float depth,
            float3 radius,
            float3 targetLocalPos
            )
        {
            flag |= Flag_Enable; // 有効フラグは必須
            var pf = new ParticleFlag(flag);
            var c  = flagList.Add(pf);

            teamIdList.Add(team);
            posList.Add(wpos);
            rotList.Add(wrot);
            oldPosList.Add(wpos);
            oldRotList.Add(wrot);
            oldSlowPosList.Add(wpos);
            localPosList.Add(targetLocalPos);
            basePosList.Add(wpos);
            baseRotList.Add(wrot);
            depthList.Add(depth);
            radiusList.Add(radius);
            frictionList.Add(0.0f);
            velocityList.Add(0);
            collisionLinkIdList.Add(0);
            collisionDistList.Add(0);
            //collisionLinkLocalPosList.Add(0);
            //collisionLinkDirectionList.Add(0);
            nextPos0List.Add(0);
            nextPos1List.Add(0);
            nextRot0List.Add(quaternion.identity);
            nextRot1List.Add(quaternion.identity);

            // トランスフォームアクセス
            int restoreTransformIndex = -1;
            int transformIndex        = -1;

            restoreTransformIndexList.Add(restoreTransformIndex);
            transformIndexList.Add(transformIndex);

            // コライダーカウント
            if (pf.IsCollider())
            {
                colliderCount++;
            }

            return(c);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// パーティクルをグループで作成
        /// </summary>
        /// <param name="team"></param>
        /// <param name="count"></param>
        /// <param name="funcFlag"></param>
        /// <param name="funcWpos"></param>
        /// <param name="funcWrot"></param>
        /// <param name="funcLpos"></param>
        /// <param name="funcLrot"></param>
        /// <param name="funcRadius"></param>
        /// <param name="funcMass"></param>
        /// <param name="funcGravity"></param>
        /// <param name="funcDrag"></param>
        /// <param name="funcDepth"></param>
        /// <param name="funcMaxVelocity"></param>
        /// <param name="funcTarget"></param>
        /// <param name="funcTargetLocalPos"></param>
        /// <returns></returns>
        public ChunkData CreateParticle(
            int team,
            int count,
            System.Func <int, uint> funcFlag,
            System.Func <int, float3> funcWpos,
            System.Func <int, quaternion> funcWrot,
            System.Func <int, float> funcDepth,
            System.Func <int, float3> funcRadius,
            System.Func <int, float3> funcTargetLocalPos
            )
        {
            var c = flagList.AddChunk(count);

            teamIdList.AddChunk(count);
            posList.AddChunk(count);
            rotList.AddChunk(count);
            oldPosList.AddChunk(count);
            oldRotList.AddChunk(count);
            oldSlowPosList.AddChunk(count);
            localPosList.AddChunk(count);
            basePosList.AddChunk(count);
            baseRotList.AddChunk(count);
            depthList.AddChunk(count);
            radiusList.AddChunk(count);
            frictionList.AddChunk(count);
            velocityList.AddChunk(count);
            collisionLinkIdList.AddChunk(count);
            collisionDistList.AddChunk(count);
            //collisionLinkLocalPosList.AddChunk(count);
            //collisionLinkDirectionList.AddChunk(count);
            nextPos0List.AddChunk(count);
            nextPos1List.AddChunk(count);
            nextRot0List.AddChunk(count);
            nextRot1List.AddChunk(count);
            restoreTransformIndexList.AddChunk(count);
            transformIndexList.AddChunk(count);

            teamIdList.Fill(c, team);
            nextRot0List.Fill(c, quaternion.identity);
            nextRot1List.Fill(c, quaternion.identity);

            for (int i = 0; i < count; i++)
            {
                int pindex = c.startIndex + i;

                uint       flag   = Flag_Enable;
                float3     wpos   = 0;
                quaternion wrot   = quaternion.identity;
                float3     tlpos  = 0;
                float      depth  = 0;
                float3     radius = 0;
                int        restoreTransformIndex = -1;
                int        transformIndex        = -1;

                if (funcFlag != null)
                {
                    flag |= funcFlag(i);
                }
                var pf = new ParticleFlag(flag);
                if (funcWpos != null)
                {
                    wpos = funcWpos(i);
                }
                if (funcWrot != null)
                {
                    wrot = funcWrot(i);
                }
                if (funcTargetLocalPos != null)
                {
                    tlpos = funcTargetLocalPos(i);
                }
                if (funcDepth != null)
                {
                    depth = funcDepth(i);
                }
                if (funcRadius != null)
                {
                    radius = funcRadius(i);
                }

                flagList[pindex]                  = pf;
                posList[pindex]                   = wpos;
                rotList[pindex]                   = wrot;
                oldPosList[pindex]                = wpos;
                oldRotList[pindex]                = wrot;
                oldSlowPosList[pindex]            = wpos;
                localPosList[pindex]              = tlpos;
                basePosList[pindex]               = wpos;
                baseRotList[pindex]               = wrot;
                depthList[pindex]                 = depth;
                radiusList[pindex]                = radius;
                restoreTransformIndexList[pindex] = restoreTransformIndex;
                transformIndexList[pindex]        = transformIndex;

                // コライダーカウント
                if (pf.IsCollider())
                {
                    colliderCount++;
                }
            }

            return(c);
        }