**Changes**
As described in T93602, this patch removes all use of the `MVert`
struct, replacing it with a generic named attribute with the name
`"position"`, consistent with other geometry types.
Variable names have been changed from `verts` to `positions`, to align
with the attribute name and the more generic design (positions are not
vertices, they are just an attribute stored on the point domain).
This change is made possible by previous commits that moved all other
data out of `MVert` to runtime data or other generic attributes. What
remains is mostly a simple type change. Though, the type still shows up
859 times, so the patch is quite large.
One compromise is that now `CD_MASK_BAREMESH` now contains
`CD_PROP_FLOAT3`. With the general move towards generic attributes
over custom data types, we are removing use of these type masks anyway.
**Benefits**
The most obvious benefit is reduced memory usage and the benefits
that brings in memory-bound situations. `float3` is only 3 bytes, in
comparison to `MVert` which was 4. When there are millions of vertices
this starts to matter more.
The other benefits come from using a more generic type. Instead of
writing algorithms specifically for `MVert`, code can just use arrays
of vectors. This will allow eliminating many temporary arrays or
wrappers used to extract positions.
Many possible improvements aren't implemented in this patch, though
I did switch simplify or remove the process of creating temporary
position arrays in a few places.
The design clarity that "positions are just another attribute" brings
allows removing explicit copying of vertices in some procedural
operations-- they are just processed like most other attributes.
**Performance**
This touches so many areas that it's hard to benchmark exhaustively,
but I observed some areas as examples.
* The mesh line node with 4 million count was 1.5x (8ms to 12ms) faster.
* The Spring splash screen went from ~4.3 to ~4.5 fps.
* The subdivision surface modifier/node was slightly faster
RNA access through Python may be slightly slower, since now we need
a name lookup instead of just a custom data type lookup for each index.
**Future Improvements**
* Remove uses of "vert_coords" functions:
* `BKE_mesh_vert_coords_alloc`
* `BKE_mesh_vert_coords_get`
* `BKE_mesh_vert_coords_apply{_with_mat4}`
* Remove more hidden copying of positions
* General simplification now possible in many areas
* Convert more code to C++ to use `float3` instead of `float[3]`
* Currently `reinterpret_cast` is used for those C-API functions
Differential Revision: https://developer.blender.org/D15982
51 lines
1.8 KiB
C++
51 lines
1.8 KiB
C++
/* SPDX-License-Identifier: GPL-2.0-or-later
|
|
* Copyright 2018 Blender Foundation. All rights reserved. */
|
|
|
|
/** \file
|
|
* \ingroup bke
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "BLI_sys_types.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
struct Mesh;
|
|
struct MeshElemMap;
|
|
struct MEdge;
|
|
struct Subdiv;
|
|
|
|
typedef struct SubdivToMeshSettings {
|
|
/* Resolution at which regular ptex (created for quad polygon) are being
|
|
* evaluated. This defines how many vertices final mesh will have: every
|
|
* regular ptex has resolution^2 vertices. Special (irregular, or ptex
|
|
* created for a corner of non-quad polygon) will have resolution of
|
|
* `resolution - 1`.
|
|
*/
|
|
int resolution;
|
|
/* When true, only edges emitted from coarse ones will be displayed. */
|
|
bool use_optimal_display;
|
|
} SubdivToMeshSettings;
|
|
|
|
/* Create real hi-res mesh from subdivision, all geometry is "real". */
|
|
struct Mesh *BKE_subdiv_to_mesh(struct Subdiv *subdiv,
|
|
const SubdivToMeshSettings *settings,
|
|
const struct Mesh *coarse_mesh);
|
|
|
|
/* Interpolate a position along the `coarse_edge` at the relative `u` coordinate. If `is_simple` is
|
|
* false, this will perform a B-Spline interpolation using the edge neighbors, otherwise a linear
|
|
* interpolation will be done base on the edge vertices. */
|
|
void BKE_subdiv_mesh_interpolate_position_on_edge(const float (*coarse_positions)[3],
|
|
const struct MEdge *coarse_edges,
|
|
const struct MeshElemMap *vert_to_edge_map,
|
|
int coarse_edge_index,
|
|
bool is_simple,
|
|
float u,
|
|
float pos_r[3]);
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|