The main motivation for this is that it's part of a fix for #113377, where I want to propagate the edit mesh pointers through copied meshes in modifiers and geometry nodes, instead of just setting the edit mesh pointer at the end of the modifier stack. That would have two main benefits: 1. We avoid the need to write to the evaluated mesh, after evaluation which means it can be shared directly among evaluated objects. 2. When an object's mesh is completely replaced by the mesh from another object during evaluation (with the object info node), the final edit mesh pointer will not be "wrong", allowing us to skip index-mapped GPU data extraction. Beyond that, using a shared pointer just makes things more automatic. Handling of edit mesh data is already complicated enough, this way some of the worry and complexity can be handled by RAII. One thing to keep in mind is that the edit mesh's BMesh is still freed manually with `EDBM_mesh_free_data` when leaving edit mode. I figured that was a more conservative approach for now. Maybe eventually that could be handled automatically with RAII too. Pull Request: https://projects.blender.org/blender/blender/pulls/120276
51 lines
1.7 KiB
C++
51 lines
1.7 KiB
C++
/* SPDX-FileCopyrightText: 2023 Blender Authors
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
#pragma once
|
|
|
|
/** \file
|
|
* \ingroup bke
|
|
*/
|
|
|
|
#include <memory>
|
|
|
|
#include "BLI_math_vector_types.hh"
|
|
#include "BLI_span.hh"
|
|
|
|
struct BMEditMesh;
|
|
struct CustomData_MeshMasks;
|
|
struct Mesh;
|
|
|
|
Mesh *BKE_mesh_wrapper_from_editmesh(std::shared_ptr<BMEditMesh> em,
|
|
const CustomData_MeshMasks *cd_mask_extra,
|
|
const Mesh *me_settings);
|
|
void BKE_mesh_wrapper_ensure_mdata(Mesh *mesh);
|
|
|
|
int BKE_mesh_wrapper_vert_len(const Mesh *mesh);
|
|
int BKE_mesh_wrapper_edge_len(const Mesh *mesh);
|
|
int BKE_mesh_wrapper_loop_len(const Mesh *mesh);
|
|
int BKE_mesh_wrapper_face_len(const Mesh *mesh);
|
|
|
|
/**
|
|
* Return a contiguous array of vertex position values, if available.
|
|
* Otherwise, vertex positions are stored in BMesh vertices and this returns null.
|
|
*/
|
|
blender::Span<blender::float3> BKE_mesh_wrapper_vert_coords(const Mesh *mesh);
|
|
|
|
/**
|
|
* Return a contiguous array of face normal values, if available.
|
|
* Otherwise, normals are stored in BMesh faces and this returns null.
|
|
*/
|
|
blender::Span<blender::float3> BKE_mesh_wrapper_face_normals(Mesh *mesh);
|
|
|
|
void BKE_mesh_wrapper_tag_positions_changed(Mesh *mesh);
|
|
|
|
void BKE_mesh_wrapper_vert_coords_copy(const Mesh *mesh,
|
|
blender::MutableSpan<blender::float3> positions);
|
|
void BKE_mesh_wrapper_vert_coords_copy_with_mat4(const Mesh *mesh,
|
|
float (*vert_coords)[3],
|
|
int vert_coords_len,
|
|
const float mat[4][4]);
|
|
|
|
Mesh *BKE_mesh_wrapper_ensure_subdivision(Mesh *mesh);
|