public CachedBatch( CachedBatchType cbt, IBatchContainer container, int layer, bool worldSpace, RasterizerState rasterizerState, DepthStencilState depthStencilState, BlendState blendState, SamplerState samplerState, Material customMaterial, bool useZBuffer ) { Batch = null; BatchType = cbt; Container = container; Layer = layer; // FIXME: Mask if multimaterial? WorldSpace = worldSpace; UseZBuffer = useZBuffer; if (cbt != CachedBatchType.MultimaterialBitmap) { RasterizerState = rasterizerState; DepthStencilState = depthStencilState; BlendState = blendState; SamplerState = samplerState; CustomMaterial = customMaterial; } else { RasterizerState = null; DepthStencilState = null; BlendState = null; SamplerState = null; CustomMaterial = null; } HashCode = Container.GetHashCode() ^ Layer.GetHashCode(); if (BlendState != null) { HashCode ^= BlendState.GetHashCode(); } if (SamplerState != null) { HashCode ^= SamplerState.GetHashCode(); } if (CustomMaterial != null) { HashCode ^= CustomMaterial.GetHashCode(); } }
public bool TryGet <T> ( out CachedBatch result, CachedBatchType cbt, IBatchContainer container, int layer, bool worldSpace, RasterizerState rasterizerState, DepthStencilState depthStencilState, BlendState blendState, SamplerState samplerState, Material customMaterial, bool useZBuffer ) { CachedBatch itemAtIndex, searchKey; searchKey = new CachedBatch( cbt, container, layer, worldSpace, rasterizerState, depthStencilState, blendState, samplerState, customMaterial, useZBuffer ); for (var i = 0; i < Count; i++) { GetItemAtIndex(i, out itemAtIndex); if (itemAtIndex.HashCode != searchKey.HashCode) { continue; } if (itemAtIndex.KeysEqual(ref searchKey)) { result = itemAtIndex; InsertAtFront(ref itemAtIndex, i); return(result.Batch != null); } } result = searchKey; return(false); }