mirror of
https://github.com/Kbz-8/42_vox.git
synced 2026-01-13 07:33:35 +00:00
world generation
This commit is contained in:
@@ -24,6 +24,7 @@ namespace Scop
|
||||
inline void SetPosition(Vec3f position) noexcept { m_position = position; }
|
||||
inline void SetScale(Vec3f scale) noexcept { m_scale = scale; }
|
||||
inline void SetOrientation(Quatf orientation) noexcept { m_orientation = orientation; }
|
||||
inline void SetVisibility(bool show) noexcept { m_is_visible = show; }
|
||||
|
||||
[[nodiscard]] inline const Vec4f& GetColor() const noexcept { return m_color; }
|
||||
[[nodiscard]] inline const Vec3f& GetPosition() const noexcept { return m_position; }
|
||||
@@ -32,6 +33,7 @@ namespace Scop
|
||||
[[nodiscard]] inline const Model& GetModel() const noexcept { return m_model; }
|
||||
[[nodiscard]] inline Model& GetModelRef() noexcept { return m_model; }
|
||||
[[nodiscard]] inline std::uint32_t GetUUID() const noexcept { return m_uuid; }
|
||||
[[nodiscard]] inline bool IsVisible() const noexcept { return m_is_visible; }
|
||||
|
||||
~Actor();
|
||||
|
||||
@@ -46,6 +48,7 @@ namespace Scop
|
||||
Vec3f m_scale = Vec3f{ 1.0f, 1.0f, 1.0f };
|
||||
std::shared_ptr<ActorScript> p_script;
|
||||
std::uint64_t m_uuid;
|
||||
bool m_is_visible = true;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -20,14 +20,28 @@ namespace Scop
|
||||
std::size_t index_size;
|
||||
std::size_t triangle_count = 0;
|
||||
|
||||
inline SubMesh(const std::vector<Vertex>& vertices, const std::vector<std::uint32_t>& indices)
|
||||
inline SubMesh(const std::vector<Vertex>& vertices, const std::vector<std::uint32_t>& indices, std::size_t index_size = 0)
|
||||
{
|
||||
CPUBuffer data(vertices.size() * sizeof(Vertex) + indices.size() * sizeof(std::uint32_t));
|
||||
std::memcpy(data.GetData(), vertices.data(), vertices.size() * sizeof(Vertex));
|
||||
std::memcpy(data.GetData() + vertices.size() * sizeof(Vertex), indices.data(), indices.size() * sizeof(std::uint32_t));
|
||||
buffer.Init(vertices.size() * sizeof(Vertex), indices.size() * sizeof(std::uint32_t), 0, std::move(data));
|
||||
triangle_count = vertices.size() / 3;
|
||||
index_size = indices.size();
|
||||
this->index_size = index_size == 0 ? indices.size() : index_size;
|
||||
triangle_count = index_size / 3;
|
||||
}
|
||||
|
||||
inline void SetData(const std::vector<Vertex>& vertices, const std::vector<std::uint32_t>& indices, std::size_t index_size = 0)
|
||||
{
|
||||
CPUBuffer vertex_data(vertices.size() * sizeof(Scop::Vertex));
|
||||
std::memcpy(vertex_data.GetData(), vertices.data(), vertex_data.GetSize());
|
||||
CPUBuffer index_data(indices.size() * sizeof(std::uint32_t));
|
||||
std::memcpy(index_data.GetData(), indices.data(), index_data.GetSize());
|
||||
|
||||
buffer.SetVertexData(std::move(vertex_data));
|
||||
buffer.SetVertexData(std::move(index_data));
|
||||
|
||||
this->index_size = index_size == 0 ? indices.size() : index_size;
|
||||
triangle_count = index_size / 3;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -41,6 +55,12 @@ namespace Scop
|
||||
|
||||
inline void AddSubMesh(SubMesh mesh) { m_sub_meshes.emplace_back(std::move(mesh)); }
|
||||
[[nodiscard]] inline SubMesh& GetSubMesh(std::size_t index) { return m_sub_meshes.at(index); }
|
||||
inline void Reset()
|
||||
{
|
||||
for(auto& mesh : m_sub_meshes)
|
||||
mesh.buffer.Destroy();
|
||||
m_sub_meshes.clear();
|
||||
}
|
||||
|
||||
~Mesh();
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ namespace Scop
|
||||
[[nodiscard]] inline std::shared_ptr<Material> GetMaterial(std::size_t mesh_index) { return m_materials[mesh_index]; }
|
||||
[[nodiscard]] inline std::vector<std::shared_ptr<Material>>& GetAllMaterials() { return m_materials; }
|
||||
[[nodiscard]] inline Vec3f GetCenter() const noexcept { return m_center; }
|
||||
[[nodiscard]] inline std::shared_ptr<Mesh> GetMesh() const { return p_mesh; }
|
||||
|
||||
void Draw(VkCommandBuffer cmd, const DescriptorSet& matrices_set, const class GraphicPipeline& pipeline, DescriptorSet& set, std::size_t& drawcalls, std::size_t& polygondrawn, std::size_t frame_index) const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user