Fix assert in some cases when using DataTransfer modifier for custom normals.
[blender.git] / source / blender / editors / physics / physics_ops.c
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) 2009 Blender Foundation.
17  * All rights reserved.
18  */
19
20 /** \file
21  * \ingroup edphys
22  */
23
24 #include <stdlib.h>
25
26 #include "RNA_access.h"
27
28 #include "WM_api.h"
29 #include "WM_types.h"
30
31 #include "ED_select_utils.h"
32 #include "ED_physics.h"
33 #include "ED_object.h"
34
35 #include "physics_intern.h"  // own include
36
37 /***************************** particles ***********************************/
38
39 static void operatortypes_particle(void)
40 {
41   WM_operatortype_append(PARTICLE_OT_select_all);
42   WM_operatortype_append(PARTICLE_OT_select_roots);
43   WM_operatortype_append(PARTICLE_OT_select_tips);
44   WM_operatortype_append(PARTICLE_OT_select_random);
45   WM_operatortype_append(PARTICLE_OT_select_linked);
46   WM_operatortype_append(PARTICLE_OT_select_less);
47   WM_operatortype_append(PARTICLE_OT_select_more);
48
49   WM_operatortype_append(PARTICLE_OT_hide);
50   WM_operatortype_append(PARTICLE_OT_reveal);
51
52   WM_operatortype_append(PARTICLE_OT_rekey);
53   WM_operatortype_append(PARTICLE_OT_subdivide);
54   WM_operatortype_append(PARTICLE_OT_remove_doubles);
55   WM_operatortype_append(PARTICLE_OT_weight_set);
56   WM_operatortype_append(PARTICLE_OT_delete);
57   WM_operatortype_append(PARTICLE_OT_mirror);
58
59   WM_operatortype_append(PARTICLE_OT_brush_edit);
60
61   WM_operatortype_append(PARTICLE_OT_shape_cut);
62
63   WM_operatortype_append(PARTICLE_OT_particle_edit_toggle);
64   WM_operatortype_append(PARTICLE_OT_edited_clear);
65
66   WM_operatortype_append(PARTICLE_OT_unify_length);
67
68   WM_operatortype_append(OBJECT_OT_particle_system_add);
69   WM_operatortype_append(OBJECT_OT_particle_system_remove);
70
71   WM_operatortype_append(PARTICLE_OT_new);
72   WM_operatortype_append(PARTICLE_OT_new_target);
73   WM_operatortype_append(PARTICLE_OT_target_remove);
74   WM_operatortype_append(PARTICLE_OT_target_move_up);
75   WM_operatortype_append(PARTICLE_OT_target_move_down);
76   WM_operatortype_append(PARTICLE_OT_connect_hair);
77   WM_operatortype_append(PARTICLE_OT_disconnect_hair);
78   WM_operatortype_append(PARTICLE_OT_copy_particle_systems);
79   WM_operatortype_append(PARTICLE_OT_duplicate_particle_system);
80
81   WM_operatortype_append(PARTICLE_OT_dupliob_refresh);
82   WM_operatortype_append(PARTICLE_OT_dupliob_copy);
83   WM_operatortype_append(PARTICLE_OT_dupliob_remove);
84   WM_operatortype_append(PARTICLE_OT_dupliob_move_up);
85   WM_operatortype_append(PARTICLE_OT_dupliob_move_down);
86
87   WM_operatortype_append(RIGIDBODY_OT_object_add);
88   WM_operatortype_append(RIGIDBODY_OT_object_remove);
89
90   WM_operatortype_append(RIGIDBODY_OT_objects_add);
91   WM_operatortype_append(RIGIDBODY_OT_objects_remove);
92
93   WM_operatortype_append(RIGIDBODY_OT_shape_change);
94   WM_operatortype_append(RIGIDBODY_OT_mass_calculate);
95
96   WM_operatortype_append(RIGIDBODY_OT_constraint_add);
97   WM_operatortype_append(RIGIDBODY_OT_constraint_remove);
98
99   WM_operatortype_append(RIGIDBODY_OT_world_add);
100   WM_operatortype_append(RIGIDBODY_OT_world_remove);
101   //  WM_operatortype_append(RIGIDBODY_OT_world_export);
102 }
103
104 static void keymap_particle(wmKeyConfig *keyconf)
105 {
106   wmKeyMap *keymap = WM_keymap_ensure(keyconf, "Particle", 0, 0);
107   keymap->poll = PE_poll;
108 }
109
110 /******************************* boids *************************************/
111
112 static void operatortypes_boids(void)
113 {
114   WM_operatortype_append(BOID_OT_rule_add);
115   WM_operatortype_append(BOID_OT_rule_del);
116   WM_operatortype_append(BOID_OT_rule_move_up);
117   WM_operatortype_append(BOID_OT_rule_move_down);
118
119   WM_operatortype_append(BOID_OT_state_add);
120   WM_operatortype_append(BOID_OT_state_del);
121   WM_operatortype_append(BOID_OT_state_move_up);
122   WM_operatortype_append(BOID_OT_state_move_down);
123 }
124
125 /********************************* fluid ***********************************/
126
127 static void operatortypes_fluid(void)
128 {
129   WM_operatortype_append(FLUID_OT_bake);
130 }
131
132 /**************************** point cache **********************************/
133
134 static void operatortypes_pointcache(void)
135 {
136   WM_operatortype_append(PTCACHE_OT_bake_all);
137   WM_operatortype_append(PTCACHE_OT_free_bake_all);
138   WM_operatortype_append(PTCACHE_OT_bake);
139   WM_operatortype_append(PTCACHE_OT_free_bake);
140   WM_operatortype_append(PTCACHE_OT_bake_from_cache);
141   WM_operatortype_append(PTCACHE_OT_add);
142   WM_operatortype_append(PTCACHE_OT_remove);
143 }
144
145 /********************************* dynamic paint ***********************************/
146
147 static void operatortypes_dynamicpaint(void)
148 {
149   WM_operatortype_append(DPAINT_OT_bake);
150   WM_operatortype_append(DPAINT_OT_surface_slot_add);
151   WM_operatortype_append(DPAINT_OT_surface_slot_remove);
152   WM_operatortype_append(DPAINT_OT_type_toggle);
153   WM_operatortype_append(DPAINT_OT_output_toggle);
154 }
155
156 /****************************** general ************************************/
157
158 void ED_operatortypes_physics(void)
159 {
160   operatortypes_particle();
161   operatortypes_boids();
162   operatortypes_fluid();
163   operatortypes_pointcache();
164   operatortypes_dynamicpaint();
165 }
166
167 void ED_keymap_physics(wmKeyConfig *keyconf)
168 {
169   keymap_particle(keyconf);
170 }