Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2022-09-14ViewLayer: Lazy sync of scene data.Monique Dewanchand
When a change happens which invalidates view layers the syncing will be postponed until the first usage. This will improve importing or adding many objects in a single operation/script. `BKE_view_layer_need_resync_tag` is used to tag the view layer to be out of sync. Before accessing `BKE_view_layer_active_base_get`, `BKE_view_layer_active_object_get`, `BKE_view_layer_active_collection` or `BKE_view_layer_object_bases` the caller should call `BKE_view_layer_synced_ensure`. Having two functions ensures that partial syncing could be added as smaller patches in the future. Tagging a view layer out of sync could be replaced with a partial sync. Eventually the number of full resyncs could be reduced. After all tagging has been replaced with partial syncs the ensure_sync could be phased out. This patch has been added to discuss the details and consequences of the current approach. For clarity the call to BKE_view_layer_ensure_sync is placed close to the getters. In the future this could be placed in more strategical places to reduce the number of calls or improve performance. Finding those strategical places isn't that clear. When multiple operations are grouped in a single script you might want to always check for resync. Some areas found that can be improved. This list isn't complete. These areas aren't addressed by this patch as these changes would be hard to detect to the reviewer. The idea is to add changes to these areas as a separate patch. It might be that the initial commit would reduce performance compared to master, but will be fixed by the additional patches. **Object duplication** During object duplication the syncing is temporarily disabled. With this patch this isn't useful as when disabled the view_layer is accessed to locate bases. This can be improved by first locating the source bases, then duplicate and sync and locate the new bases. Will be solved in a separate patch for clarity reasons ({D15886}). **Object add** `BKE_object_add` not only adds a new object, but also selects and activates the new base. This requires the view_layer to be resynced. Some callers reverse the selection and activation (See `get_new_constraint_target`). We should make the selection and activation optional. This would make it possible to add multiple objects without having to resync per object. **Postpone Activate Base** Setting the basact is done in many locations. They follow a rule as after an action find the base and set the basact. Finding the base could require a resync. The idea is to store in the view_layer the object which base will be set in the basact during the next sync, reducing the times resyncing needs to happen. Reviewed By: mont29 Maniphest Tasks: T73411 Differential Revision: https://developer.blender.org/D15885
2022-09-01Cleanup: Remove/replace View Layer macros.Monique Dewanchand
This patch is a cleanup required before refactoring the view layer syncing process {T73411}. * Remove FIRSTBASE. * Remove LASTBASE. * Remove BASACT. * Remove OBEDIT_FROM_WORKSPACE. * Replace OBACT with BKE_view_layer_active_object. * Replace OBEDIT_FROM_VIEW_LAYER with BKE_view_layer_edit_object. Reviewed By: mont29 Maniphest Tasks: T73411 Differential Revision: https://developer.blender.org/D15799
2022-08-12Fix T100370: Depth choice for "Add Cube" tool always using SurfaceGermano Cavalcante
As the surface normal is calculated along with the coordinates, the surface depth was always being used when surface orientation was set. Therefore, even calculated, ignore the surface depth when it is not required. Also promote an optimization when neither orientation nor depth is required.
2022-06-30Transform Snap: nearest face snap mode, snapping options, refactoring.jon denning
This commit adds a new face nearest snapping mode, adds new snapping options, and (lightly) refactors code around snapping. The new face nearest snapping mode will snap transformed geometry to the nearest surface in world space. In contrast, the original face snapping mode uses projection (raycasting) to snap source to target geometry. Face snapping therefore only works with what is visible, while nearest face snapping can snap geometry to occluded parts of the scene. This new mode is critical for retopology work, where some of the target mesh might be occluded (ex: sliding an edge loop that wraps around the backside of target mesh). The nearest face snapping mode has two options: "Snap to Same Target" and "Face Nearest Steps". When the Snap to Same Object option is enabled, the selected source geometry will stay near the target that it is nearest before editing started, which prevents the source geometry from snapping to other targets. The Face Nearest Steps divides the overall transformation for each vertex into n smaller transformations, then applies those n transformations with surface snapping interlacing each step. This steps option handles transformations that cross U-shaped targets better. The new snapping options allow the artist to better control which target objects (objects to which the edited geometry is snapped) are considered when snapping. In particular, the only option for filtering target objects was a "Project onto Self", which allowed the currently edited mesh to be considered as a target. Now, the artist can choose any combination of the following to be considered as a target: the active object, any edited object that isn't active (see note below), any non- edited object. Additionally, the artist has another snapping option to exclude objects that are not selectable as potential targets. The Snapping Options dropdown has been lightly reorganized to allow for the additional options. Included in this patch: - Snap target selection is more controllable for artist with additional snapping options. - Renamed a few of the snap-related functions to better reflect what they actually do now. For example, `applySnapping` implies that this handles the snapping, while `applyProject` implies something entirely different is done there. However, better names would be `applySnappingAsGroup` and `applySnappingIndividual`, respectively, where `applySnappingIndividual` previously only does Face snapping. - Added an initial coordinate parameter to snapping functions so that the nearest target before transforming can be determined(for "Snap to Same Object"), and so the transformation can be broken into smaller steps (for "Face Nearest Steps"). - Separated the BVH Tree getter code from mesh/edit mesh to its own function to reduce code duplication. - Added icon for nearest face snapping. - The original "Project onto Self" was actually not correct! This option should be called "Project onto Active" instead, but that only matters when editing multiple meshes at the same time. This patch makes this change in the UI. Reviewed By: Campbell Barton, Germano Cavalcante Differential Revision: https://developer.blender.org/D14591
2022-06-28Fix T96776: Assets dropped upside down when looking through cameraGermano Cavalcante
In perspective mode the snap point direction needs to be taken into account to define which side of the face is being looked at. If there is no face under the mouse cursor, there is no direction adjustment and the element normal will be used.
2022-06-06Refactor: Snap-related. Clarified attribute names and refactored #defines ↵jon denning
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
2022-05-30Cleanup: Clang tidyHans Goudey
Mostly duplicate includes, also use nullptr, and using default member initializers.
2022-04-29Cleanup: missing declaration warnings & spelling in commentsCampbell Barton
2022-04-28Fix non-face oriented snap cursor in dragdropGermano Cavalcante
If the measure gizmo is enabled, its snap state is used in the snap update. As it does not require a plane, the orientation of the plane is not calculated. However, the calculation of the plane's orientation must prevail over the states.
2022-04-28Snap Cursor: split 'ED_view3d_cursor_snap_data_get'Germano Cavalcante
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.
2022-03-28Cleanup/Refactor: remove unused 'SNAP_ONLY_ACTIVE' enum parameterGermano Cavalcante
`SNAP_ONLY_ACTIVE` was implemented in order to be used in the Knife tool, but the project did not go ahead.
2022-02-25Cleanup: use flags for wmEvent modifier keysCampbell Barton
Using flags makes checking multiple modifiers at once more convenient and avoids macros/functions such as IS_EVENT_MOD & WM_event_modifier_flag which have been removed. It also simplifies checking if modifier keys have changed.
2022-02-11File headers: SPDX License migrationCampbell Barton
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
2021-12-09Fix T93869: snap cursor may fail in orthographic viewGermano Cavalcante
Float precision issues cause the `ED_view3d_win_to_3d_on_plane` to return a value even when the view ray is parallel to the plane. A more general solution might be desired in this case, as other areas that use `ED_view3d_win_to_3d_on_plane` might have the same problem. For now, just work around the problem for the snap cursor.
2021-12-06Fix T93388: dropping object on grid in orthogonal view misses the floor planeGermano Cavalcante
`ED_view3d_win_to_3d_on_plane` does not use the `clip_start` and `clip_end` values of the scene, so the `do_clip` option can be misleading especially in the orthographic view where the `clip_start` is negative. For now, don't use the `do_clip` option in orthographic view.
2021-12-06Fix T93732: Snap Cursor not working after changing Add Object settingsGermano Cavalcante
`g_data_intern.state_default.gzgrp_type` is a very specific member and cannot be set to default.
2021-11-30Fix T93477: Viewport X-Ray is influencing snapping even in material modeGermano Cavalcante
The default snap behavior to perform on tools and cursors is to the final geometry and not edited geometry. In snapping to edited geometry, there are some specific behaviors that are not convenient in some cases. For example the general occlusion test of X-Ray geometries during dragdrop. This fix also resolves a regression for tools like measure and placement that were also ignoring the snap to face in x-ray mode. Differential Revision: https://developer.blender.org/D13410
2021-11-18Revert "Revert "Revert "Revert "Adjust snap source drawing when adding ↵Germano Cavalcante
multiple snap points"""" This reverts commit b8bf40ed4bf618a6bc908e39278cfbfd385e0d4b.
2021-11-18Revert "Revert "Revert "Revert "Transform: interactive mode for editing a ↵Germano Cavalcante
'Snap Source'"""" This reverts commit 701f2dfd5bc61c0f37603880fa21abfe8b1d9620.
2021-11-18Revert "Revert "Revert "Transform: interactive mode for editing a 'Snap ↵Germano Cavalcante
Source'""" This reverts commit 25fa6c74b977ac983a34b9adf5ab2f20fe2f4932.
2021-11-18Revert "Revert "Revert "Adjust snap source drawing when adding multiple snap ↵Germano Cavalcante
points""" This reverts commit c7f9a782aafcdd08868504584b2621afcf1356c2.
2021-11-18Revert "Revert "Adjust snap source drawing when adding multiple snap points""Germano Cavalcante
This reverts commit 77df32548b9f377a834b54d0b740a6a51bb2f0a5.
2021-11-18Revert "Revert "Transform: interactive mode for editing a 'Snap Source'""Germano Cavalcante
This reverts commit 805181bffae647a24e939c651da72a08c5c2b7cb.
2021-11-18Revert "Transform: interactive mode for editing a 'Snap Source'"Germano Cavalcante
This reverts commit f19bd637e2c38b8b967944a88609a190b5179439.
2021-11-18Revert "Adjust snap source drawing when adding multiple snap points"Germano Cavalcante
This reverts commit cb3ba68ec4470a170905a2dc9ea64b8fa1f8ace3.
2021-11-18Adjust snap source drawing when adding multiple snap pointsGermano Cavalcante
2021-11-18Transform: interactive mode for editing a 'Snap Source'Germano Cavalcante
This patch implements part of what was stated in {T66484}, with respect to `Base Point`. ## Introduction The snapping feature of the transform tools has a variety of applications: - Organization of nodes. - Positioning of frames in precise time units. - Retopology with snap to face - Creation of armatures with bone positioning through the snap to volume - Precise positioning of 3D or 2D objects in the surrounding geometry (CAD modeling) The goal of this document is to make it more powerful for precision modeling and still supporting the old use cases without extra complexity. The main topic addressed here is the introduction of a **interactive mode for setting a snap source** (See terminology). ## Terminology * **Snap Source**: 3d coordinate * we want to snap from. (Currently defined by the `Snap With` options: `Closest`, `Center`, `Median` and `Active`). * **Snap Target**: 3d coordinate* we want to snap to. (Vertices, Edges, Faces, Grid...) ## Interactive Mode for Editing a Snap Source Currently the fixed snap point can only be obtained through the `Snap With` options. So it's a little tricky for the user to define a snap source point having so much geometry on an object. Because of this, the user needs to resort to impractical solutions to get a point in the geometry. See example of an impractical use: {F11714181, layout=left, width=960, alt="The user used the cursor (which can be snapped) to choose the snap origin point."} The user used the cursor (which can be snapped) to choose the snap source point. While it is possible to work around this current limitation, it is important to reduce the number of steps and allow the user to set a snap source point through an optional interactive mode during a transformation. The proposed solution is to be able to move the current snap source point through a modal modifier activated with a key (eg. B). The snap source point can thus "snap" to the elements in the scene (vertex, mid-edge, Lamp, …) during this mode. {F9122814, layout=left, width=960, alt="Base Point Snap, example of transform operation via the shortcut (not the tool). After pressing g and the snap base change shortcut (e.g., shift + ctrl) the user set the base point. The base point is then visible until the end of the operation. The z axis constrains the final position."} ## Implementation Details - The feature will only be available in 3D View. - The feature will only be available for `Move`, `Rotate` and `Scale` transform modes. - The snap source editing will be enabled with a single click on the modifier key (B). - Having a snap point indicated, the new snap origin point will be confirmed with the same buttons that confirms the transformation (but the transformation will not be concluded). - The snap source editing can be canceled with the same key that activated it (B). - If the transformation is done with "release_confirm" (common for gizmos), the new feature cannot be enabled. - During the transformation, when enabling the feature, if the snap option is turned off in the scene, the snap will be forced on throughout the rest of the transformation (unless interactive mode is canceled). - During a transformation, if no snap target is set for an element in the scene (Vertex, Grid...), the snap targets to geometry Vertex, Edge, Face, Center of Edge and Perpendicular of Edge will be set automatically. - Snap cannot be turned off during the snap source editing. - Constraint or similar modification features will not be available during the snap source editing. - Text input will not be available during the snap source editing. - When adding multiple snap points (A) the new prone snap source point will be indicated with an "X" drawing. {F11817267} Maniphest Tasks: T66484 Differential Revision: https://developer.blender.org/D9415
2021-11-12Cleanup: unify snap modes to geometry in a single flagGermano Cavalcante
This combination was being repeated in some places.
2021-11-11Cleanup: typo in function nameCampbell Barton
2021-11-09Fix T92939: Crash on drop when a curve is the active objectGermano Cavalcante
The active object was being set as the edited object even though it was not in edit mode.
2021-11-09View3D Snap Cursor: make the pool a little more restrictiveGermano Cavalcante
The snap cursor tagged overlapping regions to redrawn even though the cursor itself is not drawn.
2021-11-08Fix snap cursor not active even if gizmo is availableGermano Cavalcante
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.
2021-11-02Fix snap cursor still active even when gizmo is not availableGermano Cavalcante
The snap cursor continued to appear even when the workspace is changed for example. So add the region to check in the cursor pool.
2021-10-29Fix snap cursor not working in regions with transparencyGermano Cavalcante
Use `BKE_area_find_region_type` instead of using the context region.
2021-10-28Cleanup: remove 'ED_view3d_cursor_snap_exit'Germano Cavalcante
The callers of `ED_view3d_cursor_snap_active` that must handle the snapping of the cursor. Forcing release at the end can hide leaks.
2021-10-28Fix memory leak in cursor snap deactivationGermano Cavalcante
Missed in rB32cc9ff03746
2021-10-27Cleanup: remove underscore prefix from variableCampbell Barton
Avoid using underscore prefix since these typically mean the variable shouldn't be accessed directly (it may be accessed from a macro, or memory on the stack which is assigned to a pointer). In this case a more meaningful name can be used for the argument that was shadowed.
2021-10-26View3D Snap Cursor: don't limit the number of statesGermano Cavalcante
The benefit of a flat array in this case is small and limiting, so use a linklist.
2021-10-26View3D Snap Cursor: sanitize and increase the maximum amount of statesGermano Cavalcante
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.
2021-10-25Assets: Snapping with visual feedback while draggingGermano Cavalcante
The drag and drop feature of objects in 3D View has been modified to include: - Snap the object being dragged. - Visual feedback through a box and the placement tool grid. Maniphest Tasks: T90198 Differential Revision: https://developer.blender.org/D12912
2021-10-21View3D Snap Cursor: Fix drawing state incorrectly resetGermano Cavalcante
The viewport was being changed, so it needs to be reset.
2021-10-21Cleanup: unused functuion warningsCampbell Barton
2021-10-21Cleanup: Set default snap cursor values during build timeGermano Cavalcante
2021-10-20Cleanup: silence WarningsGermano Cavalcante
Warning C4100 unreferenced formal parameter Warning C4242 conversion from 'int' to 'short', possible loss of data
2021-10-20Cleanup: unused parameters, `nullptr` instead of `NULL` in cpp code...Bastien Montagne
2021-10-20Cleanup: unused functionGermano Cavalcante
2021-10-20Fix crash when reloading with placement tool enabledGermano Cavalcante
Paint Cursors are already released at this stage.
2021-10-20View3D: Cursor Snap RefactorGermano Cavalcante
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
2021-10-19Cleanup: remove unused member and rearrange functionGermano Cavalcante
2021-10-18Cleanup: use a common prefix in static functionsGermano Cavalcante
This helps identify where the function came from.