Commit Graph

202 Commits

Author SHA1 Message Date
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
b64ec6c51e alternate fix for [#24887] - r33294.
Casting a ray onto an editmesh was building a derivedMesh, raytree, then freeing for every ray-cast.
Noticed while using ruler+snapping in editmode.

Instead of attempting to align the MFace and edit-mesh tessfaces, just use editmesh for ray-casting.
2013-04-23 23:57:27 +00:00
36e7a98459 fix [#35007] clipping border error
add clip option to ED_view3d_win_to_ray(), ED_view3d_win_to_segment()
2013-04-22 20:00:37 +00:00
37e73aa368 code cleanup: use BKE naming conventions for functions in BKE_editmesh.h and BKE_editmesh_bvh.h 2013-04-16 05:59:48 +00:00
ba283d6c9b modify snapObjectsRayEx() to use a pointer to 'ray_dist' rather then passing the dist, this is to better support multiple calls to ray-cast where only closer distances are accepted. 2013-04-14 05:37:43 +00:00
6da961775f code cleanup: rename BKE_tessmesh -> BKE_editmesh, rename EditDerivedBMesh.tc -> em. ('tc' is odd name which isn't used elsewhere). 2013-04-13 20:31:52 +00:00
94c9010e24 make scene.ray_cast() behave like object.ray_cast(), add distance arg to snapObjectsRayEx(). 2013-04-11 10:17:06 +00:00
bf77ad00b3 py api:
ray cast function, very useful to be able to cast rays into the scene for scripts.

  hit_co, hit_no, success = scene.ray_cast(start_co, end_co)
2013-04-11 09:57:26 +00:00
ef1af9f9c4 fix [#34802] Individual Transformation Confusing in Edit Mode
Individual transformation now works in editmode mesh faces/edge, armature bones and metaballs.
2013-04-04 09:20:46 +00:00
9a901691ee pass snap arguments so the ruler doesn't have to temp overwrite scene vars.
also expose snapObjectsRayEx() for more convenient ray-casting about the scene.
2013-04-03 09:48:21 +00:00
beb4d385bb use floats for transform snapping distance comparisons 2013-04-03 07:36:37 +00:00
b0ef03565d fix [#34698] Axis Locking works incorrect
don't do projection when constraints are used.
2013-03-26 03:36:18 +00:00
aaa8a13c49 code cleanup: use const events for modal and invoke operators. 2013-03-13 09:03:46 +00:00
d695d7c2ff code cleanup: use bool's for snapping functions. 2013-03-08 18:28:26 +00:00
f43153dd93 avoid floating point exceptions in snapObjects(), was attempting to scale up FLT_MAX. 2013-03-08 15:10:57 +00:00
c36f20a7d2 style cleanup 2013-03-08 04:00:06 +00:00
dfa8540cdf use bool for rna funcs. 2013-03-07 02:44:55 +00:00
6adb526f31 change to proportional editing suggested by Jeroen Hoolmans,
don't interpolate projection, just project all points within the PET radius.
2013-02-20 00:44:18 +00:00
3d41532554 fix [#34244] Snap to face projection - Entire mesh is affected by projection when Proportional Editing mode is active, regardless of influence radius 2013-02-19 16:57:04 +00:00
44b634bcb1 make EDBM_index_arrays's stay in memory, blender was allocating an array and filling it for verts/edges/faces on every redraw.
this may introduce bugs which I didn't catch, but they are very easy to identify in a debug build which has asserts to ensure the arrays are valid before use.

in my own test drawing ~98,304 quads - this gave an overall ~16% drawing speedup.
2012-12-12 06:53:39 +00:00
cf723e5e7c use htype flags as arguments to EDBM_index_arrays_init(), no functional changes. 2012-12-12 05:27:52 +00:00
7c699a217a define the size of matrix args for both rows/cols. 2012-12-11 14:29:01 +00:00
46d4d7559f Image Editor / UV:
* Bring back "Snap to Vertex", own regression introduced in r39460.

Patch by Brecht (DNA, Transform) and myself (RNA, Script).
2012-12-03 12:03:16 +00:00
76ba8f017e code cleanup: remove unused transform snapping code (only use the BVH accelerated version now).
and quiet narrowing conversion warning between signed/unsigned int.
2012-10-30 19:27:15 +00:00
f3ece5a108 style cleanup: trailing tabs & expand some non prefix tabs into spaces. 2012-10-21 05:46:41 +00:00
ccd9f1491a style cleanup: line length,
rename V3D_PROJ_RET_SUCCESS ->  V3D_PROJ_RET_OK
2012-10-07 14:00:18 +00:00
b9113f205c replace ED_view3d_project_float with ED_view3d_project_float_global 2012-10-05 03:20:14 +00:00
61ce7926d3 code cleanup: quiet warnings and use define for transform snap max distance. 2012-10-05 01:34:47 +00:00
fedc8e1722 Cycles: add "From Dupli" option for texture coordinate node. This gets the
Generated and UV coordinates from the duplicator of instance instead of the
object itself.

This was used in e.g. Big Buck Bunny for texturing instanced feathers with
a UV map on the bird. Many files changed, mainly to do some refactoring to
get rid of G.rendering global in duplilist code.
2012-10-04 21:40:39 +00:00
e77004157e make ED_view3d_project_int equivalent to ED_view3d_project_short functions. 2012-10-04 17:52:12 +00:00
edb78d090c code cleanup:
- make view3d project names more consistent.
- remove apply_project_float() its not needed.
- update comments referencing an old function name.
- move doxygen docs into the C file, prefer they are kept here to avoid getting out of sync with code.
2012-09-20 04:56:24 +00:00