Commit Graph

46976 Commits

Author SHA1 Message Date
Campbell Barton
d1e1fb2239 UV Unwrap: Correct aspect was inverted 2015-01-27 01:05:51 +11:00
Lukas Tönne
4013ae6382 Fix T43409: Particle instancing on hair sometimes doesn't have a path
cache available.
2015-01-26 14:58:15 +01:00
Sybren A. Stüvel
895fa8bc79 Timeline: Draw keyframe lines at 60% height
This patch updates the timeline editor. Ordinarily, it draws the
yellow keyframe lines at 100% of the available height. This becomes an
issue when there are keyframes for every frame, which can happen when
importing motion capture data or recording animations from the BGE. In
such cases, the green "current frame" indicator becomes very hard to
see.

This patch restricts the drawing to the bottom 60% of the available
space, thereby making the "current frame" indicator more visible.

Reviewers: aligorith

Reviewed By: aligorith

Subscribers: Severin

Projects: #bf_blender

Differential Revision: https://developer.blender.org/D1033
2015-01-26 14:49:12 +01:00
Lukas Tönne
6f2034cead Fix T43394: hair remapping needs to handle "global" hair correctly.
The function was checking the psys flag for this, but since for
disconnect/connect the same psys is used as source and target, the flag
must be passed explicitly.
2015-01-26 14:38:58 +01:00
Joshua Leung
e0ee74a171 Fix T38619: Confusing logic for Keying Set keyframing Settings
The logic used for determining whether certain keyframing settings (i.e. visual,
only needed, xyz -> rgb) got applied was wonky. The original intention here was
that the Keying Set settings would override the global settings, and the path
settings would override what was used for the Keying Set. However, that was not
happening in all cases previously, as it was only possible to add flags and not
to turn them off.

This commit fixes that by introducing separate toggles to control whether the
Keying Set/Path's settings override the settings inherited from its parent
(i.e. the Keying Set for the Path, and the User Prefs for the Keying Set).
The icons used for these toggles could get revised a bit (we need something
which communicates "override this"; the current one is the closest I could find)

WARNING: If you have old keying sets, this may cause some breakage!
2015-01-27 02:10:26 +13:00
Campbell Barton
027361c898 Fix T41834: Ctrl+LMB, Extrude Curves 2+ splines
Extrude and Ctrl+LMB now support multiple selected vertices.
Also maintain active vertices.

D964 by Tyler Sliwkanich with own modifications
2015-01-26 21:08:43 +11:00
Campbell Barton
5d61cbf008 Curves: BKE_nurb_copy left duplicate arrays
While callers accounted for this, its quite error prone. Just NULL instead.
2015-01-26 18:22:54 +11:00
Joshua Leung
8db4a24e4e Bugfix T43343: Buttons for Keyframing Settings are Mutually Exclusive
Since 1c3f2354f83b3e79dee31d837ca4d7c08d2c3f26 the keyframing settings on
Keying Sets have been incorrectly displayed as a clump of toggle buttons,
which are usually only used when only one of the options apply.

Reverting this back to how it was, while leaving bl_options in place still for
the one case where it makes sense to do it that way (i.e. for KeyingSetInfo)
2015-01-26 19:19:33 +13:00
julianeisel
146a0e9447 UI: macro for checking modifiers
Useful for UI handling where its common to check multiple modifiers at once.
2015-01-26 13:34:30 +11:00
julianeisel
b636599fde Correction to c792e546991bd9: OS-Key should be checked as well 2015-01-26 02:51:09 +01:00
julianeisel
b554bcf124 Cleanup: Remove ugly ELEM checks in modifier key handling
Campbell once told me such checks can cause warnings on some compilers, so
let's try to avoid them.

From the theoretical view, this check works quite different than the old
one, but in this case everything should work just like previousely.
2015-01-26 02:38:39 +01:00
julianeisel
c792e54699 If a modifier key is held, don't open context menu
D1019 by @gregzaal (minor edits by me).

Thanks for the patch!
2015-01-26 01:57:58 +01:00
Campbell Barton
ce6ba965dc cleanup: warnings, spelling 2015-01-25 21:15:27 +11:00
Romanov Alexander
f4a418b031 Crash when deleting NlaTrack
Steps to reproduce:
1) Create an object, animated with shape keys
2) Copy it with Alt-D
3) Push action down to nla track
4) Select that track and delete it

In attached file 1-3 steps are completed.
{F138559}

Alexander (Blend4Web Team)

Reviewers: aligorith

Subscribers: yurikovelenov, Evgeny_Rodygin, valentin_b4w, AlexKowel

Differential Revision: https://developer.blender.org/D1015
2015-01-25 18:55:05 +13:00
julianeisel
2855485565 Fix T43399: VSE - don't show fps info when stopping animation with ALT+A
Caused by a missing notifier on the animation_play operator.
2015-01-25 02:43:57 +01:00
julianeisel
492b9ab5e3 Fix T43335: Node Editor: name doesn't update
Update Node Editor info (drawn on the bottom left) on redraw if needed
2015-01-25 01:59:49 +01:00
julianeisel
c2af749ac3 Cleanup: Ugly typo (retore->restore) 2015-01-24 23:39:06 +01:00
julianeisel
f7e844570f Fix T43008: Support stacked fullscreen areas 2015-01-24 23:01:39 +01:00
Bastien Montagne
31219415d6 Fix BGE compilation after recent renames in BKE_image (tsst...). 2015-01-24 14:57:57 +01:00
Campbell Barton
d036ad552f BKE_image: use BKE_image_*** prefix
use bools for return values and some api naming consistency.
2015-01-24 17:26:59 +11:00
Campbell Barton
fcda27cdae Cleanup: style 2015-01-24 17:09:24 +11:00
Campbell Barton
6d78936c43 cleanup: style 2015-01-24 01:59:09 +11:00
Sergey Sharybin
e40387b1e2 Keep proper bone active group after removing first one
Previously active bone group would be set to NONE after removing the first
one even if there are more groups in the armature.
2015-01-23 17:00:18 +05:00
Campbell Barton
2242022653 PyAPI: Replace importlib.reload, not 'imp' 2015-01-23 16:37:30 +11:00
Campbell Barton
6a6e4a9d47 Set bAction.chanbase to deprecated 2015-01-23 10:52:20 +11:00
Joshua Leung
a730cda72f Fix: Joining armatures fixes up the drivers accordingly
Finally! At long last, I've gotten this working! This ended up being far trickier
to get right than anticipated; the normal remapping API's cannot be used as-is
as they will just clobber over subtleties whenever datablock changes are involved.
So, for now, we have to duplicate the logic a bit.
2015-01-23 02:33:32 +13:00
Joshua Leung
99a5f376a2 WIP: Attempt to get driver links remapped correctly when joining armatures
Now, RNA Paths and driver targets get corrected, but at the expense of this
always happening (i.e. even for those affecting drivers which existed before).
2015-01-23 02:33:31 +13:00
Joshua Leung
6248381783 Fix: Joining armatures wasn't updating Action Constraints properly
The code here was still trying to access ancient 2.4x "action channels" to rename
them. Now, this renames the relevant FCurves instead.
2015-01-23 02:33:31 +13:00
Sergey Sharybin
4d4456015c Quit blender with non-zero exit code if tryign to use non-existing render engine via the command line 2015-01-22 15:23:09 +05:00
Sergey Sharybin
a1ffb49e49 Fix T43120: Cycles mapping node rotation order is different from viewport
Root of the issue goes to the fact that since the very beginning Cycles was
using ZYX euler rotation for mapping shader node but blender was always
using XYZ euler rotation.

This commit switches Cycles to use XYZ euler order and adds versioning code
to preserve backward compatibility.

There was no really nice solution here because either we're ending up with
versioning code or we'll need to deal with all sort of exceptions from blender
side in order to support ZYX order for the mapping node. The latest one is
also creepy from the other render engines points of view -- that might break
compatibility with existing bindings or introduce some extra headache for them
in the future.

This could also become a PITA for us with need of supporting all sort of weird
and wonderful exceptions in the refactored viewport project.

NOTE: This commit breaks forward compatibility, meaning opening new files in
older blender might not give proper result if Mapping node was used.

Also, libraries are to be re-saved separately from the scene file, otherwise
versioning code for them wouldn't run if scene file was re-saved with new
version of blender.

Reviewers: brecht, juicyfruit, campbellbarton

Reviewed By: campbellbarton

Differential Revision: https://developer.blender.org/D973
2015-01-22 14:12:22 +05:00
Sergey Sharybin
82702db407 Expose shading node shading compatibility to the RNA
This way it is possible to probe shading compatibility of a given node from
python, making things like versioning code much easier to perform.

it's only valid for shading nodes, for other nodes the property also exists
but reads as an empty enum.

To access this compatibilities:

  node.shading_compatibility
2015-01-22 13:52:17 +05:00
Dalai Felinto
8ed439b89e bge.render.getStereoEye() and bge.types.LEFT_EYE/RIGHT_EYE
This function allows the user to run specific code for each of the
rendered stereoscopic eyes in the Game Engine.

The initial use case is to set the camera projection matrix in
a scene.pre_draw callback function for each eye, to be used in VR
(Virtual Reality) installations.

Reviewed by Mitchell Stokes and Campbell Barton, thank you guys.

Sample Test Python Script:
"""
import bge
import bgl
import blf

def init():
    """init function - runs once"""
    scene = bge.logic.getCurrentScene()
    scene.post_draw.append(write)

def write():
    """write on screen - depending on the eye"""
    width = bge.render.getWindowWidth()
    height = bge.render.getWindowHeight()

    # OpenGL setup
    bgl.glMatrixMode(bgl.GL_PROJECTION)
    bgl.glLoadIdentity()
    bgl.gluOrtho2D(0, width, 0, height)
    bgl.glMatrixMode(bgl.GL_MODELVIEW)
    bgl.glLoadIdentity()

    eye = bge.render.getStereoEye()

    if eye == bge.render.LEFT_EYE:
        blf.position(0, (width * 0.2), (height * 0.3), 0)
        blf.size(0, 40, 72)
        blf.draw(0, "Left")

    else: # bge.render.RIGHT_EYE:
        blf.position(0, (width * 0.7), (height * 0.3), 0)
        blf.size(0, 40, 72)
        blf.draw(0, "Right")
"""
2015-01-22 03:00:24 -02:00
Campbell Barton
1b1a6e0c92 error in last commit (missed in review) 2015-01-22 10:56:52 +11:00
Campbell Barton
64e869ed35 Outliner: use enum for outliner_data_operation()
No functional change, D997 by @lichtwerk
2015-01-22 10:49:10 +11:00
Sergey Sharybin
dda355442d Cycles: Support tube projection for images
This way Cycles finally becomes feature-full on image projections
compared to Blender Internal and Gooseberry Project Team could
finally finish the movie.
2015-01-22 00:41:42 +05:00
Sergey Sharybin
12ccac657f Cycles: Support sphere mapping for the image texture 2015-01-22 00:41:42 +05:00
Sybren A. Stüvel
7165db53f2 Cleanup of BGE code CcdPhysicsEnvironment::CallbackTriggers()
Refactored some code to be easier to read. Semantically the code is
identical.

  - Some conditions were negated to be able to return/continue early,
    rather than having the majority of the code inside an if-body.
  - Conditions were simplified (!(a == b)) turned into (a != b);
    repeated conditions calculated only once.
  - Unnecessary variables and one unnecessary condition were
    eliminated.

Reviewers: campbellbarton, lordloki

Reviewed By: lordloki

Projects: #game_physics

Differential Revision: https://developer.blender.org/D954
2015-01-21 18:43:05 +01:00
Campbell Barton
684942c2fe CMake/MSVC: Quotes around the path
D940 by @TeeTrizZz
2015-01-22 01:53:12 +11:00
Joshua Leung
3df93d063e Fix: Joining armatures loses drivers
Currently, when joining two armatures, the drivers of the armatures being merged
in are lost. This commit introduces a new AnimData API function for merging
animation data into another AnimData block.

NOTE:
* For now, this only copies the drivers over. As a result, manual effort will
  still be needed to go through and fix the drivers.

  I am working on automating that process, but it's more important that the
  drivers don't have to be created from scratch for now (since this is needed
  for the Goosberry rigging work).
2015-01-22 02:09:16 +13:00
Lukas Tönne
f087e9930d Added new debug flag which can be used to lazy-init the SimDebug drawing.
A development addon can be used now to enable the debug drawing, without
the need to add UI code for this in the release files.

The SimDebug feature should also get an overall build flag and use
function stubs unless enabled. That way any possibility of overhead in
releases is eliminated.
2015-01-21 14:00:59 +01:00
Campbell Barton
a86482f81c Fix T43158: pixels in the 3d-view was mis-aligned
Change the pixel offset for regions, it make oversampling blurry when drawing pixel aligned values.
See T41749
2015-01-21 23:15:39 +11:00
Lukas Tönne
47bf0934f5 Removed generic debug1..4 values from the cloth data.
These were used as UI buttons during development. If such parameters are
needed again later they should instead be added in the (now global)
SimDebugData and made accessible with a dev addon or so.
2015-01-21 10:07:11 +01:00
Campbell Barton
4422ecbb96 UI: support alt+wheel for expanded enums 2015-01-21 16:27:58 +11:00
julianeisel
17422124ec Fix T43247: Don't open pulldown when a popup overlaps it
Auto-opening of pulldown menus didn't take overlapping popups into account.
2015-01-21 03:51:18 +01:00
Campbell Barton
12bf84cbe4 BKE_screen: add BKE_screen_find_area_xy
Use from eyedropper & screen operators
also define SPACE_TYPE_ANY for readability.
2015-01-21 13:43:46 +11:00
Campbell Barton
6b655ca62c Cleanup: style 2015-01-21 11:57:11 +11:00
Bastien Montagne
f67c6445e1 Cleanup SVG icon file, pass II.
Name each icon group from its define in Blender.

Simplifies searching for a given icon (in one way or the other), and could also be
useful one day in some scripting.

Also, removed/fixed more empty and stray groups...

Finally, found that we have several svg icons not linked to any defines, and one define
with no icon (dyntopo), would be nice to sort this one way or the other too.
2015-01-20 21:53:06 +01:00
Lukas Tönne
9d9dc06014 Made SimDebugData into a single global instance.
This way it doesn't have to be stored as DNA runtime pointers or passed
down as a function argument. Currently there is now no property or
button to enable debugging, this will be added again later.
2015-01-20 18:32:06 +01:00
julianeisel
3356f3f0bb Outliner: "Show Active" - if active is a child, open tree to show child
Previously, if the active object was a child, "Show Active" only showed the
parent object. Now it also opens the tree to take children into account.

Patch D974 by @lichtwerk with some minor edits, reviewed by me.
2015-01-20 17:32:54 +01:00
Lukas Tönne
408adfae8a Fix for BI rendering of hair spirals: Was not taking the extra points
into account.
2015-01-20 16:38:47 +01:00
Nicholas Bishop
8604ec9053 De-duplicate large block of shared code for GL vert attribs
Code in ccgdm_draw_attrib_vertex() was entirely the same as the top
portion of the code in cddm_draw_attrib_vertex(). Moved this code to a
new function, DM_draw_attrib_vertex().

ccgdm_draw_attrib_vertex() was removed in favor of calling
DM_draw_attrib_vertex(). cddm_draw_attrib_vertex() still does a couple
extra things, so it still exists but calls DM_draw_attrib_vertex().

In the interest of easy code review, no changes made to the code in
DM_draw_attrib_vertex() other than the new name and an added comment.

Reviewers: campbellbarton

Reviewed By: campbellbarton

Differential Revision: https://developer.blender.org/D1010
2015-01-20 14:17:08 +01:00
Campbell Barton
58e5509da0 Fix UI glitch: Ctrl/Shift didnt refresh the UI 2015-01-20 23:16:03 +11:00
Campbell Barton
dfaf26412d Fix transform glitch: Ctrl/Shift didn't refresh 2015-01-20 23:16:02 +11:00
Campbell Barton
664ef69c9f Cleanup: use const 2015-01-20 23:16:02 +11:00
Lukas Tönne
4a132abd9d Fix for crash when using virtual parent hairs and clumping.
The paths for parents and children are generated using the same function
with a rather obscure test to distinguish them. Modifiers (clump, kink,
roughness) should not be applied to parents though.
2015-01-20 11:42:33 +01:00
Campbell Barton
6e44e4181f Cleanup: warnings 2015-01-20 21:07:35 +11:00
Sergey Sharybin
06160adbf8 Code cleanup: Unused variable in RNA callback 2015-01-20 15:05:39 +05:00
Sergey Sharybin
02fad7dca4 Fix T42844: Compositor scale offset
Different interpolation methods in compositor could lead to 0.5 pixel offset in
final renders. This is because of some inconsistency in integer coordinates
which might mean pixel corner or pixel center.

Should be all fine now.
2015-01-20 15:02:35 +05:00
Campbell Barton
967f93d1c1 Fix error in freestyle api 2015-01-20 20:00:31 +11:00
Lukas Tönne
b22a38786d Fixed merge errors. 2015-01-20 09:38:39 +01:00
Lukas Tönne
c8912073e6 Fix for incorrect DNA field name in versioning, causes constant
resetting of clump noise size on reload.

Conflicts:
	source/blender/blenloader/intern/versioning_270.c
2015-01-20 09:30:33 +01:00
Lukas Tönne
8ac20d1dee Use separate flags to enable/disable clump and roughness curves for
child hairs.

This allows disabling the curves temporarily without losing the setup.

Conflicts:
	source/blender/blenkernel/BKE_blender.h
2015-01-20 09:30:32 +01:00
Lukas Tönne
1a918cb66e Fix for slow deformation-motionblur in Cycles using the new spiral kink
mode.

This was caused by variation of the number of keys on child hairs due
to shortening of hair curves based on euclidian distances. The other
kink modes also shorten hairs, but use the parametric distance instead,
which does not vary with deformation of hairs.
2015-01-20 09:30:12 +01:00
Lukas Tönne
755734c12f Second variant of the copy-to-select operator for particles to only
copy the active particle system (and not remove existing in the process).
2015-01-20 09:30:11 +01:00
Lukas Tönne
6d65107656 Make removal of existing particle systems on copying optional.
This will be most useful when copying individual particle systems
one-by-one (to be implemented).
2015-01-20 09:30:11 +01:00
Lukas Tönne
04226e324e Added space selection option to the particle system copy operator.
By default this now copies from one object's local space to another
object's local space (instead of the previous world space). This is
more useful when transferring particles between objects, because it
doesn't require moving objects on top of each other, as long as they
have similar shapes.
2015-01-20 09:30:11 +01:00
Lukas Tönne
53135f91d2 Removed debugging code. 2015-01-20 09:30:11 +01:00
Lukas Tönne
0666de06f3 Fix for particle system copy: This has to make sure the ORIGSPACE data
layer is available.

Otherwise particle mapping to the new mesh cannot work with subdivided
and constructively-modified meshes.
2015-01-20 09:30:11 +01:00
Lukas Tönne
2a3279bb87 Changed the workflow for the particle system copy operator to the common
active-to-selected pattern.
2015-01-20 09:30:11 +01:00
Lukas Tönne
91b70d3c56 New operator for copying (hair) particle systems from one object to
another, including edit data (grooming).

This uses basically the same method as the existing connect/disconnect
feature. The main difference is that it allows working with multiple
objects and transferring the //particle/hair data// instead of the
//mesh// data (which is what connect/disconnect expects). This is a much
more realistic workflow when rigging, topology etc. changes and
groomed hair has to be transferred to the changed model.
2015-01-20 09:30:11 +01:00
Lukas Tönne
8f9f55498e Removed unused particles pointer from particle edit data. 2015-01-20 09:30:11 +01:00
Lukas Tönne
2fe96f3f88 New texture influence option for particle kink amplitude (as opposed to
frequency).
2015-01-20 09:30:11 +01:00
Lukas Tönne
9698182227 Renaming "Kink" texture influence to "Kink Frequency" to be more
specific.
2015-01-20 09:30:11 +01:00
Lukas Tönne
68608c5428 Spiral rotation axis was not always fully normalized, avoid an assert. 2015-01-20 09:30:11 +01:00
Lukas Tönne
dcfa75bc89 Make random child length work again with the spiral kink mode. 2015-01-20 09:30:11 +01:00
Sergey Sharybin
c2a7f26cbc Add missing stub to the player, so buildbot keeps delivering gooseberry builds 2015-01-20 09:30:10 +01:00
Lukas Tönne
6c908790e7 Allow clumping and roughness in Spiral kink mode as well.
This requires interpolating the parent key properties, because no single
parent key can be mapped to each key on the children any more.
2015-01-20 09:30:10 +01:00
Lukas Tönne
90e46ae6c0 Optional randomization factors for the spiral radius and axis orientation. 2015-01-20 09:30:10 +01:00
Lukas Tönne
76c7d693d9 Support in Cycles for the extra spiral keys in hair paths. 2015-01-20 09:30:10 +01:00
Lukas Tönne
6edeb43c16 Nicer calculation of the kink axis and result of the spiraling for
negative radius.
2015-01-20 09:30:10 +01:00
Lukas Tönne
9f3a840df2 Removed unused old code. 2015-01-20 09:30:10 +01:00
Lukas Tönne
374188cdfe Disable the path length check for spiral kink mode.
This test is terribly expensive for some reason and not necessary for
for the spiral mode anyway.
2015-01-20 09:30:10 +01:00
Lukas Tönne
14af65b3ef Fix for calculation of the key velocity on the last child hair segment. 2015-01-20 09:30:10 +01:00
Lukas Tönne
307c4a4df9 Another crappy approach to spirals on hairs, crazy expensive though.
Conflicts:
	source/blender/blenkernel/intern/particle.c
2015-01-20 09:30:10 +01:00
Lukas Tönne
9bf7633936 Spiral kink mode for particles.
This is BAD code, but the particle kinking does not make it easy to
write a non-local modifier that requires neighboring positions,
curvature, etc. The feature is needed for Gooseberry.
2015-01-20 09:30:10 +01:00
Lukas Tönne
c2306919b7 Optional clumping noise feature for simulating twisted hair strands.
This adds another level of clumping on child hairs. When enabled, child
hairs chose a secondary clumping target using a Voronoi pattern. This
adds visual detail on a smaller scale, which is useful particularly when
the number of parents is relatively small.

Natural fibres behave in a similar way when they become sticky and
intertwined. Hairs close to each other form a first twisted strand, then
combine into larger strands. Similar features can be found in ropes:
http://en.wikipedia.org/wiki/Hair_twists
http://en.wikipedia.org/wiki/Rope

Conflicts:
	source/blender/blenloader/intern/versioning_270.c
2015-01-20 09:30:10 +01:00
Lukas Tönne
7f219137cf Disable scope updates in texture and image paint modes.
Scope update is very slow for high resolutions, and currently blocks
the UI thread(!). This is especially terrible in paint modes, where
each stroke causes a scope update and unacceptable freezing.

The scopes update method tries to avoid this somewhat by skipping if the
toolbar is disabled, but this doesn't help when painting where brush
tools etc. are frequently needed. It's also a bad-level poll, with the
core system accessing a UI element.

Eventually scope updates should become a low-priority background job,
as well as becoming threaded. Until then this polling provides a usable
workaround to the most outrageous cases.
2015-01-20 09:30:09 +01:00
Lukas Tönne
d1246969ed Curve-based control for "roughness" (noise displacement) of child hair. 2015-01-20 09:30:09 +01:00
Lukas Tönne
c86d55d5e7 Curve-based control for child path tapering.
This is an alternative method to the current fixed function with a
clump factor and "shape" parameter. This function is quite limited and
does not give the desired result in many cases (e.g. long, parallel
rasta strands are problematic). So rather than trying to add more
parameters there is now a fully user-defined optional curve for setting
the tapering shape.
2015-01-20 09:30:09 +01:00
Lukas Tönne
4c82367fd8 Moved kink, clump and roughness functions into the dedicated source file. 2015-01-20 09:30:09 +01:00
Lukas Tönne
4f1c0a181d Reorganizing hair child code a little bit to make it not totally insane.
This contains a few pieces of code for a future "modifier" system that
would allow more flexible combination of effects. Eventually a node
system is the way to go, but the current code makes that impossible.
2015-01-20 09:30:09 +01:00
Lukas Tönne
b292d783f2 Separate context freeing from task freeing in threaded particle updates
to prevent double-freeing/invalid mem access.

This can happen with the "virtual parents" feature, which generates both
parent and child paths. Each task free function also freed the shared
context, leading to double freeing.
2015-01-20 09:30:09 +01:00
Lukas Tönne
1727a165dd Properly register the mathutils.interpolate submodule. 2015-01-20 09:30:09 +01:00
Lukas Tönne
1b6f5ecbf4 Fix for invalid access to undefined hair data in edge-only cloth meshes.
Cloth data is used both for hair and actual cloth, which makes things
really difficult. The face number was used for distinguishing the two
types (no faces == hair mesh), but the extra hair data necessary for
hair sim is generated by particles and not available for edge-only cloth
meshes. This really needs to be sanitized ...

Conflicts:
	source/blender/physics/intern/BPH_mass_spring.cpp
2015-01-20 09:30:09 +01:00
Lukas Tönne
db2ac79fc7 Radical simplification of the wind effect on hair, since the previous
approach does not work very well.

Using a cross section estimate still causes large oscillations due to
varying hair force based on angles. It also requires a sensible hair
thickness value (particle radius) which is difficult to control and
visualize at this point.

The new model is based purely on per-vertex forces, which seems to be
much more stable. It's also somewhat justified by the fact that each
hair vertex represents a certain mass.

Conflicts:
	source/blender/physics/intern/BPH_mass_spring.cpp
2015-01-20 09:30:09 +01:00
Lukas Tönne
f0e8690526 Fix for wind force function call. 2015-01-20 09:30:09 +01:00
Lukas Tönne
5c7adf5be2 Improved force field effects on hair strands.
The previous calculation was modulated with the angle between the wind
direction and the segments, which leads to very oscillating behavior.

Now the formula includes an estimate for the geometric cross section
of a hair segment based on the incident angle and the hair thickness
(currently just the particle size). This gives a more stable behavior
and more realistic response to wind.

Conflicts:
	source/blender/blenkernel/intern/particle_system.c
	source/blender/physics/intern/BPH_mass_spring.cpp
2015-01-20 09:30:09 +01:00
Lukas Tönne
658fc3ddbc New python submodule mathutils.interpolate for various mesh interpolation and weighting methods.
This module will contain mirrored functions for calculating and applying
weights for points on a mesh. This includes barycentric and UV weighting
and possibly more advanced global weighting such as harmonic weights.

The naming should follow this scheme:
<type>_{2d,3d}_{calc,apply}

e.g.
poly_2d_calc
poly_2d_apply
uv_3d_calc
...

Reviewers: campbellbarton

Differential Revision: https://developer.blender.org/D939
2015-01-20 09:30:09 +01:00
Lukas Tönne
3b938f3d7f Fix for missing library linking in blenderplayer. 2015-01-20 09:30:08 +01:00
Lukas Tönne
3f3c19e391 Another fix for particle instance child lookups, was not subtracting
parent amount.
2015-01-20 09:30:08 +01:00
Lukas Tönne
c3c19509b3 Fix for invalid particle pointer access in mixed particle/child loop. 2015-01-20 09:30:08 +01:00
Lukas Tönne
790b931956 Better update function for particle settings affecting nested cloth
modifier.
2015-01-20 09:30:08 +01:00
Lukas Tönne
60bf6c123f Fix for applying the bending randomness factor.
A stupid hack is needed here, changing the way the factor is applied to
angular bending springs. In cloth sim the bending factor of individual
springs is applied as a mix value between the bending stiffness and a
max value, but this max value isn't even used in hair sim so that
approach becomes useless.

Conflicts:
	source/blender/physics/intern/BPH_mass_spring.cpp
2015-01-20 09:30:08 +01:00
Lukas Tönne
d031831a05 Randomness factor for hair bending stiffness.
This helps to create some variation in a hair system, which can
otherwise become very uniform and boring. It's yet another confusing
setting in a system that should have been nodified, but only option for
now (broken windows ...)

Conflicts:
	source/blender/blenkernel/intern/particle_system.c
	source/blender/physics/intern/BPH_mass_spring.cpp
2015-01-20 09:30:08 +01:00
Lukas Tönne
64a4d4ed25 Fix for particle instance initial frames.
These were not orthonormal and tended to flip with changing hair
direction, now use the particle hair matrix which is stable wrt. the
mesh surface.
2015-01-20 09:30:08 +01:00
Lukas Tönne
bd033721c2 Fix for particle instance modifier: use a stable parallel-transport
framing method instead of the Frenet frame.

The Frenet frame is very succeptible to sudden twists along straight
sections of a curve where the second derivative (curvature) becomes 0.
2015-01-20 09:30:08 +01:00
Lukas Tönne
674c98bd06 Nicer hashing functionality for sim debugging using a variadic macro
to support multiple hash identifiers.

Using explicit hashing functions for every sim debug call defeats the
purpose of having a quick feedback system. Now this can be done simply
by passing an arbitrary number of hash inputs (integers) at the end of
the function calls, which are then combined by a system of variadic
macros (based on the ELEM feature). Up to 8 identifiers are supported
currently, but more could be added easily if needed.

Conflicts:
	source/blender/blenkernel/intern/particle_system.c
	source/blender/physics/intern/BPH_mass_spring.cpp
2015-01-20 09:30:08 +01:00
Lukas Tönne
52384179f4 Some tweaking of value ranges for hair target density and removed
density factor (already included in grid velocity).

Conflicts:
	source/blender/physics/intern/BPH_mass_spring.cpp
2015-01-20 09:30:08 +01:00
Lukas Tönne
2da21b30ae Inverted effect of target density was unstable, the divergence term
needs to be substracted instead.
2015-01-20 09:30:08 +01:00
Lukas Tönne
325990ff6e Use dedicated debug values in cloth settings instead of abusing unused
other values.

Conflicts:
	source/blender/physics/intern/BPH_mass_spring.cpp
2015-01-20 09:30:08 +01:00
Lukas Tönne
faa112cd27 Fixed wrong stride values used for offsetting the index of Eigen values.
The Eigen solver for hair grids uses an extra margin of 1, which means
greater stride values.
2015-01-20 09:30:08 +01:00
Lukas Tönne
d73de8f277 Hair grid code was using an invalid hair segment at each hair end with
zero vectors, leading to bad density values.

Conflicts:
	source/blender/physics/intern/BPH_mass_spring.cpp
2015-01-20 09:30:07 +01:00
Lukas Tönne
95f9726173 A bunch of debug drawing changes.
Conflicts:
	source/blender/physics/intern/BPH_mass_spring.cpp
2015-01-20 09:30:07 +01:00
Lukas Tönne
7c153c3a3d Corrected the divergence and gradient calculation for the hair grid
solver input and output.

This uses the central difference method (instead of combined forward/
backward difference), which makes it easier to correctly account for
grid borders.
2015-01-20 09:30:07 +01:00
Lukas Tönne
42fc88de43 Fallback method for defining density in the hair grid using discrete
samples.

This is just an intermediate method to make sure the density is valid.
Eventually the closest-point method should be used, but for testing
the poisson solver this is easier to debug.

Conflicts:
	source/blender/physics/intern/BPH_mass_spring.cpp
2015-01-20 09:30:07 +01:00
Lukas Tönne
e73df249c7 Added a margin to the number of cells used in the poisson grid solver,
to ensure we always have one layer of empty cells around the fluid.
2015-01-20 09:30:07 +01:00
Lukas Tönne
e6b80eb179 Fix for merge errors and leftover unused code lines. 2015-01-20 09:30:07 +01:00
Lukas Tönne
b3cbafb966 Implementation of a target density feature for the hair simulation.
This allows setting a target density which the fluid simulation will
take into account as an additional term in the pressure Poisson
equation. Based on two papers
"Detail Preserving Continuum Simulation of Straight Hair" (McAdams et al. 2009)
and
"Two-way Coupled SPH and Particle Level Set Fluid Simulation" (Losasso et al. 2008)

Currently the target pressure is specified directly, but it will be
a lot more convenient to define this in terms of a geometric value such
as "number of hairs per area" (combined with hair "thickness").

Conflicts:
	source/blender/physics/intern/BPH_mass_spring.cpp
2015-01-20 09:30:07 +01:00
Lukas Tönne
a754c0af40 Another fix for off-by-one hair grid resolution errors. 2015-01-20 09:30:07 +01:00
Lukas Tönne
9c660f18ac Rewriting the grid rasterization function for hair segments. 2015-01-20 09:30:07 +01:00
Lukas Tönne
e56bda4a02 Draw actual hair keys when the "Guide Hair" setting is enabled.
Without this certain debug tasks become very hard to visualize.
2015-01-20 09:30:07 +01:00
Lukas Tönne
62d9aa05ab Fix for grid drawing in 3D view, was using one less grid cell. 2015-01-20 09:30:07 +01:00
Lukas Tönne
046510fcf9 Merge branch 'hair_immediate_fixes' into gooseberry
Conflicts:
	source/blender/physics/intern/BPH_mass_spring.cpp
2015-01-20 09:30:07 +01:00
Lukas Tönne
be24adc9ef Implemented PIC and FLIP methods for combining the fluid grid simulation
with the Lagrangian hair model.
2015-01-20 09:30:07 +01:00
Lukas Tönne
926a674fe8 Main solver step for generating a divergence-free hair velocity field
on the grid.

This uses the Eigen conjugate-gradient solver to solve the implicit
Poisson equation for the pressure Laplacian:

    div(grad(p)) = div(v)

As described in "Detail Preserving Continuum Simulation of Straight Hair"
(McAdams, Selle, 2009).

Conflicts:
	source/blender/physics/intern/BPH_mass_spring.cpp
2015-01-20 09:30:06 +01:00
Lukas Tönne
7740b1671c Pampering the stupid MSVC compiler again, it fails to build valid C code. 2015-01-20 09:30:06 +01:00
Lukas Tönne
aa16b5c222 Added new header for Eigen utility classes.
These make passing data between Eigen vector and matrix types and plain
C arrays more convenient.
2015-01-20 09:30:06 +01:00
Lukas Tönne
74d6f31879 Updated a few comments. 2015-01-20 09:30:06 +01:00
Lukas Tönne
9cd8e9f146 Compile hair volumetrics code as C++, so we can use Eigen easier. 2015-01-20 09:30:06 +01:00
Lukas Tönne
46db288832 Minor debug code fix.
Conflicts:
	source/blender/physics/intern/BPH_mass_spring.cpp
2015-01-20 09:30:06 +01:00
Lukas Tönne
bf96400558 Use a fixed, uniform cell size for hair continuum grids.
This is a bit more awkward for artists to use, but necessary for
a stable solution of the hair continuum calculation. The grid size is
defined by the user, the extent of the grid is then calculated based on
the hair geometry. A hard upper limit prevents bad memory allocation
in case too small values are entered.

Conflicts:
	source/blender/physics/intern/BPH_mass_spring.cpp
2015-01-20 09:30:06 +01:00
Lukas Tönne
8dbb6f0d5d Removed unused voxel_filter_size DNA property.
This is an artifact of earlier attempts to implement velocity smoothing,
but doesn't work anyway.

Conflicts:
	source/blender/physics/intern/BPH_mass_spring.cpp
2015-01-20 09:30:06 +01:00
Lukas Tönne
e3dcbc3679 Renamed HairVertexGrid to HairGrid, since it's not actually storing
hair vertex data.

Conflicts:
	source/blender/physics/intern/BPH_mass_spring.cpp
2015-01-20 09:30:06 +01:00
Lukas Tönne
dddf088375 Removed unused "collider grid" struct from hair volumetrics.
This is a leftover from previous approach of hair collisions (with
insufficient results). The hair volumetrics actually implements
"collision" with solid objects as well, but uses a Neumann boundary
condition on the main grid for this purpose.
2015-01-20 09:30:06 +01:00
Lukas Tönne
d05c653ade Better grid rasterization method for hair volumetric grids.
This is based on the paper
"Detail Preserving Continuum Simulation of Straight Hair"
(McAdams, Selle, Ward, 2009)

The main difference is that hair line segments are used rather than only
rasterizing velocity at the vertices. This gives a much better coverage
of the hair volume grid, otherwise gaps can be produced at smaller grid
cell sizes and the distribution is uneven along the hair curve.

The algorithm for rasterizing is a variation of Bresenham's algorithm
extended onto 3D grids.

Conflicts:
	source/blender/physics/intern/BPH_mass_spring.cpp
2015-01-20 09:30:06 +01:00
Lukas Tönne
c37de38716 New debug element "circle" for simulations, which is quite useful for
visualizing scalar fields.
2015-01-20 09:30:06 +01:00
Lukas Tönne
7dda1ea396 Debug grid drawing for hair volume was drawing one subdivision too many. 2015-01-20 09:30:06 +01:00
Lukas Tönne
211be0ae6e Unused leftover debug variable. 2015-01-20 09:30:06 +01:00
Lukas Tönne
d42525a9b5 Reimplemented the voxel texture type for displaying hair continuum grids.
Conflicts:
	source/blender/physics/intern/BPH_mass_spring.cpp
2015-01-20 09:30:05 +01:00
Lukas Tönne
cd717f145d Expose hair grid info in the RNA (read-only); it can be useful for
debugging purposes.
2015-01-20 09:30:05 +01:00
Lukas Tönne
9d27b53d41 Debug visualization code of a slice of the hair velocity vector field. 2015-01-20 09:30:05 +01:00
Lukas Tönne
9be290c92e Removed arbitrary factor 2.0 on volumetric hair friction factor.
This was introducing energy into the system for any factor beyond 0.5
and caused major instability.
2015-01-20 09:30:05 +01:00
Lukas Tönne
54c69c4ed8 Fill the hair volume grid with the _new_ velocities from the first
solver step, instead of using the previous step's velocities.

Conflicts:
	source/blender/physics/intern/BPH_mass_spring.cpp
2015-01-20 09:30:05 +01:00
Lukas Tönne
c3968861b3 Debug drawing feature to visualize the hair continuum grid. 2015-01-20 09:30:05 +01:00
Lukas Tönne
aea309779f Perform grid-based velocity smoothing for hair outside of the implicit
solver step.

Calculating forces and jacobians from linearly interpolated grid values
is problematic due to discontinuities at the grid boundaries. The new
approach of modifying velocities after the backward euler solver step
was suggested in a newer paper

"Detail Preserving Continuum Simulation of Straight Hair"
(McAdams, Selle 2009)

Conflicts:
	source/blender/physics/intern/BPH_mass_spring.cpp
2015-01-20 09:30:05 +01:00
Lukas Tönne
4381fa3157 Minor fix for lost variable declaration during cherry-picking. 2015-01-20 09:30:05 +01:00
Lukas Tönne
4ff68d031d Fix for warnings/errors
Conflicts:
	source/blender/blenkernel/intern/key.c
	source/blender/blenkernel/intern/particle_system.c
	source/blender/makesrna/intern/rna_particle.c
2015-01-20 09:30:05 +01:00
Lukas Tönne
edc9baaae4 Moved render simplification function for particle distribution into the
distribution code.
2015-01-20 09:30:05 +01:00
Lukas Tönne
34762de38f Removed unused variable. 2015-01-20 09:30:05 +01:00
Lukas Tönne
09f171c525 A little bit of code sanity by splitting particle distribution function
by type.

Instead of squashing totally unrelated code into the same monster
function.
2015-01-20 09:30:04 +01:00
Lukas Tönne
0f43ba8235 Moved particle code for distributions into own file to make hacking
easier.

This code is badly broken and needs to be replaced, but at least having
a workable code structure might help with quick hacks to fix the worst
cases.
2015-01-20 09:30:04 +01:00
Lukas Tönne
f03fc27bf7 Removed unused line. 2015-01-20 09:30:04 +01:00
Lukas Tönne
c01ed4875b New hair editing feature "Shape Cut", for cutting hair based on a mesh
shape instead of a brush tool.

The brush cutting tool for hair, while useful, is not very accurate and
often requires rotating the model constantly to get the right trimming
on every side. This makes adjustments to a hair shape a very tedious
process.

On the other hand, making proxy meshes for hair shapes is a common
workflow. The new operator allows using such rough meshes as boundaries
for hair. All hairs that are outside the shape mesh are removed, while
those cutting it at some length are shortened accordingly.

The operator can be accessed in the particle edit mode toolbar via the
"Shape Cut" button. The "Shape Object" must be set first and stays
selected as a tool setting for repeatedly applying the shape.
2015-01-20 09:30:04 +01:00
Lukas Tönne
117f4bbe66 Switched back to blender implicit solver for merge. 2015-01-20 09:30:04 +01:00
Lukas Tönne
4cdf0ab5cf Unified the main Eigen solver function a bit for constrained/unconstrained
solver variants.
2015-01-20 09:30:04 +01:00
Lukas Tönne
2356264ca9 Ported the remaining implicit solver functions for Eigen.
Also added a couple of utility wrapper functions for Eigen types to make
interfacing with plain float arrays and blenlib math easier.
2015-01-20 09:30:04 +01:00
Lukas Tönne
4eac83da66 Updating Eigen implicit dynamics solver implementation to adhere to the
new mass-spring solver API.

Conflicts:
	source/blender/physics/intern/implicit_eigen.cpp
2015-01-20 09:30:04 +01:00
Lukas Tönne
35d09c7ab6 Fix for inverted condition: hair data needs to be rebuilt when the
cloth DM does not exist.
2015-01-20 09:30:04 +01:00
Lukas Tönne
4a16242e60 Cleanup: Removed the unnecessary cloth solver abstraction (there is only
one solver anyway), and split some particle cloth functions for clarity.

Conflicts:
	source/blender/blenkernel/BKE_particle.h
	source/blender/blenkernel/intern/particle_system.c
	source/blender/blenloader/intern/versioning_270.c
	source/blender/makesdna/DNA_particle_types.h
	source/blender/makesrna/intern/rna_particle.c
2015-01-20 09:30:04 +01:00
Lukas Tönne
0b0acb6124 enum instead of #define for cloth vertex flags. 2015-01-20 09:30:04 +01:00
Lukas Tönne
ce53303f61 Removed accidentally committed debug print. 2015-01-20 09:30:04 +01:00
Lukas Tönne
fe8fad54b1 Use the generic task scheduler for threaded particle tasks, i.e.
distribution and path caching for child particles.

This gives a significant improvement of viewport playback performance
with higher child particle counts. Particles previously used their own
threads and had a rather high limit for threading. Also threading
apparently was disabled because only 1 thread was being used ...
2015-01-20 09:30:03 +01:00
Lukas Tönne
c1f4542f0f Removed block matrix indices storage from ClothSpring struct.
This is not necessary: the implicit solver data can keep track instead
of how many off-diagonal matrix blocks are in use (provided the
allocation limit is calculated correctly). Every time a spring is
created it then simply increments this counter and uses the block index
locally - no need to store this persistently.
2015-01-20 09:30:03 +01:00
Lukas Tönne
a5f207de79 Removed unused force arguments for angular bending springs and avoid
redundant calculation for counterforces.
2015-01-20 09:30:03 +01:00
Lukas Tönne
173bdfe05e Guide hair drawing for hair particles.
Without this the particle system only shows the actual non-simulated
hairs ("guide hairs") during edit mode. These hairs are used for goals
as well, so showing them in the regular viewport is pretty important.

Also the usual hair curves are interpolated along the entire length,
which makes it very difficult to see exact vertex positions, unless
using exact powers of 2 for the segment number and match the display
steps.

Conflicts:
	source/blender/blenkernel/intern/particle.c
2015-01-20 09:30:03 +01:00
Lukas Tönne
acf4506299 Improved child hair curling for interpolated child particles.
The curl radius for children in interpolated mode was calculated using
the total offset from the parent particle. This leads to very large
radii when the distance is large due to sparse parents. Such behavior is
also very unrealistic because the curl radius is mostly constant and
defined by the material properties.

All the child hairs are roughly parallel by default. To simulate the
agglomeration of children into hair wisps the "flatness" parameter is
now used to clump them together.
2015-01-20 09:30:03 +01:00
Lukas Tönne
64b9ba06a7 Cloth solver data for edit mode is unused, removed it. 2015-01-20 09:30:03 +01:00
Lukas Tönne
6097de2db9 Fix for scons files missing physics include folder. 2015-01-20 09:30:03 +01:00
Lukas Tönne
48e67c49a5 Added separate damping for bending springs.
The bend damping factor was hardcoded to the same value as the stiffness.
Now it has its own factor in the settings and button in hair dynamics.
2015-01-20 09:30:03 +01:00
Lukas Tönne
e694b7c04b Set the length threshold for hair simulation to 10% again (from 1%).
With the default 5 substeps the simulation can otherwise still become
unstable. This is just a preliminary measure anyway until the length
variance can be fixed properly.
2015-01-20 09:30:03 +01:00
Lukas Tönne
43424a639b Fix for outdated root array size when changing the particle amount
during simulation.
2015-01-20 09:30:03 +01:00
Lukas Tönne
d613c38171 Fix for hair chain testing in the cloth modifier.
Bending springs are en-bloc and not interleaved with other springs, so
this can't be used as a test for hair roots. Use consecutive indices
instead.
2015-01-20 09:30:03 +01:00
Lukas Tönne
577150c635 Completed the implementation of bent rest shapes for hair.
Basically follows the Pixar approach from "Artistic Simulation of Curly
Hair".
2015-01-20 09:30:03 +01:00
Lukas Tönne
520922876a Target calculation for local non-straight rest shapes.
This is more involved than using simple straight bending targets
constructed from the neighboring segments, but necessary for restoring
groomed rest shapes.

The targets are defined by parallel-transporting a coordinate frame
along the hair, which smoothly rotates to avoid sudden twisting (Frenet
frame problem). The rest positions of hair vertices defines the target
vectors relative to the frame. In the deformed motion state the frame
is then recalculated and the targets constructed in world/root space.
2015-01-20 09:30:03 +01:00
Lukas Tönne
7d4799b41d Have to include BLI_utildefines before BKE_collision now to have bool
defined.
2015-01-20 09:30:02 +01:00
Lukas Tönne
6394189e68 Clear forces and constraints together at the start of the time step,
easier to verify.
2015-01-20 09:30:02 +01:00
Lukas Tönne
e44187cd5f Fix for missing initialization of local cloth modifier inside particle
systems.
2015-01-20 09:30:02 +01:00
Lukas Tönne
c036c72284 Proper implementation of angular bending springs including jacobian
derivatives for stabilization.

The bending forces are based on a simplified torsion model where each
neighboring point of a vertex creates a force toward a local goal. This
can be extended later by defining the goals in a local curve frame, so
that natural hair shapes other than perfectly straight hair are
supported.

Calculating the jacobians for the bending forces analytically proved
quite difficult and doesn't work yet, so the fallback method for now
is a straightforward finite difference method. This works very well and
is not too costly. Even the original paper ("Artistic Simulation of
Curly Hair") suggests this approach.
2015-01-20 09:30:02 +01:00
Lukas Tönne
3a8ef0ef6c Unused function declaration. 2015-01-20 09:30:02 +01:00
Lukas Tönne
491e7493c7 Basic solver result feedback from the mass-spring (cloth/hair) solver.
This returns a general status (success/no-convergence/other) along with
basic statistics (min/max/average) for the error value and the number
of iterations. It allows some general estimation of the simulation
quality and detection of critical settings that could become a problem.
Better visualization and extended feedback can follow later.
2015-01-20 09:30:02 +01:00
Lukas Tönne
00bb836e17 Calculate bending targets based on the direction of previous segments.
This makes the bending a truely local effect. Eventually target
directions should be based in a local coordinate frame that gets
parallel transported along the curve. This will allow non-straight
rest shapes for hairs as well as supporting twist forces. However,
calculating locally transformed spring forces is more complicated.
2015-01-20 09:30:02 +01:00
Lukas Tönne
e5ae13b809 Simple debug drawing support inside the implicit solver. 2015-01-20 09:30:02 +01:00
Lukas Tönne
14bd99b0f3 Added a damping term for angular bending springs. 2015-01-20 09:30:02 +01:00
Lukas Tönne
7a7778d003 Simple initial implementation of angular bending springs.
These are much better suited for creating stiff hair. The previous
bending springs are based on "push" type spring along the hypothenuse
of 3 hair vertices. This sort of spring requires a very large force
in the direction of the spring for any angular effect, and is still
unstable in the equilibrium.

The new bending spring model is based on "target" vectors defined in a
local hair frame, which generates a force perpendicular to the hair
segment. For further details see
"Artistic Simulation of Curly Hair" (Pixar technical memo #12-03a)
or
"A Mass Spring Model for Hair Simulation" (Selle, Lentine, Fedkiw 2008)

Currently the implementation uses a single root frame that is not yet
propagated along the hair, so the resulting rest shape is not very
natural. Also damping and derivatives are still missing.
2015-01-20 09:30:02 +01:00
Lukas Tönne
86a4da1c54 Replace the dynamic root transform in the implicit solver data with a
single transform matrix.

Dynamic properties of the transformation are only needed during the
setup phase when they should be read from external data (hair system
roots) and generate fictitious forces on each point.
2015-01-20 09:30:02 +01:00
Lukas Tönne
fa1c2ba7c6 More scons fixes for physics lib. 2015-01-20 09:30:02 +01:00
Lukas Tönne
09ad433179 Fixed scons build files for new physics subfolder. 2015-01-20 09:30:02 +01:00
Lukas Tönne
f03d253f55 Disabled the velocity filtering feature for now, since the weighting is
incorrect.

The voxel grid needs better tool support to make it usable, so fixing
the filtering is not high priority right now.
2015-01-20 09:30:02 +01:00
Lukas Tönne
226beb9866 Added basic filtering feature for velocity smoothing.
This is part of the original method from "Volumetric Methods for
Simulation and Rendering of Hair". The current filter is a simple box
filter. Other energy-preserving filters such as gaussian filtering
can be implemented later.

The filter size is currently given as a cell count. This is not ideal,
rather it should use a geometrical length value, but this is too
abstract for proper artistical use. Eventually defining the whole grid
in terms of spatial size might work better (possibly using an external
object).
2015-01-20 09:30:01 +01:00
Lukas Tönne
bbae8f88b8 Made the voxel grid size for hair interaction configurable and increased
the default to 32.

Conflicts:
	source/blender/blenloader/intern/versioning_270.c
2015-01-20 09:30:01 +01:00
Lukas Tönne
be016daf15 Reduced the length threshold for disabling short hairs from 0.1 to 0.01. 2015-01-20 09:30:01 +01:00
Lukas Tönne
0ddea77b1a Fix for rB71271bb, was replacing the force vectors entirely instead of
adding.
2015-01-20 09:30:01 +01:00
Lukas Tönne
59d76a406e Fix for effector force fields on hair, using the world-to-root
transformation.
2015-01-20 09:30:01 +01:00
Lukas Tönne
d43170d09d Add weak repulsion forces to hair collision response to keep the hair
at a the margin distance ("outer" softbody margin).

This has to be clamped arbitrarily unfortunately, otherwise the
repulsion force can add too much energy into the system. A factor of
4 * restitution impulse seems to give good results for now, this can
be refined later on if necessary.
2015-01-20 09:30:01 +01:00
Lukas Tönne
8876429edd Added back the velocity smoothing implementation.
This is now also decoupled from the internal solver data. The grid is
created as an opaque structure, filled with vertex or collider data
(todo), and then forces can be calculated by interpolating the grid at
random locations. These forces and derivatives are then fed into the
solver.
2015-01-20 09:30:01 +01:00
Lukas Tönne
a8cf092160 Fix for Sintel hair bug.
The hair solver needs sane input to converge within reasonable time
steps. In particular the spring lengths must not be too difference
(factor 0.01..100 or so max, this is comparable to rigid body simulation
of vastly different masses, which is also unstable).

The basic hair system generate strands with equally spaced points, which
is good solver material. However, the hair edit operators, specifically
the cutting tool, can move points along the strands, creating tightly
packed hair points. This puts the solver under enormous stress and
causes the "explosions" observed already during the Sintel project.

The simple solution for now is to exclude very short hairs from the
simulation. Later the cutting tool should be modified such that it
keeps the segments roughly at the same length and throws away vertices
when the hair gets too short (same goes for the extension tool).

The hair system should have a general mechanism for making sure that
situations such as this don't occur. This will have to be a design
consideration for replacements in any future hair system.
2015-01-20 09:30:01 +01:00
Lukas Tönne
6623395638 Minor fix when gravity code is disabled. 2015-01-20 09:30:01 +01:00
Lukas Tönne
58e33ab279 Removed unused code.
Conflicts:
	source/blender/physics/intern/implicit_blender.c
2015-01-20 09:30:01 +01:00
Lukas Tönne
d0379f82d1 Added a calculation function for the fictitious forces introduced by
moving hair root reference frames.

This calculates Euler, Coriolis and Centrifugal forces which result
from describing hair in a moving reference frame.
http://en.wikipedia.org/wiki/Fictitious_force
2015-01-20 09:30:01 +01:00
Lukas Tönne
a49b170b27 Fix for own misconception of fictitious forces in the moving hair root
frames.

These forces don't have to be calculated for each individual
contribution. Rather they can be split off and be calculated on top of
the basic force vector rotation (todo).
2015-01-20 09:30:01 +01:00