Example #1
0
 private bool OnAcceptRenderMesh(RenderContext context, RenderMesh renderMesh)
 {
     // NOTICE: Don't use Linq, as It would allocated objects and triggers GC
     foreach (var test in acceptRenderMeshes)
     {
         if (!test(context, renderMesh))
         {
             return(false);
         }
     }
     return(true);
 }
Example #2
0
        private void QuickSort(int[] indices, RenderMesh[] meshes, int left, int right)
        {
            if (left > right)
            {
                return;
            }

            int i     = left;
            int j     = right;
            int pivot = indices[(left + right) / 2];

            while (i <= j)
            {
                while (indices[i] < pivot)
                {
                    ++i;
                }
                while (indices[j] > pivot)
                {
                    --j;
                }
                if (i <= j)
                {
                    RenderMesh meshTmp = meshes[i];
                    meshes[i] = meshes[j];
                    meshes[j] = meshTmp;

                    int indexTmp = indices[i];
                    indices[i++] = indices[j];
                    indices[j--] = indexTmp;
                }
            }

            // Recurse
            if (left < j)
            {
                QuickSort(indices, meshes, left, j);
            }
            if (i < right)
            {
                QuickSort(indices, meshes, i, right);
            }
        }
Example #3
0
        private void PrepareModelForRendering(RenderModel renderModel)
        {
            foreach (var mesh in renderModel.Model.Meshes)
            {
                if (acceptPrepareMeshForRenderings.Count > 0 && !OnAcceptPrepareMeshForRendering(renderModel, mesh))
                {
                    continue;
                }

                var effectMesh = new RenderMesh(renderModel, mesh);
                UpdateEffect(effectMesh);

                // Register mesh for rendering
                if (renderModel.RenderMeshes[meshPassSlot] == null)
                {
                    renderModel.RenderMeshes[meshPassSlot] = new List <RenderMesh>();
                }
                renderModel.RenderMeshes[meshPassSlot].Add(effectMesh);
            }
        }
Example #4
0
 /// <summary>
 /// Generates the sort key for each mesh. Meshes will be sorted in ascending order using this key.
 /// </summary>
 /// <param name="renderMesh">The render mesh.</param>
 /// <returns></returns>
 public abstract int GenerateSortKey(RenderMesh renderMesh);