private void PropagateDataReadyEventToComponents(SurfaceData sd, bool outputWritten, float elapsedBakeTimeSeconds, int inFlightIndex) { SpatialMappingBase.LODType lod = SpatialMappingBase.GetLODFromTPCM(sd.trianglesPerCubicMeter); SpatialMappingBase requester = GetSMComponentFromInFlightIndex(inFlightIndex); if (outputWritten) { // prop successes to anyone with a matching LOD; some screening will // be needed at the component level. foreach (SMComponentRecord comp in m_Components) { if (comp.m_Component.lodType == lod && comp.m_Component.bakePhysics == sd.bakeCollider) { comp.m_OnDataReady(requester, sd, outputWritten, elapsedBakeTimeSeconds); } } } else { // notify ONLY the requester of failure; no one else should care if (inFlightIndex != -1) { m_InFlightRequests[inFlightIndex].m_Requester.m_OnDataReady(requester, sd, outputWritten, elapsedBakeTimeSeconds); } else { Debug.LogError(System.String.Format("SpatialMappingContext unable to notify a component about a failure to cook surface {0}!", sd.id.handle)); } } }
public SpatialMappingBase.LODType NextLodVal(SpatialMappingBase.LODType oldlod, int incval) { var newlodp1 = oldlod; var newlodm1 = oldlod; switch (oldlod) { case SpatialMappingBase.LODType.High: { newlodm1 = SpatialMappingBase.LODType.Medium; break; } case SpatialMappingBase.LODType.Medium: { newlodp1 = SpatialMappingBase.LODType.High; newlodm1 = SpatialMappingBase.LODType.Low; break; } case SpatialMappingBase.LODType.Low: { newlodp1 = SpatialMappingBase.LODType.Medium; break; } } var newlod = (incval < 0 ? newlodm1 : newlodp1); return(newlod); }
public override void Update() { if (gRenderer != null) { gRenderer.enabled = MeshVisualization != GroundMeshVisualization.None; if (gRenderer.enabled) { if (MeshVisualization == GroundMeshVisualization.Debug) { gRenderer.renderState = SpatialMappingRenderer.RenderState.Visualization; } else { gRenderer.renderState = SpatialMappingRenderer.RenderState.Occlusion; } } if (gCollider != null) { if (Check(surfaceParent, gCollider.surfaceParent, gRenderer.surfaceParent, ref lastSurfaceParent)) { surfaceParent = gCollider.surfaceParent = gRenderer.surfaceParent = lastSurfaceParent; } if (Check(updateCountBeforeSpatialMappingCleanup, gCollider.numUpdatesBeforeRemoval, gRenderer.numUpdatesBeforeRemoval, ref lastUpdateCount)) { updateCountBeforeSpatialMappingCleanup = gCollider.numUpdatesBeforeRemoval = gRenderer.numUpdatesBeforeRemoval = lastUpdateCount; } if (Check(secondsBetweenSpatialMappingUpdates, gCollider.secondsBetweenUpdates, gRenderer.secondsBetweenUpdates, ref lastUpdateTime)) { secondsBetweenSpatialMappingUpdates = gCollider.secondsBetweenUpdates = gRenderer.secondsBetweenUpdates = lastUpdateTime; } if (Check(freezeUpdates, gCollider.freezeUpdates, gRenderer.freezeUpdates, ref lastFreezeUpdates)) { freezeUpdates = gCollider.freezeUpdates = gRenderer.freezeUpdates = lastFreezeUpdates; } if (Check(HalfBoxExtents, gCollider.halfBoxExtents, gRenderer.halfBoxExtents, ref lastHalfBox)) { HalfBoxExtents = gCollider.halfBoxExtents = gRenderer.halfBoxExtents = lastHalfBox; } if (Check(LODType, gCollider.lodType, gRenderer.lodType, ref lastLODType)) { LODType = gCollider.lodType = gRenderer.lodType = lastLODType; } if (Check(volumeType, gCollider.volumeType, gRenderer.volumeType, ref lastVolumeType)) { volumeType = gCollider.volumeType = gRenderer.volumeType = lastVolumeType; } } } base.Update(); }
protected override void Awake() { base.Awake(); #if !UNITY_EDITOR if (Windows.Graphics.Holographic.HolographicDisplay.GetDefault()?.IsOpaque == false) { transform.ClearChildren(); } #endif var gr = this.Ensure <SpatialMappingRenderer>(); gr.Value.occlusionMaterial = OcclusionMaterial; gr.Value.visualMaterial = VisualizationMaterial; var gc = this.Ensure <SpatialMappingCollider>(); gCollider = gc; gRenderer = gr; if (gc.IsNew) { gc.Value.enableCollisions = true; gc.Value.layer = GroundLayer; gc.Value.material = Roughness; if (gr.IsNew) { gc.Value.surfaceParent = surfaceParent; gc.Value.freezeUpdates = freezeUpdates; gc.Value.secondsBetweenUpdates = secondsBetweenSpatialMappingUpdates; gc.Value.numUpdatesBeforeRemoval = updateCountBeforeSpatialMappingCleanup; gc.Value.lodType = LODType; gc.Value.volumeType = volumeType; gc.Value.halfBoxExtents = HalfBoxExtents; } else { gc.Value.surfaceParent = gr.Value.surfaceParent; gc.Value.freezeUpdates = gr.Value.freezeUpdates; gc.Value.secondsBetweenUpdates = gr.Value.secondsBetweenUpdates; gc.Value.numUpdatesBeforeRemoval = gr.Value.numUpdatesBeforeRemoval; gc.Value.lodType = gr.Value.lodType; gc.Value.volumeType = gr.Value.volumeType; gc.Value.halfBoxExtents = gr.Value.halfBoxExtents; } } gr.Value.surfaceParent = gc.Value.surfaceParent; gr.Value.freezeUpdates = gc.Value.freezeUpdates; gr.Value.secondsBetweenUpdates = gc.Value.secondsBetweenUpdates; gr.Value.numUpdatesBeforeRemoval = gc.Value.numUpdatesBeforeRemoval; gr.Value.lodType = gc.Value.lodType; gr.Value.volumeType = gc.Value.volumeType; gr.Value.halfBoxExtents = gc.Value.halfBoxExtents; lastSurfaceParent = surfaceParent; lastUpdateCount = updateCountBeforeSpatialMappingCleanup; lastUpdateTime = secondsBetweenSpatialMappingUpdates; lastFreezeUpdates = freezeUpdates; lastHalfBox = HalfBoxExtents; lastLODType = LODType; lastVolumeType = volumeType; }