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 #7109

Merged
merged 29 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
ad66bc7
Add overrideClipStyle BranchUniform to fix map tile bug
andremig-bentley Aug 26, 2024
acde094
Merge branch 'master' into andremig/clipstyle-bug
andremig-bentley Aug 26, 2024
270d635
rush change
andremig-bentley Aug 26, 2024
a20792e
Update core/frontend/src/render/webgl/BranchUniforms.ts
andremig-bentley Aug 26, 2024
c304bc9
cleanup
andremig-bentley Aug 26, 2024
6eac2f3
Merge branch 'master' into andremig/clipstyle-bug
andremig-bentley Sep 3, 2024
b0b1c6f
Change name to disable, add disable to MapTiles, add unit test
andremig-bentley Sep 3, 2024
ce86e67
Merge branch 'master' into andremig/clipstyle-bug
andremig-bentley Sep 3, 2024
bf81771
extract-api cleanup
andremig-bentley Sep 3, 2024
3994c45
rush lint
andremig-bentley Sep 3, 2024
f71ba30
cleanup
andremig-bentley Sep 4, 2024
33aeaee
Merge branch 'master' into andremig/clipstyle-bug
andremig-bentley Sep 5, 2024
aa926c5
Merge branch 'master' into andremig/clipstyle-bug
andremig-bentley Sep 25, 2024
87dfebf
Merge branch 'master' into andremig/clipstyle-bug
andremig-bentley Sep 25, 2024
a35549e
Merge branch 'andremig/clipstyle-bug' of /~https://github.com/iTwin/itw…
andremig-bentley Sep 25, 2024
d74beed
adding disableClipStyle inheritance from the top of the stack
andremig-bentley Sep 25, 2024
7cad058
Merge branch 'master' into andremig/clipstyle-bug
andremig-bentley Oct 2, 2024
cdce204
Merge branch 'master' into andremig/clipstyle-bug
andremig-bentley Oct 4, 2024
157a0e0
Merge branch 'master' into andremig/clipstyle-bug
pmconne Oct 7, 2024
cc4f8ab
Merge branch 'master' into andremig/clipstyle-bug
pmconne Oct 7, 2024
2ede4fc
disableClipStyle reset on pop, full inheritance from top of stack, ad…
andremig-bentley Oct 9, 2024
b1994b6
setClipStyle based on newly created branchState
andremig-bentley Oct 9, 2024
6c095d5
Merge branch 'master' into andremig/clipstyle-bug
andremig-bentley Oct 9, 2024
509c670
bug fix, test additions
andremig-bentley Oct 9, 2024
86c765c
Merge branch 'master' into andremig/clipstyle-bug
pmconne Oct 9, 2024
da0c702
Merge branch 'master' into andremig/clipstyle-bug
andremig-bentley Oct 9, 2024
3db9a8f
doc fix
andremig-bentley Oct 9, 2024
aa0aba6
Update core/frontend/src/test/render/webgl/BranchUniforms.test.ts
andremig-bentley Oct 9, 2024
cbfa8ab
Merge branch 'master' into andremig/clipstyle-bug
andremig-bentley Oct 9, 2024
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 @@ -4562,6 +4562,7 @@ export interface GraphicBranchOptions {
// @internal (undocumented)
classifierOrDrape?: RenderPlanarClassifier | RenderTextureDrape;
clipVolume?: RenderClipVolume;
disableClipStyle?: true;
// @internal (undocumented)
frustum?: GraphicBranchFrustum;
hline?: HiddenLine.Settings;
Expand Down Expand Up @@ -9069,6 +9070,8 @@ export interface RealityMeshGraphicParams {
// (undocumented)
readonly baseTransparent: boolean;
// (undocumented)
readonly disableClipStyle?: true;
// (undocumented)
readonly featureTable: PackedFeatureTable;
// (undocumented)
readonly layerClassifiers?: MapLayerClassifiers;
Expand Down Expand Up @@ -10022,7 +10025,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;
// @internal (undocumented)
createGeometryFromMesh(mesh: Mesh, viOrigin: Point3d | undefined): RenderGeometry | undefined;
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 @@ -160,6 +160,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 @@ -610,8 +610,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 @@ -46,6 +46,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 Down Expand Up @@ -73,6 +77,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 @@ -108,6 +113,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 @@ -315,6 +315,7 @@ export class Branch extends Graphic {
public readonly appearanceProvider?: FeatureAppearanceProvider;
public readonly secondaryClassifiers?: PlanarClassifier[];
public readonly viewAttachmentId?: Id64String;
public disableClipStyle?: true;
public readonly transformFromExternalIModel?: Transform;

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

if (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 @@ -384,7 +384,7 @@ export class RealityMeshGeometry extends IndexedGeometry implements RenderGeomet
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