2020-08-11 12:07:21 -04:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <cstddef>
|
|
|
|
#include <functional>
|
|
|
|
#include <vector>
|
|
|
|
|
2022-08-15 11:10:06 -04:00
|
|
|
#include "assetptr.hpp"
|
2020-08-11 12:07:21 -04:00
|
|
|
#include "gfx_buffer.hpp"
|
|
|
|
#include "gfx_framebuffer.hpp"
|
2022-08-15 11:10:06 -04:00
|
|
|
#include "gfx_pipeline.hpp"
|
|
|
|
#include "gfx_renderpass.hpp"
|
|
|
|
#include "gfx_texture.hpp"
|
2020-08-11 12:07:21 -04:00
|
|
|
#include "matrix.hpp"
|
|
|
|
#include "object.hpp"
|
2022-08-15 11:10:06 -04:00
|
|
|
#include "pass.hpp"
|
2020-08-11 12:07:21 -04:00
|
|
|
|
|
|
|
class Texture;
|
|
|
|
class Mesh;
|
|
|
|
|
|
|
|
struct SelectableObject {
|
|
|
|
enum class Type {
|
|
|
|
Object,
|
|
|
|
Handle
|
2022-02-21 00:15:24 -05:00
|
|
|
} type = Type::Object;
|
2022-08-15 11:10:06 -04:00
|
|
|
|
2020-08-11 12:07:21 -04:00
|
|
|
Matrix4x4 axis_model;
|
2022-08-15 11:10:06 -04:00
|
|
|
|
2020-08-11 12:07:21 -04:00
|
|
|
enum class Axis {
|
|
|
|
X,
|
|
|
|
Y,
|
|
|
|
Z
|
2022-02-21 00:15:24 -05:00
|
|
|
} axis = Axis::X;
|
2022-08-15 11:10:06 -04:00
|
|
|
|
2020-08-11 12:07:21 -04:00
|
|
|
enum class RenderType {
|
|
|
|
Mesh,
|
|
|
|
Sphere
|
2022-02-21 00:15:24 -05:00
|
|
|
} render_type = RenderType::Mesh;
|
2022-08-15 11:10:06 -04:00
|
|
|
|
2020-08-11 12:07:21 -04:00
|
|
|
float sphere_size = 1.0f;
|
2022-08-15 11:10:06 -04:00
|
|
|
|
2022-02-21 00:15:24 -05:00
|
|
|
prism::Object object = prism::NullObject;
|
2020-08-11 12:07:21 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
class DebugPass : public Pass {
|
|
|
|
public:
|
|
|
|
void initialize() override;
|
|
|
|
|
2021-02-17 01:32:46 -05:00
|
|
|
void create_render_target_resources(RenderTarget& target) override;
|
|
|
|
|
2022-08-15 11:10:06 -04:00
|
|
|
void render_scene(Scene& scene, GFXCommandBuffer* commandBuffer) override;
|
2020-08-11 12:07:21 -04:00
|
|
|
|
2022-02-21 00:15:24 -05:00
|
|
|
void get_selected_object(int x, int y, const std::function<void(SelectableObject)>& callback);
|
2021-05-12 09:56:44 -04:00
|
|
|
void draw_arrow(GFXCommandBuffer* commandBuffer, prism::float3 color, Matrix4x4 model);
|
2022-08-15 11:10:06 -04:00
|
|
|
|
2020-08-11 12:07:21 -04:00
|
|
|
GFXTexture* get_requested_texture(PassTextureType type) override {
|
2022-08-15 11:10:06 -04:00
|
|
|
if (type == PassTextureType::SelectionSobel)
|
2020-08-11 12:07:21 -04:00
|
|
|
return sobelTexture;
|
2022-08-15 11:10:06 -04:00
|
|
|
|
2020-08-11 12:07:21 -04:00
|
|
|
return nullptr;
|
|
|
|
}
|
2022-08-15 11:10:06 -04:00
|
|
|
|
2020-08-11 12:07:21 -04:00
|
|
|
GFXTexture* selectTexture = nullptr;
|
|
|
|
GFXTexture* selectDepthTexture = nullptr;
|
|
|
|
GFXTexture* sobelTexture = nullptr;
|
|
|
|
|
2022-05-21 17:46:27 -04:00
|
|
|
prism::Object selected_object = prism::NullObject;
|
2022-08-15 11:10:06 -04:00
|
|
|
|
2020-08-11 12:07:21 -04:00
|
|
|
private:
|
|
|
|
void createOffscreenResources();
|
2022-08-15 11:10:06 -04:00
|
|
|
|
2020-08-14 19:56:27 -04:00
|
|
|
prism::Extent extent;
|
2022-08-15 11:10:06 -04:00
|
|
|
|
2020-08-11 12:07:21 -04:00
|
|
|
std::vector<SelectableObject> selectable_objects;
|
2022-08-15 11:10:06 -04:00
|
|
|
|
2020-08-11 12:07:21 -04:00
|
|
|
AssetPtr<Texture> pointTexture, spotTexture, sunTexture, probeTexture;
|
|
|
|
AssetPtr<Mesh> cubeMesh, arrowMesh, sphereMesh;
|
|
|
|
|
|
|
|
GFXPipeline* primitive_pipeline = nullptr;
|
|
|
|
GFXPipeline* arrow_pipeline = nullptr;
|
|
|
|
GFXPipeline* billboard_pipeline = nullptr;
|
|
|
|
|
|
|
|
GFXPipeline* selectPipeline = nullptr;
|
|
|
|
GFXRenderPass* selectRenderPass = nullptr;
|
|
|
|
GFXFramebuffer* selectFramebuffer = nullptr;
|
|
|
|
GFXBuffer* selectBuffer = nullptr;
|
2022-08-15 11:10:06 -04:00
|
|
|
|
2020-08-11 12:07:21 -04:00
|
|
|
GFXPipeline* sobelPipeline = nullptr;
|
|
|
|
GFXFramebuffer* sobelFramebuffer = nullptr;
|
|
|
|
GFXRenderPass* sobelRenderPass = nullptr;
|
2021-02-03 06:55:46 -05:00
|
|
|
|
|
|
|
GFXBuffer* scene_info_buffer = nullptr;
|
2020-08-11 12:07:21 -04:00
|
|
|
};
|