diff options
author | over0219 <over0219@umn.edu> | 2020-06-23 03:00:36 +0300 |
---|---|---|
committer | over0219 <over0219@umn.edu> | 2020-06-23 03:00:36 +0300 |
commit | 88ab1c138dcb370829ae0362ad6ee8a462d8a6ca (patch) | |
tree | f8a1f130be9bd564141e720114e31aef4839e748 /extern | |
parent | 50e2c479cc22d0efd1d744720df64311d8fefb80 (diff) |
more interface changes
Diffstat (limited to 'extern')
-rw-r--r-- | extern/softbody/src/admmpd_collision.cpp | 8 | ||||
-rw-r--r-- | extern/softbody/src/admmpd_collision.h | 23 | ||||
-rw-r--r-- | extern/softbody/src/admmpd_solver.cpp | 26 | ||||
-rw-r--r-- | extern/softbody/src/admmpd_solver.h | 18 | ||||
-rw-r--r-- | extern/softbody/src/admmpd_types.h | 26 |
5 files changed, 56 insertions, 45 deletions
diff --git a/extern/softbody/src/admmpd_collision.cpp b/extern/softbody/src/admmpd_collision.cpp index 02a197c4138..54bca95729e 100644 --- a/extern/softbody/src/admmpd_collision.cpp +++ b/extern/softbody/src/admmpd_collision.cpp @@ -50,10 +50,10 @@ void EmbeddedMeshCollision::set_obstacles( obs_tree.init(obs_aabbs); } // end add obstacle - + /* void EmbeddedMeshCollision::detect(const Eigen::MatrixXd *x0, const Eigen::MatrixXd *x1) { - /* + // First, update the positions of the embedded vertex // and perform collision detection against obstacles int n_ev = emb_V0.rows(); @@ -93,9 +93,9 @@ void EmbeddedMeshCollision::detect(const Eigen::MatrixXd *x0, const Eigen::Matri // Only bother with self collision if it // is not colliding with an obstacle. // This is only useful for discrete tests. -*/ -} // end emb collision detect +} // end emb collision detect +*/ /* void FloorCollider::detect(const Eigen::MatrixXd *x) { diff --git a/extern/softbody/src/admmpd_collision.h b/extern/softbody/src/admmpd_collision.h index 5126d1a6958..2996249158e 100644 --- a/extern/softbody/src/admmpd_collision.h +++ b/extern/softbody/src/admmpd_collision.h @@ -4,10 +4,8 @@ #ifndef ADMMPD_COLLISION_H_ #define ADMMPD_COLLISION_H_ -#include <Eigen/Sparse> -#include <Eigen/Geometry> -#include <vector> #include "admmpd_bvh.h" +#include "admmpd_types.h" namespace admmpd { @@ -62,16 +60,23 @@ public: const int *faces, int nf); - // Unlike set_obstacles, the pointers - void set_embedded( - const Eigen::MatrixXd *emb_barys, - const Eigen::VectorXi *vtx_to_tet, - const Eigen::MatrixXi *tets){} + // Updates the tetmesh BVH for self collisions + // TODO + void update_bvh( + const EmbeddedMeshData *mesh, + const Eigen::MatrixXd *x0, + const Eigen::MatrixXd *x1) + { (void)(mesh); (void)(x0); (void)(x1); } // Given a list of deformable vertices (the lattice) // perform collision detection of the surface mesh against // obstacles and possibly self. - void detect(const Eigen::MatrixXd *x0, const Eigen::MatrixXd *x1); + void detect( + const EmbeddedMeshData *mesh, + const Eigen::MatrixXd *x0, + const Eigen::MatrixXd *x1){ + + } void jacobian( const Eigen::MatrixXd *x, diff --git a/extern/softbody/src/admmpd_solver.cpp b/extern/softbody/src/admmpd_solver.cpp index da766d43cc1..17bd8c7d008 100644 --- a/extern/softbody/src/admmpd_solver.cpp +++ b/extern/softbody/src/admmpd_solver.cpp @@ -21,14 +21,14 @@ template <typename T> using RowSparseMatrix = SparseMatrix<T,RowMajor>; typedef struct ThreadData { const Options *options; - Data *data; + SolverData *data; } ThreadData; bool Solver::init( const Eigen::MatrixXd &V, const Eigen::MatrixXi &T, const Options *options, - Data *data) + SolverData *data) { BLI_assert(data != NULL); BLI_assert(options != NULL); @@ -49,7 +49,7 @@ bool Solver::init( int Solver::solve( const Options *options, - Data *data) + SolverData *data) { BLI_assert(data != NULL); BLI_assert(options != NULL); @@ -89,7 +89,7 @@ int Solver::solve( void Solver::init_solve( const Options *options, - Data *data) + SolverData *data) { BLI_assert(data != NULL); BLI_assert(options != NULL); @@ -138,7 +138,7 @@ static void parallel_zu_update( void Solver::solve_local_step( const Options *options, - Data *data) + SolverData *data) { BLI_assert(data != NULL); BLI_assert(options != NULL); @@ -152,7 +152,7 @@ void Solver::solve_local_step( void Solver::update_constraints( const Options *options, - Data *data) + SolverData *data) { BLI_assert(data != NULL); BLI_assert(options != NULL); @@ -195,7 +195,7 @@ void Solver::update_constraints( } // end update constraints typedef struct LinSolveThreadData { - Data *data; + SolverData *data; MatrixXd *ls_x; MatrixXd *ls_b; } LinSolveThreadData; @@ -211,7 +211,7 @@ static void parallel_lin_solve( void Solver::solve_conjugate_gradients( const Options *options, - Data *data) + SolverData *data) { BLI_assert(data != NULL); BLI_assert(options != NULL); @@ -230,7 +230,7 @@ void Solver::solve_conjugate_gradients( // Solve Ax = b in parallel auto solve_Ax_b = []( - Data *data_, + SolverData *data_, MatrixXd *x_, MatrixXd *b_) { @@ -267,7 +267,7 @@ void Solver::solve_conjugate_gradients( }; // Update CGData - admmpd::Data::CGData *cgdata = &data->cgdata; + admmpd::SolverData::CGData *cgdata = &data->cgdata; double eps = options->min_res; cgdata->b = data->b; if (cgdata->r.rows() != nx) @@ -316,7 +316,7 @@ void Solver::solve_conjugate_gradients( bool Solver::compute_matrices( const Options *options, - Data *data) + SolverData *data) { BLI_assert(data != NULL); BLI_assert(options != NULL); @@ -392,7 +392,7 @@ bool Solver::compute_matrices( void Solver::compute_masses( const Options *options, - Data *data) + SolverData *data) { BLI_assert(data != NULL); BLI_assert(options != NULL); @@ -432,7 +432,7 @@ void Solver::compute_masses( void Solver::append_energies( const Options *options, - Data *data, + SolverData *data, std::vector<Triplet<double> > &D_triplets) { BLI_assert(data != NULL); diff --git a/extern/softbody/src/admmpd_solver.h b/extern/softbody/src/admmpd_solver.h index 229411ae340..d26da293bc8 100644 --- a/extern/softbody/src/admmpd_solver.h +++ b/extern/softbody/src/admmpd_solver.h @@ -17,45 +17,45 @@ public: const Eigen::MatrixXd &V, // vertices const Eigen::MatrixXi &T, // tets const Options *options, - Data *data); + SolverData *data); // Solve a single time step. // Returns number of iterations. int solve( const Options *options, - Data *data); + SolverData *data); protected: void update_constraints( const Options *options, - Data *data); + SolverData *data); void init_solve( const Options *options, - Data *data); + SolverData *data); void solve_local_step( const Options *options, - Data *data); + SolverData *data); // Global step with CG: // 1/2||Ax-b||^2 + k/2||Kx-l||^2 void solve_conjugate_gradients( const Options *options, - Data *data); + SolverData *data); bool compute_matrices( const Options *options, - Data *data); + SolverData *data); void compute_masses( const Options *options, - Data *data); + SolverData *data); void append_energies( const Options *options, - Data *data, + SolverData *data, std::vector<Eigen::Triplet<double> > &D_triplets); }; // class ADMMPD_solver diff --git a/extern/softbody/src/admmpd_types.h b/extern/softbody/src/admmpd_types.h index 48f3121f721..925072b282f 100644 --- a/extern/softbody/src/admmpd_types.h +++ b/extern/softbody/src/admmpd_types.h @@ -36,9 +36,23 @@ struct Options { {} }; -struct Data { +struct TetMesh { + Eigen::MatrixXd x_rest; // verts at rest + Eigen::MatrixXi faces; // surface elements, m x 3 + Eigen::MatrixXi tets; // internal elements, m x 4 +}; // type 0 + +struct EmbeddedMeshData { // i.e. the lattice + Eigen::MatrixXd x_rest; // embedded verts at rest + Eigen::MatrixXi faces; // embedded faces + Eigen::MatrixXi tets; // lattice elements, m x 4 + Eigen::VectorXi vtx_to_tet; // what tet vtx is embedded in, p x 1 + Eigen::MatrixXd barys; // barycoords of the embedding, p x 4 +}; // type 1 + +struct SolverData { // Set from input - Eigen::MatrixXi tets; // elements t x 4 + Eigen::MatrixXi tets; // elements t x 4, copy from mesh Eigen::MatrixXd x; // vertices, n x 3 Eigen::MatrixXd v; // velocity, n x 3 // Set in compute_matrices: @@ -71,14 +85,6 @@ struct Data { std::vector<double> weights; // per-energy weights }; -struct EmbeddedMeshData { // i.e. the lattice - Eigen::MatrixXd x_rest; // embedded verts at rest - Eigen::MatrixXi faces; // embedded faces - Eigen::MatrixXi tets; // lattice elements, m x 4 - Eigen::VectorXi vtx_to_tet; // what tet vtx is embedded in, p x 1 - Eigen::MatrixXd barys; // barycoords of the embedding, p x 4 -}; - } // namespace admmpd #endif // ADMMPD_TYPES_H_ |