Momentum
A library for solving nonlinear optimization problems related to human body kinematics
Loading...
Searching...
No Matches
blend_shape_base.h
Go to the documentation of this file.
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8#pragma once
9
11#include <momentum/math/types.h>
12
13namespace momentum {
14
20 public:
21 BlendShapeBase() = default;
22 BlendShapeBase(const BlendShapeBase&) = default;
26
32 size_t modelSize,
33 size_t numShapes,
34 momentum::span<const std::string> shapeNames = {});
35
36 virtual ~BlendShapeBase() = default;
37
39 void setShapeVectors(
40 const MatrixXf& shapeVectors,
41 momentum::span<const std::string> shapeNames = {});
42
43 [[nodiscard]] const MatrixXf& getShapeVectors() const {
44 return shapeVectors_;
45 }
46
52 template <typename T>
53 [[nodiscard]] VectorX<T> computeDeltas(const BlendWeightsT<T>& blendWeights) const;
54
60 template <typename T>
61 void applyDeltas(const BlendWeightsT<T>& blendWeights, std::vector<Eigen::Vector3<T>>& result)
62 const;
63
66 void setShapeVector(
67 size_t index,
69 std::string_view name = "");
70
71 [[nodiscard]] Eigen::Index shapeSize() const {
72 return shapeVectors_.cols();
73 }
74
75 [[nodiscard]] size_t modelSize() const {
76 return shapeVectors_.rows() / 3;
77 }
78
79 [[nodiscard]] const std::vector<std::string>& getShapeNames() const {
80 return shapeNames_;
81 }
82
83 [[nodiscard]] std::string_view getShapeName(size_t index) const {
84 return shapeNames_[index];
85 }
86
87 void setShapeName(size_t index, std::string_view name) {
88 shapeNames_[index] = name;
89 }
90
91 protected:
93 std::vector<std::string> shapeNames_;
94};
95
96} // namespace momentum
Vector< T, Dynamic > VectorX
Dynamic-size column vector. Common return type for solver residuals and parameter vectors.
Definition types.h:207
gsl::span< T > span
Span type alias using gsl::span (C++17 fallback).
Definition span_compat.h:54
MatrixX< float > MatrixXf
Definition types.h:82
virtual ~BlendShapeBase()=default
const MatrixXf & getShapeVectors() const
BlendShapeBase(const BlendShapeBase &)=default
BlendShapeBase & operator=(const BlendShapeBase &)=default
VectorX< T > computeDeltas(const BlendWeightsT< T > &blendWeights) const
Calculates weighted combination of shape vectors.
BlendShapeBase(BlendShapeBase &&)=default
void setShapeName(size_t index, std::string_view name)
std::vector< std::string > shapeNames_
void setShapeVectors(const MatrixXf &shapeVectors, momentum::span< const std::string > shapeNames={})
const std::vector< std::string > & getShapeNames() const
Eigen::Index shapeSize() const
void applyDeltas(const BlendWeightsT< T > &blendWeights, std::vector< Eigen::Vector3< T > > &result) const
Adds weighted shape vectors to existing vertices.
BlendShapeBase & operator=(BlendShapeBase &&)=default
void setShapeVector(size_t index, momentum::span< const Vector3f > shapeVector, std::string_view name="")
std::string_view getShapeName(size_t index) const