polyscope icon indicating copy to clipboard operation
polyscope copied to clipboard

Update geometry from UI parameter

Open Jeordanis opened this issue 2 years ago • 1 comments

I have this UI callback to control how a mesh is generated but changing it in the UI doesn't affect the mesh in the viewport. What am I missing? I can't find any documentation about this. Thanks.

int sides = 6;
void UICallback()
{
  bool changed = ImGui::InputInt("Sides", &sides);

}

// In main:
  polyscope::init();
  polyscope::state::userCallback = UICallback;
  polyscope::show();

Jeordanis avatar Apr 14 '23 14:04 Jeordanis

Hi!

How is this sides variable being used in your full code? If you are updating the scene geometry somehow, you need to re-send that updated geometry to Polyscope.

The usual workflow would be something like (1) get a new value for the sides parameter, (2) run some of your own code to update/regenerate the scene content, and (3) send that updated to content with polyscope_mesh->updateVertexPositions() or a new polyscope::registerSurfaceMesh() or something like that. All of these (1), (2), (3) would be called inside of your UI callback function (perhaps only if changed=true).

nmwsharp avatar May 01 '23 06:05 nmwsharp