blender-staging.git
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.

Convention is CMAKE_CFLAGS_${UPPERCASE_TARGET_NAME}, (CXXFLAGS for C++).

eg: CMAKE_CFLAGS_BF_BLENDER, CMAKE_CFLAGS_MAKESDNA, CMAKE_CXXFLAGS_CYCLES_KERNEL

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 `bpy.app.binary_path_python does search, then swaps its getset with the string it finds.
This caused a freed pointer to be stored in bpy.app'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
developers.

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).

4 years agoCycles: Fix compilation error on Windows with OSL enabled
Sergey Sharybin [Mon, 11 Jul 2016 16:15:51 +0000 (18:15 +0200)]
Cycles: Fix compilation error on Windows with OSL enabled

Seems there's some conflict around `near` identifier in that configuration.

4 years agoCycles: Fix typo
Sergey Sharybin [Mon, 11 Jul 2016 16:01:40 +0000 (18:01 +0200)]
Cycles: Fix typo

4 years agoFix T48824: Crash when having too many ray-to-volume intersections
Sergey Sharybin [Mon, 11 Jul 2016 15:58:42 +0000 (17:58 +0200)]
Fix T48824: Crash when having too many ray-to-volume intersections

Code might have writing past the array boundaries.

4 years agoFix T48812: Brush size invalid with HIDPI
Campbell Barton [Mon, 11 Jul 2016 15:15:54 +0000 (01:15 +1000)]
Fix T48812: Brush size invalid with HIDPI

Missed from c5b2f12b

4 years agoDepsgraph: Fix crash in Weight VG modifier
Sergey Sharybin [Mon, 11 Jul 2016 13:15:09 +0000 (15:15 +0200)]
Depsgraph: Fix crash in Weight VG modifier

4 years agoDepsgraph: Fix shape key nodes trying to be added multiple times
Sergey Sharybin [Mon, 11 Jul 2016 13:07:11 +0000 (15:07 +0200)]
Depsgraph: Fix shape key nodes trying to be added multiple times

4 years agoCleanup: line length
Campbell Barton [Mon, 11 Jul 2016 13:04:39 +0000 (23:04 +1000)]
Cleanup: line length

4 years agoCycles: Fix Extend image extension mode on OpenCL
Sergey Sharybin [Mon, 11 Jul 2016 12:46:42 +0000 (14:46 +0200)]
Cycles: Fix Extend image extension mode on OpenCL

4 years agoCycles: Use utility define for restrict pointers
Sergey Sharybin [Mon, 11 Jul 2016 11:53:37 +0000 (13:53 +0200)]
Cycles: Use utility define for restrict pointers

This way restrict can be used for CUDA and OpenCL as well.

From quick tests in areas i've been testing this it might give some
barely measurable %% of speedup, but it increases registers pressure.

So use of this qualifier is still really limited.

4 years agoCycles: Cleanup, variables name
Sergey Sharybin [Mon, 11 Jul 2016 11:44:19 +0000 (13:44 +0200)]
Cycles: Cleanup, variables name

Using camel case for variables is something what didn't came from our original
code, but rather from third party libraries. Let's avoid those as much as possible.

4 years agoCycles: Add _all suffix to shadow traversal file
Sergey Sharybin [Mon, 11 Jul 2016 10:31:25 +0000 (12:31 +0200)]
Cycles: Add _all suffix to shadow traversal file

Matches better naming of volume traversal files, where we've got
optimized versions of a single step of volume intersection and
traversal which will gather all volume intersections.

4 years agoCycles: Move BVK kernel files to own directory
Sergey Sharybin [Mon, 11 Jul 2016 10:28:45 +0000 (12:28 +0200)]
Cycles: Move BVK kernel files to own directory

BVH traversal is not really that much a geometry and we've got
quite some traversals now. Makes sense to keep them separate in
the name of source structure clarity.

4 years agoDyntopo: fix lop-sided edge collapse
Campbell Barton [Mon, 11 Jul 2016 11:49:59 +0000 (21:49 +1000)]
Dyntopo: fix lop-sided edge collapse

When an edge was collapsed, one of the vertices would be removed.
Edges attached to the deleted vertex wouldn't be considered for collapsing again,
making the outcome from collapsing edges depend on the edge-vertex order.

Use a hash to lookup the final vertex when collapsing edges, instead of skipping them.

4 years agoFix sculpting high poly meshes
Campbell Barton [Mon, 11 Jul 2016 07:08:27 +0000 (17:08 +1000)]
Fix sculpting high poly meshes

Attempted to free unallocated memory,
interestingly nobody noticed this for ~7 years (error from 3078c806).

4 years agoDyntopo: possible modified option was incorrectly set
Campbell Barton [Mon, 11 Jul 2016 06:03:17 +0000 (16:03 +1000)]
Dyntopo: possible modified option was incorrectly set

4 years agoDyntopo: remove redundant existing face check
Campbell Barton [Mon, 11 Jul 2016 05:26:23 +0000 (15:26 +1000)]
Dyntopo: remove redundant existing face check

Gives minor speedup

4 years agoBLI_math: move interp_*_cubic to its own function
Campbell Barton [Mon, 11 Jul 2016 05:28:39 +0000 (15:28 +1000)]
BLI_math: move interp_*_cubic to its own function

4 years agoCMake: suppressing indentation warning for extern
Campbell Barton [Mon, 11 Jul 2016 05:27:48 +0000 (15:27 +1000)]
CMake: suppressing indentation warning for extern

4 years agoFix T48822: Crash when I try to use "Join" (Ctrl Key + J) with two meshes.
Bastien Montagne [Sun, 10 Jul 2016 18:12:58 +0000 (20:12 +0200)]
Fix T48822: Crash when I try to use "Join" (Ctrl Key + J) with two meshes.

Own stupid typo in recent refactor work...

4 years agoRefactor/enhance BKE_action_make_local().
Bastien Montagne [Sun, 10 Jul 2016 15:07:27 +0000 (17:07 +0200)]
Refactor/enhance BKE_action_make_local().

Now using modern features from libquery/libremap areas.

Provides same kind of fixes/improvements as for BKE_object_make_local() (see rBd1a4ae3f395a6).

4 years agoRefactor/enhance ntreeMakeLocal().
Bastien Montagne [Sun, 10 Jul 2016 14:55:55 +0000 (16:55 +0200)]
Refactor/enhance ntreeMakeLocal().

Now using modern features from libquery/libremap areas.

Provides same kind of fixes/improvements as for BKE_object_make_local() (see rBd1a4ae3f395a6).

4 years agoRefactor/enhance BKE_image_make_local().
Bastien Montagne [Sun, 10 Jul 2016 14:44:09 +0000 (16:44 +0200)]
Refactor/enhance BKE_image_make_local().

Now using modern features from libquery/libremap areas.

Provides same kind of fixes/improvements as for BKE_object_make_local() (see rBd1a4ae3f395a6).

4 years agoRefactor/enhance BKE_material_make_local() and BKE_image_make_local().
Bastien Montagne [Sun, 10 Jul 2016 14:38:17 +0000 (16:38 +0200)]
Refactor/enhance BKE_material_make_local() and BKE_image_make_local().

Now using modern features from libquery/libremap areas.

Provides same kind of fixes/improvements as for BKE_object_make_local() (see rBd1a4ae3f395a6).

4 years agoRefactor/enhance BKE_lamp_make_local() and BKE_camera_make_local().
Bastien Montagne [Sun, 10 Jul 2016 14:15:03 +0000 (16:15 +0200)]
Refactor/enhance BKE_lamp_make_local() and BKE_camera_make_local().

Now using modern features from libquery/libremap areas.

Provides same kind of fixes/improvements as for BKE_object_make_local() (see rBd1a4ae3f395a6).

4 years agoRefactor/enhance BKE_brush_make_local() and BKE_speaker_make_local().
Bastien Montagne [Sun, 10 Jul 2016 13:49:01 +0000 (15:49 +0200)]
Refactor/enhance BKE_brush_make_local() and BKE_speaker_make_local().

Now using modern features from libquery/libremap areas.

Provides same kind of fixes/improvements as for BKE_object_make_local() (see rBd1a4ae3f395a6).

4 years agoRefactor/enhance BKE_particlesettings_make_local().
Bastien Montagne [Sun, 10 Jul 2016 13:13:01 +0000 (15:13 +0200)]
Refactor/enhance BKE_particlesettings_make_local().

Now using modern features from libquery/libremap areas.

Provides same kind of fixes/improvements as for BKE_object_make_local() (see rBd1a4ae3f395a6).

4 years agoCycles: Fix failed assert with isotropic Ashikhmin-Shirley distribution in the Glossy...
Lukas Stockner [Sun, 10 Jul 2016 14:41:21 +0000 (16:41 +0200)]
Cycles: Fix failed assert with isotropic Ashikhmin-Shirley distribution in the Glossy node

The shader sync code used the anisotropic version of the Ashikhmin-Shirley closure for both
Anisotropic and Glossy BSDF, which caused a failed assert because the anisotropic closure
expects an addiitonal SVM node.

4 years agoAdd missing braces
Campbell Barton [Sun, 10 Jul 2016 22:45:00 +0000 (08:45 +1000)]
Add missing braces

4 years agoFix T48815: Translate node's 'Relative' checkbox has the same tooltip as blur node...
Philipp Oeser [Sun, 10 Jul 2016 12:57:31 +0000 (14:57 +0200)]
Fix T48815: Translate node's 'Relative' checkbox has the same tooltip as blur node's 'Relative' checkbox.

Differential Revision: https://developer.blender.org/D2099

4 years agoCleanup/Refactor: pass Main pointer to all ID copy functions.
Bastien Montagne [Sun, 10 Jul 2016 12:52:00 +0000 (14:52 +0200)]
Cleanup/Refactor: pass Main pointer to all ID copy functions.

Also allows us to get rid of a few _copy_ex() versions...

4 years agoAdd BKE_key_copy_ex() that takes a Main as parameter.
Bastien Montagne [Sat, 9 Jul 2016 13:43:45 +0000 (15:43 +0200)]
Add BKE_key_copy_ex() that takes a Main as parameter.

4 years agoRefactor/enhance BKE_lattice_make_local(), and add BKE_lattice_copy_ex() that takes...
Bastien Montagne [Sat, 9 Jul 2016 13:38:02 +0000 (15:38 +0200)]
Refactor/enhance BKE_lattice_make_local(), and add BKE_lattice_copy_ex() that takes a Main as parameter.

Now using modern features from libquery/libremap areas.

Provides same kind of fixes/improvements as for BKE_object_make_local() (see rBd1a4ae3f395a6).

4 years agoRefactor/enhance BKE_mball_make_local(), and add BKE_mball_copy_ex() that takes a...
Bastien Montagne [Sat, 9 Jul 2016 13:18:51 +0000 (15:18 +0200)]
Refactor/enhance BKE_mball_make_local(), and add BKE_mball_copy_ex() that takes a Main as parameter.

Now using modern features from libquery/libremap areas.

Provides same kind of fixes/improvements as for BKE_object_make_local() (see rBd1a4ae3f395a6).

4 years agoRefactor/enhance BKE_curve_make_local(), and add BKE_curve_copy_ex() that takes a...
Bastien Montagne [Sat, 9 Jul 2016 13:08:24 +0000 (15:08 +0200)]
Refactor/enhance BKE_curve_make_local(), and add BKE_curve_copy_ex() that takes a Main as parameter.

Now using modern features from libquery/libremap areas.

Provides same kind of fixes/improvements as for BKE_object_make_local() (see rBd1a4ae3f395a6).

4 years agoCleanup to shapekeys' make_local (and copy) functions.
Bastien Montagne [Sat, 9 Jul 2016 12:44:48 +0000 (14:44 +0200)]
Cleanup to shapekeys' make_local (and copy) functions.

Mostly pass bmain and do not check for NULL key, keys' make_local is
suspiciously simple in fact, but think until those behave like real
full-featured IDs, it's doing enough!

4 years agoMinor fix/cleanup to object's make_local.
Bastien Montagne [Sat, 9 Jul 2016 12:43:57 +0000 (14:43 +0200)]
Minor fix/cleanup to object's make_local.

4 years agoFix: Apply Scale to Delta Scale was doubling the effect
Joshua Leung [Fri, 8 Jul 2016 23:52:41 +0000 (11:52 +1200)]
Fix: Apply Scale to Delta Scale was doubling the effect

4 years agoClear Transforms and Deltas
Joshua Leung [Fri, 8 Jul 2016 23:52:09 +0000 (11:52 +1200)]
Clear Transforms and Deltas

* Alt-G, Alt-R, Alt-S  --> These don't clear delta transforms by default anymore,
  making it possible to use these to properly store a "rest" pose

* Alt-Shift-G, Alt-Shift-R, Alt-Shift-S  --> These WILL clear both the normal
  transform and the delta, should you need to do so.

4 years agoFix (unreported) broken shapekeys after 'make_local' of datablocks used both directly...
Bastien Montagne [Fri, 8 Jul 2016 17:53:57 +0000 (19:53 +0200)]
Fix (unreported) broken shapekeys after 'make_local' of datablocks used both directly and directly.

At first thought it was own recent work, but think issue is there since ages actually...

Basically, id_make_local() would always localize mesh/curve/lattice shapekeys, even in case
obdata localization actually made a local copy instead of localizing original datablock.

This was causing shapekeys being localized twice, and other odd nasty effects.

4 years agoInitial fix for proxy issues regarding new libquery/libremap ID handling code.
Bastien Montagne [Fri, 8 Jul 2016 17:33:22 +0000 (19:33 +0200)]
Initial fix for proxy issues regarding new libquery/libremap ID handling code.

libquery now passes an extra flag info to the callback, in case that specific
ID usage is considered as indirect.

In most cases, it's just set from ID_IS_LINKED_DATABLOCK() result on datablock owner,
but in proxy object case we also consider ob->data, materials and pose usages as indirect.

Does not fixes all issues yet, but should already make behavior with proxy object saner.

4 years agoRefactor/enhance BKE_mesh_make_local().
Bastien Montagne [Fri, 8 Jul 2016 16:08:36 +0000 (18:08 +0200)]
Refactor/enhance BKE_mesh_make_local().

Now using modern features from libquery/libremap areas.

Provides same kind of fixes/improvements as for BKE_object_make_local() (see rBd1a4ae3f395a6).

Note: this enlightened broken case of proxy objects regarding make_local
(and also whole remapping, in fact). Will be fixed in near future.

4 years agoFix own very stupid mistake in BKE_library_idtype_can_use_idtype() usage (inverted...
Bastien Montagne [Fri, 8 Jul 2016 15:39:03 +0000 (17:39 +0200)]
Fix own very stupid mistake in BKE_library_idtype_can_use_idtype() usage (inverted arguments).

4 years agoLibquery: fix missing image pointers from Mesh's UV layers.
Bastien Montagne [Fri, 8 Jul 2016 15:28:28 +0000 (17:28 +0200)]
Libquery: fix missing image pointers from Mesh's UV layers.

Not really happy with this, could lead to a **lot** of callback executions...
But libquery foreach looper must go over **all** ID pointers,
otherwise remapping & co is broken!

A possible fix for future would be to have 'image slots' defined at root of poly/facetex layers,
and just a (short) index in each face/poly item - would also save a reasonable amount of memory...

4 years agoRefactor/enhance BKE_object_make_local().
Bastien Montagne [Fri, 8 Jul 2016 14:20:21 +0000 (16:20 +0200)]
Refactor/enhance BKE_object_make_local().

Now using modern features from libquery/libremap areas.

Also, it should handle much better cases where localized ID was also indirectly used by non-refcounting users
(typical case: object used as modifier/constraint/whatever target from another linked object, previous
code would not take those into account and just localize original object instead of making a local copy.
Would result in local object used by linked one, which would be partially 'undone' on next file reload... Crappy behavior).

And it fixes some obvious errors too (nullifying all proxy pointers unconditionnaly,
some missing refcounted usages cases in extern_local_object(), etc.).

4 years agoRefactor: pass Main to id_make_local.
Bastien Montagne [Fri, 8 Jul 2016 14:14:55 +0000 (16:14 +0200)]
Refactor: pass Main to id_make_local.

Totally stupid to not pass it, and then let (some) BKE_foo_make_local() use G.main!

Note: unused for now, much more refactoring still to come in make_local area!

4 years agoFix (unreported) missing special updates in case we are remapping obdata (mesh/curve...
Bastien Montagne [Fri, 8 Jul 2016 13:16:45 +0000 (15:16 +0200)]
Fix (unreported) missing special updates in case we are remapping obdata (mesh/curve/metaball at least).

4 years agoRework/split test_object_materials().
Bastien Montagne [Fri, 8 Jul 2016 12:36:25 +0000 (14:36 +0200)]
Rework/split test_object_materials().

Now test_object_materials only handles one object. New test_all_objects_materials
checks the whole bmain->object list for cases where it is actually needed.

Should avoid some useless looping over all objects!

4 years agoRefactor remapping's pre/post process of special cases.
Bastien Montagne [Fri, 8 Jul 2016 11:22:54 +0000 (13:22 +0200)]
Refactor remapping's pre/post process of special cases.

Main issue was that BKE_libblock_relink_ex was pretty much ignoring all those...
Also, unlinking of objects was not handling correctly indirect-related flags.

Refactored code into helper functions to avoid too much duplicated code.

4 years agoFix T48799: Particles set as objects cast wrong ray shadows in BI
Sergey Sharybin [Fri, 8 Jul 2016 16:10:29 +0000 (18:10 +0200)]
Fix T48799: Particles set as objects cast wrong ray shadows in BI

4 years agoBMesh: add decimate edit-mode tool
Campbell Barton [Fri, 8 Jul 2016 13:35:27 +0000 (23:35 +1000)]
BMesh: add decimate edit-mode tool

Support applying decimate to the mesh selection.

4 years agoCorrect error in non-uniform scale IK commit
Campbell Barton [Fri, 8 Jul 2016 11:06:38 +0000 (21:06 +1000)]
Correct error in non-uniform scale IK commit

Rename arg to avoid confusion

4 years agoFix T48808: Regression: Cycles OpenCL broken after Hair BVH commit
Sergey Sharybin [Fri, 8 Jul 2016 07:41:36 +0000 (09:41 +0200)]
Fix T48808: Regression: Cycles OpenCL broken after Hair BVH commit

4 years agoMesh/Curve Join: remove edit-mode toggle
Campbell Barton [Fri, 8 Jul 2016 06:41:22 +0000 (16:41 +1000)]
Mesh/Curve Join: remove edit-mode toggle

Toggling edit-node after joining objects is redundant as far as I can see -
(dates back to first revision).

Also caused all edges to be drawn w/ meshes, redundant undo step w/ curves.

4 years agoUndo: use system memcmp
Campbell Barton [Fri, 8 Jul 2016 05:42:50 +0000 (15:42 +1000)]
Undo: use system memcmp

`my_memcmp` didn't work properly comparing memory sizes not aligned to 4 bytes,
this worked while we used guarded-alloc (which always wrote a guard at the end of each allocation).
Since moving to lockfree allocator it could read uninitialized memory.

It also consistently performed ~10-30% worse then glibc's.
This is typically well optimized, no need to do ourselves.

4 years agoFix T48807: Each stroke halves brush size
Campbell Barton [Fri, 8 Jul 2016 04:51:12 +0000 (14:51 +1000)]
Fix T48807: Each stroke halves brush size

Missed from c5b2f12b

4 years agowritefile: optimize undo memory use
Campbell Barton [Fri, 8 Jul 2016 04:32:29 +0000 (14:32 +1000)]
writefile: optimize undo memory use

Slop-space on Linux wasted ~20% of memory for undo storage.

4 years agoFix/Workaround non-uniform scaled bones failing w/ IK solver
Campbell Barton [Fri, 8 Jul 2016 00:18:40 +0000 (10:18 +1000)]
Fix/Workaround non-uniform scaled bones failing w/ IK solver

Scaling a bone on the Y axis (for a stretch effect), wasn't supported by the IK solver.

Support this by solving as uniform scaled bones by matching the X,Z axis to the Y.

Requested by @pepeland, see D2088 for details.

4 years agoCleanup: use normalize_v#_length
Campbell Barton [Fri, 8 Jul 2016 00:14:49 +0000 (10:14 +1000)]
Cleanup: use normalize_v#_length

4 years agoBLI_math: add normalize functions which fit to a length
Campbell Barton [Thu, 7 Jul 2016 23:52:29 +0000 (09:52 +1000)]
BLI_math: add normalize functions which fit to a length

Convenient since its common to normalize then scale,
since these are inlined, use for regular normalize w/ 1.0 length.