public void DestroyDecalEntity(DecalEntity decalEntity) { if (!m_DecalEntityIndexer.IsValid(decalEntity)) { return; } var decalItem = m_DecalEntityIndexer.GetItem(decalEntity); m_DecalEntityIndexer.DestroyDecalEntity(decalEntity); int chunkIndex = decalItem.chunkIndex; int arrayIndex = decalItem.arrayIndex; DecalEntityChunk entityChunk = entityChunks[chunkIndex]; DecalCachedChunk cachedChunk = cachedChunks[chunkIndex]; DecalCulledChunk culledChunk = culledChunks[chunkIndex]; DecalDrawCallChunk drawCallChunk = drawCallChunks[chunkIndex]; int lastArrayIndex = entityChunk.count - 1; if (arrayIndex != lastArrayIndex) { m_DecalEntityIndexer.UpdateIndex(entityChunk.decalEntities[lastArrayIndex], arrayIndex); } entityChunk.RemoveAtSwapBack(arrayIndex); cachedChunk.RemoveAtSwapBack(arrayIndex); culledChunk.RemoveAtSwapBack(arrayIndex); drawCallChunk.RemoveAtSwapBack(arrayIndex); }
public DecalEntity CreateDecalEntity(DecalProjector decalProjector) { var material = decalProjector.material; if (material == null) { material = errorMaterial; } using (new ProfilingScope(null, m_AddDecalSampler)) { int chunkIndex = CreateChunkIndex(material); int entityIndex = entityChunks[chunkIndex].count; DecalEntity entity = m_DecalEntityIndexer.CreateDecalEntity(entityIndex, chunkIndex); DecalEntityChunk entityChunk = entityChunks[chunkIndex]; DecalCachedChunk cachedChunk = cachedChunks[chunkIndex]; DecalCulledChunk culledChunk = culledChunks[chunkIndex]; DecalDrawCallChunk drawCallChunk = drawCallChunks[chunkIndex]; // Make sure we have space to add new entity if (entityChunks[chunkIndex].capacity == entityChunks[chunkIndex].count) { using (new ProfilingScope(null, m_ResizeChunks)) { int newCapacity = entityChunks[chunkIndex].capacity + entityChunks[chunkIndex].capacity; newCapacity = math.max(8, newCapacity); entityChunk.SetCapacity(newCapacity); cachedChunk.SetCapacity(newCapacity); culledChunk.SetCapacity(newCapacity); drawCallChunk.SetCapacity(newCapacity); } } entityChunk.Push(); cachedChunk.Push(); culledChunk.Push(); drawCallChunk.Push(); entityChunk.decalProjectors[entityIndex] = decalProjector; entityChunk.decalEntities[entityIndex] = entity; entityChunk.transformAccessArray.Add(decalProjector.transform); UpdateDecalEntityData(entity, decalProjector); return(entity); } }
public void Execute(DecalCachedChunk cachedChunk, DecalCulledChunk culledChunk, int count) { cachedChunk.currentJobHandle.Complete(); CullingGroup cullingGroup = culledChunk.cullingGroups; cullingGroup.targetCamera = m_Camera; cullingGroup.SetDistanceReferencePoint(m_Camera.transform.position); cullingGroup.SetBoundingDistances(m_BoundingDistance); cachedChunk.boundingSpheres.CopyTo(cachedChunk.boundingSphereArray); cullingGroup.SetBoundingSpheres(cachedChunk.boundingSphereArray); cullingGroup.SetBoundingSphereCount(count); culledChunk.cameraPosition = m_Camera.transform.position; culledChunk.cullingMask = m_Camera.cullingMask; #if UNITY_EDITOR culledChunk.sceneCullingMask = GetSceneCullingMaskFromCamera(m_Camera); #endif }
private void Execute(DecalCulledChunk culledChunk, int count) { if (count == 0) { return; } culledChunk.currentJobHandle.Complete(); for (int i = 0; i < count; ++i) { culledChunk.visibleDecalIndices[i] = i; } culledChunk.visibleDecalCount = count; culledChunk.cameraPosition = m_Camera.transform.position; culledChunk.cullingMask = m_Camera.cullingMask; #if UNITY_EDITOR culledChunk.sceneCullingMask = GetSceneCullingMaskFromCamera(m_Camera); #endif }