Skip to content

Commit

Permalink
#5952: Refine the IGeometryRenderer interface a bit, include the rend…
Browse files Browse the repository at this point in the history
…erAllVisibleGeometry method
  • Loading branch information
codereader committed May 1, 2022
1 parent 160c5e8 commit 2b94826
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 16 deletions.
7 changes: 4 additions & 3 deletions include/igeometryrenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,11 @@ class IGeometryRenderer

// Updates the vertex data. The size of the vertex and index array must be the same
// as the one passed to addGeometry. To change the size the data needs to be removed and re-added.
// If the slot has been deactivated before, the reactivateSlot flag indicates whether
// the geometry should be re-activated by this call.
virtual void updateGeometry(Slot slot, const std::vector<RenderVertex>& vertices,
const std::vector<unsigned int>& indices, bool reactivateSlot) = 0;
const std::vector<unsigned int>& indices) = 0;

// Submits all active geometry slots to GL
virtual void renderAllVisibleGeometry() = 0;

// Submits the geometry of a single slot to GL, regardless of its active state
virtual void renderGeometry(Slot slot) = 0;
Expand Down
2 changes: 1 addition & 1 deletion libs/render/RenderableGeometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ class RenderableGeometry :
else
{
// In case the slot had been deactivated => reactivate automatically
_shader->updateGeometry(_surfaceSlot, vertices, indices, true);
_shader->updateGeometry(_surfaceSlot, vertices, indices);
}

// Fire the bounds changed signal (after submitting the changed vertices)
Expand Down
18 changes: 10 additions & 8 deletions radiantcore/rendersystem/backend/GeometryRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class GeometryRenderer :

void activateGeometry(Slot slot) override
{
auto& slotInfo = _slots.at(slot);
const auto& slotInfo = _slots.at(slot);
auto& group = getGroupByIndex(slotInfo.groupIndex);

// Remove the geometry from the visible set
Expand All @@ -106,7 +106,7 @@ class GeometryRenderer :

void deactivateGeometry(Slot slot) override
{
auto& slotInfo = _slots.at(slot);
const auto& slotInfo = _slots.at(slot);
auto& group = getGroupByIndex(slotInfo.groupIndex);

// Remove the geometry from the visible set
Expand Down Expand Up @@ -134,33 +134,35 @@ class GeometryRenderer :
}

void updateGeometry(Slot slot, const std::vector<RenderVertex>& vertices,
const std::vector<unsigned int>& indices, bool reactivateSlot) override
const std::vector<unsigned int>& indices) override
{
auto& slotInfo = _slots.at(slot);
const auto& slotInfo = _slots.at(slot);

// Upload the new vertex and index data
_store.updateData(slotInfo.storageHandle, vertices, indices);
}

AABB getGeometryBounds(Slot slot) override
{
auto& slotInfo = _slots.at(slot);
const auto& slotInfo = _slots.at(slot);

return _store.getBounds(slotInfo.storageHandle);
}

void render()
void renderAllVisibleGeometry() override
{
for (auto& group : _groups)
{
if (group.visibleStorageHandles.empty()) continue;

_renderer.submitGeometry(group.visibleStorageHandles, group.primitiveMode);
}
}

void renderGeometry(Slot slot) override
{
auto& slotInfo = _slots.at(slot);
auto& group = getGroupByIndex(slotInfo.groupIndex);
const auto& slotInfo = _slots.at(slot);
const auto& group = getGroupByIndex(slotInfo.groupIndex);

_renderer.submitGeometry(slotInfo.storageHandle, group.primitiveMode);
}
Expand Down
11 changes: 8 additions & 3 deletions radiantcore/rendersystem/backend/OpenGLShader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ void OpenGLShader::drawSurfaces(const VolumeTest& view)

if (hasSurfaces())
{
_geometryRenderer.render();
_geometryRenderer.renderAllVisibleGeometry();

// Surfaces are not allowed to render vertex colours (for now)
// otherwise they don't show up in their parent entity's colour
Expand Down Expand Up @@ -165,9 +165,14 @@ void OpenGLShader::removeGeometry(IGeometryRenderer::Slot slot)
}

void OpenGLShader::updateGeometry(IGeometryRenderer::Slot slot, const std::vector<RenderVertex>& vertices,
const std::vector<unsigned int>& indices, bool reactivateSlot)
const std::vector<unsigned int>& indices)
{
_geometryRenderer.updateGeometry(slot, vertices, indices, reactivateSlot);
_geometryRenderer.updateGeometry(slot, vertices, indices);
}

void OpenGLShader::renderAllVisibleGeometry()
{
_geometryRenderer.renderAllVisibleGeometry();
}

void OpenGLShader::renderGeometry(IGeometryRenderer::Slot slot)
Expand Down
3 changes: 2 additions & 1 deletion radiantcore/rendersystem/backend/OpenGLShader.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ class OpenGLShader :
void deactivateGeometry(IGeometryRenderer::Slot slot) override;
void removeGeometry(IGeometryRenderer::Slot slot) override;
void updateGeometry(IGeometryRenderer::Slot slot, const std::vector<RenderVertex>& vertices,
const std::vector<unsigned int>& indices, bool reactivateSlot) override;
const std::vector<unsigned int>& indices) override;
void renderAllVisibleGeometry() override;
void renderGeometry(IGeometryRenderer::Slot slot) override;
AABB getGeometryBounds(IGeometryRenderer::Slot slot) override;
IGeometryStore::Slot getGeometryStorageLocation(IGeometryRenderer::Slot slot) override;
Expand Down

0 comments on commit 2b94826

Please sign in to comment.