From 6f6fee59c46e9e4161de5400ddaef3ce0fb38f71 Mon Sep 17 00:00:00 2001 From: zhouhang95 <765229842@qq.com> Date: Mon, 9 Oct 2023 17:46:12 +0800 Subject: [PATCH] improve zhaoruiyang code --- zenovis/src/bate/HudGraphicPrimHighlight.cpp | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/zenovis/src/bate/HudGraphicPrimHighlight.cpp b/zenovis/src/bate/HudGraphicPrimHighlight.cpp index 105035f574..09ba459ecc 100644 --- a/zenovis/src/bate/HudGraphicPrimHighlight.cpp +++ b/zenovis/src/bate/HudGraphicPrimHighlight.cpp @@ -93,20 +93,16 @@ struct PrimitiveHighlight : IGraphicDraw { if (prim->tris->empty()) { // prepare data auto const &verts = prim->verts; - auto vertex_count = prim->size(); - vector 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 @@ -138,13 +134,9 @@ struct PrimitiveHighlight : IGraphicDraw { auto selected_count = elements.size(); // ----- prepare data ----- auto const &pos = prim->attr("pos"); - auto vertex_count = prim->size(); - vector 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 -----