Commit c2654cdd authored by Carson Brownlee's avatar Carson Brownlee
Browse files

code cleanup

parent 3d45971d
......@@ -61,8 +61,6 @@ if (VTK_ENABLE_OSPRAY)
vtk_module_link(VTK::RenderingRayTracing
PUBLIC
ospray::ospray
ospray::ospray_module_ispc
openvkl::openvkl_module_ispc_driver
)
if (VTKOSPRAY_ENABLE_DENOISER)
vtk_module_find_package(
......
......@@ -112,16 +112,7 @@ void CellMaterials(vtkOSPRayRendererNode* orn, OSPRenderer oRenderer, vtkPolyDat
float localOpacity = 1.f;
if (width >= 4)
{
double* color = vColors->GetTuple(i);
OSPMaterial oMaterial;
oMaterial = vtkOSPRayMaterialHelpers::NewMaterial(orn, oRenderer, "obj");
float diffusef[] = { static_cast<float>(color[0]) / (255.0f),
static_cast<float>(color[1]) / (255.0f), static_cast<float>(color[2]) / (255.0f) };
float localOpacity = 1.f;
if (width >= 4)
{
localOpacity = static_cast<float>(color[3]) / (255.0f);
}
localOpacity = static_cast<float>(color[3]) / (255.0f);
ospSetVec3f(oMaterial, "kd", diffusef[0], diffusef[1], diffusef[2]);
float specAdjust = 2.0f / (2.0f + specPower);
float specularf[] = { specColor[0] * specAdjust, specColor[1] * specAdjust,
......@@ -813,7 +804,9 @@ void vtkOSPRayPolyDataMapperNode::ORenderPoly(void* renderer, vtkOSPRayActorNode
vtkPolyDataMapperNode::TransformPoints(act, poly, _vertices);
size_t numPositions = _vertices.size() / 3;
if (numPositions == 0)
{
return;
}
std::vector<osp::vec3f> vertices(numPositions);
for (size_t i = 0; i < numPositions; i++)
{
......@@ -1224,10 +1217,8 @@ void vtkOSPRayPolyDataMapperNode::ORenderPoly(void* renderer, vtkOSPRayActorNode
}
}
}
if (position)
ospRelease(position);
if (cellMaterials)
ospRelease(cellMaterials);
ospRelease(position);
ospRelease(cellMaterials);
for (auto it : mats)
{
......
......@@ -969,13 +969,6 @@ void vtkOSPRayRendererNode::PrintSelf(ostream& os, vtkIndent indent)
this->Superclass::PrintSelf(os, indent);
}
// triangle mesh data
static std::vector<float> vertexTest = { -1.0f, -1.0f, 3.0f, -1.0f, 1.0f, 3.0f, 1.0f, -1.0f, 3.0f,
0.1f, 0.1f, 0.3f };
static std::vector<float> colorTest = { 0.9f, 0.5f, 0.5f, 1.0f, 0.8f, 0.8f, 0.8f, 1.0f, 0.8f, 0.8f,
0.8f, 1.0f, 0.5f, 0.9f, 0.5f, 1.0f };
static std::vector<int32_t> indexTest = { 0, 1, 2, 1, 2, 3 };
//----------------------------------------------------------------------------
void vtkOSPRayRendererNode::Traverse(int operation)
{
......@@ -1016,7 +1009,9 @@ void vtkOSPRayRendererNode::Traverse(int operation)
RTW::Backend* backend = this->Internal->Backend;
if (backend == nullptr)
{
return;
}
// lights
// TODO: Carson: free lights
......
......@@ -368,6 +368,7 @@ void vtkOSPRayVolumeMapperNode::UpdateTransferFunction(
vtkVolumeProperty* volProperty = vol->GetProperty();
vtkColorTransferFunction* colorTF = volProperty->GetRGBTransferFunction(0);
vtkPiecewiseFunction* scalarTF = volProperty->GetScalarOpacity(0);
vtkVolumeMapper* mapper = vtkVolumeMapper::SafeDownCast(this->GetRenderable());
this->TFVals.resize(this->NumColors * 3);
this->TFOVals.resize(this->NumColors);
......@@ -385,31 +386,32 @@ void vtkOSPRayVolumeMapperNode::UpdateTransferFunction(
colorTF->GetTable(tfRangeD[0], tfRangeD[1], this->NumColors, &this->TFVals[0]);
// todo: samplingStep should be adjusted for AMR/unstructured
float scalarOpacityUnitDistance = volProperty->GetScalarOpacityUnitDistance();
if (scalarOpacityUnitDistance < 1e-29) // avoid div by 0
if (mapper->GetBlendMode() != vtkVolumeMapper::ISOSURFACE_BLEND)
{
scalarOpacityUnitDistance = 1e-29;
}
for (int i = 0; i < this->NumColors; i++)
{
this->TFOVals[i] = this->TFOVals[i] / scalarOpacityUnitDistance * this->SamplingStep;
float scalarOpacityUnitDistance = volProperty->GetScalarOpacityUnitDistance();
if (scalarOpacityUnitDistance < 1e-29) // avoid div by 0
{
scalarOpacityUnitDistance = 1e-29;
}
for (int i = 0; i < this->NumColors; i++)
{
this->TFOVals[i] = this->TFOVals[i] / scalarOpacityUnitDistance * this->SamplingStep;
}
}
// if (this->TransferFunction)
// ospRelease(this->TransferFunction);
this->TransferFunction = ospNewTransferFunction("piecewiseLinear");
OSPData colorData = ospNewCopyData1D(this->NumColors, OSP_VEC3F, &this->TFVals[0]);
ospCommit(colorData);
ospSetObject(this->TransferFunction, "color", colorData);
// ospRelease(colorData);
ospRelease(colorData);
ospSetVec2f(this->TransferFunction, "valueRange", tfRange.x, tfRange.y);
OSPData tfAlphaData = ospNewCopyData1D(this->NumColors, OSP_FLOAT, &this->TFOVals[0]);
ospCommit(tfAlphaData);
ospSetObject(this->TransferFunction, "opacity", tfAlphaData);
// ospRelease(tfAlphaData);
ospRelease(tfAlphaData);
ospCommit(this->TransferFunction);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment