2011-02-18 13:05:18 +00:00
|
|
|
/*
|
2008-04-16 22:40:48 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
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.
|
|
|
|
*
|
|
|
|
* The Original Code is: all of this file.
|
|
|
|
*
|
2011-10-10 09:38:02 +00:00
|
|
|
* Contributor(s): (mar-2001 nzc)
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
2008-04-16 22:40:48 +00:00
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
2002-10-12 11:37:38 +00:00
|
|
|
*/
|
2012-02-17 18:59:41 +00:00
|
|
|
#ifndef __BKE_MESH_H__
|
|
|
|
#define __BKE_MESH_H__
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2011-02-18 13:05:18 +00:00
|
|
|
/** \file BKE_mesh.h
|
|
|
|
* \ingroup bke
|
|
|
|
*/
|
|
|
|
|
2018-05-15 13:26:40 +02:00
|
|
|
/* defines BLI_INLINE */
|
2018-11-07 12:19:10 +11:00
|
|
|
#include "BLI_compiler_compat.h"
|
2018-05-15 13:26:40 +02:00
|
|
|
|
2018-06-01 17:05:21 +02:00
|
|
|
/* defines CustomDataMask */
|
|
|
|
#include "BKE_customdata.h"
|
|
|
|
|
2012-06-04 12:10:38 +00:00
|
|
|
struct ID;
|
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;
|
2018-04-06 12:07:27 +02:00
|
|
|
struct Depsgraph;
|
2013-04-22 12:00:37 +00:00
|
|
|
struct EdgeHash;
|
2002-10-12 11:37:38 +00:00
|
|
|
struct ListBase;
|
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 LinkNode;
|
|
|
|
struct BLI_Stack;
|
|
|
|
struct MemArena;
|
2010-09-04 05:31:25 +00:00
|
|
|
struct BMesh;
|
2018-06-01 17:05:21 +02:00
|
|
|
struct KeyBlock;
|
2015-07-17 03:36:03 +10:00
|
|
|
struct MLoopTri;
|
2013-02-05 12:46:15 +00:00
|
|
|
struct Main;
|
2002-10-12 11:37:38 +00:00
|
|
|
struct Mesh;
|
2018-06-01 17:05:21 +02:00
|
|
|
struct ModifierData;
|
2010-09-04 05:31:25 +00:00
|
|
|
struct MPoly;
|
|
|
|
struct MLoop;
|
2002-10-12 11:37:38 +00:00
|
|
|
struct MFace;
|
2009-01-23 20:36:47 +00:00
|
|
|
struct MEdge;
|
2002-10-12 11:37:38 +00:00
|
|
|
struct MVert;
|
2018-05-17 15:26:59 +02:00
|
|
|
struct MVertTri;
|
2010-09-04 05:31:25 +00:00
|
|
|
struct MDeformVert;
|
2016-03-14 15:17:29 +11:00
|
|
|
struct MDisps;
|
2002-10-12 11:37:38 +00:00
|
|
|
struct Object;
|
Added custom vertex/edge/face data for meshes:
All data layers, including MVert/MEdge/MFace, are now managed as custom
data layers. The pointers like Mesh.mvert, Mesh.dvert or Mesh.mcol are
still used of course, but allocating, copying or freeing these arrays
should be done through the CustomData API.
Work in progress documentation on this is here:
http://mediawiki.blender.org/index.php/BlenderDev/BlenderArchitecture/CustomData
Replaced TFace by MTFace:
This is the same struct, except that it does not contain color, that now
always stays separated in MCol. This was not a good design decision to
begin with, and it is needed for adding multiple color layers later. Note
that this does mean older Blender versions will not be able to read UV
coordinates from the next release, due to an SDNA limitation.
Removed DispListMesh:
This now fully replaced by DerivedMesh. To provide access to arrays of
vertices, edges and faces, like DispListMesh does. The semantics of the
DerivedMesh.getVertArray() and similar functions were changed to return
a pointer to an array if one exists, or otherwise allocate a temporary
one. On releasing the DerivedMesh, this temporary array will be removed
automatically.
Removed ssDM and meshDM DerivedMesh backends:
The ssDM backend was for DispListMesh, so that became obsolete automatically.
The meshDM backend was replaced by the custom data backend, that now figures
out which layers need to be modified, and only duplicates those.
This changes code in many places, and overall removes 2514 lines of code.
So, there's a good chance this might break some stuff, although I've been
testing it for a few days now. The good news is, adding multiple color and
uv layers should now become easy.
2006-11-20 04:28:02 +00:00
|
|
|
struct CustomData;
|
2011-02-09 02:28:11 +00:00
|
|
|
struct Scene;
|
2011-10-30 09:19:07 +00:00
|
|
|
struct MLoopUV;
|
2014-01-11 11:31:44 +01:00
|
|
|
struct ReportList;
|
2018-10-09 15:37:10 +11:00
|
|
|
struct BMEditMesh;
|
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(
|
2018-11-20 13:28:25 +11:00
|
|
|
const struct Mesh *me,
|
2018-05-02 11:39:23 +02:00
|
|
|
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
|
|
|
|
2018-10-09 16:09:59 +11:00
|
|
|
struct Mesh *BKE_mesh_from_bmesh_nomain(struct BMesh *bm, const struct BMeshToMeshParams *params);
|
2018-12-13 11:18:02 +00:00
|
|
|
struct Mesh *BKE_mesh_from_bmesh_for_eval_nomain(struct BMesh *bm, const int64_t cd_mask_extra);
|
2018-05-02 11:39:23 +02:00
|
|
|
|
2018-10-09 15:37:10 +11:00
|
|
|
struct Mesh *BKE_mesh_from_editmesh_with_coords_thin_wrap(
|
|
|
|
struct BMEditMesh *em, CustomDataMask data_mask, float (*vertexCos)[3]);
|
|
|
|
|
2015-04-19 14:21:23 +10:00
|
|
|
int poly_find_loop_from_vert(
|
|
|
|
const struct MPoly *poly,
|
2015-07-11 04:39:27 +10:00
|
|
|
const struct MLoop *loopstart, unsigned vert);
|
2015-04-19 14:21:23 +10:00
|
|
|
int poly_get_adj_loops_from_vert(
|
2015-07-11 04:39:27 +10:00
|
|
|
const struct MPoly *poly,
|
|
|
|
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);
|
First step to handle missing libs/datablocks when reading a file.
Idea is, instead of ignoring completely missing linked datablocks, to
create void placeholders for them.
That way, you can work on your file, save it, and find again your missing data once
lib becomes available again. Or you can edit missing lib's path (in Outliner),
save and reload the file, and you are done.
Also, Outliner now shows broken libraries (and placeholders) with a 'broken lib' icon.
Future plans are also to be able to relocate missing libs and reload them at runtime.
Code notes:
- Placeholder ID is just a regular datablock of same type as expected linked one,
with 'default' data, and a LIB_MISSING bitflag set.
- To allow creation of such datablocks, creation of datablocks in BKE was split in two step:
+ Allocation of memory itself.
+ Setting of all internal data to default values.
See also the design task (T43351).
Reviewed by @campbellbarton, thanks a bunch!
Differential Revision: https://developer.blender.org/D1394
2015-10-20 14:44:57 +02:00
|
|
|
void BKE_mesh_init(struct Mesh *me);
|
2013-02-05 12:46:15 +00:00
|
|
|
struct Mesh *BKE_mesh_add(struct Main *bmain, const char *name);
|
Refactor ID copying (and to some extent, ID freeing).
This will allow much finer controll over how we copy data-blocks, from
full copy in Main database, to "lighter" ones (out of Main, inside an
already allocated datablock, etc.).
This commit also transfers a llot of what was previously handled by
per-ID-type custom code to generic ID handling code in BKE_library.
Hopefully will avoid in future inconsistencies and missing bits we had
all over the codebase in the past.
It also adds missing copying handling for a few types, most notably
Scene (which where using a fully customized handling previously).
Note that the type of allocation used during copying (regular in Main,
allocated but outside of Main, or not allocated by ID handling code at
all) is stored in ID's, which allows to handle them correctly when
freeing. This needs to be taken care of with caution when doing 'weird'
unusual things with ID copying and/or allocation!
As a final note, while rather noisy, this commit will hopefully not
break too much existing branches, old 'API' has been kept for the main
part, as a wrapper around new code. Cleaning it up will happen later.
Design task : T51804
Phab Diff: D2714
2017-08-07 16:39:55 +02:00
|
|
|
void BKE_mesh_copy_data(struct Main *bmain, struct Mesh *me_dst, const struct Mesh *me_src, const int flag);
|
2017-06-14 22:36:30 +02:00
|
|
|
struct Mesh *BKE_mesh_copy(struct Main *bmain, const struct Mesh *me);
|
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(
|
2018-04-25 12:21:07 +02:00
|
|
|
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);
|
2018-04-19 11:03:58 +02:00
|
|
|
|
2018-09-20 12:33:45 +02:00
|
|
|
/* Performs copy for use during evaluation, optional referencing original arrays to reduce memory. */
|
|
|
|
struct Mesh *BKE_mesh_copy_for_eval(struct Mesh *source, bool reference);
|
2018-08-16 14:20:36 +02:00
|
|
|
|
2018-05-08 11:33:31 +02: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);
|
|
|
|
|
2016-07-20 19:49:45 +02:00
|
|
|
void BKE_mesh_make_local(struct Main *bmain, struct Mesh *me, const bool lib_local);
|
2018-11-27 14:17:54 +11:00
|
|
|
void BKE_mesh_boundbox_calc(struct Mesh *me, float r_loc[3], float r_size[3]);
|
2012-05-05 21:28:12 +00:00
|
|
|
void BKE_mesh_texspace_calc(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(
|
2018-06-11 16:02:46 +02:00
|
|
|
struct Main *bmain, struct Object *ob, struct ListBase *dispbase, const bool use_orco_uv, 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);
|
2013-08-14 11:29:58 +00:00
|
|
|
void BKE_mesh_material_index_remove(struct Mesh *me, short index);
|
|
|
|
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);
|
2012-05-05 21:28:12 +00:00
|
|
|
void BKE_mesh_smooth_flag_set(struct Object *meshOb, int enableSmooth);
|
2013-09-09 02:11:44 +00:00
|
|
|
|
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);
|
2018-11-21 14:37:56 -02:00
|
|
|
struct BoundBox *BKE_mesh_texspace_get(struct Mesh *me, float r_loc[3], float r_rot[3], float r_size[3]);
|
2017-06-09 15:19:02 +02:00
|
|
|
void BKE_mesh_texspace_get_reference(struct Mesh *me, short **r_texflag, float **r_loc, float **r_rot, 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
|
|
|
|
2018-04-30 21:03:16 +02:00
|
|
|
bool BKE_mesh_uv_cdlayer_rename_index(
|
|
|
|
struct Mesh *me, const int loop_index, const int face_index,
|
|
|
|
const char *new_name, const bool do_tessface);
|
2013-09-20 11:14:08 +00:00
|
|
|
bool BKE_mesh_uv_cdlayer_rename(struct Mesh *me, const char *old_name, const char *new_name, bool do_tessface);
|
|
|
|
|
2015-03-29 04:44:05 +11:00
|
|
|
float (*BKE_mesh_vertexCos_get(const struct Mesh *me, int *r_numVerts))[3];
|
2011-02-09 15:13:20 +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
|
|
|
|
2018-05-08 17:17:40 +02:00
|
|
|
struct Mesh *BKE_mesh_new_from_object(
|
|
|
|
struct Depsgraph *depsgraph, struct Main *bmain, struct Scene *sce, struct Object *ob,
|
2018-10-11 12:14:03 +11:00
|
|
|
const bool apply_modifiers, const bool calc_undeformed);
|
2018-06-01 17:05:21 +02:00
|
|
|
struct Mesh *BKE_mesh_create_derived_for_modifier(
|
|
|
|
struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob,
|
|
|
|
struct ModifierData *md, 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,
|
2018-06-01 17:05:21 +02:00
|
|
|
CustomDataMask 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
|
|
|
|
Bake API - bpy.ops.object.bake()
New operator that can calls a bake function to the current render engine when available. This commit provides no feature for the users, but allows external engines to be accessed by the operator and be integrated with the baking api.
The API itself is simple. Blender sends a populated array of BakePixels to the renderer, and gets back an array of floats with the result.
The Blender Internal (and multires) system is still running independent, but we eventually will pipe it through the API as well. Cycles baking will come next as a separated commit
Python Operator:
----------------
The operator can be called with some arguments, or a user interface can be created for it. In that case the arguments can be ommited and the interface can expose the settings from bpy.context.scene.render.bake
bpy.ops.object.bake(type='COMBINED', filepath="", width=512, height=512, margin=16, use_selected_to_active=False, cage_extrusion=0, cage="", normal_space='TANGENT', normal_r='POS_X', normal_g='POS_Y', normal_b='POS_Z', save_mode='INTERNAL', use_clear=False, use_split_materials=False, use_automatic_name=False)
Note: external save mode is currently disabled.
Supported Features:
------------------
* Margin - Baked result is extended this many pixels beyond the border of each UV "island," to soften seams in the texture.
* Selected to Active - bake shading on the surface of selected object to the active object. The rays are cast from the lowpoly object inwards towards the highpoly object. If the highpoly object is not entirely involved by the lowpoly object, you can tweak the rays start point with Cage Extrusion. For even more control of the cage you can use a Cage object.
* Cage Extrusion - distance to use for the inward ray cast when using selected to active
* Custom Cage - object to use as cage (instead of the lowpoly object).
* Normal swizzle - change the axis that gets mapped to RGB
* Normal space - save as tangent or object normal spaces
Supported Passes:
-----------------
Any pass that is supported by Blender renderlayer system. Though it's up to the external engine to provide a valid enum with its supported passes. Normal passes get a special treatment since we post-process them to converted and "swizzled"
Development Notes for External Engines:
---------------------------------------
(read them in bake_api.c)
* For a complete implementation example look at the Cycles Bake commit (next).
Review: D421
Reviewed by: Campbell Barton, Brecht van Lommel, Sergey Sharybin, Thomas Dinge
Normal map pipeline "consulting" by Andy Davies (metalliandy)
Original design by Brecht van Lommel.
The entire commit history can be found on the branch: bake-cycles
2014-01-02 19:05:07 -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]);
|
2014-09-01 20:09:31 +10:00
|
|
|
void BKE_mesh_transform(struct Mesh *me, 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_ensure_navmesh(struct Mesh *me);
|
|
|
|
|
|
|
|
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-05-08 11:33:31 +02:00
|
|
|
void BKE_mesh_apply_vert_coords(struct Mesh *mesh, float (*vertCoords)[3]);
|
2018-07-05 10:12:36 +02:00
|
|
|
void BKE_mesh_apply_vert_normals(struct Mesh *mesh, short (*vertNormals)[3]);
|
2018-05-08 11:33:31 +02:00
|
|
|
|
2018-05-17 15:26:59 +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(
|
2012-01-06 00:08:37 +00:00
|
|
|
struct MVert *mverts, 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(
|
2012-01-06 00:45:07 +00:00
|
|
|
struct MVert *mverts, 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(
|
2015-10-12 20:12:55 +02:00
|
|
|
struct MVert *mverts, 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);
|
2013-09-09 02:11:44 +00:00
|
|
|
void BKE_mesh_calc_normals_tessface(
|
|
|
|
struct MVert *mverts, int numVerts,
|
2015-07-11 04:39:27 +10:00
|
|
|
const struct MFace *mfaces, int numFaces,
|
2014-03-16 03:24:05 +11:00
|
|
|
float (*r_faceNors)[3]);
|
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);
|
2013-09-09 02:11:44 +00: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 {
|
|
|
|
float vec_lnor[3]; /* Automatically computed loop normal. */
|
|
|
|
float vec_ref[3]; /* Reference vector, orthogonal to vec_lnor. */
|
|
|
|
float vec_ortho[3]; /* Third vector, orthogonal to vec_lnor and vec_ref. */
|
|
|
|
float ref_alpha; /* Reference angle, around vec_ortho, in ]0, pi] range (0.0 marks that space as invalid). */
|
|
|
|
float ref_beta; /* Reference angle, around vec_lnor, in ]0, 2pi] range (0.0 marks that space as invalid). */
|
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
|
|
|
/* All loops using this lnor space (i.e. smooth fan of loops),
|
|
|
|
* as (depending on owning MLoopNorSpaceArrary.data_type):
|
|
|
|
* - Indices (uint_in_ptr), or
|
|
|
|
* - BMLoop pointers. */
|
|
|
|
struct LinkNode *loops;
|
|
|
|
char flags;
|
2018-05-25 22:24:24 +05:30
|
|
|
|
|
|
|
void *user_data; /* To be used for extended processing related to loop normal spaces (aka smooth fans). */
|
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,
|
|
|
|
};
|
|
|
|
|
|
|
|
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);
|
|
|
|
void BKE_lnor_space_add_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
|
|
|
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]);
|
|
|
|
|
|
|
|
bool BKE_mesh_has_custom_loop_normals(struct Mesh *me);
|
|
|
|
|
2017-02-22 09:40:46 +01:00
|
|
|
void BKE_mesh_calc_normals_split(struct Mesh *mesh);
|
|
|
|
void BKE_mesh_calc_normals_split_ex(struct Mesh *mesh, struct MLoopNorSpaceArray *r_lnors_spacearr);
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
void BKE_mesh_normals_loop_custom_set(
|
2015-07-11 04:39:27 +10:00
|
|
|
const struct MVert *mverts, 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(
|
2015-09-04 22:41:10 +02:00
|
|
|
const struct MVert *mverts, 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]);
|
|
|
|
|
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]);
|
|
|
|
|
2013-09-09 02:11:44 +00:00
|
|
|
void BKE_mesh_calc_poly_normal(
|
2015-07-11 04:39:27 +10:00
|
|
|
const struct MPoly *mpoly, 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(
|
2015-07-11 04:39:27 +10:00
|
|
|
const struct MPoly *mpoly, 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(
|
2015-07-11 04:39:27 +10:00
|
|
|
const struct MPoly *mpoly, 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(
|
2015-07-11 04:39:27 +10:00
|
|
|
const struct MPoly *mpoly, const struct MLoop *loopstart,
|
|
|
|
const struct MVert *mvarray);
|
2013-09-09 02:11:44 +00:00
|
|
|
void BKE_mesh_calc_poly_angles(
|
2015-07-11 04:39:27 +10:00
|
|
|
const struct MPoly *mpoly, const struct MLoop *loopstart,
|
|
|
|
const struct MVert *mvarray, float angles[]);
|
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]);
|
|
|
|
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-11 04:39:27 +10:00
|
|
|
void BKE_mesh_calc_volume(
|
2015-07-20 05:19:47 +10:00
|
|
|
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,
|
|
|
|
const int numTex, 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(
|
2017-05-25 15:11:00 +10:00
|
|
|
struct CustomData *fdata, struct CustomData *ldata, struct MFace *mface,
|
2014-01-21 16:32:36 +01:00
|
|
|
int *polyindices, 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,
|
|
|
|
int *polyindices, unsigned int (*loopindices)[4], const int num_faces, const char *layer_name);
|
2013-09-09 02:11:44 +00:00
|
|
|
int BKE_mesh_recalc_tessellation(
|
|
|
|
struct CustomData *fdata, struct CustomData *ldata, struct CustomData *pdata,
|
|
|
|
struct MVert *mvert,
|
|
|
|
int totface, int totloop, int totpoly,
|
2015-05-20 12:54:45 +10:00
|
|
|
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,
|
|
|
|
|
|
|
|
const float (*vert_cos_src)[3],
|
|
|
|
const float (*vert_cos_dst)[3],
|
|
|
|
|
|
|
|
const float (*vert_cos_org)[3],
|
|
|
|
float (*vert_cos_new)[3]);
|
2009-01-21 22:40:28 +00:00
|
|
|
|
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(
|
2012-03-15 20:10:07 +00:00
|
|
|
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);
|
|
|
|
|
|
|
|
bool BKE_mesh_validate_all_customdata(
|
2018-12-03 16:19:08 +01:00
|
|
|
struct CustomData *vdata, 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);
|
2013-03-16 01:19:03 +00:00
|
|
|
void BKE_mesh_calc_edges(struct Mesh *mesh, bool update, const bool select);
|
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
|
|
|
|
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,
|
2015-05-12 13:57:11 +05:00
|
|
|
struct Mesh *mesh);
|
|
|
|
|
2017-04-21 21:14:11 +10:00
|
|
|
/* Draw Cache */
|
|
|
|
enum {
|
|
|
|
BKE_MESH_BATCH_DIRTY_ALL = 0,
|
2017-08-22 22:04:40 +10:00
|
|
|
BKE_MESH_BATCH_DIRTY_MAYBE_ALL,
|
2017-04-21 21:14:11 +10:00
|
|
|
BKE_MESH_BATCH_DIRTY_SELECT,
|
2017-07-10 14:43:57 +02:00
|
|
|
BKE_MESH_BATCH_DIRTY_SHADING,
|
2017-07-13 00:27:06 +10:00
|
|
|
BKE_MESH_BATCH_DIRTY_SCULPT_COORDS,
|
2018-10-04 16:03:51 +10:00
|
|
|
BKE_MESH_BATCH_DIRTY_UVEDIT_ALL,
|
|
|
|
BKE_MESH_BATCH_DIRTY_UVEDIT_SELECT,
|
2017-04-21 21:14:11 +10:00
|
|
|
};
|
2018-08-23 10:14:29 -03:00
|
|
|
void BKE_mesh_batch_cache_dirty_tag(struct Mesh *me, int mode);
|
2017-04-21 21:14:11 +10:00
|
|
|
void BKE_mesh_batch_cache_free(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
|
|
|
|
|
2012-02-17 18:59:41 +00:00
|
|
|
#endif /* __BKE_MESH_H__ */
|