improved model loading and added model component
This commit is contained in:
@@ -2,10 +2,8 @@
|
||||
#version 450 core
|
||||
|
||||
layout(location = 0) in vec3 a_Position;
|
||||
layout(location = 1) in vec4 a_Color;
|
||||
layout(location = 2) in vec3 a_Normal;
|
||||
layout(location = 3) in vec2 a_TexCoord;
|
||||
layout(location = 4) in int a_EntityID;
|
||||
layout(location = 1) in vec3 a_Normal;
|
||||
layout(location = 2) in vec2 a_TexCoord;
|
||||
|
||||
layout(std140, binding = 0) uniform Camera
|
||||
{
|
||||
@@ -20,25 +18,20 @@ layout(std140, binding = 1) uniform Transform
|
||||
|
||||
struct VertexOutput
|
||||
{
|
||||
vec4 Color;
|
||||
vec2 TexCoord;
|
||||
vec3 Normal;
|
||||
vec3 ViewPos;
|
||||
};
|
||||
|
||||
layout (location = 0) out VertexOutput Output;
|
||||
layout (location = 4) out flat int v_EntityID;
|
||||
layout (location = 5) out vec4 v_Pos;
|
||||
|
||||
void main()
|
||||
{
|
||||
Output.Color = a_Color;
|
||||
Output.TexCoord = a_TexCoord;
|
||||
Output.Normal = mat3(transpose(inverse(u_Transform))) * a_Normal;
|
||||
Output.ViewPos = u_ViewPosition;
|
||||
|
||||
v_EntityID = a_EntityID;
|
||||
|
||||
v_Pos = u_Transform * vec4(a_Position, 1.0);
|
||||
gl_Position = u_ViewProjection * v_Pos;
|
||||
}
|
||||
@@ -49,9 +42,22 @@ void main()
|
||||
layout (location = 0) out vec4 color;
|
||||
layout (location = 1) out int color2;
|
||||
|
||||
layout (std140, binding = 2) uniform Material
|
||||
{
|
||||
vec4 u_Albedo;
|
||||
float u_Roughness;
|
||||
float u_Metallic;
|
||||
float u_AmbientStrength;
|
||||
float u_SpecularStrength;
|
||||
};
|
||||
|
||||
layout(std140, binding = 3) uniform EditorID
|
||||
{
|
||||
int u_EntityID;
|
||||
};
|
||||
|
||||
struct VertexOutput
|
||||
{
|
||||
vec4 Color;
|
||||
vec2 TexCoord;
|
||||
vec3 Normal;
|
||||
vec3 ViewPos;
|
||||
@@ -67,8 +73,7 @@ void main()
|
||||
vec3 lightColor = vec3(1.0f, 1.0f, 1.0f);
|
||||
|
||||
// Ambiant lighting
|
||||
float ambientStrength = 0.8;
|
||||
vec3 ambient = ambientStrength * lightColor;
|
||||
vec3 ambient = lightColor * u_AmbientStrength;
|
||||
|
||||
// Diffuse lighting
|
||||
vec3 norm = normalize(Input.Normal);
|
||||
@@ -78,16 +83,19 @@ void main()
|
||||
vec3 diffuse = diff * lightColor;
|
||||
|
||||
// Specular highlight
|
||||
float specularStrength = 0.5;
|
||||
vec3 viewDir = normalize(Input.ViewPos - v_Pos.xyz); // .xyz here too
|
||||
vec3 reflectDir = reflect(-lightDir, norm);
|
||||
|
||||
float spec = pow(max(dot(viewDir, reflectDir), 0.0), 32);
|
||||
vec3 specular = specularStrength * spec * lightColor;
|
||||
float shininess = mix(2.0, 256.0, 1.0 - u_Roughness);
|
||||
float spec = pow(max(dot(viewDir, reflectDir), 0.0), shininess);
|
||||
vec3 specularColor = mix(vec3(1.0), u_Albedo.rgb, u_Metallic);
|
||||
vec3 specular = u_SpecularStrength * spec * lightColor * specularColor;
|
||||
|
||||
vec3 result = (ambient + diffuse + specular) * Input.Color.rgb; // objectColor → Input.Color.rgb
|
||||
// Total
|
||||
//vec3 result = (ambient + diffuse + specular) * Input.Color.rgb; // objectColor → Input.Color.rgb
|
||||
vec3 result = (ambient + diffuse + specular) * u_Albedo.rgb; // objectColor → Input.Color.rgb
|
||||
|
||||
// Output
|
||||
color = vec4(result, 1.0); // vec3 → vec4
|
||||
color2 = v_EntityID;
|
||||
color = vec4(result, u_Albedo.w); // vec3 → vec4
|
||||
color2 = u_EntityID;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
#ifndef EDITOR_HPP
|
||||
#define EDITOR_HPP
|
||||
|
||||
#include <X11/X.h>
|
||||
#include <open_engine.hpp>
|
||||
|
||||
#include "open_engine/fastgltf.hpp"
|
||||
#include "open_engine/logging.hpp"
|
||||
#include "open_engine/ref_scope.hpp"
|
||||
#include "open_engine/renderer/model3d.hpp"
|
||||
#include "open_engine/renderer/renderer3d.hpp"
|
||||
#include "open_engine/scene/components.hpp"
|
||||
#include "panels/content_browser.hpp"
|
||||
@@ -135,11 +135,16 @@ namespace OpenEngine {
|
||||
// ============================================================
|
||||
|
||||
Entity cube3 = scene->CreateEntity("glb");
|
||||
Entity cube4 = scene->CreateEntity("glb2");
|
||||
cube3.AddComponent<TransformComponent>();
|
||||
cube4.AddComponent<TransformComponent>();
|
||||
|
||||
Ref<Mesh> test = TestGLTF();
|
||||
Ref<Model3D> model = Model3D::Create("./assets/models/cubes.glb");
|
||||
Ref<Model3D> model2 = Model3D::Create("./assets/models/cube_legs.glb");
|
||||
Ref<Model3D> monkey = Model3D::Create("./assets/models/monkey.glb");
|
||||
|
||||
cube3.AddComponent<MeshComponent>(CreateMesh(test->vertices, test->indices, (uint32_t)cube3));
|
||||
cube3.AddComponent<ModelComponent>(model);
|
||||
cube4.AddComponent<ModelComponent>(monkey);
|
||||
|
||||
/*
|
||||
auto view = scene->GetRegistry().view<TagComponent>();
|
||||
|
||||
@@ -22,6 +22,7 @@ namespace OpenEngine {
|
||||
void SphereShapeOnImGuiRender(entt::registry& registry, entt::entity entity);
|
||||
void BoxShapeOnImGuiRender(entt::registry& registry, entt::entity entity);
|
||||
void PlaneShapeOnImGuiRender(entt::registry& registry, entt::entity entity);
|
||||
void ModelOnImGuiRender(entt::registry& registry, entt::entity entity);
|
||||
}
|
||||
|
||||
#endif // EDITOR_COMPONENT_HPP
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "open_engine/renderer/renderer3d.hpp"
|
||||
#include "open_engine/scene/components.hpp"
|
||||
#include <Jolt/Physics/Body/MotionType.h>
|
||||
#include <cstdint>
|
||||
#include <editor_component.hpp>
|
||||
#include <entt/entity/fwd.hpp>
|
||||
#include <glm/gtc/type_ptr.hpp>
|
||||
@@ -295,4 +296,33 @@ namespace OpenEngine {
|
||||
"%.2f",
|
||||
ImGuiSliderFlags_AlwaysClamp);
|
||||
}
|
||||
|
||||
void ModelOnImGuiRender(entt::registry& registry, entt::entity entity)
|
||||
{
|
||||
auto& model_comp = registry.get<ModelComponent>(entity);
|
||||
|
||||
bool opened = ImGui::TreeNodeEx(
|
||||
(void*)(intptr_t)entity,
|
||||
ImGuiTreeNodeFlags_None,
|
||||
"Meshes",
|
||||
nullptr
|
||||
);
|
||||
|
||||
if (opened) {
|
||||
unsigned int i = 0;
|
||||
for (auto& mesh : model_comp.model->GetMeshes())
|
||||
ImGui::Text("Mesh: %i", i++);
|
||||
|
||||
|
||||
ImGui::PushStyleColor(ImGuiCol_ChildBg, {1, 1, 1, 1});
|
||||
if (ImGui::BeginChild("Material list")) {
|
||||
for (auto& mesh : model_comp.model->GetMeshes())
|
||||
ImGui::Text("Material: %s", mesh.material.name.c_str());
|
||||
ImGui::EndChild();
|
||||
}
|
||||
ImGui::PopStyleColor();
|
||||
|
||||
ImGui::TreePop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ namespace OpenEngine {
|
||||
RegisterDrawer<SphereShapeComponent>("Sphere Shape", &SphereShapeOnImGuiRender);
|
||||
RegisterDrawer<BoxShapeComponent>("Box Shape", &BoxShapeOnImGuiRender);
|
||||
RegisterDrawer<PlaneShapeComponent>("Plane Shape", &PlaneShapeOnImGuiRender);
|
||||
RegisterDrawer<ModelComponent>("Model", &ModelOnImGuiRender);
|
||||
|
||||
scene = context;
|
||||
selected_context = {};
|
||||
@@ -81,6 +82,11 @@ namespace OpenEngine {
|
||||
selected_context.AddComponent<PlaneShapeComponent>();
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
if (!selected_context.HasComponent<ModelComponent>())
|
||||
if (ImGui::MenuItem("Model")) {
|
||||
selected_context.AddComponent<ModelComponent>();
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
}
|
||||
|
||||
void EntityPopup(Ref<Scene>& scene)
|
||||
|
||||
34
imgui.ini
34
imgui.ini
@@ -1,6 +1,6 @@
|
||||
[Window][WindowOverViewport_11111111]
|
||||
Pos=0,24
|
||||
Size=2560,1371
|
||||
Size=1272,1363
|
||||
Collapsed=0
|
||||
|
||||
[Window][Debug##Default]
|
||||
@@ -10,31 +10,31 @@ Collapsed=0
|
||||
|
||||
[Window][Statistics]
|
||||
Pos=0,24
|
||||
Size=224,439
|
||||
Size=409,437
|
||||
Collapsed=0
|
||||
DockId=0x00000003,0
|
||||
|
||||
[Window][Properties]
|
||||
Pos=2110,24
|
||||
Size=450,810
|
||||
Pos=822,24
|
||||
Size=450,805
|
||||
Collapsed=0
|
||||
DockId=0x00000007,0
|
||||
|
||||
[Window][Viewport]
|
||||
Pos=226,61
|
||||
Size=1882,964
|
||||
Pos=411,61
|
||||
Size=409,956
|
||||
Collapsed=0
|
||||
DockId=0x00000012,0
|
||||
|
||||
[Window][Dear ImGui Demo]
|
||||
Pos=2110,836
|
||||
Size=450,559
|
||||
Pos=822,831
|
||||
Size=450,556
|
||||
Collapsed=0
|
||||
DockId=0x00000008,0
|
||||
|
||||
[Window][Scene]
|
||||
Pos=0,465
|
||||
Size=224,930
|
||||
Pos=0,463
|
||||
Size=409,924
|
||||
Collapsed=0
|
||||
DockId=0x00000004,0
|
||||
|
||||
@@ -143,8 +143,8 @@ Collapsed=0
|
||||
DockId=0x00000012,1
|
||||
|
||||
[Window][Assets]
|
||||
Pos=226,1027
|
||||
Size=1882,368
|
||||
Pos=411,1019
|
||||
Size=409,368
|
||||
Collapsed=0
|
||||
DockId=0x0000000C,0
|
||||
|
||||
@@ -155,18 +155,18 @@ Collapsed=0
|
||||
DockId=0x0000000F,0
|
||||
|
||||
[Window][##play_state_bar]
|
||||
Pos=226,24
|
||||
Size=1882,35
|
||||
Pos=411,24
|
||||
Size=409,35
|
||||
Collapsed=0
|
||||
DockId=0x00000011,0
|
||||
|
||||
[Docking][Data]
|
||||
DockSpace ID=0x08BD597D Window=0x1BBC0F80 Pos=0,24 Size=2560,1371 Split=X
|
||||
DockSpace ID=0x08BD597D Window=0x1BBC0F80 Pos=0,24 Size=1272,1363 Split=X
|
||||
DockNode ID=0x00000005 Parent=0x08BD597D SizeRef=820,1386 Split=X
|
||||
DockNode ID=0x00000001 Parent=0x00000005 SizeRef=224,1386 Split=Y Selected=0xE601B12F
|
||||
DockNode ID=0x00000001 Parent=0x00000005 SizeRef=409,1386 Split=Y Selected=0xE601B12F
|
||||
DockNode ID=0x00000003 Parent=0x00000001 SizeRef=255,417 Selected=0x553E127E
|
||||
DockNode ID=0x00000004 Parent=0x00000001 SizeRef=255,883 Selected=0xE601B12F
|
||||
DockNode ID=0x00000002 Parent=0x00000005 SizeRef=594,1386 Split=Y Selected=0xC450F867
|
||||
DockNode ID=0x00000002 Parent=0x00000005 SizeRef=409,1386 Split=Y Selected=0xC450F867
|
||||
DockNode ID=0x00000009 Parent=0x00000002 SizeRef=483,784 Split=Y Selected=0xC450F867
|
||||
DockNode ID=0x0000000B Parent=0x00000009 SizeRef=409,932 Split=X Selected=0xC450F867
|
||||
DockNode ID=0x0000000D Parent=0x0000000B SizeRef=1080,993 Split=Y Selected=0xC450F867
|
||||
|
||||
38
open_engine/include/open_engine/gltf/gltf_model3d.hpp
Normal file
38
open_engine/include/open_engine/gltf/gltf_model3d.hpp
Normal file
@@ -0,0 +1,38 @@
|
||||
#ifndef GLTF_MODEL3D_HPP
|
||||
#define GLTF_MODEL3D_HPP
|
||||
|
||||
#include "open_engine/renderer/model3d.hpp"
|
||||
|
||||
#include <fastgltf/types.hpp>
|
||||
#include <vector>
|
||||
#include <cstddef>
|
||||
|
||||
namespace OpenEngine {
|
||||
|
||||
class GLTFModel3D : public Model3D
|
||||
{
|
||||
public:
|
||||
GLTFModel3D(const char* path);
|
||||
|
||||
void loadPrimitive(fastgltf::Asset& asset,
|
||||
fastgltf::Primitive& primitive,
|
||||
Mesh& out);
|
||||
virtual const Mesh& GetMesh(int index) const override;
|
||||
virtual const std::vector<Mesh>& GetMeshes() const override;
|
||||
|
||||
virtual size_t GetMeshCount() const override { return meshes.size(); };
|
||||
|
||||
virtual std::vector<Mesh>::iterator begin() override { return meshes.begin(); };
|
||||
virtual std::vector<Mesh>::iterator end() override { return meshes.end(); };
|
||||
|
||||
virtual std::vector<Mesh>::const_iterator begin() const override { return meshes.cbegin(); };
|
||||
virtual std::vector<Mesh>::const_iterator end() const override { return meshes.end(); };
|
||||
|
||||
private:
|
||||
std::string name;
|
||||
std::vector<Mesh> meshes;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // GLTF_MODEL3D_HPP
|
||||
69
open_engine/include/open_engine/renderer/model3d.hpp
Normal file
69
open_engine/include/open_engine/renderer/model3d.hpp
Normal file
@@ -0,0 +1,69 @@
|
||||
#ifndef MODEL3D_HPP
|
||||
#define MODEL3D_HPP
|
||||
|
||||
#include "open_engine/core/uuid.hpp"
|
||||
#include "open_engine/renderer/vertex_array.hpp"
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <glm/glm.hpp>
|
||||
#include <vector>
|
||||
|
||||
namespace OpenEngine {
|
||||
|
||||
struct Material
|
||||
{
|
||||
glm::vec4 albedo = { 1.0f, 0.0f, 0.8f, 1.0f };
|
||||
float roughness = 1.0f;
|
||||
float metallic = 1.0f;
|
||||
float ambient_strength = 1.0f;
|
||||
float specular_strength = 1.0f;
|
||||
std::string name = "un-named material";
|
||||
};
|
||||
|
||||
struct MeshVertex
|
||||
{
|
||||
glm::vec3 position;
|
||||
glm::vec3 normal;
|
||||
glm::vec2 text_coords;
|
||||
};
|
||||
|
||||
struct Mesh
|
||||
{
|
||||
UUID uuid;
|
||||
|
||||
Material material;
|
||||
|
||||
Ref<VertexArray> vertex_array;
|
||||
Ref<VertexBuffer> vertex_buffer;
|
||||
Ref<IndexBuffer> index_buffer;
|
||||
|
||||
// TODO: Make them a ptr or something
|
||||
std::vector<MeshVertex> vertices;
|
||||
std::vector<uint32_t> indices;
|
||||
};
|
||||
|
||||
// TODO: Model3D.Instanciate();
|
||||
// Or Model3D.GetVertices() {return iterateaccessorwithindex bla bla bla}
|
||||
// What data should Model3D hold in the end if it is not a renderable object?
|
||||
class Model3D
|
||||
{
|
||||
public:
|
||||
virtual ~Model3D() = default;
|
||||
|
||||
static Ref<Model3D> Create(const char* path);
|
||||
|
||||
virtual const Mesh& GetMesh(int index) const = 0;
|
||||
virtual const std::vector<Mesh>& GetMeshes() const = 0;
|
||||
|
||||
virtual size_t GetMeshCount() const = 0;
|
||||
|
||||
virtual std::vector<Mesh>::iterator begin() = 0;
|
||||
virtual std::vector<Mesh>::iterator end() = 0;
|
||||
|
||||
virtual std::vector<Mesh>::const_iterator begin() const = 0;
|
||||
virtual std::vector<Mesh>::const_iterator end() const = 0;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // MODEL3D_HPP
|
||||
@@ -2,9 +2,8 @@
|
||||
#define RENDERER3D_HPP
|
||||
|
||||
#include "open_engine/renderer/editor_camera.hpp"
|
||||
#include "open_engine/renderer/vertex_array.hpp"
|
||||
#include "open_engine/renderer/buffer.hpp"
|
||||
#include "open_engine/scene/scene_camera.hpp"
|
||||
#include "open_engine/renderer/model3d.hpp"
|
||||
#include <cstdint>
|
||||
|
||||
namespace OpenEngine {
|
||||
@@ -18,40 +17,12 @@ namespace OpenEngine {
|
||||
Cube
|
||||
};
|
||||
|
||||
struct MeshVertex
|
||||
{
|
||||
glm::vec3 position;
|
||||
glm::vec4 color;
|
||||
glm::vec3 normal;
|
||||
glm::vec2 text_coords;
|
||||
uint32_t id = -1;
|
||||
};
|
||||
|
||||
struct Material
|
||||
{
|
||||
glm::vec4 albedo = { 1.0f, 1.0f, 1.0f, 1.0f };
|
||||
float roughness = 1.0f;
|
||||
float metallic = 1.0f;
|
||||
float ambient_strength = 1.0f;
|
||||
float specular_strength = 1.0f;
|
||||
};
|
||||
|
||||
struct Mesh
|
||||
{
|
||||
Ref<VertexArray> vertex_array;
|
||||
Ref<VertexBuffer> vertex_buffer;
|
||||
Ref<IndexBuffer> index_buffer;
|
||||
|
||||
// TODO: Make them a ptr or something
|
||||
std::vector<MeshVertex> vertices;
|
||||
std::vector<uint32_t> indices;
|
||||
};
|
||||
|
||||
Ref<Mesh> CreateMesh(const std::vector<MeshVertex>& vertices,
|
||||
const std::vector<uint32_t>& indices,
|
||||
uint32_t id);
|
||||
const std::vector<uint32_t>& indices);
|
||||
void PopulateMesh(Mesh& mesh);
|
||||
Ref<Mesh> CreateCube(uint32_t id = -1);
|
||||
Ref<Mesh> CreateQuad(uint32_t id = -1, bool back_face = false);
|
||||
|
||||
// ==================================================
|
||||
|
||||
class Renderer3D
|
||||
@@ -66,6 +37,12 @@ namespace OpenEngine {
|
||||
|
||||
static void DrawMesh(const Ref<Mesh>& mesh, Material& material,
|
||||
const glm::mat4& transform);
|
||||
static void DrawMesh(const Ref<Mesh>& mesh, Material& material,
|
||||
const glm::mat4& transform,
|
||||
uint32_t entity_id);
|
||||
static void DrawModel(const Ref<Model3D>& model,
|
||||
const glm::mat4& transform,
|
||||
uint32_t entity_id);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
#include "open_engine/renderer/renderer3d.hpp"
|
||||
#include "open_engine/physics.hpp"
|
||||
#include "open_engine/core/uuid.hpp"
|
||||
#include "open_engine/ref_scope.hpp"
|
||||
#include "open_engine/renderer/model3d.hpp"
|
||||
|
||||
#include <Jolt/Physics/Body/BodyCreationSettings.h>
|
||||
#include <Jolt/Physics/Body/BodyInterface.h>
|
||||
@@ -147,16 +149,36 @@ namespace OpenEngine {
|
||||
struct BoxShapeComponent
|
||||
{
|
||||
glm::vec3 size = { 1.0f, 1.0f, 1.0f };
|
||||
|
||||
BoxShapeComponent() = default;
|
||||
BoxShapeComponent(const BoxShapeComponent&) = default;
|
||||
};
|
||||
|
||||
struct SphereShapeComponent
|
||||
{
|
||||
float radius = 1.0f;
|
||||
|
||||
SphereShapeComponent() = default;
|
||||
SphereShapeComponent(const SphereShapeComponent&) = default;
|
||||
};
|
||||
|
||||
struct PlaneShapeComponent
|
||||
{
|
||||
float extent = 1.0f;
|
||||
|
||||
PlaneShapeComponent() = default;
|
||||
PlaneShapeComponent(const PlaneShapeComponent&) = default;
|
||||
};
|
||||
|
||||
struct ModelComponent
|
||||
{
|
||||
Ref<Model3D> model;
|
||||
|
||||
ModelComponent() = default;
|
||||
ModelComponent(const ModelComponent&) = default;
|
||||
ModelComponent(Ref<Model3D>& model)
|
||||
: model(model)
|
||||
{}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#include "logging.hpp"
|
||||
#include <fastgltf.hpp>
|
||||
#include "ref_scope.hpp"
|
||||
#include "renderer/renderer3d.hpp"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
@@ -58,8 +57,6 @@ namespace OpenEngine {
|
||||
auto& pbr = material.pbrData;
|
||||
|
||||
auto& c = pbr.baseColorFactor;
|
||||
for (auto& vert : out.vertices)
|
||||
vert.color = glm::vec4(c[0], c[1], c[2], c[3]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
137
open_engine/src/open_engine/gltf/gltf_model3d.cpp
Normal file
137
open_engine/src/open_engine/gltf/gltf_model3d.cpp
Normal file
@@ -0,0 +1,137 @@
|
||||
#include "logging.hpp"
|
||||
#include <pch.hpp>
|
||||
|
||||
#include <gltf/gltf_model3d.hpp>
|
||||
|
||||
#include <fastgltf/core.hpp>
|
||||
#include <fastgltf/types.hpp>
|
||||
#include <fastgltf/tools.hpp>
|
||||
#include <fastgltf/glm_element_traits.hpp>
|
||||
|
||||
namespace OpenEngine {
|
||||
|
||||
void PopulateMesh(Mesh& mesh)
|
||||
{
|
||||
mesh.vertex_array = VertexArray::Create();
|
||||
|
||||
mesh.vertex_buffer = VertexBuffer::Create(mesh.vertices.size() * sizeof(MeshVertex));
|
||||
mesh.vertex_buffer->SetData(mesh.vertices.data(), mesh.vertices.size() * sizeof(MeshVertex));
|
||||
|
||||
BufferLayout layout = {
|
||||
{ ShaderDataType::Float3, "a_Position" },
|
||||
{ ShaderDataType::Float3, "a_Normal" },
|
||||
{ ShaderDataType::Float2, "a_TexCoord" }
|
||||
};
|
||||
|
||||
mesh.vertex_buffer->SetLayout(layout);
|
||||
mesh.vertex_array->AddVertexBuffer(mesh.vertex_buffer);
|
||||
|
||||
mesh.index_buffer = IndexBuffer::Create(mesh.indices.data(), mesh.indices.size());
|
||||
mesh.vertex_array->SetIndexBuffer(mesh.index_buffer);
|
||||
}
|
||||
|
||||
Ref<Mesh> CreateMesh(const std::vector<MeshVertex>& vertices,
|
||||
const std::vector<uint32_t>& indices)
|
||||
{
|
||||
Ref<Mesh> mesh = CreateRef<Mesh>();
|
||||
|
||||
mesh->vertices = vertices;
|
||||
mesh->indices = indices;
|
||||
|
||||
PopulateMesh(*mesh);
|
||||
|
||||
return mesh;
|
||||
}
|
||||
|
||||
void GLTFModel3D::loadPrimitive(fastgltf::Asset& asset,
|
||||
fastgltf::Primitive& primitive,
|
||||
Mesh& out)
|
||||
{
|
||||
if (primitive.indicesAccessor.has_value()) {
|
||||
auto& accessor = asset.accessors[primitive.indicesAccessor.value()];
|
||||
out.indices.resize(accessor.count);
|
||||
|
||||
fastgltf::iterateAccessorWithIndex<uint32_t>(asset, accessor,
|
||||
[&](uint32_t index, size_t i) {
|
||||
out.indices[i] = index;
|
||||
});
|
||||
}
|
||||
|
||||
{
|
||||
auto* position_iterator = primitive.findAttribute("POSITION");
|
||||
auto& accessor = asset.accessors[position_iterator->accessorIndex];
|
||||
out.vertices.resize(accessor.count);
|
||||
|
||||
fastgltf::iterateAccessorWithIndex<glm::vec3>(asset, accessor,
|
||||
[&](glm::vec3 pos, size_t i) {
|
||||
out.vertices[i].position = pos;
|
||||
});
|
||||
}
|
||||
|
||||
if (auto* normal_iterator = primitive.findAttribute("NORMAL");
|
||||
normal_iterator != primitive.attributes.end()) {
|
||||
auto& accessor = asset.accessors[normal_iterator->accessorIndex];
|
||||
|
||||
fastgltf::iterateAccessorWithIndex<glm::vec3>(asset, accessor,
|
||||
[&](glm::vec3 norm, size_t i) {
|
||||
out.vertices[i].normal = norm;
|
||||
});
|
||||
}
|
||||
|
||||
{
|
||||
if (primitive.materialIndex.has_value()) {
|
||||
auto& material = asset.materials[primitive.materialIndex.value()];
|
||||
auto& pbr = material.pbrData;
|
||||
|
||||
auto& color = pbr.baseColorFactor;
|
||||
auto& roughness = pbr.roughnessFactor;
|
||||
auto& metallic = pbr.metallicFactor;
|
||||
|
||||
out.material.name = material.name;
|
||||
out.material.albedo = glm::vec4(color[0], color[1], color[2], color[3]);
|
||||
out.material.roughness = roughness;
|
||||
out.material.metallic = metallic;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GLTFModel3D::GLTFModel3D(const char* path)
|
||||
{
|
||||
fastgltf::Parser parser;
|
||||
|
||||
auto data = fastgltf::GltfDataBuffer::FromPath(path);
|
||||
if (data.error() != fastgltf::Error::None)
|
||||
OE_CORE_ERROR("Could not parse model");
|
||||
|
||||
auto asset = parser.loadGltfBinary(data.get(), ".",
|
||||
fastgltf::Options::LoadExternalBuffers
|
||||
);
|
||||
if (asset.error() != fastgltf::Error::None)
|
||||
OE_CORE_ERROR("Could not optain asset");
|
||||
|
||||
|
||||
for (auto& mesh : asset->meshes) {
|
||||
name = mesh.name;
|
||||
|
||||
for (auto& primitive : mesh.primitives) {
|
||||
Mesh prim_mesh;
|
||||
|
||||
loadPrimitive(asset.get(), primitive, prim_mesh);
|
||||
PopulateMesh(prim_mesh);
|
||||
|
||||
meshes.emplace_back(prim_mesh);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const Mesh& GLTFModel3D::GetMesh(int index) const
|
||||
{
|
||||
return meshes[index];
|
||||
}
|
||||
|
||||
const std::vector<Mesh>& GLTFModel3D::GetMeshes() const
|
||||
{
|
||||
return meshes;
|
||||
}
|
||||
|
||||
}
|
||||
19
open_engine/src/open_engine/renderer/model3d.cpp
Normal file
19
open_engine/src/open_engine/renderer/model3d.cpp
Normal file
@@ -0,0 +1,19 @@
|
||||
#include <pch.hpp>
|
||||
|
||||
#include <renderer/model3d.hpp>
|
||||
|
||||
#include <gltf/gltf_model3d.hpp>
|
||||
#include <instrumentor.hpp>
|
||||
#include <ref_scope.hpp>
|
||||
|
||||
|
||||
namespace OpenEngine {
|
||||
|
||||
Ref<Model3D> Model3D::Create(const char* path)
|
||||
{
|
||||
OE_PROFILE_FUNCTION();
|
||||
|
||||
return CreateRef<GLTFModel3D>(path);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -23,39 +23,6 @@
|
||||
namespace OpenEngine {
|
||||
|
||||
// SHOULD BE MOVED ==================================
|
||||
Ref<Mesh> CreateMesh(const std::vector<MeshVertex>& vertices,
|
||||
const std::vector<uint32_t>& indices,
|
||||
uint32_t id)
|
||||
{
|
||||
Ref<Mesh> mesh = CreateRef<Mesh>();
|
||||
|
||||
std::vector<MeshVertex> verts = vertices;
|
||||
for (auto& vertex : verts)
|
||||
vertex.id = id;
|
||||
|
||||
mesh->vertices = verts;
|
||||
mesh->indices = indices;
|
||||
|
||||
mesh->vertex_array = VertexArray::Create();
|
||||
|
||||
mesh->vertex_buffer = VertexBuffer::Create(vertices.size() * sizeof(MeshVertex));
|
||||
mesh->vertex_buffer->SetData(mesh->vertices.data(), vertices.size() * sizeof(MeshVertex));
|
||||
|
||||
BufferLayout layout = {
|
||||
{ ShaderDataType::Float3, "a_Position" },
|
||||
{ ShaderDataType::Float4, "a_Color" },
|
||||
{ ShaderDataType::Float3, "a_Normal" },
|
||||
{ ShaderDataType::Float2, "a_TexCoord" },
|
||||
{ ShaderDataType::Int, "a_EntityID"}
|
||||
};
|
||||
mesh->vertex_buffer->SetLayout(layout);
|
||||
mesh->vertex_array->AddVertexBuffer(mesh->vertex_buffer);
|
||||
|
||||
mesh->index_buffer = IndexBuffer::Create(indices.data(), indices.size());
|
||||
mesh->vertex_array->SetIndexBuffer(mesh->index_buffer);
|
||||
|
||||
return mesh;
|
||||
}
|
||||
|
||||
Ref<Mesh> CreateQuad(uint32_t id, bool back_face)
|
||||
{
|
||||
@@ -67,16 +34,16 @@ namespace OpenEngine {
|
||||
if (back_face) {
|
||||
vertices = {
|
||||
// Front face (normal 0, 0, 1)
|
||||
{{-0.5f, -0.5f, 0.0f}, { 0.5f, 0.5f, 0.5f, 1 }, {0,0,1}, {0,0}, id},
|
||||
{{-0.5f, 0.5f, 0.0f}, { 0.5f, 0.5f, 0.5f, 1 }, {0,0,1}, {0,1}, id},
|
||||
{{ 0.5f, 0.5f, 0.0f}, { 0.5f, 0.5f, 0.5f, 1 }, {0,0,1}, {1,1}, id},
|
||||
{{ 0.5f, -0.5f, 0.0f}, { 0.5f, 0.5f, 0.5f, 1 }, {0,0,1}, {1,0}, id},
|
||||
{{-0.5f, -0.5f, 0.0f}, {0,0,1}, {0,0}},
|
||||
{{-0.5f, 0.5f, 0.0f}, {0,0,1}, {0,1}},
|
||||
{{ 0.5f, 0.5f, 0.0f}, {0,0,1}, {1,1}},
|
||||
{{ 0.5f, -0.5f, 0.0f}, {0,0,1}, {1,0}},
|
||||
|
||||
// Back face (normal 0, 0, -1)
|
||||
{{-0.5f, -0.5f, -0.0f}, { 0.5f, 0.5f, 0.5f, 1 }, {0,0,-1}, {0,0}, id},
|
||||
{{-0.5f, 0.5f, -0.0f}, { 0.5f, 0.5f, 0.5f, 1 }, {0,0,-1}, {0,1}, id},
|
||||
{{ 0.5f, 0.5f, -0.0f}, { 0.5f, 0.5f, 0.5f, 1 }, {0,0,-1}, {1,1}, id},
|
||||
{{ 0.5f, -0.5f, -0.0f}, { 0.5f, 0.5f, 0.5f, 1 }, {0,0,-1}, {1,0}, id}
|
||||
{{-0.5f, -0.5f, -0.0f}, {0,0,-1}, {0,0}},
|
||||
{{-0.5f, 0.5f, -0.0f}, {0,0,-1}, {0,1}},
|
||||
{{ 0.5f, 0.5f, -0.0f}, {0,0,-1}, {1,1}},
|
||||
{{ 0.5f, -0.5f, -0.0f}, {0,0,-1}, {1,0}}
|
||||
};
|
||||
|
||||
indices = {
|
||||
@@ -88,10 +55,10 @@ namespace OpenEngine {
|
||||
} else {
|
||||
vertices = {
|
||||
// Front face (normal 0, 0, 1)
|
||||
{{-0.5f, -0.5f, 0.0f}, { 0.5f, 0.5f, 0.5f, 1 }, {0,0,1}, {0,0}, id},
|
||||
{{-0.5f, 0.5f, 0.0f}, { 0.5f, 0.5f, 0.5f, 1 }, {0,0,1}, {0,1}, id},
|
||||
{{ 0.5f, 0.5f, 0.0f}, { 0.5f, 0.5f, 0.5f, 1 }, {0,0,1}, {1,1}, id},
|
||||
{{ 0.5f, -0.5f, 0.0f}, { 0.5f, 0.5f, 0.5f, 1 }, {0,0,1}, {1,0}, id}
|
||||
{{-0.5f, -0.5f, 0.0f}, {0,0,1}, {0,0}},
|
||||
{{-0.5f, 0.5f, 0.0f}, {0,0,1}, {0,1}},
|
||||
{{ 0.5f, 0.5f, 0.0f}, {0,0,1}, {1,1}},
|
||||
{{ 0.5f, -0.5f, 0.0f}, {0,0,1}, {1,0}}
|
||||
};
|
||||
|
||||
indices = {
|
||||
@@ -100,7 +67,7 @@ namespace OpenEngine {
|
||||
};
|
||||
}
|
||||
|
||||
return CreateMesh(vertices, indices, id);
|
||||
return CreateMesh(vertices, indices);
|
||||
}
|
||||
|
||||
Ref<Mesh> CreateCube(uint32_t id)
|
||||
@@ -109,40 +76,40 @@ namespace OpenEngine {
|
||||
OE_CORE_DEBUG("Creating cube with id {}.", id);
|
||||
std::vector<MeshVertex> vertices = {
|
||||
// Front face (normal 0, 0, 1)
|
||||
{{-0.5f, -0.5f, 0.5f}, { 0.5f, 0.5f, 0.5f, 1 }, {0,0,1}, {0,0}, id},
|
||||
{{-0.5f, 0.5f, 0.5f}, { 0.5f, 0.5f, 0.5f, 1 }, {0,0,1}, {0,1}, id},
|
||||
{{ 0.5f, 0.5f, 0.5f}, { 0.5f, 0.5f, 0.5f, 1 }, {0,0,1}, {1,1}, id},
|
||||
{{ 0.5f, -0.5f, 0.5f}, { 0.5f, 0.5f, 0.5f, 1 }, {0,0,1}, {1,0}, id},
|
||||
{{-0.5f, -0.5f, 0.5f}, {0,0,1}, {0,0}},
|
||||
{{-0.5f, 0.5f, 0.5f}, {0,0,1}, {0,1}},
|
||||
{{ 0.5f, 0.5f, 0.5f}, {0,0,1}, {1,1}},
|
||||
{{ 0.5f, -0.5f, 0.5f}, {0,0,1}, {1,0}},
|
||||
|
||||
// Back face (normal 0, 0, -1)
|
||||
{{-0.5f, -0.5f, -0.5f}, { 0.5f, 0.5f, 0.5f, 1 }, {0,0,-1}, {0,0}, id},
|
||||
{{-0.5f, 0.5f, -0.5f}, { 0.5f, 0.5f, 0.5f, 1 }, {0,0,-1}, {0,1}, id},
|
||||
{{ 0.5f, 0.5f, -0.5f}, { 0.5f, 0.5f, 0.5f, 1 }, {0,0,-1}, {1,1}, id},
|
||||
{{ 0.5f, -0.5f, -0.5f}, { 0.5f, 0.5f, 0.5f, 1 }, {0,0,-1}, {1,0}, id},
|
||||
{{-0.5f, -0.5f, -0.5f}, {0,0,-1}, {0,0}},
|
||||
{{-0.5f, 0.5f, -0.5f}, {0,0,-1}, {0,1}},
|
||||
{{ 0.5f, 0.5f, -0.5f}, {0,0,-1}, {1,1}},
|
||||
{{ 0.5f, -0.5f, -0.5f}, {0,0,-1}, {1,0}},
|
||||
|
||||
// Left face (normal -1, 0, 0)
|
||||
{{-0.5f, -0.5f, -0.5f}, { 0.5f, 0.5f, 0.5f, 1 }, {-1,0,0}, {0,0}, id},
|
||||
{{-0.5f, 0.5f, -0.5f}, { 0.5f, 0.5f, 0.5f, 1 }, {-1,0,0}, {0,1}, id},
|
||||
{{-0.5f, 0.5f, 0.5f}, { 0.5f, 0.5f, 0.5f, 1 }, {-1,0,0}, {1,1}, id},
|
||||
{{-0.5f, -0.5f, 0.5f}, { 0.5f, 0.5f, 0.5f, 1 }, {-1,0,0}, {1,0}, id},
|
||||
{{-0.5f, -0.5f, -0.5f}, {-1,0,0}, {0,0}},
|
||||
{{-0.5f, 0.5f, -0.5f}, {-1,0,0}, {0,1}},
|
||||
{{-0.5f, 0.5f, 0.5f}, {-1,0,0}, {1,1}},
|
||||
{{-0.5f, -0.5f, 0.5f}, {-1,0,0}, {1,0}},
|
||||
|
||||
// Right face (normal 1, 0, 0)
|
||||
{{ 0.5f, -0.5f, -0.5f}, { 0.5f, 0.5f, 0.5f, 1 }, {1,0,0}, {0,0}, id},
|
||||
{{ 0.5f, 0.5f, -0.5f}, { 0.5f, 0.5f, 0.5f, 1 }, {1,0,0}, {0,1}, id},
|
||||
{{ 0.5f, 0.5f, 0.5f}, { 0.5f, 0.5f, 0.5f, 1 }, {1,0,0}, {1,1}, id},
|
||||
{{ 0.5f, -0.5f, 0.5f}, { 0.5f, 0.5f, 0.5f, 1 }, {1,0,0}, {1,0}, id},
|
||||
{{ 0.5f, -0.5f, -0.5f}, {1,0,0}, {0,0}},
|
||||
{{ 0.5f, 0.5f, -0.5f}, {1,0,0}, {0,1}},
|
||||
{{ 0.5f, 0.5f, 0.5f}, {1,0,0}, {1,1}},
|
||||
{{ 0.5f, -0.5f, 0.5f}, {1,0,0}, {1,0}},
|
||||
|
||||
// Top face (normal 0, 1, 0)
|
||||
{{-0.5f, 0.5f, -0.5f}, { 0.5f, 0.5f, 0.5f, 1 }, {0,1,0}, {0,0}, id},
|
||||
{{-0.5f, 0.5f, 0.5f}, { 0.5f, 0.5f, 0.5f, 1 }, {0,1,0}, {0,1}, id},
|
||||
{{ 0.5f, 0.5f, 0.5f}, { 0.5f, 0.5f, 0.5f, 1 }, {0,1,0}, {1,1}, id},
|
||||
{{ 0.5f, 0.5f, -0.5f}, { 0.5f, 0.5f, 0.5f, 1 }, {0,1,0}, {1,0}, id},
|
||||
{{-0.5f, 0.5f, -0.5f}, {0,1,0}, {0,0}},
|
||||
{{-0.5f, 0.5f, 0.5f}, {0,1,0}, {0,1}},
|
||||
{{ 0.5f, 0.5f, 0.5f}, {0,1,0}, {1,1}},
|
||||
{{ 0.5f, 0.5f, -0.5f}, {0,1,0}, {1,0}},
|
||||
|
||||
// Bottom face (normal 0, -1, 0)
|
||||
{{-0.5f, -0.5f, -0.5f}, { 0.5f, 0.5f, 0.5f, 1 }, {0,-1,0}, {0,0}, id},
|
||||
{{-0.5f, -0.5f, 0.5f}, { 0.5f, 0.5f, 0.5f, 1 }, {0,-1,0}, {0,1}, id},
|
||||
{{ 0.5f, -0.5f, 0.5f}, { 0.5f, 0.5f, 0.5f, 1 }, {0,-1,0}, {1,1}, id},
|
||||
{{ 0.5f, -0.5f, -0.5f}, { 0.5f, 0.5f, 0.5f, 1 }, {0,-1,0}, {1,0}, id},
|
||||
{{-0.5f, -0.5f, -0.5f}, {0,-1,0}, {0,0}},
|
||||
{{-0.5f, -0.5f, 0.5f}, {0,-1,0}, {0,1}},
|
||||
{{ 0.5f, -0.5f, 0.5f}, {0,-1,0}, {1,1}},
|
||||
{{ 0.5f, -0.5f, -0.5f}, {0,-1,0}, {1,0}},
|
||||
};
|
||||
|
||||
std::vector<uint32_t> indices = {
|
||||
@@ -160,7 +127,7 @@ namespace OpenEngine {
|
||||
20, 22, 21, 20, 23, 22
|
||||
};
|
||||
|
||||
return CreateMesh(vertices, indices, id);
|
||||
return CreateMesh(vertices, indices);
|
||||
}
|
||||
|
||||
// ==================================================
|
||||
@@ -185,6 +152,8 @@ namespace OpenEngine {
|
||||
|
||||
Material material_buffer;
|
||||
Ref<UniformBuffer> material_uniform_buffer;
|
||||
|
||||
Ref<UniformBuffer> id_uniform_buffer;
|
||||
};
|
||||
|
||||
static Renderer3DData renderer_data;
|
||||
@@ -200,6 +169,7 @@ namespace OpenEngine {
|
||||
renderer_data.camera_uniform_buffer = UniformBuffer::Create(sizeof(Renderer3DData::CameraData), 0);
|
||||
renderer_data.transform_uniform_buffer = UniformBuffer::Create(sizeof(Renderer3DData::TransformData), 1);
|
||||
renderer_data.material_uniform_buffer = UniformBuffer::Create(sizeof(Material), 2);
|
||||
renderer_data.id_uniform_buffer = UniformBuffer::Create(sizeof(uint32_t), 3);
|
||||
|
||||
glEnable(GL_DEBUG_OUTPUT);
|
||||
glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
|
||||
@@ -215,6 +185,7 @@ namespace OpenEngine {
|
||||
renderer_data.camera_uniform_buffer.reset();
|
||||
renderer_data.transform_uniform_buffer.reset();
|
||||
renderer_data.material_uniform_buffer.reset();
|
||||
renderer_data.id_uniform_buffer.reset();
|
||||
}
|
||||
|
||||
void Renderer3D::BeginScene(const SceneCamera& camera, const glm::mat4& transform)
|
||||
@@ -259,4 +230,48 @@ namespace OpenEngine {
|
||||
|
||||
RenderCommand::DrawIndexed(mesh->vertex_array, mesh->indices.size());
|
||||
}
|
||||
|
||||
void Renderer3D::DrawMesh(const Ref<Mesh>& mesh, Material& material,
|
||||
const glm::mat4& transform,
|
||||
uint32_t entity_id)
|
||||
{
|
||||
OE_PROFILE_FUNCTION();
|
||||
|
||||
renderer_data.color_shader_3d->Bind();
|
||||
|
||||
renderer_data.transform_buffer.transform = transform;
|
||||
renderer_data.transform_uniform_buffer->SetData(&renderer_data.transform_buffer, sizeof(Renderer3DData::TransformData));
|
||||
|
||||
renderer_data.material_buffer = material;
|
||||
renderer_data.material_uniform_buffer->SetData(&renderer_data.material_buffer, sizeof(Material));
|
||||
|
||||
renderer_data.id_uniform_buffer->SetData(&entity_id, sizeof(uint32_t));
|
||||
|
||||
mesh->vertex_array->Bind();
|
||||
|
||||
RenderCommand::DrawIndexed(mesh->vertex_array, mesh->indices.size());
|
||||
}
|
||||
|
||||
void Renderer3D::DrawModel(const Ref<Model3D>& model,
|
||||
const glm::mat4& transform,
|
||||
uint32_t entity_id)
|
||||
{
|
||||
OE_PROFILE_FUNCTION();
|
||||
|
||||
renderer_data.color_shader_3d->Bind();
|
||||
|
||||
renderer_data.transform_buffer.transform = transform;
|
||||
renderer_data.transform_uniform_buffer->SetData(&renderer_data.transform_buffer, sizeof(Renderer3DData::TransformData));
|
||||
|
||||
for (auto& mesh : *model) {
|
||||
renderer_data.material_buffer = mesh.material;
|
||||
renderer_data.material_uniform_buffer->SetData(&renderer_data.material_buffer, sizeof(Material));
|
||||
|
||||
renderer_data.id_uniform_buffer->SetData(&entity_id, sizeof(uint32_t));
|
||||
|
||||
mesh.vertex_array->Bind();
|
||||
|
||||
RenderCommand::DrawIndexed(mesh.vertex_array, mesh.indices.size());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "logging.hpp"
|
||||
#include "physics.hpp"
|
||||
#include "ref_scope.hpp"
|
||||
#include "renderer/model3d.hpp"
|
||||
#include <Jolt/Physics/Body/MotionType.h>
|
||||
#include <Jolt/Physics/Collision/ObjectLayer.h>
|
||||
#include <Jolt/Physics/Collision/Shape/ConvexShape.h>
|
||||
@@ -264,7 +265,17 @@ namespace OpenEngine {
|
||||
material = _entity.GetComponents<MaterialComponent>().material;
|
||||
|
||||
if (mesh.mesh)
|
||||
Renderer3D::DrawMesh(mesh.mesh, material, GetTransformFromComp(transform));
|
||||
Renderer3D::DrawMesh(mesh.mesh, material, GetTransformFromComp(transform), (uint32_t)_entity);
|
||||
}
|
||||
|
||||
auto model_view = registry.view<TransformComponent, ModelComponent>();
|
||||
|
||||
for (const auto& entity : model_view) {
|
||||
auto [transform, model_comp] = model_view.get<TransformComponent, ModelComponent>(entity);
|
||||
|
||||
Entity _entity(entity, this);
|
||||
|
||||
Renderer3D::DrawModel(model_comp.model, GetTransformFromComp(transform), (uint32_t)_entity);
|
||||
}
|
||||
|
||||
Renderer3D::EndScene();
|
||||
@@ -363,4 +374,9 @@ namespace OpenEngine {
|
||||
void Scene::OnComponentAdded<PlaneShapeComponent>(Entity entity, PlaneShapeComponent& component)
|
||||
{
|
||||
}
|
||||
|
||||
template<>
|
||||
void Scene::OnComponentAdded<ModelComponent>(Entity entity, ModelComponent& component)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user