2023-08-16 00:20:26 +10:00
|
|
|
/* SPDX-FileCopyrightText: 2013 Blender Authors
|
2023-05-31 16:19:06 +02:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
2013-03-23 03:00:37 +00:00
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup bke
|
2013-03-23 03:00:37 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
2018-08-29 15:32:50 +02:00
|
|
|
#include "DNA_collection_types.h"
|
2013-03-23 03:00:37 +00:00
|
|
|
#include "DNA_freestyle_types.h"
|
|
|
|
|
|
|
|
|
|
#include "BLI_blenlib.h"
|
Cleanup: reduce amount of math-related includes
Using ClangBuildAnalyzer on the whole Blender build, it was pointing
out that BLI_math.h is the heaviest "header hub" (i.e. non tiny file
that is included a lot).
However, there's very little (actually zero) source files in Blender
that need "all the math" (base, colors, vectors, matrices,
quaternions, intersection, interpolation, statistics, solvers and
time). A common use case is source files needing just vectors, or
just vectors & matrices, or just colors etc. Actually, 181 files
were including the whole math thing without needing it at all.
This change removes BLI_math.h completely, and instead in all the
places that need it, includes BLI_math_vector.h or BLI_math_color.h
and so on.
Change from that:
- BLI_math_color.h was included 1399 times -> now 408 (took 114.0sec
to parse -> now 36.3sec)
- BLI_simd.h 1403 -> 418 (109.7sec -> 34.9sec).
Full rebuild of Blender (Apple M1, Xcode, RelWithDebInfo) is not
affected much (342sec -> 334sec). Most of benefit would be when
someone's changing BLI_simd.h or BLI_math_color.h or similar files,
that now there's 3x fewer files result in a recompile.
Pull Request #110944
2023-08-09 11:39:20 +03:00
|
|
|
#include "BLI_math_rotation.h"
|
2023-10-18 17:15:30 +02:00
|
|
|
#include "BLI_string_utils.hh"
|
2013-03-23 03:00:37 +00:00
|
|
|
|
2023-09-04 16:16:26 +02:00
|
|
|
#include "BLT_translation.h"
|
|
|
|
|
|
2017-11-14 17:23:40 +11:00
|
|
|
#include "BKE_freestyle.h"
|
2024-01-15 12:44:04 -05:00
|
|
|
#include "BKE_lib_id.hh"
|
2017-11-14 17:23:40 +11:00
|
|
|
#include "BKE_linestyle.h"
|
|
|
|
|
|
2021-08-31 13:36:28 +10:00
|
|
|
/* Function declarations. */
|
2013-03-26 08:05:56 +00:00
|
|
|
static FreestyleLineSet *alloc_lineset(void);
|
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
|
|
|
static void copy_lineset(FreestyleLineSet *new_lineset, FreestyleLineSet *lineset, const int flag);
|
2013-03-26 08:05:56 +00:00
|
|
|
static FreestyleModuleConfig *alloc_module(void);
|
2013-03-23 03:00:37 +00:00
|
|
|
static void copy_module(FreestyleModuleConfig *new_module, FreestyleModuleConfig *module);
|
|
|
|
|
|
|
|
|
|
void BKE_freestyle_config_init(FreestyleConfig *config)
|
|
|
|
|
{
|
|
|
|
|
config->mode = FREESTYLE_CONTROL_EDITOR_MODE;
|
|
|
|
|
|
2014-02-08 06:07:10 +11:00
|
|
|
BLI_listbase_clear(&config->modules);
|
2013-03-23 03:00:37 +00:00
|
|
|
config->flags = 0;
|
2013-09-08 17:56:04 +00:00
|
|
|
config->sphere_radius = 0.1f;
|
2013-03-23 03:00:37 +00:00
|
|
|
config->dkr_epsilon = 0.0f;
|
|
|
|
|
config->crease_angle = DEG2RADF(134.43f);
|
|
|
|
|
|
2014-02-08 06:07:10 +11:00
|
|
|
BLI_listbase_clear(&config->linesets);
|
2013-03-23 03:00:37 +00:00
|
|
|
}
|
|
|
|
|
|
2017-12-26 13:31:45 -02:00
|
|
|
void BKE_freestyle_config_free(FreestyleConfig *config, const bool do_id_user)
|
2013-03-23 03:00:37 +00:00
|
|
|
{
|
2023-08-04 08:51:13 +10:00
|
|
|
LISTBASE_FOREACH (FreestyleLineSet *, lineset, &config->linesets) {
|
2013-03-23 03:00:37 +00:00
|
|
|
if (lineset->group) {
|
2017-12-26 13:31:45 -02:00
|
|
|
if (do_id_user) {
|
|
|
|
|
id_us_min(&lineset->group->id);
|
|
|
|
|
}
|
2023-07-17 10:46:26 +02:00
|
|
|
lineset->group = nullptr;
|
2013-03-23 03:00:37 +00:00
|
|
|
}
|
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-04-30 15:57:22 +02:00
|
|
|
if (lineset->linestyle) {
|
2013-03-23 03:00:37 +00:00
|
|
|
if (do_id_user) {
|
|
|
|
|
id_us_min(&lineset->linestyle->id);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2023-07-17 10:46:26 +02:00
|
|
|
lineset->linestyle = nullptr;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
}
|
2014-02-08 06:07:10 +11:00
|
|
|
BLI_freelistN(&config->linesets);
|
|
|
|
|
BLI_freelistN(&config->modules);
|
2013-03-23 03:00:37 +00:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
void BKE_freestyle_config_copy(FreestyleConfig *new_config,
|
|
|
|
|
const FreestyleConfig *config,
|
|
|
|
|
const int flag)
|
2013-03-23 03:00:37 +00:00
|
|
|
{
|
2023-08-04 08:51:13 +10:00
|
|
|
FreestyleLineSet *new_lineset;
|
|
|
|
|
FreestyleModuleConfig *new_module;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-03-23 03:00:37 +00:00
|
|
|
new_config->mode = config->mode;
|
|
|
|
|
new_config->flags = config->flags;
|
|
|
|
|
new_config->sphere_radius = config->sphere_radius;
|
|
|
|
|
new_config->dkr_epsilon = config->dkr_epsilon;
|
|
|
|
|
new_config->crease_angle = config->crease_angle;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-03-23 03:00:37 +00:00
|
|
|
BLI_listbase_clear(&new_config->linesets);
|
2023-08-04 08:51:13 +10:00
|
|
|
LISTBASE_FOREACH (FreestyleLineSet *, lineset, &config->linesets) {
|
2013-03-23 03:00:37 +00:00
|
|
|
new_lineset = alloc_lineset();
|
|
|
|
|
copy_lineset(new_lineset, lineset, flag);
|
|
|
|
|
BLI_addtail(&new_config->linesets, (void *)new_lineset);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
2016-09-18 21:36:34 +02:00
|
|
|
BLI_listbase_clear(&new_config->modules);
|
2023-08-04 08:51:13 +10:00
|
|
|
LISTBASE_FOREACH (FreestyleModuleConfig *, module, &config->modules) {
|
2013-03-23 03:00:37 +00:00
|
|
|
new_module = alloc_module();
|
|
|
|
|
copy_module(new_module, module);
|
|
|
|
|
BLI_addtail(&new_config->modules, (void *)new_module);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
}
|
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
|
|
|
|
|
|
|
|
static void copy_lineset(FreestyleLineSet *new_lineset, FreestyleLineSet *lineset, const int flag)
|
2019-04-17 06:17:24 +02:00
|
|
|
{
|
2015-03-19 14:33:05 +11:00
|
|
|
new_lineset->linestyle = lineset->linestyle;
|
2013-03-23 03:00:37 +00:00
|
|
|
new_lineset->flags = lineset->flags;
|
|
|
|
|
new_lineset->selection = lineset->selection;
|
|
|
|
|
new_lineset->qi = lineset->qi;
|
|
|
|
|
new_lineset->qi_start = lineset->qi_start;
|
|
|
|
|
new_lineset->qi_end = lineset->qi_end;
|
|
|
|
|
new_lineset->edge_types = lineset->edge_types;
|
|
|
|
|
new_lineset->exclude_edge_types = lineset->exclude_edge_types;
|
|
|
|
|
new_lineset->group = lineset->group;
|
2023-06-19 20:06:55 +10:00
|
|
|
STRNCPY(new_lineset->name, lineset->name);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
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
|
|
|
if ((flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0) {
|
|
|
|
|
id_us_plus((ID *)new_lineset->linestyle);
|
|
|
|
|
id_us_plus((ID *)new_lineset->group);
|
|
|
|
|
}
|
2013-03-23 03:00:37 +00:00
|
|
|
}
|
|
|
|
|
|
2023-07-18 14:18:07 +10:00
|
|
|
static FreestyleModuleConfig *alloc_module()
|
2013-03-23 03:00:37 +00:00
|
|
|
{
|
|
|
|
|
return (FreestyleModuleConfig *)MEM_callocN(sizeof(FreestyleModuleConfig),
|
|
|
|
|
"style module configuration");
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-13 11:50:54 +09:00
|
|
|
FreestyleModuleConfig *BKE_freestyle_module_add(FreestyleConfig *config)
|
2013-03-23 03:00:37 +00:00
|
|
|
{
|
|
|
|
|
FreestyleModuleConfig *module_conf = alloc_module();
|
|
|
|
|
BLI_addtail(&config->modules, (void *)module_conf);
|
2023-07-17 10:46:26 +02:00
|
|
|
module_conf->script = nullptr;
|
2013-03-23 03:00:37 +00:00
|
|
|
module_conf->is_displayed = 1;
|
2014-05-13 11:50:54 +09:00
|
|
|
return module_conf;
|
2013-03-23 03:00:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void copy_module(FreestyleModuleConfig *new_module, FreestyleModuleConfig *module)
|
|
|
|
|
{
|
2013-04-03 00:00:29 +00:00
|
|
|
new_module->script = module->script;
|
2013-03-23 03:00:37 +00:00
|
|
|
new_module->is_displayed = module->is_displayed;
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-13 11:50:54 +09:00
|
|
|
bool BKE_freestyle_module_delete(FreestyleConfig *config, FreestyleModuleConfig *module_conf)
|
2013-03-23 03:00:37 +00:00
|
|
|
{
|
2019-04-22 09:39:35 +10:00
|
|
|
if (BLI_findindex(&config->modules, module_conf) == -1) {
|
2014-05-13 11:50:54 +09:00
|
|
|
return false;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2013-03-23 03:00:37 +00:00
|
|
|
BLI_freelinkN(&config->modules, module_conf);
|
2014-05-13 11:50:54 +09:00
|
|
|
return true;
|
2013-03-23 03:00:37 +00:00
|
|
|
}
|
|
|
|
|
|
2016-09-18 21:36:34 +02:00
|
|
|
bool BKE_freestyle_module_move(FreestyleConfig *config,
|
|
|
|
|
FreestyleModuleConfig *module_conf,
|
|
|
|
|
int direction)
|
2013-03-23 03:00:37 +00:00
|
|
|
{
|
2016-09-18 21:36:34 +02:00
|
|
|
return ((BLI_findindex(&config->modules, module_conf) > -1) &&
|
|
|
|
|
(BLI_listbase_link_move(&config->modules, module_conf, direction) == true));
|
2013-03-23 03:00:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BKE_freestyle_lineset_unique_name(FreestyleConfig *config, FreestyleLineSet *lineset)
|
|
|
|
|
{
|
|
|
|
|
BLI_uniquename(&config->linesets,
|
|
|
|
|
lineset,
|
|
|
|
|
"FreestyleLineSet",
|
|
|
|
|
'.',
|
|
|
|
|
offsetof(FreestyleLineSet, name),
|
|
|
|
|
sizeof(lineset->name));
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-18 14:18:07 +10:00
|
|
|
static FreestyleLineSet *alloc_lineset()
|
2013-03-23 03:00:37 +00:00
|
|
|
{
|
|
|
|
|
return (FreestyleLineSet *)MEM_callocN(sizeof(FreestyleLineSet), "Freestyle line set");
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-20 11:30:25 +10:00
|
|
|
FreestyleLineSet *BKE_freestyle_lineset_add(Main *bmain, FreestyleConfig *config, const char *name)
|
2013-03-23 03:00:37 +00:00
|
|
|
{
|
2014-11-16 13:57:58 +01:00
|
|
|
int lineset_index = BLI_listbase_count(&config->linesets);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-03-23 03:00:37 +00:00
|
|
|
FreestyleLineSet *lineset = alloc_lineset();
|
|
|
|
|
BLI_addtail(&config->linesets, (void *)lineset);
|
|
|
|
|
BKE_freestyle_lineset_set_active_index(config, lineset_index);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-09-04 16:16:26 +02:00
|
|
|
lineset->linestyle = BKE_linestyle_new(bmain, DATA_("LineStyle"));
|
2013-03-23 03:00:37 +00:00
|
|
|
lineset->flags |= FREESTYLE_LINESET_ENABLED;
|
|
|
|
|
lineset->selection = FREESTYLE_SEL_VISIBILITY | FREESTYLE_SEL_EDGE_TYPES |
|
|
|
|
|
FREESTYLE_SEL_IMAGE_BORDER;
|
|
|
|
|
lineset->qi = FREESTYLE_QI_VISIBLE;
|
|
|
|
|
lineset->qi_start = 0;
|
|
|
|
|
lineset->qi_end = 100;
|
|
|
|
|
lineset->edge_types = FREESTYLE_FE_SILHOUETTE | FREESTYLE_FE_BORDER | FREESTYLE_FE_CREASE;
|
|
|
|
|
lineset->exclude_edge_types = 0;
|
2023-07-17 10:46:26 +02:00
|
|
|
lineset->group = nullptr;
|
2014-05-11 17:50:16 +09:00
|
|
|
if (name) {
|
2023-05-09 12:50:37 +10:00
|
|
|
STRNCPY(lineset->name, name);
|
2014-05-11 17:50:16 +09:00
|
|
|
}
|
|
|
|
|
else if (lineset_index > 0) {
|
2023-09-04 16:16:26 +02:00
|
|
|
SNPRINTF(lineset->name, DATA_("LineSet %i"), lineset_index + 1);
|
2014-05-11 17:50:16 +09:00
|
|
|
}
|
|
|
|
|
else {
|
2023-09-04 16:16:26 +02:00
|
|
|
STRNCPY(lineset->name, DATA_("LineSet"));
|
2014-05-11 17:50:16 +09:00
|
|
|
}
|
2013-03-23 03:00:37 +00:00
|
|
|
BKE_freestyle_lineset_unique_name(config, lineset);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-03-23 03:00:37 +00:00
|
|
|
return lineset;
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-10 23:32:22 +09:00
|
|
|
bool BKE_freestyle_lineset_delete(FreestyleConfig *config, FreestyleLineSet *lineset)
|
|
|
|
|
{
|
2019-04-22 09:39:35 +10:00
|
|
|
if (BLI_findindex(&config->linesets, lineset) == -1) {
|
2014-05-10 23:32:22 +09:00
|
|
|
return false;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2014-05-10 23:32:22 +09:00
|
|
|
if (lineset->group) {
|
2015-11-09 19:47:10 +01:00
|
|
|
id_us_min(&lineset->group->id);
|
2014-05-10 23:32:22 +09:00
|
|
|
}
|
|
|
|
|
if (lineset->linestyle) {
|
2015-11-09 19:47:10 +01:00
|
|
|
id_us_min(&lineset->linestyle->id);
|
2014-05-10 23:32:22 +09:00
|
|
|
}
|
|
|
|
|
BLI_remlink(&config->linesets, lineset);
|
|
|
|
|
MEM_freeN(lineset);
|
2014-05-11 17:48:55 +09:00
|
|
|
BKE_freestyle_lineset_set_active_index(config, 0);
|
2014-05-10 23:32:22 +09:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-23 03:00:37 +00:00
|
|
|
FreestyleLineSet *BKE_freestyle_lineset_get_active(FreestyleConfig *config)
|
|
|
|
|
{
|
2023-08-04 08:51:13 +10:00
|
|
|
LISTBASE_FOREACH (FreestyleLineSet *, lineset, &config->linesets) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if (lineset->flags & FREESTYLE_LINESET_CURRENT) {
|
2013-03-23 03:00:37 +00:00
|
|
|
return lineset;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2013-03-23 03:00:37 +00:00
|
|
|
}
|
2023-07-17 10:46:26 +02:00
|
|
|
return nullptr;
|
2013-03-23 03:00:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
short BKE_freestyle_lineset_get_active_index(FreestyleConfig *config)
|
|
|
|
|
{
|
|
|
|
|
FreestyleLineSet *lineset;
|
|
|
|
|
short i;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-03-23 03:00:37 +00:00
|
|
|
for (lineset = (FreestyleLineSet *)config->linesets.first, i = 0; lineset;
|
|
|
|
|
lineset = lineset->next, i++)
|
|
|
|
|
{
|
2019-04-22 09:39:35 +10:00
|
|
|
if (lineset->flags & FREESTYLE_LINESET_CURRENT) {
|
2013-03-23 03:00:37 +00:00
|
|
|
return i;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2013-03-23 03:00:37 +00:00
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BKE_freestyle_lineset_set_active_index(FreestyleConfig *config, short index)
|
|
|
|
|
{
|
|
|
|
|
FreestyleLineSet *lineset;
|
|
|
|
|
short i;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-03-23 03:00:37 +00:00
|
|
|
for (lineset = (FreestyleLineSet *)config->linesets.first, i = 0; lineset;
|
|
|
|
|
lineset = lineset->next, i++)
|
|
|
|
|
{
|
2019-04-22 09:39:35 +10:00
|
|
|
if (i == index) {
|
2013-03-23 03:00:37 +00:00
|
|
|
lineset->flags |= FREESTYLE_LINESET_CURRENT;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
|
else {
|
2013-03-23 03:00:37 +00:00
|
|
|
lineset->flags &= ~FREESTYLE_LINESET_CURRENT;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2013-03-23 03:00:37 +00:00
|
|
|
}
|
|
|
|
|
}
|