mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-21 19:45:44 +00:00
Merge branch 'volume-raytracing-crash' into 'master'
Fix use of uninitialized invSpacing value in volume raytracing The SamplerRect worklet had an error where it was possible that the invSpacing stack-local values could be used uninitialized. On the first iteration of the loop in the SamplerRect operation, it calls LocateCell, which is supposed to set invSpacing. Under most conditions it does, but if one of the ray directions is 0 (which can happen with axis-aligned views), one of the invSpacing dimensions was skipped, leaving the value to whatever garbage happened to be on the stack. Later, the invSpacing value was used to interpolate a scalar, which under some circumstances could cause an array index error when looking up a color in the color map. This fix changes the condition for when the ray direction is 0 to still initialize invSpacing. See merge request !441
This commit is contained in:
commit
1d5fbea3e9
@ -681,9 +681,14 @@ class SamplerCellAssocRect : public vtkm::worklet::WorkletMapField
|
||||
{
|
||||
for(vtkm::Int32 dim = 0; dim < 3; ++dim)
|
||||
{
|
||||
if(rayDir[dim] == 0.f) continue;
|
||||
vtkm::FloatDefault searchDir = (rayDir[dim] > 0.f) ? vtkm::FloatDefault(1.0) : vtkm::FloatDefault(-1.0);
|
||||
bool notFound = true;
|
||||
if(rayDir[dim] == 0.f)
|
||||
{
|
||||
// If the ray direction is zero, then the ray does not move from
|
||||
// cell to cell, and is therefore already found.
|
||||
notFound = false;
|
||||
}
|
||||
vtkm::FloatDefault searchDir = (rayDir[dim] > 0.f) ? vtkm::FloatDefault(1.0) : vtkm::FloatDefault(-1.0);
|
||||
while(notFound)
|
||||
{
|
||||
vtkm::Id nextPoint = cell[dim] + static_cast<vtkm::Id>(searchDir);
|
||||
|
Loading…
Reference in New Issue
Block a user