Commit Graph

93 Commits

Author SHA1 Message Date
Sergey Sharybin c1bc70b711 Cleanup: Add a copyright notice to files and use SPDX format
A lot of files were missing copyright field in the header and
the Blender Foundation contributed to them in a sense of bug
fixing and general maintenance.

This change makes it explicit that those files are at least
partially copyrighted by the Blender Foundation.

Note that this does not make it so the Blender Foundation is
the only holder of the copyright in those files, and developers
who do not have a signed contract with the foundation still
hold the copyright as well.

Another aspect of this change is using SPDX format for the
header. We already used it for the license specification,
and now we state it for the copyright as well, following the
FAQ:

    https://reuse.software/faq/
2023-05-31 16:19:06 +02:00
Monique Dewanchand 23276bcc37 Adding `const Scene*` parameter in many areas.
Related to {D15885} that requires scene parameter
to be added in many places. To speed up the review process
the adding of the scene parameter was added in a separate
patch.

Reviewed By: mont29

Maniphest Tasks: T73411

Differential Revision: https://developer.blender.org/D15930
2022-09-14 21:30:56 +02:00
Campbell Barton c434782e3a File headers: SPDX License migration
Use a shorter/simpler license convention, stops the header taking so
much space.

Follow the SPDX license specification: https://spdx.org/licenses

- C/C++/objc/objc++
- Python
- Shell Scripts
- CMake, GNUmakefile

While most of the source tree has been included

- `./extern/` was left out.
- `./intern/cycles` & `./intern/atomic` are also excluded because they
  use different header conventions.

doc/license/SPDX-license-identifiers.txt has been added to list SPDX all
used identifiers.

See P2788 for the script that automated these edits.

Reviewed By: brecht, mont29, sergey

Ref D14069
2022-02-11 09:14:36 +11:00
Campbell Barton 6483dee141 Cleanup: replace int with bool type 2021-12-07 18:15:15 +11:00
Campbell Barton ffc4c126f5 Cleanup: move public doc-strings into headers for 'blenkernel'
- Added space below non doc-string comments to make it clear
  these aren't comments for the symbols directly below them.
- Use doxy sections for some headers.
- Minor improvements to doc-strings.

Ref T92709
2021-12-07 17:38:48 +11:00
Campbell Barton f1e4903854 Cleanup: full sentences in comments, improve comment formatting 2021-06-26 21:50:48 +10:00
Alexander Gavrilov 78ff852680 Force Fields: implement early filtering by the Affect flags.
Most fields have Affect Location and Rotation options that switch
off their effect, but they are only checked as the last step after
the force is already computed. It is more efficient to check it
when building the list of field objects, just like zero weight.
It is also possible to check the strength-related fields for 0.

As an aside, this adds Location to Texture fields (they don't
handle rotation) and both Location & Rotation checkboxes to
Fluid Flow. Boid and Curve Guide remain without options for
now as they are completely different from others.

Differential Revision: https://developer.blender.org/D10087
2021-02-02 23:03:16 +03:00
Campbell Barton 525364be31 Cleanup: reduce indirect DNA header inclusion
Remove DNA headers, using forward declarations where possible.

Also removed duplicate header, header including it's self
and unnecessary inclusion of libc system headers from BKE header.
2020-12-15 12:34:14 +11:00
Jacques Lucke 91694b9b58 Code Style: use "#pragma once" in source directory
This replaces header include guards with `#pragma once`.
A couple of include guards are not removed yet (e.g. `__RNA_TYPES_H__`),
because they are used in other places.

This patch has been generated by P1561 followed by `make format`.

Differential Revision: https://developer.blender.org/D8466
2020-08-07 09:50:34 +02:00
Alexander Gavrilov 9e70129952 Cloth: allow forces to act parallel to cloth.
Currently all force effectors can only act on cloth when the force is
perpendicular to the surface. This makes sense for wind, but not for
other forces; and the user may want even wind to have some friction.

This changes effector code to output two force vectors - although
you of course can pass the same pointer for both. The force is split
between the two outputs based on a new per-effector setting.

Differential Revision: https://developer.blender.org/D8017
2020-06-19 12:17:02 +03:00
Jacques Lucke 5de56f9596 Cleanup: make remaining blenkernel headers work in C++ 2020-03-02 15:07:49 +01:00
Campbell Barton 60475b9549 Cleanup: remove various unused defines 2020-02-15 15:24:03 +11:00
Campbell Barton aa42da0385 Cleanup: comments (long lines) in blenkernel 2019-04-27 12:07:07 +10:00
Campbell Barton e12c08e8d1 ClangFormat: apply to source, most of intern
Apply clang format as proposed in T53211.

For details on usage and instructions for migrating branches
without conflicts, see:

https://wiki.blender.org/wiki/Tools/ClangFormat
2019-04-17 06:21:24 +02:00
Sergey Sharybin f2a21472c4 Fix T61473: Crash particle system is updating
Original and localized particle settings were sharing some
of the runtime pointers.
2019-02-18 17:00:50 +01:00
Campbell Barton de13d0a80c doxygen: add newline after \file
While \file doesn't need an argument, it can't have another doxy
command after it.
2019-02-18 08:22:12 +11:00
Campbell Barton eef4077f18 Cleanup: remove redundant doxygen \file argument
Move \ingroup onto same line to be more compact and
make it clear the file is in the group.
2019-02-06 15:45:22 +11:00
Campbell Barton 4ef09cf937 Cleanup: remove author/date info from doxy headers 2019-02-02 11:58:24 +11:00
Campbell Barton 65ec7ec524 Cleanup: remove redundant, invalid info from headers
BF-admins agree to remove header information that isn't useful,
to reduce noise.

- BEGIN/END license blocks

  Developers should add non license comments as separate comment blocks.
  No need for separator text.

- Contributors

  This is often invalid, outdated or misleading
  especially when splitting files.

  It's more useful to git-blame to find out who has developed the code.

See P901 for script to perform these edits.
2019-02-02 01:36:28 +11:00
Brecht Van Lommel 7400aa7e59 Depsgraph: remove features incompatible with new system.
Some features are incompatible with multithreading and reliable evaluation
of dependencies. We are now removing them as part of a bigger cleanup to
fix bugs in keyframing and invalid animation evaluations.

* Dupliframes have been removed. This was a hack added before there were
  more powerful features like the array modifier.
* Slow parent has been removed, never worked in 2.8. It was always
  unreliable for use in production due to depending on whatever frame was
  previously evaluated, which was not always the previous frame.
* Particle instanced objects used to have their transform evaluated at
  the particle time. Now it always gets the current time transform.
* Boids can no longer do predictive avoidance of force field objects,
  but still for other particles.

Differential Revision: https://developer.blender.org/D4274
2019-01-31 12:03:05 +01:00
Campbell Barton c0f88ed8a8 Cleanup: sort forward declarations of enum & struct
Done using:
  source/tools/utils_maintenance/c_sort_blocks.py
2019-01-28 21:17:58 +11:00
Campbell Barton 2e392a0fdc Merge branch 'master' into blender2.8 2018-12-02 14:16:09 +11:00
Campbell Barton c00e1f68e9 Cleanup: BKE_effect.h naming 2018-12-02 14:14:51 +11:00
Campbell Barton 18d87e79e9 Merge branch 'master' into blender2.8 2018-06-29 09:25:40 +02:00
Campbell Barton b372766816 Cleanup: trailing newlines 2018-06-29 09:23:51 +02:00
Brecht Van Lommel a99dcab148 Depsgraph: cache collision relations, for performance and stability.
Same reasoning as effector relations in earlier commit.
2018-06-25 13:35:41 +02:00
Brecht Van Lommel cc4dc2dce2 Depsgraph: cache effector relations, for performance and stability.
To find all effectors in the scene, we need to loop over all objects.
Doing this during depsgraph evaluation caused crashes because not all
objects are guaranteed to be evaluated yet.

To fix this, we now cache the relations as part of the dependency graph
build. As a bonus this also makes evaluation faster for big scenes,
since looping over all objects for each particle system is slow.

Fixes T55156.
2018-06-22 17:57:22 +02:00
Campbell Barton 06a1a66a9b Merge branch 'master' into blender2.8 2018-06-17 17:10:19 +02:00
Campbell Barton 6fc8a74886 Cleanup: trailing space for blenkernel 2018-06-17 17:05:51 +02:00
Brecht Van Lommel 17bd5c9d4b Collections and groups unification
OVERVIEW

* In 2.7 terminology, all layers and groups are now collection datablocks.
* These collections are nestable, linkable, instanceable, overrideable, ..
  which opens up new ways to set up scenes and link + override data.
* Viewport/render visibility and selectability are now a part of the collection
  and shared across all view layers and linkable.
* View layers define which subset of the scene collection hierarchy is excluded
  for each. For many workflows one view layer can be used, these are more of an
  advanced feature now.

OUTLINER

* The outliner now has a "View Layer" display mode instead of "Collections",
  which can display the collections and/or objects in the view layer.
* In this display mode, collections can be excluded with the right click menu.
  These will then be greyed out and their objects will be excluded.
* To view collections not linked to any scene, the "Blender File" display mode
  can be used, with the new filtering option to just see Colleciton datablocks.
* The outliner right click menus for collections and objects were reorganized.
* Drag and drop still needs to be improved. Like before, dragging the icon or
  text gives different results, we'll unify this later.

LINKING AND OVERRIDES

* Collections can now be linked into the scene without creating an instance,
  with the link/append operator or from the collections view in the outliner.
* Collections can get static overrides with the right click menu in the outliner,
  but this is rather unreliable and not clearly communicated at the moment.
* We still need to improve the make override operator to turn collection instances
  into collections with overrides directly in the scene.

PERFORMANCE

* We tried to make performance not worse than before and improve it in some
  cases. The main thing that's still a bit slower is multiple scenes, we have to
  change the layer syncing to only updated affected scenes.
* Collections keep a list of their parent collections for faster incremental
  updates in syncing and caching.
* View layer bases are now in a object -> base hash to avoid quadratic time
  lookups internally and in API functions like visible_get().

VERSIONING

* Compatibility with 2.7 files should be improved due to the new visibility
  controls. Of course users may not want to set up their scenes differently
  now to avoid having separate layers and groups.
* Compatibility with 2.8 is mostly there, and was tested on Eevee demo and Hero
  files. There's a few things which are know to be not quite compatible, like
  nested layer collections inside groups.
* The versioning code for 2.8 files is quite complicated, and isolated behind
  #ifdef so it can be removed at the end of the release cycle.

KNOWN ISSUES

* The G-key group operators in the 3D viewport were left mostly as is, they
  need to be modified still to fit better.
* Same for the groups panel in the object properties. This needs to be updated
  still, or perhaps replaced by something better.
* Collections must all have a unique name. Less restrictive namespacing is to
  be done later, we'll have to see how important this is as all objects within
  the collections must also have a unique name anyway.
* Full scene copy and delete scene are exactly doing the right thing yet.

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

https://code.blender.org/2018/05/collections-and-groups/
2018-05-18 13:34:24 +02:00
Brecht Van Lommel 34ab90f546 Depsgraph: remove EvaluationContext, pass Depsgraph instead.
The depsgraph was always created within a fixed evaluation context. Passing
both risks the depsgraph and evaluation context not matching, and it
complicates the Python API where we'd have to expose both which is not so
easy to understand.

This also removes the global evaluation context in main, which assumed there
to be a single active scene and view layer.

Differential Revision: https://developer.blender.org/D3152
2018-04-16 19:55:33 +02:00
Campbell Barton 1b462e5a51 Pass EvaluationContext instead of bContext
2.8x branch added bContext arg in many places,
pass eval-context instead since its not simple to reason about what
what nested functions do when they can access and change almost anything.

Also use const to prevent unexpected modifications.

This fixes crash loading files with shadows,
since off-screen buffers use a NULL context for rendering.
2017-08-16 12:46:04 +10:00
Luca Rood 1c4c288727 Pass EvaluationContext argument everywhere
Note that some little parts of code have been dissabled because eval_ctx
was not available there. This should be resolved once DerivedMesh is
replaced.
2017-07-21 14:47:26 +02:00
Lukas Tönne 6ecab6dd8e Revert particle system and point cache removal in blender2.8 branch.
This reverts commit 5aa19be912 and b4a721af69.

Due to postponement of particle system rewrite it was decided to put particle code
back into the 2.8 branch for the time being.
2016-12-28 17:30:58 +01:00
Dalai Felinto 605263177b Merge remote-tracking branch 'origin/master' into blender2.8 2016-12-23 15:36:16 +01:00
Lukas Tönne 4d5cd638ff String drawing function for the "simdebug" utilities.
Simple string drawing API for debug drawing, in addition to basic primitives.
2016-12-20 11:02:40 +01:00
Bastien Montagne 069569f820 Merge branch 'master' into blender2.8
In addition to pack of conflicts listed below, also had to comment out particle part of new Alembic code... :/

Conflicts:
	intern/ghost/intern/GHOST_WindowWin32.cpp
	source/blender/blenkernel/BKE_effect.h
	source/blender/blenkernel/BKE_pointcache.h
	source/blender/blenkernel/intern/cloth.c
	source/blender/blenkernel/intern/depsgraph.c
	source/blender/blenkernel/intern/dynamicpaint.c
	source/blender/blenkernel/intern/effect.c
	source/blender/blenkernel/intern/particle_system.c
	source/blender/blenkernel/intern/pointcache.c
	source/blender/blenkernel/intern/rigidbody.c
	source/blender/blenkernel/intern/smoke.c
	source/blender/blenkernel/intern/softbody.c
	source/blender/depsgraph/intern/builder/deg_builder_relations.cc
	source/blender/gpu/intern/gpu_debug.c
	source/blender/makesdna/DNA_object_types.h
	source/blender/makesrna/intern/rna_particle.c
2016-08-21 13:18:26 +02:00
Alexander Gavrilov 9368bdab01 Fix depsgraph to compute more accurate links for collision & force.
Current implementation more or less indiscriminately links physics
objects to colliders and forces, ignoring precise details of layer
checks and collider groups. The new depsgraph seemed to lack some
such links at all. The relevant code in modifiers suffers from a
lot of duplication.

Different physics simulations use independent implementations of
collision and similar things, which results in a lot of variance:

* Cloth collides with objects on same or visible layer with dupli.
* Softbody collides with objects on same layer without dupli.
* Non-hair particles collide on same layer with dupli.
* Smoke uses same code as cloth, but needs different modifier.
* Dynamic paint "collides" with brushes on any layer without dupli.

Force fields with absorption also imply dependency on colliders:

* For most systems, colliders are selected from same layer as field.
* For non-hair particles, it uses the same exact set as the particles.

As a special quirk, smoke ignores smoke flow force fields; on the other
hand dependency on such field implies dependency on the smoke domain.

This introduces two utility functions each for old and new depsgraph
that are flexible enough to handle all these variations, and uses them
to handle particles, cloth, smoke, softbody and dynpaint.

One thing to watch out for is that depsgraph code shouldn't rely on
any properties that don't cause a graph rebuild when changed. This
was violated in the original code that was building force field links,
while taking zero field weights into account.

This change may cause new dependency cycles in cases where necessary
dependencies were missing, but may also remove cycles in situations
where unnecessary links were previously created. It's also now possible
to solve some cycles by switching to explicit groups, since they are
now properly taken into account for dependencies.

Differential Revision: https://developer.blender.org/D2141
2016-08-16 15:46:36 +03:00
Lukas Tönne df2e543d44 Removed some unused declarations for boids code. 2016-04-16 11:11:39 +02:00
Lukas Tönne 987bb50a74 Removed remaining use of pointers to particle types as well as boids headers. 2016-04-13 18:10:23 +02:00
Lukas Tönne 664f5b8c06 Removed particle DNA. 2016-04-13 13:41:11 +02:00
Lukas Tönne d47173c8ca Removed blenkernel particle code. 2016-04-13 10:49:39 +02:00
Campbell Barton b1d758ae6b Cleanup: redundant struct declarations 2015-03-29 03:56:39 +11: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
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 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 d43f760892 Hair debugging: use "categories" (strings) for grouping debug elements
and support clearing for categories.
2015-01-20 09:29:56 +01:00
Lukas Tönne 1ed88bb24e Partial response force for hair collisions.
This implements a penalty force as well as a repulsion force to avoid
further penetration, as suggested in
"Simulating Complex Hair with Robust Collision Handling"
(http://graphics.snu.ac.kr/publications/2005-choe-HairSim/Choe_2005_SCA.pdf)

Friction forces are still missing. More problematic is handling of
moving colliders, when face swap places with the hair vertex and a
collision is missed, putting the vertex inside the mesh volume. Larger
margins might help, but ultimately using Bullet collision detection is
probably more reliable and failsafe.
2015-01-20 09:29:56 +01:00
Lukas Tönne d8cf12fe5a Debug drawing for simulations, to aid in visualizing abstract data such
as forces, velocities, contact points etc.

This uses a hash table to store debug elements (dots, lines, vectors at
this point). The hash table allows continuous display of elements that
are generated only in certain time steps, e.g. contact points, while
avoiding massive memory allocation. In any case, this system is really
a development feature, but very helpful in finding issues with the
internal solver data.
2015-01-20 09:29:56 +01:00
Lukas Tönne 30c9fe19a3 Fix for crash caused by effectors doing precalculation //during// DAG
updates.

This file crashes on loading with NULL pointer access to curve_cache:
{F77132}

The pdInitEffectors function was amalgamating the simple
collection of effector objects with an automatic precalculation for
curve guides and the like. This precalculation requires object data
that may not be available until the DAG has finished.

Since for DAG dependencies only the list of effectors is required,
added an argument to disable precalculation when collecting effectors.
2014-02-14 12:58:43 +01:00