public static Hash128 ToHash128(ref RenderMesh renderMesh) { if (renderMesh.mesh != null && renderMesh.material != null) { return(UnityEngine.Hash128.Compute( $"{renderMesh.mesh.GetInstanceID()}{renderMesh.material.GetInstanceID()}{renderMesh.layer}{renderMesh.castShadows}{renderMesh.receiveShadows}{renderMesh.subMesh}")); } throw new ArgumentException("mesh and material couldn't be null"); }
protected override void OnUpdate() { ForEach((MeshRenderer meshRenderer, MeshFilter meshFilter) => { var entity = GetPrimaryEntity(meshRenderer); var dst = new RenderMesh(); dst.mesh = meshFilter.sharedMesh; dst.castShadows = meshRenderer.shadowCastingMode; dst.receiveShadows = meshRenderer.receiveShadows; var materials = meshRenderer.sharedMaterials; if (materials.Length == 1 && AttachToPrimaryEntityForSingleMaterial) { dst.material = materials[0]; dst.subMesh = 0; DstEntityManager.AddSharedComponentData(entity, dst); DstEntityManager.AddComponentData(entity, new PerInstanceCullingTag()); } else { for (int m = 0; m != materials.Length; m++) { var meshEntity = CreateAdditionalEntity(meshRenderer); dst.material = materials[m]; dst.subMesh = m; DstEntityManager.AddSharedComponentData(meshEntity, dst); DstEntityManager.AddComponentData(meshEntity, new PerInstanceCullingTag()); //@TODO: Shouldn't be necessary to add Position Component, but looks like TransformSystem doesn't setup LocalToWorld otherwise... DstEntityManager.AddComponentData(meshEntity, new Position()); // Parent it var attach = CreateAdditionalEntity(meshRenderer); DstEntityManager.AddComponentData(attach, new Attach { Parent = entity, Child = meshEntity }); } } //@TODO: Transform system should handle RenderMeshFlippedWindingTag // Flag this thing as positively or negatively scaled, so we can batch the renders correctly for the static case. //if (math.determinant(localToWorld) < 0.0) // entityManager.AddComponent(meshEnt, ComponentType.Create<RenderMeshFlippedWindingTag>()); }); }
/// <summary> /// Construct a <see cref="RenderMeshDescription"/> using defaults from the given /// <see cref="Renderer"/> and <see cref="Mesh"/> objects. /// </summary> /// <param name="renderer">The renderer object (e.g. a <see cref="MeshRenderer"/>) to get default settings from.</param> /// <param name="mesh">The mesh to use and get default bounds from.</param> /// <param name="sharedMaterials">The list of materials to render the entity with. /// If the list is null or empty, <see cref="Renderer.GetSharedMaterials"/> will be used to obtain the list. /// An explicit list can be supplied if you have already called <see cref="Renderer.GetSharedMaterials"/> previously, /// or if you want to use different materials.</param> /// <param name="subMeshIndex">The sub-mesh of the mesh to use for rendering. The corresponding material index /// from <see cref="sharedMaterials"/> will be used as the material for that sub-mesh.</param> public RenderMeshDescription( Renderer renderer, Mesh mesh, List <Material> sharedMaterials = null, int subMeshIndex = 0) { Debug.Assert(renderer != null, "Must have a non-null Renderer to create RenderMeshDescription."); Debug.Assert(mesh != null, "Must have a non-null Mesh to create RenderMeshDescription."); if (sharedMaterials is null) { sharedMaterials = new List <Material>(capacity: 10); } if (sharedMaterials.Count == 0) { renderer.GetSharedMaterials(sharedMaterials); } Debug.Assert(subMeshIndex >= 0 && subMeshIndex < sharedMaterials.Count, "Sub-mesh index out of bounds, no matching material."); var motionVectorGenerationMode = renderer.motionVectorGenerationMode; var needMotionVectorPass = (motionVectorGenerationMode == MotionVectorGenerationMode.Object) || (motionVectorGenerationMode == MotionVectorGenerationMode.ForceNoMotion); RenderMesh = new RenderMesh { mesh = mesh, material = sharedMaterials[subMeshIndex], subMesh = subMeshIndex, layer = renderer.gameObject.layer, castShadows = renderer.shadowCastingMode, receiveShadows = renderer.receiveShadows, needMotionVectorPass = needMotionVectorPass, }; RenderingLayerMask = renderer.renderingLayerMask; FlipWinding = false; MotionMode = motionVectorGenerationMode; var staticLightingMode = RenderMeshUtility.StaticLightingModeFromRenderer(renderer); var lightProbeUsage = renderer.lightProbeUsage; LightProbeUsage = (staticLightingMode == StaticLightingMode.LightProbes) ? lightProbeUsage : LightProbeUsage.Off; }
public static void Convert( Entity entity, EntityManager dstEntityManager, GameObjectConversionSystem conversionSystem, Renderer meshRenderer, Mesh mesh, List <Material> materials) { var materialCount = materials.Count; // Don't add RenderMesh (and other required components) unless both mesh and material assigned. if ((mesh != null) && (materialCount > 0)) { var renderMesh = new RenderMesh { mesh = mesh, castShadows = meshRenderer.shadowCastingMode, receiveShadows = meshRenderer.receiveShadows, layer = meshRenderer.gameObject.layer }; //@TODO: Transform system should handle RenderMeshFlippedWindingTag automatically. This should not be the responsibility of the conversion system. float4x4 localToWorld = meshRenderer.transform.localToWorldMatrix; var flipWinding = math.determinant(localToWorld) < 0.0; if (materialCount == 1 && AttachToPrimaryEntityForSingleMaterial) { renderMesh.material = materials[0]; renderMesh.subMesh = 0; dstEntityManager.AddSharedComponentData(entity, renderMesh); dstEntityManager.AddComponentData(entity, new PerInstanceCullingTag()); dstEntityManager.AddComponentData(entity, new RenderBounds { Value = mesh.bounds.ToAABB() }); if (flipWinding) { dstEntityManager.AddComponent(entity, ComponentType.ReadWrite <RenderMeshFlippedWindingTag>()); } conversionSystem.ConfigureEditorRenderData(entity, meshRenderer.gameObject, true); } else { for (var m = 0; m != materialCount; m++) { var meshEntity = conversionSystem.CreateAdditionalEntity(meshRenderer); renderMesh.material = materials[m]; renderMesh.subMesh = m; dstEntityManager.AddSharedComponentData(meshEntity, renderMesh); dstEntityManager.AddComponentData(meshEntity, new PerInstanceCullingTag()); dstEntityManager.AddComponentData(meshEntity, new RenderBounds { Value = mesh.bounds.ToAABB() }); dstEntityManager.AddComponentData(meshEntity, new LocalToWorld { Value = localToWorld }); if (!dstEntityManager.HasComponent <Static>(meshEntity)) { dstEntityManager.AddComponentData(meshEntity, new Parent { Value = entity }); dstEntityManager.AddComponentData(meshEntity, new LocalToParent { Value = float4x4.identity }); } if (flipWinding) { dstEntityManager.AddComponent(meshEntity, ComponentType.ReadWrite <RenderMeshFlippedWindingTag>()); } conversionSystem.ConfigureEditorRenderData(meshEntity, meshRenderer.gameObject, true); } } } }
protected override void OnUpdate() { var sceneBounds = MinMaxAABB.Empty; var materials = new List <Material>(10); Entities.ForEach((MeshRenderer meshRenderer, MeshFilter meshFilter) => { var entity = GetPrimaryEntity(meshRenderer); var mesh = meshFilter.sharedMesh; meshRenderer.GetSharedMaterials(materials); var materialCount = materials.Count; // Don't add RenderMesh (and other required components) unless both mesh and material assigned. if ((mesh != null) && (materialCount > 0)) { var dst = new RenderMesh(); dst.mesh = mesh; dst.castShadows = meshRenderer.shadowCastingMode; dst.receiveShadows = meshRenderer.receiveShadows; dst.layer = meshRenderer.gameObject.layer; //@TODO: Transform system should handle RenderMeshFlippedWindingTag automatically. This should not be the responsibility of the conversion system. float4x4 localToWorld = meshRenderer.transform.localToWorldMatrix; var flipWinding = math.determinant(localToWorld) < 0.0; if (materialCount == 1 && AttachToPrimaryEntityForSingleMaterial) { dst.material = materials[0]; dst.subMesh = 0; DstEntityManager.AddSharedComponentData(entity, dst); DstEntityManager.AddComponentData(entity, new PerInstanceCullingTag()); DstEntityManager.AddComponentData(entity, new RenderBounds { Value = mesh.bounds.ToAABB() }); if (flipWinding) { DstEntityManager.AddComponent(entity, ComponentType.ReadWrite <RenderMeshFlippedWindingTag>()); } ConfigureEditorRenderData(entity, meshRenderer.gameObject, true); } else { for (var m = 0; m != materialCount; m++) { var meshEntity = CreateAdditionalEntity(meshRenderer); dst.material = materials[m]; dst.subMesh = m; DstEntityManager.AddSharedComponentData(meshEntity, dst); DstEntityManager.AddComponentData(meshEntity, new PerInstanceCullingTag()); DstEntityManager.AddComponentData(meshEntity, new RenderBounds { Value = mesh.bounds.ToAABB() }); DstEntityManager.AddComponentData(meshEntity, new LocalToWorld { Value = localToWorld }); if (!DstEntityManager.HasComponent <Static>(meshEntity)) { DstEntityManager.AddComponentData(meshEntity, new Parent { Value = entity }); DstEntityManager.AddComponentData(meshEntity, new LocalToParent { Value = float4x4.identity }); } if (flipWinding) { DstEntityManager.AddComponent(meshEntity, ComponentType.ReadWrite <RenderMeshFlippedWindingTag>()); } ConfigureEditorRenderData(meshEntity, meshRenderer.gameObject, true); } } sceneBounds.Encapsulate(meshRenderer.bounds.ToAABB()); } }); }
private static void AddComponentsToEntity( RenderMesh renderMesh, Entity entity, EntityManager dstEntityManager, GameObjectConversionSystem conversionSystem, Renderer meshRenderer, Mesh mesh, List <Material> materials, bool flipWinding, int id) { renderMesh.material = materials[id]; renderMesh.subMesh = id; dstEntityManager.AddSharedComponentData(entity, renderMesh); dstEntityManager.AddComponentData(entity, new PerInstanceCullingTag()); dstEntityManager.AddComponentData(entity, new RenderBounds { Value = mesh.bounds.ToAABB() }); if (flipWinding) { dstEntityManager.AddComponent(entity, ComponentType.ReadWrite <RenderMeshFlippedWindingTag>()); } conversionSystem.ConfigureEditorRenderData(entity, meshRenderer.gameObject, true); #if ENABLE_HYBRID_RENDERER_V2 && UNITY_2020_1_OR_NEWER && (HDRP_9_0_0_OR_NEWER || URP_9_0_0_OR_NEWER) // Hybrid V2 uploads WorldToLocal from C# to rendering. Need to refresh it. // TODO: Do this on GPU side in the copy compute shader. Would be free in BW bound shader! dstEntityManager.AddComponent(entity, ComponentType.ReadWrite <WorldToLocal>()); #if HDRP_9_0_0_OR_NEWER // HDRP previous frame matrices (for motion vectors) if (renderMesh.needMotionVectorPass) { dstEntityManager.AddComponent(entity, ComponentType.ReadWrite <BuiltinMaterialPropertyUnity_MatrixPreviousM>()); dstEntityManager.AddComponent(entity, ComponentType.ReadWrite <BuiltinMaterialPropertyUnity_MatrixPreviousMI>()); } dstEntityManager.AddComponentData(entity, CreateMotionVectorsParams(ref renderMesh, ref meshRenderer)); #endif dstEntityManager.AddComponentData(entity, new BuiltinMaterialPropertyUnity_RenderingLayer { Value = new uint4(meshRenderer.renderingLayerMask, 0, 0, 0) }); dstEntityManager.AddComponentData(entity, new BuiltinMaterialPropertyUnity_WorldTransformParams { Value = flipWinding ? new float4(0, 0, 0, -1) : new float4(0, 0, 0, 1) }); #if URP_9_0_0_OR_NEWER // Default initialized light data for URP dstEntityManager.AddComponentData(entity, new BuiltinMaterialPropertyUnity_LightData { Value = new float4(0, 0, 1, 0) }); #endif #endif }
private static BuiltinMaterialPropertyUnity_MotionVectorsParams CreateMotionVectorsParams(ref RenderMesh mesh, ref Renderer meshRenderer) { float s_bias = -0.001f; float hasLastPositionStream = mesh.needMotionVectorPass ? 1.0f : 0.0f; var motionVectorGenerationMode = meshRenderer.motionVectorGenerationMode; float forceNoMotion = (motionVectorGenerationMode == MotionVectorGenerationMode.ForceNoMotion) ? 0.0f : 1.0f; float cameraVelocity = (motionVectorGenerationMode == MotionVectorGenerationMode.Camera) ? 0.0f : 1.0f; return(new BuiltinMaterialPropertyUnity_MotionVectorsParams { Value = new float4(hasLastPositionStream, forceNoMotion, s_bias, cameraVelocity) }); }
public static void Convert( Entity entity, EntityManager dstEntityManager, GameObjectConversionSystem conversionSystem, Renderer meshRenderer, Mesh mesh, List <Material> materials) { var materialCount = materials.Count; // Don't add RenderMesh (and other required components) unless both mesh and material assigned. if ((mesh != null) && (materialCount > 0)) { var renderMesh = new RenderMesh { mesh = mesh, castShadows = meshRenderer.shadowCastingMode, receiveShadows = meshRenderer.receiveShadows, layer = meshRenderer.gameObject.layer }; renderMesh.needMotionVectorPass = (meshRenderer.motionVectorGenerationMode == MotionVectorGenerationMode.Object) || (meshRenderer.motionVectorGenerationMode == MotionVectorGenerationMode.ForceNoMotion); //@TODO: Transform system should handle RenderMeshFlippedWindingTag automatically. This should not be the responsibility of the conversion system. float4x4 localToWorld = meshRenderer.transform.localToWorldMatrix; var flipWinding = math.determinant(localToWorld) < 0.0; if (materialCount == 1 && AttachToPrimaryEntityForSingleMaterial) { AddComponentsToEntity( renderMesh, entity, dstEntityManager, conversionSystem, meshRenderer, mesh, materials, flipWinding, 0); } else { for (var m = 0; m != materialCount; m++) { var meshEntity = conversionSystem.CreateAdditionalEntity(meshRenderer); dstEntityManager.AddComponentData(meshEntity, new LocalToWorld { Value = localToWorld }); if (!dstEntityManager.HasComponent <Static>(meshEntity)) { dstEntityManager.AddComponentData(meshEntity, new Parent { Value = entity }); dstEntityManager.AddComponentData(meshEntity, new LocalToParent { Value = float4x4.identity }); } AddComponentsToEntity( renderMesh, meshEntity, dstEntityManager, conversionSystem, meshRenderer, mesh, materials, flipWinding, m); } } } }
private static void AddComponentsToEntity( Entity entity, EntityManager dstEntityManager, GameObjectConversionSystem conversionSystem, Renderer meshRenderer, Mesh mesh, List <Material> materials, Dictionary <MaterialLookupKey, Material> createdMaterials, bool flipWinding, int id, LightMaps lightMaps, int lightmapIndex, AABB localBounds) { var needMotionVectorPass = (meshRenderer.motionVectorGenerationMode == MotionVectorGenerationMode.Object) || (meshRenderer.motionVectorGenerationMode == MotionVectorGenerationMode.ForceNoMotion); var renderMesh = new RenderMesh { mesh = mesh, castShadows = meshRenderer.shadowCastingMode, receiveShadows = meshRenderer.receiveShadows, layer = meshRenderer.gameObject.layer, subMesh = id, needMotionVectorPass = needMotionVectorPass }; var staticLightingMode = StaticLightingMode.None; if (meshRenderer.lightmapIndex >= 65534 || meshRenderer.lightmapIndex < 0) { staticLightingMode = StaticLightingMode.LightProbes; } else if (meshRenderer.lightmapIndex >= 0) { staticLightingMode = StaticLightingMode.Lightmapped; } dstEntityManager.AddComponentData(entity, new PerInstanceCullingTag()); dstEntityManager.AddComponentData(entity, new RenderBounds { Value = localBounds }); var material = materials[id]; if (staticLightingMode == StaticLightingMode.Lightmapped && lightMaps.isValid) { conversionSystem.DeclareAssetDependency(meshRenderer.gameObject, material); var localFlags = LightMappingFlags.Lightmapped; if (lightMaps.hasDirections) { localFlags |= LightMappingFlags.Directional; } if (lightMaps.hasShadowMask) { localFlags |= LightMappingFlags.ShadowMask; } var key = new MaterialLookupKey { BaseMaterial = materials[id], lightmaps = lightMaps, Flags = localFlags }; var lookUp = createdMaterials ?? new Dictionary <MaterialLookupKey, Material>(); if (lookUp.TryGetValue(key, out Material result)) { material = result; } else { material = new Material(materials[id]); material.name = $"{material.name}_Lightmapped_"; material.EnableKeyword("LIGHTMAP_ON"); material.SetTexture("unity_Lightmaps", lightMaps.colors); material.SetTexture("unity_LightmapsInd", lightMaps.directions); material.SetTexture("unity_ShadowMasks", lightMaps.shadowMasks); if (lightMaps.hasDirections) { material.name = material.name + "_DIRLIGHTMAP"; material.EnableKeyword("DIRLIGHTMAP_COMBINED"); } if (lightMaps.hasShadowMask) { material.name = material.name + "_SHADOW_MASK"; } lookUp[key] = material; } dstEntityManager.AddComponentData(entity, new BuiltinMaterialPropertyUnity_LightmapST() { Value = meshRenderer.lightmapScaleOffset }); dstEntityManager.AddComponentData(entity, new BuiltinMaterialPropertyUnity_LightmapIndex() { Value = lightmapIndex }); dstEntityManager.AddSharedComponentData(entity, lightMaps); } else if (staticLightingMode == StaticLightingMode.LightProbes) { if (meshRenderer.lightProbeUsage == LightProbeUsage.CustomProvided) { dstEntityManager.AddComponent <CustomProbeTag>(entity); } else if (meshRenderer.lightProbeUsage == LightProbeUsage.BlendProbes && LightmapSettings.lightProbes != null && LightmapSettings.lightProbes.count > 0) { dstEntityManager.AddComponent <BlendProbeTag>(entity); } else { dstEntityManager.AddComponent <AmbientProbeTag>(entity); } } renderMesh.material = material; dstEntityManager.AddSharedComponentData(entity, renderMesh); if (flipWinding) { dstEntityManager.AddComponent(entity, ComponentType.ReadWrite <RenderMeshFlippedWindingTag>()); } conversionSystem.ConfigureEditorRenderData(entity, meshRenderer.gameObject, true); #if ENABLE_HYBRID_RENDERER_V2 dstEntityManager.AddComponent(entity, ComponentType.ReadOnly <WorldToLocal_Tag>()); #if HDRP_9_0_0_OR_NEWER // HDRP previous frame matrices (for motion vectors) if (needMotionVectorPass) { dstEntityManager.AddComponent(entity, ComponentType.ReadWrite <BuiltinMaterialPropertyUnity_MatrixPreviousM>()); dstEntityManager.AddComponent(entity, ComponentType.ReadWrite <BuiltinMaterialPropertyUnity_MatrixPreviousMI_Tag>()); } dstEntityManager.AddComponentData(entity, CreateMotionVectorsParams(ref renderMesh, ref meshRenderer)); #endif dstEntityManager.AddComponentData(entity, new BuiltinMaterialPropertyUnity_RenderingLayer { Value = new uint4(meshRenderer.renderingLayerMask, 0, 0, 0) }); dstEntityManager.AddComponentData(entity, new BuiltinMaterialPropertyUnity_WorldTransformParams { Value = flipWinding ? new float4(0, 0, 0, -1) : new float4(0, 0, 0, 1) }); #if URP_9_0_0_OR_NEWER // Default initialized light data for URP dstEntityManager.AddComponentData(entity, new BuiltinMaterialPropertyUnity_LightData { Value = new float4(0, 0, 1, 0) }); #endif #endif }
private static void AddComponentsToEntity( Entity entity, EntityManager dstEntityManager, GameObjectConversionSystem conversionSystem, Renderer meshRenderer, Mesh mesh, Material material, bool flipWinding, int id, AABB localBounds) { var needMotionVectorPass = (meshRenderer.motionVectorGenerationMode == MotionVectorGenerationMode.Object) || (meshRenderer.motionVectorGenerationMode == MotionVectorGenerationMode.ForceNoMotion); var renderMesh = new RenderMesh { mesh = mesh, material = material, castShadows = meshRenderer.shadowCastingMode, receiveShadows = meshRenderer.receiveShadows, layer = meshRenderer.gameObject.layer, subMesh = id, needMotionVectorPass = needMotionVectorPass }; dstEntityManager.AddSharedComponentData(entity, renderMesh); dstEntityManager.AddComponentData(entity, new PerInstanceCullingTag()); dstEntityManager.AddComponentData(entity, new RenderBounds { Value = localBounds }); if (flipWinding) { dstEntityManager.AddComponent(entity, ComponentType.ReadWrite <RenderMeshFlippedWindingTag>()); } conversionSystem.ConfigureEditorRenderData(entity, meshRenderer.gameObject, true); #if ENABLE_HYBRID_RENDERER_V2 dstEntityManager.AddComponent(entity, ComponentType.ReadOnly <WorldToLocal_Tag>()); #if HDRP_9_0_0_OR_NEWER // HDRP previous frame matrices (for motion vectors) if (needMotionVectorPass) { dstEntityManager.AddComponent(entity, ComponentType.ReadWrite <BuiltinMaterialPropertyUnity_MatrixPreviousM>()); dstEntityManager.AddComponent(entity, ComponentType.ReadWrite <BuiltinMaterialPropertyUnity_MatrixPreviousMI_Tag>()); } dstEntityManager.AddComponentData(entity, CreateMotionVectorsParams(ref renderMesh, ref meshRenderer)); #endif dstEntityManager.AddComponentData(entity, new BuiltinMaterialPropertyUnity_RenderingLayer { Value = new uint4(meshRenderer.renderingLayerMask, 0, 0, 0) }); dstEntityManager.AddComponentData(entity, new BuiltinMaterialPropertyUnity_WorldTransformParams { Value = flipWinding ? new float4(0, 0, 0, -1) : new float4(0, 0, 0, 1) }); #if URP_9_0_0_OR_NEWER // Default initialized light data for URP dstEntityManager.AddComponentData(entity, new BuiltinMaterialPropertyUnity_LightData { Value = new float4(0, 0, 1, 0) }); if (meshRenderer.lightProbeUsage == LightProbeUsage.CustomProvided) { dstEntityManager.AddComponent <CustomProbeTag>(entity); } else { dstEntityManager.AddComponent <AmbientProbeTag>(entity); } #endif #endif }
protected override void OnUpdate() { var sceneBounds = MinMaxAABB.Empty; var materials = new List <Material>(10); Entities.ForEach((MeshRenderer meshRenderer, MeshFilter meshFilter) => { var entity = GetPrimaryEntity(meshRenderer); var dst = new RenderMesh(); dst.mesh = meshFilter.sharedMesh; dst.castShadows = meshRenderer.shadowCastingMode; dst.receiveShadows = meshRenderer.receiveShadows; dst.layer = meshRenderer.gameObject.layer; //@TODO: Transform system should handle RenderMeshFlippedWindingTag automatically. This should not be the responsibility of the conversion system. float4x4 localToWorld = meshRenderer.transform.localToWorldMatrix; var flipWinding = math.determinant(localToWorld) < 0.0; meshRenderer.GetSharedMaterials(materials); var materialCount = materials.Count; if (materialCount == 1 && AttachToPrimaryEntityForSingleMaterial) { dst.material = materials[0]; dst.subMesh = 0; DstEntityManager.AddSharedComponentData(entity, dst); DstEntityManager.AddComponentData(entity, new PerInstanceCullingTag()); if (flipWinding) { DstEntityManager.AddComponent(entity, ComponentType.ReadWrite <RenderMeshFlippedWindingTag>()); } } else { for (var m = 0; m != materialCount; m++) { var meshEntity = CreateAdditionalEntity(meshRenderer); dst.material = materials[m]; dst.subMesh = m; DstEntityManager.AddSharedComponentData(meshEntity, dst); DstEntityManager.AddComponentData(meshEntity, new PerInstanceCullingTag()); DstEntityManager.AddComponentData(meshEntity, new LocalToWorld { Value = localToWorld }); if (!DstEntityManager.HasComponent <Static>(meshEntity)) { DstEntityManager.AddComponentData(meshEntity, new Parent { Value = entity }); DstEntityManager.AddComponentData(meshEntity, new LocalToParent { Value = float4x4.identity }); } if (flipWinding) { DstEntityManager.AddComponent(meshEntity, ComponentType.ReadWrite <RenderMeshFlippedWindingTag>()); } } } sceneBounds.Encapsulate(meshRenderer.bounds.ToAABB()); }); using (var boundingVolume = DstEntityManager.CreateEntityQuery(typeof(SceneBoundingVolume))) { if (!boundingVolume.IsEmptyIgnoreFilter) { var bounds = boundingVolume.GetSingleton <SceneBoundingVolume>(); bounds.Value.Encapsulate(sceneBounds); boundingVolume.SetSingleton(bounds); } } }