Skip to content

Commit e22d1e1

Browse files
committed
refactor: Simplify getNeedToRebuildShaders in VolumeMapper
Instead of comparing a big state that take all actor properties into account, compare the mtime of the actor as it takes properties into account
1 parent 1e9aef8 commit e22d1e1

File tree

1 file changed

+5
-16
lines changed
  • Sources/Rendering/OpenGL/VolumeMapper

1 file changed

+5
-16
lines changed

Sources/Rendering/OpenGL/VolumeMapper/index.js

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -568,17 +568,9 @@ function vtkOpenGLVolumeMapper(publicAPI, model) {
568568
};
569569

570570
publicAPI.getNeedToRebuildShaders = (cellBO, ren, actor) => {
571-
const actorProps = actor.getProperty();
572-
573571
recomputeLightComplexity(actor, ren.getLights());
574572

575573
const numComp = model.scalarTexture.getComponents();
576-
const opacityModes = [];
577-
const forceNearestInterps = [];
578-
for (let nc = 0; nc < numComp; nc++) {
579-
opacityModes.push(actorProps.getOpacityMode(nc));
580-
forceNearestInterps.push(actorProps.getForceNearestInterpolation(nc));
581-
}
582574

583575
const ext = model.currentInput.getSpatialExtent();
584576
const spc = model.currentInput.getSpacing();
@@ -596,17 +588,15 @@ function vtkOpenGLVolumeMapper(publicAPI, model) {
596588
const hasZBufferTexture = !!model.zBufferTexture;
597589

598590
const state = {
599-
iComps: actorProps.getIndependentComponents(),
600-
colorMixPreset: actorProps.getColorMixPreset(),
601-
interpolationType: actorProps.getInterpolationType(),
602-
useLabelOutline: publicAPI.isLabelmapOutlineRequired(actor),
603591
numComp,
604592
maxSamples,
605-
useGradientOpacity: actorProps.getUseGradientOpacity(0),
606593
blendMode: model.renderable.getBlendMode(),
607594
hasZBufferTexture,
608-
opacityModes,
609-
forceNearestInterps,
595+
// The actor MTime takes its properties into account
596+
// When it changes, it means that the shaders need to be updated because either:
597+
// - the actor has been updated
598+
// - a different actor is used with this mapper
599+
actorTime: actor.getMTime(),
610600
};
611601

612602
// We need to rebuild the shader if one of these variables has changed,
@@ -1490,7 +1480,6 @@ function vtkOpenGLVolumeMapper(publicAPI, model) {
14901480
model.VBOBuildTime.getMTime() < publicAPI.getMTime() ||
14911481
model.VBOBuildTime.getMTime() < actor.getMTime() ||
14921482
model.VBOBuildTime.getMTime() < model.renderable.getMTime() ||
1493-
model.VBOBuildTime.getMTime() < actor.getProperty().getMTime() ||
14941483
model.VBOBuildTime.getMTime() < model.currentInput.getMTime() ||
14951484
!model.scalarTexture?.getHandle() ||
14961485
!model.colorTexture?.getHandle() ||

0 commit comments

Comments
 (0)