Cleanup: Simplify freeing and clearing mesh runtime data
Separate freeing and clearing mesh runtime data in a more obvious way. This makes it easier to see what data is meant to be cleared on certain changes, rather than conflating it with freeing all of the runtime caches. Also comment and reduce the surface area of the "mesh runtime" API. The redundancy in some functions made it confusing which one should be used, resulting in subtle bugs or unnecessary boilerplate code. Also, now bke::MeshRuntime is able to free all the data it owns by itself, which makes this area easier to reason about. That required changing the interface of a few functions to avoid passing Mesh when they really just dealt with some runtime struct. With more RAII semantics in the future, more of this manual freeing will become unnecessary.
This commit is contained in:
@@ -413,17 +413,6 @@ float (*BKE_mesh_vertex_normals_for_write(struct Mesh *mesh))[3];
|
||||
*/
|
||||
float (*BKE_mesh_poly_normals_for_write(struct Mesh *mesh))[3];
|
||||
|
||||
/**
|
||||
* Free any cached vertex or poly normals. Face corner (loop) normals are also derived data,
|
||||
* but are not handled with the same method yet, so they are not included. It's important that this
|
||||
* is called after the mesh changes size, since otherwise cached normal arrays might not be large
|
||||
* enough (though it may be called indirectly by other functions).
|
||||
*
|
||||
* \note Normally it's preferred to call #BKE_mesh_normals_tag_dirty instead,
|
||||
* but this can be used in specific situations to reset a mesh or reduce memory usage.
|
||||
*/
|
||||
void BKE_mesh_clear_derived_normals(struct Mesh *mesh);
|
||||
|
||||
/**
|
||||
* Mark the mesh's vertex normals non-dirty, for when they are calculated or assigned manually.
|
||||
*/
|
||||
@@ -987,10 +976,10 @@ void BKE_mesh_eval_geometry(struct Depsgraph *depsgraph, struct Mesh *mesh);
|
||||
|
||||
/* Draw Cache */
|
||||
void BKE_mesh_batch_cache_dirty_tag(struct Mesh *me, eMeshBatchDirtyMode mode);
|
||||
void BKE_mesh_batch_cache_free(struct Mesh *me);
|
||||
void BKE_mesh_batch_cache_free(void *batch_cache);
|
||||
|
||||
extern void (*BKE_mesh_batch_cache_dirty_tag_cb)(struct Mesh *me, eMeshBatchDirtyMode mode);
|
||||
extern void (*BKE_mesh_batch_cache_free_cb)(struct Mesh *me);
|
||||
extern void (*BKE_mesh_batch_cache_free_cb)(void *batch_cache);
|
||||
|
||||
/* mesh_debug.c */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user