Blender  V3.3
abc_subdiv_disabler.cc
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2020 Blender Foundation. All rights reserved. */
3 #include "abc_subdiv_disabler.h"
4 
5 #include <cstdio>
6 
7 #include "BLI_listbase.h"
8 
9 #include "DEG_depsgraph.h"
10 #include "DEG_depsgraph_query.h"
11 
12 #include "DNA_layer_types.h"
13 #include "DNA_mesh_types.h"
14 #include "DNA_modifier_types.h"
15 #include "DNA_object_types.h"
16 
17 #include "BKE_modifier.h"
18 
19 namespace blender::io::alembic {
20 
22 {
23 }
24 
26 {
27  for (ModifierData *modifier : disabled_modifiers_) {
28  modifier->mode &= ~eModifierMode_DisableTemporary;
29  }
30 }
31 
33 {
34  Scene *scene = DEG_get_input_scene(depsgraph_);
35  ViewLayer *view_layer = DEG_get_input_view_layer(depsgraph_);
36 
37  LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
38  Object *object = base->object;
39 
40  if (object->type != OB_MESH) {
41  continue;
42  }
43 
44  ModifierData *subdiv = get_subdiv_modifier(scene, object);
45  if (subdiv == nullptr) {
46  continue;
47  }
48 
49  /* This disables more modifiers than necessary, as it doesn't take restrictions like
50  * "export selected objects only" into account. However, with the subsurfs disabled,
51  * moving to a different frame is also going to be faster, so in the end this is probably
52  * a good thing to do. */
54  disabled_modifiers_.insert(subdiv);
56  }
57 }
58 
60 {
61  ModifierData *md = static_cast<ModifierData *>(ob->modifiers.last);
62 
63  for (; md; md = md->prev) {
65  continue;
66  }
67 
68  if (md->type == eModifierType_Subsurf) {
69  SubsurfModifierData *smd = reinterpret_cast<SubsurfModifierData *>(md);
70 
71  if (smd->subdivType == ME_CC_SUBSURF) {
72  return md;
73  }
74  }
75 
76  /* mesh is not a subsurf. break */
78  return nullptr;
79  }
80  }
81 
82  return nullptr;
83 }
84 
85 } // namespace blender::io::alembic
bool BKE_modifier_is_enabled(const struct Scene *scene, struct ModifierData *md, int required_mode)
#define LISTBASE_FOREACH(type, var, list)
Definition: BLI_listbase.h:336
#define ELEM(...)
struct Depsgraph Depsgraph
Definition: DEG_depsgraph.h:35
void DEG_id_tag_update(struct ID *id, int flag)
struct Scene * DEG_get_input_scene(const Depsgraph *graph)
struct ViewLayer * DEG_get_input_view_layer(const Depsgraph *graph)
@ ID_RECALC_GEOMETRY
Definition: DNA_ID.h:791
@ ME_CC_SUBSURF
@ eModifierMode_Render
@ eModifierMode_DisableTemporary
@ eModifierType_ParticleSystem
@ eModifierType_Subsurf
@ eModifierType_Displace
Object is a sort of wrapper for general info.
@ OB_MESH
static ModifierData * get_subdiv_modifier(Scene *scene, Object *ob)
Scene scene
const Depsgraph * depsgraph
void * last
Definition: DNA_listBase.h:31
struct ModifierData * prev
ListBase modifiers
ListBase object_bases