4 years ago[MSVC2015/Cycles] MSVC2015 before update 3 produce invalid builds
Ray Molenkamp [Mon, 18 Jul 2016 13:24:46 +0000 (15:24 +0200)]
[MSVC2015/Cycles] MSVC2015 before update 3 produce invalid builds

I'm not quite sure where the codegen bug gets triggered but it's easily
noticeable in the barcelona scene. (extra saturated leafs and illumination
on the right ledge of the pool)

2013 buildbot reference image:

2015 With no updates (compiler version 19.00.23026)

2015 With Update 2 (Compiler version 19.00.23918)

2015 With Update 3 (Compiler version 19.00.24210)

This patch blocks all compiler builds before update 3 in a similar way we
did for msvc 2013 update 4

Reviewers: campbellbarton, brecht, juicyfruit

Reviewed By: juicyfruit

Tags: #bf_blender

Differential Revision:

4 years ago[MSVC/LNK4199/Cleanup] Delay loading is causing linker warnings.
Ray Molenkamp [Mon, 18 Jul 2016 13:16:45 +0000 (15:16 +0200)]
[MSVC/LNK4199/Cleanup] Delay loading is causing linker warnings.

We recently added delay-loading of the openmp dll's so we no longer had to use
the stub loader, we however put these linker flags on the global linker flags
causing any sub projects not using openmp to spit linker warning 4199 while building,

Warning LNK4199 /DELAYLOAD:vcomp140.dll ignored; no imports found from vcomp140.dll datatoc k:\BlenderGit\build_windows_2015a\source\blender\datatoc\LINK 1

This patch makes the delay-load only apply to the blender project.

Reviewers: sergey

Subscribers: sergey

Tags: #bf_blender

Differential Revision:

4 years agoFix (unreported) ED_region_tag_redraw_partial() could override a previously defined...
Bastien Montagne [Mon, 18 Jul 2016 12:37:04 +0000 (14:37 +0200)]
Fix (unreported) ED_region_tag_redraw_partial() could override a previously defined partial redraw, instead of extending it.

Probably not an issue currently, since partial redraw is not much used
(only from sculpt code and box-rendering it seems?), but logic was broken here.

4 years agoFix T48848: Cycles - Camera Culling - Camera Culling removes objects which are still...
Sergey Sharybin [Mon, 18 Jul 2016 12:29:37 +0000 (14:29 +0200)]
Fix T48848: Cycles - Camera Culling - Camera Culling removes objects which are still in frame

4 years agoFix T48877: Lightmap Pack fails w/ 1-3 faces
Campbell Barton [Mon, 18 Jul 2016 09:44:51 +0000 (19:44 +1000)]
Fix T48877: Lightmap Pack fails w/ 1-3 faces

Unnecessary limit was applied.

4 years agoCMake: correct py-module on OSX
Campbell Barton [Mon, 18 Jul 2016 09:28:45 +0000 (19:28 +1000)]
CMake: correct py-module on OSX

4 years agoFix T48860: Cycles SSS artifacts with spatially split BVH
Sergey Sharybin [Fri, 15 Jul 2016 12:55:37 +0000 (14:55 +0200)]
Fix T48860: Cycles SSS artifacts with spatially split BVH

The issue was caused by SSS intersection code gathering all
intersections without check for duplicated ones. This caused
situations when same intersection will be recorded twice in
the case if triangle is shared by several BVH nodes.

Usually this is handled by checking intersection distance
after sorting intersections (in shadow_blocked for example)
but for SSS we don't do such sorting and using number of
intersections to calculate various things.

Didn't find anything smarter than to check intersection
distance in triangle_intersect_subsurface().

This solves render artifacts in the cost of 1.5% slowdown
of extreme case rendering (SSS object filling in whole
FullHD screen).

Reviewers: brecht

Reviewed By: brecht

Differential Revision:

4 years agoCycles: Fix OpenCL compilation after the recent numerical fixes
Lukas Stockner [Sun, 17 Jul 2016 17:24:53 +0000 (19:24 +0200)]
Cycles: Fix OpenCL compilation after the recent numerical fixes

4 years agoBLI_heap: replace memarena w/ local allocator
Campbell Barton [Sun, 17 Jul 2016 09:02:01 +0000 (19:02 +1000)]
BLI_heap: replace memarena w/ local allocator

- Since element size its known it's less work to do inline.
- In test with high-poly model, gave ~9% overall speedup for decimate modifier.

4 years agoCleanup: minor edits to BLI_heap
Campbell Barton [Sun, 17 Jul 2016 07:31:27 +0000 (17:31 +1000)]
Cleanup: minor edits to BLI_heap

4 years agoCycles: Fix three numerical issues in the fresnel, normal map and Beckmann code
Lukas Stockner [Sat, 16 Jul 2016 18:48:12 +0000 (20:48 +0200)]
Cycles: Fix three numerical issues in the fresnel, normal map and Beckmann code

- In fresnel_dielectric, the differentials calculation sometimes divided by zero.
- When the normal map was (0.5, 0.5, 0.5), the code would try to normalize a zero vector. Now, it just uses the regular normal as a fallback.
- The approximate error function used in Beckmann sampling sometimes overflowed to inf while calculating r^16. The final value is 1 - 1/r^16, however,
  so now it just returns 1 if the computation would overflow otherwise.

4 years agoCycles: Deduplicate geometric factor calculation in the Beckmann distribution
Lukas Stockner [Sat, 16 Jul 2016 18:44:28 +0000 (20:44 +0200)]
Cycles: Deduplicate geometric factor calculation in the Beckmann distribution

Also, this fixes a numerical issue where A would be inf.
Since later G is set to 1 if A is larger than 1.6, the code now checks the reciprocal of A for being smaller than 1/1.6 - same effect, but no inf involved.

4 years agoFix use after free error from ab993e37
Campbell Barton [Sat, 16 Jul 2016 17:03:22 +0000 (03:03 +1000)]
Fix use after free error from ab993e37

4 years agoCleanup: spelling
Campbell Barton [Sat, 16 Jul 2016 07:48:57 +0000 (17:48 +1000)]
Cleanup: spelling

4 years agoCleanup: line length
Campbell Barton [Sat, 16 Jul 2016 06:36:30 +0000 (16:36 +1000)]
Cleanup: line length

4 years agoUse the value `VIEW_PROJ_PERSP` in the remaining places
Germano Cavalcante [Sat, 16 Jul 2016 00:25:44 +0000 (21:25 -0300)]
Use the value `VIEW_PROJ_PERSP` in the remaining places

also changes the name of the callbacks:
- walk_parent_snap_project_cb to cb_walk_parent_snap_project;
- cb_leaf_snap_vert to cb_walk_leaf_snap_vert;
- cb_leaf_snap_edge to cb_walk_leaf_snap_edge;
- test_vert_depth_cb to test_vert_ray_dist_cb;
- test_edge_depth_cb to test_edge_ray_dist_cb;

and cleanup:

4 years agoCycles: Fix refitting of regular BVH
Sergey Sharybin [Fri, 15 Jul 2016 16:12:05 +0000 (18:12 +0200)]
Cycles: Fix refitting of regular BVH

Was causing CUDA issues on viewport edits.

4 years agoUI: modifier keys now trigger number button updates
Campbell Barton [Fri, 15 Jul 2016 11:54:38 +0000 (21:54 +1000)]
UI: modifier keys now trigger number button updates

Number buttons & sliders weren't updating when shift/ctrl were pressed.

Note that this is a regression in 2.77 but hard to track down since it worked unreliably for some time.

4 years agoBump maximum threads number to 1024
Sergey Sharybin [Sun, 7 Jun 2015 20:48:51 +0000 (22:48 +0200)]
Bump maximum threads number to 1024

This commit contains all the changes required for most optimal maximum threads
number bump. This is needed to avoid possibly unneeded initialization or data
allocation on systems with lower threads count.

TODO: Still need to review arrays in render data structures from render_types.h,

P.S. We might remove actual bump of max threads from this patch, so when we'll
be applying the patch we can do all the preparation work and then do actual
bump of max threads.

Reviewers: mont29, campbellbarton

Reviewed By: mont29, campbellbarton

Maniphest Tasks: T43306

Differential Revision:

4 years agoCycles: Add option to disable new Hair BVH
Sergey Sharybin [Thu, 7 Jul 2016 16:04:16 +0000 (18:04 +0200)]
Cycles: Add option to disable new Hair BVH

While it's an extra option added to the interface which might not be
fully obvious for artists, it allows to save up to 20% of memory in
hairy scenes.

This is high enough memory saver in my opinion which might become
handy for some production files where it's more important to make
scene to fit into memory rather than trying to use more optimal BVH
structure but go into swap or crash.

Reviewers: dingto, brecht

Reviewed By: dingto, brecht

Differential Revision:

4 years agofix T48857: Improved the handling of Material Alpha, based on patch D1949 with some...
Sandy Carter [Fri, 15 Jul 2016 14:14:32 +0000 (16:14 +0200)]
fix T48857: Improved the handling of Material Alpha, based on patch D1949 with some small modifications

4 years agoCollada: changed specification of material alpha from using transparency to using...
Gaia Clary [Fri, 15 Jul 2016 14:12:39 +0000 (16:12 +0200)]
Collada: changed specification of material alpha from using transparency to using transparent with opaque=A_ONE

4 years agoRe-initialize source/tools submodule
Sergey Sharybin [Fri, 15 Jul 2016 13:12:28 +0000 (15:12 +0200)]
Re-initialize source/tools submodule

4 years agomissed from last commit
Campbell Barton [Fri, 15 Jul 2016 10:00:18 +0000 (20:00 +1000)]
missed from last commit

4 years agoObject Snap: make normal argument optional
Campbell Barton [Fri, 15 Jul 2016 09:46:59 +0000 (19:46 +1000)]
Object Snap: make normal argument optional

Often its not needed, setting correctly takes some extra calculation - so allow for it to be left unset.

4 years agoFix T48855: Ruler thickness broken in ortho view
Campbell Barton [Fri, 15 Jul 2016 09:22:00 +0000 (19:22 +1000)]
Fix T48855: Ruler thickness broken in ortho view

Don't do ray-casts from the view unless cursor coords are passed.

4 years agoObject Snap: replace perspective bool with enum
Campbell Barton [Fri, 15 Jul 2016 09:14:46 +0000 (19:14 +1000)]
Object Snap: replace perspective bool with enum

Allows to set the projection as none,
to make it more obvious when we don't want to handle viewport projections in some cases.

4 years agoCorrect error in snap commit
Campbell Barton [Fri, 15 Jul 2016 08:40:16 +0000 (18:40 +1000)]
Correct error in snap commit

4 years agoCleanup: use BLI_math for paint smooth-stroke
Campbell Barton [Fri, 15 Jul 2016 07:17:42 +0000 (17:17 +1000)]
Cleanup: use BLI_math for paint smooth-stroke

4 years agoCleanup: rename snap vars
Campbell Barton [Fri, 15 Jul 2016 07:12:43 +0000 (17:12 +1000)]
Cleanup: rename snap vars

4 years agoAdd "Snap Selection to Active" option in menu
Campbell Barton [Fri, 15 Jul 2016 07:07:18 +0000 (17:07 +1000)]
Add "Snap Selection to Active" option in menu

D1963 by @wisaac, re-worked to de-duplicate logic

4 years agoSupport for loading multiple images from the file selector
Campbell Barton [Fri, 15 Jul 2016 06:02:46 +0000 (16:02 +1000)]
Support for loading multiple images from the file selector

D2035 by @jside, extended to support mixing single images and sequences in the one selection.

4 years agoFix select grouped parent, extend option was ignored
Campbell Barton [Fri, 15 Jul 2016 05:56:28 +0000 (15:56 +1000)]
Fix select grouped parent, extend option was ignored

D2067 by @mangostaniko

4 years agoUI: Remove spaces around '/'
Campbell Barton [Fri, 15 Jul 2016 05:50:42 +0000 (15:50 +1000)]
UI: Remove spaces around '/'

D2093 by @Blendify

4 years agoSequencer: Remove add effect strip filesel properties
Campbell Barton [Fri, 15 Jul 2016 05:45:45 +0000 (15:45 +1000)]
Sequencer: Remove add effect strip filesel properties

D2096 by @chadf

Unused, copy-paste error.

4 years agoFix py-driver in startup.blend crash in background mode
Campbell Barton [Fri, 15 Jul 2016 05:29:27 +0000 (15:29 +1000)]
Fix py-driver in startup.blend crash in background mode

Obscure regression in own commit from b34929786.
While this could be considered correct, it introduces a crash so disable the update call.

4 years agoCode cleanup: show unused arguments names for ShaderNode::constant_fold.
Brecht Van Lommel [Thu, 14 Jul 2016 20:48:41 +0000 (22:48 +0200)]
Code cleanup: show unused arguments names for ShaderNode::constant_fold.

4 years agofix T48857: Added support for transparency (used Patch D1949 from bwrsandman with...
Gaia Clary [Thu, 14 Jul 2016 19:42:44 +0000 (21:42 +0200)]
fix T48857: Added support for transparency (used Patch D1949 from bwrsandman with some slight changes)

4 years agoUse BMesh solver for new boolean modifiers
Campbell Barton [Thu, 14 Jul 2016 16:46:04 +0000 (02:46 +1000)]
Use BMesh solver for new boolean modifiers

4 years agoCleanup: comment blocks
Campbell Barton [Thu, 14 Jul 2016 16:36:21 +0000 (02:36 +1000)]
Cleanup: comment blocks

4 years agoFix T48844: Nodetrees of appended materials/textures/etc. were not correctly made...
Bastien Montagne [Thu, 14 Jul 2016 16:18:54 +0000 (18:18 +0200)]
Fix T48844: Nodetrees of appended materials/textures/etc. were not correctly made local.

Previous commits now allow to use id_make_local() here, as one would expect.

Note that I also checked T36003 case, working fine as well with new code.

4 years agoCorrect recent own fix to id_clear_lib_data_ex().
Bastien Montagne [Thu, 14 Jul 2016 16:16:05 +0000 (18:16 +0200)]
Correct recent own fix to id_clear_lib_data_ex().

Datablocks' nodetree are *never* in main, while shapekeys are...

4 years agoCleanup/refactor: handle shapekeys exactly like 'owned' nodetrees in make_local process.
Bastien Montagne [Thu, 14 Jul 2016 13:38:41 +0000 (15:38 +0200)]
Cleanup/refactor: handle shapekeys exactly like 'owned' nodetrees in make_local process.

4 years agoCleanup: use BKE's ntreeFromID in readfile instead of local same function.
Bastien Montagne [Thu, 14 Jul 2016 13:32:25 +0000 (15:32 +0200)]
Cleanup: use BKE's ntreeFromID in readfile instead of local same function.

Also, no need to set ntree->id.lib to NULL after BKE_libblock_copy_nolib(),
generic datablock copy function always make copy local.

4 years agoFix bad handling of datablock's nodetree id_clear_lib_data_ex().
Bastien Montagne [Thu, 14 Jul 2016 13:23:53 +0000 (15:23 +0200)]
Fix bad handling of datablock's nodetree id_clear_lib_data_ex().

Those data blocks are never shared, exactly as with shapekeys, much simpler
to also clear their lib_data (especially since they have no user!).

4 years agoGet rid of BKE_key_make_local().
Bastien Montagne [Thu, 14 Jul 2016 11:07:45 +0000 (13:07 +0200)]
Get rid of BKE_key_make_local().

This function was only a wrapper around id_clear_lib_data(), and shapekeys
are not linkable nor shareable anyway, no point keeping this currently,
was only adding confusion about shapekey 'status' as a datatblock.

4 years agoAdd option to id_make_local to force localization of datablock, even if not used...
Bastien Montagne [Thu, 14 Jul 2016 11:03:22 +0000 (13:03 +0200)]
Add option to id_make_local to force localization of datablock, even if not used locally.

Will be used by link/append code.

4 years agoFix T48843: Sequencer crash with many effects
Campbell Barton [Thu, 14 Jul 2016 16:30:37 +0000 (02:30 +1000)]
Fix T48843: Sequencer crash with many effects

Switch from a fixed stack to a linked list,
since guessing the maximum possible size may fail with invalid/overlapping strips.

4 years agoAdd developer tools submodule
Campbell Barton [Thu, 14 Jul 2016 15:26:40 +0000 (01:26 +1000)]
Add developer tools submodule

This is intended for utilities to help with development,
which aren't needed for building.

See for details

4 years agoCleanup: line length
Campbell Barton [Thu, 14 Jul 2016 15:26:04 +0000 (01:26 +1000)]
Cleanup: line length

4 years agoPyAPI: minor cleanup with library linking
Campbell Barton [Thu, 14 Jul 2016 11:00:05 +0000 (21:00 +1000)]
PyAPI: minor cleanup with library linking

4 years agoConsolidate multiple checks for out->rect_float in prepare_effect_imbufs()
Chad Fraleigh [Thu, 14 Jul 2016 12:15:43 +0000 (14:15 +0200)]
Consolidate multiple checks for out->rect_float in prepare_effect_imbufs()

Many checks for out->rect_float being [non-]NULL are done back-to-back.
Combining them into a single check for slightly more efficient code and
less code clutter for easier readability/understanding.

Differential Revision:

4 years agoCleanup: Use BKE_scene_base_add for creating bases
Julian Eisel [Thu, 14 Jul 2016 11:58:40 +0000 (13:58 +0200)]
Cleanup: Use BKE_scene_base_add for creating bases

And use __func__ macro.

4 years agoCycles: Give better idea which OpenCL kernel is currently compiling
Sergey Sharybin [Thu, 14 Jul 2016 10:49:20 +0000 (12:49 +0200)]
Cycles: Give better idea which OpenCL kernel is currently compiling

4 years agoCycles: Avoid strings passed by value in OpenCL device
Sergey Sharybin [Thu, 14 Jul 2016 10:44:51 +0000 (12:44 +0200)]
Cycles: Avoid strings passed by value in OpenCL device

Also use more const qualifiers in the code.

4 years agoMake --debug-all include --debug-cycles and --debug-libmv
Sergey Sharybin [Thu, 14 Jul 2016 10:14:55 +0000 (12:14 +0200)]
Make --debug-all include --debug-cycles and --debug-libmv

4 years agoLibmv: Fix some strict compiler warnings
Sergey Sharybin [Thu, 14 Jul 2016 09:49:38 +0000 (11:49 +0200)]
Libmv: Fix some strict compiler warnings

One of them was a real bug!

4 years agoCycles: Fix wrong size of sobol texture
Sergey Sharybin [Thu, 14 Jul 2016 09:11:23 +0000 (11:11 +0200)]
Cycles: Fix wrong size of sobol texture

After reformulation of SSS indirect rays it became possible to
try accessing dimension higher than was pre-calculated on scene

This is because we're traversing rays backwards, which means we
are using higher dimensions first now.

4 years agoCycles: Fix wrong termination criteria in intersect_all functions
Sergey Sharybin [Thu, 14 Jul 2016 09:08:24 +0000 (11:08 +0200)]
Cycles: Fix wrong termination criteria in intersect_all functions

It was possible to miss bounces termination criteria in this functions,
mainly when max_hits was set to 0.

Made the check more robust in traversal functions (which should not
affect performance, it's an operation of same complexity AFAIK).

Also avoid doing ray-scene intersection from shadow_blocked when
limit of transparent bounces was already reached.

4 years agoCMake: per-target CFLAG & CXXFLAG support
Campbell Barton [Thu, 14 Jul 2016 09:11:33 +0000 (19:11 +1000)]
CMake: per-target CFLAG & CXXFLAG support

Applying cflags globally can be problematic especially with extern, intern libs.

Now flags from target named will be used when defined,
allowing for developers to define flags for modules they maintain.



On Linux run `make help` for full list of names, MSVC shows these in the solution.

4 years agoPyAPI: Leak fix caused crash w/ attr swap trick
Campbell Barton [Thu, 14 Jul 2016 08:27:20 +0000 (18:27 +1000)]
PyAPI: Leak fix caused crash w/ attr swap trick

Accessing ` does search, then swaps its getset with the string it finds.
This caused a freed pointer to be stored in's dictionary.

Fix by using the same string for get/set access.

4 years agoPyAPI: fix leak linking library data
Campbell Barton [Thu, 14 Jul 2016 07:38:22 +0000 (17:38 +1000)]
PyAPI: fix leak linking library data

4 years agoPyAPI: fix memory leaks in dictionary assignment
Campbell Barton [Thu, 14 Jul 2016 07:28:28 +0000 (17:28 +1000)]
PyAPI: fix memory leaks in dictionary assignment

Thanks to Kévin Dietrich for spotting driver leak,
checked other uses of PyDict_SetItem and found more.

4 years agoPyAPI: Use module names on initializaton
Campbell Barton [Thu, 14 Jul 2016 05:51:56 +0000 (15:51 +1000)]
PyAPI: Use module names on initializaton

No need to re-convert from C strings to PyUnicode.

4 years agoImproves the accuracy of snap to edges
Germano Cavalcante [Thu, 14 Jul 2016 03:47:32 +0000 (00:47 -0300)]
Improves the accuracy of snap to edges

Recently the snap to edges has been changed to work with coordinates 2d. Thus, the lambda of the snap pointon on edge becomes different from the actual lambda in a 3d edge.

The solution to correct the lambda was this:

if (is_persp) {
const float fac = depth_a / (depth_a + depth_b);
lambda *= (1.0f + (fac - 0.5f) * (1.0f - lambda));

But the lambda was still not very accurate.
Now the function uses the `dist_squared_ray_to_seg_v3` to get the coordinate of the snap point on the edge. And then tests that point.

The accuracy returned to normal values.

4 years agoCleanup: style
Campbell Barton [Thu, 14 Jul 2016 03:37:49 +0000 (13:37 +1000)]
Cleanup: style

4 years agoUse BLI_endian_switch in dna_genfile
Campbell Barton [Thu, 14 Jul 2016 01:52:53 +0000 (11:52 +1000)]
Use BLI_endian_switch in dna_genfile

4 years agoSimplify snapping functions
Germano Cavalcante [Thu, 14 Jul 2016 03:02:21 +0000 (00:02 -0300)]
Simplify snapping functions

from D2104: reference all repeated (and strange) equations (example: mul_m4_m4m4(pmat_local, pmat, obmat)) in the function `precalc_project.

This is useful for maintenance.

4 years agoFix T48846: Ruler/Protractor crash in ortho mode
Campbell Barton [Thu, 14 Jul 2016 01:06:40 +0000 (11:06 +1000)]
Fix T48846: Ruler/Protractor crash in ortho mode

Error in recent snap changes.

4 years agoFix T48845: Crash when right-clicking on a curve property
Kévin Dietrich [Wed, 13 Jul 2016 22:24:31 +0000 (00:24 +0200)]
Fix T48845: Crash when right-clicking on a curve property

Caused by typo in rBd2312602125a452e6562a76ab91779943c67396d

4 years agoFix T48734: Driver not updating when using Single From Driver within same object
Sergey Sharybin [Wed, 13 Jul 2016 13:00:29 +0000 (15:00 +0200)]
Fix T48734: Driver not updating when using Single From Driver within same object

4 years agoFix T48839: Selection from pose mode gives wrong snap results
Campbell Barton [Wed, 13 Jul 2016 12:22:37 +0000 (22:22 +1000)]
Fix T48839: Selection from pose mode gives wrong snap results

Current code changes the selection then then runs ED_armature_sync_selection
to copy to the bones rootsel flag from the parents tipsel.

Use this logic for entering edit-mode too.

4 years agoBoolean Modifier: Add back BMesh option
Campbell Barton [Wed, 13 Jul 2016 07:45:55 +0000 (17:45 +1000)]
Boolean Modifier: Add back BMesh option

There are still issues with overlapping geometry,
however some of the issues reported are are causing problems,
or fail entirely with Carve too.

4 years agoDepsgraph: Make proxy behavior closer to old depsgraph
Sergey Sharybin [Wed, 13 Jul 2016 08:55:35 +0000 (10:55 +0200)]
Depsgraph: Make proxy behavior closer to old depsgraph

Fixes possible missing update of proxy_from pointer before using
it in relations builder.

4 years agoRevert "Depsgraph: Russian electric tape bodge to have multiple proxies work"
Sergey Sharybin [Wed, 13 Jul 2016 08:39:55 +0000 (10:39 +0200)]
Revert "Depsgraph: Russian electric tape bodge to have multiple proxies work"

This reverts commit 47d0d9cca4d0c3ccbdc368e97fc24652379fd368.

Reverting the commit. Not only it did not solve all the cases of proxy popping,
but also broke real cases with single proxy involved.

4 years agoDepsgraph: Accumulate object layers from all bases
Sergey Sharybin [Wed, 13 Jul 2016 08:07:09 +0000 (10:07 +0200)]
Depsgraph: Accumulate object layers from all bases

This solves bug when same object is instanced from multiple bases.

4 years agoUse BLI_bvhtree_walk_dfs for snapping
Campbell Barton [Wed, 13 Jul 2016 04:42:00 +0000 (14:42 +1000)]
Use BLI_bvhtree_walk_dfs for snapping

The snapping functions when performed in the perspective view,
have some problems in the threshold (a distortion) and in the clip plane (the normal is incorrect).
These problems can be only observed when making the snap to edges or to vertices (nearest to ray function).

This patch propose a totally different solution.
The idea is to project the edges of bvh nodes and test the 2d projection of the snap element.

For this it used the BLI_bvhtree_walk_dfs function.

It is important to pay particular attention also to the changes in `ED_transform_snap_object_project_view3d_ex`

4 years agoVertex/Weight Paint: Support view-selected on last-stroke
Campbell Barton [Wed, 13 Jul 2016 03:57:46 +0000 (13:57 +1000)]
Vertex/Weight Paint: Support view-selected on last-stroke

D1875 by @lichtwerk

4 years agoFix 48831, Step II: UI icon code was not able to update/generate 'auto ID icon' from...
Bastien Montagne [Tue, 12 Jul 2016 19:08:38 +0000 (21:08 +0200)]
Fix 48831, Step II: UI icon code was not able to update/generate 'auto ID icon' from non-ID icon draw code.

Now using generic icon rendering system in that case too, instead of custom code
which was only handling 'deferred' custom file-loaded icons.

4 years agoFix 48831, Step I: Mismatch issues bewteen ID icon and preview system.
Bastien Montagne [Tue, 12 Jul 2016 15:49:30 +0000 (17:49 +0200)]
Fix 48831, Step I: Mismatch issues bewteen ID icon and preview system.

- icon_id from ID and PreviewImage were not guaranteed to be in sync.
- PreviewImage one was not reset on file read.
- Through RNA e.g., it was possible to ensure an ID icon via its preview image,
  which was running code designed for custom previews/icons system, instead
  of generating correct 'auto ID icon'.

4 years agoRevert "OpenJPEG: update to 2.1 from 1.5"
Sergey Sharybin [Tue, 12 Jul 2016 15:38:26 +0000 (17:38 +0200)]
Revert "OpenJPEG: update to 2.1 from 1.5"

This reverts commit f12204196fb1ee985ab9745cf9c70877601145f9.

Campbell, sorry. have to revert this for the time being.

We've missed some very important bits, such as:

- FFmpeg is usually linked against OpenJPEG
- OIIO needs OpenJPEG as well.

For FFmpeg issues we can either disable OpenJPEG there (since
we don't really use it), or bump FFmpeg to version 3.1.1 which
can use either of OpenJPEG 1.5 or 2.1.

For OIIO we do need OpenJPEG support (otherwise Cycles will
not be able to use j2k/j2c textures) and currently there is
NO solution to make OIIO working with OpenJPEG 2.1.

According to Matthias Fauconneau (aka mfv) Larry is working
on the patch to get OIIO work with OpenJPEG 2.1, but it'll
take some time still.

I've tried to look into support of some sort of build system
flag and do ifdefs, but it all becomes quite nasty, especially
with bundled OpenJPEG bumped to 2.1.

Surely such an update is something we'll have to apply to
but at this exact moment it causes quite some pain for all

Suggest to wait for until OIIO supports OpenJPEG 2.1 and then
go with the updates for real.

4 years agoFix T48818: Objects with alpha maps cast wrong ray shadows in BI
Sergey Sharybin [Tue, 12 Jul 2016 13:40:40 +0000 (15:40 +0200)]
Fix T48818: Objects with alpha maps cast wrong ray shadows in BI

4 years agoOpenJPEG: update to 2.1 from 1.5
Campbell Barton [Thu, 9 Jun 2016 11:56:29 +0000 (21:56 +1000)]
OpenJPEG: update to 2.1 from 1.5

Stream handling has changed so this required changes to how files & memory are accessed.

4 years agoFix saving jpeg2k images from Python
Campbell Barton [Tue, 12 Jul 2016 10:35:02 +0000 (20:35 +1000)]
Fix saving jpeg2k images from Python

Quality was defaulting to lowest and no codec was set.

4 years agoCleanup: remove redundant check
Campbell Barton [Tue, 12 Jul 2016 07:59:25 +0000 (17:59 +1000)]
Cleanup: remove redundant check

4 years agoFix T48830: Outliner draw crash, missing NULL check
Campbell Barton [Tue, 12 Jul 2016 04:39:39 +0000 (14:39 +1000)]
Fix T48830: Outliner draw crash, missing NULL check

Fix from @cheleb

4 years agowritefile: reuse SDNA between writes
Campbell Barton [Tue, 12 Jul 2016 02:53:49 +0000 (12:53 +1000)]
writefile: reuse SDNA between writes

Avoids decoding the SDNA string every undo step.

4 years agoreadfile: report SDNA decoding errors on file read
Campbell Barton [Tue, 12 Jul 2016 02:23:48 +0000 (12:23 +1000)]
readfile: report SDNA decoding errors on file read

This was printed to the stdout, however the error case wasn't checked or well supported.
Also, errors decoding SDNA would sometimes call exit(1).

4 years agowritefile: remove SDNA last-hit, optimize DNA reconstruct
Campbell Barton [Tue, 12 Jul 2016 01:48:04 +0000 (11:48 +1000)]
writefile: remove SDNA last-hit, optimize DNA reconstruct

- Move last-hit index out of SDNA struct
  (allows for access by multiple threads).
- Replace O(n^2) search with hash lookup in DNA reconstruction.

4 years agoRemove usercount handling from BKE_id_expand_local.
Bastien Montagne [Mon, 11 Jul 2016 19:27:15 +0000 (21:27 +0200)]
Remove usercount handling from BKE_id_expand_local.

Idea looked good, but we have too much custom situations here (some half-fake-sub-ID
being copied with their 'owner', animdata, etc.), let's let datablock copy functions
handle that themselves.

Also allows to safely call BKE_id_expand_local from all copy functions now (only when
copying linked data).

4 years agoCleanup: remove call to BKE_id_lib_local_paths() in make_local functions.
Bastien Montagne [Mon, 11 Jul 2016 19:03:02 +0000 (21:03 +0200)]
Cleanup: remove call to BKE_id_lib_local_paths() in make_local functions.

This one is already called by matching copy functions, no need to call it twice!

4 years agoUse new generic BKE_id_expand_local() for make_local() for object.
Bastien Montagne [Mon, 11 Jul 2016 18:56:28 +0000 (20:56 +0200)]
Use new generic BKE_id_expand_local() for make_local() for object.

4 years agoUse new generic BKE_id_expand_local() for make_local() for image/material/texture...
Bastien Montagne [Mon, 11 Jul 2016 18:45:57 +0000 (20:45 +0200)]
Use new generic BKE_id_expand_local() for make_local() for image/material/texture/world.

As said in previous commits, did not touch to copy functions for now, due to ntree issues...

4 years agoRevert 'use new BKE_id_expand_local()' change for Lamp's copy function.
Bastien Montagne [Mon, 11 Jul 2016 18:16:22 +0000 (20:16 +0200)]
Revert 'use new BKE_id_expand_local()' change for Lamp's copy function.

ntree is once more time a PITA - actually, all sub-IDs that get copied together with the 'main' one are
(shapekey was workedaround, as was animdata/action issue, but nodes are more touchy).

For now, better not to touch that, needs careful check & rethink.

4 years agoUse new generic BKE_id_expand_local() for make_local() for nodetree.
Bastien Montagne [Mon, 11 Jul 2016 17:44:14 +0000 (19:44 +0200)]
Use new generic BKE_id_expand_local() for make_local() for nodetree.

Did not changed ntree copy for now, this func is a mess of expand/non-expand/bmain/non-bmain cases...
Keep it for later!

4 years agoUse new generic BKE_id_expand_local() for both make_local() and copy() functions...
Bastien Montagne [Mon, 11 Jul 2016 17:39:34 +0000 (19:39 +0200)]
Use new generic BKE_id_expand_local() for both make_local() and copy() functions of actions, brushes and particles.

This greatly simplifies said code, once again no change expected from user PoV.

4 years agoUse new generic BKE_id_expand_local() for both make_local() and copy() functions...
Bastien Montagne [Mon, 11 Jul 2016 17:13:42 +0000 (19:13 +0200)]
Use new generic BKE_id_expand_local() for both make_local() and copy() functions of obdata
(armature, mesh, curve, mball, lattice, lamp, camera, and speaker).

This greatly simplifies said code, once again no change expected from user PoV.

4 years agoAdd an exception/hack to new BKE_id_expand_local(), to ignore actions datablock in...
Bastien Montagne [Mon, 11 Jul 2016 17:09:46 +0000 (19:09 +0200)]
Add an exception/hack to new BKE_id_expand_local(), to ignore actions datablock in its usercount handling.

Reason is, typically those actions datablock usercounts have already been adjusted in BKE_animdata_copy()
(called by generic iddata copy function).

Think this needs to be reworked a bit too, there are way too much ways to copy animdata currently,
it's rather confusing. But not the goal here, so for now we'll live with the hack!

4 years agoFix (unreported) memory leak when making local linked databock which has a preview...
Bastien Montagne [Mon, 11 Jul 2016 14:50:59 +0000 (16:50 +0200)]
Fix (unreported) memory leak when making local linked databock which has a preview image.

Also cleaned-up/synchronized code across al ID types that support preview.

4 years agoAdd generic 'BKE_id_expand_local' to BKE_library,
Bastien Montagne [Mon, 11 Jul 2016 14:41:59 +0000 (16:41 +0200)]
Add generic 'BKE_id_expand_local' to BKE_library,
will be used by both make_local() and copy() datablock functions.

Note that this new func make 'extern' all IDs used by localized datablock,
not only refcounted ones as it used to be in each type's functions (with a few exceptions).