Commit f5e3a9b1 authored by Ken Martin's avatar Ken Martin

Break the UpdateVBO method into smaller pieces.

This change breaks the Update VBO method into a method
to GetNeedToRebuildBufferObjects and BuildBufferObjects to make
it easier for subclasses to override the default behavior.

Change-Id: I99b3378b0e6b7c3ec9da4000ab33d213b8fc67c4
parent 737c5e62
......@@ -149,7 +149,7 @@ void vtkOpenGLSphereMapper::SetCameraShaderParameters(vtkgl::CellBO &cellBO,
void vtkOpenGLSphereMapper::SetMapperShaderParameters(vtkgl::CellBO &cellBO,
vtkRenderer *ren, vtkActor *actor)
{
if (cellBO.indexCount && (this->OpenGLUpdateTime > cellBO.attributeUpdateTime ||
if (cellBO.indexCount && (this->VBOBuildTime > cellBO.attributeUpdateTime ||
cellBO.ShaderSourceTime > cellBO.attributeUpdateTime))
{
vtkgl::VBOLayout &layout = this->Layout;
......@@ -241,7 +241,20 @@ vtkgl::VBOLayout vtkOpenGLSphereMapperCreateVBO(float * points, vtkIdType numPts
}
//-------------------------------------------------------------------------
void vtkOpenGLSphereMapper::UpdateVBO(vtkRenderer *vtkNotUsed(ren), vtkActor *act)
bool vtkOpenGLSphereMapper::GetNeedToRebuildBufferObjects(vtkRenderer *vtkNotUsed(ren), vtkActor *act)
{
// picking state does not require a rebuild, unlike our parent
if (this->VBOBuildTime < this->GetMTime() ||
this->VBOBuildTime < act->GetMTime() ||
this->VBOBuildTime < this->CurrentInput->GetMTime())
{
return true;
}
return false;
}
//-------------------------------------------------------------------------
void vtkOpenGLSphereMapper::BuildBufferObjects(vtkRenderer *vtkNotUsed(ren), vtkActor *act)
{
vtkPolyData *poly = this->CurrentInput;
......
......@@ -67,9 +67,13 @@ protected:
const char *ScaleArray;
// Description:
// Does the VBO/IBO need to be rebuilt
virtual bool GetNeedToRebuildBufferObjects(vtkRenderer *ren, vtkActor *act);
// Description:
// Update the VBO to contain point based values
virtual void UpdateVBO(vtkRenderer *ren, vtkActor *act);
virtual void BuildBufferObjects(vtkRenderer *ren, vtkActor *act);
virtual void RenderPieceDraw(vtkRenderer *ren, vtkActor *act);
......
......@@ -213,7 +213,7 @@ void vtkOpenGLStickMapper::SetCameraShaderParameters(vtkgl::CellBO &cellBO,
void vtkOpenGLStickMapper::SetMapperShaderParameters(vtkgl::CellBO &cellBO,
vtkRenderer *ren, vtkActor *actor)
{
if (cellBO.indexCount && (this->OpenGLUpdateTime > cellBO.attributeUpdateTime ||
if (cellBO.indexCount && (this->VBOBuildTime > cellBO.attributeUpdateTime ||
cellBO.ShaderSourceTime > cellBO.attributeUpdateTime))
{
vtkHardwareSelector* selector = ren->GetSelector();
......@@ -454,7 +454,24 @@ size_t vtkOpenGLStickMapperCreateTriangleIndexBuffer(
}
//-------------------------------------------------------------------------
void vtkOpenGLStickMapper::UpdateVBO(vtkRenderer *ren, vtkActor *act)
bool vtkOpenGLStickMapper::GetNeedToRebuildBufferObjects(vtkRenderer *ren, vtkActor *act)
{
// picking state changing always requires a rebuild
vtkHardwareSelector* selector = ren->GetSelector();
bool picking = (ren->GetIsPicking() || selector != NULL);
if (this->VBOBuildTime < this->GetMTime() ||
this->VBOBuildTime < act->GetMTime() ||
this->VBOBuildTime < this->CurrentInput->GetMTime() ||
this->LastSelectionState || picking)
{
return true;
}
return false;
}
//-------------------------------------------------------------------------
void vtkOpenGLStickMapper::BuildBufferObjects(vtkRenderer *ren, vtkActor *act)
{
vtkPolyData *poly = this->CurrentInput;
......
......@@ -73,9 +73,13 @@ protected:
const char *OrientationArray;
const char *SelectionIdArray;
// Description:
// Does the VBO/IBO need to be rebuilt
virtual bool GetNeedToRebuildBufferObjects(vtkRenderer *ren, vtkActor *act);
// Description:
// Update the VBO to contain point based values
virtual void UpdateVBO(vtkRenderer *ren, vtkActor *act);
virtual void BuildBufferObjects(vtkRenderer *ren, vtkActor *act);
virtual void RenderPieceDraw(vtkRenderer *ren, vtkActor *act);
......
......@@ -439,7 +439,7 @@ void vtkOpenGLGlyph3DHelper::GlyphRenderInstances(
// do the superclass and then reset a couple values
if (this->Tris.indexCount && // we have points and one of
(this->OpenGLUpdateTime > this->InstanceBuffersLoadTime ||
(this->VBOBuildTime > this->InstanceBuffersLoadTime ||
this->Tris.ShaderSourceTime > this->InstanceBuffersLoadTime ||
pointMTime > this->InstanceBuffersLoadTime.GetMTime()))
{
......
......@@ -68,9 +68,13 @@ protected:
// Set the shader parameters related to the actor/mapper
virtual void SetMapperShaderParameters(vtkgl::CellBO &cellBO, vtkRenderer *ren, vtkActor *act);
// Description:
// Does the VBO/IBO need to be rebuilt
virtual bool GetNeedToRebuildBufferObjects(vtkRenderer *ren, vtkActor *act);
// Description:
// Update the VBO to contain point based values
virtual void UpdateVBO(vtkRenderer *ren, vtkActor *act);
virtual void BuildBufferObjects(vtkRenderer *ren, vtkActor *act);
virtual void RenderPieceDraw(vtkRenderer *ren, vtkActor *act);
......@@ -148,7 +152,7 @@ void vtkOpenGLPointGaussianMapperHelper::SetCameraShaderParameters(vtkgl::CellBO
void vtkOpenGLPointGaussianMapperHelper::SetMapperShaderParameters(vtkgl::CellBO &cellBO,
vtkRenderer *ren, vtkActor *actor)
{
if (cellBO.indexCount && (this->OpenGLUpdateTime > cellBO.attributeUpdateTime ||
if (cellBO.indexCount && (this->VBOBuildTime > cellBO.attributeUpdateTime ||
cellBO.ShaderSourceTime > cellBO.attributeUpdateTime))
{
vtkgl::VBOLayout &layout = this->Layout;
......@@ -248,7 +252,20 @@ size_t vtkOpenGLPointGaussianMapperHelperCreateTriangleIndexBuffer(
}
//-------------------------------------------------------------------------
void vtkOpenGLPointGaussianMapperHelper::UpdateVBO(vtkRenderer *vtkNotUsed(ren), vtkActor *act)
bool vtkOpenGLPointGaussianMapperHelper::GetNeedToRebuildBufferObjects(vtkRenderer *vtkNotUsed(ren), vtkActor *act)
{
// picking state does not require a rebuild, unlike our parent
if (this->VBOBuildTime < this->GetMTime() ||
this->VBOBuildTime < act->GetMTime() ||
this->VBOBuildTime < this->CurrentInput->GetMTime())
{
return true;
}
return false;
}
//-------------------------------------------------------------------------
void vtkOpenGLPointGaussianMapperHelper::BuildBufferObjects(vtkRenderer *vtkNotUsed(ren), vtkActor *act)
{
vtkPolyData *poly = this->CurrentInput;
......@@ -276,7 +293,7 @@ void vtkOpenGLPointGaussianMapperHelper::UpdateVBO(vtkRenderer *vtkNotUsed(ren),
this->Owner->GetScaleArray())->GetVoidPointer(0)),
this->VBO);
// create the IBO
// we use no IBO
this->Points.indexCount = 0;
this->Lines.indexCount = 0;
this->TriStrips.indexCount = 0;
......
......@@ -683,7 +683,7 @@ void vtkOpenGLPolyDataMapper::SetMapperShaderParameters(vtkgl::CellBO &cellBO,
// Now to update the VAO too, if necessary.
vtkgl::VBOLayout &layout = this->Layout;
if (cellBO.indexCount && (this->OpenGLUpdateTime > cellBO.attributeUpdateTime ||
if (cellBO.indexCount && (this->VBOBuildTime > cellBO.attributeUpdateTime ||
cellBO.ShaderSourceTime > cellBO.attributeUpdateTime))
{
cellBO.vao.Bind();
......@@ -1049,21 +1049,8 @@ void vtkOpenGLPolyDataMapper::RenderPieceStart(vtkRenderer* ren, vtkActor *actor
this->TimeToDraw = 0.0;
this->pickingAttributeIDOffset = 0;
bool picking = (ren->GetIsPicking() || selector != NULL);
// Update the OpenGL if needed.
if (this->OpenGLUpdateTime < this->GetMTime() ||
this->OpenGLUpdateTime < actor->GetMTime() ||
this->OpenGLUpdateTime < this->CurrentInput->GetMTime())
{
this->UpdateVBO(ren, actor);
this->OpenGLUpdateTime.Modified();
}
else if ((this->LastSelectionState || picking) && selector &&
selector->GetFieldAssociation() == vtkDataObject::FIELD_ASSOCIATION_POINTS)
{
this->UpdateVBO(ren, actor);
this->OpenGLUpdateTime.Modified();
}
// make sure the BOs are up to date
this->UpdateBufferObjects(ren, actor);
// If we are coloring by texture, then load the texture map.
// Use Map as indicator, because texture hangs around.
......@@ -1357,7 +1344,39 @@ void vtkOpenGLPolyDataMapper::ComputeBounds()
}
//-------------------------------------------------------------------------
void vtkOpenGLPolyDataMapper::UpdateVBO(vtkRenderer *ren, vtkActor *act)
void vtkOpenGLPolyDataMapper::UpdateBufferObjects(vtkRenderer *ren, vtkActor *act)
{
if (this->GetNeedToRebuildBufferObjects(ren,act))
{
this->BuildBufferObjects(ren,act);
this->VBOBuildTime.Modified();
}
}
//-------------------------------------------------------------------------
bool vtkOpenGLPolyDataMapper::GetNeedToRebuildBufferObjects(vtkRenderer *ren, vtkActor *act)
{
if (this->VBOBuildTime < this->GetMTime() ||
this->VBOBuildTime < act->GetMTime() ||
this->VBOBuildTime < this->CurrentInput->GetMTime())
{
return true;
}
else
{
vtkHardwareSelector* selector = ren->GetSelector();
bool picking = (ren->GetIsPicking() || selector != NULL);
if ((this->LastSelectionState || picking) && selector &&
selector->GetFieldAssociation() == vtkDataObject::FIELD_ASSOCIATION_POINTS)
{
return true;
}
}
return false;
}
//-------------------------------------------------------------------------
void vtkOpenGLPolyDataMapper::BuildBufferObjects(vtkRenderer *ren, vtkActor *act)
{
vtkPolyData *poly = this->CurrentInput;
......@@ -1443,8 +1462,7 @@ void vtkOpenGLPolyDataMapper::UpdateVBO(vtkRenderer *ren, vtkActor *act)
}
}
// Iterate through all of the different types in the polydata, building OpenGLs
// and IBOs as appropriate for each type.
// Build the VBO
this->Layout =
CreateVBO(poly->GetPoints(),
cellPointMap.size() > 0 ? (unsigned int)cellPointMap.size() : poly->GetPoints()->GetNumberOfPoints(),
......@@ -1456,7 +1474,7 @@ void vtkOpenGLPolyDataMapper::UpdateVBO(vtkRenderer *ren, vtkActor *act)
pointCellMap.size() > 0 ? &pointCellMap.front() : NULL,
cellScalars, cellNormals);
// create the IBOs
// now create the IBOs
this->Points.indexCount = CreatePointIndexBuffer(prims[0],
this->Points.ibo);
......
......@@ -152,8 +152,16 @@ protected:
virtual void SetPropertyShaderParameters(vtkgl::CellBO &cellBO, vtkRenderer *ren, vtkActor *act);
// Description:
// Update the VBO to contain point based values
virtual void UpdateVBO(vtkRenderer *ren, vtkActor *act);
// Update the VBO/IBO to be current
virtual void UpdateBufferObjects(vtkRenderer *ren, vtkActor *act);
// Description:
// Does the VBO/IBO need to be rebuilt
virtual bool GetNeedToRebuildBufferObjects(vtkRenderer *ren, vtkActor *act);
// Description:
// Build the VBO/IBO, called by UpdateBufferObjects
virtual void BuildBufferObjects(vtkRenderer *ren, vtkActor *act);
// The VBO and its layout.
vtkgl::BufferObject VBO;
......@@ -180,7 +188,7 @@ protected:
vtkTimeStamp DepthPeelingChanged;
bool UsingScalarColoring;
vtkTimeStamp OpenGLUpdateTime; // When was the OpenGL updated?
vtkTimeStamp VBOBuildTime; // When was the OpenGL VBO updated?
vtkOpenGLTexture* InternalColorTexture;
int PopulateSelectionSettings;
......
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