summaryrefslogtreecommitdiffstats
path: root/src/RendererSection.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/RendererSection.cpp')
-rw-r--r--src/RendererSection.cpp54
1 files changed, 38 insertions, 16 deletions
diff --git a/src/RendererSection.cpp b/src/RendererSection.cpp
index 429a8bd..7ea74df 100644
--- a/src/RendererSection.cpp
+++ b/src/RendererSection.cpp
@@ -9,16 +9,26 @@
#include "RendererSectionData.hpp"
-RendererSection::RendererSection(const RendererSectionData& data, std::shared_ptr<Gal::Pipeline> pipeline, std::shared_ptr<Gal::BufferBinding> bufferBinding) {
+RendererSection::RendererSection(const RendererSectionData& data,
+ std::shared_ptr<Gal::Pipeline> solidPipeline,
+ std::shared_ptr<Gal::BufferBinding> solidBufferBinding,
+ std::shared_ptr<Gal::Pipeline> liquidPipeline,
+ std::shared_ptr<Gal::BufferBinding> liquidBufferBinding) {
OPTICK_EVENT();
auto gal = Gal::GetImplementation();
- buffer = gal->CreateBuffer();
- pipelineInstance = pipeline->CreateInstance({
- {bufferBinding, buffer}
+ solidBuffer = gal->CreateBuffer();
+ solidPipelineInstance = solidPipeline->CreateInstance({
+ {solidBufferBinding, solidBuffer}
});
- pipelineInstance->SetInstancesCount(4);
+ solidPipelineInstance->SetInstancesCount(4);
+
+ liquidBuffer = gal->CreateBuffer();
+ liquidPipelineInstance = liquidPipeline->CreateInstance({
+ {liquidBufferBinding, liquidBuffer}
+ });
+ liquidPipelineInstance->SetInstancesCount(4);
UpdateData(data);
}
@@ -32,18 +42,27 @@ RendererSection::~RendererSection() {
}
-void swap(RendererSection & lhs, RendererSection & rhs) {
- std::swap(lhs.pipelineInstance, rhs.pipelineInstance);
- std::swap(lhs.buffer, rhs.buffer);
- std::swap(lhs.hash, rhs.hash);
- std::swap(lhs.numOfFaces, rhs.numOfFaces);
- std::swap(lhs.sectionPos, rhs.sectionPos);
+void RendererSection::RenderSolid() {
+ OPTICK_EVENT();
+ solidPipelineInstance->Activate();
+ solidPipelineInstance->Render(0, solidFacesCount);
}
-void RendererSection::Render() {
+void RendererSection::RenderLiquid() {
OPTICK_EVENT();
- pipelineInstance->Activate();
- pipelineInstance->Render(0, numOfFaces);
+ liquidPipelineInstance->Activate();
+ liquidPipelineInstance->Render(0, liquidFacesCount);
+}
+
+void swap(RendererSection & lhs, RendererSection & rhs) {
+ std::swap(lhs.solidPipelineInstance, rhs.solidPipelineInstance);
+ std::swap(lhs.solidBuffer, rhs.solidBuffer);
+ std::swap(lhs.liquidPipelineInstance, rhs.liquidPipelineInstance);
+ std::swap(lhs.liquidBuffer, rhs.liquidBuffer);
+ std::swap(lhs.hash, rhs.hash);
+ std::swap(lhs.solidFacesCount, rhs.solidFacesCount);
+ std::swap(lhs.liquidFacesCount, rhs.liquidFacesCount);
+ std::swap(lhs.sectionPos, rhs.sectionPos);
}
Vector RendererSection::GetPosition() {
@@ -57,9 +76,12 @@ size_t RendererSection::GetHash() {
void RendererSection::UpdateData(const RendererSectionData & data) {
OPTICK_EVENT();
- buffer->SetData({ reinterpret_cast<const std::byte*>(data.vertices.data()), reinterpret_cast<const std::byte*>(data.vertices.data() + data.vertices.size())});
+ solidBuffer->SetData({ reinterpret_cast<const std::byte*>(data.solidVertices.data()), reinterpret_cast<const std::byte*>(data.solidVertices.data() + data.solidVertices.size())});
+ solidFacesCount = data.solidVertices.size();
+
+ liquidBuffer->SetData({ reinterpret_cast<const std::byte*>(data.liquidVertices.data()), reinterpret_cast<const std::byte*>(data.liquidVertices.data() + data.liquidVertices.size()) });
+ liquidFacesCount = data.liquidVertices.size();
- numOfFaces = data.vertices.size();
sectionPos = data.sectionPos;
hash = data.hash;
}