Commit fc779976 authored by David E. DeMarle's avatar David E. DeMarle

dont leak the light either

parent d67f69e2
......@@ -38,11 +38,13 @@ vtkStandardNewMacro(vtkOSPRayLightNode);
//----------------------------------------------------------------------------
vtkOSPRayLightNode::vtkOSPRayLightNode()
{
this->OLight = nullptr;
}
//----------------------------------------------------------------------------
vtkOSPRayLightNode::~vtkOSPRayLightNode()
{
ospRelease((OSPLight)this->OLight);
}
//----------------------------------------------------------------------------
......@@ -120,6 +122,9 @@ void vtkOSPRayLightNode::Render(bool prepass)
{
if (prepass)
{
ospRelease((OSPLight)this->OLight);
OSPLight ospLight;
vtkOSPRayRendererNode *orn =
static_cast<vtkOSPRayRendererNode *>(
this->GetFirstAncestorOfType("vtkOSPRayRendererNode"));
......@@ -136,7 +141,7 @@ void vtkOSPRayLightNode::Render(bool prepass)
}
if (vtkOSPRayLightNode::GetIsAmbient(light))
{
OSPLight ospLight = ospNewLight(oRenderer, "ambient");
ospLight = ospNewLight(oRenderer, "ambient");
color[0] = static_cast<float>(light->GetDiffuseColor()[0]);
color[1] = static_cast<float>(light->GetDiffuseColor()[1]);
color[2] = static_cast<float>(light->GetDiffuseColor()[2]);
......@@ -163,7 +168,6 @@ void vtkOSPRayLightNode::Render(bool prepass)
pz = p[2];
}
float coneAngle = static_cast<float>(light->GetConeAngle());
OSPLight ospLight;
if (coneAngle <= 0.0)
{
ospLight = ospNewLight(oRenderer, "PointLight");
......@@ -225,7 +229,7 @@ void vtkOSPRayLightNode::Render(bool prepass)
direction[0] = fx - px;
direction[1] = fy - py;
direction[2] = fz - pz;
OSPLight ospLight = ospNewLight(oRenderer, "DirectionalLight");
ospLight = ospNewLight(oRenderer, "DirectionalLight");
ospSet3f(ospLight, "color", color[0], color[1], color[2]);
float fI = static_cast<float>
(vtkOSPRayLightNode::LightScale*
......@@ -240,5 +244,6 @@ void vtkOSPRayLightNode::Render(bool prepass)
ospCommit(ospLight);
orn->AddLight(ospLight);
}
this->OLight = ospLight;
}
}
......@@ -91,6 +91,7 @@ private:
void operator=(const vtkOSPRayLightNode&) = delete;
static double LightScale;
void *OLight;
};
#endif
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