Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add disableClipStyle to BranchState (backport #7109) [release/4.9.x] #7254

Merged
merged 2 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion common/api/core-frontend.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -4529,6 +4529,7 @@ export interface GraphicBranchOptions {
// @internal (undocumented)
classifierOrDrape?: RenderPlanarClassifier | RenderTextureDrape;
clipVolume?: RenderClipVolume;
disableClipStyle?: true;
// @internal (undocumented)
frustum?: GraphicBranchFrustum;
hline?: HiddenLine.Settings;
Expand Down Expand Up @@ -8925,6 +8926,8 @@ export interface RealityMeshGraphicParams {
// (undocumented)
readonly baseTransparent: boolean;
// (undocumented)
readonly disableClipStyle?: true;
// (undocumented)
readonly featureTable: PackedFeatureTable;
// (undocumented)
readonly layerClassifiers?: MapLayerClassifiers;
Expand Down Expand Up @@ -9842,7 +9845,7 @@ export abstract class RenderSystem implements IDisposable {
// @internal (undocumented)
createBackgroundMapDrape(_drapedTree: TileTreeReference, _mapTree: MapTileTreeReference): RenderTextureDrape | undefined;
abstract createBatch(graphic: RenderGraphic, features: RenderFeatureTable, range: ElementAlignedBox3d, options?: BatchOptions): RenderGraphic;
createBranch(branch: GraphicBranch, transform: Transform): RenderGraphic;
createBranch(branch: GraphicBranch, transform: Transform, options?: GraphicBranchOptions): RenderGraphic;
createClipVolume(_clipVector: ClipVector): RenderClipVolume | undefined;
abstract createGraphic(options: CustomGraphicBuilderOptions | ViewportGraphicBuilderOptions): GraphicBuilder;
abstract createGraphicBranch(branch: GraphicBranch, transform: Transform, options?: GraphicBranchOptions): RenderGraphic;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@itwin/core-frontend",
"comment": "",
"type": "none"
}
],
"packageName": "@itwin/core-frontend"
}
4 changes: 4 additions & 0 deletions core/frontend/src/render/GraphicBranch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ export interface GraphicBranchOptions {
* @internal
*/
viewAttachmentId?: Id64String;
/** If true, the view's [DisplayStyleSettings.clipStyle]($common) will be disabled for this branch.
* No [ClipStyle.insideColor]($common), [ClipStyle.outsideColor]($common), or [ClipStyle.intersectionStyle]($common) will be applied.
*/
disableClipStyle?: true;
}

/** Clip/Transform for a branch that are varied over time.
Expand Down
1 change: 1 addition & 0 deletions core/frontend/src/render/RealityMeshGraphicParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ export interface RealityMeshGraphicParams {
readonly baseTransparent: boolean;
readonly textures?: TerrainTexture[];
readonly layerClassifiers?: MapLayerClassifiers;
readonly disableClipStyle?: true;
}
4 changes: 2 additions & 2 deletions core/frontend/src/render/RenderSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -537,8 +537,8 @@ export abstract class RenderSystem implements IDisposable {
public abstract createGraphicList(primitives: RenderGraphic[]): RenderGraphic;

/** Create a RenderGraphic consisting of a list of Graphics, with optional transform and symbology overrides applied to the list */
public createBranch(branch: GraphicBranch, transform: Transform): RenderGraphic {
return this.createGraphicBranch(branch, transform);
public createBranch(branch: GraphicBranch, transform: Transform, options?: GraphicBranchOptions): RenderGraphic {
return this.createGraphicBranch(branch, transform, options);
}

/** Create a graphic from a [[GraphicBranch]]. */
Expand Down
6 changes: 6 additions & 0 deletions core/frontend/src/render/webgl/BranchState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ export interface BranchStateOptions {
forceViewCoords?: boolean;
readonly viewAttachmentId?: Id64String;
groupNodeId?: number;
/** If true, the view's [DisplayStyleSettings.clipStyle]($common) will be disabled for this branch.
* No [ClipStyle.insideColor]($common), [ClipStyle.outsideColor]($common), or [ClipStyle.intersectionStyle]($common) will be applied.
*/
disableClipStyle?: true;
}

/**
Expand All @@ -71,6 +75,7 @@ export class BranchState {
public get realityModelDisplaySettings() { return this._opts.realityModelDisplaySettings; }
public get viewAttachmentId() { return this._opts.viewAttachmentId; }
public get groupNodeId() { return this._opts.groupNodeId; }
public get disableClipStyle() { return this._opts.disableClipStyle;}

public get symbologyOverrides() {
return this._opts.symbologyOverrides;
Expand Down Expand Up @@ -105,6 +110,7 @@ export class BranchState {
realityModelDisplaySettings: branch.branch.realityModelDisplaySettings ?? prev.realityModelDisplaySettings,
viewAttachmentId: branch.viewAttachmentId ?? prev.viewAttachmentId,
groupNodeId: branch.branch.groupNodeId ?? prev.groupNodeId,
disableClipStyle: branch.disableClipStyle ?? prev.disableClipStyle,
});
}

Expand Down
16 changes: 16 additions & 0 deletions core/frontend/src/render/webgl/BranchUniforms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { RenderCommands } from "./RenderCommands";
import { desync, sync, SyncToken } from "./Sync";
import { Target } from "./Target";
import { ClipStack } from "./ClipStack";
import { IModelApp } from "../../IModelApp";

function equalXYZs(a: XYZ | undefined, b: XYZ | undefined): boolean {
if (a === b)
Expand Down Expand Up @@ -103,6 +104,9 @@ export class BranchUniforms {
public pushBranch(branch: Branch): void {
desync(this);
this._stack.pushBranch(branch);

this.setClipStyle(this.top.disableClipStyle);

if (this.top.clipVolume)
this.clipStack.push(this.top.clipVolume);

Expand All @@ -126,6 +130,7 @@ export class BranchUniforms {
this.clipStack.pop();

this._stack.pop();
this.setClipStyle(this.top.disableClipStyle);
}

public pushViewClip(): void {
Expand Down Expand Up @@ -251,4 +256,15 @@ export class BranchUniforms {

return true;
}

// set the clip style based on disableClipStyle
private setClipStyle(disableClipStyle: true | undefined) {
const vp = IModelApp.viewManager.selectedView;
if (vp) {
const style = vp.view.displayStyle.settings.clipStyle;
this.clipStack.insideColor.alpha = disableClipStyle ? 0 : (style.insideColor ? 1 : 0);
this.clipStack.outsideColor.alpha = disableClipStyle ? 0 : (style.outsideColor ? 1 : 0);
this.clipStack.intersectionStyle.alpha = disableClipStyle ? 0 : (style.intersectionStyle ? style.intersectionStyle.width : 0);
}
}
}
2 changes: 2 additions & 0 deletions core/frontend/src/render/webgl/Graphic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ export class Branch extends Graphic {
public readonly appearanceProvider?: FeatureAppearanceProvider;
public readonly secondaryClassifiers?: PlanarClassifier[];
public readonly viewAttachmentId?: Id64String;
public disableClipStyle?: true;

public constructor(branch: GraphicBranch, localToWorld: Transform, viewFlags?: ViewFlags, opts?: GraphicBranchOptions) {
super();
Expand All @@ -328,6 +329,7 @@ export class Branch extends Graphic {
this.iModel = opts.iModel;
this.frustum = opts.frustum;
this.viewAttachmentId = opts.viewAttachmentId;
this.disableClipStyle = opts.disableClipStyle;

if (opts.hline)
this.edgeSettings = EdgeSettings.create(opts.hline);
Expand Down
2 changes: 1 addition & 1 deletion core/frontend/src/render/webgl/RealityMesh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ export class RealityMeshGeometry extends IndexedGeometry implements IDisposable,
branch.add(system.createBatch(primitive!, featureTable, mesh.getRange(), { tileId }));
}

return system.createBranch(branch, realityMesh._transform ? realityMesh._transform : Transform.createIdentity());
return system.createBranch(branch, realityMesh._transform ? realityMesh._transform : Transform.createIdentity(), {disableClipStyle: params.disableClipStyle});
}

public collectStatistics(stats: RenderMemory.Statistics): void {
Expand Down
Loading
Loading