Commit 5388c05a authored by Michael Fogleman's avatar Michael Fogleman

Allow selecting scivis vs pathtracer for OSPRay

parent bbf9b115
Pipeline #25100 passed with stage
......@@ -64,6 +64,14 @@ void vtkOSPRayCompositePolyDataMapper2Node::PrintSelf(ostream& os, vtkIndent ind
this->Superclass::PrintSelf(os, indent);
}
//----------------------------------------------------------------------------
void vtkOSPRayCompositePolyDataMapper2Node::Invalidate(bool prepass)
{
if (prepass)
{
this->RenderTime = 0;
}
}
//----------------------------------------------------------------------------
void vtkOSPRayCompositePolyDataMapper2Node::Render(bool prepass)
......
......@@ -40,6 +40,8 @@ public:
//Make ospray calls to render me.
virtual void Render(bool prepass);
virtual void Invalidate(bool prepass);
protected:
vtkOSPRayCompositePolyDataMapper2Node();
~vtkOSPRayCompositePolyDataMapper2Node();
......
......@@ -914,6 +914,15 @@ void vtkOSPRayPolyDataMapperNode::CreateNewMeshes()
this->OSPMeshes = myMeshes;
}
//----------------------------------------------------------------------------
void vtkOSPRayPolyDataMapperNode::Invalidate(bool prepass)
{
if (prepass)
{
this->RenderTime = 0;
}
}
//----------------------------------------------------------------------------
void vtkOSPRayPolyDataMapperNode::Render(bool prepass)
{
......
......@@ -37,6 +37,8 @@ public:
//Make ospray calls to render me.
virtual void Render(bool prepass);
virtual void Invalidate(bool prepass);
protected:
vtkOSPRayPolyDataMapperNode();
~vtkOSPRayPolyDataMapperNode();
......
......@@ -18,6 +18,7 @@
#include "vtkCollectionIterator.h"
#include "vtkInformation.h"
#include "vtkInformationIntegerKey.h"
#include "vtkInformationStringKey.h"
#include "vtkObjectFactory.h"
#include "vtkOSPRayActorNode.h"
#include "vtkOSPRayCameraNode.h"
......@@ -161,6 +162,7 @@ vtkInformationKeyMacro(vtkOSPRayRendererNode, SAMPLES_PER_PIXEL, Integer);
vtkInformationKeyMacro(vtkOSPRayRendererNode, MAX_FRAMES, Integer);
vtkInformationKeyMacro(vtkOSPRayRendererNode, AMBIENT_SAMPLES, Integer);
vtkInformationKeyMacro(vtkOSPRayRendererNode, COMPOSITE_ON_GL, Integer);
vtkInformationKeyMacro(vtkOSPRayRendererNode, RENDERER_TYPE, String);
//============================================================================
vtkStandardNewMacro(vtkOSPRayRendererNode);
......@@ -251,6 +253,32 @@ int vtkOSPRayRendererNode::GetMaxFrames(vtkRenderer *renderer)
return 1;
}
//----------------------------------------------------------------------------
void vtkOSPRayRendererNode::SetRendererType(std::string name, vtkRenderer *renderer)
{
if (!renderer)
{
return;
}
vtkInformation *info = renderer->GetInformation();
info->Set(vtkOSPRayRendererNode::RENDERER_TYPE(), name);
}
//----------------------------------------------------------------------------
std::string vtkOSPRayRendererNode::GetRendererType(vtkRenderer *renderer)
{
if (!renderer)
{
return std::string("scivis");
}
vtkInformation *info = renderer->GetInformation();
if (info && info->Has(vtkOSPRayRendererNode::RENDERER_TYPE()))
{
return (info->Get(vtkOSPRayRendererNode::RENDERER_TYPE()));
}
return std::string("scivis");
}
//----------------------------------------------------------------------------
void vtkOSPRayRendererNode::SetAmbientSamples(int value, vtkRenderer *renderer)
{
......@@ -427,6 +455,15 @@ void vtkOSPRayRendererNode::Traverse(int operation)
this->Apply(operation,false);
}
//----------------------------------------------------------------------------
void vtkOSPRayRendererNode::Invalidate(bool prepass)
{
if (prepass)
{
this->RenderTime = 0;
}
}
//----------------------------------------------------------------------------
void vtkOSPRayRendererNode::Build(bool prepass)
{
......@@ -454,11 +491,15 @@ void vtkOSPRayRendererNode::Render(bool prepass)
if (prepass)
{
OSPRenderer oRenderer = NULL;
if (!this->ORenderer)
static std::string previousType;
std::string type = this->GetRendererType(static_cast<vtkRenderer*>(this->Renderable));
if (!this->ORenderer || previousType != type)
{
this->Traverse(invalidate);
ospRelease((osp::Renderer*)this->ORenderer);
oRenderer = (osp::Renderer*)ospNewRenderer("scivis");
oRenderer = (osp::Renderer*)ospNewRenderer(type.c_str());
this->ORenderer = oRenderer;
previousType = type;
}
else
{
......
......@@ -25,6 +25,7 @@
class vtkRenderer;
class vtkInformationIntegerKey;
class vtkInformationStringKey;
// ospray forward decs so that someone does not need to include ospray.h
namespace osp {
struct Model;
......@@ -56,6 +57,10 @@ public:
//Traverse graph in ospray's prefered order and render
virtual void Render(bool prepass);
//Description:
//Invalidate cached data
virtual void Invalidate(bool prepass);
//Description:
//Put my results into the correct place in the provided pixel buffer.
virtual void WriteLayer(unsigned char *buffer, float *zbuffer,
......@@ -83,6 +88,11 @@ public:
static void SetMaxFrames(int, vtkRenderer *renderer);
static int GetMaxFrames(vtkRenderer *renderer);
//
static vtkInformationStringKey* RENDERER_TYPE();
static void SetRendererType(std::string name, vtkRenderer *renderer);
static std::string GetRendererType(vtkRenderer *renderer);
//Description:
//When present on renderer, controls the number of ambient occlusion
//samples shot per hit.
......@@ -143,8 +153,8 @@ protected:
float* ODepthBuffer;
private:
vtkOSPRayRendererNode(const vtkOSPRayRendererNode&) VTK_DELETE_FUNCTION;
void operator=(const vtkOSPRayRendererNode&) VTK_DELETE_FUNCTION;
vtkOSPRayRendererNode(const vtkOSPRayRendererNode&); // Not implemented.
void operator=(const vtkOSPRayRendererNode&); // Not implemented.
};
#endif
......@@ -174,6 +174,7 @@ void vtkViewNode::AddMissingNode(vtkObject *obj)
//----------------------------------------------------------------------------
void vtkViewNode::TraverseAllPasses()
{
// this->Traverse(invalidate); // do we want this here?
this->Traverse(build);
this->Traverse(synchronize);
this->Traverse(render);
......@@ -254,6 +255,9 @@ void vtkViewNode::Apply(int operation, bool prepass)
case render:
this->Render(prepass);
break;
case invalidate:
this->Invalidate(prepass);
break;
default:
cerr << "UNKNOWN OPERATION" << operation << endl;
}
......
......@@ -54,6 +54,10 @@ public:
//Makes calls to make self visible.
virtual void Render(bool /*prepass*/) {};
//Description:
//Clear any cached data.
virtual void Invalidate(bool /*prepass*/) {};
//Description:
//Access the node that owns this one.
virtual void SetParent(vtkViewNode*);
......@@ -96,7 +100,7 @@ public:
//Description:
//internal mechanics of graph traversal and actions
enum operation_type{noop, build, synchronize, render};
enum operation_type{noop, build, synchronize, render, invalidate};
protected:
vtkViewNode();
......
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