Commit Graph

80 Commits

Author SHA1 Message Date
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
Jeroen Bakker 048c5580c2 Revert "CleanUp: Introduce `eMeshBatchDirtyMode` enum"
This reverts commit 0796807720.
2020-10-09 07:25:43 +02:00
Bastien Montagne 253dbe71dc Refactor: remove `BKE_<id_type>_copy` functions.
Those were only shallow wrappers around `BKE_id_copy`, barely used (even
fully unused in some cases), and we want to get rid of those ID-specific
helpers for the common ID management tasks. Also prevents weird custom
behaviors (like `BKE_object_copy`, who was the only basic ID copy
function to reset user count of the new copy to zero).

Part of 71219.
2020-10-07 18:05:06 +02:00
Jeroen Bakker 0796807720 CleanUp: Introduce `eMeshBatchDirtyMode` enum
It used to be an `int mode`.
2020-10-07 16:18:12 +02: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
Bastien Montagne da7fcd3e52 Cleanup: MetaBall: Move to IDTypeInfo and remove unused BKE API. 2020-03-06 16:23:23 +01:00
Bastien Montagne 4bfa256ea4 Refactor ID make local to use a single flag parameter.
Instead of using anonymous booleans flags, also allows to keep the same
behavior in all cases, without needing special handling from calling
code for our beloved oddballs object proxies...
2020-03-04 11:43:31 +01:00
Jacques Lucke 5de56f9596 Cleanup: make remaining blenkernel headers work in C++ 2020-03-02 15:07:49 +01:00
Campbell Barton adfb9ec87c Cleanup: const args, naming, doxy groups, clang-format 2019-08-23 09:09:38 +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
Campbell Barton 40f8ddf829 3D View: move deselect all logic into an option
This removes `VIEW3D_OT_select_or_deselect_all`, adding a
deselect_all option to the `VIEW3D_OT_select` operator.

- Add utility functions to simplify de-selecting all.

- Return true from selection functions when they change the selection
  to avoid redundant updates.

- Use arrays of bases when passing objects between selection utility
  functions since some users require bases.

- Fix logical error in box selection that updated all objects after
  the first hit.
2019-03-26 20:25:25 +11:00
Campbell Barton 085e9e3bed Cleanup: move variable declarations to headers
Quiet undeclared variable warning.
2019-02-23 12:59:13 +11: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
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 0b837a4986 Cleanup: style, use const args 2018-11-08 08:02:09 +11:00
Habib Gahbiche 5f8d369495 Multi-Objects: MBALL_OT_select_similar
Compared to previous implementation, the following has been changed:
* Threshold: is now an absolute value. This allows a comparison with e.g. radii
  that are much larger than selected radius. This is also consistent with
  `CURVE_OT_select_similar`

* Radius in world space is the average of the radius scaled in x, y and z
  directions
* Since MetaBalls are symmetrical, rotation is only considered from 0 to π/2.
  So for example rotations of 90° and -90° are considered equal.
  This is also consistent with the way `CURVE_OT_select_similar` works.

Fix/changes from committer (Dalai Felinto):
* Drawing not updating after changes. (see original patch for details).

Reviewers: dfelinto
Differential Revision: https://developer.blender.org/D3895
2018-11-07 00:15:39 -02:00
Dalai Felinto 0a893c0901 Multi-Objects: MBALL_OT_select_all
Based on D3893 by Habib Gahbiche.
2018-11-06 23:32:49 -02:00
Bastien Montagne a6b65c75cd Fix T56360: metaball viewport checkbox crash.
Do same as for other geometry types to compute bbox, instead of blindly
returning NULL `ob->bb`...
2018-08-23 21:40:43 +02:00
Dalai Felinto 613523d5f5 Rename: *_batch_cache_dirty > *_batch_cache_dirty_tag 2018-08-23 10:20:16 -03:00
Sergey Sharybin 180e8f8bfb Depsgraph: Remove confusing metaball logic
DATA datablock must evaluation must never depend on object it is
used for. If there is something what depends on an object, it must
be done on object level.

At least the actual callback was empty.
2018-06-06 12:36:51 +02:00
Campbell Barton f897d95372 EditMBall: multi-object select random
D3356 by @Quetzal
2018-05-12 22:16:09 +02:00
Germano e4774c0b2d Metaball: pointers used in `DRW_shgroup_call_dynamic_add` don't need to hold the reference. 2018-05-02 21:26:43 -03: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
Germano fa0e89b9e8 Metalball drawing: rename mball helpers to handles
and also rename some related functions
2018-02-16 02:01:09 -02:00
Germano 88c88c4610 Fix T51210: Draw Manager: Support for Metaball Drawing
Differential Revision: D2914
2017-11-16 15:12:32 -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
Campbell Barton 30e83d58ff Object Apply Transform: option to apply properties
In some cases users may want to disable this option
to avoid changing other properties besides vertex locations.
2017-08-11 22:32:07 +10: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
Bastien Montagne eeb9e5316a Make whole ID copying code use const source pointer.
Noisy change, but safe, and better do it sooner than later if we are to
rework copying code. Also, previous commit shows this *is* useful to
catch some mistakes.
2017-06-14 22:38:11 +02:00
Bastien Montagne d8d4bef6cc Refactor/deduplicate even more make_local code (and fix part of T48907).
Turns out most BKE_foo_make_local datablock-specific functions are actually doing
exactly the same thing, only two currently need special additional operations
(object and brush ones). So added a BKE_id_make_local_generic instead
of copying same code over and over.

Also, changed a bit how make_local works in case we are localizing a whole library.
We need to do the 'remap' step (from old linked ID to new local one) in the second loop,
otherwise we miss some dependencies. This fixes main part of T48907.
2016-07-21 16:54:36 +02:00
Bastien Montagne f87603662d Add option to id_make_local to force localization of datablock, even if not used locally.
Will be used by link/append code.
2016-07-14 18:33:12 +02:00
Bastien Montagne 87b974caa1 Cleanup/Refactor: pass Main pointer to all ID copy functions.
Also allows us to get rid of a few _copy_ex() versions...
2016-07-10 14:52:00 +02:00
Bastien Montagne 338121e2a0 Refactor/enhance BKE_mball_make_local(), and add BKE_mball_copy_ex() that takes a Main as parameter.
Now using modern features from libquery/libremap areas.

Provides same kind of fixes/improvements as for BKE_object_make_local() (see rBd1a4ae3f395a6).
2016-07-09 15:44:12 +02:00
Bastien Montagne 897e97f078 ID-Remap - Step one: core work (cleanup and rework of generic ID datablock handling).
This commit changes a lot of how IDs are handled internally, especially the unlinking/freeing
processes. So far, this was very fuzy, to summarize cleanly deleting or replacing a datablock
was pretty much impossible, except for a few special cases.

Also, unlinking was handled by each datatype, in a rather messy and prone-to-errors way (quite
a few ID usages were missed or wrongly handled that way).

One of the main goal of id-remap branch was to cleanup this, and fatorize ID links handling
by using library_query utils to allow generic handling of those, which is now the case
(now, generic ID links handling is only "knwon" from readfile.c and library_query.c).

This commit also adds backends to allow live replacement and deletion of datablocks in Blender
(so-called 'remapping' process, where we replace all usages of a given ID pointer by a new one,
or NULL one in case of unlinking).

This will allow nice new features, like ability to easily reload or relocate libraries, real immediate
deletion of datablocks in blender, replacement of one datablock by another, etc.
Some of those are for next commits.

A word of warning: this commit is highly risky, because it affects potentially a lot in Blender core.
Though it was tested rather deeply, being totally impossible to check all possible ID usage cases,
it's likely there are some remaining issues and bugs in new code... Please report them! ;)

Review task: D2027 (https://developer.blender.org/D2027).
Reviewed by campbellbarton, thanks a bunch.
2016-06-22 17:53:50 +02:00
Bastien Montagne e5916187e8 First step to handle missing libs/datablocks when reading a file.
Idea is, instead of ignoring completely missing linked datablocks, to
create void placeholders for them.

That way, you can work on your file, save it, and find again your missing data once
lib becomes available again. Or you can edit missing lib's path (in Outliner),
save and reload the file, and you are done.

Also, Outliner now shows broken libraries (and placeholders) with a 'broken lib' icon.

Future plans are also to be able to relocate missing libs and reload them at runtime.

Code notes:
    - Placeholder ID is just a regular datablock of same type as expected linked one,
      with 'default' data, and a LIB_MISSING bitflag set.
    - To allow creation of such datablocks, creation of datablocks in BKE was split in two step:
        + Allocation of memory itself.
        + Setting of all internal data to default values.

See also the design task (T43351).

Reviewed by @campbellbarton, thanks a bunch!

Differential Revision: https://developer.blender.org/D1394
2015-10-20 14:44:57 +02:00
Sergey Sharybin a09341469e Depsgraph: Add evaluation callbacks for granular nodes update
This commit only adds callbacks which then later be used with major dependency
graph commit, keeping the upcoming commit more clean to follow.

Should be no functional changes so far still.
2015-05-12 16:06:37 +05:00
Krzysztof Recko 98f4106694 Metaball tessellation optimization (Octree to BVH)
Speedup is non-linear, 2x-10x faster is quite normal.
Patch T43678.

- Switched from an Octree to BVH.
- Finding first points of surface no longer "wastes" density function evaluation: every result is cached.
- Use MemArena instead of using own memory management.
- Correct calculation of metaelem bounding box.
- Remove mball_count(): mballs are now counted "on the go".
2015-04-07 13:19:50 +10:00
Campbell Barton b1d758ae6b Cleanup: redundant struct declarations 2015-03-29 03:56:39 +11:00
Campbell Barton 7bc8ddc6e2 use BKE_mball_tessellate.h include
also remove unused includes
2015-03-25 22:40:09 +11:00
Campbell Barton e8f3fa99de Support more object types scene-scale (on creation)
- lamp
- camera
- font
- empty & effector

Also fix inconsistency with apply transform
(modified shape-keys for meshes but not curve/lattice)
2014-09-01 21:01:11 +10:00
Sergey Sharybin 709041ed0b Threaded object update and EvaluationContext
Summary:
Made objects update happening from multiple threads. It is a task-based
scheduling system which uses current dependency graph for spawning new
tasks. This means threading happens on object level, but the system is
flexible enough for higher granularity.

Technical details:

- Uses task scheduler which was recently committed to trunk
  (that one which Brecht ported from Cycles).

- Added two utility functions to dependency graph:
  * DAG_threaded_update_begin, which is called to  initialize threaded
    objects update. It will also schedule root DAG node to the queue,
    hence starting evaluation process.

    Initialization will calculate how much parents are to be evaluation
    before current DAG node can be scheduled. This value is used by task
    threads for faster detecting which nodes might be scheduled.

  * DAG_threaded_update_handle_node_updated which is  called from task
    thread function when node was fully handled.

	This function decreases num_pending_parents of node children and
	schedules children with zero valency.

    As it might have become clear, task thread receives DAG nodes and
    decides which callback to call for it.

    Currently only BKE_object_handle_update is called for object nodes.

    In the future it'll call node->callback() from Ali's new DAG.

- This required adding some workarounds to the render pipeline.
  Mainly to stop using get_object_dm() from modifiers' apply callback.
  Such a call was only a workaround for dependency graph glitch when
  rendering scene with, say, boolean modifiers before displaying
  this scene.

  Such change moves workaround from one place to another, so overall
  hackentropy remains the same.

- Added paradigm of EvaluaitonContext. Currently it's more like just a
  more reliable replacement for G.is_rendering which fails in some
  circumstances.

  Future idea of this context is to also store all the local data needed
  for objects evaluation such as local time, Copy-on-Write data and so.

  There're two types of EvaluationContext:

  * Context used for viewport updated and owned by Main. In the future
    this context might be easily moved to Window or Screen to allo
    per-window/per-screen local time.

  * Context used by render engines to evaluate objects for render purposes.
    Render engine is an owner of this context.

  This context is passed to all object update routines.

Reviewers: brecht, campbellbarton

Reviewed By: brecht

CC: lukastoenne

Differential Revision: https://developer.blender.org/D94
2013-12-26 17:24:42 +06:00
Sergey Sharybin 26c34fc29f Merge remained parts of r57520: use use_render argument rather than G.is_rendering 2013-08-19 11:04:32 +00:00
Campbell Barton b6ffc681b1 view-selected didnt work for metaballs in object mode (radius from previous commit was 2x too large too). 2013-06-28 18:19:55 +00:00
Campbell Barton 221a383366 use 'bool' for BLI_/BKE_ functions. 2013-03-09 05:35:49 +00:00
Sergey Sharybin fdfa5910b5 Fix #34040: Moving Normal Node with enabled Cycles Material Preview crashes
Issue was caused by couple of circumstances:

- Normal Map node requires tesselated faces to compute tangent space
- All temporary meshes needed for Cycles export were adding to G.main
- Undo pushes would temporary set meshes tessfaces to NULL
- Moving node will cause undo push and tree re-evaluate fr preview

All this leads to threading conflict between preview render and undo
system.

Solved it in  way that all temporary meshes are adding to that exact
Main which was passed to Cycles via BlendData. This required couple
of mechanic changes like adding extra parameter to *_add() functions
and adding some *_ex() functions to make it possible RNA adds objects
to Main passed to new() RNA function.

This was tricky to pass Main to RNA function and IMO that's not so
nice to pass main to function, so ended up with such decision:

- Object.to_mesh() will add temp mesh to G.main
- Added Main.meshes.new_from_object() which does the same as to_mesh,
  but adds temporary mesh to specified Main.

So now all temporary meshes needed for preview render would be added
to preview_main which does not conflict with undo pushes.

Viewport render shall not be an issue because object sync happens from
main thread in this case.

It could be some issues with final render, but that's not so much
likely to happen, so shall be fine.

Thanks to Brecht for review!
2013-02-05 12:46:15 +00:00
Campbell Barton b26ccf0aff toggle cut through in the knife tool now refreshes (before you had to wave the mouse about to see the result).
also remove print from last commit.
2012-10-06 03:34:52 +00:00
Campbell Barton c4472bbab6 add mball_foreachScreenElem() and use for lasso & circle selection, also utility metaball functions to (de)select all. 2012-10-06 03:02:14 +00:00