Blender  V3.3
abc_writer_mball.cc
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
7 #include "abc_writer_mball.h"
9 
10 #include "BLI_assert.h"
11 
12 #include "BKE_displist.h"
13 #include "BKE_lib_id.h"
14 #include "BKE_mball.h"
15 #include "BKE_mesh.h"
16 #include "BKE_object.h"
17 
18 #include "DNA_mesh_types.h"
19 #include "DNA_meta_types.h"
20 
21 namespace blender::io::alembic {
22 
24  : ABCGenericMeshWriter(args)
25 {
26 }
27 
29 {
31  bool supported = is_basis_ball(scene, context->object) &&
33  return supported;
34 }
35 
37 {
38  /* We assume that metaballs are always animated, as the current object may
39  * not be animated but another ball in the same group may be. */
40  return true;
41 }
42 
44 {
45  /* Metaballs should be exported to subdivision surfaces, if the export options allow. */
46  return true;
47 }
48 
49 Mesh *ABCMetaballWriter::get_export_mesh(Object *object_eval, bool &r_needsfree)
50 {
51  Mesh *mesh_eval = BKE_object_get_evaluated_mesh(object_eval);
52  if (mesh_eval != nullptr) {
53  /* Mesh_eval only exists when generative modifiers are in use. */
54  r_needsfree = false;
55  return mesh_eval;
56  }
57  r_needsfree = true;
58  return BKE_mesh_new_from_object(args_.depsgraph, object_eval, false, false);
59 }
60 
62 {
63  BKE_id_free(nullptr, mesh);
64 }
65 
66 bool ABCMetaballWriter::is_basis_ball(Scene *scene, Object *ob) const
67 {
68  Object *basis_ob = BKE_mball_basis_find(scene, ob);
69  return ob == basis_ob;
70 }
71 
72 } // namespace blender::io::alembic
display list (or rather multi purpose list) stuff.
void BKE_id_free(struct Main *bmain, void *idv)
struct Object * BKE_mball_basis_find(struct Scene *scene, struct Object *ob)
Definition: mball.c:508
struct Mesh * BKE_mesh_new_from_object(struct Depsgraph *depsgraph, struct Object *object, bool preserve_all_data_layers, bool preserve_origindex)
General operations, lookup, etc. for blender objects.
struct Mesh * BKE_object_get_evaluated_mesh(const struct Object *object)
struct Scene * DEG_get_input_scene(const Depsgraph *graph)
const ABCWriterConstructorArgs args_
virtual bool is_supported(const HierarchyContext *context) const override
virtual bool export_as_subdivision_surface(Object *ob_eval) const override
virtual Mesh * get_export_mesh(Object *object_eval, bool &r_needsfree) override
virtual void free_export_mesh(Mesh *mesh) override
ABCMetaballWriter(const ABCWriterConstructorArgs &args)
virtual bool is_supported(const HierarchyContext *context) const override
virtual bool check_is_animated(const HierarchyContext &context) const override
Scene scene