~mht/surcut

1248699fe47515e5f14992d3fa1aeaca610aabe1 — Martin Hafskjold Thoresen 4 years ago 852da4c
Add floater for force scale
2 files changed, 11 insertions(+), 7 deletions(-)

M arap-mold.cpp
M main.cpp
M arap-mold.cpp => arap-mold.cpp +0 -2
@@ 224,8 224,6 @@ void arap::iter(const Mesh &mesh, const arap::Args &args, const Eigen::MatrixXd 
    igl::fit_rotations(StackCovMats, true, Rotations);
  }

  NO_NANS(Rotations);

  if (!args.skip_mold_rotations) { /* ~~ Moldability ~~ */
    // 1. Go through all the boundary faces of the tet mesh
    // 2. Skip if the face satisfies direction constraint

M main.cpp => main.cpp +11 -5
@@ 56,6 56,8 @@ bool show_list = false;
bool show_forces = false;
// Don't use the ARAP enforcing moldability.  (only makes sense to use wiht `stitching`).
bool regular_arap = false;
// Scale factor for all stitching forces
float force_scale = 1.0;

int iteration_count = 0;



@@ 128,6 130,8 @@ void draw_menu(Mesh &mesh) {
    ImGui::SliderFloat("blend", &arap_args.blend, 0.0, 1.0, "%.2f");
  }

  ImGui::SliderFloat("Force", &force_scale, 0.5, 100.0, "%.2f");

  if (ImGui::Checkbox("Stiching", &stitching)) {
    if (!stitching)
      mesh.forces = MatrixXd::Zero(mesh.vertices.rows(), mesh.vertices.cols());


@@ 291,8 295,10 @@ void compute_things(Mesh &mesh, bool only_plane) {
        // at the dynamics implementation in `arap-mold.cpp`.

        // Symmetric forces - think springs
        mesh.forces.row(v) += force_direction * 0.48;
        mesh.forces.row(other_i) -= force_direction * 0.48;
        // XXX(todo): Maybe the force should be proportional to the area of the non-moldable
        // triangle(s)?
        mesh.forces.row(v) += force_direction * (double)force_scale;
        // mesh.forces.row(other_i) -= force_direction * 0.48;
      }
    }



@@ 357,7 363,7 @@ void draw_plane(Viewer &viewer, Mesh &mesh) {
  viewer.data().add_edges(planeEA, planeEB, c);

  if (show_forces) {
    viewer.data().add_edges(mesh.vertices, mesh.vertices + mesh.forces,
    viewer.data().add_edges(mesh.vertices, mesh.vertices + mesh.forces * 0.2,
                            Eigen::RowVector3d(1.0, 0.0, 1.0));
  }
}


@@ 550,8 556,8 @@ int main(int argc, char *argv[]) {
    } else if (key == '.') {
      step_arap(mesh);
    } else if (key == 'R') {
      mesh.vertices = tetmesh_out.vertices;
      mesh.rest_state = mesh.vertices;
      mesh.vertices = mesh.rest_state = tetmesh_out.vertices;
      arap::precomputation(mesh, arap_data);
      compute_things(mesh);
    }
    return false;