Changeset View
Changeset View
Standalone View
Standalone View
source/blender/makesrna/intern/rna_scene.c
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
| Show First 20 Lines • Show All 145 Lines • ▼ Show 20 Lines | |||||
| const EnumPropertyItem rna_enum_snap_element_items[] = { | const EnumPropertyItem rna_enum_snap_element_items[] = { | ||||
| {SCE_SNAP_MODE_INCREMENT, | {SCE_SNAP_MODE_INCREMENT, | ||||
| "INCREMENT", | "INCREMENT", | ||||
| ICON_SNAP_INCREMENT, | ICON_SNAP_INCREMENT, | ||||
| "Increment", | "Increment", | ||||
| "Snap to increments of grid"}, | "Snap to increments of grid"}, | ||||
| {SCE_SNAP_MODE_VERTEX, "VERTEX", ICON_SNAP_VERTEX, "Vertex", "Snap to vertices"}, | {SCE_SNAP_MODE_VERTEX, "VERTEX", ICON_SNAP_VERTEX, "Vertex", "Snap to vertices"}, | ||||
| {SCE_SNAP_MODE_EDGE, "EDGE", ICON_SNAP_EDGE, "Edge", "Snap to edges"}, | {SCE_SNAP_MODE_EDGE, "EDGE", ICON_SNAP_EDGE, "Edge", "Snap to edges"}, | ||||
| {SCE_SNAP_MODE_FACE, "FACE", ICON_SNAP_FACE, "Face", "Snap to faces"}, | {SCE_SNAP_MODE_FACE_RAYCAST, | ||||
| "FACE", /* TODO(@gfxcoder): replace with "FACE_RAYCAST" as "FACE" is not descriptive. */ | |||||
| ICON_SNAP_FACE, | |||||
| "Face Project", | |||||
| "Snap by projecting onto faces"}, | |||||
| {SCE_SNAP_MODE_FACE_NEAREST, | |||||
| "FACE_NEAREST", | |||||
| ICON_SNAP_FACE_NEAREST, | |||||
| "Face Nearest", | |||||
| "Snap to nearest point on faces"}, | |||||
| {SCE_SNAP_MODE_VOLUME, "VOLUME", ICON_SNAP_VOLUME, "Volume", "Snap to volume"}, | {SCE_SNAP_MODE_VOLUME, "VOLUME", ICON_SNAP_VOLUME, "Volume", "Snap to volume"}, | ||||
| {SCE_SNAP_MODE_EDGE_MIDPOINT, | {SCE_SNAP_MODE_EDGE_MIDPOINT, | ||||
| "EDGE_MIDPOINT", | "EDGE_MIDPOINT", | ||||
| ICON_SNAP_MIDPOINT, | ICON_SNAP_MIDPOINT, | ||||
| "Edge Center", | "Edge Center", | ||||
| "Snap to the middle of edges"}, | "Snap to the middle of edges"}, | ||||
| {SCE_SNAP_MODE_EDGE_PERPENDICULAR, | {SCE_SNAP_MODE_EDGE_PERPENDICULAR, | ||||
| "EDGE_PERPENDICULAR", | "EDGE_PERPENDICULAR", | ||||
| ICON_SNAP_PERPENDICULAR, | ICON_SNAP_PERPENDICULAR, | ||||
| "Edge Perpendicular", | "Edge Perpendicular", | ||||
| "Snap to the nearest point on an edge"}, | "Snap to the nearest point on an edge"}, | ||||
| {0, NULL, 0, NULL, NULL}, | {0, NULL, 0, NULL, NULL}, | ||||
campbellbarton: Maybe this could be called `SCE_SNAP_MODE_FACE_NEAREST` since the difference between SURFACE… | |||||
Done Inline Actions(changed, see comment) gfxcoder: (changed, see comment) | |||||
| }; | }; | ||||
| const EnumPropertyItem rna_enum_snap_node_element_items[] = { | const EnumPropertyItem rna_enum_snap_node_element_items[] = { | ||||
| {SCE_SNAP_MODE_GRID, "GRID", ICON_SNAP_GRID, "Grid", "Snap to grid"}, | {SCE_SNAP_MODE_GRID, "GRID", ICON_SNAP_GRID, "Grid", "Snap to grid"}, | ||||
| {SCE_SNAP_MODE_NODE_X, "NODE_X", ICON_NODE_SIDE, "Node X", "Snap to left/right node border"}, | {SCE_SNAP_MODE_NODE_X, "NODE_X", ICON_NODE_SIDE, "Node X", "Snap to left/right node border"}, | ||||
| {SCE_SNAP_MODE_NODE_Y, "NODE_Y", ICON_NODE_TOP, "Node Y", "Snap to top/bottom node border"}, | {SCE_SNAP_MODE_NODE_Y, "NODE_Y", ICON_NODE_TOP, "Node Y", "Snap to top/bottom node border"}, | ||||
| {SCE_SNAP_MODE_NODE_X | SCE_SNAP_MODE_NODE_Y, | {SCE_SNAP_MODE_NODE_X | SCE_SNAP_MODE_NODE_Y, | ||||
| "NODE_XY", | "NODE_XY", | ||||
| ▲ Show 20 Lines • Show All 3,121 Lines • ▼ Show 20 Lines | static void rna_def_tool_settings(BlenderRNA *brna) | ||||
| prop = RNA_def_property(srna, "snap_elements", PROP_ENUM, PROP_NONE); | prop = RNA_def_property(srna, "snap_elements", PROP_ENUM, PROP_NONE); | ||||
| RNA_def_property_enum_bitflag_sdna(prop, NULL, "snap_mode"); | RNA_def_property_enum_bitflag_sdna(prop, NULL, "snap_mode"); | ||||
| RNA_def_property_enum_items(prop, rna_enum_snap_element_items); | RNA_def_property_enum_items(prop, rna_enum_snap_element_items); | ||||
| RNA_def_property_enum_funcs(prop, NULL, "rna_ToolSettings_snap_mode_set", NULL); | RNA_def_property_enum_funcs(prop, NULL, "rna_ToolSettings_snap_mode_set", NULL); | ||||
| RNA_def_property_flag(prop, PROP_ENUM_FLAG); | RNA_def_property_flag(prop, PROP_ENUM_FLAG); | ||||
| RNA_def_property_ui_text(prop, "Snap Element", "Type of element to snap to"); | RNA_def_property_ui_text(prop, "Snap Element", "Type of element to snap to"); | ||||
| RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */ | RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */ | ||||
| prop = RNA_def_property(srna, "snap_face_nearest_steps", PROP_INT, PROP_FACTOR); | |||||
| RNA_def_property_int_sdna(prop, NULL, "snap_face_nearest_steps"); | |||||
| RNA_def_property_range(prop, 1, 100); | |||||
Not Done Inline ActionsThe default should be set in: source/blender/makesdna/DNA_scene_defaults.h campbellbarton: The default should be set in: `source/blender/makesdna/DNA_scene_defaults.h` | |||||
Done Inline Actions(done, but see comment) gfxcoder: (done, but see comment) | |||||
| RNA_def_property_ui_text( | |||||
| prop, | |||||
| "Face Nearest Steps", | |||||
| "Number of steps to break transformation into for face nearest snapping"); | |||||
Not Done Inline Actions*picky* booleans typically use use_ prefix (by convention). campbellbarton: *picky* booleans typically use `use_` prefix (by convention). | |||||
Done Inline Actions(changed) gfxcoder: (changed) | |||||
| prop = RNA_def_property(srna, "use_snap_to_same_target", PROP_BOOLEAN, PROP_NONE); | |||||
| RNA_def_property_boolean_sdna(prop, NULL, "snap_flag", SCE_SNAP_KEEP_ON_SAME_OBJECT); | |||||
Not Done Inline ActionsDescription is vague, from looking at the code, this doesn't seem "object" related, it's passing in init_co_local instead of prev_co_local. campbellbarton: Description is vague, from looking at the code, this doesn't seem "object" related, it's… | |||||
Done Inline Actions(reworked, see comment) gfxcoder: (reworked, see comment) | |||||
| RNA_def_property_ui_text( | |||||
| prop, | |||||
| "Snap to Same Target", | |||||
| "Snap only to target that source was initially near (Face Nearest Only)"); | |||||
| /* node editor uses own set of snap modes */ | /* node editor uses own set of snap modes */ | ||||
| prop = RNA_def_property(srna, "snap_node_element", PROP_ENUM, PROP_NONE); | prop = RNA_def_property(srna, "snap_node_element", PROP_ENUM, PROP_NONE); | ||||
| RNA_def_property_enum_bitflag_sdna(prop, NULL, "snap_node_mode"); | RNA_def_property_enum_bitflag_sdna(prop, NULL, "snap_node_mode"); | ||||
| RNA_def_property_enum_items(prop, rna_enum_snap_node_element_items); | RNA_def_property_enum_items(prop, rna_enum_snap_node_element_items); | ||||
| RNA_def_property_ui_text(prop, "Snap Node Element", "Type of element to snap to"); | RNA_def_property_ui_text(prop, "Snap Node Element", "Type of element to snap to"); | ||||
| RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */ | RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */ | ||||
| /* image editor uses own set of snap modes */ | /* image editor uses own set of snap modes */ | ||||
| prop = RNA_def_property(srna, "snap_uv_element", PROP_ENUM, PROP_NONE); | prop = RNA_def_property(srna, "snap_uv_element", PROP_ENUM, PROP_NONE); | ||||
| RNA_def_property_enum_bitflag_sdna(prop, NULL, "snap_uv_mode"); | RNA_def_property_enum_bitflag_sdna(prop, NULL, "snap_uv_mode"); | ||||
| RNA_def_property_enum_items(prop, snap_uv_element_items); | RNA_def_property_enum_items(prop, snap_uv_element_items); | ||||
| RNA_def_property_ui_text(prop, "Snap UV Element", "Type of element to snap to"); | RNA_def_property_ui_text(prop, "Snap UV Element", "Type of element to snap to"); | ||||
| RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */ | RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */ | ||||
| prop = RNA_def_property(srna, "use_snap_uv_grid_absolute", PROP_BOOLEAN, PROP_NONE); | prop = RNA_def_property(srna, "use_snap_uv_grid_absolute", PROP_BOOLEAN, PROP_NONE); | ||||
| RNA_def_property_boolean_sdna(prop, NULL, "snap_uv_flag", SCE_SNAP_ABS_GRID); | RNA_def_property_boolean_sdna(prop, NULL, "snap_uv_flag", SCE_SNAP_ABS_GRID); | ||||
| RNA_def_property_ui_text( | RNA_def_property_ui_text( | ||||
| prop, | prop, | ||||
| "Absolute Grid Snap", | "Absolute Grid Snap", | ||||
| "Absolute grid alignment while translating (based on the pivot center)"); | "Absolute grid alignment while translating (based on the pivot center)"); | ||||
| RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */ | RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */ | ||||
| /* TODO(@gfxcoder): Rename `snap_target` to `snap_source` to avoid | /* TODO(@gfxcoder): Rename `snap_target` to `snap_source` to avoid previous ambiguity of "target" | ||||
| * previous ambiguity of "target" (now, "source" is geometry to be moved and "target" is | * (now, "source" is geometry to be moved and "target" is geometry to which moved geometry is | ||||
| * geometry to which moved geometry is snapped). */ | * snapped). */ | ||||
| prop = RNA_def_property(srna, "snap_target", PROP_ENUM, PROP_NONE); | prop = RNA_def_property(srna, "snap_target", PROP_ENUM, PROP_NONE); | ||||
| RNA_def_property_enum_sdna(prop, NULL, "snap_target"); | RNA_def_property_enum_sdna(prop, NULL, "snap_target"); | ||||
| RNA_def_property_enum_items(prop, rna_enum_snap_source_items); | RNA_def_property_enum_items(prop, rna_enum_snap_source_items); | ||||
| RNA_def_property_ui_text(prop, "Snap Target", "Which part to snap onto the target"); | RNA_def_property_ui_text(prop, "Snap Target", "Which part to snap onto the target"); | ||||
| RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */ | RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */ | ||||
| prop = RNA_def_property(srna, "use_snap_peel_object", PROP_BOOLEAN, PROP_NONE); | prop = RNA_def_property(srna, "use_snap_peel_object", PROP_BOOLEAN, PROP_NONE); | ||||
| RNA_def_property_boolean_sdna(prop, NULL, "snap_flag", SCE_SNAP_PEEL_OBJECT); | RNA_def_property_boolean_sdna(prop, NULL, "snap_flag", SCE_SNAP_PEEL_OBJECT); | ||||
| RNA_def_property_ui_text( | RNA_def_property_ui_text( | ||||
| prop, "Snap Peel Object", "Consider objects as whole when finding volume center"); | prop, "Snap Peel Object", "Consider objects as whole when finding volume center"); | ||||
| RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */ | RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */ | ||||
| prop = RNA_def_property(srna, "use_snap_project", PROP_BOOLEAN, PROP_NONE); | prop = RNA_def_property(srna, "use_snap_project", PROP_BOOLEAN, PROP_NONE); | ||||
| RNA_def_property_boolean_sdna(prop, NULL, "snap_flag", SCE_SNAP_PROJECT); | RNA_def_property_boolean_sdna(prop, NULL, "snap_flag", SCE_SNAP_PROJECT); | ||||
| RNA_def_property_ui_text(prop, | RNA_def_property_ui_text(prop, | ||||
| "Project Individual Elements", | "Project Individual Elements", | ||||
| "Project individual elements on the surface of other objects"); | "Project individual elements on the surface of other objects"); | ||||
| RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */ | RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */ | ||||
| prop = RNA_def_property(srna, "use_snap_backface_culling", PROP_BOOLEAN, PROP_NONE); | prop = RNA_def_property(srna, "use_snap_backface_culling", PROP_BOOLEAN, PROP_NONE); | ||||
| RNA_def_property_boolean_sdna(prop, NULL, "snap_flag", SCE_SNAP_BACKFACE_CULLING); | RNA_def_property_boolean_sdna(prop, NULL, "snap_flag", SCE_SNAP_BACKFACE_CULLING); | ||||
| RNA_def_property_ui_text(prop, "Backface Culling", "Exclude back facing geometry from snapping"); | RNA_def_property_ui_text(prop, "Backface Culling", "Exclude back facing geometry from snapping"); | ||||
| RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */ | RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */ | ||||
| /* TODO(@gfxcoder): Rename `use_snap_self` to `use_snap_active`, because active is correct but | |||||
| * self is not (breaks API). This only makes a difference when more than one mesh is edited. */ | |||||
| prop = RNA_def_property(srna, "use_snap_self", PROP_BOOLEAN, PROP_NONE); | prop = RNA_def_property(srna, "use_snap_self", PROP_BOOLEAN, PROP_NONE); | ||||
| RNA_def_property_boolean_negative_sdna(prop, NULL, "snap_flag", SCE_SNAP_NO_SELF); | RNA_def_property_boolean_negative_sdna(prop, NULL, "snap_flag", SCE_SNAP_NOT_TO_ACTIVE); | ||||
| RNA_def_property_ui_text(prop, "Project onto Self", "Snap onto itself (Edit Mode Only)"); | RNA_def_property_ui_text( | ||||
| prop, "Snap onto Active", "Snap onto itself only if enabled (Edit Mode Only)"); | |||||
| RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */ | |||||
| prop = RNA_def_property(srna, "use_snap_edit", PROP_BOOLEAN, PROP_NONE); | |||||
| RNA_def_property_boolean_sdna(prop, NULL, "snap_flag", SCE_SNAP_TO_INCLUDE_EDITED); | |||||
| RNA_def_property_ui_text( | |||||
| prop, "Snap onto Edited", "Snap onto non-active objects in Edit Mode (Edit Mode Only)"); | |||||
| RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */ | |||||
| prop = RNA_def_property(srna, "use_snap_nonedit", PROP_BOOLEAN, PROP_NONE); | |||||
| RNA_def_property_boolean_sdna(prop, NULL, "snap_flag", SCE_SNAP_TO_INCLUDE_NONEDITED); | |||||
| RNA_def_property_ui_text( | |||||
| prop, "Snap onto Non-edited", "Snap onto objects not in Edit Mode (Edit Mode Only)"); | |||||
| RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */ | |||||
| prop = RNA_def_property(srna, "use_snap_selectable", PROP_BOOLEAN, PROP_NONE); | |||||
| RNA_def_property_boolean_sdna(prop, NULL, "snap_flag", SCE_SNAP_TO_ONLY_SELECTABLE); | |||||
| RNA_def_property_ui_text( | |||||
| prop, "Snap onto Selectable Only", "Snap only onto objects that are selectable"); | |||||
| RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */ | RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */ | ||||
| prop = RNA_def_property(srna, "use_snap_translate", PROP_BOOLEAN, PROP_NONE); | prop = RNA_def_property(srna, "use_snap_translate", PROP_BOOLEAN, PROP_NONE); | ||||
| RNA_def_property_boolean_sdna( | RNA_def_property_boolean_sdna( | ||||
| prop, NULL, "snap_transform_mode_flag", SCE_SNAP_TRANSFORM_MODE_TRANSLATE); | prop, NULL, "snap_transform_mode_flag", SCE_SNAP_TRANSFORM_MODE_TRANSLATE); | ||||
| RNA_def_property_ui_text( | RNA_def_property_ui_text( | ||||
| prop, "Use Snap for Translation", "Move is affected by snapping settings"); | prop, "Use Snap for Translation", "Move is affected by snapping settings"); | ||||
| RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */ | RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */ | ||||
| ▲ Show 20 Lines • Show All 4,873 Lines • Show Last 20 Lines | |||||
Maybe this could be called SCE_SNAP_MODE_FACE_NEAREST since the difference between SURFACE and FACE doesn't seem meaningful (it's using two different terms for the same thing).
For the UI Snap to Nearest Face or Snap to Nearest Surface could be used.