diff options
author | over0219 <over0219@umn.edu> | 2020-07-09 22:42:20 +0300 |
---|---|---|
committer | over0219 <over0219@umn.edu> | 2020-07-09 22:42:20 +0300 |
commit | 14a76718e5e0d16c87e45f27f20a31aebe1e19e6 (patch) | |
tree | 8e365dd4c354f774a092acbf01f5ba00f4e7d8ea /extern/softbody/src/admmpd_pin.h | |
parent | b650bdc5ecfca7357cbd4cc1f0f5b2279db91a9c (diff) |
added goal positions
Diffstat (limited to 'extern/softbody/src/admmpd_pin.h')
-rw-r--r-- | extern/softbody/src/admmpd_pin.h | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/extern/softbody/src/admmpd_pin.h b/extern/softbody/src/admmpd_pin.h new file mode 100644 index 00000000000..8080d9d2c85 --- /dev/null +++ b/extern/softbody/src/admmpd_pin.h @@ -0,0 +1,88 @@ +// Copyright Matt Overby 2020. +// Distributed under the MIT License. + +#ifndef ADMMPD_PIN_H_ +#define ADMMPD_PIN_H_ + +#include "admmpd_bvh.h" +#include "admmpd_types.h" +#include <unordered_map> +#include <vector> + +namespace admmpd { + +class Pin { +public: + + virtual ~Pin() {} + + // Clears all pins + virtual void clear() = 0; + + // Set the pin location (q) and per-axis stiffness (k) + // Stiffness should be 0 to 1. It can go larger, but + // the resulting matrix will be poorly conditioned. + virtual void set_pin( + int idx, + const Eigen::Vector3d &q, + const Eigen::Vector3d &k) = 0; + + // Returns true if the vert is pinned +// virtual bool has_pin(int idx) const = 0; + + // Creates linearization for constraint: + // Px=q with stiffnesses baked in + virtual void linearize( + const Eigen::MatrixXd *x, // not used yet + std::vector<Eigen::Triplet<double> > *trips, + std::vector<double> *q) = 0; + + // Returns per-axis pin stiffness +// virtual Eigen::Vector3d get_pin_k(int idx) const = 0; + + // Returns pin location, or zero vector if not set + // virtual Eigen::Vector3d get_pin_pos(int idx) const = 0; +}; + +class EmbeddedMeshPin : public Pin { +public: + EmbeddedMeshPin(const EmbeddedMeshData *mesh_) : mesh(mesh_){} + + // Clears all pins + void clear(); + + // Set the pin location of the embedded vertex + void set_pin( + int idx, + const Eigen::Vector3d &p, + const Eigen::Vector3d &k); + + // Returns true if the deforming vertex is pinned +// bool has_pin(int idx) const; + + void linearize( + const Eigen::MatrixXd *x, // not used yet + std::vector<Eigen::Triplet<double> > *trips, + std::vector<double> *q); + + // Returns per-axis pin stiffness of the deforming vertex (not embedded) + // or zero if not pinned + // Baryweights are included. +// Eigen::Vector3d get_pin_k(int idx) const; + + // Returns pin location of the deforming vertex (not embedded) + // or zero vector if not set +// Eigen::Vector3d get_pin_pos(int idx) const; + +protected: + // A ptr to the embedded mesh data + const EmbeddedMeshData *mesh; + + // Pins for embedded vertices: + std::unordered_map<int,Eigen::Vector3d> pin_k; + std::unordered_map<int,Eigen::Vector3d> pin_pos; +}; + +} // namespace admmpd + +#endif // ADMMPD_PIN_H_ |