Blender  V3.3
ikplugin_api.c
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 #include "BIK_api.h"
9 
10 #include "DNA_action_types.h"
11 #include "DNA_object_types.h"
12 #include "DNA_scene_types.h"
13 
14 #include "ikplugin_api.h"
15 
16 #ifdef WITH_IK_SOLVER
17 # include "iksolver_plugin.h"
18 #endif
19 
20 #ifdef WITH_IK_ITASC
21 # include "itasc_plugin.h"
22 #endif
23 
24 static IKPlugin ikplugin_tab[] = {
25 #ifdef WITH_IK_SOLVER
26  /* Legacy IK solver */
27  {
32  NULL,
33  NULL,
34  NULL,
35  },
36 #endif
37 
38 #ifdef WITH_IK_ITASC
39  /* iTaSC IK solver */
40  {
48  },
49 #endif
50 
51  {NULL}};
52 
53 static IKPlugin *get_plugin(bPose *pose)
54 {
55  if (!pose || pose->iksolver < 0 ||
56  pose->iksolver >= ((sizeof(ikplugin_tab) / sizeof(IKPlugin)) - 1)) {
57  return NULL;
58  }
59 
60  return &ikplugin_tab[pose->iksolver];
61 }
62 
63 /*----------------------------------------*/
64 /* Plugin API */
65 
66 void BIK_init_tree(struct Depsgraph *depsgraph, Scene *scene, Object *ob, float ctime)
67 {
68  IKPlugin *plugin = get_plugin(ob->pose);
69 
70  if (plugin && plugin->initialize_tree_func) {
71  plugin->initialize_tree_func(depsgraph, scene, ob, ctime);
72  }
73 }
74 
76  struct Depsgraph *depsgraph, struct Scene *scene, Object *ob, bPoseChannel *pchan, float ctime)
77 {
78  IKPlugin *plugin = get_plugin(ob->pose);
79 
80  if (plugin && plugin->execute_tree_func) {
81  plugin->execute_tree_func(depsgraph, scene, ob, pchan, ctime);
82  }
83 }
84 
85 void BIK_release_tree(struct Scene *scene, Object *ob, float ctime)
86 {
87  IKPlugin *plugin = get_plugin(ob->pose);
88 
89  if (plugin && plugin->release_tree_func) {
90  plugin->release_tree_func(scene, ob, ctime);
91  }
92 }
93 
94 void BIK_clear_data(struct bPose *pose)
95 {
96  IKPlugin *plugin = get_plugin(pose);
97 
98  if (plugin && plugin->remove_armature_func) {
99  plugin->remove_armature_func(pose);
100  }
101 }
102 
103 void BIK_clear_cache(struct bPose *pose)
104 {
105  IKPlugin *plugin = get_plugin(pose);
106 
107  if (plugin && plugin->clear_cache) {
108  plugin->clear_cache(pose);
109  }
110 }
111 
112 void BIK_update_param(struct bPose *pose)
113 {
114  IKPlugin *plugin = get_plugin(pose);
115 
116  if (plugin && plugin->update_param) {
117  plugin->update_param(pose);
118  }
119 }
120 
121 void BIK_test_constraint(struct Object *ob, struct bConstraint *cons)
122 {
123  IKPlugin *plugin = get_plugin(ob->pose);
124 
125  if (plugin && plugin->test_constraint) {
126  plugin->test_constraint(ob, cons);
127  }
128 }
struct Depsgraph Depsgraph
Definition: DEG_depsgraph.h:35
Object is a sort of wrapper for general info.
Scene scene
const Depsgraph * depsgraph
void BIK_clear_cache(struct bPose *pose)
Definition: ikplugin_api.c:103
void BIK_execute_tree(struct Depsgraph *depsgraph, struct Scene *scene, Object *ob, bPoseChannel *pchan, float ctime)
Definition: ikplugin_api.c:75
void BIK_test_constraint(struct Object *ob, struct bConstraint *cons)
Definition: ikplugin_api.c:121
void BIK_release_tree(struct Scene *scene, Object *ob, float ctime)
Definition: ikplugin_api.c:85
void BIK_init_tree(struct Depsgraph *depsgraph, Scene *scene, Object *ob, float ctime)
Definition: ikplugin_api.c:66
void BIK_update_param(struct bPose *pose)
Definition: ikplugin_api.c:112
static IKPlugin ikplugin_tab[]
Definition: ikplugin_api.c:24
void BIK_clear_data(struct bPose *pose)
Definition: ikplugin_api.c:94
static IKPlugin * get_plugin(bPose *pose)
Definition: ikplugin_api.c:53
void iksolver_execute_tree(struct Depsgraph *depsgraph, struct Scene *scene, Object *ob, bPoseChannel *pchan_root, float ctime)
void iksolver_initialize_tree(struct Depsgraph *UNUSED(depsgraph), struct Scene *UNUSED(scene), struct Object *ob, float UNUSED(ctime))
void iksolver_clear_data(bPose *pose)
void iksolver_release_tree(struct Scene *UNUSED(scene), struct Object *ob, float UNUSED(ctime))
void itasc_clear_cache(struct bPose *pose)
void itasc_clear_data(struct bPose *pose)
void itasc_update_param(struct bPose *pose)
void itasc_release_tree(struct Scene *scene, struct Object *ob, float ctime)
void itasc_initialize_tree(struct Depsgraph *depsgraph, struct Scene *scene, Object *ob, float ctime)
void itasc_execute_tree(struct Depsgraph *depsgraph, struct Scene *scene, Object *ob, bPoseChannel *pchan_root, float ctime)
void itasc_test_constraint(struct Object *ob, struct bConstraint *cons)
void(* clear_cache)(struct bPose *pose)
Definition: ikplugin_api.h:31
void(* remove_armature_func)(struct bPose *pose)
Definition: ikplugin_api.h:30
void(* initialize_tree_func)(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, float ctime)
Definition: ikplugin_api.h:20
void(* release_tree_func)(struct Scene *scene, struct Object *ob, float ctime)
Definition: ikplugin_api.h:29
void(* update_param)(struct bPose *pose)
Definition: ikplugin_api.h:32
void(* execute_tree_func)(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, struct bPoseChannel *pchan, float ctime)
Definition: ikplugin_api.h:24
void(* test_constraint)(struct Object *ob, struct bConstraint *cons)
Definition: ikplugin_api.h:33
struct bPose * pose