8000 Fixed mesh data regression by Cons-Cat · Pull Request #68 · liblava/liblava · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fixed mesh data regression #68

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion liblava-demo/triangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ int main(int argc, char* argv[]) {
if (!triangle)
return error::create_failed;

auto& triangle_data = triangle->get_data();
mesh_data& triangle_data = triangle->get_data();
triangle_data.vertices.at(0).color = v4(1.f, 0.f, 0.f, 1.f);
triangle_data.vertices.at(1).color = v4(0.f, 1.f, 0.f, 1.f);
triangle_data.vertices.at(2).color = v4(0.f, 0.f, 1.f, 1.f);
Expand Down
15 changes: 10 additions & 5 deletions liblava/resource/mesh.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace lava {
* @tparam T Input vertex struct
*/
template<typename T = vertex>
struct mesh_data {
struct mesh_template_data {
/// List of vertices
std::vector<T> vertices;

Expand Down Expand Up @@ -139,7 +139,7 @@ struct mesh_template : entity {
*
* @param value Mesh data
*/
void set_data(mesh_data<T> const& value) {
void set_data(mesh_template_data<T> const& value) {
data = value;
}

Expand All @@ -148,7 +148,7 @@ struct mesh_template : entity {
*
* @return mesh_data& Mesh data
*/
mesh_data<T>& get_data() {
mesh_template_data<T>& get_data() {
return data;
}

Expand All @@ -157,7 +157,9 @@ struct mesh_template : entity {
*
* @param value Mesh data to add
*/
void add_data(mesh_data<T> const& value);
void add_data(mesh_template_data<T> const& value){
data = value;
}

/**
* @brief Get the vertices of the mesh
Expand Down Expand Up @@ -244,7 +246,7 @@ struct mesh_template : entity {
device_ptr device = nullptr;

/// Mesh data
mesh_data<T> data;
mesh_template_data<T> data;

/// Vertex buffer
buffer::ptr vertex_buffer;
Expand Down Expand Up @@ -680,6 +682,9 @@ constexpr std::array<UVType, 24> make_primitive_uvs_cube() {
return uvs;
}

/// Mesh data with default vertex
using mesh_data = mesh_template_data<vertex>;

/// Mesh with default vertex
using mesh = mesh_template<vertex>;

Expand Down
0