Blender  V3.3
IK_QTask.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2001-2002 NaN Holding BV. All rights reserved. */
3 
8 #pragma once
9 
10 #include "IK_Math.h"
11 #include "IK_QJacobian.h"
12 #include "IK_QSegment.h"
13 
14 class IK_QTask {
15  public:
16  IK_QTask(int size, bool primary, bool active, const IK_QSegment *segment);
17  virtual ~IK_QTask()
18  {
19  }
20 
21  int Id() const
22  {
23  return m_size;
24  }
25 
26  void SetId(int id)
27  {
28  m_id = id;
29  }
30 
31  int Size() const
32  {
33  return m_size;
34  }
35 
36  bool Primary() const
37  {
38  return m_primary;
39  }
40 
41  bool Active() const
42  {
43  return m_active;
44  }
45 
46  double Weight() const
47  {
48  return m_weight * m_weight;
49  }
50 
51  void SetWeight(double weight)
52  {
53  m_weight = sqrt(weight);
54  }
55 
56  virtual void ComputeJacobian(IK_QJacobian &jacobian) = 0;
57 
58  virtual double Distance() const = 0;
59 
60  virtual bool PositionTask() const
61  {
62  return false;
63  }
64 
65  virtual void Scale(double)
66  {
67  }
68 
69  protected:
70  int m_id;
71  int m_size;
72  bool m_primary;
73  bool m_active;
75  double m_weight;
76 };
77 
78 class IK_QPositionTask : public IK_QTask {
79  public:
80  IK_QPositionTask(bool primary, const IK_QSegment *segment, const Vector3d &goal);
81 
82  void ComputeJacobian(IK_QJacobian &jacobian);
83 
84  double Distance() const;
85 
86  bool PositionTask() const
87  {
88  return true;
89  }
90  void Scale(double scale)
91  {
92  m_goal *= scale;
93  m_clamp_length *= scale;
94  }
95 
96  private:
97  Vector3d m_goal;
98  double m_clamp_length;
99 };
100 
102  public:
103  IK_QOrientationTask(bool primary, const IK_QSegment *segment, const Matrix3d &goal);
104 
105  double Distance() const
106  {
107  return m_distance;
108  }
109  void ComputeJacobian(IK_QJacobian &jacobian);
110 
111  private:
112  Matrix3d m_goal;
113  double m_distance;
114 };
115 
117  public:
118  IK_QCenterOfMassTask(bool primary, const IK_QSegment *segment, const Vector3d &center);
119 
120  void ComputeJacobian(IK_QJacobian &jacobian);
121 
122  double Distance() const;
123 
124  void Scale(double scale)
125  {
126  m_goal_center *= scale;
127  m_distance *= scale;
128  }
129 
130  private:
131  double ComputeTotalMass(const IK_QSegment *segment);
132  Vector3d ComputeCenter(const IK_QSegment *segment);
133  void JacobianSegment(IK_QJacobian &jacobian, Vector3d &center, const IK_QSegment *segment);
134 
135  Vector3d m_goal_center;
136  double m_total_mass_inv;
137  double m_distance;
138 };
sqrt(x)+1/max(0
NSNotificationCenter * center
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
void Scale(double scale)
Definition: IK_QTask.h:124
void ComputeJacobian(IK_QJacobian &jacobian)
Definition: IK_QTask.cpp:177
IK_QCenterOfMassTask(bool primary, const IK_QSegment *segment, const Vector3d &center)
Definition: IK_QTask.cpp:121
double Distance() const
Definition: IK_QTask.cpp:197
IK_QOrientationTask(bool primary, const IK_QSegment *segment, const Matrix3d &goal)
Definition: IK_QTask.cpp:79
double Distance() const
Definition: IK_QTask.h:105
void ComputeJacobian(IK_QJacobian &jacobian)
Definition: IK_QTask.cpp:86
void ComputeJacobian(IK_QJacobian &jacobian)
Definition: IK_QTask.cpp:37
void Scale(double scale)
Definition: IK_QTask.h:90
double Distance() const
Definition: IK_QTask.cpp:70
IK_QPositionTask(bool primary, const IK_QSegment *segment, const Vector3d &goal)
Definition: IK_QTask.cpp:19
bool PositionTask() const
Definition: IK_QTask.h:86
void SetId(int id)
Definition: IK_QTask.h:26
bool Active() const
Definition: IK_QTask.h:41
const IK_QSegment * m_segment
Definition: IK_QTask.h:74
void SetWeight(double weight)
Definition: IK_QTask.h:51
virtual void ComputeJacobian(IK_QJacobian &jacobian)=0
double Weight() const
Definition: IK_QTask.h:46
double m_weight
Definition: IK_QTask.h:75
bool Primary() const
Definition: IK_QTask.h:36
virtual ~IK_QTask()
Definition: IK_QTask.h:17
bool m_active
Definition: IK_QTask.h:73
virtual double Distance() const =0
bool m_primary
Definition: IK_QTask.h:72
virtual bool PositionTask() const
Definition: IK_QTask.h:60
int Id() const
Definition: IK_QTask.h:21
int m_size
Definition: IK_QTask.h:71
virtual void Scale(double)
Definition: IK_QTask.h:65
int m_id
Definition: IK_QTask.h:70
int Size() const
Definition: IK_QTask.h:31
IK_QTask(int size, bool primary, bool active, const IK_QSegment *segment)
Definition: IK_QTask.cpp:12
Segment< FEdge *, Vec3r > segment
bool active
all scheduled work for the GPU.