Refactoring camera
This commit is contained in:
@@ -34,7 +34,7 @@ void InspectorView::commitUpdate() {}
|
|||||||
|
|
||||||
void InspectorView::prepareRender() {}
|
void InspectorView::prepareRender() {}
|
||||||
|
|
||||||
void InspectorView::render() { renderGraph.render(Component::Camera()); }
|
void InspectorView::render() { renderGraph.render(Component::Camera(), Component::Transform()); }
|
||||||
|
|
||||||
void InspectorView::applyArea(URect ) {}
|
void InspectorView::applyArea(URect ) {}
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ void PlayView::keyCallback(KeyCode code, InputAction action, KeyModifier modifie
|
|||||||
cam = c;
|
cam = c;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
std::cout << cam.getCameraPosition() << std::endl;
|
std::cout << tra.getPosition() << std::endl;
|
||||||
std::cout << tra.getRotation() << std::endl;
|
std::cout << tra.getRotation() << std::endl;
|
||||||
}
|
}
|
||||||
if (code == KeyCode::KEY_R && action == InputAction::RELEASE) {
|
if (code == KeyCode::KEY_R && action == InputAction::RELEASE) {
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ void SceneView::commitUpdate() {}
|
|||||||
|
|
||||||
void SceneView::prepareRender() {}
|
void SceneView::prepareRender() {}
|
||||||
|
|
||||||
void SceneView::render() { renderGraph.render(viewportCamera); }
|
void SceneView::render() { renderGraph.render(viewportCamera, Component::Transform()); }
|
||||||
|
|
||||||
void SceneView::keyCallback(KeyCode code, InputAction action, KeyModifier) { cameraSystem.keyCallback(code, action); }
|
void SceneView::keyCallback(KeyCode code, InputAction action, KeyModifier) { cameraSystem.keyCallback(code, action); }
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ target_sources(Engine
|
|||||||
PRIVATE
|
PRIVATE
|
||||||
BoxCollider.h
|
BoxCollider.h
|
||||||
Camera.h
|
Camera.h
|
||||||
Camera.cpp
|
|
||||||
Collider.h
|
Collider.h
|
||||||
Collider.cpp
|
Collider.cpp
|
||||||
Component.h
|
Component.h
|
||||||
|
|||||||
@@ -1,53 +0,0 @@
|
|||||||
#include "Camera.h"
|
|
||||||
#include "Actor/Actor.h"
|
|
||||||
#include <algorithm>
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
using namespace Seele;
|
|
||||||
using namespace Seele::Component;
|
|
||||||
using namespace Seele::Math;
|
|
||||||
|
|
||||||
Camera::Camera() : viewMatrix(Matrix4()), cameraPos(Vector()), bNeedsViewBuild(false) {
|
|
||||||
yaw = -3.1415f / 2;
|
|
||||||
pitch = 0;
|
|
||||||
Vector eyePos = Vector(0, 0, -5);
|
|
||||||
Vector lookAt = Vector(0, 0, 0);
|
|
||||||
viewMatrix = glm::lookAt(eyePos, lookAt, Vector(0, 1, 0));
|
|
||||||
cameraPos = eyePos;
|
|
||||||
cameraForward = Vector(0, 0, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
Camera::~Camera() {}
|
|
||||||
|
|
||||||
void Camera::mouseMove(float deltaYaw, float deltaPitch) {
|
|
||||||
yaw += deltaYaw / 500.f;
|
|
||||||
pitch += deltaPitch / 500.f;
|
|
||||||
Vector cameraDirection = glm::normalize(Vector(cos(yaw) * cos(pitch), sin(pitch), sin(yaw) * cos(pitch)));
|
|
||||||
Matrix4 viewMat = glm::lookAt(getTransform().getPosition(), getTransform().getPosition() + cameraDirection, Vector(0, 1, 0));
|
|
||||||
getTransform().setRotation(viewMat); // quaternion from matrix, janky but im bad at math
|
|
||||||
bNeedsViewBuild = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Camera::mouseScroll(float x) {
|
|
||||||
getTransform().translate(getTransform().getForward() * x);
|
|
||||||
bNeedsViewBuild = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Camera::moveX(float amount) {
|
|
||||||
getTransform().translate(getTransform().getForward() * amount);
|
|
||||||
bNeedsViewBuild = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Camera::moveY(float amount) {
|
|
||||||
getTransform().translate(getTransform().getRight() * amount);
|
|
||||||
bNeedsViewBuild = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Camera::buildViewMatrix() {
|
|
||||||
Vector eyePos = getTransform().getPosition();
|
|
||||||
Vector lookAt = eyePos + getTransform().getForward();
|
|
||||||
viewMatrix = glm::lookAt(eyePos, lookAt, Vector(0, 1, 0));
|
|
||||||
cameraPos = eyePos;
|
|
||||||
cameraForward = getTransform().getForward();
|
|
||||||
bNeedsViewBuild = false;
|
|
||||||
}
|
|
||||||
@@ -6,32 +6,8 @@
|
|||||||
namespace Seele {
|
namespace Seele {
|
||||||
namespace Component {
|
namespace Component {
|
||||||
struct Camera {
|
struct Camera {
|
||||||
REQUIRE_COMPONENT(Transform)
|
|
||||||
|
|
||||||
Camera();
|
|
||||||
~Camera();
|
|
||||||
|
|
||||||
Matrix4 getViewMatrix() const {
|
|
||||||
assert(!bNeedsViewBuild);
|
|
||||||
return viewMatrix;
|
|
||||||
}
|
|
||||||
Vector getCameraPosition() const { return cameraPos; }
|
|
||||||
Vector getCameraForward() const { return cameraForward; }
|
|
||||||
void mouseMove(float deltaX, float deltaY);
|
|
||||||
void mouseScroll(float x);
|
|
||||||
void moveX(float amount);
|
|
||||||
void moveY(float amount);
|
|
||||||
void buildViewMatrix();
|
|
||||||
|
|
||||||
bool mainCamera = false;
|
|
||||||
|
|
||||||
private:
|
|
||||||
float yaw;
|
|
||||||
float pitch;
|
|
||||||
Matrix4 viewMatrix;
|
Matrix4 viewMatrix;
|
||||||
Vector cameraPos;
|
bool mainCamera = false;
|
||||||
Vector cameraForward;
|
|
||||||
bool bNeedsViewBuild;
|
|
||||||
};
|
};
|
||||||
} // namespace Component
|
} // namespace Component
|
||||||
} // namespace Seele
|
} // namespace Seele
|
||||||
|
|||||||
@@ -88,11 +88,11 @@ BasePass::BasePass(Gfx::PGraphics graphics, PScene scene) : RenderPass(graphics)
|
|||||||
|
|
||||||
BasePass::~BasePass() {}
|
BasePass::~BasePass() {}
|
||||||
|
|
||||||
void BasePass::beginFrame(const Component::Camera& cam) {
|
void BasePass::beginFrame(const Component::Camera& cam, const Component::Transform& transform) {
|
||||||
RenderPass::beginFrame(cam);
|
RenderPass::beginFrame(cam, transform);
|
||||||
|
|
||||||
cameraPos = cam.getCameraPosition();
|
cameraPos = transform.getPosition();
|
||||||
cameraForward = cam.getCameraForward();
|
cameraForward = transform.getForward();
|
||||||
|
|
||||||
lightCullingLayout->reset();
|
lightCullingLayout->reset();
|
||||||
opaqueCulling = lightCullingLayout->allocateDescriptorSet();
|
opaqueCulling = lightCullingLayout->allocateDescriptorSet();
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ class BasePass : public RenderPass {
|
|||||||
BasePass(BasePass&&) = default;
|
BasePass(BasePass&&) = default;
|
||||||
BasePass& operator=(BasePass&&) = default;
|
BasePass& operator=(BasePass&&) = default;
|
||||||
virtual ~BasePass();
|
virtual ~BasePass();
|
||||||
virtual void beginFrame(const Component::Camera& cam) override;
|
virtual void beginFrame(const Component::Camera& cam, const Component::Transform& transform) override;
|
||||||
virtual void render() override;
|
virtual void render() override;
|
||||||
virtual void endFrame() override;
|
virtual void endFrame() override;
|
||||||
virtual void publishOutputs() override;
|
virtual void publishOutputs() override;
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ CachedDepthPass::CachedDepthPass(Gfx::PGraphics graphics, PScene scene) : Render
|
|||||||
|
|
||||||
CachedDepthPass::~CachedDepthPass() {}
|
CachedDepthPass::~CachedDepthPass() {}
|
||||||
|
|
||||||
void CachedDepthPass::beginFrame(const Component::Camera& cam) { RenderPass::beginFrame(cam); }
|
void CachedDepthPass::beginFrame(const Component::Camera& cam, const Component::Transform& transform) { RenderPass::beginFrame(cam, transform); }
|
||||||
|
|
||||||
void CachedDepthPass::render() {
|
void CachedDepthPass::render() {
|
||||||
query->beginQuery();
|
query->beginQuery();
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ class CachedDepthPass : public RenderPass {
|
|||||||
CachedDepthPass(CachedDepthPass&&) = default;
|
CachedDepthPass(CachedDepthPass&&) = default;
|
||||||
CachedDepthPass& operator=(CachedDepthPass&&) = default;
|
CachedDepthPass& operator=(CachedDepthPass&&) = default;
|
||||||
virtual ~CachedDepthPass();
|
virtual ~CachedDepthPass();
|
||||||
virtual void beginFrame(const Component::Camera& cam) override;
|
virtual void beginFrame(const Component::Camera& cam, const Component::Transform& transform) override;
|
||||||
virtual void render() override;
|
virtual void render() override;
|
||||||
virtual void endFrame() override;
|
virtual void endFrame() override;
|
||||||
virtual void publishOutputs() override;
|
virtual void publishOutputs() override;
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ DepthCullingPass::DepthCullingPass(Gfx::PGraphics graphics, PScene scene) : Rend
|
|||||||
|
|
||||||
DepthCullingPass::~DepthCullingPass() {}
|
DepthCullingPass::~DepthCullingPass() {}
|
||||||
|
|
||||||
void DepthCullingPass::beginFrame(const Component::Camera& cam) { RenderPass::beginFrame(cam); }
|
void DepthCullingPass::beginFrame(const Component::Camera& cam, const Component::Transform& transform) { RenderPass::beginFrame(cam, transform); }
|
||||||
|
|
||||||
void DepthCullingPass::render() {
|
void DepthCullingPass::render() {
|
||||||
query->beginQuery();
|
query->beginQuery();
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ class DepthCullingPass : public RenderPass {
|
|||||||
DepthCullingPass(DepthCullingPass&&) = default;
|
DepthCullingPass(DepthCullingPass&&) = default;
|
||||||
DepthCullingPass& operator=(DepthCullingPass&&) = default;
|
DepthCullingPass& operator=(DepthCullingPass&&) = default;
|
||||||
virtual ~DepthCullingPass();
|
virtual ~DepthCullingPass();
|
||||||
virtual void beginFrame(const Component::Camera& cam) override;
|
virtual void beginFrame(const Component::Camera& cam, const Component::Transform& transform) override;
|
||||||
virtual void render() override;
|
virtual void render() override;
|
||||||
virtual void endFrame() override;
|
virtual void endFrame() override;
|
||||||
virtual void publishOutputs() override;
|
virtual void publishOutputs() override;
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ LightCullingPass::LightCullingPass(Gfx::PGraphics graphics, PScene scene) : Rend
|
|||||||
|
|
||||||
LightCullingPass::~LightCullingPass() {}
|
LightCullingPass::~LightCullingPass() {}
|
||||||
|
|
||||||
void LightCullingPass::beginFrame(const Component::Camera& cam) {
|
void LightCullingPass::beginFrame(const Component::Camera& cam, const Component::Transform& transform) {
|
||||||
RenderPass::beginFrame(cam);
|
RenderPass::beginFrame(cam, transform);
|
||||||
|
|
||||||
oLightIndexCounter->pipelineBarrier(Gfx::SE_ACCESS_MEMORY_WRITE_BIT | Gfx::SE_ACCESS_MEMORY_READ_BIT,
|
oLightIndexCounter->pipelineBarrier(Gfx::SE_ACCESS_MEMORY_WRITE_BIT | Gfx::SE_ACCESS_MEMORY_READ_BIT,
|
||||||
Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT, Gfx::SE_ACCESS_MEMORY_WRITE_BIT,
|
Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT, Gfx::SE_ACCESS_MEMORY_WRITE_BIT,
|
||||||
@@ -229,7 +229,7 @@ void LightCullingPass::setupFrustums() {
|
|||||||
numThreads = glm::ceil(glm::vec4(viewportWidth / (float)BLOCK_SIZE, viewportHeight / (float)BLOCK_SIZE, 1, 0));
|
numThreads = glm::ceil(glm::vec4(viewportWidth / (float)BLOCK_SIZE, viewportHeight / (float)BLOCK_SIZE, 1, 0));
|
||||||
numThreadGroups = glm::ceil(glm::vec4(numThreads.x / (float)BLOCK_SIZE, numThreads.y / (float)BLOCK_SIZE, 1, 0));
|
numThreadGroups = glm::ceil(glm::vec4(numThreads.x / (float)BLOCK_SIZE, numThreads.y / (float)BLOCK_SIZE, 1, 0));
|
||||||
|
|
||||||
RenderPass::beginFrame(Component::Camera());
|
RenderPass::beginFrame(Component::Camera(), Component::Transform());
|
||||||
|
|
||||||
dispatchParamsLayout = graphics->createDescriptorLayout("pDispatchParams");
|
dispatchParamsLayout = graphics->createDescriptorLayout("pDispatchParams");
|
||||||
dispatchParamsLayout->addDescriptorBinding(Gfx::DescriptorBinding{
|
dispatchParamsLayout->addDescriptorBinding(Gfx::DescriptorBinding{
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ class LightCullingPass : public RenderPass {
|
|||||||
LightCullingPass(LightCullingPass&&) = default;
|
LightCullingPass(LightCullingPass&&) = default;
|
||||||
LightCullingPass& operator=(LightCullingPass&&) = default;
|
LightCullingPass& operator=(LightCullingPass&&) = default;
|
||||||
virtual ~LightCullingPass();
|
virtual ~LightCullingPass();
|
||||||
virtual void beginFrame(const Component::Camera& cam) override;
|
virtual void beginFrame(const Component::Camera& cam, const Component::Transform& transform) override;
|
||||||
virtual void render() override;
|
virtual void render() override;
|
||||||
virtual void endFrame() override;
|
virtual void endFrame() override;
|
||||||
virtual void publishOutputs() override;
|
virtual void publishOutputs() override;
|
||||||
|
|||||||
@@ -65,11 +65,11 @@ RayTracingPass::RayTracingPass(Gfx::PGraphics graphics, PScene scene) : RenderPa
|
|||||||
}
|
}
|
||||||
|
|
||||||
static uint32 pass = 0;
|
static uint32 pass = 0;
|
||||||
static Component::Camera lastCam;
|
static Component::Transform lastCam;
|
||||||
void RayTracingPass::beginFrame(const Component::Camera& cam) {
|
void RayTracingPass::beginFrame(const Component::Camera& cam, const Component::Transform& transform) {
|
||||||
RenderPass::beginFrame(cam);
|
RenderPass::beginFrame(cam, transform);
|
||||||
if (lastCam.getCameraPosition() != cam.getCameraPosition() || lastCam.getCameraForward() != cam.getCameraForward()) {
|
if (lastCam.getPosition() != transform.getPosition() || lastCam.getForward() != transform.getForward()) {
|
||||||
lastCam = cam;
|
lastCam = transform;
|
||||||
pass = 0;
|
pass = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ class RayTracingPass : public RenderPass {
|
|||||||
RayTracingPass(Gfx::PGraphics graphics, PScene scene);
|
RayTracingPass(Gfx::PGraphics graphics, PScene scene);
|
||||||
RayTracingPass(RayTracingPass&& other) = default;
|
RayTracingPass(RayTracingPass&& other) = default;
|
||||||
RayTracingPass& operator=(RayTracingPass&& other) = default;
|
RayTracingPass& operator=(RayTracingPass&& other) = default;
|
||||||
virtual void beginFrame(const Component::Camera& cam) override;
|
virtual void beginFrame(const Component::Camera& cam, const Component::Transform& transform) override;
|
||||||
virtual void render() override;
|
virtual void render() override;
|
||||||
virtual void endFrame() override;
|
virtual void endFrame() override;
|
||||||
virtual void publishOutputs() override;
|
virtual void publishOutputs() override;
|
||||||
|
|||||||
@@ -23,9 +23,9 @@ class RenderGraph {
|
|||||||
pass->createRenderPass();
|
pass->createRenderPass();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void render(const Component::Camera& cam) {
|
void render(const Component::Camera& cam, const Component::Transform& transform) {
|
||||||
for (auto& pass : passes) {
|
for (auto& pass : passes) {
|
||||||
pass->beginFrame(cam);
|
pass->beginFrame(cam, transform);
|
||||||
}
|
}
|
||||||
for (auto& pass : passes) {
|
for (auto& pass : passes) {
|
||||||
pass->render();
|
pass->render();
|
||||||
|
|||||||
@@ -23,9 +23,9 @@ RenderPass::RenderPass(Gfx::PGraphics graphics) : graphics(graphics) {
|
|||||||
|
|
||||||
RenderPass::~RenderPass() {}
|
RenderPass::~RenderPass() {}
|
||||||
|
|
||||||
void RenderPass::beginFrame(const Component::Camera& cam) {
|
void RenderPass::beginFrame(const Component::Camera& cam, const Component::Transform& transform) {
|
||||||
auto screenDim = Vector2(static_cast<float>(viewport->getWidth()), static_cast<float>(viewport->getHeight()));
|
auto screenDim = Vector2(static_cast<float>(viewport->getWidth()), static_cast<float>(viewport->getHeight()));
|
||||||
Matrix4 cameraMatrix = cam.getViewMatrix();
|
Matrix4 cameraMatrix = cam.viewMatrix;
|
||||||
Matrix4 projectionMatrix = viewport->getProjectionMatrix();
|
Matrix4 projectionMatrix = viewport->getProjectionMatrix();
|
||||||
viewParams = {
|
viewParams = {
|
||||||
.viewMatrix = cameraMatrix,
|
.viewMatrix = cameraMatrix,
|
||||||
@@ -34,8 +34,8 @@ void RenderPass::beginFrame(const Component::Camera& cam) {
|
|||||||
.inverseProjection = glm::inverse(projectionMatrix),
|
.inverseProjection = glm::inverse(projectionMatrix),
|
||||||
.viewProjectionMatrix = projectionMatrix * cameraMatrix,
|
.viewProjectionMatrix = projectionMatrix * cameraMatrix,
|
||||||
.inverseViewProjectionMatrix = glm::inverse(projectionMatrix * cameraMatrix),
|
.inverseViewProjectionMatrix = glm::inverse(projectionMatrix * cameraMatrix),
|
||||||
.cameraPosition_WS = Vector4(cam.getCameraPosition(), 1),
|
.cameraPosition_WS = Vector4(transform.getPosition(), 1),
|
||||||
.cameraForward_WS = Vector4(cam.getCameraForward(), 1),
|
.cameraForward_WS = Vector4(transform.getForward(), 1),
|
||||||
.screenDimensions = screenDim,
|
.screenDimensions = screenDim,
|
||||||
.invScreenDimensions = 1.0f / screenDim,
|
.invScreenDimensions = 1.0f / screenDim,
|
||||||
.frameIndex = Gfx::getCurrentFrameIndex(),
|
.frameIndex = Gfx::getCurrentFrameIndex(),
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ class RenderPass {
|
|||||||
RenderPass(RenderPass&&) = default;
|
RenderPass(RenderPass&&) = default;
|
||||||
RenderPass& operator=(RenderPass&&) = default;
|
RenderPass& operator=(RenderPass&&) = default;
|
||||||
virtual ~RenderPass();
|
virtual ~RenderPass();
|
||||||
virtual void beginFrame(const Component::Camera& cam);
|
virtual void beginFrame(const Component::Camera& cam, const Component::Transform& transform);
|
||||||
virtual void render() = 0;
|
virtual void render() = 0;
|
||||||
virtual void endFrame() = 0;
|
virtual void endFrame() = 0;
|
||||||
virtual void publishOutputs() = 0;
|
virtual void publishOutputs() = 0;
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ ToneMappingPass::ToneMappingPass(Gfx::PGraphics graphics) : RenderPass(graphics)
|
|||||||
|
|
||||||
ToneMappingPass::~ToneMappingPass() {}
|
ToneMappingPass::~ToneMappingPass() {}
|
||||||
|
|
||||||
void ToneMappingPass::beginFrame(const Component::Camera& cam) { RenderPass::beginFrame(cam); }
|
void ToneMappingPass::beginFrame(const Component::Camera& cam, const Component::Transform& transform) { RenderPass::beginFrame(cam, transform); }
|
||||||
|
|
||||||
void ToneMappingPass::render() {
|
void ToneMappingPass::render() {
|
||||||
hdrInputTexture.getTexture()->changeLayout(Gfx::SE_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, Gfx::SE_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
|
hdrInputTexture.getTexture()->changeLayout(Gfx::SE_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, Gfx::SE_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ class ToneMappingPass : public RenderPass {
|
|||||||
ToneMappingPass(ToneMappingPass&&) = default;
|
ToneMappingPass(ToneMappingPass&&) = default;
|
||||||
ToneMappingPass& operator=(ToneMappingPass&&) = default;
|
ToneMappingPass& operator=(ToneMappingPass&&) = default;
|
||||||
virtual ~ToneMappingPass();
|
virtual ~ToneMappingPass();
|
||||||
virtual void beginFrame(const Component::Camera& cam) override;
|
virtual void beginFrame(const Component::Camera& cam, const Component::Transform& transform) override;
|
||||||
virtual void render() override;
|
virtual void render() override;
|
||||||
virtual void endFrame() override;
|
virtual void endFrame() override;
|
||||||
virtual void publishOutputs() override;
|
virtual void publishOutputs() override;
|
||||||
|
|||||||
@@ -53,8 +53,8 @@ UIPass::UIPass(Gfx::PGraphics graphics, UI::PSystem system) : RenderPass(graphic
|
|||||||
|
|
||||||
UIPass::~UIPass() {}
|
UIPass::~UIPass() {}
|
||||||
|
|
||||||
void UIPass::beginFrame(const Component::Camera& cam) {
|
void UIPass::beginFrame(const Component::Camera& cam, const Component::Transform& transform) {
|
||||||
RenderPass::beginFrame(cam);
|
RenderPass::beginFrame(cam, transform);
|
||||||
glyphs.clear();
|
glyphs.clear();
|
||||||
usedTextures.clear();
|
usedTextures.clear();
|
||||||
elements.clear();
|
elements.clear();
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ class UIPass : public RenderPass {
|
|||||||
UIPass(UIPass&&) = default;
|
UIPass(UIPass&&) = default;
|
||||||
UIPass& operator=(UIPass&&) = default;
|
UIPass& operator=(UIPass&&) = default;
|
||||||
virtual ~UIPass();
|
virtual ~UIPass();
|
||||||
virtual void beginFrame(const Component::Camera& cam) override;
|
virtual void beginFrame(const Component::Camera& cam, const Component::Transform& transform) override;
|
||||||
virtual void render() override;
|
virtual void render() override;
|
||||||
virtual void endFrame() override;
|
virtual void endFrame() override;
|
||||||
virtual void publishOutputs() override;
|
virtual void publishOutputs() override;
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ VisibilityPass::VisibilityPass(Gfx::PGraphics graphics) : RenderPass(graphics) {
|
|||||||
|
|
||||||
VisibilityPass::~VisibilityPass() {}
|
VisibilityPass::~VisibilityPass() {}
|
||||||
|
|
||||||
void VisibilityPass::beginFrame(const Component::Camera& cam) {
|
void VisibilityPass::beginFrame(const Component::Camera& cam, const Component::Transform& transform) {
|
||||||
RenderPass::beginFrame(cam);
|
RenderPass::beginFrame(cam, transform);
|
||||||
cullingBuffer->rotateBuffer(VertexData::getMeshletCount() * sizeof(VertexData::MeshletCullingInfo), true);
|
cullingBuffer->rotateBuffer(VertexData::getMeshletCount() * sizeof(VertexData::MeshletCullingInfo), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ class VisibilityPass : public RenderPass {
|
|||||||
VisibilityPass(VisibilityPass&&) = default;
|
VisibilityPass(VisibilityPass&&) = default;
|
||||||
VisibilityPass& operator=(VisibilityPass&&) = default;
|
VisibilityPass& operator=(VisibilityPass&&) = default;
|
||||||
virtual ~VisibilityPass();
|
virtual ~VisibilityPass();
|
||||||
virtual void beginFrame(const Component::Camera& cam) override;
|
virtual void beginFrame(const Component::Camera& cam, const Component::Transform& transform) override;
|
||||||
virtual void render() override;
|
virtual void render() override;
|
||||||
virtual void endFrame() override;
|
virtual void endFrame() override;
|
||||||
virtual void publishOutputs() override;
|
virtual void publishOutputs() override;
|
||||||
|
|||||||
@@ -3,8 +3,12 @@
|
|||||||
using namespace Seele;
|
using namespace Seele;
|
||||||
using namespace Seele::System;
|
using namespace Seele::System;
|
||||||
|
|
||||||
CameraUpdater::CameraUpdater(PScene scene) : ComponentSystem(scene) {}
|
CameraUpdater::CameraUpdater(PScene scene) : ComponentSystem<Component::Camera, Component::Transform>(scene) {}
|
||||||
|
|
||||||
CameraUpdater::~CameraUpdater() {}
|
CameraUpdater::~CameraUpdater() {}
|
||||||
|
|
||||||
void CameraUpdater::update(Component::Camera& camera) { camera.buildViewMatrix(); }
|
void CameraUpdater::update(Component::Camera& camera, Component::Transform& transform) {
|
||||||
|
Vector eyePos = transform.getPosition();
|
||||||
|
Vector lookAt = eyePos + transform.getForward();
|
||||||
|
camera.viewMatrix = glm::lookAt(eyePos, lookAt, Vector(0, 1, 0));
|
||||||
|
}
|
||||||
|
|||||||
@@ -4,12 +4,12 @@
|
|||||||
|
|
||||||
namespace Seele {
|
namespace Seele {
|
||||||
namespace System {
|
namespace System {
|
||||||
class CameraUpdater : public ComponentSystem<Component::Camera> {
|
class CameraUpdater : public ComponentSystem<Component::Camera, Component::Transform> {
|
||||||
public:
|
public:
|
||||||
CameraUpdater(PScene scene);
|
CameraUpdater(PScene scene);
|
||||||
virtual ~CameraUpdater();
|
virtual ~CameraUpdater();
|
||||||
|
|
||||||
virtual void update(Component::Camera& camera);
|
virtual void update(Component::Camera& camera, Component::Transform& transform);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -65,14 +65,17 @@ void GameView::prepareRender() {}
|
|||||||
|
|
||||||
void GameView::render() {
|
void GameView::render() {
|
||||||
Component::Camera cam;
|
Component::Camera cam;
|
||||||
scene->view<Component::Camera>([&cam](Component::Camera& c) {
|
Component::Transform transform;
|
||||||
if (c.mainCamera)
|
scene->view<Component::Camera, Component::Transform>([&cam, &transform](Component::Camera& c, Component::Transform& t) {
|
||||||
|
if (c.mainCamera) {
|
||||||
cam = c;
|
cam = c;
|
||||||
|
transform = t;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
if (getGlobals().useRayTracing && graphics->supportRayTracing()) {
|
if (getGlobals().useRayTracing && graphics->supportRayTracing()) {
|
||||||
rayTracingGraph.render(cam);
|
rayTracingGraph.render(cam, transform);
|
||||||
} else {
|
} else {
|
||||||
renderGraph.render(cam);
|
renderGraph.render(cam, transform);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user