2011-02-18 13:05:18 +00:00
|
|
|
/*
|
2002-10-12 11:37:38 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
2008-04-16 22:40:48 +00:00
|
|
|
* of the License, or (at your option) any later version.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
|
|
|
* All rights reserved.
|
|
|
|
*/
|
2012-02-17 18:59:41 +00:00
|
|
|
#pragma once
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
* \ingroup bke
|
2011-02-18 13:05:18 +00:00
|
|
|
*/
|
|
|
|
|
2020-10-09 07:27:18 +02:00
|
|
|
#include "BKE_mesh_types.h"
|
2020-10-19 12:11:38 +02:00
|
|
|
#include "BLI_utildefines.h"
|
2018-05-15 13:26:40 +02:00
|
|
|
|
2019-01-28 21:08:24 +11:00
|
|
|
struct BLI_Stack;
|
|
|
|
struct BMesh;
|
2016-07-01 19:07:11 +10:00
|
|
|
struct BMeshCreateParams;
|
2018-05-02 11:39:23 +02:00
|
|
|
struct BMeshFromMeshParams;
|
|
|
|
struct BMeshToMeshParams;
|
2005-07-14 18:04:27 +00:00
|
|
|
struct BoundBox;
|
2019-01-28 21:08:24 +11:00
|
|
|
struct CustomData;
|
Refactor CDData masks, to have one mask per mesh elem type.
We already have different storages for cddata of verts, edges etc.,
'simply' do the same for the mask flags we use all around Blender code
to request some data, or limit some operation to some layers, etc.
Reason we need this is that some cddata types (like Normals) are
actually shared between verts/polys/loops, and we don’t want to generate
clnors everytime we request vnors!
As a side note, this also does final fix to T59338, which was the
trigger for this patch (need to request computed loop normals for
another mesh than evaluated one).
Reviewers: brecht, campbellbarton, sergey
Differential Revision: https://developer.blender.org/D4407
2019-03-07 11:13:40 +01:00
|
|
|
struct CustomData_MeshMasks;
|
2018-04-06 12:07:27 +02:00
|
|
|
struct Depsgraph;
|
2013-04-22 12:00:37 +00:00
|
|
|
struct EdgeHash;
|
2019-01-28 21:08:24 +11:00
|
|
|
struct ID;
|
2018-06-01 17:05:21 +02:00
|
|
|
struct KeyBlock;
|
2019-01-28 21:08:24 +11:00
|
|
|
struct LinkNode;
|
|
|
|
struct ListBase;
|
|
|
|
struct MDeformVert;
|
|
|
|
struct MDisps;
|
|
|
|
struct MEdge;
|
|
|
|
struct MFace;
|
|
|
|
struct MLoop;
|
2015-07-17 03:36:03 +10:00
|
|
|
struct MLoopTri;
|
2019-01-28 21:08:24 +11:00
|
|
|
struct MLoopUV;
|
2010-09-04 05:31:25 +00:00
|
|
|
struct MPoly;
|
2002-10-12 11:37:38 +00:00
|
|
|
struct MVert;
|
2019-01-28 21:08:24 +11:00
|
|
|
struct Main;
|
|
|
|
struct MemArena;
|
|
|
|
struct Mesh;
|
|
|
|
struct ModifierData;
|
2002-10-12 11:37:38 +00:00
|
|
|
struct Object;
|
2020-04-09 18:49:40 +02:00
|
|
|
struct PointCloud;
|
2019-01-28 21:08:24 +11:00
|
|
|
struct Scene;
|
2013-09-09 02:11:44 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2013-09-09 05:42:26 +00:00
|
|
|
/* setting zero so we can catch bugs in OpenMP/BMesh */
|
|
|
|
#ifdef DEBUG
|
|
|
|
# define BKE_MESH_OMP_LIMIT 0
|
|
|
|
#else
|
|
|
|
# define BKE_MESH_OMP_LIMIT 10000
|
|
|
|
#endif
|
2013-05-08 12:56:51 +00:00
|
|
|
|
2013-09-09 02:11:44 +00:00
|
|
|
/* *** mesh.c *** */
|
2013-06-14 08:28:27 +00:00
|
|
|
|
2018-05-02 11:39:23 +02:00
|
|
|
struct BMesh *BKE_mesh_to_bmesh_ex(const struct Mesh *me,
|
|
|
|
const struct BMeshCreateParams *create_params,
|
|
|
|
const struct BMeshFromMeshParams *convert_params);
|
2016-07-01 19:07:11 +10:00
|
|
|
struct BMesh *BKE_mesh_to_bmesh(struct Mesh *me,
|
|
|
|
struct Object *ob,
|
|
|
|
const bool add_key_index,
|
|
|
|
const struct BMeshCreateParams *params);
|
2013-01-24 04:02:30 +00:00
|
|
|
|
2019-09-16 10:45:49 +02:00
|
|
|
struct Mesh *BKE_mesh_from_bmesh_nomain(struct BMesh *bm,
|
|
|
|
const struct BMeshToMeshParams *params,
|
|
|
|
const struct Mesh *me_settings);
|
Refactor CDData masks, to have one mask per mesh elem type.
We already have different storages for cddata of verts, edges etc.,
'simply' do the same for the mask flags we use all around Blender code
to request some data, or limit some operation to some layers, etc.
Reason we need this is that some cddata types (like Normals) are
actually shared between verts/polys/loops, and we don’t want to generate
clnors everytime we request vnors!
As a side note, this also does final fix to T59338, which was the
trigger for this patch (need to request computed loop normals for
another mesh than evaluated one).
Reviewers: brecht, campbellbarton, sergey
Differential Revision: https://developer.blender.org/D4407
2019-03-07 11:13:40 +01:00
|
|
|
struct Mesh *BKE_mesh_from_bmesh_for_eval_nomain(struct BMesh *bm,
|
2019-09-16 10:45:49 +02:00
|
|
|
const struct CustomData_MeshMasks *cd_mask_extra,
|
|
|
|
const struct Mesh *me_settings);
|
2018-05-02 11:39:23 +02:00
|
|
|
|
2020-02-08 01:02:18 +11:00
|
|
|
int poly_find_loop_from_vert(const struct MPoly *poly, const struct MLoop *loopstart, uint vert);
|
2015-04-19 14:21:23 +10:00
|
|
|
int poly_get_adj_loops_from_vert(const struct MPoly *poly,
|
2015-07-11 04:39:27 +10:00
|
|
|
const struct MLoop *mloop,
|
|
|
|
unsigned int vert,
|
|
|
|
unsigned int r_adj[2]);
|
2012-02-28 23:08:40 +00:00
|
|
|
|
2012-05-22 15:28:44 +00:00
|
|
|
int BKE_mesh_edge_other_vert(const struct MEdge *e, int v);
|
2018-10-20 21:02:52 +03:00
|
|
|
void BKE_mesh_looptri_get_real_edges(const struct Mesh *mesh,
|
|
|
|
const struct MLoopTri *looptri,
|
|
|
|
int r_edges[3]);
|
2012-05-22 15:28:44 +00:00
|
|
|
|
ID-Remap - Step one: core work (cleanup and rework of generic ID datablock handling).
This commit changes a lot of how IDs are handled internally, especially the unlinking/freeing
processes. So far, this was very fuzy, to summarize cleanly deleting or replacing a datablock
was pretty much impossible, except for a few special cases.
Also, unlinking was handled by each datatype, in a rather messy and prone-to-errors way (quite
a few ID usages were missed or wrongly handled that way).
One of the main goal of id-remap branch was to cleanup this, and fatorize ID links handling
by using library_query utils to allow generic handling of those, which is now the case
(now, generic ID links handling is only "knwon" from readfile.c and library_query.c).
This commit also adds backends to allow live replacement and deletion of datablocks in Blender
(so-called 'remapping' process, where we replace all usages of a given ID pointer by a new one,
or NULL one in case of unlinking).
This will allow nice new features, like ability to easily reload or relocate libraries, real immediate
deletion of datablocks in blender, replacement of one datablock by another, etc.
Some of those are for next commits.
A word of warning: this commit is highly risky, because it affects potentially a lot in Blender core.
Though it was tested rather deeply, being totally impossible to check all possible ID usage cases,
it's likely there are some remaining issues and bugs in new code... Please report them! ;)
Review task: D2027 (https://developer.blender.org/D2027).
Reviewed by campbellbarton, thanks a bunch.
2016-06-22 17:29:38 +02:00
|
|
|
void BKE_mesh_free(struct Mesh *me);
|
2019-07-30 18:38:31 +02:00
|
|
|
void BKE_mesh_clear_geometry(struct Mesh *me);
|
2013-02-05 12:46:15 +00:00
|
|
|
struct Mesh *BKE_mesh_add(struct Main *bmain, const char *name);
|
2019-09-16 10:45:49 +02:00
|
|
|
void BKE_mesh_copy_settings(struct Mesh *me_dst, const struct Mesh *me_src);
|
2013-03-17 19:55:10 +00:00
|
|
|
void BKE_mesh_update_customdata_pointers(struct Mesh *me, const bool do_ensure_tess_cd);
|
2014-03-16 21:55:30 +11:00
|
|
|
void BKE_mesh_ensure_skin_customdata(struct Mesh *me);
|
2009-08-30 21:30:07 +00:00
|
|
|
|
2018-05-08 17:15:23 +02:00
|
|
|
struct Mesh *BKE_mesh_new_nomain(
|
|
|
|
int verts_len, int edges_len, int tessface_len, int loops_len, int polys_len);
|
2018-05-08 17:06:30 +02:00
|
|
|
struct Mesh *BKE_mesh_new_nomain_from_template(const struct Mesh *me_src,
|
2018-05-08 17:15:23 +02:00
|
|
|
int verts_len,
|
|
|
|
int edges_len,
|
|
|
|
int tessface_len,
|
|
|
|
int loops_len,
|
|
|
|
int polys_len);
|
2019-08-27 18:17:27 +02:00
|
|
|
struct Mesh *BKE_mesh_new_nomain_from_template_ex(const struct Mesh *me_src,
|
|
|
|
int verts_len,
|
|
|
|
int edges_len,
|
|
|
|
int tessface_len,
|
|
|
|
int loops_len,
|
|
|
|
int polys_len,
|
2020-02-26 14:24:57 +11:00
|
|
|
struct CustomData_MeshMasks mask);
|
2018-04-19 11:03:58 +02:00
|
|
|
|
2020-09-04 20:59:13 +02:00
|
|
|
void BKE_mesh_eval_delete(struct Mesh *mesh_eval);
|
2019-07-28 15:12:38 +02:00
|
|
|
|
2019-04-27 12:07:07 +10:00
|
|
|
/* Performs copy for use during evaluation,
|
|
|
|
* optional referencing original arrays to reduce memory. */
|
2018-09-20 12:33:45 +02:00
|
|
|
struct Mesh *BKE_mesh_copy_for_eval(struct Mesh *source, bool reference);
|
2018-08-16 14:20:36 +02:00
|
|
|
|
2019-04-27 12:07:07 +10:00
|
|
|
/* These functions construct a new Mesh,
|
|
|
|
* contrary to BKE_mesh_from_nurbs which modifies ob itself. */
|
2018-05-08 17:28:43 +02:00
|
|
|
struct Mesh *BKE_mesh_new_nomain_from_curve(struct Object *ob);
|
|
|
|
struct Mesh *BKE_mesh_new_nomain_from_curve_displist(struct Object *ob, struct ListBase *dispbase);
|
2018-05-08 11:33:31 +02:00
|
|
|
|
2017-07-20 18:37:30 +10:00
|
|
|
bool BKE_mesh_ensure_facemap_customdata(struct Mesh *me);
|
|
|
|
bool BKE_mesh_clear_facemap_customdata(struct Mesh *me);
|
|
|
|
|
2012-12-21 07:28:14 +00:00
|
|
|
float (*BKE_mesh_orco_verts_get(struct Object *ob))[3];
|
2012-05-05 21:28:12 +00:00
|
|
|
void BKE_mesh_orco_verts_transform(struct Mesh *me, float (*orco)[3], int totvert, int invert);
|
2008-01-29 19:49:03 +00:00
|
|
|
int test_index_face(struct MFace *mface, struct CustomData *mfdata, int mfindex, int nr);
|
2012-05-05 16:03:57 +00:00
|
|
|
struct Mesh *BKE_mesh_from_object(struct Object *ob);
|
2018-05-29 15:49:21 +02:00
|
|
|
void BKE_mesh_assign_object(struct Main *bmain, struct Object *ob, struct Mesh *me);
|
2012-05-05 21:28:12 +00:00
|
|
|
void BKE_mesh_from_metaball(struct ListBase *lb, struct Mesh *me);
|
2015-07-11 04:39:27 +10:00
|
|
|
int BKE_mesh_nurbs_to_mdata(struct Object *ob,
|
|
|
|
struct MVert **r_allvert,
|
|
|
|
int *r_totvert,
|
|
|
|
struct MEdge **r_alledge,
|
|
|
|
int *r_totedge,
|
|
|
|
struct MLoop **r_allloop,
|
|
|
|
struct MPoly **r_allpoly,
|
|
|
|
int *r_totloop,
|
|
|
|
int *r_totpoly);
|
|
|
|
int BKE_mesh_nurbs_displist_to_mdata(struct Object *ob,
|
|
|
|
const struct ListBase *dispbase,
|
|
|
|
struct MVert **r_allvert,
|
|
|
|
int *r_totvert,
|
|
|
|
struct MEdge **r_alledge,
|
|
|
|
int *r_totedge,
|
|
|
|
struct MLoop **r_allloop,
|
|
|
|
struct MPoly **r_allpoly,
|
|
|
|
struct MLoopUV **r_alluv,
|
|
|
|
int *r_totloop,
|
|
|
|
int *r_totpoly);
|
2017-06-21 10:30:38 +02:00
|
|
|
void BKE_mesh_from_nurbs_displist(struct Main *bmain,
|
2018-06-11 16:02:46 +02:00
|
|
|
struct Object *ob,
|
|
|
|
struct ListBase *dispbase,
|
|
|
|
const char *obdata_name,
|
|
|
|
bool temporary);
|
|
|
|
void BKE_mesh_from_nurbs(struct Main *bmain, struct Object *ob);
|
2018-06-01 13:48:39 +02:00
|
|
|
void BKE_mesh_to_curve_nurblist(const struct Mesh *me,
|
|
|
|
struct ListBase *nurblist,
|
|
|
|
const int edge_users_test);
|
2018-06-11 16:02:46 +02:00
|
|
|
void BKE_mesh_to_curve(struct Main *bmain,
|
|
|
|
struct Depsgraph *depsgraph,
|
|
|
|
struct Scene *scene,
|
|
|
|
struct Object *ob);
|
2020-04-09 18:49:40 +02:00
|
|
|
void BKE_pointcloud_from_mesh(struct Mesh *me, struct PointCloud *pointcloud);
|
|
|
|
void BKE_mesh_to_pointcloud(struct Main *bmain,
|
|
|
|
struct Depsgraph *depsgraph,
|
|
|
|
struct Scene *scene,
|
|
|
|
struct Object *ob);
|
2020-10-26 23:12:22 -05:00
|
|
|
void BKE_mesh_from_pointcloud(const struct PointCloud *pointcloud, struct Mesh *me);
|
2020-04-09 18:49:40 +02:00
|
|
|
void BKE_pointcloud_to_mesh(struct Main *bmain,
|
|
|
|
struct Depsgraph *depsgraph,
|
|
|
|
struct Scene *scene,
|
|
|
|
struct Object *ob);
|
2013-08-14 11:29:58 +00:00
|
|
|
void BKE_mesh_material_index_remove(struct Mesh *me, short index);
|
2019-07-31 12:04:52 -07:00
|
|
|
bool BKE_mesh_material_index_used(struct Mesh *me, short index);
|
2013-08-14 11:29:58 +00:00
|
|
|
void BKE_mesh_material_index_clear(struct Mesh *me);
|
2015-04-28 07:24:56 +10:00
|
|
|
void BKE_mesh_material_remap(struct Mesh *me, const unsigned int *remap, unsigned int remap_len);
|
2019-08-25 12:00:03 +10:00
|
|
|
void BKE_mesh_smooth_flag_set(struct Mesh *me, const bool use_smooth);
|
2013-09-09 02:11:44 +00:00
|
|
|
|
2020-10-23 22:27:46 +02:00
|
|
|
/* Needed after converting a mesh with subsurf optimal display to mesh. */
|
|
|
|
void BKE_mesh_edges_set_draw_render(struct Mesh *me);
|
|
|
|
|
2012-05-05 21:28:12 +00:00
|
|
|
const char *BKE_mesh_cmp(struct Mesh *me1, struct Mesh *me2, float thresh);
|
2010-10-27 02:22:55 +00:00
|
|
|
|
2012-05-05 21:28:12 +00:00
|
|
|
struct BoundBox *BKE_mesh_boundbox_get(struct Object *ob);
|
2019-09-23 15:31:11 +02:00
|
|
|
|
|
|
|
void BKE_mesh_texspace_calc(struct Mesh *me);
|
|
|
|
void BKE_mesh_texspace_ensure(struct Mesh *me);
|
2019-09-23 15:54:21 +02:00
|
|
|
void BKE_mesh_texspace_get(struct Mesh *me, float r_loc[3], float r_size[3]);
|
|
|
|
void BKE_mesh_texspace_get_reference(struct Mesh *me,
|
|
|
|
short **r_texflag,
|
|
|
|
float **r_loc,
|
|
|
|
float **r_size);
|
2013-07-15 11:11:36 +00:00
|
|
|
void BKE_mesh_texspace_copy_from_object(struct Mesh *me, struct Object *ob);
|
2005-07-14 18:04:27 +00:00
|
|
|
|
2017-02-22 10:53:28 +01:00
|
|
|
void BKE_mesh_split_faces(struct Mesh *mesh, bool free_loop_normals);
|
2015-03-20 12:41:31 +05:00
|
|
|
|
2019-05-16 13:49:21 +02:00
|
|
|
/* Create new mesh from the given object at its current state.
|
2019-05-24 14:37:47 +02:00
|
|
|
* The owner of this mesh is unknown, it is up to the caller to decide.
|
|
|
|
*
|
|
|
|
* If preserve_all_data_layers is truth then the modifier stack is re-evaluated to ensure it
|
|
|
|
* preserves all possible custom data layers.
|
|
|
|
*
|
|
|
|
* NOTE: Dependency graph argument is required when preserve_all_data_layers is truth, and is
|
|
|
|
* ignored otherwise. */
|
|
|
|
struct Mesh *BKE_mesh_new_from_object(struct Depsgraph *depsgraph,
|
|
|
|
struct Object *object,
|
|
|
|
bool preserve_all_data_layers);
|
2019-05-16 13:49:21 +02:00
|
|
|
|
2019-08-02 17:45:32 +02:00
|
|
|
/* This is a version of BKE_mesh_new_from_object() which stores mesh in the given main database.
|
|
|
|
* However, that function enforces object type to be a geometry one, and ensures a mesh is always
|
|
|
|
* generated, be it empty. */
|
2019-05-24 14:37:47 +02:00
|
|
|
struct Mesh *BKE_mesh_new_from_object_to_bmain(struct Main *bmain,
|
|
|
|
struct Depsgraph *depsgraph,
|
|
|
|
struct Object *object,
|
|
|
|
bool preserve_all_data_layers);
|
2019-05-16 13:49:21 +02:00
|
|
|
|
2018-06-01 17:05:21 +02:00
|
|
|
struct Mesh *BKE_mesh_create_derived_for_modifier(struct Depsgraph *depsgraph,
|
|
|
|
struct Scene *scene,
|
2019-04-28 15:41:30 +02:00
|
|
|
struct Object *ob_eval,
|
|
|
|
struct ModifierData *md_eval,
|
2018-06-01 17:05:21 +02:00
|
|
|
int build_shapekey_layers);
|
|
|
|
|
|
|
|
/* Copies a nomain-Mesh into an existing Mesh. */
|
2018-06-06 10:30:24 +02:00
|
|
|
void BKE_mesh_nomain_to_mesh(struct Mesh *mesh_src,
|
|
|
|
struct Mesh *mesh_dst,
|
|
|
|
struct Object *ob,
|
Refactor CDData masks, to have one mask per mesh elem type.
We already have different storages for cddata of verts, edges etc.,
'simply' do the same for the mask flags we use all around Blender code
to request some data, or limit some operation to some layers, etc.
Reason we need this is that some cddata types (like Normals) are
actually shared between verts/polys/loops, and we don’t want to generate
clnors everytime we request vnors!
As a side note, this also does final fix to T59338, which was the
trigger for this patch (need to request computed loop normals for
another mesh than evaluated one).
Reviewers: brecht, campbellbarton, sergey
Differential Revision: https://developer.blender.org/D4407
2019-03-07 11:13:40 +01:00
|
|
|
const struct CustomData_MeshMasks *mask,
|
|
|
|
bool take_ownership);
|
2018-06-06 10:30:24 +02:00
|
|
|
void BKE_mesh_nomain_to_meshkey(struct Mesh *mesh_src, struct Mesh *mesh_dst, struct KeyBlock *kb);
|
2018-06-01 17:05:21 +02:00
|
|
|
|
2013-09-09 02:11:44 +00:00
|
|
|
/* vertex level transformations & checks (no derived mesh) */
|
|
|
|
|
2015-07-11 04:39:27 +10:00
|
|
|
bool BKE_mesh_minmax(const struct Mesh *me, float r_min[3], float r_max[3]);
|
2020-08-02 17:17:31 +10:00
|
|
|
void BKE_mesh_transform(struct Mesh *me, const float mat[4][4], bool do_keys);
|
2013-09-09 02:11:44 +00:00
|
|
|
void BKE_mesh_translate(struct Mesh *me, const float offset[3], const bool do_keys);
|
|
|
|
|
|
|
|
void BKE_mesh_tessface_calc(struct Mesh *mesh);
|
|
|
|
void BKE_mesh_tessface_ensure(struct Mesh *mesh);
|
|
|
|
void BKE_mesh_tessface_clear(struct Mesh *mesh);
|
|
|
|
|
|
|
|
void BKE_mesh_do_versions_cd_flag_init(struct Mesh *mesh);
|
|
|
|
|
|
|
|
void BKE_mesh_mselect_clear(struct Mesh *me);
|
|
|
|
void BKE_mesh_mselect_validate(struct Mesh *me);
|
|
|
|
int BKE_mesh_mselect_find(struct Mesh *me, int index, int type);
|
|
|
|
int BKE_mesh_mselect_active_get(struct Mesh *me, int type);
|
|
|
|
void BKE_mesh_mselect_active_set(struct Mesh *me, int index, int type);
|
|
|
|
|
2018-12-17 18:15:41 +11:00
|
|
|
void BKE_mesh_count_selected_items(const struct Mesh *mesh, int r_count[3]);
|
|
|
|
|
2019-08-22 06:28:35 +10:00
|
|
|
float (*BKE_mesh_vert_coords_alloc(const struct Mesh *mesh, int *r_vert_len))[3];
|
|
|
|
void BKE_mesh_vert_coords_get(const struct Mesh *mesh, float (*vert_coords)[3]);
|
|
|
|
|
2019-08-22 13:45:31 +10:00
|
|
|
void BKE_mesh_vert_coords_apply_with_mat4(struct Mesh *mesh,
|
|
|
|
const float (*vert_coords)[3],
|
|
|
|
const float mat[4][4]);
|
2019-08-22 06:28:35 +10:00
|
|
|
void BKE_mesh_vert_coords_apply(struct Mesh *mesh, const float (*vert_coords)[3]);
|
2020-09-04 20:59:13 +02:00
|
|
|
void BKE_mesh_vert_normals_apply(struct Mesh *mesh, const short (*vert_normals)[3]);
|
2018-05-08 11:33:31 +02:00
|
|
|
|
2013-09-09 02:11:44 +00:00
|
|
|
/* *** mesh_evaluate.c *** */
|
2004-07-08 20:38:27 +00:00
|
|
|
|
2018-06-05 15:59:30 +02:00
|
|
|
void BKE_mesh_calc_normals_mapping_simple(struct Mesh *me);
|
2012-05-05 21:28:12 +00:00
|
|
|
void BKE_mesh_calc_normals_mapping(struct MVert *mverts,
|
2012-01-06 00:08:37 +00:00
|
|
|
int numVerts,
|
2015-07-11 04:39:27 +10:00
|
|
|
const struct MLoop *mloop,
|
|
|
|
const struct MPoly *mpolys,
|
|
|
|
int numLoops,
|
|
|
|
int numPolys,
|
|
|
|
float (*r_polyNors)[3],
|
|
|
|
const struct MFace *mfaces,
|
|
|
|
int numFaces,
|
|
|
|
const int *origIndexFace,
|
|
|
|
float (*r_faceNors)[3]);
|
2012-05-05 21:28:12 +00:00
|
|
|
void BKE_mesh_calc_normals_mapping_ex(struct MVert *mverts,
|
2012-01-06 00:45:07 +00:00
|
|
|
int numVerts,
|
2015-07-11 04:39:27 +10:00
|
|
|
const struct MLoop *mloop,
|
|
|
|
const struct MPoly *mpolys,
|
|
|
|
int numLoops,
|
|
|
|
int numPolys,
|
|
|
|
float (*r_polyNors)[3],
|
|
|
|
const struct MFace *mfaces,
|
|
|
|
int numFaces,
|
|
|
|
const int *origIndexFace,
|
|
|
|
float (*r_faceNors)[3],
|
2013-03-19 23:17:44 +00:00
|
|
|
const bool only_face_normals);
|
2013-05-28 14:23:07 +00:00
|
|
|
void BKE_mesh_calc_normals_poly(struct MVert *mverts,
|
2015-10-12 20:12:55 +02:00
|
|
|
float (*r_vertnors)[3],
|
|
|
|
int numVerts,
|
2015-07-11 04:39:27 +10:00
|
|
|
const struct MLoop *mloop,
|
|
|
|
const struct MPoly *mpolys,
|
2014-03-16 03:24:05 +11:00
|
|
|
int numLoops,
|
|
|
|
int numPolys,
|
|
|
|
float (*r_polyNors)[3],
|
2013-06-12 09:35:02 +00:00
|
|
|
const bool only_face_normals);
|
2013-05-28 14:23:07 +00:00
|
|
|
void BKE_mesh_calc_normals(struct Mesh *me);
|
2018-05-08 10:06:37 +02:00
|
|
|
void BKE_mesh_ensure_normals(struct Mesh *me);
|
2018-10-11 16:32:49 +11:00
|
|
|
void BKE_mesh_ensure_normals_for_display(struct Mesh *mesh);
|
2015-07-17 03:36:03 +10:00
|
|
|
void BKE_mesh_calc_normals_looptri(struct MVert *mverts,
|
|
|
|
int numVerts,
|
|
|
|
const struct MLoop *mloop,
|
|
|
|
const struct MLoopTri *looptri,
|
|
|
|
int looptri_num,
|
|
|
|
float (*r_tri_nors)[3]);
|
Refactor: Merge non-functional-change part of 'edit normals' 2017 GSoC.
This merges changes in internals, runtime-only of existing custom
normals code, which make sense as of themselves, and will make diff of
soc branch easier/lighter to review.
In the details, it mostly changes two things:
* Now, smooth fans (aka MLoopNorSpaceArray) can store either loop
indices, or pointers to BMLoop themselves. This makes sense since in
BMesh, it's relatively easy to get index from a BMElement, but nearly
impracticable to go the other way around.
* First change enforces another, now we cannot rely anymore on `loops`
being NULL in MLoopNorSpace to detect single-loop fans, so we instead
store that info in a new flag.
Again, these are expected to be totally non-functional changes.
2018-03-01 16:54:21 +01:00
|
|
|
void BKE_mesh_loop_manifold_fan_around_vert_next(const struct MLoop *mloops,
|
|
|
|
const struct MPoly *mpolys,
|
|
|
|
const int *loop_to_poly,
|
|
|
|
const int *e2lfan_curr,
|
|
|
|
const uint mv_pivot_index,
|
|
|
|
const struct MLoop **r_mlfan_curr,
|
|
|
|
int *r_mlfan_curr_index,
|
|
|
|
int *r_mlfan_vert_index,
|
|
|
|
int *r_mpfan_curr_index);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-02-22 15:00:42 +01:00
|
|
|
void BKE_edges_sharp_from_angle_set(const struct MVert *mverts,
|
|
|
|
const int numVerts,
|
|
|
|
struct MEdge *medges,
|
|
|
|
const int numEdges,
|
|
|
|
struct MLoop *mloops,
|
|
|
|
const int numLoops,
|
|
|
|
struct MPoly *mpolys,
|
|
|
|
const float (*polynors)[3],
|
|
|
|
const int numPolys,
|
|
|
|
const float split_angle);
|
|
|
|
|
Add Custom Loop Normals.
This is the core code for it, tools (datatransfer and modifier) will come in next commits).
RNA api is already there, though.
See the code for details, but basically, we define, for each 'smooth fan'
(which is a set of adjacent loops around a same vertex that are smooth, i.e. have a single same normal),
a 'loop normal space' (or lnor space), using auto-computed normal and relevant edges, and store
custom normal as two angular factors inside that space. This allows to have custom normals
'following' deformations of the geometry, and to only save two shorts per loop in new clnor CDLayer.
Normal manipulation (editing, mixing, interpolating, etc.) shall always happen with plain 3D vectors normals,
and be converted back into storage format at the end.
Clnor computation has also been threaded (at least for Mesh case, not for BMesh), since the process can
be rather heavy with high poly meshes.
Also, bumping subversion, and fix mess in 2.70 versioning code.
2015-02-05 14:24:48 +01:00
|
|
|
/**
|
|
|
|
* References a contiguous loop-fan with normal offset vars.
|
|
|
|
*/
|
|
|
|
typedef struct MLoopNorSpace {
|
2019-04-21 13:44:06 +10:00
|
|
|
/** Automatically computed loop normal. */
|
|
|
|
float vec_lnor[3];
|
|
|
|
/** Reference vector, orthogonal to vec_lnor. */
|
|
|
|
float vec_ref[3];
|
|
|
|
/** Third vector, orthogonal to vec_lnor and vec_ref. */
|
|
|
|
float vec_ortho[3];
|
|
|
|
/** Reference angle, around vec_ortho, in ]0, pi] range (0.0 marks that space as invalid). */
|
|
|
|
float ref_alpha;
|
|
|
|
/** Reference angle, around vec_lnor, in ]0, 2pi] range (0.0 marks that space as invalid). */
|
|
|
|
float ref_beta;
|
|
|
|
/** All loops using this lnor space (i.e. smooth fan of loops),
|
Refactor: Merge non-functional-change part of 'edit normals' 2017 GSoC.
This merges changes in internals, runtime-only of existing custom
normals code, which make sense as of themselves, and will make diff of
soc branch easier/lighter to review.
In the details, it mostly changes two things:
* Now, smooth fans (aka MLoopNorSpaceArray) can store either loop
indices, or pointers to BMLoop themselves. This makes sense since in
BMesh, it's relatively easy to get index from a BMElement, but nearly
impracticable to go the other way around.
* First change enforces another, now we cannot rely anymore on `loops`
being NULL in MLoopNorSpace to detect single-loop fans, so we instead
store that info in a new flag.
Again, these are expected to be totally non-functional changes.
2018-03-01 16:54:21 +01:00
|
|
|
* as (depending on owning MLoopNorSpaceArrary.data_type):
|
|
|
|
* - Indices (uint_in_ptr), or
|
|
|
|
* - BMLoop pointers. */
|
|
|
|
struct LinkNode *loops;
|
|
|
|
char flags;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-21 13:44:06 +10:00
|
|
|
/** To be used for extended processing related to loop normal spaces (aka smooth fans). */
|
|
|
|
void *user_data;
|
Add Custom Loop Normals.
This is the core code for it, tools (datatransfer and modifier) will come in next commits).
RNA api is already there, though.
See the code for details, but basically, we define, for each 'smooth fan'
(which is a set of adjacent loops around a same vertex that are smooth, i.e. have a single same normal),
a 'loop normal space' (or lnor space), using auto-computed normal and relevant edges, and store
custom normal as two angular factors inside that space. This allows to have custom normals
'following' deformations of the geometry, and to only save two shorts per loop in new clnor CDLayer.
Normal manipulation (editing, mixing, interpolating, etc.) shall always happen with plain 3D vectors normals,
and be converted back into storage format at the end.
Clnor computation has also been threaded (at least for Mesh case, not for BMesh), since the process can
be rather heavy with high poly meshes.
Also, bumping subversion, and fix mess in 2.70 versioning code.
2015-02-05 14:24:48 +01:00
|
|
|
} MLoopNorSpace;
|
Refactor: Merge non-functional-change part of 'edit normals' 2017 GSoC.
This merges changes in internals, runtime-only of existing custom
normals code, which make sense as of themselves, and will make diff of
soc branch easier/lighter to review.
In the details, it mostly changes two things:
* Now, smooth fans (aka MLoopNorSpaceArray) can store either loop
indices, or pointers to BMLoop themselves. This makes sense since in
BMesh, it's relatively easy to get index from a BMElement, but nearly
impracticable to go the other way around.
* First change enforces another, now we cannot rely anymore on `loops`
being NULL in MLoopNorSpace to detect single-loop fans, so we instead
store that info in a new flag.
Again, these are expected to be totally non-functional changes.
2018-03-01 16:54:21 +01:00
|
|
|
/**
|
|
|
|
* MLoopNorSpace.flags
|
|
|
|
*/
|
|
|
|
enum {
|
|
|
|
MLNOR_SPACE_IS_SINGLE = 1 << 0,
|
|
|
|
};
|
|
|
|
|
Add Custom Loop Normals.
This is the core code for it, tools (datatransfer and modifier) will come in next commits).
RNA api is already there, though.
See the code for details, but basically, we define, for each 'smooth fan'
(which is a set of adjacent loops around a same vertex that are smooth, i.e. have a single same normal),
a 'loop normal space' (or lnor space), using auto-computed normal and relevant edges, and store
custom normal as two angular factors inside that space. This allows to have custom normals
'following' deformations of the geometry, and to only save two shorts per loop in new clnor CDLayer.
Normal manipulation (editing, mixing, interpolating, etc.) shall always happen with plain 3D vectors normals,
and be converted back into storage format at the end.
Clnor computation has also been threaded (at least for Mesh case, not for BMesh), since the process can
be rather heavy with high poly meshes.
Also, bumping subversion, and fix mess in 2.70 versioning code.
2015-02-05 14:24:48 +01:00
|
|
|
/**
|
|
|
|
* Collection of #MLoopNorSpace basic storage & pre-allocation.
|
|
|
|
*/
|
|
|
|
typedef struct MLoopNorSpaceArray {
|
|
|
|
MLoopNorSpace **lspacearr; /* MLoop aligned array */
|
|
|
|
struct LinkNode
|
|
|
|
*loops_pool; /* Allocated once, avoids to call BLI_linklist_prepend_arena() for each loop! */
|
Refactor: Merge non-functional-change part of 'edit normals' 2017 GSoC.
This merges changes in internals, runtime-only of existing custom
normals code, which make sense as of themselves, and will make diff of
soc branch easier/lighter to review.
In the details, it mostly changes two things:
* Now, smooth fans (aka MLoopNorSpaceArray) can store either loop
indices, or pointers to BMLoop themselves. This makes sense since in
BMesh, it's relatively easy to get index from a BMElement, but nearly
impracticable to go the other way around.
* First change enforces another, now we cannot rely anymore on `loops`
being NULL in MLoopNorSpace to detect single-loop fans, so we instead
store that info in a new flag.
Again, these are expected to be totally non-functional changes.
2018-03-01 16:54:21 +01:00
|
|
|
char data_type; /* Whether we store loop indices, or pointers to BMLoop. */
|
2018-05-25 22:24:24 +05:30
|
|
|
int num_spaces; /* Number of clnors spaces defined in this array. */
|
Add Custom Loop Normals.
This is the core code for it, tools (datatransfer and modifier) will come in next commits).
RNA api is already there, though.
See the code for details, but basically, we define, for each 'smooth fan'
(which is a set of adjacent loops around a same vertex that are smooth, i.e. have a single same normal),
a 'loop normal space' (or lnor space), using auto-computed normal and relevant edges, and store
custom normal as two angular factors inside that space. This allows to have custom normals
'following' deformations of the geometry, and to only save two shorts per loop in new clnor CDLayer.
Normal manipulation (editing, mixing, interpolating, etc.) shall always happen with plain 3D vectors normals,
and be converted back into storage format at the end.
Clnor computation has also been threaded (at least for Mesh case, not for BMesh), since the process can
be rather heavy with high poly meshes.
Also, bumping subversion, and fix mess in 2.70 versioning code.
2015-02-05 14:24:48 +01:00
|
|
|
struct MemArena *mem;
|
|
|
|
} MLoopNorSpaceArray;
|
Refactor: Merge non-functional-change part of 'edit normals' 2017 GSoC.
This merges changes in internals, runtime-only of existing custom
normals code, which make sense as of themselves, and will make diff of
soc branch easier/lighter to review.
In the details, it mostly changes two things:
* Now, smooth fans (aka MLoopNorSpaceArray) can store either loop
indices, or pointers to BMLoop themselves. This makes sense since in
BMesh, it's relatively easy to get index from a BMElement, but nearly
impracticable to go the other way around.
* First change enforces another, now we cannot rely anymore on `loops`
being NULL in MLoopNorSpace to detect single-loop fans, so we instead
store that info in a new flag.
Again, these are expected to be totally non-functional changes.
2018-03-01 16:54:21 +01:00
|
|
|
/**
|
|
|
|
* MLoopNorSpaceArray.data_type
|
|
|
|
*/
|
|
|
|
enum {
|
|
|
|
MLNOR_SPACEARR_LOOP_INDEX = 0,
|
|
|
|
MLNOR_SPACEARR_BMLOOP_PTR = 1,
|
|
|
|
};
|
|
|
|
|
2019-02-28 20:40:21 +01:00
|
|
|
/* Low-level custom normals functions. */
|
Refactor: Merge non-functional-change part of 'edit normals' 2017 GSoC.
This merges changes in internals, runtime-only of existing custom
normals code, which make sense as of themselves, and will make diff of
soc branch easier/lighter to review.
In the details, it mostly changes two things:
* Now, smooth fans (aka MLoopNorSpaceArray) can store either loop
indices, or pointers to BMLoop themselves. This makes sense since in
BMesh, it's relatively easy to get index from a BMElement, but nearly
impracticable to go the other way around.
* First change enforces another, now we cannot rely anymore on `loops`
being NULL in MLoopNorSpace to detect single-loop fans, so we instead
store that info in a new flag.
Again, these are expected to be totally non-functional changes.
2018-03-01 16:54:21 +01:00
|
|
|
void BKE_lnor_spacearr_init(MLoopNorSpaceArray *lnors_spacearr,
|
|
|
|
const int numLoops,
|
|
|
|
const char data_type);
|
Add Custom Loop Normals.
This is the core code for it, tools (datatransfer and modifier) will come in next commits).
RNA api is already there, though.
See the code for details, but basically, we define, for each 'smooth fan'
(which is a set of adjacent loops around a same vertex that are smooth, i.e. have a single same normal),
a 'loop normal space' (or lnor space), using auto-computed normal and relevant edges, and store
custom normal as two angular factors inside that space. This allows to have custom normals
'following' deformations of the geometry, and to only save two shorts per loop in new clnor CDLayer.
Normal manipulation (editing, mixing, interpolating, etc.) shall always happen with plain 3D vectors normals,
and be converted back into storage format at the end.
Clnor computation has also been threaded (at least for Mesh case, not for BMesh), since the process can
be rather heavy with high poly meshes.
Also, bumping subversion, and fix mess in 2.70 versioning code.
2015-02-05 14:24:48 +01:00
|
|
|
void BKE_lnor_spacearr_clear(MLoopNorSpaceArray *lnors_spacearr);
|
|
|
|
void BKE_lnor_spacearr_free(MLoopNorSpaceArray *lnors_spacearr);
|
|
|
|
MLoopNorSpace *BKE_lnor_space_create(MLoopNorSpaceArray *lnors_spacearr);
|
|
|
|
void BKE_lnor_space_define(MLoopNorSpace *lnor_space,
|
|
|
|
const float lnor[3],
|
|
|
|
float vec_ref[3],
|
|
|
|
float vec_other[3],
|
|
|
|
struct BLI_Stack *edge_vectors);
|
Refactor: Merge non-functional-change part of 'edit normals' 2017 GSoC.
This merges changes in internals, runtime-only of existing custom
normals code, which make sense as of themselves, and will make diff of
soc branch easier/lighter to review.
In the details, it mostly changes two things:
* Now, smooth fans (aka MLoopNorSpaceArray) can store either loop
indices, or pointers to BMLoop themselves. This makes sense since in
BMesh, it's relatively easy to get index from a BMElement, but nearly
impracticable to go the other way around.
* First change enforces another, now we cannot rely anymore on `loops`
being NULL in MLoopNorSpace to detect single-loop fans, so we instead
store that info in a new flag.
Again, these are expected to be totally non-functional changes.
2018-03-01 16:54:21 +01:00
|
|
|
void BKE_lnor_space_add_loop(MLoopNorSpaceArray *lnors_spacearr,
|
|
|
|
MLoopNorSpace *lnor_space,
|
|
|
|
const int ml_index,
|
|
|
|
void *bm_loop,
|
|
|
|
const bool is_single);
|
Add Custom Loop Normals.
This is the core code for it, tools (datatransfer and modifier) will come in next commits).
RNA api is already there, though.
See the code for details, but basically, we define, for each 'smooth fan'
(which is a set of adjacent loops around a same vertex that are smooth, i.e. have a single same normal),
a 'loop normal space' (or lnor space), using auto-computed normal and relevant edges, and store
custom normal as two angular factors inside that space. This allows to have custom normals
'following' deformations of the geometry, and to only save two shorts per loop in new clnor CDLayer.
Normal manipulation (editing, mixing, interpolating, etc.) shall always happen with plain 3D vectors normals,
and be converted back into storage format at the end.
Clnor computation has also been threaded (at least for Mesh case, not for BMesh), since the process can
be rather heavy with high poly meshes.
Also, bumping subversion, and fix mess in 2.70 versioning code.
2015-02-05 14:24:48 +01:00
|
|
|
void BKE_lnor_space_custom_data_to_normal(MLoopNorSpace *lnor_space,
|
|
|
|
const short clnor_data[2],
|
|
|
|
float r_custom_lnor[3]);
|
|
|
|
void BKE_lnor_space_custom_normal_to_data(MLoopNorSpace *lnor_space,
|
|
|
|
const float custom_lnor[3],
|
|
|
|
short r_clnor_data[2]);
|
|
|
|
|
2019-02-28 20:40:21 +01:00
|
|
|
/* Medium-level custom normals functions. */
|
2015-07-11 04:39:27 +10:00
|
|
|
void BKE_mesh_normals_loop_split(const struct MVert *mverts,
|
|
|
|
const int numVerts,
|
|
|
|
struct MEdge *medges,
|
|
|
|
const int numEdges,
|
Add Custom Loop Normals.
This is the core code for it, tools (datatransfer and modifier) will come in next commits).
RNA api is already there, though.
See the code for details, but basically, we define, for each 'smooth fan'
(which is a set of adjacent loops around a same vertex that are smooth, i.e. have a single same normal),
a 'loop normal space' (or lnor space), using auto-computed normal and relevant edges, and store
custom normal as two angular factors inside that space. This allows to have custom normals
'following' deformations of the geometry, and to only save two shorts per loop in new clnor CDLayer.
Normal manipulation (editing, mixing, interpolating, etc.) shall always happen with plain 3D vectors normals,
and be converted back into storage format at the end.
Clnor computation has also been threaded (at least for Mesh case, not for BMesh), since the process can
be rather heavy with high poly meshes.
Also, bumping subversion, and fix mess in 2.70 versioning code.
2015-02-05 14:24:48 +01:00
|
|
|
struct MLoop *mloops,
|
|
|
|
float (*r_loopnors)[3],
|
|
|
|
const int numLoops,
|
|
|
|
struct MPoly *mpolys,
|
|
|
|
const float (*polynors)[3],
|
|
|
|
const int numPolys,
|
2018-02-20 13:03:10 +01:00
|
|
|
const bool use_split_normals,
|
|
|
|
const float split_angle,
|
Add Custom Loop Normals.
This is the core code for it, tools (datatransfer and modifier) will come in next commits).
RNA api is already there, though.
See the code for details, but basically, we define, for each 'smooth fan'
(which is a set of adjacent loops around a same vertex that are smooth, i.e. have a single same normal),
a 'loop normal space' (or lnor space), using auto-computed normal and relevant edges, and store
custom normal as two angular factors inside that space. This allows to have custom normals
'following' deformations of the geometry, and to only save two shorts per loop in new clnor CDLayer.
Normal manipulation (editing, mixing, interpolating, etc.) shall always happen with plain 3D vectors normals,
and be converted back into storage format at the end.
Clnor computation has also been threaded (at least for Mesh case, not for BMesh), since the process can
be rather heavy with high poly meshes.
Also, bumping subversion, and fix mess in 2.70 versioning code.
2015-02-05 14:24:48 +01:00
|
|
|
MLoopNorSpaceArray *r_lnors_spacearr,
|
|
|
|
short (*clnors_data)[2],
|
|
|
|
int *r_loop_to_poly);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Add Custom Loop Normals.
This is the core code for it, tools (datatransfer and modifier) will come in next commits).
RNA api is already there, though.
See the code for details, but basically, we define, for each 'smooth fan'
(which is a set of adjacent loops around a same vertex that are smooth, i.e. have a single same normal),
a 'loop normal space' (or lnor space), using auto-computed normal and relevant edges, and store
custom normal as two angular factors inside that space. This allows to have custom normals
'following' deformations of the geometry, and to only save two shorts per loop in new clnor CDLayer.
Normal manipulation (editing, mixing, interpolating, etc.) shall always happen with plain 3D vectors normals,
and be converted back into storage format at the end.
Clnor computation has also been threaded (at least for Mesh case, not for BMesh), since the process can
be rather heavy with high poly meshes.
Also, bumping subversion, and fix mess in 2.70 versioning code.
2015-02-05 14:24:48 +01:00
|
|
|
void BKE_mesh_normals_loop_custom_set(const struct MVert *mverts,
|
2015-07-11 04:39:27 +10:00
|
|
|
const int numVerts,
|
|
|
|
struct MEdge *medges,
|
|
|
|
const int numEdges,
|
2015-09-04 22:41:10 +02:00
|
|
|
struct MLoop *mloops,
|
|
|
|
float (*r_custom_loopnors)[3],
|
|
|
|
const int numLoops,
|
Add Custom Loop Normals.
This is the core code for it, tools (datatransfer and modifier) will come in next commits).
RNA api is already there, though.
See the code for details, but basically, we define, for each 'smooth fan'
(which is a set of adjacent loops around a same vertex that are smooth, i.e. have a single same normal),
a 'loop normal space' (or lnor space), using auto-computed normal and relevant edges, and store
custom normal as two angular factors inside that space. This allows to have custom normals
'following' deformations of the geometry, and to only save two shorts per loop in new clnor CDLayer.
Normal manipulation (editing, mixing, interpolating, etc.) shall always happen with plain 3D vectors normals,
and be converted back into storage format at the end.
Clnor computation has also been threaded (at least for Mesh case, not for BMesh), since the process can
be rather heavy with high poly meshes.
Also, bumping subversion, and fix mess in 2.70 versioning code.
2015-02-05 14:24:48 +01:00
|
|
|
struct MPoly *mpolys,
|
|
|
|
const float (*polynors)[3],
|
|
|
|
const int numPolys,
|
|
|
|
short (*r_clnors_data)[2]);
|
|
|
|
void BKE_mesh_normals_loop_custom_from_vertices_set(const struct MVert *mverts,
|
2015-09-04 22:41:10 +02:00
|
|
|
float (*r_custom_vertnors)[3],
|
|
|
|
const int numVerts,
|
Add Custom Loop Normals.
This is the core code for it, tools (datatransfer and modifier) will come in next commits).
RNA api is already there, though.
See the code for details, but basically, we define, for each 'smooth fan'
(which is a set of adjacent loops around a same vertex that are smooth, i.e. have a single same normal),
a 'loop normal space' (or lnor space), using auto-computed normal and relevant edges, and store
custom normal as two angular factors inside that space. This allows to have custom normals
'following' deformations of the geometry, and to only save two shorts per loop in new clnor CDLayer.
Normal manipulation (editing, mixing, interpolating, etc.) shall always happen with plain 3D vectors normals,
and be converted back into storage format at the end.
Clnor computation has also been threaded (at least for Mesh case, not for BMesh), since the process can
be rather heavy with high poly meshes.
Also, bumping subversion, and fix mess in 2.70 versioning code.
2015-02-05 14:24:48 +01:00
|
|
|
struct MEdge *medges,
|
|
|
|
const int numEdges,
|
|
|
|
struct MLoop *mloops,
|
|
|
|
const int numLoops,
|
|
|
|
struct MPoly *mpolys,
|
|
|
|
const float (*polynors)[3],
|
|
|
|
const int numPolys,
|
|
|
|
short (*r_clnors_data)[2]);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-08-12 18:21:41 +02:00
|
|
|
void BKE_mesh_normals_loop_to_vertex(const int numVerts,
|
|
|
|
const struct MLoop *mloops,
|
|
|
|
const int numLoops,
|
|
|
|
const float (*clnors)[3],
|
|
|
|
float (*r_vert_clnors)[3]);
|
|
|
|
|
2019-02-28 20:40:21 +01:00
|
|
|
/* High-level custom normals functions. */
|
|
|
|
bool BKE_mesh_has_custom_loop_normals(struct Mesh *me);
|
|
|
|
|
|
|
|
void BKE_mesh_calc_normals_split(struct Mesh *mesh);
|
|
|
|
void BKE_mesh_calc_normals_split_ex(struct Mesh *mesh,
|
|
|
|
struct MLoopNorSpaceArray *r_lnors_spacearr);
|
|
|
|
|
|
|
|
void BKE_mesh_set_custom_normals(struct Mesh *mesh, float (*r_custom_loopnors)[3]);
|
|
|
|
void BKE_mesh_set_custom_normals_from_vertices(struct Mesh *mesh, float (*r_custom_vertnors)[3]);
|
|
|
|
|
2013-09-09 02:11:44 +00:00
|
|
|
void BKE_mesh_calc_poly_normal(const struct MPoly *mpoly,
|
2015-07-11 04:39:27 +10:00
|
|
|
const struct MLoop *loopstart,
|
|
|
|
const struct MVert *mvarray,
|
|
|
|
float r_no[3]);
|
2013-09-09 02:11:44 +00:00
|
|
|
void BKE_mesh_calc_poly_normal_coords(const struct MPoly *mpoly,
|
2015-07-11 04:39:27 +10:00
|
|
|
const struct MLoop *loopstart,
|
|
|
|
const float (*vertex_coords)[3],
|
|
|
|
float r_no[3]);
|
2013-09-09 02:11:44 +00:00
|
|
|
void BKE_mesh_calc_poly_center(const struct MPoly *mpoly,
|
2015-07-11 04:39:27 +10:00
|
|
|
const struct MLoop *loopstart,
|
|
|
|
const struct MVert *mvarray,
|
|
|
|
float r_cent[3]);
|
2013-09-09 02:11:44 +00:00
|
|
|
float BKE_mesh_calc_poly_area(const struct MPoly *mpoly,
|
2015-07-11 04:39:27 +10:00
|
|
|
const struct MLoop *loopstart,
|
|
|
|
const struct MVert *mvarray);
|
2019-09-09 19:41:12 +02:00
|
|
|
float BKE_mesh_calc_area(const struct Mesh *me);
|
2019-07-14 16:49:44 +02:00
|
|
|
float BKE_mesh_calc_poly_uv_area(const struct MPoly *mpoly, const struct MLoopUV *uv_array);
|
2013-09-09 02:11:44 +00:00
|
|
|
void BKE_mesh_calc_poly_angles(const struct MPoly *mpoly,
|
2015-07-11 04:39:27 +10:00
|
|
|
const struct MLoop *loopstart,
|
|
|
|
const struct MVert *mvarray,
|
|
|
|
float angles[]);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-09-09 02:11:44 +00:00
|
|
|
void BKE_mesh_poly_edgehash_insert(struct EdgeHash *ehash,
|
|
|
|
const struct MPoly *mp,
|
|
|
|
const struct MLoop *mloop);
|
|
|
|
void BKE_mesh_poly_edgebitmap_insert(unsigned int *edge_bitmap,
|
|
|
|
const struct MPoly *mp,
|
|
|
|
const struct MLoop *mloop);
|
|
|
|
|
2015-07-11 04:39:27 +10:00
|
|
|
bool BKE_mesh_center_median(const struct Mesh *me, float r_cent[3]);
|
2020-06-18 22:27:46 +10:00
|
|
|
bool BKE_mesh_center_median_from_polys(const struct Mesh *me, float r_cent[3]);
|
2015-07-11 04:39:27 +10:00
|
|
|
bool BKE_mesh_center_bounds(const struct Mesh *me, float r_cent[3]);
|
2017-08-21 15:06:07 +10:00
|
|
|
bool BKE_mesh_center_of_surface(const struct Mesh *me, float r_cent[3]);
|
|
|
|
bool BKE_mesh_center_of_volume(const struct Mesh *me, float r_cent[3]);
|
2013-05-28 14:23:07 +00:00
|
|
|
|
2015-07-20 05:19:47 +10:00
|
|
|
void BKE_mesh_calc_volume(const struct MVert *mverts,
|
|
|
|
const int mverts_num,
|
|
|
|
const struct MLoopTri *mlooptri,
|
|
|
|
const int looptri_num,
|
|
|
|
const struct MLoop *mloop,
|
|
|
|
float *r_volume,
|
|
|
|
float r_center[3]);
|
2014-07-11 12:06:13 +02:00
|
|
|
|
2013-09-09 02:11:44 +00:00
|
|
|
/* tessface */
|
|
|
|
void BKE_mesh_loops_to_mface_corners(struct CustomData *fdata,
|
|
|
|
struct CustomData *ldata,
|
2014-01-22 02:56:52 +11:00
|
|
|
struct CustomData *pdata,
|
|
|
|
unsigned int lindex[4],
|
|
|
|
int findex,
|
2013-09-09 02:11:44 +00:00
|
|
|
const int polyindex,
|
|
|
|
const int mf_len,
|
2020-09-04 20:59:13 +02:00
|
|
|
const int numUV,
|
2013-09-09 02:11:44 +00:00
|
|
|
const int numCol,
|
2014-04-13 12:18:51 +02:00
|
|
|
const bool hasPCol,
|
|
|
|
const bool hasOrigSpace,
|
|
|
|
const bool hasLNor);
|
2014-01-21 16:32:36 +01:00
|
|
|
void BKE_mesh_loops_to_tessdata(struct CustomData *fdata,
|
2017-05-25 15:11:00 +10:00
|
|
|
struct CustomData *ldata,
|
|
|
|
struct MFace *mface,
|
2020-07-13 11:27:09 +02:00
|
|
|
const int *polyindices,
|
2014-01-21 16:32:36 +01:00
|
|
|
unsigned int (*loopindices)[4],
|
|
|
|
const int num_faces);
|
2016-04-26 18:43:02 +10:00
|
|
|
void BKE_mesh_tangent_loops_to_tessdata(struct CustomData *fdata,
|
|
|
|
struct CustomData *ldata,
|
|
|
|
struct MFace *mface,
|
2020-07-13 11:27:09 +02:00
|
|
|
const int *polyindices,
|
2016-04-26 18:43:02 +10:00
|
|
|
unsigned int (*loopindices)[4],
|
|
|
|
const int num_faces,
|
|
|
|
const char *layer_name);
|
2019-08-25 14:32:47 +10:00
|
|
|
int BKE_mesh_tessface_calc_ex(struct CustomData *fdata,
|
|
|
|
struct CustomData *ldata,
|
|
|
|
struct CustomData *pdata,
|
|
|
|
struct MVert *mvert,
|
|
|
|
int totface,
|
|
|
|
int totloop,
|
|
|
|
int totpoly,
|
|
|
|
const bool do_face_nor_copy);
|
2015-07-17 03:36:03 +10:00
|
|
|
void BKE_mesh_recalc_looptri(const struct MLoop *mloop,
|
|
|
|
const struct MPoly *mpoly,
|
|
|
|
const struct MVert *mvert,
|
|
|
|
int totloop,
|
|
|
|
int totpoly,
|
|
|
|
struct MLoopTri *mlooptri);
|
2013-09-09 02:11:44 +00:00
|
|
|
void BKE_mesh_convert_mfaces_to_mpolys(struct Mesh *mesh);
|
|
|
|
void BKE_mesh_do_versions_convert_mfaces_to_mpolys(struct Mesh *mesh);
|
|
|
|
void BKE_mesh_convert_mfaces_to_mpolys_ex(struct ID *id,
|
|
|
|
struct CustomData *fdata,
|
|
|
|
struct CustomData *ldata,
|
|
|
|
struct CustomData *pdata,
|
|
|
|
int totedge_i,
|
|
|
|
int totface_i,
|
|
|
|
int totloop_i,
|
|
|
|
int totpoly_i,
|
|
|
|
struct MEdge *medge,
|
|
|
|
struct MFace *mface,
|
2014-03-16 03:24:05 +11:00
|
|
|
int *r_totloop,
|
|
|
|
int *r_totpoly,
|
|
|
|
struct MLoop **r_mloop,
|
|
|
|
struct MPoly **r_mpoly);
|
2013-09-09 02:11:44 +00:00
|
|
|
|
2016-03-14 15:17:29 +11:00
|
|
|
void BKE_mesh_mdisp_flip(struct MDisps *md, const bool use_loop_mdisp_flip);
|
|
|
|
|
2016-03-14 15:32:48 +11:00
|
|
|
void BKE_mesh_polygon_flip_ex(struct MPoly *mpoly,
|
|
|
|
struct MLoop *mloop,
|
|
|
|
struct CustomData *ldata,
|
2016-06-07 13:04:05 +02:00
|
|
|
float (*lnors)[3],
|
|
|
|
struct MDisps *mdisp,
|
|
|
|
const bool use_loop_mdisp_flip);
|
2016-02-28 15:29:56 +01:00
|
|
|
void BKE_mesh_polygon_flip(struct MPoly *mpoly, struct MLoop *mloop, struct CustomData *ldata);
|
|
|
|
void BKE_mesh_polygons_flip(struct MPoly *mpoly,
|
|
|
|
struct MLoop *mloop,
|
|
|
|
struct CustomData *ldata,
|
|
|
|
int totpoly);
|
|
|
|
|
2018-04-25 12:21:07 +02:00
|
|
|
/* merge verts */
|
|
|
|
/* Enum for merge_mode of CDDM_merge_verts.
|
|
|
|
* Refer to mesh.c for details. */
|
|
|
|
enum {
|
|
|
|
MESH_MERGE_VERTS_DUMP_IF_MAPPED,
|
|
|
|
MESH_MERGE_VERTS_DUMP_IF_EQUAL,
|
|
|
|
};
|
|
|
|
struct Mesh *BKE_mesh_merge_verts(struct Mesh *mesh,
|
|
|
|
const int *vtargetmap,
|
|
|
|
const int tot_vtargetmap,
|
|
|
|
const int merge_mode);
|
|
|
|
|
2013-09-09 02:11:44 +00:00
|
|
|
/* flush flags */
|
|
|
|
void BKE_mesh_flush_hidden_from_verts_ex(const struct MVert *mvert,
|
|
|
|
const struct MLoop *mloop,
|
|
|
|
struct MEdge *medge,
|
|
|
|
const int totedge,
|
|
|
|
struct MPoly *mpoly,
|
|
|
|
const int totpoly);
|
|
|
|
void BKE_mesh_flush_hidden_from_verts(struct Mesh *me);
|
|
|
|
void BKE_mesh_flush_hidden_from_polys_ex(struct MVert *mvert,
|
|
|
|
const struct MLoop *mloop,
|
|
|
|
struct MEdge *medge,
|
|
|
|
const int totedge,
|
|
|
|
const struct MPoly *mpoly,
|
|
|
|
const int totpoly);
|
|
|
|
void BKE_mesh_flush_hidden_from_polys(struct Mesh *me);
|
|
|
|
void BKE_mesh_flush_select_from_polys_ex(struct MVert *mvert,
|
|
|
|
const int totvert,
|
|
|
|
const struct MLoop *mloop,
|
|
|
|
struct MEdge *medge,
|
|
|
|
const int totedge,
|
|
|
|
const struct MPoly *mpoly,
|
|
|
|
const int totpoly);
|
|
|
|
void BKE_mesh_flush_select_from_polys(struct Mesh *me);
|
|
|
|
void BKE_mesh_flush_select_from_verts_ex(const struct MVert *mvert,
|
|
|
|
const int totvert,
|
|
|
|
const struct MLoop *mloop,
|
|
|
|
struct MEdge *medge,
|
|
|
|
const int totedge,
|
|
|
|
struct MPoly *mpoly,
|
|
|
|
const int totpoly);
|
|
|
|
void BKE_mesh_flush_select_from_verts(struct Mesh *me);
|
2013-06-14 07:15:38 +00:00
|
|
|
|
2013-09-09 02:11:44 +00:00
|
|
|
/* spatial evaluation */
|
|
|
|
void BKE_mesh_calc_relative_deform(const struct MPoly *mpoly,
|
|
|
|
const int totpoly,
|
|
|
|
const struct MLoop *mloop,
|
|
|
|
const int totvert,
|
2009-01-21 22:40:28 +00:00
|
|
|
|
2013-09-09 02:11:44 +00:00
|
|
|
const float (*vert_cos_src)[3],
|
|
|
|
const float (*vert_cos_dst)[3],
|
2007-09-18 19:39:25 +00:00
|
|
|
|
2013-09-09 02:11:44 +00:00
|
|
|
const float (*vert_cos_org)[3],
|
|
|
|
float (*vert_cos_new)[3]);
|
2007-09-18 19:39:25 +00:00
|
|
|
|
2013-09-09 02:11:44 +00:00
|
|
|
/* *** mesh_validate.c *** */
|
|
|
|
|
2018-07-01 15:47:09 +02:00
|
|
|
bool BKE_mesh_validate(struct Mesh *me, const bool do_verbose, const bool cddata_check_mask);
|
2018-04-27 00:39:53 -04:00
|
|
|
bool BKE_mesh_is_valid(struct Mesh *me);
|
2018-07-01 15:47:09 +02:00
|
|
|
bool BKE_mesh_validate_material_indices(struct Mesh *me);
|
2013-09-09 02:11:44 +00:00
|
|
|
|
2013-09-04 01:29:34 +00:00
|
|
|
bool BKE_mesh_validate_arrays(struct Mesh *me,
|
2011-12-08 04:51:03 +00:00
|
|
|
struct MVert *mverts,
|
|
|
|
unsigned int totvert,
|
|
|
|
struct MEdge *medges,
|
|
|
|
unsigned int totedge,
|
2012-06-28 09:08:11 +00:00
|
|
|
struct MFace *mfaces,
|
|
|
|
unsigned int totface,
|
2012-03-15 20:10:07 +00:00
|
|
|
struct MLoop *mloops,
|
|
|
|
unsigned int totloop,
|
|
|
|
struct MPoly *mpolys,
|
|
|
|
unsigned int totpoly,
|
2011-12-08 04:51:03 +00:00
|
|
|
struct MDeformVert *dverts, /* assume totvert length */
|
2013-09-04 01:29:34 +00:00
|
|
|
const bool do_verbose,
|
|
|
|
const bool do_fixes,
|
|
|
|
bool *r_change);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-09-04 01:29:34 +00:00
|
|
|
bool BKE_mesh_validate_all_customdata(struct CustomData *vdata,
|
2018-12-03 16:19:08 +01:00
|
|
|
const uint totvert,
|
|
|
|
struct CustomData *edata,
|
|
|
|
const uint totedge,
|
|
|
|
struct CustomData *ldata,
|
|
|
|
const uint totloop,
|
|
|
|
struct CustomData *pdata,
|
|
|
|
const uint totpoly,
|
2013-09-04 06:50:15 +00:00
|
|
|
const bool check_meshmask,
|
2013-09-04 01:29:34 +00:00
|
|
|
const bool do_verbose,
|
|
|
|
const bool do_fixes,
|
|
|
|
bool *r_change);
|
|
|
|
|
2013-09-09 02:11:44 +00:00
|
|
|
void BKE_mesh_strip_loose_faces(struct Mesh *me);
|
|
|
|
void BKE_mesh_strip_loose_polysloops(struct Mesh *me);
|
|
|
|
void BKE_mesh_strip_loose_edges(struct Mesh *me);
|
2011-02-09 02:28:11 +00:00
|
|
|
|
2013-09-09 02:11:44 +00:00
|
|
|
void BKE_mesh_calc_edges_legacy(struct Mesh *me, const bool use_old);
|
2018-10-24 11:37:44 +11:00
|
|
|
void BKE_mesh_calc_edges_loose(struct Mesh *mesh);
|
2020-10-09 11:56:12 +02:00
|
|
|
void BKE_mesh_calc_edges(struct Mesh *mesh, bool keep_existing_edges, const bool select_new_edges);
|
2018-09-25 12:35:43 +02:00
|
|
|
void BKE_mesh_calc_edges_tessface(struct Mesh *mesh);
|
2011-02-09 15:13:20 +00:00
|
|
|
|
2020-12-14 13:00:28 +01:00
|
|
|
/* In DerivedMesh.cc */
|
2020-05-25 20:16:42 +10:00
|
|
|
void BKE_mesh_wrapper_deferred_finalize(struct Mesh *me_eval,
|
2020-09-04 20:59:13 +02:00
|
|
|
const CustomData_MeshMasks *cd_mask_finalize);
|
2020-05-25 20:16:42 +10:00
|
|
|
|
2015-05-12 13:57:11 +05:00
|
|
|
/* **** Depsgraph evaluation **** */
|
|
|
|
|
2018-04-06 12:07:27 +02:00
|
|
|
void BKE_mesh_eval_geometry(struct Depsgraph *depsgraph, struct Mesh *mesh);
|
2015-05-12 13:57:11 +05:00
|
|
|
|
2017-04-21 21:14:11 +10:00
|
|
|
/* Draw Cache */
|
2020-10-09 07:27:18 +02:00
|
|
|
void BKE_mesh_batch_cache_dirty_tag(struct Mesh *me, eMeshBatchDirtyMode mode);
|
2017-04-21 21:14:11 +10:00
|
|
|
void BKE_mesh_batch_cache_free(struct Mesh *me);
|
|
|
|
|
2020-10-09 07:27:18 +02:00
|
|
|
extern void (*BKE_mesh_batch_cache_dirty_tag_cb)(struct Mesh *me, eMeshBatchDirtyMode mode);
|
2019-02-23 12:58:39 +11:00
|
|
|
extern void (*BKE_mesh_batch_cache_free_cb)(struct Mesh *me);
|
|
|
|
|
2018-05-15 13:26:40 +02:00
|
|
|
/* Inlines */
|
|
|
|
|
2018-10-15 16:58:42 +11:00
|
|
|
/* Instead of -1 that function uses ORIGINDEX_NONE as defined in BKE_customdata.h,
|
2018-05-15 13:26:40 +02:00
|
|
|
* but I don't want to force every user of BKE_mesh.h to also include that file.
|
|
|
|
* ~~ Sybren */
|
|
|
|
BLI_INLINE int BKE_mesh_origindex_mface_mpoly(const int *index_mf_to_mpoly,
|
|
|
|
const int *index_mp_to_orig,
|
|
|
|
const int i)
|
|
|
|
{
|
|
|
|
const int j = index_mf_to_mpoly[i];
|
|
|
|
return (j != -1) ? (index_mp_to_orig ? index_mp_to_orig[j] : j) : -1;
|
|
|
|
}
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|