Blender  V2.93
IK_QTask.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
17  * All rights reserved.
18  * Original author: Laurence
19  */
20 
25 #pragma once
26 
27 #include "IK_Math.h"
28 #include "IK_QJacobian.h"
29 #include "IK_QSegment.h"
30 
31 class IK_QTask {
32  public:
33  IK_QTask(int size, bool primary, bool active, const IK_QSegment *segment);
34  virtual ~IK_QTask()
35  {
36  }
37 
38  int Id() const
39  {
40  return m_size;
41  }
42 
43  void SetId(int id)
44  {
45  m_id = id;
46  }
47 
48  int Size() const
49  {
50  return m_size;
51  }
52 
53  bool Primary() const
54  {
55  return m_primary;
56  }
57 
58  bool Active() const
59  {
60  return m_active;
61  }
62 
63  double Weight() const
64  {
65  return m_weight * m_weight;
66  }
67 
68  void SetWeight(double weight)
69  {
70  m_weight = sqrt(weight);
71  }
72 
73  virtual void ComputeJacobian(IK_QJacobian &jacobian) = 0;
74 
75  virtual double Distance() const = 0;
76 
77  virtual bool PositionTask() const
78  {
79  return false;
80  }
81 
82  virtual void Scale(double)
83  {
84  }
85 
86  protected:
87  int m_id;
88  int m_size;
89  bool m_primary;
90  bool m_active;
92  double m_weight;
93 };
94 
95 class IK_QPositionTask : public IK_QTask {
96  public:
97  IK_QPositionTask(bool primary, const IK_QSegment *segment, const Vector3d &goal);
98 
99  void ComputeJacobian(IK_QJacobian &jacobian);
100 
101  double Distance() const;
102 
103  bool PositionTask() const
104  {
105  return true;
106  }
107  void Scale(double scale)
108  {
109  m_goal *= scale;
110  m_clamp_length *= scale;
111  }
112 
113  private:
114  Vector3d m_goal;
115  double m_clamp_length;
116 };
117 
119  public:
120  IK_QOrientationTask(bool primary, const IK_QSegment *segment, const Matrix3d &goal);
121 
122  double Distance() const
123  {
124  return m_distance;
125  }
126  void ComputeJacobian(IK_QJacobian &jacobian);
127 
128  private:
129  Matrix3d m_goal;
130  double m_distance;
131 };
132 
134  public:
135  IK_QCenterOfMassTask(bool primary, const IK_QSegment *segment, const Vector3d &center);
136 
137  void ComputeJacobian(IK_QJacobian &jacobian);
138 
139  double Distance() const;
140 
141  void Scale(double scale)
142  {
143  m_goal_center *= scale;
144  m_distance *= scale;
145  }
146 
147  private:
148  double ComputeTotalMass(const IK_QSegment *segment);
149  Vector3d ComputeCenter(const IK_QSegment *segment);
150  void JacobianSegment(IK_QJacobian &jacobian, Vector3d &center, const IK_QSegment *segment);
151 
152  Vector3d m_goal_center;
153  double m_total_mass_inv;
154  double m_distance;
155 };
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:141
void ComputeJacobian(IK_QJacobian &jacobian)
Definition: IK_QTask.cpp:193
IK_QCenterOfMassTask(bool primary, const IK_QSegment *segment, const Vector3d &center)
Definition: IK_QTask.cpp:137
double Distance() const
Definition: IK_QTask.cpp:213
IK_QOrientationTask(bool primary, const IK_QSegment *segment, const Matrix3d &goal)
Definition: IK_QTask.cpp:95
double Distance() const
Definition: IK_QTask.h:122
void ComputeJacobian(IK_QJacobian &jacobian)
Definition: IK_QTask.cpp:102
void ComputeJacobian(IK_QJacobian &jacobian)
Definition: IK_QTask.cpp:53
void Scale(double scale)
Definition: IK_QTask.h:107
double Distance() const
Definition: IK_QTask.cpp:86
IK_QPositionTask(bool primary, const IK_QSegment *segment, const Vector3d &goal)
Definition: IK_QTask.cpp:35
bool PositionTask() const
Definition: IK_QTask.h:103
void SetId(int id)
Definition: IK_QTask.h:43
bool Active() const
Definition: IK_QTask.h:58
const IK_QSegment * m_segment
Definition: IK_QTask.h:91
void SetWeight(double weight)
Definition: IK_QTask.h:68
virtual void ComputeJacobian(IK_QJacobian &jacobian)=0
double Weight() const
Definition: IK_QTask.h:63
double m_weight
Definition: IK_QTask.h:92
bool Primary() const
Definition: IK_QTask.h:53
virtual ~IK_QTask()
Definition: IK_QTask.h:34
bool m_active
Definition: IK_QTask.h:90
virtual double Distance() const =0
bool m_primary
Definition: IK_QTask.h:89
virtual bool PositionTask() const
Definition: IK_QTask.h:77
int Id() const
Definition: IK_QTask.h:38
int m_size
Definition: IK_QTask.h:88
virtual void Scale(double)
Definition: IK_QTask.h:82
int m_id
Definition: IK_QTask.h:87
int Size() const
Definition: IK_QTask.h:48
IK_QTask(int size, bool primary, bool active, const IK_QSegment *segment)
Definition: IK_QTask.cpp:28
Segment< FEdge *, Vec3r > segment
bool active
all scheduled work for the GPU.