Skip to content

Commit

Permalink
fix shader compilation error and invisible color layers in certain ci…
Browse files Browse the repository at this point in the history
…rcumstances (#4556)

* fix shader compilation error and invisible color layers in certain circumstances
* update changelog
* Apply suggestions from code review

Co-Authored-By: Daniel <[email protected]>
* Merge branch 'master' into fix-invisible-layers
  • Loading branch information
philippotto authored Apr 21, 2020
1 parent b230f23 commit ccfd33b
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 20 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.md).
- The datastore checks if a organization folder can be created before creating a new organization. [#4501](https://github.com/scalableminds/webknossos/pull/4501)
- Fixed a bug where under certain circumstances groups in the tree tab were not sorted by name. [#4542](https://github.com/scalableminds/webknossos/pull/4542)
- Fixed that `segmentationOpacity` could not be set anymore as part of the recommended settings for a task type. [#4545](https://github.com/scalableminds/webknossos/pull/4545)
- Fixed a rendering error which could make some layers disappear in certain circumstances. [#4556](https://github.com/scalableminds/webknossos/pull/4556)

### Removed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,14 @@ class PlaneMaterialFactory {
attributes: Object;
shaderId: number;
storePropertyUnsubscribers: Array<() => void> = [];
leastRecentlyVisibleLayers: Array<string>;
leastRecentlyVisibleColorLayers: Array<string>;
oldShaderCode: ?string;

constructor(planeID: OrthoView, isOrthogonal: boolean, shaderId: number) {
this.planeID = planeID;
this.isOrthogonal = isOrthogonal;
this.shaderId = shaderId;
this.leastRecentlyVisibleLayers = [];
this.leastRecentlyVisibleColorLayers = [];
}

setup() {
Expand Down Expand Up @@ -414,19 +414,20 @@ class PlaneMaterialFactory {
const settings = layerSettings[dataLayer.name];
if (settings != null) {
const isLayerEnabled = !settings.isDisabled;
const isSegmentationLayer = segmentationLayerName === dataLayer.name;
if (
!isSegmentationLayer &&
oldVisibilityPerLayer[dataLayer.name] != null &&
oldVisibilityPerLayer[dataLayer.name] !== isLayerEnabled
) {
if (settings.isDisabled) {
this.onDisableLayer(dataLayer.name);
this.onDisableColorLayer(dataLayer.name);
} else {
this.onEnableLayer(dataLayer.name);
this.onEnableColorLayer(dataLayer.name);
}
}
oldVisibilityPerLayer[dataLayer.name] = isLayerEnabled;
const name = sanitizeName(dataLayer.name);
const isSegmentationLayer = segmentationLayerName === dataLayer.name;
this.updateUniformsForLayer(settings, name, elementClass, isSegmentationLayer);
}
}
Expand Down Expand Up @@ -605,32 +606,39 @@ class PlaneMaterialFactory {
onlyColorLayers: true,
}).map(layer => layer.name);

// In case, this.leastRecentlyVisibleLayers does not contain all disabled layers
// In case, this.leastRecentlyVisibleColorLayers does not contain all disabled layers
// because they were already disabled on page load), append the disabled layers
// which are not already in that array.
// Note that the order of this array is important (earlier elements are more "recently used")
// which is why it is important how this operation is done.
this.leastRecentlyVisibleLayers = [
...this.leastRecentlyVisibleLayers,
..._.without(disabledLayerNames, ...this.leastRecentlyVisibleLayers),
this.leastRecentlyVisibleColorLayers = [
...this.leastRecentlyVisibleColorLayers,
..._.without(disabledLayerNames, ...this.leastRecentlyVisibleColorLayers),
];

return enabledLayerNames
.concat(this.leastRecentlyVisibleLayers)
const names = enabledLayerNames
.concat(this.leastRecentlyVisibleColorLayers)
.slice(0, maximumLayerCountToRender)
.sort()
.map(sanitizeName);
.sort();

return names.map(sanitizeName);
}

onDisableLayer = layerName => {
this.leastRecentlyVisibleLayers = _.without(this.leastRecentlyVisibleLayers, layerName);
this.leastRecentlyVisibleLayers = [layerName, ...this.leastRecentlyVisibleLayers];
onDisableColorLayer = layerName => {
this.leastRecentlyVisibleColorLayers = _.without(
this.leastRecentlyVisibleColorLayers,
layerName,
);
this.leastRecentlyVisibleColorLayers = [layerName, ...this.leastRecentlyVisibleColorLayers];

this.recomputeFragmentShader();
};

onEnableLayer = layerName => {
this.leastRecentlyVisibleLayers = _.without(this.leastRecentlyVisibleLayers, layerName);
onEnableColorLayer = layerName => {
this.leastRecentlyVisibleColorLayers = _.without(
this.leastRecentlyVisibleColorLayers,
layerName,
);
this.recomputeFragmentShader();
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ export function getEnabledLayers(
if (settings == null) {
return false;
}
return settings.isDisabled === options.invert;
return settings.isDisabled === Boolean(options.invert);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ class DatasetSettings extends React.PureComponent<DatasetSettingsProps> {
<span style={{ fontWeight: 700 }}>
{!isColorLayer && isVolumeTracing ? "Volume Layer" : layerName}
</span>
<Tag style={{ cursor: "default", marginLeft: 8 }}>{elementClass} Layer</Tag>
<Tag style={{ cursor: "default", marginLeft: 8 }}>{elementClass}</Tag>
{this.getFindDataButton(layerName, isDisabled, isColorLayer)}
{this.getReloadDataButton(layerName)}
</Col>
Expand Down

0 comments on commit ccfd33b

Please sign in to comment.