Skip to content
Open
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
10 changes: 10 additions & 0 deletions Sources/Rendering/Core/Mapper/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export interface IMapperInitialValues extends IAbstractMapper3DInitialValues {
interpolateScalarsBeforeMapping?: boolean;
forceCompileOnly?: number;
useInvertibleColors?: boolean;
coordShiftScaleEnabled?: boolean;
customShaderAttributes?: any;
}

Expand Down Expand Up @@ -467,6 +468,15 @@ export interface vtkMapper
setInterpolateScalarsBeforeMapping(
interpolateScalarsBeforeMapping: boolean
): boolean;

/**
* Control whether the mapper should automatically shift and scale
* the coordinates to improve precision. This is enabled by default.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add comment to explain when/why you would want to turn it off.

*
* @param {Boolean} coordShiftScaleEnabled
* @default true
*/
setCoordShiftScaleEnabled(coordShiftScaleEnabled: boolean): boolean;
}

/**
Expand Down
3 changes: 3 additions & 0 deletions Sources/Rendering/Core/Mapper/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,8 @@ const DEFAULT_VALUES = {
invertibleScalars: null,

customShaderAttributes: [],

coordShiftScaleEnabled: true,
};

// ----------------------------------------------------------------------------
Expand Down Expand Up @@ -825,6 +827,7 @@ export function extend(publicAPI, model, initialValues = {}) {
'scalarVisibility',
'static',
'useLookupTableScalarRange',
'coordShiftScaleEnabled',
'customShaderAttributes', // point data array names that will be transferred to the VBO
]);
macro.setGetArray(publicAPI, model, ['scalarRange'], 2);
Expand Down
10 changes: 8 additions & 2 deletions Sources/Rendering/OpenGL/Glyph3DMapper/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -694,8 +694,14 @@ function vtkOpenGLGlyph3DMapper(publicAPI, model) {
const garray = model.renderable.getMatrixArray();

const pts = model.renderable.getInputData(0).getPoints();
const { useShiftAndScale, coordShift, coordScale } =
computeCoordShiftAndScale(pts);
let useShiftAndScale = false;
let coordShift = 0.0;
let coordScale = 1.0;

if (model.renderable.getCoordShiftScaleEnabled() && pts) {
({ useShiftAndScale, coordShift, coordScale } =
computeCoordShiftAndScale(pts));
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of having a flag, could you detect when shift/scale have "bad" values ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe a metric could be computed with regard to the current camera settings.
An error in the "display world" could be considered to too large and coord shift/scale be therefore discarded ?


if (model.hardwareSupport) {
// update the buffer objects if needed
Expand Down
8 changes: 6 additions & 2 deletions Sources/Rendering/OpenGL/PolyDataMapper/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1258,7 +1258,9 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) {
const numClipPlanes = model.renderable.getNumberOfClippingPlanes();
const planeEquations = [];

const shiftScaleEnabled = cellBO.getCABO().getCoordShiftAndScaleEnabled();
const shiftScaleEnabled =
model.renderable.coordShiftScaleEnabled &&
cellBO.getCABO().getCoordShiftAndScaleEnabled();
const inverseShiftScaleMatrix = shiftScaleEnabled
? cellBO.getCABO().getInverseShiftAndScaleMatrix()
: null;
Expand Down Expand Up @@ -1460,7 +1462,9 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) {
const camm = model.openGLCamera.getKeyMatrixTime().getMTime();
const progm = program.getLastCameraMTime();

const shiftScaleEnabled = cellBO.getCABO().getCoordShiftAndScaleEnabled();
const shiftScaleEnabled =
model.renderable.coordShiftScaleEnabled &&
cellBO.getCABO().getCoordShiftAndScaleEnabled();
const inverseShiftScaleMatrix = shiftScaleEnabled
? cellBO.getCABO().getInverseShiftAndScaleMatrix()
: null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ function defaultValues(publicAPI, model, initialValues) {
initialValues._pipeline?.mapper ?? // in case mapper was provided
vtkGlyph3DMapper.newInstance({
scalarMode: ScalarMode.USE_POINT_FIELD_DATA,
coordShiftScaleEnabled: false, // disable shift scale by default for widgets using glyphs
}),
actor:
initialValues._pipeline?.actor ?? // in case actor was provided
Expand Down
Loading