Speed up mesh isolation.
This commit is contained in:
parent
52b94e5aa4
commit
de8670794c
@ -116,7 +116,7 @@ OV.Navigator = class
|
||||
},
|
||||
onViewTypeChanged : () => {
|
||||
this.SetSelection (null);
|
||||
this.ShowAllMeshes ();
|
||||
this.ShowAllMeshes (true);
|
||||
}
|
||||
});
|
||||
|
||||
@ -170,9 +170,9 @@ OV.Navigator = class
|
||||
return this.meshesPanel.HasHiddenMesh ();
|
||||
}
|
||||
|
||||
ShowAllMeshes ()
|
||||
ShowAllMeshes (show)
|
||||
{
|
||||
this.meshesPanel.ShowAllMeshes ();
|
||||
this.meshesPanel.ShowAllMeshes (show);
|
||||
this.callbacks.updateMeshesVisibility ();
|
||||
}
|
||||
|
||||
|
||||
@ -1,3 +1,11 @@
|
||||
OV.NavigatorItemRecurse =
|
||||
{
|
||||
No : 0,
|
||||
Parents : 1,
|
||||
Children : 2,
|
||||
All : 3
|
||||
};
|
||||
|
||||
OV.MaterialItem = class extends OV.TreeViewSingleItem
|
||||
{
|
||||
constructor (name, materialIndex, callbacks)
|
||||
@ -45,7 +53,7 @@ OV.MeshItem = class extends OV.TreeViewButtonItem
|
||||
return this.visible;
|
||||
}
|
||||
|
||||
SetVisible (visible)
|
||||
SetVisible (visible, recurse)
|
||||
{
|
||||
this.visible = visible;
|
||||
if (this.visible) {
|
||||
@ -53,8 +61,10 @@ OV.MeshItem = class extends OV.TreeViewButtonItem
|
||||
} else {
|
||||
this.showHideButton.SetImage ('hidden');
|
||||
}
|
||||
if (this.parent instanceof OV.NodeItem) {
|
||||
this.parent.UpdateVisibleStatus ();
|
||||
if (recurse === OV.NavigatorItemRecurse.Parents) {
|
||||
if (this.parent instanceof OV.NodeItem) {
|
||||
this.parent.SetVisible (this.parent.CalculateIsVisible (), OV.NavigatorItemRecurse.Parents);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -66,6 +76,7 @@ OV.NodeItem = class extends OV.TreeViewGroupButtonItem
|
||||
super (name, null);
|
||||
this.nodeId = nodeId;
|
||||
this.callbacks = callbacks;
|
||||
this.visible = true;
|
||||
|
||||
this.fitToWindowButton = new OV.TreeViewButton ('fit');
|
||||
this.fitToWindowButton.OnClick (() => {
|
||||
@ -86,6 +97,11 @@ OV.NodeItem = class extends OV.TreeViewGroupButtonItem
|
||||
}
|
||||
|
||||
IsVisible ()
|
||||
{
|
||||
return this.visible;
|
||||
}
|
||||
|
||||
CalculateIsVisible ()
|
||||
{
|
||||
let isVisible = false;
|
||||
this.EnumerateMeshItems ((meshItem) => {
|
||||
@ -96,12 +112,27 @@ OV.NodeItem = class extends OV.TreeViewGroupButtonItem
|
||||
return isVisible;
|
||||
}
|
||||
|
||||
SetVisible (visible)
|
||||
SetVisible (visible, recurse)
|
||||
{
|
||||
this.UpdateVisibleIcon (visible);
|
||||
for (let child of this.children) {
|
||||
if (child instanceof OV.NodeItem || child instanceof OV.MeshItem) {
|
||||
child.SetVisible (visible);
|
||||
this.visible = visible;
|
||||
if (this.visible) {
|
||||
this.showHideButton.SetImage ('visible');
|
||||
} else {
|
||||
this.showHideButton.SetImage ('hidden');
|
||||
}
|
||||
if (OV.IsDefined (this.callbacks.onVisibilityChanged)) {
|
||||
this.callbacks.onVisibilityChanged (this.visible);
|
||||
}
|
||||
if (recurse === OV.NavigatorItemRecurse.Children || recurse === OV.NavigatorItemRecurse.All) {
|
||||
for (let child of this.children) {
|
||||
if (child instanceof OV.NodeItem || child instanceof OV.MeshItem) {
|
||||
child.SetVisible (this.visible, OV.NavigatorItemRecurse.Children);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (recurse === OV.NavigatorItemRecurse.Parents || recurse === OV.NavigatorItemRecurse.All) {
|
||||
if (this.parent instanceof OV.NodeItem) {
|
||||
this.parent.SetVisible (this.parent.CalculateIsVisible (), OV.NavigatorItemRecurse.Parents);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -116,25 +147,4 @@ OV.NodeItem = class extends OV.TreeViewGroupButtonItem
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
UpdateVisibleStatus ()
|
||||
{
|
||||
let visible = this.IsVisible ();
|
||||
this.UpdateVisibleIcon (visible);
|
||||
if (this.parent instanceof OV.NodeItem) {
|
||||
this.parent.UpdateVisibleStatus ();
|
||||
}
|
||||
}
|
||||
|
||||
UpdateVisibleIcon (visible)
|
||||
{
|
||||
if (visible) {
|
||||
this.showHideButton.SetImage ('visible');
|
||||
} else {
|
||||
this.showHideButton.SetImage ('hidden');
|
||||
}
|
||||
if (OV.IsDefined (this.callbacks.onVisibilityChanged)) {
|
||||
this.callbacks.onVisibilityChanged (visible);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -631,6 +631,15 @@ OV.NavigatorMeshesPanel = class extends OV.NavigatorPanel
|
||||
return this.meshInstanceIdToItem.get (meshInstanceId.GetKey ());
|
||||
}
|
||||
|
||||
EnumerateNodeItems (processor)
|
||||
{
|
||||
for (const nodeItem of this.nodeIdToItem.values ()) {
|
||||
if (!processor (nodeItem)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
EnumerateMeshItems (processor)
|
||||
{
|
||||
for (const meshItem of this.meshInstanceIdToItem.values ()) {
|
||||
@ -659,10 +668,14 @@ OV.NavigatorMeshesPanel = class extends OV.NavigatorPanel
|
||||
return hasHiddenMesh;
|
||||
}
|
||||
|
||||
ShowAllMeshes ()
|
||||
ShowAllMeshes (show)
|
||||
{
|
||||
this.EnumerateNodeItems ((nodeItem) => {
|
||||
nodeItem.SetVisible (show, OV.NavigatorItemRecurse.No);
|
||||
return true;
|
||||
});
|
||||
this.EnumerateMeshItems ((meshItem) => {
|
||||
meshItem.SetVisible (true);
|
||||
meshItem.SetVisible (show, OV.NavigatorItemRecurse.No);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
@ -670,13 +683,13 @@ OV.NavigatorMeshesPanel = class extends OV.NavigatorPanel
|
||||
ToggleNodeVisibility (nodeId)
|
||||
{
|
||||
let nodeItem = this.GetNodeItem (nodeId);
|
||||
nodeItem.SetVisible (!nodeItem.IsVisible ());
|
||||
nodeItem.SetVisible (!nodeItem.IsVisible (), OV.NavigatorItemRecurse.All);
|
||||
}
|
||||
|
||||
ToggleMeshVisibility (meshInstanceId)
|
||||
{
|
||||
let meshItem = this.GetMeshItem (meshInstanceId);
|
||||
meshItem.SetVisible (!meshItem.IsVisible ());
|
||||
meshItem.SetVisible (!meshItem.IsVisible (), OV.NavigatorItemRecurse.Parents);
|
||||
}
|
||||
|
||||
IsMeshIsolated (meshInstanceId)
|
||||
@ -694,16 +707,7 @@ OV.NavigatorMeshesPanel = class extends OV.NavigatorPanel
|
||||
|
||||
IsolateMesh (meshInstanceId)
|
||||
{
|
||||
// TODO: slow because of recursion
|
||||
|
||||
let isIsolated = this.IsMeshIsolated (meshInstanceId);
|
||||
this.EnumerateMeshItems ((meshItem) => {
|
||||
if (meshItem.GetMeshInstanceId ().IsEqual (meshInstanceId) || isIsolated) {
|
||||
meshItem.SetVisible (true);
|
||||
} else {
|
||||
meshItem.SetVisible (false);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
this.ShowAllMeshes (false);
|
||||
this.ToggleMeshVisibility (meshInstanceId)
|
||||
}
|
||||
};
|
||||
|
||||
@ -161,7 +161,7 @@ OV.Website = class
|
||||
name : 'Show all meshes',
|
||||
icon : 'visible',
|
||||
onClick : () => {
|
||||
this.navigator.ShowAllMeshes ();
|
||||
this.navigator.ShowAllMeshes (true);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -186,7 +186,11 @@ OV.Website = class
|
||||
name : isMeshIsolated ? 'Remove isolation' : 'Isolate mesh',
|
||||
icon : isMeshIsolated ? 'deisolate' : 'isolate',
|
||||
onClick : () => {
|
||||
this.navigator.IsolateMesh (meshUserData.originalMeshId);
|
||||
if (isMeshIsolated) {
|
||||
this.navigator.ShowAllMeshes (true);
|
||||
} else {
|
||||
this.navigator.IsolateMesh (meshUserData.originalMeshId);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user