Commit Graph

232 Commits

Author SHA1 Message Date
a00b6d1271 Cleanup: (float)floor -> floorf 2014-10-10 00:24:34 +02:00
059e0dafb4 Cleanup: const correctness for BLI_sortlist 2014-09-24 14:55:02 +10:00
3a40aed3d5 Cleanup: use float versions of functions when in/output are floats 2014-09-24 14:55:02 +10:00
ee8dafe462 Fix crash on edit mode with multi-align project 2014-08-08 19:35:09 +02:00
4f18ab1b20 Fix T40958 align rotation + project individual elements not working
This is another example of transform code crappiness. Projection
snapping for objects is handled separately than regular snapping.
Luckilly for us, we have the normal ready from the raycast result and a
copy of code from ElementRotation function can do the necessary
rotations for us.

I have not enforced constraints here (arguably, maybe I should, and the
already present projection snapping should do that too but seems it is
commented out and the unorthodox order of operations here has me a bit
scared. Leaving as TODO)
2014-07-31 17:02:17 +02:00
6355e3a45d As suggested by Campbell, rather use BVHTree to get len_diff in this morning's fix.
Note than it's using nearest faces, since it showed to be much more performant than
nearest vertex (quite odd, it's about 40% slower for the first element, then 50 times quicker
for all others, as if BVH was cached, and building face was slower than verts one,
but then using it, much quicker!).
2014-07-28 20:34:23 +02:00
c4b47b89f7 Fix T41191: Face snapping doesn't work properly.
Issue was caused by rB47ec0394ca3d, which disabled BBox check in editmode - but bbox check was also
setting `len_diff`, which is mandatory when doing ray_start_local correction for ortho view...

Now, in this case, we do a quick rough compute of len_diff from vertices coordinates (accuracy is not
needed here, we just have to be sure corrected `ray_start_local` remains 'before' (outside) of the
geometry).
2014-07-28 15:21:42 +02:00
d49b86d0f9 Fix T41201: Blender Crashes when UV Editing
Disable adding snapping point outside of 3D space for now,
visualization of the points is not implemented outside of
this space and silently adding them wouldn't really be a
good idea.
2014-07-28 17:11:41 +06:00
f745564e4e GSOC 2013 paint
Yep, at last it's here!

There are a few minor issues remaining but development can go on in
master after discussion at blender institute.

For full list of features see:

http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.72/Painting

Thanks to Sergey and Campbell for the extensive review and to the
countless artists that have given their input and reported issues during
development.
2014-07-21 12:02:05 +02:00
00b29156e0 Defines: replace ELEM3-16 with ELEM(...), that can take varargs 2014-07-20 01:33:40 +10:00
47ec0394ca Fix T40679.
Cleanest way here is not do bounding box collision for editmeshes at
all. Decision is taken because:

* Usually we want to do the snapping to the edited mesh anyway (when we
don't the mesh is skipped completely, so we don't need to worry for
extra checks)

* Bounding box is calculated from derived mesh. This means that for
subsurfed meshes for instance, the bounding box may be significantly
smaller than the size of the edit mesh.
2014-06-18 18:40:11 +03:00
d9de1b367e Revert "Fix flickering when transform snapping in edit mode and cursor is"
Looks like the cleanest way to handle this is to no do bounding box collision
for edit mode at all. But this is easy to enforce

This reverts commit 7b5fe4f316.

Conflicts:
	source/blender/editors/transform/transform_snap.c
2014-06-18 18:20:55 +03:00
781de742eb Fix T40610. This is a critical bug caused by own bugfix that does not
allow editing any object type without bounding boxes.

This should be included in the final release!
2014-06-14 14:30:22 +03:00
7b5fe4f316 Fix flickering when transform snapping in edit mode and cursor is
slightly outside the mesh.

Reported by Thomas Beck on irc. Issue here is that the mesh bounding box
changes as we are transforming the vertices. Solution is to collide
against the initial bounding box. Unfortunately the snapping functions
are made in a way that a lot of code needed to be tweaked here, but the
change should be straightforward and harmless (famous last words, I
know).

Ideally we might want to even increase the size of the bounding box a
little (as seen in screen space) to allow snapping even in cases where,
cursor is slightly outside the bounding box, but since this is not so
straightforward to do for all cases, at least for me, leaving this as
a TODO.
2014-06-12 01:43:38 +03:00
663c800ef3 Fix T36973: Active snapping fails for edges/faces
also add snap-active support for armatures, pose & metas
2014-05-09 18:29:02 +10:00
4ca67869cc Code cleanup: remove unused includes
Opted to keep includes if they are used indirectly (even if removing is possible).
2014-05-01 04:47:51 +10:00
c67bd49e56 Code cleanup: use 'const' for arrays (editors) 2014-04-27 00:25:15 +10:00
9ae0e585b0 View2d: API Cleanup for view<->region conversion
View2D had some inconsistencies making it error prone in some cases.

- Inconstant checking for NULL x/y args.
  Disallow NULL args for x/y destination pointers, instead add:
  - UI_view2d_region_to_view_x/y
  - UI_view2d_view_to_region_x/y

- '_no_clip' suffix wasn't always used for non-clipping conversion,
  switch it around and use a '_clip' suffix for all funcs that clip.

- UI_view2d_text_cache_add now clips before adding cache.

- '_clip' funcs return a bool to quickly check if its in the view.

- add conversion for rectangles, since this is a common task:
  - UI_view2d_view_to_region_rcti
  - UI_view2d_region_to_view_rctf
2014-04-21 16:59:40 +10:00
e6cdce725c Code cleanup: use bools & const args 2014-04-17 02:53:34 +10:00
fb0959f88d Code cleanup: replace dot with len_squared and is_zero checks 2014-03-29 22:24:12 +11:00
aea00c7a81 Code cleanup: style 2014-02-13 08:52:12 +11:00
b3afbcab8f ListBase API: add utility api funcs for clearing and checking empty 2014-02-08 06:24:05 +11:00
482823a1ab Fix T38435: Crash when pressing MMB in walk mode
Snap code may be called with a NULL region, add check about this and assume ray_start is OK in this case!
2014-02-02 20:35:45 +01:00
fed1b8b16d Code cleanup: suffix vars to make obvious they are squared 2014-02-03 02:46:45 +11:00
1e096ee816 More snapping fixes (this is ridiculous).
I hope this time we are done!
2014-01-30 18:50:12 +01:00
0cb49286ce Fix T38409: Snapping Bug
Issue partially caused by own errors (glicth in new BKE_boundbox_ray_hit_check() code causing segfault in volume snapping,
and we have to treat ortho and persp differently in case of face snapping, because in persp our ray_start might very well
already be *inside* the boundbox of the checked object), and partly due to the fact that ED_view3d_win_to_vector()
was returning wrong vector (negated one) for ortho views (see previous commit).
2014-01-30 17:16:07 +01:00
810c6d1880 Fix T38358: typo in own rB77089a3bf203.
Also allowed me to fine another potential issue, hit.dist was no more initialized correctly - and I had forgotten to take into account Brecht's remark about normalize_v3() also returning the vector's previous length.
2014-01-30 11:54:55 +01:00
77089a3bf2 Fix T38358: Face snapping fails on Orthographic view
Issue is caused by start point of ray used to detect faces under the mouse is set rather far away in ortho 3dviews.
The loss of precision on the ray location induced by this can lead to face snapping failures.

Solution is to do the raycasting with a temp start point, much closer to the object we check, and add back
to the found distance the diff to the real start point once detection is done (as we need all hit distances
from all tested objects to be relative to a common point!).

Note this commit only addresses the "face snapping on mesh" case, other kind of snapping do not seem to suffer
from this issue.

Reviewers: brecht, campbellbarton

Differential Revision: https://developer.blender.org/D268
2014-01-29 20:10:03 +01:00
afb9393dda Fix T38354: Excess memory allocation when projecting onto object with multires
Found three cases where created bvhtree was not freed...
2014-01-26 16:56:50 +01:00
19da32abf3 Fix T38128: snapping to node border uses node centers.
This was caused by recent change to transform locations being changed
to the upper-left corner of nodes (rBa857a6f).
2014-01-21 13:13:41 +01:00
709041ed0b Threaded object update and EvaluationContext
Summary:
Made objects update happening from multiple threads. It is a task-based
scheduling system which uses current dependency graph for spawning new
tasks. This means threading happens on object level, but the system is
flexible enough for higher granularity.

Technical details:

- Uses task scheduler which was recently committed to trunk
  (that one which Brecht ported from Cycles).

- Added two utility functions to dependency graph:
  * DAG_threaded_update_begin, which is called to  initialize threaded
    objects update. It will also schedule root DAG node to the queue,
    hence starting evaluation process.

    Initialization will calculate how much parents are to be evaluation
    before current DAG node can be scheduled. This value is used by task
    threads for faster detecting which nodes might be scheduled.

  * DAG_threaded_update_handle_node_updated which is  called from task
    thread function when node was fully handled.

	This function decreases num_pending_parents of node children and
	schedules children with zero valency.

    As it might have become clear, task thread receives DAG nodes and
    decides which callback to call for it.

    Currently only BKE_object_handle_update is called for object nodes.

    In the future it'll call node->callback() from Ali's new DAG.

- This required adding some workarounds to the render pipeline.
  Mainly to stop using get_object_dm() from modifiers' apply callback.
  Such a call was only a workaround for dependency graph glitch when
  rendering scene with, say, boolean modifiers before displaying
  this scene.

  Such change moves workaround from one place to another, so overall
  hackentropy remains the same.

- Added paradigm of EvaluaitonContext. Currently it's more like just a
  more reliable replacement for G.is_rendering which fails in some
  circumstances.

  Future idea of this context is to also store all the local data needed
  for objects evaluation such as local time, Copy-on-Write data and so.

  There're two types of EvaluationContext:

  * Context used for viewport updated and owned by Main. In the future
    this context might be easily moved to Window or Screen to allo
    per-window/per-screen local time.

  * Context used by render engines to evaluate objects for render purposes.
    Render engine is an owner of this context.

  This context is passed to all object update routines.

Reviewers: brecht, campbellbarton

Reviewed By: brecht

CC: lukastoenne

Differential Revision: https://developer.blender.org/D94
2013-12-26 17:24:42 +06:00
3f2f7091d6 Revert svn r55587, fix for T34698 (Disable snap when transform axis is constrained)
Currently we don't properly support snapping + axis-constraints, but
there are cases where its handy to project-snap for eg, and constraint
to an axis so re-enable this.
2013-12-19 04:54:11 +11:00
ac38f2584f Code Cleanup: replace ABS() with fabsf() when used with float expressions. 2013-12-01 13:11:12 +11:00
82238c3e36 Fix T37550: Crash while snaping to curve made from Susane (bug in recent addition) 2013-11-21 00:21:31 +11:00
8f7f8d679c Style Cleanup: whitespace 2013-11-17 22:00:57 +11:00
b0ff255b55 Transform: vertex snapping for curves
This adds vertex snapping capabilities for curves. Snaps to all control points
of other objects, and visible + selected control points and handles in curve
edit mode.

Reviewed By: brecht

Differential Revision: http://developer.blender.org/D3
2013-11-16 20:21:13 +01:00
Lukas Toenne
7398600090 True grid snapping for nodes: This snaps nodes to the actual background grid instead of using incremental offset (which is not useful for nodes). Increment snapping has been disabled for nodes to avoid
confusion, grid snap is now the default as it seems to be the most wanted and easy to use mode.

Absolute grid snapping happens in a somewhat generic function 'applyGridAbsolute', which could also be used for objects and other transforms later on. It is conceptually similar to the 'project' snapping
option, in that it calculates a delta vector for each element on top of the overall transform, which places each node on the grid.

Node transform now uses the top-left node corner for TransformData->loc. The transform center is still the average of node centers, so that scaling and rotation works nicely.

snapGrid*** functions have been renamed to snapGridIncrement*** to distinguish better between incremental and absolute grid snapping.
2013-11-06 17:46:32 +00:00
17994825f0 Fix #37251: Snap not working correctly in metaball edit mode.
It wasn't enabled in snapping code from the beginning it seems,
but from quick tests snapping for mballs works just fine.

Maybe we could drop out check for edit object type now?
2013-11-06 08:27:18 +00:00
3264461598 move bmesh array lookup data and utility functions from editmesh into bmesh,
since enough bmesh operations can also take advantage of direct index lookups on verts/edges/faces.

developers note:
- EDBM_index_arrays_init/ensure/free -> BM_mesh_elem_table_ensure/init/free
- EDBM_vert/edge/face_at_index -> BM_vert/edge/face_at_index
- EDBM_uv_element_map_create/free -> BM_uv_element_map_create/free
- ED_uv_element_get -> BM_uv_element_get
2013-10-28 02:05:33 +00:00
5816aa42bf code cleanup: minor transform refactor
redraw flag were mixing up types - int/char/bool, add enum type to use instead.
2013-10-23 06:48:36 +00:00
fd01e72877 check SELECT flags for curves (was checking for nonzero which would break if new files use this field for other flags) 2013-10-01 12:35:43 +00:00
fc6c283271 code cleanup: use bool for imbuf allocation functions. 2013-09-10 01:00:03 +00:00
ea94411db6 Enable vertex snapping to bundle positions
This means it's possible now to snap stuff to
reconstructed tracks positions.
2013-09-09 11:37:37 +00:00
f008a4c551 edit to object center snapping, exit early if unsupported. 2013-08-19 04:23:54 +00:00
43e9913ba3 add support for snapping to empty centers during transform. 2013-08-19 04:22:05 +00:00
aea5114633 editmesh draw optimizations: use customdata offsets rather then per-element lookups. 2013-06-20 11:18:19 +00:00
972c01ac0c remove NULL checks for return values from EDBM_***_at_index calls. 2013-06-20 07:00:57 +00:00
a25703eb36 ruler snap adjustments
- when in wireframe mode: don't snap to faces, instead snap to the closest edge/vertex.
- when not in wireframe mode: snap to the front-most element (was a problem that it could snap to an edge/vert behind the face)
- reduce the distance for selecting ruler points, was too easy to accidentally drag a ruler.
2013-04-25 09:39:03 +00:00
00d04e1924 rna api function scene.ray_cast now returns the object and its matrix (incase its a dupli). 2013-04-24 17:49:13 +00:00
3b8221045f simple optimizations for bvhtree_from_mesh_faces() for editmesh, was quite inefficient (unneeded loops, not breaking out of face loop early).
also correct own oversight - use TRANSFORM_DIST_MAX_RAY rather then when checking for max value in snapDerivedMesh.
2013-04-24 00:25:12 +00:00