Depsgraph: remove EvaluationContext, pass Depsgraph instead.
[blender.git] / source / blender / ikplugin / intern / ikplugin_api.c
1 /*
2  * ***** BEGIN GPL LICENSE BLOCK *****
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software Foundation,
16  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  *
18  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
19  * All rights reserved.
20  *
21  * The Original Code is: all of this file.
22  *
23  * Original author: Benoit Bolsee
24  * Contributor(s): 
25  *
26  * ***** END GPL LICENSE BLOCK *****
27  */
28
29 /** \file blender/ikplugin/intern/ikplugin_api.c
30  *  \ingroup ikplugin
31  */
32
33 #include "BIK_api.h"
34 #include "BLI_blenlib.h"
35
36 #include "DNA_object_types.h"
37 #include "DNA_action_types.h"
38 #include "DNA_scene_types.h"
39
40 #include "ikplugin_api.h"
41
42 #ifdef WITH_IK_SOLVER
43 #  include "iksolver_plugin.h"
44 #endif
45
46 #ifdef WITH_IK_ITASC
47 #  include "itasc_plugin.h"
48 #endif
49
50 static IKPlugin ikplugin_tab[] = {
51 #ifdef WITH_IK_SOLVER
52         /* Legacy IK solver */
53         {
54                 iksolver_initialize_tree,
55                 iksolver_execute_tree,
56                 NULL,
57                 NULL,
58                 NULL,
59                 NULL,
60                 NULL,
61         },
62 #endif
63
64 #ifdef WITH_IK_ITASC
65         /* iTaSC IK solver */
66         {
67                 itasc_initialize_tree,
68                 itasc_execute_tree,
69                 itasc_release_tree,
70                 itasc_clear_data,
71                 itasc_clear_cache,
72                 itasc_update_param,
73                 itasc_test_constraint,
74         },
75 #endif
76
77         { NULL }
78 };
79
80 static IKPlugin *get_plugin(bPose *pose)
81 {
82         if (!pose || pose->iksolver < 0 || pose->iksolver >= ((sizeof(ikplugin_tab) / sizeof(IKPlugin)) - 1))
83                 return NULL;
84
85         return &ikplugin_tab[pose->iksolver];
86 }
87
88
89 /*----------------------------------------*/
90 /* Plugin API                                                     */
91
92 void BIK_initialize_tree(struct Depsgraph *depsgraph, Scene *scene, Object *ob, float ctime)
93 {
94         IKPlugin *plugin = get_plugin(ob->pose);
95
96         if (plugin && plugin->initialize_tree_func)
97                 plugin->initialize_tree_func(depsgraph, scene, ob, ctime);
98 }
99
100 void BIK_execute_tree(struct Depsgraph *depsgraph, struct Scene *scene, Object *ob, bPoseChannel *pchan, float ctime)
101 {
102         IKPlugin *plugin = get_plugin(ob->pose);
103
104         if (plugin && plugin->execute_tree_func)
105                 plugin->execute_tree_func(depsgraph, scene, ob, pchan, ctime);
106 }
107
108 void BIK_release_tree(struct Scene *scene, Object *ob, float ctime) 
109 {
110         IKPlugin *plugin = get_plugin(ob->pose);
111
112         if (plugin && plugin->release_tree_func)
113                 plugin->release_tree_func(scene, ob, ctime);
114 }
115
116 void BIK_clear_data(struct bPose *pose)
117 {
118         IKPlugin *plugin = get_plugin(pose);
119
120         if (plugin && plugin->remove_armature_func)
121                 plugin->remove_armature_func(pose);
122 }
123
124 void BIK_clear_cache(struct bPose *pose)
125 {
126         IKPlugin *plugin = get_plugin(pose);
127
128         if (plugin && plugin->clear_cache)
129                 plugin->clear_cache(pose);
130 }
131
132 void BIK_update_param(struct bPose *pose)
133 {
134         IKPlugin *plugin = get_plugin(pose);
135
136         if (plugin && plugin->update_param)
137                 plugin->update_param(pose);
138 }
139
140 void BIK_test_constraint(struct Object *ob, struct bConstraint *cons)
141 {
142         IKPlugin *plugin = get_plugin(ob->pose);
143
144         if (plugin && plugin->test_constraint)
145                 plugin->test_constraint(ob, cons);
146 }
147