Blender  V2.59
physics_ops.c
Go to the documentation of this file.
00001 /*
00002  * $Id: physics_ops.c 36703 2011-05-15 16:42:39Z jhk $
00003  *
00004  * ***** BEGIN GPL LICENSE BLOCK *****
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * as published by the Free Software Foundation; either version 2
00009  * of the License, or (at your option) any later version. 
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software Foundation,
00018  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019  *
00020  * The Original Code is Copyright (C) 2009 Blender Foundation.
00021  * All rights reserved.
00022  *
00023  * Contributor(s): Blender Foundation
00024  *
00025  * ***** END GPL LICENSE BLOCK *****
00026  */
00027 
00033 #include <stdlib.h>
00034 
00035 
00036 #include "RNA_access.h"
00037 
00038 #include "WM_api.h"
00039 #include "WM_types.h"
00040 
00041 #include "ED_physics.h"
00042 #include "ED_object.h"
00043 
00044 #include "physics_intern.h" // own include
00045 
00046 /***************************** particles ***********************************/
00047 
00048 static void operatortypes_particle(void)
00049 {
00050         WM_operatortype_append(PARTICLE_OT_select_all);
00051         WM_operatortype_append(PARTICLE_OT_select_roots);
00052         WM_operatortype_append(PARTICLE_OT_select_tips);
00053         WM_operatortype_append(PARTICLE_OT_select_linked);
00054         WM_operatortype_append(PARTICLE_OT_select_less);
00055         WM_operatortype_append(PARTICLE_OT_select_more);
00056         WM_operatortype_append(PARTICLE_OT_select_inverse);
00057 
00058         WM_operatortype_append(PARTICLE_OT_hide);
00059         WM_operatortype_append(PARTICLE_OT_reveal);
00060 
00061         WM_operatortype_append(PARTICLE_OT_rekey);
00062         WM_operatortype_append(PARTICLE_OT_subdivide);
00063         WM_operatortype_append(PARTICLE_OT_remove_doubles);
00064         WM_operatortype_append(PARTICLE_OT_weight_set); 
00065         WM_operatortype_append(PARTICLE_OT_delete);
00066         WM_operatortype_append(PARTICLE_OT_mirror);
00067 
00068         WM_operatortype_append(PARTICLE_OT_brush_edit);
00069 
00070         WM_operatortype_append(PARTICLE_OT_particle_edit_toggle);
00071         WM_operatortype_append(PARTICLE_OT_edited_clear);
00072 
00073 
00074         WM_operatortype_append(OBJECT_OT_particle_system_add);
00075         WM_operatortype_append(OBJECT_OT_particle_system_remove);
00076 
00077         WM_operatortype_append(PARTICLE_OT_new);
00078         WM_operatortype_append(PARTICLE_OT_new_target);
00079         WM_operatortype_append(PARTICLE_OT_target_remove);
00080         WM_operatortype_append(PARTICLE_OT_target_move_up);
00081         WM_operatortype_append(PARTICLE_OT_target_move_down);
00082         WM_operatortype_append(PARTICLE_OT_connect_hair);
00083         WM_operatortype_append(PARTICLE_OT_disconnect_hair);
00084 
00085         WM_operatortype_append(PARTICLE_OT_dupliob_copy);
00086         WM_operatortype_append(PARTICLE_OT_dupliob_remove);
00087         WM_operatortype_append(PARTICLE_OT_dupliob_move_up);
00088         WM_operatortype_append(PARTICLE_OT_dupliob_move_down);
00089 }
00090 
00091 static void keymap_particle(wmKeyConfig *keyconf)
00092 {
00093         wmKeyMapItem *kmi;
00094         wmKeyMap *keymap;
00095         
00096         keymap= WM_keymap_find(keyconf, "Particle", 0, 0);
00097         keymap->poll= PE_poll;
00098         
00099         WM_keymap_add_item(keymap, "PARTICLE_OT_select_all", AKEY, KM_PRESS, 0, 0);
00100         WM_keymap_add_item(keymap, "PARTICLE_OT_select_more", PADPLUSKEY, KM_PRESS, KM_CTRL, 0);
00101         WM_keymap_add_item(keymap, "PARTICLE_OT_select_less", PADMINUS, KM_PRESS, KM_CTRL, 0);
00102         WM_keymap_add_item(keymap, "PARTICLE_OT_select_linked", LKEY, KM_PRESS, 0, 0);
00103         RNA_boolean_set(WM_keymap_add_item(keymap, "PARTICLE_OT_select_linked", LKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "deselect", 1);
00104         WM_keymap_add_item(keymap, "PARTICLE_OT_select_inverse", IKEY, KM_PRESS, KM_CTRL, 0);
00105 
00106         WM_keymap_add_item(keymap, "PARTICLE_OT_delete", XKEY, KM_PRESS, 0, 0);
00107         WM_keymap_add_item(keymap, "PARTICLE_OT_delete", DELKEY, KM_PRESS, 0, 0);
00108 
00109         WM_keymap_add_item(keymap, "PARTICLE_OT_reveal", HKEY, KM_PRESS, KM_ALT, 0);
00110         WM_keymap_add_item(keymap, "PARTICLE_OT_hide", HKEY, KM_PRESS, 0, 0);
00111         RNA_boolean_set(WM_keymap_add_item(keymap, "PARTICLE_OT_hide", HKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "unselected", 1);
00112 
00113         kmi = WM_keymap_verify_item(keymap, "VIEW3D_OT_manipulator", LEFTMOUSE, KM_PRESS, KM_ANY, 0);
00114         RNA_boolean_set(kmi->ptr, "release_confirm", 1);
00115 
00116         WM_keymap_add_item(keymap, "PARTICLE_OT_brush_edit", LEFTMOUSE, KM_PRESS, 0, 0);
00117         WM_keymap_add_item(keymap, "PARTICLE_OT_brush_edit", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0);
00118 
00119         /* size radial control */
00120         kmi = WM_keymap_add_item(keymap, "WM_OT_radial_control", FKEY, KM_PRESS, 0, 0);
00121         RNA_string_set(kmi->ptr, "data_path", "tool_settings.particle_edit.brush.size");
00122 
00123         /* size radial control */
00124         kmi = WM_keymap_add_item(keymap, "WM_OT_radial_control", FKEY, KM_PRESS, KM_SHIFT, 0);
00125         RNA_string_set(kmi->ptr, "data_path", "tool_settings.particle_edit.brush.strength");
00126 
00127         WM_keymap_add_menu(keymap, "VIEW3D_MT_particle_specials", WKEY, KM_PRESS, 0, 0);
00128         
00129         WM_keymap_add_item(keymap, "PARTICLE_OT_weight_set", KKEY, KM_PRESS, KM_SHIFT, 0);
00130 
00131         ED_object_generic_keymap(keyconf, keymap, 2);
00132 }
00133 
00134 /******************************* boids *************************************/
00135 
00136 static void operatortypes_boids(void)
00137 {
00138         WM_operatortype_append(BOID_OT_rule_add);
00139         WM_operatortype_append(BOID_OT_rule_del);
00140         WM_operatortype_append(BOID_OT_rule_move_up);
00141         WM_operatortype_append(BOID_OT_rule_move_down);
00142 
00143         WM_operatortype_append(BOID_OT_state_add);
00144         WM_operatortype_append(BOID_OT_state_del);
00145         WM_operatortype_append(BOID_OT_state_move_up);
00146         WM_operatortype_append(BOID_OT_state_move_down);
00147 }
00148 
00149 /********************************* fluid ***********************************/
00150 
00151 static void operatortypes_fluid(void)
00152 {
00153         WM_operatortype_append(FLUID_OT_bake);
00154 }
00155 
00156 /**************************** point cache **********************************/
00157 
00158 static void operatortypes_pointcache(void)
00159 {
00160         WM_operatortype_append(PTCACHE_OT_bake_all);
00161         WM_operatortype_append(PTCACHE_OT_free_bake_all);
00162         WM_operatortype_append(PTCACHE_OT_bake);
00163         WM_operatortype_append(PTCACHE_OT_free_bake);
00164         WM_operatortype_append(PTCACHE_OT_bake_from_cache);
00165         WM_operatortype_append(PTCACHE_OT_add);
00166         WM_operatortype_append(PTCACHE_OT_remove);
00167 }
00168 
00169 //static void keymap_pointcache(wmWindowManager *wm)
00170 //{
00171 //      wmKeyMap *keymap= WM_keymap_find(wm, "Pointcache", 0, 0);
00172 //      
00173 //      WM_keymap_add_item(keymap, "PHYSICS_OT_bake_all", AKEY, KM_PRESS, 0, 0);
00174 //      WM_keymap_add_item(keymap, "PHYSICS_OT_free_all", PADPLUSKEY, KM_PRESS, KM_CTRL, 0);
00175 //      WM_keymap_add_item(keymap, "PHYSICS_OT_bake_particle_system", PADMINUS, KM_PRESS, KM_CTRL, 0);
00176 //      WM_keymap_add_item(keymap, "PHYSICS_OT_free_particle_system", LKEY, KM_PRESS, 0, 0);
00177 //}
00178 
00179 /****************************** general ************************************/
00180 
00181 void ED_operatortypes_physics(void)
00182 {
00183         operatortypes_particle();
00184         operatortypes_boids();
00185         operatortypes_fluid();
00186         operatortypes_pointcache();
00187 }
00188 
00189 void ED_keymap_physics(wmKeyConfig *keyconf)
00190 {
00191         keymap_particle(keyconf);
00192         //keymap_pointcache(keyconf);
00193 }
00194 
00195 
00196