Commit Graph

70 Commits

Author SHA1 Message Date
Campbell Barton 651b8fb14e Undo: unified undo system w/ linear history
- Use a single undo history for all operations.
- UndoType's are registered and poll the context to check if they
  should be used when performing an undo push.
- Mode switching is used to ensure the state is correct before
  undo data is restored.
- Some undo types accumulate changes (image & text editing)
  others store the state multiple times (with de-duplication).
  This is supported by checking UndoStack.mode `ACCUMULATE` / `STORE`.
- Each undo step stores ID datablocks they use with utilities to help
  manage restoring correct ID's.
  Needed since global undo is now mixed with other modes undo.
- Currently performs each undo step when going up/down history
  Previously this wasn't done, making history fail in some cases.
  This can be optimized to skip some combinations of undo steps.

grease-pencil is an exception which has not been updated
since it integrates undo into the draw-session.

See D3113
2018-03-31 20:40:37 +02:00
Campbell Barton 1e4b612d6a Cleanup: add _types.h suffix to DNA headers 2018-02-07 11:14:08 +11:00
Bastien Montagne 9da7dfa158 Refactor ID copying (and to some extent, ID freeing).
This will allow much finer controll over how we copy data-blocks, from
full copy in Main database, to "lighter" ones (out of Main, inside an
already allocated datablock, etc.).

This commit also transfers a llot of what was previously handled by
per-ID-type custom code to generic ID handling code in BKE_library.
Hopefully will avoid in future inconsistencies and missing bits we had
all over the codebase in the past.

It also adds missing copying handling for a few types, most notably
Scene (which where using a fully customized handling previously).

Note that the type of allocation used during copying (regular in Main,
allocated but outside of Main, or not allocated by ID handling code at
all) is stored in ID's, which allows to handle them correctly when
freeing. This needs to be taken care of with caution when doing 'weird'
unusual things with ID copying and/or allocation!

As a final note, while rather noisy, this commit will hopefully not
break too much existing branches, old 'API' has been kept for the main
part, as a wrapper around new code. Cleaning it up will happen later.

Design task : T51804
Phab Diff: D2714
2017-08-07 16:39:55 +02:00
Alexander Gavrilov 1fe9d671cf Fix T49004 and motion blur of cloth, softbody, etc past the end frame.
Point cache read code contains checks designed to prevent it reading
stale data when the relevant simulation code should instead compute
the next frame from the previous one. However in some situations like
motion blur subframes the simulation can't possibly do it and just
exits. This causes completely incorrect motion blur at or after the
last cached frame.

To fix, add a parameter that tells the cache code whether it should
apply the checks and exit, or read what it can even if stale (true
means exactly same as old behavior).

Doing this in cache rather than clamping the frame number better in
the caller lets it handle the case of incomplete cache that stops
before the official last frame.

Reviewed By: mont29, lukastoenne

Maniphest Tasks: T49004

Differential Revision: https://developer.blender.org/D2144
2016-08-11 13:36:29 +03:00
Brecht Van Lommel 74e40663da Fix T47971: rigid body baking crash due to thread race condition. 2016-04-02 13:04:26 +02:00
Kévin Dietrich e9452f909c Implementation of OpenVDB as a possible cache format for smoke
simulations.

This commits implements OpenVDB as an extra cache format in the Point
Cache system for smoke simulations. Compilation with the library is
turned off by default for now, and shall be enabled when the library is
present.

A documentation of its doings is available here: http://
wiki.blender.org/index.php/User:Kevindietrich/OpenVDBSmokeExport.

A guide to compile OpenVDB can be found here (Linux): http://
wiki.blender.org/index.php?title=Dev:Doc/Building_Blender/Linux/
Dependencies_From_Source#OpenVDB

Reviewers: sergey, lukastoenne, brecht, campbellbarton

Reviewed By: brecht, campbellbarton

Subscribers: galenb, Blendify, robocyte, Lapineige, bliblubli,
jtheninja, lukasstockner97, dingto, brecht

Differential Revision: https://developer.blender.org/D1721
2016-01-23 08:39:40 +01:00
Kévin Dietrich 45b6893e70 Point Cache: use job system for bake operators.
Reviewers: brecht

Differential Revision: https://developer.blender.org/D1731
2016-01-17 02:01:41 +01:00
Campbell Barton 7724b26ab2 Cleanup: use const for object copy funcs 2015-06-02 20:21:45 +10:00
Lukas Tönne 8f9f55498e Removed unused particles pointer from particle edit data. 2015-01-20 09:30:11 +01:00
Campbell Barton 617557b08e Code cleanup: remove TRUE/FALSE & WITH_BOOL_COMPAT define 2014-04-01 15:22:28 +11:00
Brecht Van Lommel 72cf50ed1e Related to #36532: show message in modifier when cloth point cache read fails,
for example due to a subsurf modifier preceding a cloth modifier.
2013-09-03 19:58:09 +00:00
Sergej Reich 089cf12435 rigidbody: Add point cache support
Add read/write/interpolate functions.

In order to get rigid body point cache id from object it's now required to pass the
scene to BKE_ptcache_ids_from_object().

Rigid body cache is drawn in the orange color of the bullet logo.
2013-01-23 05:56:34 +00:00
Sergej Reich 8b8d4ba7ef sim: Remove "continue physics" code
This was left over from 2.4x days and is not used anymore.
Now simulations are always interactive.
2013-01-22 20:47:03 +00:00
Sergey Sharybin c1abde5935 Fix #32667: Curve softbodies doesn't render animation (cycles)
Issue was caused by cycles being duplicated curve objects before converting
them to mesh. This duplication will loose pointcache which resulted in object
not being properly deformed.
2012-09-27 14:37:20 +00:00
Campbell Barton 9892736206 code cleanup: header cleanup and remove some duplicate defines. 2012-05-12 20:39:39 +00:00
Campbell Barton 1615b46963 style cleanup 2012-04-21 13:37:26 +00:00
Campbell Barton 7cc206ddca Code Cleanup: remove non existing function declarations.
added some missing functions too - which are not used yep but should be there for api completeness.
* CDDM_set_mloop
* CDDM_set_mpoly
* BLI_mempool_count
2012-02-29 15:00:37 +00:00
Campbell Barton 2b7ca2304a unify include guard defines, __$FILENAME__
without the underscores these clogged up the namespace for autocompleation which was annoying.
2012-02-17 18:59:41 +00:00
Brecht Van Lommel 8651e6fba7 Fix part of #29310: secondary point caches for cloth did not get steps
set to correct default, was 10 when supposed to be 1.
2011-11-24 20:46:00 +00:00
Miika Hamalainen edec46b0a6 Merge with trunk r41625 2011-11-07 16:36:49 +00:00
Campbell Barton 33accdb725 use (const char*) rather than (char*) where possible.
also removed some unused function definitons.
2011-11-05 11:04:28 +00:00
Miika Hamalainen 46ae692710 Merge with trunk r41342 2011-10-28 17:00:53 +00:00
Campbell Barton 4a04f72069 remove $Id: tags after discussion on the mailign list: http://markmail.org/message/fp7ozcywxum3ar7n 2011-10-23 17:52:20 +00:00
Miika Hamalainen 8be3249537 Merge with trunk r40991 2011-10-13 21:43:02 +00:00
Campbell Barton 54adf3de62 fix bad svn ID tags 2011-10-10 09:44:14 +00:00
Campbell Barton bc40f11093 header cleanup (no functional changes) 2011-10-10 09:38:02 +00:00
Miika Hamalainen 2987b68b0f Dynamic Paint:
* Fixed cmake compile.
* Fixed segmentation fault when closing Blender, caused by rna changes from earlier svn trunk merge.
2011-06-16 18:25:41 +00:00
Miika Hamalainen 3de22dec26 Dynamic Paint:
Committed changes from previous weeks, biggest changes are:
* Canvas can now have multiple "surfaces" that each can have specific format, type and settings.
* Renewed UI to support this new system.
* Aside from old "image sequence" output format, Dynamic Paint can now work on vertex level as well. Currently vertex paint and displace are supported.
* Integrated vertex level painting with Point Cache.
* Added viewport preview for Point Cache surfaces.

Due to massive amount of changes, old Dynamic Paint saves are no longer supported. Also some features are temporarily missing or may not work properly.
2011-06-16 10:41:00 +00:00
Nathan Letwory 22638e22ea doxygen: blenkernel under core as module. 2011-02-18 13:05:18 +00:00
Campbell Barton fd448bcfc7 remove/comment unused defines, also zero FileGlobal.filename to quiet valgrind. 2011-01-16 21:12:38 +00:00
Janne Karhu d9c6f51ee2 Compiler warning fixes for the same point cache things Joshua tried to fix earlier, don't know why I didn't notice these before. 2011-01-10 02:40:24 +00:00
Janne Karhu 9231ff4160 Viscoelastic springs for sph particle fluids, original patch by Stephen Whitehorn (chickencoop)
* Viscoelastic springs between the fluid particles can simulate all kinds
  of viscous and elastic substances, such as jelly and honey. This is
  achieved by creating springs dynamically between neighboring particles
  and adjusting their rest length based on stretching/compression.
* This nearly completes the currently intended functionality for particle
  fluids. The last missing thing is a surfacing extraction algorithm,
  which is needed for a proper representation of a sph fluid.
* I also cleaned up and renamed some of the fluid parameters to make the
  ui a bit easier to understand.
* One addition to the patch is an option to use "initial rest length" for
  the springs, which uses the lengths between the particles at the time of
  spring creation as the spring rest lengths instead of interaction radius/2.
  This makes the fluid keep it's original shape better (good for very
  viscoelastic materials), but can create large density differences inside
  the fluid (not really physically correct for a fluid).
* Viscoelastic springs are stored in point cache as extra data.
2011-01-09 19:09:41 +00:00
Janne Karhu 1786923afc Replace uint32_t in pointcache code with unsigned int as it's supported in dna
* Not strictly necessary right now, but better for future.
* Struct data (only boids at the moment) is now written as structs (with dna) so they work between 64 and 32 bit machines too.
2011-01-09 18:23:41 +00:00
Janne Karhu e32bbef017 Fix for [#25544] Blender crashes when changing the particles emission amount
* I've getting bad feelings about the point cache index_array for a while (cause for this bug too), so from now on memory cache uses a simple binary search directly on the index data to handle queries to specific data points.
* This is a bit slower than just checking from a dedicated array, but it's much less error prone, uses less memory and makes the code more readable too, so it's not a tough choice.
2011-01-09 07:41:51 +00:00
Janne Karhu a6a2512f47 Pointcache code cleanup and disk cache compression options:
* Massive reorganization of pointcache code, things are now cleaner than ever.
* For all but smoke the cache is first written to memory when using disk cache and after that written to disk in one operation. This allows less disk operations and the possibility to compress the data before writing it to disk.
* Previously only smoke cache could be compressed, now the same options exist for other physics types too (when using disk cache). For now the default compression option is still "no compression", but if there aren't any problems this can be set to "light compression" as it's actually faster than no compression in most cases since there's less data to write to the disk. Based on quick tests heavy compression can reduce the file size down to 1/3rd of the original size, but is really slow compared to other options, so it should be used only if file size is critical!
* The pointcache code wasn't really 64bit compatible (for disk cache) until now, so this update should fix some crashes on 64bit builds too. Now all integer data that's saved to disk uses 32 bit unsigned integers, so simulations done on 64bit should load fine on 32bit machines and vice versa. (Important disk cache simulations made on 64bit builds should be converted to memory cache in a revision before this commit).
* There are also the beginnings of extradata handling code in pointcache in anticipation of adding the dynamic springs for particle fluids (the springs need to be stored as extradata into point cache).
* Particles were being read from the cache with a slightly wrong framerate. In most cases this probably wasn't noticeable, but none the less the code is now correct in every way.
* Small other fixes here and there & some cosmetic changes to cache panel, but over all there should be no functional changes other than the new disk cache compression options.
* This whole re-organization also seems to fix bug #25436 and hopefully shouldn't introduce any new ones!
2011-01-02 06:52:47 +00:00
Campbell Barton 3bed4cbf2b fix [#25283] Edge length display difficult to read
- made theme colors for mesh edge len & face angle/area display.
- use %g rather then %f for float display, trims unneeded zeros.
- store cached 2d and 3d text color as bytes rather then floats, compare when drawing to avoid setting the context.
- use unsigned char for more color functions, avoids casting to glColorubv().
2010-12-20 03:59:22 +00:00
Janne Karhu b58dbbd51b Extreme makeover of pointcache code:
* Pointcache code was quite ugly looking and complicated, so here are mostly just cosmetic adjustments, but some improved logic also.
* Slight cleanup of pointcache ui too.
* Shouldn't have any functional changes what so ever, so poke me right away if something seems off.
2010-12-18 15:03:31 +00:00
Janne Karhu 17cd5811e7 Smoke now uses only one point cache where both normal and high resolution smoke are stored together:
* Separate caches were causing quite a lot of problems both in principle and practice.
* For example it doesn't really make sense to have different frame ranges for normal and high resolution smoke, but this was fully possible before.
* Also to fully bake the smoke you had to do a "Bake All Dynamics", which completely defeats the whole point of the feature!
* As a result of this change the smoke cache usage is much much simpler and less error prone.
* This is quite a big change, but hopefully there should be less rather than more problems as a result :)

Some other related changes:
* Changing the cache name now works for disk caches properly too, it now just renames the cache files so should be faster too!
* Smoke is now always forced to disk cache with step 1 on file load as there were some strange cases where smoke was trying to use memory cache.
* Disabled smoke debug prints from console.
* Disabled changing smoke parameters when smoke is baked.

Note to users: The unfortunate side effect of this is that old high resolution simulations have to be baked again, but in return you get much better and more logical functionality. Sorry none the less!
2010-11-30 21:31:18 +00:00
Campbell Barton d1759639dc - remove unused includes IMB_*, BIF_* & MEM_*
- remove MEM_guardedalloc.h from header files (include directly)
2010-08-16 05:46:10 +00:00
Brecht Van Lommel 0738ae7688 2.5: more removal of G.main. 2010-08-13 14:23:44 +00:00
Brecht Van Lommel 5fa7d1c1b4 2.5: code changes to reduce the usage of G.main and pass it along
or get it from the context instead.
2010-08-01 12:47:49 +00:00
Janne Karhu 18fb3aa5bf Fix for [#21983] Entering Particle Edit mode crash 2010-04-13 19:44:16 +00:00
Brecht Van Lommel 515592438f Baking for dupligroup & linked library objects
- library data allows pointcache writing (hard to know how this should work long term so ifdef'd for now)
- changing the frame now updates the dupligroup objects
- BKE_ptcache_ids_from_object(), option to get the id's from duplis

note! scene_update_tagged() is called from the main() loop, and runs BKE_ptcache_quick_cache_all(), this could become a performance issue, especially with duplis, should probably not call BKE_ptcache_quick_cache_all() all the time, even when not playing back animation.
(commits 27856 by Campbell from render25 branch)
2010-03-30 12:23:13 +00:00
Janne Karhu df7b696b73 Big cleanup of particle system core, also some minor pointcache cleanup. Shouldn't contain any functional changes. 2010-03-21 20:36:06 +00:00
Janne Karhu 979aa4e990 Point cache optimization: only cache particles that are alive.
This reduces point cache sizes dramatically especially if particle
life time is small compared to total simulation length. For example
with the settings: particle amount = 10000, start = 1, end = 200,
life = 10, cache step = 1, the unoptimized blend file size (compressed)
was a little over 22 Mb and with this optimization the file is a little
under 2 Mb (again compressed). In addition to saving memory/disk space
this also probably speeds up reading from cache, since there's less
data to read.

As an additional fix the memory cache size (displayed in cache panel)
is now calculated correctly.
2010-03-09 03:01:18 +00:00
Janne Karhu d1f19d7e84 Fix for [#19955] 2.5 Particles are calculated wrong when object has any transform animation
* The exact location of particle birth wasn't cached if cache step was greater than 1, so the interpolation from an unborn particle to a living one wasn't accurate at all.
* Although not ideal, the current solution is to copy the birth location to the previous cached frame so it's always exact. This should work properly for memory & disk cache.
* This fix shouldn't cause any problems, but exhaustive tests of caching are difficult so be sure to let me know if there's strange behavior.
2010-02-25 00:03:16 +00:00
Campbell Barton 081c1205a3 correct fsf address 2010-02-12 13:34:04 +00:00
Campbell Barton 70942f9a83 last commit was no good since pe_get_current was running recalc_emitter_field on mousemove and poll() functions.
run on entering particle editmode only.
2010-01-12 13:40:29 +00:00
Matt Ebb a358b6386d * Fix for incorrect disabling after baking cloth sim
* Fix for time cursor getting 'stuck' after baking point caches
2009-12-04 04:28:50 +00:00
Daniel Genrich 8e2d861695 Smoke:
* Enable cache for high res + new preview
* Bugfix for smoke banding (in cooperation with N_T)

Hint: Work-in-progress regarding collision objects so can be broken, didn't test

Hint2: jahka enabled a general particle panel but 
* bake button doesn't work
* step is not supported for cloth
* several other things there ;)
2009-09-09 18:39:40 +00:00