// TODO: move to ChiselGeneratedComponentManager public void OnRenderModel(Camera camera, DrawModeFlags helperStateFlags) { // When we toggle visibility on brushes in the editor hierarchy, we want to render a different mesh // but still have the same lightmap, and keep lightmap support. // We do this by setting forceRenderingOff to true on all MeshRenderers. // This makes them behave like before, except that they don't render. This means they are still // part of things such as lightmap generation. At the same time we use Graphics.DrawMesh to // render the sub-mesh with the exact same settings as the MeshRenderer. if (materialPropertyBlock == null) { materialPropertyBlock = new MaterialPropertyBlock(); } var layer = gameObject.layer; var matrix = transform.localToWorldMatrix; if (VisibilityState != VisibilityState.Mixed) { if ((helperStateFlags & ~DrawModeFlags.HideRenderables) != DrawModeFlags.None) { RenderChiselRenderObjects(generated.debugHelpers, materialPropertyBlock, matrix, layer, camera); } return; } if ((helperStateFlags & ~DrawModeFlags.HideRenderables) != DrawModeFlags.None) { RenderChiselRenderPartialObjects(generated.debugHelpers, materialPropertyBlock, matrix, layer, camera); } if ((helperStateFlags & DrawModeFlags.HideRenderables) == DrawModeFlags.None) { RenderChiselRenderPartialObjects(generated.renderables, materialPropertyBlock, matrix, layer, camera); } }
public static void OnRenderModels(Camera camera, DrawModeFlags helperStateFlags) { foreach (var model in models) { model.OnRenderModel(camera, helperStateFlags); } }
public static void OnRenderModels(Camera camera, DrawModeFlags helperStateFlags) { foreach (var model in models) { if (model == null) { continue; } model.OnRenderModel(camera, helperStateFlags); } }
public static DrawModeFlags UpdateHelperSurfaceState(DrawModeFlags helperStateFlags, bool ignoreBrushVisibility = true) { foreach (var model in models) { if (!model || !model.isActiveAndEnabled || model.generated == null) { continue; } model.generated.UpdateHelperSurfaceState(helperStateFlags, ignoreBrushVisibility); } return(helperStateFlags); }
public void UpdateHelperSurfaceState(DrawModeFlags helperStateFlags, bool ignoreBrushVisibility = false) { if (!ignoreBrushVisibility) { ChiselGeneratedComponentManager.UpdateVisibility(); } var shouldHideMesh = !ignoreBrushVisibility && visibilityState != VisibilityState.AllVisible && visibilityState != VisibilityState.Unknown; var showRenderables = (helperStateFlags & DrawModeFlags.HideRenderables) == DrawModeFlags.None; for (int i = 0; i < renderables.Length; i++) { var renderable = renderables[i]; if (renderable == null || renderable.invalid) { continue; } if (renderable.meshRenderer != null) { renderable.meshRenderer.forceRenderingOff = shouldHideMesh || !showRenderables; } } for (int i = 0; i < debugHelpers.Length; i++) { var showState = (helperStateFlags & kGeneratedDebugShowFlags[i]) != DrawModeFlags.None; debugHelpers[i].visible = !shouldHideMesh && showState; } if (ignoreBrushVisibility || !needVisibilityMeshUpdate) { return; } if (visibilityState == VisibilityState.Mixed) { for (int i = 0; i < renderables.Length; i++) { var renderable = renderables[i]; if (renderable == null || renderable.invalid) { continue; } renderable.UpdateVisibilityMesh(showRenderables); } for (int i = 0; i < debugHelpers.Length; i++) { var show = (helperStateFlags & kGeneratedDebugShowFlags[i]) != DrawModeFlags.None; var debugHelper = debugHelpers[i]; if (debugHelper == null) { continue; } debugHelper.UpdateVisibilityMesh(show); } } needVisibilityMeshUpdate = false; }
public static void SetCameraDrawMode(Camera camera, DrawModeFlags drawModeFlags) { s_CameraDrawMode[camera] = drawModeFlags; }