feat: add selection to meshrendercomponent
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
#include <destrum/Graphics/Renderer.h>
|
||||
#include <destrum/Graphics/Pipelines/ImguiPass.h>
|
||||
#include <destrum/Graphics/ResourcesInspector.h>
|
||||
#include <destrum/Util/AssetBrowser.h>
|
||||
|
||||
#include <destrum/Input/InputManager.h>
|
||||
|
||||
@@ -53,6 +54,7 @@ public:
|
||||
virtual void onWindowResize(int, int) {};
|
||||
virtual void onViewportResize(int, int) {}
|
||||
virtual void drawViewportOverlay() {}
|
||||
virtual void onViewportAssetDropped(std::string_view) {}
|
||||
|
||||
virtual void onPlayModeChanged(bool) {}
|
||||
|
||||
@@ -107,10 +109,12 @@ protected:
|
||||
bool physics{true};
|
||||
bool inspector{true};
|
||||
bool imageCache{false};
|
||||
bool assets{true};
|
||||
};
|
||||
|
||||
DebugWindows m_DebugWindows{};
|
||||
ResourcesInspector m_ResourcesInspector;
|
||||
AssetBrowser m_AssetBrowser;
|
||||
|
||||
void drawWindowsMenu();
|
||||
void drawPhysicsPanel(float dt, float fixedDt, float accumulator);
|
||||
|
||||
@@ -4,6 +4,13 @@
|
||||
#include <destrum/ObjectModel/Component.h>
|
||||
|
||||
#include <destrum/Graphics/ids.h>
|
||||
#include <destrum/Graphics/Resources/PrimitiveMeshes.h>
|
||||
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
class GameRenderer;
|
||||
class RenderResources;
|
||||
|
||||
class MeshRendererComponent final: public Component {
|
||||
public:
|
||||
@@ -30,6 +37,18 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
void DrawMeshField(RenderResources& resources);
|
||||
void DrawPrimitiveSettings(RenderResources& resources);
|
||||
void DrawMaterialField(RenderResources& resources, GameRenderer& renderer);
|
||||
void DrawMaterialEditor(RenderResources& resources, GameRenderer& renderer);
|
||||
void AssignPrimitive(RenderResources& resources, const PrimitiveMeshes::Desc& desc);
|
||||
void LoadDroppedModel(RenderResources& resources, const std::string& path);
|
||||
|
||||
std::string m_MeshSearch;
|
||||
std::string m_MaterialSearch;
|
||||
std::optional<PrimitiveMeshes::Desc> m_PrimitiveDraft;
|
||||
std::string m_PrimitiveDraftKey;
|
||||
|
||||
MeshID meshID{NULL_MESH_ID};
|
||||
MaterialID materialID{NULL_MATERIAL_ID};
|
||||
std::string meshKey;
|
||||
|
||||
@@ -34,6 +34,8 @@ public:
|
||||
|
||||
[[nodiscard]] std::optional<std::string> ToVirtualPath(const std::filesystem::path& fullPath) const;
|
||||
|
||||
[[nodiscard]] const std::vector<FSMount>& GetMounts() const { return mounts; }
|
||||
|
||||
private:
|
||||
static std::vector<uint8_t> ReadFile(const std::filesystem::path& fullPath);
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ public:
|
||||
MaterialID addSimpleTextureMaterial(ImageID textureID);
|
||||
[[nodiscard]] const Material& getMaterial(MaterialID id) const;
|
||||
[[nodiscard]] const std::string& getMaterialKey(MaterialID id) const;
|
||||
[[nodiscard]] std::size_t getMaterialCount() const { return materials.size(); }
|
||||
[[nodiscard]] std::optional<MaterialID> findMaterialByKey(std::string_view key) const;
|
||||
[[nodiscard]] std::optional<MaterialID> findMaterialByName(
|
||||
std::string_view name,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef PRIMITIVEMESHES_H
|
||||
#define PRIMITIVEMESHES_H
|
||||
|
||||
#include <array>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
@@ -10,9 +11,36 @@
|
||||
#include <destrum/Graphics/Resources/CPUMesh.h>
|
||||
|
||||
namespace PrimitiveMeshes {
|
||||
enum class Shape {
|
||||
Box,
|
||||
Plane,
|
||||
Sphere,
|
||||
Cylinder,
|
||||
Capsule,
|
||||
};
|
||||
|
||||
inline constexpr std::array<Shape, 5> AllShapes{
|
||||
Shape::Box, Shape::Plane, Shape::Sphere, Shape::Cylinder, Shape::Capsule,
|
||||
};
|
||||
|
||||
struct Desc {
|
||||
Shape shape{Shape::Box};
|
||||
glm::vec3 size{1.0f};
|
||||
float radius{0.5f};
|
||||
float height{2.0f};
|
||||
|
||||
bool operator==(const Desc&) const = default;
|
||||
};
|
||||
|
||||
[[nodiscard]] const char* ShapeName(Shape shape);
|
||||
[[nodiscard]] Desc DefaultDesc(Shape shape);
|
||||
|
||||
[[nodiscard]] CPUMesh Make(const Desc& desc);
|
||||
[[nodiscard]] CPUMesh MakeBox(const glm::vec3& size);
|
||||
|
||||
[[nodiscard]] std::string MakeKey(const Desc& desc);
|
||||
[[nodiscard]] std::string BoxKey(const glm::vec3& size);
|
||||
[[nodiscard]] std::optional<Desc> ParseKey(std::string_view key);
|
||||
[[nodiscard]] bool IsPrimitiveKey(std::string_view key);
|
||||
[[nodiscard]] std::string_view StripDuplicateSuffix(std::string_view key);
|
||||
[[nodiscard]] std::optional<CPUMesh> MakeFromKey(std::string_view key);
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
#ifndef DESTRUM_ASSETBROWSER_H
|
||||
#define DESTRUM_ASSETBROWSER_H
|
||||
|
||||
#include <filesystem>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
class AssetBrowser final {
|
||||
public:
|
||||
void Draw(bool* open = nullptr);
|
||||
|
||||
[[nodiscard]] static bool IsModel(std::string_view path);
|
||||
|
||||
private:
|
||||
struct Entry {
|
||||
std::string name;
|
||||
bool directory{false};
|
||||
};
|
||||
|
||||
void Refresh();
|
||||
void Navigate(const std::string& scheme, const std::filesystem::path& folder);
|
||||
bool DrawEntry(const Entry& entry);
|
||||
|
||||
std::string m_Scheme;
|
||||
std::filesystem::path m_Folder;
|
||||
std::vector<Entry> m_Entries;
|
||||
std::string m_Filter;
|
||||
bool m_Dirty{true};
|
||||
};
|
||||
|
||||
#endif // DESTRUM_ASSETBROWSER_H
|
||||
@@ -24,6 +24,7 @@ namespace ImGuiUtils {
|
||||
float speed = 0.1f);
|
||||
|
||||
inline constexpr const char* GameObjectPayload = "DESTRUM_GAMEOBJECT";
|
||||
inline constexpr const char* AssetPayload = "DESTRUM_ASSET";
|
||||
|
||||
bool InputString(const char* label, std::string& value, ImGuiInputTextFlags flags = 0, const char* hint = nullptr);
|
||||
bool InputStringMultiline(const char* label, std::string& value);
|
||||
|
||||
Reference in New Issue
Block a user