Skip to content

Commit

Permalink
improve zhaoruiyang code
Browse files Browse the repository at this point in the history
  • Loading branch information
zhouhang95 committed Oct 9, 2023
1 parent ca5e140 commit 6f6fee5
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions zenovis/src/bate/HudGraphicPrimHighlight.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,20 +93,16 @@ struct PrimitiveHighlight : IGraphicDraw {
if (prim->tris->empty()) {
// prepare data
auto const &verts = prim->verts;
auto vertex_count = prim->size();
vector<vec3f> mem(vertex_count);
for (int i = 0; i < vertex_count; i++)
mem[i] = verts[i];

// bind buffers
vbo->bind_data(mem.data(), mem.size() * sizeof(mem[0]));
vbo->bind_data(verts.data(), verts.size() * sizeof(verts[0]));
vbo->attribute(0, sizeof(float) * 0, sizeof(float) * 3, GL_FLOAT, 3);

// draw particles
CHECK_GL(glEnable(GL_PROGRAM_POINT_SIZE));
shader->use();
scene->camera->set_program_uniforms(shader);
CHECK_GL(glDrawArrays(GL_POINTS, 0, mem.size()));
CHECK_GL(glDrawArrays(GL_POINTS, 0, verts.size()));
CHECK_GL(glDisable(GL_PROGRAM_POINT_SIZE));

// unbind buffers
Expand Down Expand Up @@ -138,13 +134,9 @@ struct PrimitiveHighlight : IGraphicDraw {
auto selected_count = elements.size();
// ----- prepare data -----
auto const &pos = prim->attr<zeno::vec3f>("pos");
auto vertex_count = prim->size();
vector<vec3f> mem(vertex_count);
for (int i = 0; i < vertex_count; i++)
mem[i] = pos[i];

// ----- bind buffers -----
vbo->bind_data(mem.data(), mem.size() * sizeof(mem[0]));
vbo->bind_data(pos.data(), pos.size() * sizeof(pos[0]));
vbo->attribute(0, sizeof(float) * 0, sizeof(float) * 3, GL_FLOAT, 3);

// ----- draw selected vertices -----
Expand Down

0 comments on commit 6f6fee5

Please sign in to comment.