add hook in vertex and control point menu's, Ctrl+H
TODO's - add for lattice - break up add_hook - add other hook operators
This commit is contained in:
@@ -49,7 +49,7 @@ class PHYSICS_PT_softbody(PhysicButtonsPanel):
|
||||
ob = context.object
|
||||
|
||||
split = layout.split()
|
||||
split.operator_context = "EXEC_DEFAULT"
|
||||
split.operator_context = 'EXEC_DEFAULT'
|
||||
|
||||
if md:
|
||||
# remove modifier + settings
|
||||
|
||||
@@ -154,7 +154,7 @@ class IMAGE_MT_uvs_mirror(bpy.types.Menu):
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
layout.operator_context = "EXEC_REGION_WIN"
|
||||
layout.operator_context = 'EXEC_REGION_WIN'
|
||||
|
||||
props = layout.itemO("tfm.mirror", text="X Axis", properties=True)
|
||||
props.constraint_axis[0] = True
|
||||
|
||||
@@ -69,9 +69,9 @@ class INFO_MT_file(bpy.types.Menu):
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
layout.operator_context = "EXEC_AREA"
|
||||
layout.operator_context = 'EXEC_AREA'
|
||||
layout.itemO("wm.read_homefile", text="New", icon='ICON_NEW')
|
||||
layout.operator_context = "INVOKE_AREA"
|
||||
layout.operator_context = 'INVOKE_AREA'
|
||||
layout.itemO("wm.open_mainfile", text="Open...", icon='ICON_FILE_FOLDER')
|
||||
layout.item_menu_enumO("wm.open_recentfile", "file", text="Open Recent")
|
||||
layout.itemO("wm.recover_last_session")
|
||||
@@ -79,14 +79,14 @@ class INFO_MT_file(bpy.types.Menu):
|
||||
|
||||
layout.itemS()
|
||||
|
||||
layout.operator_context = "EXEC_AREA"
|
||||
layout.operator_context = 'EXEC_AREA'
|
||||
layout.itemO("wm.save_mainfile", text="Save", icon='ICON_FILE_TICK')
|
||||
layout.operator_context = "INVOKE_AREA"
|
||||
layout.operator_context = 'INVOKE_AREA'
|
||||
layout.itemO("wm.save_as_mainfile", text="Save As...")
|
||||
layout.itemO("screen.userpref_show", text="User Preferences...", icon='ICON_PREFERENCES')
|
||||
|
||||
layout.itemS()
|
||||
layout.operator_context = "INVOKE_AREA"
|
||||
layout.operator_context = 'INVOKE_AREA'
|
||||
layout.itemO("wm.link_append", text="Link")
|
||||
layout.item_booleanO("wm.link_append", "link", False, text="Append")
|
||||
layout.itemS()
|
||||
@@ -100,7 +100,7 @@ class INFO_MT_file(bpy.types.Menu):
|
||||
|
||||
layout.itemS()
|
||||
|
||||
layout.operator_context = "EXEC_AREA"
|
||||
layout.operator_context = 'EXEC_AREA'
|
||||
layout.itemO("wm.exit_blender", text="Quit", icon='ICON_QUIT')
|
||||
|
||||
# test for expanding menus
|
||||
@@ -177,7 +177,7 @@ class INFO_MT_add(bpy.types.Menu):
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
layout.operator_context = "EXEC_SCREEN"
|
||||
layout.operator_context = 'EXEC_SCREEN'
|
||||
|
||||
# layout.item_menu_enumO("object.mesh_add", "type", text="Mesh", icon='ICON_OUTLINER_OB_MESH')
|
||||
layout.itemM("INFO_MT_mesh_add", icon='ICON_OUTLINER_OB_MESH')
|
||||
@@ -189,7 +189,7 @@ class INFO_MT_add(bpy.types.Menu):
|
||||
|
||||
layout.itemS()
|
||||
|
||||
layout.operator_context = "INVOKE_SCREEN"
|
||||
layout.operator_context = 'INVOKE_SCREEN'
|
||||
|
||||
layout.itemO("object.armature_add", text="Armature", icon='ICON_OUTLINER_OB_ARMATURE')
|
||||
layout.item_enumO("object.add", "type", 'LATTICE', icon='ICON_OUTLINER_OB_LATTICE')
|
||||
@@ -199,7 +199,7 @@ class INFO_MT_add(bpy.types.Menu):
|
||||
|
||||
layout.item_enumO("object.add", "type", 'CAMERA', icon='ICON_OUTLINER_OB_CAMERA')
|
||||
|
||||
layout.operator_context = "EXEC_SCREEN"
|
||||
layout.operator_context = 'EXEC_SCREEN'
|
||||
|
||||
layout.item_menu_enumO("object.lamp_add", "type", 'LAMP', text="Lamp", icon='ICON_OUTLINER_OB_LAMP')
|
||||
|
||||
|
||||
@@ -29,11 +29,11 @@ class USERPREF_HT_header(bpy.types.Header):
|
||||
|
||||
userpref = context.user_preferences
|
||||
|
||||
layout.operator_context = "EXEC_AREA"
|
||||
layout.operator_context = 'EXEC_AREA'
|
||||
layout.itemO("wm.save_homefile", text="Save As Default")
|
||||
|
||||
if userpref.active_section == 'INPUT':
|
||||
layout.operator_context = "INVOKE_DEFAULT"
|
||||
layout.operator_context = 'INVOKE_DEFAULT'
|
||||
layout.itemO("wm.keyconfig_export", "Export Key Configuration...")
|
||||
|
||||
|
||||
|
||||
@@ -137,7 +137,7 @@ class VIEW3D_MT_view(bpy.types.Menu):
|
||||
|
||||
layout.itemS()
|
||||
|
||||
layout.operator_context = "INVOKE_REGION_WIN"
|
||||
layout.operator_context = 'INVOKE_REGION_WIN'
|
||||
|
||||
layout.itemO("view3d.clip_border", text="Clipping Border...")
|
||||
layout.itemO("view3d.zoom_border", text="Zoom Border...")
|
||||
@@ -668,6 +668,18 @@ class VIEW3D_MT_paint_vertex(bpy.types.Menu):
|
||||
props = layout.itemO("paint.vertex_color_set", text="Set Selected Vertex Colors", properties=True)
|
||||
props.selected = True
|
||||
|
||||
|
||||
class VIEW3D_MT_hook(bpy.types.Menu):
|
||||
bl_label = "Hooks"
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
layout.operator_context = 'EXEC_AREA'
|
||||
layout.items_enumO("object.hook_add", "type")
|
||||
# layout.itemS()
|
||||
# Other operators still need porting
|
||||
|
||||
|
||||
# ********** Sculpt menu **********
|
||||
|
||||
|
||||
@@ -782,7 +794,7 @@ class VIEW3D_MT_pose(bpy.types.Menu):
|
||||
|
||||
layout.itemS()
|
||||
|
||||
layout.operator_context = "EXEC_AREA"
|
||||
layout.operator_context = 'EXEC_AREA'
|
||||
layout.item_enumO("pose.autoside_names", "axis", 'XAXIS', text="AutoName Left/Right")
|
||||
layout.item_enumO("pose.autoside_names", "axis", 'YAXIS', text="AutoName Front/Back")
|
||||
layout.item_enumO("pose.autoside_names", "axis", 'ZAXIS', text="AutoName Top/Bottom")
|
||||
@@ -791,7 +803,7 @@ class VIEW3D_MT_pose(bpy.types.Menu):
|
||||
|
||||
layout.itemS()
|
||||
|
||||
layout.operator_context = "INVOKE_AREA"
|
||||
layout.operator_context = 'INVOKE_AREA'
|
||||
layout.itemO("pose.armature_layers", text="Change Armature Layers...")
|
||||
layout.itemO("pose.bone_layers", text="Change Bone Layers...")
|
||||
|
||||
@@ -973,6 +985,10 @@ class VIEW3D_MT_edit_mesh_vertices(bpy.types.Menu):
|
||||
layout.itemO("object.vertex_group_blend")
|
||||
layout.itemO("mesh.shape_propagate_to_all")
|
||||
|
||||
layout.itemS()
|
||||
|
||||
layout.itemM("VIEW3D_MT_hook")
|
||||
|
||||
|
||||
class VIEW3D_MT_edit_mesh_edges(bpy.types.Menu):
|
||||
bl_label = "Edges"
|
||||
@@ -1128,6 +1144,10 @@ class VIEW3D_MT_edit_curve_ctrlpoints(bpy.types.Menu):
|
||||
|
||||
layout.item_menu_enumO("curve.handle_type_set", "type")
|
||||
|
||||
layout.itemS()
|
||||
|
||||
layout.itemM("VIEW3D_MT_hook")
|
||||
|
||||
|
||||
class VIEW3D_MT_edit_curve_segments(bpy.types.Menu):
|
||||
bl_label = "Segments"
|
||||
@@ -1294,7 +1314,7 @@ class VIEW3D_MT_edit_armature(bpy.types.Menu):
|
||||
|
||||
layout.itemS()
|
||||
|
||||
layout.operator_context = "EXEC_AREA"
|
||||
layout.operator_context = 'EXEC_AREA'
|
||||
layout.item_enumO("armature.autoside_names", "type", 'XAXIS', text="AutoName Left/Right")
|
||||
layout.item_enumO("armature.autoside_names", "type", 'YAXIS', text="AutoName Front/Back")
|
||||
layout.item_enumO("armature.autoside_names", "type", 'ZAXIS', text="AutoName Top/Bottom")
|
||||
@@ -1302,7 +1322,7 @@ class VIEW3D_MT_edit_armature(bpy.types.Menu):
|
||||
|
||||
layout.itemS()
|
||||
|
||||
layout.operator_context = "INVOKE_DEFAULT"
|
||||
layout.operator_context = 'INVOKE_DEFAULT'
|
||||
layout.itemO("armature.armature_layers")
|
||||
layout.itemO("armature.bone_layers")
|
||||
|
||||
@@ -1679,6 +1699,7 @@ bpy.types.register(VIEW3D_MT_object_showhide)
|
||||
bpy.types.register(VIEW3D_MT_make_single_user)
|
||||
bpy.types.register(VIEW3D_MT_make_links)
|
||||
|
||||
bpy.types.register(VIEW3D_MT_hook)
|
||||
|
||||
bpy.types.register(VIEW3D_MT_sculpt) # Sculpt Menu
|
||||
|
||||
|
||||
@@ -161,7 +161,7 @@ void paint_brush_slot_remove(Paint *p)
|
||||
|
||||
int paint_facesel_test(Object *ob)
|
||||
{
|
||||
return (ob && ob->data && (((Mesh *)ob->data)->editflag & ME_EDIT_PAINT_MASK) && (ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT|OB_MODE_TEXTURE_PAINT)));
|
||||
return (ob && ob->type==OB_MESH && ob->data && (((Mesh *)ob->data)->editflag & ME_EDIT_PAINT_MASK) && (ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT|OB_MODE_TEXTURE_PAINT)));
|
||||
}
|
||||
|
||||
void paint_init(Paint *p, const char col[3])
|
||||
|
||||
@@ -164,6 +164,7 @@ void ED_operatortypes_curve(void)
|
||||
void ED_keymap_curve(wmKeyConfig *keyconf)
|
||||
{
|
||||
wmKeyMap *keymap;
|
||||
wmKeyMapItem *kmi;
|
||||
|
||||
keymap= WM_keymap_find(keyconf, "Font", 0, 0);
|
||||
keymap->poll= ED_operator_editfont;
|
||||
@@ -249,6 +250,10 @@ void ED_keymap_curve(wmKeyConfig *keyconf)
|
||||
|
||||
WM_keymap_add_item(keymap, "CURVE_OT_specials_menu", WKEY, KM_PRESS, 0, 0);
|
||||
|
||||
/* menus */
|
||||
kmi= WM_keymap_add_item(keymap, "WM_OT_call_menu", HKEY, KM_PRESS, KM_CTRL, 0);
|
||||
RNA_string_set(kmi->ptr, "name", "VIEW3D_MT_hook");
|
||||
|
||||
ED_object_generic_keymap(keyconf, keymap, TRUE);
|
||||
}
|
||||
|
||||
|
||||
@@ -157,7 +157,7 @@ void ED_operatormacros_mesh(void)
|
||||
{
|
||||
wmOperatorType *ot;
|
||||
wmOperatorTypeMacro *otmacro;
|
||||
int constraint_axis[3] = {0, 0, 1};
|
||||
// int constraint_axis[3] = {0, 0, 1};
|
||||
|
||||
/*combining operators with invoke and exec portions doesn't work yet.
|
||||
|
||||
@@ -231,7 +231,7 @@ void ED_keymap_mesh(wmKeyConfig *keyconf)
|
||||
WM_keymap_add_item(keymap, "MESH_OT_hide", HKEY, KM_PRESS, 0, 0);
|
||||
RNA_boolean_set(WM_keymap_add_item(keymap, "MESH_OT_hide", HKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "unselected", 1);
|
||||
WM_keymap_add_item(keymap, "MESH_OT_reveal", HKEY, KM_PRESS, KM_ALT, 0);
|
||||
|
||||
|
||||
/* tools */
|
||||
WM_keymap_add_item(keymap, "MESH_OT_normals_make_consistent", NKEY, KM_PRESS, KM_CTRL, 0);
|
||||
RNA_boolean_set(WM_keymap_add_item(keymap, "MESH_OT_normals_make_consistent", NKEY, KM_PRESS, KM_SHIFT|KM_CTRL, 0)->ptr, "inside", 1);
|
||||
@@ -297,6 +297,9 @@ void ED_keymap_mesh(wmKeyConfig *keyconf)
|
||||
kmi= WM_keymap_add_item(keymap, "WM_OT_call_menu", VKEY, KM_PRESS, KM_CTRL, 0);
|
||||
RNA_string_set(kmi->ptr, "name", "VIEW3D_MT_edit_mesh_vertices");
|
||||
|
||||
kmi= WM_keymap_add_item(keymap, "WM_OT_call_menu", HKEY, KM_PRESS, KM_CTRL, 0);
|
||||
RNA_string_set(kmi->ptr, "name", "VIEW3D_MT_hook");
|
||||
|
||||
kmi= WM_keymap_add_item(keymap, "WM_OT_call_menu", UKEY, KM_PRESS, 0, 0);
|
||||
RNA_string_set(kmi->ptr, "name", "VIEW3D_MT_uv_map");
|
||||
|
||||
|
||||
@@ -2135,4 +2135,3 @@ void OBJECT_OT_game_property_remove(wmOperatorType *ot)
|
||||
|
||||
RNA_def_int(ot->srna, "index", 0, 0, INT_MAX, "Index", "Property index to remove ", 0, INT_MAX);
|
||||
}
|
||||
|
||||
|
||||
@@ -43,18 +43,26 @@
|
||||
#include "DNA_object_types.h"
|
||||
#include "DNA_scene_types.h"
|
||||
#include "DNA_view3d_types.h"
|
||||
#include "DNA_windowmanager_types.h"
|
||||
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_customdata.h"
|
||||
#include "BKE_depsgraph.h"
|
||||
#include "BKE_mesh.h"
|
||||
#include "BKE_modifier.h"
|
||||
#include "BKE_object.h"
|
||||
|
||||
#include "RNA_define.h"
|
||||
#include "RNA_access.h"
|
||||
|
||||
#include "ED_curve.h"
|
||||
#include "ED_mesh.h"
|
||||
#include "ED_object.h"
|
||||
#include "ED_view3d.h"
|
||||
|
||||
#include "WM_types.h"
|
||||
#include "WM_api.h"
|
||||
|
||||
#include "object_intern.h"
|
||||
|
||||
/* XXX operators for this are not implemented yet */
|
||||
@@ -610,3 +618,42 @@ void hookmenu(Scene *scene, View3D *v3d)
|
||||
}
|
||||
}
|
||||
|
||||
static int object_add_hook_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
View3D *v3d = CTX_wm_view3d(C);
|
||||
|
||||
int mode= RNA_enum_get(op->ptr, "type");
|
||||
|
||||
// XXX - todo, break up this function for different operators
|
||||
// and detect if this finished correctly or not,
|
||||
add_hook(scene, v3d, mode);
|
||||
|
||||
WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene);
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void OBJECT_OT_hook_add(wmOperatorType *ot)
|
||||
{
|
||||
static EnumPropertyItem prop_new_hook_types[] = {
|
||||
{1, "NEW", 0, "New Object", "Create a new object and assign the verts to it."},
|
||||
{2, "SELECTED", 0, "Selection", "Add the hook to the selected object."},
|
||||
{0, NULL, 0, NULL, NULL}
|
||||
};
|
||||
|
||||
/* identifiers */
|
||||
ot->name= "Add Hook";
|
||||
ot->description= "Add hook to selected verts.";
|
||||
ot->idname= "OBJECT_OT_hook_add";
|
||||
|
||||
/* api callbacks */
|
||||
ot->invoke= WM_menu_invoke;
|
||||
ot->exec= object_add_hook_exec;
|
||||
// ot->poll= ED_operator_editmesh;
|
||||
|
||||
/* flags */
|
||||
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
|
||||
RNA_def_enum(ot->srna, "type", prop_new_hook_types, 0, "Type", "");
|
||||
}
|
||||
|
||||
|
||||
@@ -106,6 +106,8 @@ void OBJECT_OT_convert(struct wmOperatorType *ot);
|
||||
int object_hook_index_array(Object *obedit, int *tot, int **indexar, char *name, float *cent_r);
|
||||
void object_hook_select(Object *obedit, struct HookModifierData *hmd);
|
||||
|
||||
void OBJECT_OT_hook_add(struct wmOperatorType *ot);
|
||||
|
||||
/* object_lattice.c */
|
||||
void free_editLatt(Object *ob);
|
||||
void make_editLatt(Object *obedit);
|
||||
|
||||
@@ -188,6 +188,8 @@ void ED_operatortypes_object(void)
|
||||
|
||||
WM_operatortype_append(OBJECT_OT_group_add);
|
||||
WM_operatortype_append(OBJECT_OT_group_remove);
|
||||
|
||||
WM_operatortype_append(OBJECT_OT_hook_add);
|
||||
}
|
||||
|
||||
void ED_operatormacros_object(void)
|
||||
|
||||
Reference in New Issue
Block a user