Blender V4.3
abc_writer_mball.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9#include "abc_writer_mball.h"
11
12#include "BKE_lib_id.hh"
13#include "BKE_mball.hh"
14#include "BKE_mesh.hh"
15#include "BKE_object.hh"
16
18
19#include "DNA_mesh_types.h"
20
21namespace blender::io::alembic {
22
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
49Mesh *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
66bool 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
void BKE_id_free(Main *bmain, void *idv)
Object * BKE_mball_basis_find(Scene *scene, Object *ob)
Definition mball.cc:394
Mesh * BKE_mesh_new_from_object(Depsgraph *depsgraph, Object *object, bool preserve_all_data_layers, bool preserve_origindex)
General operations, lookup, etc. for blender objects.
Mesh * BKE_object_get_evaluated_mesh(const Object *object_eval)
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