Blender V5.3
mesh_utils.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2026 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#include "DNA_ID.h"
6#include "DNA_object_types.h"
7
8#include "BKE_lib_id.hh"
9#include "BKE_mesh.hh"
10#include "BKE_object.hh"
11#include "BKE_object_types.hh"
12
14
15#include "IO_mesh_utils.hh"
16
17namespace blender::io {
18
20 Depsgraph *depsgraph,
21 Object *obj_eval,
22 const bool apply_modifiers)
23{
24 /* Curves and NURBS surfaces have no mesh in their pre-modified state,
25 * convert one on demand. */
26 bool is_original_mesh_type = true;
27 if (const ID *data_orig = obj_eval->runtime->data_orig) {
28 if (GS(data_orig->name) != ID_ME) {
29 is_original_mesh_type = false;
30 if (!apply_modifiers) {
32 depsgraph, DEG_get_original(obj_eval), true, true, true);
33 }
34 }
35 }
36 if (apply_modifiers) {
37 coerce.mesh = BKE_object_get_evaluated_mesh(obj_eval);
38 }
39 else {
40 coerce.mesh = is_original_mesh_type ? BKE_object_get_pre_modified_mesh(obj_eval) :
41 coerce.owned;
42 }
43
44 return coerce.mesh;
45}
46
48{
49 if (owned) {
50 BKE_id_free(nullptr, owned);
51 owned = nullptr;
52 }
53}
54
55} // namespace blender::io
General operations, lookup, etc. for blender objects.
ID and Library types, which are fundamental for SDNA.
Object is a sort of wrapper for general info.
const Mesh * mesh_coerce_for_export_setup(MeshCoerceForExport &coerce, Depsgraph *depsgraph, Object *obj_eval, const bool apply_modifiers)
Definition mesh_utils.cc:19
const Mesh * BKE_object_get_pre_modified_mesh(const Object *object)
Definition object.cc:4444
void BKE_id_free(Main *bmain, void *idv)
T * DEG_get_original(T *id)
ID_Type GS(const char *name)
Definition DNA_ID.h:410
Mesh * BKE_mesh_new_from_object(Depsgraph *depsgraph, Object *object, bool preserve_all_data_layers, bool preserve_origindex, bool ensure_subdivision)
Mesh * BKE_object_get_evaluated_mesh(const Object *object_eval)
Definition object.cc:4436
bke::ObjectRuntime * runtime