Esempio n. 1
0
 private void RenderMe(Camera c)
 {
     if (!Application.isPlaying)
     {
         return;
     }
     fCBP.Flush();
     v2CBP.Flush();
     argsCBP.Flush();
     args[0] = ri.mesh.GetIndexCount(0);
     for (int done = 0; done < instanceCount; done += batchSize)
     {
         int run = Math.Min(instanceCount - done, batchSize);
         args[1] = (uint)run;
         for (int batchInd = 0; batchInd < run; ++batchInd)
         {
             var obj = objects[done + batchInd];
             posArr[batchInd]  = obj.position;
             dirArr[batchInd]  = new Vector2(Mathf.Cos(obj.rotation) * obj.scale, Mathf.Sin(obj.rotation) * obj.scale);
             timeArr[batchInd] = obj.time;
         }
         var posCB  = v2CBP.Rent();
         var dirCB  = v2CBP.Rent();
         var timeCB = fCBP.Rent();
         posCB.SetData(posArr, 0, 0, run);
         dirCB.SetData(dirArr, 0, 0, run);
         timeCB.SetData(timeArr, 0, 0, run);
         pb.SetBuffer(positionPropertyId, posCB);
         pb.SetBuffer(directionPropertyId, dirCB);
         pb.SetBuffer(timePropertyId, timeCB);
         var argsCB = argsCBP.Rent();
         argsCB.SetData(args);
         CallRender(c, argsCB);
     }
 }