mesh_rviz_plugins icon indicating copy to clipboard operation
mesh_rviz_plugins copied to clipboard

[Pull request] A necessary check when choose `shader_program_` from other types to `ShaderProgram::TEXTURE`

Open myboyhood opened this issue 1 year ago • 0 comments

Hello! Thanks for this useful code!

In textured_mesh_visual.cc file, the function void TexturedMeshVisual::setShaderProgram(ShaderProgram shader_program) There is a Bug when shader_program_ change from other types to ShaderProgram::TEXTURE)

The reason is as following: Since the tex_img_ need to be passed from cv_bridge in function void TexturedMeshVisual::setFromMessage in textured_mesh_visual.cc.

tex_img_ can recieve data only when (shader_program_ == ShaderProgram::TEXTURE). Thus, when shader_program_ is initially not ShaderProgram::TEXTURE, the tex_img_ have no valid data.

suggestion But when we choose ShaderProgram::TEXTURE in Rviz. We should check the tex_img_ firstly!

 // origin directly updateTexture
//    updateTexture(mesh_material_, tex_img_);
    // myboyhood change to check the img cols and rows
    if(!mesh_material_.isNull() && tex_img_.cols > 0 && tex_img_.rows > 0){
      updateTexture(mesh_material_, tex_img_);
    }else{
      printf("pass this Choose ShaderProgram::TEXTURE, wait for next matching!\n");
    }

myboyhood avatar Nov 03 '23 08:11 myboyhood