Age | Commit message (Collapse) | Author |
|
into enums
The transformation snapping code contains a bunch of `#define`s, some ambiguously or incorrectly named attributes. This patch contains refactored code to improve this. This patch does (should) not change functionality of snapping.
Clarified ambiguously / incorrectly named attributes.
- "Target" is used to refer to the part of the source that is to be snapped (Active, Median, Center, Closest), but several other areas of Blender use the term "target" to refer to the thing being snapped to and "source" to refer to the thing getting snapped. Moreover, the implications of the previous terms do not match the descriptions. For example: `SCE_SNAP_TARGET_CENTER` does not snap the grabbed geometry to the center of the target, but instead "Snap transforamtion center onto target".
- "Select" refers to the condition for an object to be a possible target for snapping.
- `SCE_SNAP_MODE_FACE` is renamed to `SCE_SNAP_MODE_FACE_RAYCAST` to better describe its affect and to make way for other face snapping methods (ex: nearest).
Refactored related `#define` into `enum`s. In particular, constants relating to...
- `ToolSettings.snap_flag` are now in `enum eSnapFlag`
- `ToolSettings.snap_mode` are now in `enum eSnapMode`
- `ToolSettings.snap_source` (was `snap_target`) are now in `enum eSnapSourceSelect`
- `ToolSettings.snap_flag` (`SCE_SNAP_NO_SELF`) and `TransSnap.target_select` are now in `enum eSnapTargetSelect`
As the terms became more consistent and the constants were packed together into meaningful enumerations, some of the attribute names seemed ambiguous. For example, it is unclear whether `SnapObjectParams.snap_select` referred to the target or the source. This patch also adds a small amount of clarity.
This patch also swaps out generic types (ex: `char`, `short`, `ushort`) and unclear hard coded numbers (ex: `0`) used with snap-related enumerations with the actual `enum`s and values.
Note: I did leave myself some comments to follow-up with further refactoring. Specifically, using "target" and "source" consistently will mean the Python API will need to change (ex: `ToolSettings.snap_target` is not `ToolSettings.snap_source`). If the API is going to change, it would be good to make sure that the used terms are descriptive enough. For example, `bpy.ops.transform.translate` uses a `snap` argument to determine if snapping should be enabled while transforming. Perhaps `use_snap` might be an improvement that's more consistent with other conventions.
This patch is (mostly) a subset of D14591, as suggested by @mano-wii.
Task T69342 proposes to separate the `Absolute Grid Snap` option out from `Increment` snapping method into its own method. Also, there might be reason to create additional snapping methods or options. (Indeed, D14591 heads in this direction). This patch can work along with these suggestions, as this patch is trying to clarify the snapping code and to prompt more work in this area.
Reviewed By: mano-wii
Differential Revision: https://developer.blender.org/D15037
|
|
Split 'ED_view3d_cursor_snap_data_get' into 'update' and 'get' functions
Sometimes we just want to update and sometimes we just get the result.
Make it clear.
|
|
Regression introduced in
{rB721335553ccb5ce4f7a374b958b7d65befa319df}.
`plane_omat` is only computed if `snap_state->draw_plane` is `true`.
|
|
Activating a gizmo used the windows eventstate which may have values
newer than the event used to activate the gizmo.
This meant transforms check for the key that activated transform
could be incorrect.
Support passing an event when calling operators to avoid this problem.
|
|
This avoids transform jumping which is a problem when tweaking values a
small amount. A fix for T40549 was made box-select used the location
when the key was pressed.
While it's important for box-select or any operator where it's expected
the drag-start location is used, this is only needed in some cases.
Since the event stores the click location and the current location,
no longer overwrite the events real location. Operators that depend on
using the drag-start can use this location if they need.
In some cases the region relative cursor location (Event.mval) now needs
to be calculated based on the click location.
- Added `WM_event_drag_start_mval` for convenient access to the region
relative drag-start location (for drag events).
- Added `WM_event_drag_start_xy` for window relative coordinates.
- Added Python property Event.mouse_prev_click_x/y
Resolves T93599.
Reviewed By: Severin
Ref D14213
|
|
|
|
Use a shorter/simpler license convention, stops the header taking so
much space.
Follow the SPDX license specification: https://spdx.org/licenses
- C/C++/objc/objc++
- Python
- Shell Scripts
- CMake, GNUmakefile
While most of the source tree has been included
- `./extern/` was left out.
- `./intern/cycles` & `./intern/atomic` are also excluded because they
use different header conventions.
doc/license/SPDX-license-identifiers.txt has been added to list SPDX all
used identifiers.
See P2788 for the script that automated these edits.
Reviewed By: brecht, mont29, sergey
Ref D14069
|
|
This combination was being repeated in some places.
|
|
|
|
Error introduced in rB69d6222481b4 and partially fixed in rB24310441ddc8.
When gizmo was turned on but the scene has more than one 3D viewport, one of them the snap cursor did not appear.
|
|
The snap cursor continued to appear even when the workspace is changed for example.
So add the region to check in the cursor pool.
|
|
3 is a small amount as each viewport creates a gizmo that creates its own state
Now if the state is not created, the gizmos use the last state.
|
|
|
|
|
|
Properties with `_funcs_runtime` are always saved when exporting keymaps.
This is an error since changing one changes all others.
For now, work around the problem by setting the `PROP_IDPROPERTY` flag.
|
|
Warning C4100 unreferenced formal parameter
Warning C4242 conversion from 'int' to 'short', possible loss of data
|
|
|
|
Make the snap system consistent with the placement tool and leak-safe.
**Changes:**
- Store `SnapCursorDataIntern` in a `static` variable;
- Initialize (lazily) `SnapCursorDataIntern` only once (for the keymap).
- Move setup members of `V3DSnapCursorData` to a new struct `V3DSnapCursorState`
- Merge `ED_view3d_cursor_snap_activate_point` and `ED_view3d_cursor_snap_activate_plane` into `state = ED_view3d_cursor_snap_active()`
- Merge `ED_view3d_cursor_snap_deactivate_point` and `ED_view3d_cursor_snap_deactivate_plane` into `ED_view3d_cursor_snap_deactive(state)`
- Be sure to free the snap context when closing via `ED_view3d_cursor_snap_exit`
- Use RNA properties callbacks to update the properties of the `"Add Primitive Object"` operator
|
|
Move most of the gizmo snap and placement code to `view_cursor_snap.c`.
Simplify and extend the snap API.
Differential Revision: https://developer.blender.org/D12868
|
|
Move runtime parameters out of context creation.
Not being able to choose another region and v3d limits the use of the
snap API.
|
|
Also use doxy style function reference `#` prefix chars when
referencing identifiers.
|
|
|
|
|
|
This patch fixes many minor spelling mistakes, all in comments or
console output. Mostly contractions like can't, won't, don't, its/it's,
etc.
Differential Revision: https://developer.blender.org/D11663
Reviewed by Harley Acheson
|
|
Includes fixes to misspelled function names.
Ref D11280
|
|
The grid plane was drawn too big on retina displays compared to other screens,
because the factor was multiplied by the native pixel-size, which is 2 for
Retina displays.
|
|
|
|
values in 'Adjust Last Operation'
Always use the defaults here (radius, depth etc), since desired bounds
have been set interactively, it does not make sense to use a different
value from a previous command.
The Cube tool has already seen a fix for this in rB26e5718e29a7, but
Cone/UVSphere/Cylinder/IcoSphere havent.
Maniphest Tasks: T87677
Differential Revision: https://developer.blender.org/D11038
|
|
This allows the addition of the `SNAP_GEOM_CAGE` option.
Currently unused.
|
|
This simplifies the addition of future improvements.
Also make it more practical to expose as a parameter of gizmo for Python.
|
|
No functional changes.
This makes the `ED_gizmotypes_snap_3d_update` function more specialized.
|
|
The Tool stores desired dimensions as `scale` and thus had to half the
scale again in `make_prim_init()` because by default all primitives are
created at a size of 2 in blender.
This worked, but:
- [1] it logged something like size=2, scale=2,2,2 for a 2x2x2 cube
[which does not sound right, it should be size=2 scale=1,1,1]
- [2] it had to make an exception for the case scale is exactly 1x1x1
[this happens when the property is not set specifically, e.g. adding
primitives from the menu]
-- this exception led to double sized primitives being created when the
tool asked for exact dimensions of 1x1x1
Now - instead of compensating in `make_prim_init()` - do this earlier in
the tool itself, see `view3d_interactive_add_modal`, this fixes the bug
and now also correctly logs size=2 scale 0.5,0.5,0.5 for a 1x1x1 cube.
Maniphest Tasks: T86347
Differential Revision: https://developer.blender.org/D10632
|
|
|
|
While useful in some cases, this meant it wasn't possible to use the
"Floor" for object placement without looking top-down or bottom up.
|
|
|
|
The cursor-plane was too dense/bright when approaching view alignment.
|
|
When using the interactive add tool for primitives with a fixed
height and base aspect ratio, the height of the created primitive
would be incorrect (two times too small or two times too big).
When the base origin was centered, the `fixed_aspect_dimension`
was not changed even though the base length was doubled.
Additionally, when the height origin was centered but the height
aspect ratio was fixed, the height was doubled leading to an
incorrect size.
The fix doubles `fixed_aspect_dimension` when the base origin is
centered and correctly calculates the height of the primitive when
the aspect ratio is set to fixed.
Ref D10140
|
|
Draw the cursor plane smaller then further away from the view.
This makes the plane being drawn onto easier to perceive.
|
|
In practice it's common these settings shouldn't be linked for drawing
the initial (base) plane, compared with the height.
|
|
This makes it more convent to add many objects with a fixed aspect ratio.
|
|
Move some of the more obscure options into a popover,
so they don't take up so much room in the top-bar.
|
|
This adds a "Snap to" option that allows using all the scenes snap
settings which includes incremental & absolute grid snapping options.
This is optional because always following scene snapping would not
snap to geometry by default (which seems to be the most useful default).
|
|
|
|
The size property was only used for the cube
|
|
Make the name follow the convention of other View3D keymaps.
|
|
When activating add-object from from a tweak event (default keymap),
the snap gizmo could snap to a new location while dragging.
Workaround this by re-calculating the snap position where the tweak
event starts.
Reported T57210#1077747
|
|
|
|
Now the gizmo is drawn only when the eventstate located in
`wm->winactive->eventstate` has not changed.
So it doesn't matter if it's "selected" or not.
This commit also removes the use of the private header "wm.h"
Reviewed By: campbellbarton
Differential Revision: https://developer.blender.org/D9539
|
|
|
|
Zoom with an orthographic view wasn't refreshing the preview plane.
|