Example #1
0
 void Update()
 {
     //animStateInfo = animator.GetCurrentAnimatorStateInfo(0);
     //Debug.LogError(animStateInfo.normalizedTime);
     ProfilerSample.BeginSample("TimerUpdate");
     Timer.Instance.Update(Time.deltaTime);
     ProfilerSample.EndSample();
 }
Example #2
0
 void Update() //NOTE: using FixedUpdate the camera follow bhv should be also updated in FixedUpdate after this script is executed
 {
     //RpgMapHelper.DebugDrawRect( transform.position, CollRect, Color.white );
     if (Dir.sqrMagnitude > 0f)
     {
         // divide by n per second ( n:2 )
         m_speed += (MaxSpeed - m_speed) / Mathf.Pow(2f, Time.deltaTime);
     }
     else
     {
         m_speed /= Mathf.Pow(2f, Time.deltaTime);
     }
     Dir.z = 0f;
     transform.position += Dir * m_speed * Time.deltaTime;
     if (IsCollEnabled)
     {
         ProfilerSample.BeginSample("DoCollisions");
         DoCollisions();
         ProfilerSample.EndSample();
     }
 }
Example #3
0
    private void ContainsPoint()
    {
        ProfilerSample.BeginSample("ContainsPoint");
        for (int i = 0, length = centers.Length; i < length; i++)
        {
            result[i] = ContainsPoint(centers[i]) ? 1 : 0;
        }
        ProfilerSample.EndSample();

        ProfilerSample.BeginSample("ContainsPointJobSystem");
        // Create a native array of a single float to store the result. This example waits for the job to complete for illustration purposes
        AABBJob job = new AABBJob();

        job.max = max;
        job.min = min;
        pointArray.CopyFrom(centers);
        job.points = pointArray;
        job.result = rs;
        // Schedule the job
        JobHandle handle = job.Schedule();

        // Wait for the job to complete
        handle.Complete();
        rs.CopyTo(result);
        ProfilerSample.EndSample();

        ProfilerSample.BeginSample("ContainsPointComputeShader");
        computeShader.SetVector(Shader.PropertyToID("box_min"), min);                  //cpu->gpu
        computeShader.SetVector(Shader.PropertyToID("box_max"), max);                  //cpu->gpu
        computeShader.SetInt(Shader.PropertyToID("size"), count);                      //cpu->gpu
        pointsBuffer.SetData(centers);
        computeShader.SetBuffer(_kernel, Shader.PropertyToID("points"), pointsBuffer); //cpu->gpu
        computeShader.SetBuffer(_kernel, Shader.PropertyToID("output"), output);       ////cpu->gpu->cpu
        //Debug.Log(output.count + "        " + result.Length);
        computeShader.Dispatch(_kernel, 1024, 1, 1);                                   //调用核函数
        output.GetData(result);                                                        //获取compute shader中计算后的结果数据
        ProfilerSample.EndSample();
    }
Example #4
0
        const int k_subDiv = 6;         // sub divisions
        public bool IsColliding(Vector3 vPos)
        {
            Vector3 vCheckedPos = Vector3.zero;

            for (int i = 0; i < k_subDiv; ++i)
            {
                for (int j = 0; j < k_subDiv; ++j)
                {
                    vCheckedPos.x = vPos.x + Mathf.Lerp(CollRect.x, CollRect.x + CollRect.width, (float)i / (k_subDiv - 1));
                    vCheckedPos.y = vPos.y + Mathf.Lerp(CollRect.y, CollRect.y + CollRect.height, (float)j / (k_subDiv - 1));

                    ProfilerSample.BeginSample("GetAutotileCollisionAtPosition");
                    eTileCollisionType collType = AutoTileMap.Instance.GetAutotileCollisionAtPosition(vCheckedPos);
                    ProfilerSample.EndSample();

                    if (collType != eTileCollisionType.PASSABLE && collType != eTileCollisionType.OVERLAY)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Example #5
0
    private void Intersects()
    {
        ProfilerSample.BeginSample("Intersects");
        for (int i = 0, length = aabbs.Length; i < length; i++)
        {
            AABB aabb = aabbs[i];
            result[i] = Intersects(aabb.aabbMin, aabb.aabbMax) ? 1 : 0;
        }
        ProfilerSample.EndSample();

        //ProfilerSample.BeginSample("IntersectsJobSystem");
        //// Create a native array of a single float to store the result. This example waits for the job to complete for illustration purposes
        //AABBJob job = new AABBJob();
        //job.max = max;
        //job.min = min;
        //aabbArray.CopyFrom(aabbs);
        //job.aabbs = aabbArray;
        //job.result = rs;
        //// Schedule the job
        //JobHandle handle = job.Schedule();
        //// Wait for the job to complete
        //handle.Complete();
        //rs.CopyTo(result);
        //ProfilerSample.EndSample();

        ProfilerSample.BeginSample("IntersectsComputeShader");
        computeShader.SetVector(Shader.PropertyToID("box_min"), min);                //cpu->gpu
        computeShader.SetVector(Shader.PropertyToID("box_max"), max);                //cpu->gpu
        computeShader.SetInt(Shader.PropertyToID("size"), count);                    //cpu->gpu
        aabbsBuffer.SetData(aabbs);
        computeShader.SetBuffer(_kernel, Shader.PropertyToID("aabbs"), aabbsBuffer); //cpu->gpu
        computeShader.SetBuffer(_kernel, Shader.PropertyToID("output"), output);     ////cpu->gpu->cpu
        //Debug.Log(output.count + "        " + result.Length);
        computeShader.Dispatch(_kernel, 1024, 1, 1);                                 //调用核函数
        output.GetData(result);                                                      //获取compute shader中计算后的结果数据
        ProfilerSample.EndSample();
    }