Files
Aethera/render_3D/render_3D/visual/Mesh_Visual.hpp
T
2026-08-29 00:38:34 +08:00

52 lines
1.8 KiB
C++

#pragma once
#include "Basic_Visual.hpp"
#include <vector>
namespace aethera::render_3d {
struct Mesh_Vertex {
Vec3 position{};
Color color{Color::white()};
Vec3 normal{};
Vec2 texture_coordinate{};
bool operator==(const Mesh_Vertex&) const = default;
};
struct Mesh_Frame_Tag {};
struct Mesh_Frame {
std::vector<Mesh_Vertex> items{}; /* 本次提交的完整 Mesh 顶点集合。 */
bool operator==(const Mesh_Frame&) const;
};
namespace detail {
struct Mesh_Prepared_Data {
std::vector<Prepared_Position> positions{};
std::vector<Prepared_Color> colors{};
std::vector<Prepared_Position> normals{};
std::vector<std::array<float, 2>> texture_coordinates{};
};
struct Mesh_Spec {
using Item = Mesh_Vertex;
using Prepared_Data = Mesh_Prepared_Data;
[[nodiscard]] static const Datoviz_Visual_Operations& datoviz_operations();
[[nodiscard]] static bool valid(const Item&) noexcept;
static void prepare(const std::vector<Item>&, Prepared_Data&);
};
}
struct Mesh_Visual : Def<Mesh_Visual, Basic_Visual,
Tagged_Buffer<Mesh_Frame_Tag, Mesh_Frame>> {
using Visual_Base = Mesh_Visual;
using Frame_Tag = Mesh_Frame_Tag;
using Frame = Mesh_Frame;
using Specification = detail::Mesh_Spec;
using Item = typename Specification::Item;
struct Prop : Prev_Prop { bool operator==(const Prop&) const; };
struct State : Prev_State {
std::size_t item_count{}; /* 最近一次发布的输入项数。 */
std::size_t prepared_item_count{}; /* 最近一次 Prepare 的后端项数。 */
std::uint64_t prepared_revision{}; /* 最近一次 Prepare 的提交版本。 */
bool operator==(const State&) const;
};
struct Private;
};
}
#include "Mesh_Visual.ipp"