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:

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.

4 years agoCleanup: spelling
Campbell Barton [Thu, 7 Jul 2016 23:46:12 +0000 (09:46 +1000)]
Cleanup: spelling

4 years agoMake use of new 'idtype can use idtype' check (in ID usages code, and ID remapping...
Bastien Montagne [Thu, 7 Jul 2016 19:18:04 +0000 (21:18 +0200)]
Make use of new 'idtype can use idtype' check (in ID usages code, and ID remapping one too).

Reduces calls to BKE_library_foreach_ID_link() from 312 to 105 when relocating a library in a
rather simple lib reload test...

4 years agolibquery: add new 'BKE_library_idtype_can_use_idtype()' helper.
Bastien Montagne [Thu, 7 Jul 2016 18:51:21 +0000 (20:51 +0200)]
libquery: add new 'BKE_library_idtype_can_use_idtype()' helper.

This should allow us to avoid a lot of useless processing when iterating over the
whole main database (unlink/remap/usages checks/etc.).

Note that some ID types report they can use any type for now, due to
fuzzyness/indefined nature of some usages (like constraints/modifiers/game logic,
or ID pointer of nodes...). Maybe we could address this (like e.g. adding defines
in relevant headers to restrict ID types used by constraints, by modifiers, etc.).
But don’t think this is top priority for now.

4 years agoCleanup/fix animsys 'id_type_can_have_animdata()'.
Bastien Montagne [Thu, 7 Jul 2016 18:48:33 +0000 (20:48 +0200)]
Cleanup/fix animsys 'id_type_can_have_animdata()'.

This func now actually takes an ID type as argument, added new 'id_can_have_animdata()'
to check whether a datablock may be animated or not.

4 years agoExtend libquery checks to test wether an ID is used locally and/or indirectly.
Bastien Montagne [Thu, 7 Jul 2016 17:39:14 +0000 (19:39 +0200)]
Extend libquery checks to test wether an ID is used locally and/or indirectly.

4 years agoFix T48793: Bilinear filter clamps at edge pixels
Campbell Barton [Thu, 7 Jul 2016 16:14:54 +0000 (02:14 +1000)]
Fix T48793: Bilinear filter clamps at edge pixels

4 years agoFix single threaded compositor define
Campbell Barton [Thu, 7 Jul 2016 15:38:22 +0000 (01:38 +1000)]
Fix single threaded compositor define

4 years agoCycles: Enable unaligned BVH builder for scenes with hair
Sergey Sharybin [Thu, 7 Jul 2016 10:41:45 +0000 (12:41 +0200)]
Cycles: Enable unaligned BVH builder for scenes with hair

This commit enables new unaligned BVH builder and traversal for scenes
with hair. This happens automatically, no need of manual control over

There are some possible optimization still to happen here and there,
but overall there's already nice speedup:

                      Master                 Hair BVH
  bunny.blend         8:06.54                 5:57.14
  victor.blend       16:07.44                15:37.35

Unfortunately, such more complexity is not really coming for free,
so there's some downsides, but those are within acceptable range:

                      Master                Hair BVH
  classroom.blend     5:31.79                5:35.11
  barcelona.blend     4:38.58                4:44.51

Memory usage is also somewhat bigger for hairy scenes, but speed
benefit pays well for that. Additionally as was mentioned in one
of previous commits we can add an option to disable hair BVH and
have similar render time but have memory saving.

Reviewers: brecht, dingto, lukasstockner97, juicyfruit, maiself

Differential Revision:

4 years agoCycles: Implement unaligned nodes BVH traversal
Sergey Sharybin [Thu, 7 Jul 2016 10:23:13 +0000 (12:23 +0200)]
Cycles: Implement unaligned nodes BVH traversal

This commit implements traversal of unaligned BVH nodes.

QBVH traversal is fully SIMD optimized and calculates orientation
for all 4 children at a time, regular BVH might probably be optimized
a bit more.

4 years agoCycles: Implement unaligned nodes BVH builder
Sergey Sharybin [Thu, 7 Jul 2016 10:18:57 +0000 (12:18 +0200)]
Cycles: Implement unaligned nodes BVH builder

This is a special builder type which is allowed to orient nodes to
strands direction, hence minimizing their surface area in comparison
with axis-aligned nodes. Such nodes are much more efficient for hair

Implementation of BVH builder is based on Embree, and generally idea
there is to calculate axis-aligned SAH and oriented SAH and if SAH
of oriented node is smaller than axis-aligned SAH we create unaligned

We store both aligned and unaligned nodes in the same tree (which
seems to be different from what Embree is doing) so we don't have
any any extra calculations needed to set up hair ray for BVH
traversal, hence avoiding any possible negative effect of this new
BVH nodes type.

This new builder is currently not in use, still need to make BVH
traversal code aware of unaligned nodes.

4 years agoCycles: Switch node address to absolute values in BVH tree
Sergey Sharybin [Tue, 14 Jun 2016 12:29:09 +0000 (14:29 +0200)]
Cycles: Switch node address to absolute values in BVH tree

This seems to be straightforward way to support heterogeneous nodes
in the same tree.

There is some penalty related on 4gig limit of the address space now,
but here's are the thing:

Traversal code was already using ints to store final offset, so
there can't be regressions really.

This is a required commit to make it possible to encode both aligned
and unaligned nodes in the same array. Also, in the future we can use
this to get rid of __leaf_nodes array (which is a bit tricky to do since
trickery in pack_instances().

4 years agoCycles: Reduce memory usage by de-duplicating triangle storage
Sergey Sharybin [Fri, 10 Jun 2016 14:13:50 +0000 (16:13 +0200)]
Cycles: Reduce memory usage by de-duplicating triangle storage

There are several internal changes for this:

First idea is to make __tri_verts to behave similar to __tri_storage,
meaning, __tri_verts array now contains all vertices of all triangles
instead of just mesh vertices. This saves some lookup when reading
triangle coordinates in functions like triangle_normal().

In order to make it efficient needed to store global triangle offset
somewhere. So no __tri_vindex.w contains a global triangle index which
can be used to read triangle vertices.

Additionally, the order of vertices in that array is aligned with
primitives from BVH. This is needed to keep cache as much coherent as
possible for BVH traversal. This causes some extra tricks needed to
fill the array in and deal with True Displacement but those trickery
is fully required to prevent noticeable slowdown.

Next idea was to use this __tri_verts instead of __tri_storage in
intersection code. Unfortunately, this is quite tricky to do without
noticeable speed loss. Mainly this loss is caused by extra lookup
happening to access vertex coordinate.

Fortunately, tricks here and there (i,e, some types changes to avoid
casts which are not really coming for free) reduces those losses to
an acceptable level. So now they are within couple of percent only,

On a positive site we've achieved:

- Few percent of memory save with triangle-only scenes. Actual save
  in this case is close to size of all vertices.

  On a more fine-subdivided scenes this benefit might become more

- Huge memory save of hairy scenes. For example, on koro.blend
  there is about 20% memory save. Similar figure for bunny.blend.

This memory save was the main goal of this commit to move forward
with Hair BVH which required more memory per BVH node. So while
this sounds exciting, this memory optimization will become invisible
by upcoming Hair BVH work.

But again on a positive side, we can add an option to NOT use Hair
BVH and then we'll have same-ish render times as we've got currently
but will have this 20% memory benefit on hairy scenes.

4 years agoCycles: Support visibility check for inner nodes of QBVH
Sergey Sharybin [Fri, 10 Jun 2016 08:14:05 +0000 (10:14 +0200)]
Cycles: Support visibility check for inner nodes of QBVH

It was initially unsupported because initial idea of checking visibility
of all children was slowing scenes down a lot. Now the idea has changed
and we only perform visibility check of current node. This avoids huge
slowdown (from tests here it seems to be withing 1-2%, but more tests
would never hurt) and gives nice speedup of ray traversal for complex
scenes which utilized ray visibility.

Here's timing of koro.blend:

                  Without visibility check         With visibility check
Original file           4min 20sec                      4min 23sec
Camera rays only        1min 43 sec                       55sec

Unfortunately, this doesn't come for free and requires extra data in
BVH node, which increases memory usage of BVH nodes by 15%. This we
can solve with some future trickery of avoiding __tri_storage created
for curve segments.

4 years agoQuiet gcc warning-as-error about non-const pointer passed to const parameter.
Bastien Montagne [Thu, 7 Jul 2016 15:23:12 +0000 (17:23 +0200)]
Quiet gcc warning-as-error about non-const pointer passed to const parameter.

4 years agoFix T48802 Unwrap buttons, can't add hotkey in 3DView's UV Unwrap menu.
Bastien Montagne [Thu, 7 Jul 2016 15:03:30 +0000 (17:03 +0200)]
Fix T48802 Unwrap buttons, can't add hotkey in 3DView's UV Unwrap menu.

Those unwrap operators are a bit tricky, some are available from both 3DView and UVEditor, others only from 3DView...

Hacked around this by returning Mesh keymap for UV_OT ops for specific 3DView/MeshEditMode context.

4 years agoRNA: rename sorting -> sort
Campbell Barton [Thu, 7 Jul 2016 14:56:01 +0000 (00:56 +1000)]
RNA: rename sorting -> sort

Shorter and consistent with other RNA.

4 years agoSkip the ID part of object names when comparing
Campbell Barton [Thu, 7 Jul 2016 14:49:44 +0000 (00:49 +1000)]
Skip the ID part of object names when comparing

Also no need to calloc arrays which are immediately filled

4 years agoCleanup: spelling, style
Campbell Barton [Thu, 7 Jul 2016 14:48:03 +0000 (00:48 +1000)]
Cleanup: spelling, style

4 years agoCleanup: use static sets, remove redundant copy
Campbell Barton [Thu, 7 Jul 2016 14:28:41 +0000 (00:28 +1000)]
Cleanup: use static sets, remove redundant copy

4 years agoRevert "ChildOf Constraint: Hide the Loc/Rot/Scale toggles"
Joshua Leung [Thu, 7 Jul 2016 13:59:43 +0000 (01:59 +1200)]
Revert "ChildOf Constraint: Hide the Loc/Rot/Scale toggles"

This reverts commit 4fd78bb06faa31f265af6a5f247cf4255b5ac479.

After further testing, it turns out that these options are less-broken than
I remember them being (and have been hearing about). Specifically, as long
as you disable all 3-axes of a transform component (i.e. all location, all
rotation, all scale) you're not likely to have problems, whereas if you only
disabled one axis (i.e. y-rotation), you may have problems in some cases.

So, restoring these to the UI.

4 years agoCode Cleanup - Split out the FCurve auto-color code into a separate function
Joshua Leung [Thu, 7 Jul 2016 13:37:41 +0000 (01:37 +1200)]
Code Cleanup - Split out the FCurve auto-color code into a separate function

4 years agoFix T48747: Stuck in edit mode after selecting another object in the animation editors
Joshua Leung [Thu, 7 Jul 2016 13:24:47 +0000 (01:24 +1200)]
Fix T48747: Stuck in edit mode after selecting another object in the animation editors

4 years agoFix: Keyframe click-selection threshold in Dopesheet was still hardcoded to 7px
Joshua Leung [Thu, 7 Jul 2016 12:32:05 +0000 (00:32 +1200)]
Fix: Keyframe click-selection threshold in Dopesheet was still hardcoded to 7px

4 years agoDopesheet: Added "Moving Hold" as a keyframe type
Joshua Leung [Thu, 7 Jul 2016 11:37:15 +0000 (23:37 +1200)]
Dopesheet: Added "Moving Hold" as a keyframe type

Currently "long keyframes" are only useful for indicating where stationary
holds occur. If however you try to create a "moving hold" (where the values
are slightly different, but in terms of overall effect, it's still a hold)
then it could get tricky to keep track of where these occur.

Now it's possible to tag such keyframes (using the keyframe types - RKEY)
as being part of a moving hold. These will not only be drawn differently
from normal keyframes, but they will also result in a "long keyframe"
being drawn between each pair of them, just like if they had been completely
stationary instead.

Currently the theming/styling of these is a bit rough. They reuse the existing
theme colours for long keyframes.

4 years agoTransforms to Delta Transforms
Joshua Leung [Mon, 4 Jul 2016 00:52:51 +0000 (12:52 +1200)]
Transforms to Delta Transforms

* Added new operators to take the current transform value (loc/rot/scale or all 3)
  and convert/apply that transform to a corresponding delta transform value. By default,
  the transform value will be zeroed out again afterwards, so you don't end up with a
  double transform.

* These operators can be found in the "Apply" menu (Ctrl-A)

* The "Animated Transforms to Deltas" (which does a similar job, except it adjusts all
  existing animation data instead of the current transform) has also been moved to the
  Apply menu (it was in the Transform menu instead)

4 years agoAnimation Editors: Object datablocks are now sorted alphabetically by default
Joshua Leung [Sun, 3 Jul 2016 14:50:10 +0000 (02:50 +1200)]
Animation Editors: Object datablocks are now sorted alphabetically by default

A long requested feature has been to have objects appear in alphabetical order
in the animation editors, so that it is easier to find where they occur. This
commit implements support for this.

The main sticking point has been the performance impact of having this sorting
happening all the time (as the actual list of "bases" cannot be modified, as the
old depsgraph still needs random-looking unsorted order of objects for scheduling
updates). However, it recently occurred to me that perhaps by restricting it to
the one case where the ordering actually matters (i.e. when we're getting the channel
list for drawing all channels, vs operating on them), and adding a toggle to turn the
sorting off in heavy scenes when it might bog down things, that it will probably
be acceptable enough in general.  Furthermore, if things get really bad, we can investigate
putting in place some sort of caching scheme for this too - though hopefully the
new depsgraph will make that unnecessary (i.e. it doesn't sort the bases directly anymore).

4 years agoCode Cleanup: Move out logic for checking if an object can be included in the dopesheet
Joshua Leung [Sun, 3 Jul 2016 07:25:09 +0000 (19:25 +1200)]
Code Cleanup: Move out logic for checking if an object can be included in the dopesheet

4 years agoDopesheet: Keyframe size can be adjusted as part of theme settings
Joshua Leung [Sat, 2 Jul 2016 15:42:28 +0000 (03:42 +1200)]
Dopesheet: Keyframe size can be adjusted as part of theme settings

This commit introduces a scale factor setting for scaling all keyframe indicators
in the Dopesheet Editor up/down, in order to make them easier to select. It is perhaps
most useful for keyframe types which are usually indicated using smaller keyframes
(e.g. breakdown), which may get tricky to quickly select.

4 years agoNLA: Indicate position of action-local markers on strips
Joshua Leung [Tue, 28 Jun 2016 15:16:07 +0000 (03:16 +1200)]
NLA: Indicate position of action-local markers on strips

To make it easier to synchronise timing across multiple strips, if you add
markers locally to an action, these will show up in the NLA strip in the
NLA Editor. These markings can then be used to line up the start/end of
another strip, or even to make sure that the markers from two different
strips end up lining up.

By default, this is turned on, but it can be disabled (via the View menu)
if it adds too much visual noise.

4 years agoFix (unreported) crash when remapping armatures.
Bastien Montagne [Thu, 7 Jul 2016 12:52:39 +0000 (14:52 +0200)]
Fix (unreported) crash when remapping armatures.

Objects' Pose holds references to the armature bones, so we have to force POSE_RECALC in those cases...

4 years agoOutliner: Match search length w/ id name length
Campbell Barton [Thu, 7 Jul 2016 06:36:25 +0000 (16:36 +1000)]
Outliner: Match search length w/ id name length

4 years agowritefile: call undo flush after writing the windowmanager
Campbell Barton [Thu, 7 Jul 2016 06:27:33 +0000 (16:27 +1000)]
writefile: call undo flush after writing the windowmanager

Data here is constantly changing, avoids outliner data being included in those changes for undo.

4 years agoCleanup: move write flush into its own function
Campbell Barton [Thu, 7 Jul 2016 06:02:45 +0000 (16:02 +1000)]
Cleanup: move write flush into its own function

No point passing dummy args to existing function, split out logic instead.

Also add flush after writing mesh data too.

4 years agoFix memory leak switching sculpt mode + dyntopo
Campbell Barton [Thu, 7 Jul 2016 05:48:25 +0000 (15:48 +1000)]
Fix memory leak switching sculpt mode + dyntopo

Auto-enabling dyntopo w/ mode switching leaked memory when undo was used.

4 years agoTransform Snap: fix vert & edit object in ortho view
Germano Cavalcante [Thu, 7 Jul 2016 05:16:27 +0000 (15:16 +1000)]
Transform Snap: fix vert & edit object in ortho view

The callback used in `BLI_bvhtree_find_nearest_to_ray` was wrong and could result in crash.

Also de-duplicate vert/edge logic.

4 years agoFix failing script_load_addons test after recent code cleanup.
Brecht Van Lommel [Wed, 6 Jul 2016 19:43:55 +0000 (21:43 +0200)]
Fix failing script_load_addons test after recent code cleanup.

4 years agoCycles tests: Don't create fail file on idiff warning
Sergey Sharybin [Wed, 6 Jul 2016 15:39:09 +0000 (17:39 +0200)]
Cycles tests: Don't create fail file on idiff warning

4 years agoRevert rB961ebfa8c40b9909 - do not set Main's versions directly in do_versions().
Bastien Montagne [Wed, 6 Jul 2016 15:12:35 +0000 (17:12 +0200)]
Revert rB961ebfa8c40b9909 - do not set Main's versions directly in do_versions().

This breaks any post-versionning (like IPO conversion, python handler, etc.).

rB961ebfa8c40b9909 mentions some Main being do_versionned several times (which is not desired for sure),
will try to reproduce again and find another fix.

4 years agoFix Python API error message (do_unlink, instead of unlink)
Dalai Felinto [Wed, 6 Jul 2016 14:32:46 +0000 (11:32 -0300)]
Fix Python API error message (do_unlink, instead of unlink)

4 years agowritefile: add flushes
Campbell Barton [Wed, 6 Jul 2016 13:27:22 +0000 (23:27 +1000)]
writefile: add flushes

Flush on grease pencil and data with image preview or packed data.

4 years agowritefile: avoid adding SDNA to every undo step
Campbell Barton [Wed, 6 Jul 2016 12:23:50 +0000 (22:23 +1000)]
writefile: avoid adding SDNA to every undo step

Since SDNA was allocated for each undo step,
the new address meant it was considered different and included again.

Add an option not to duplicate the DNA string when calling DNA_sdna_from_data,
as well as avoiding a redundant copy, it writes the same address each time.

4 years agoFix memleak with recent Outliner writefile changes.
Bastien Montagne [Wed, 6 Jul 2016 12:45:06 +0000 (14:45 +0200)]
Fix memleak with recent Outliner writefile changes.

4 years agoCleanup/simplify/fixes BKE_object_is_libdata and BKE_object_obdata_is_libdata.
Bastien Montagne [Wed, 6 Jul 2016 12:37:03 +0000 (14:37 +0200)]
Cleanup/simplify/fixes BKE_object_is_libdata and BKE_object_obdata_is_libdata.

Removed checks for ob->proxy from the equation, you can totally have proxy objects
linked into another .blend file!