2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2009-07-16 20:10:33 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
*
|
|
|
|
* 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
|
2012-03-18 09:27:36 +00:00
|
|
|
* of the License, or (at your option) any later version.
|
2009-07-16 20:10:33 +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.
|
2009-07-16 20:10:33 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2009 Blender Foundation.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
2012-03-18 09:27:36 +00:00
|
|
|
*
|
2009-07-16 20:10:33 +00:00
|
|
|
* Contributor(s): Blender Foundation
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
2011-02-27 20:20:01 +00:00
|
|
|
/** \file blender/makesrna/intern/rna_mesh_api.c
|
|
|
|
* \ingroup RNA
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2009-07-16 20:10:33 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "RNA_define.h"
|
|
|
|
|
2014-01-11 11:31:44 +01:00
|
|
|
#include "DNA_customdata_types.h"
|
|
|
|
|
2013-05-28 19:35:26 +00:00
|
|
|
#include "BLI_sys_types.h"
|
2009-07-16 20:10:33 +00:00
|
|
|
|
2012-07-08 06:00:27 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2013-09-10 15:26:12 +00:00
|
|
|
#include "BLI_math.h"
|
2012-07-08 06:00:27 +00:00
|
|
|
|
2012-09-22 14:07:55 +00:00
|
|
|
#include "rna_internal.h" /* own include */
|
|
|
|
|
2009-10-22 23:22:05 +00:00
|
|
|
#ifdef RNA_RUNTIME
|
2013-06-14 09:59:09 +00:00
|
|
|
|
|
|
|
#include "DNA_mesh_types.h"
|
|
|
|
|
2013-12-12 16:26:11 +11:00
|
|
|
#include "BKE_mesh.h"
|
|
|
|
#include "BKE_mesh_mapping.h"
|
|
|
|
#include "ED_mesh.h"
|
|
|
|
|
2013-09-20 06:35:28 +00:00
|
|
|
static const char *rna_Mesh_unit_test_compare(struct Mesh *mesh, struct Mesh *mesh2)
|
2010-10-27 02:22:55 +00:00
|
|
|
{
|
2012-05-12 11:01:29 +00:00
|
|
|
const char *ret = BKE_mesh_cmp(mesh, mesh2, FLT_EPSILON * 60);
|
2018-06-09 14:40:09 +02:00
|
|
|
|
2010-10-27 02:22:55 +00:00
|
|
|
if (!ret)
|
|
|
|
ret = "Same";
|
2018-06-09 14:40:09 +02:00
|
|
|
|
2010-10-27 02:22:55 +00:00
|
|
|
return ret;
|
|
|
|
}
|
2010-01-04 22:30:09 +00: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
|
|
|
static void rna_Mesh_create_normals_split(Mesh *mesh)
|
|
|
|
{
|
|
|
|
if (!CustomData_has_layer(&mesh->ldata, CD_NORMAL)) {
|
|
|
|
CustomData_add_layer(&mesh->ldata, CD_NORMAL, CD_CALLOC, NULL, mesh->totloop);
|
|
|
|
CustomData_set_layer_flag(&mesh->ldata, CD_NORMAL, CD_FLAG_TEMPORARY);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-13 12:13:30 +00:00
|
|
|
static void rna_Mesh_free_normals_split(Mesh *mesh)
|
2013-09-10 15:26:12 +00:00
|
|
|
{
|
|
|
|
CustomData_free_layers(&mesh->ldata, CD_NORMAL, mesh->totloop);
|
|
|
|
}
|
|
|
|
|
2014-01-11 11:31:44 +01:00
|
|
|
static void rna_Mesh_calc_tangents(Mesh *mesh, ReportList *reports, const char *uvmap)
|
|
|
|
{
|
|
|
|
float (*r_looptangents)[4];
|
|
|
|
|
|
|
|
if (CustomData_has_layer(&mesh->ldata, CD_MLOOPTANGENT)) {
|
|
|
|
r_looptangents = CustomData_get_layer(&mesh->ldata, CD_MLOOPTANGENT);
|
|
|
|
memset(r_looptangents, 0, sizeof(float[4]) * mesh->totloop);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
r_looptangents = CustomData_add_layer(&mesh->ldata, CD_MLOOPTANGENT, CD_CALLOC, NULL, mesh->totloop);
|
|
|
|
CustomData_set_layer_flag(&mesh->ldata, CD_MLOOPTANGENT, CD_FLAG_TEMPORARY);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Compute loop normals if needed. */
|
|
|
|
if (!CustomData_has_layer(&mesh->ldata, CD_NORMAL)) {
|
2015-03-20 12:41:31 +05:00
|
|
|
BKE_mesh_calc_normals_split(mesh);
|
2014-01-11 11:31:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
BKE_mesh_loop_tangents(mesh, uvmap, r_looptangents, reports);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void rna_Mesh_free_tangents(Mesh *mesh)
|
|
|
|
{
|
|
|
|
CustomData_free_layers(&mesh->ldata, CD_MLOOPTANGENT, mesh->totloop);
|
|
|
|
}
|
|
|
|
|
2015-02-18 22:47:23 +05:00
|
|
|
static void rna_Mesh_calc_tessface(Mesh *mesh, int free_mpoly)
|
|
|
|
{
|
|
|
|
ED_mesh_calc_tessface(mesh, free_mpoly != 0);
|
|
|
|
}
|
|
|
|
|
2013-09-10 15:26:12 +00:00
|
|
|
static void rna_Mesh_calc_smooth_groups(Mesh *mesh, int use_bitflags, int *r_poly_group_len,
|
|
|
|
int **r_poly_group, int *r_group_total)
|
2013-06-14 09:59:09 +00:00
|
|
|
{
|
|
|
|
*r_poly_group_len = mesh->totpoly;
|
|
|
|
*r_poly_group = BKE_mesh_calc_smoothgroups(
|
|
|
|
mesh->medge, mesh->totedge,
|
|
|
|
mesh->mpoly, mesh->totpoly,
|
|
|
|
mesh->mloop, mesh->totloop,
|
2013-09-02 18:33:06 +00:00
|
|
|
r_group_total, use_bitflags);
|
2013-06-14 09:59:09 +00: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
|
|
|
static void rna_Mesh_normals_split_custom_do(Mesh *mesh, float (*custom_loopnors)[3], const bool use_vertices)
|
|
|
|
{
|
|
|
|
float (*polynors)[3];
|
|
|
|
short (*clnors)[2];
|
|
|
|
const int numloops = mesh->totloop;
|
|
|
|
bool free_polynors = false;
|
|
|
|
|
|
|
|
clnors = CustomData_get_layer(&mesh->ldata, CD_CUSTOMLOOPNORMAL);
|
|
|
|
if (clnors) {
|
|
|
|
memset(clnors, 0, sizeof(*clnors) * numloops);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
clnors = CustomData_add_layer(&mesh->ldata, CD_CUSTOMLOOPNORMAL, CD_DEFAULT, NULL, numloops);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (CustomData_has_layer(&mesh->pdata, CD_NORMAL)) {
|
|
|
|
polynors = CustomData_get_layer(&mesh->pdata, CD_NORMAL);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
polynors = MEM_mallocN(sizeof(float[3]) * mesh->totpoly, __func__);
|
2015-10-12 20:12:55 +02:00
|
|
|
BKE_mesh_calc_normals_poly(
|
|
|
|
mesh->mvert, NULL, mesh->totvert,
|
|
|
|
mesh->mloop, mesh->mpoly, mesh->totloop, mesh->totpoly, polynors, false);
|
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
|
|
|
free_polynors = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (use_vertices) {
|
|
|
|
BKE_mesh_normals_loop_custom_from_vertices_set(
|
|
|
|
mesh->mvert, custom_loopnors, mesh->totvert, mesh->medge, mesh->totedge, mesh->mloop, mesh->totloop,
|
|
|
|
mesh->mpoly, (const float (*)[3])polynors, mesh->totpoly, clnors);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
BKE_mesh_normals_loop_custom_set(
|
|
|
|
mesh->mvert, mesh->totvert, mesh->medge, mesh->totedge, mesh->mloop, custom_loopnors, mesh->totloop,
|
|
|
|
mesh->mpoly, (const float (*)[3])polynors, mesh->totpoly, clnors);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (free_polynors) {
|
|
|
|
MEM_freeN(polynors);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void rna_Mesh_normals_split_custom_set(Mesh *mesh, ReportList *reports, int normals_len, float *normals)
|
|
|
|
{
|
|
|
|
float (*loopnors)[3] = (float (*)[3])normals;
|
|
|
|
const int numloops = mesh->totloop;
|
|
|
|
|
|
|
|
if (normals_len != numloops * 3) {
|
|
|
|
BKE_reportf(reports, RPT_ERROR,
|
2015-02-06 09:51:53 +01:00
|
|
|
"Number of custom normals is not number of loops (%f / %d)",
|
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
|
|
|
(float)normals_len / 3.0f, numloops);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
rna_Mesh_normals_split_custom_do(mesh, loopnors, false);
|
2015-03-30 15:04:42 +02:00
|
|
|
|
|
|
|
DAG_id_tag_update(&mesh->id, 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
|
|
|
}
|
|
|
|
|
|
|
|
static void rna_Mesh_normals_split_custom_set_from_vertices(
|
|
|
|
Mesh *mesh, ReportList *reports, int normals_len, float *normals)
|
|
|
|
{
|
|
|
|
float (*vertnors)[3] = (float (*)[3])normals;
|
|
|
|
const int numverts = mesh->totvert;
|
|
|
|
|
|
|
|
if (normals_len != numverts * 3) {
|
|
|
|
BKE_reportf(reports, RPT_ERROR,
|
2015-02-06 09:51:53 +01:00
|
|
|
"Number of custom normals is not number of vertices (%f / %d)",
|
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
|
|
|
(float)normals_len / 3.0f, numverts);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
rna_Mesh_normals_split_custom_do(mesh, vertnors, true);
|
2015-03-30 15:04:42 +02:00
|
|
|
|
|
|
|
DAG_id_tag_update(&mesh->id, 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
|
|
|
}
|
|
|
|
|
2014-09-01 20:09:31 +10:00
|
|
|
static void rna_Mesh_transform(Mesh *mesh, float *mat, int shape_keys)
|
2013-12-17 22:13:15 +11:00
|
|
|
{
|
2014-09-01 20:09:31 +10:00
|
|
|
BKE_mesh_transform(mesh, (float (*)[4])mat, shape_keys);
|
|
|
|
|
|
|
|
DAG_id_tag_update(&mesh->id, 0);
|
2013-12-17 22:13:15 +11:00
|
|
|
}
|
|
|
|
|
2016-02-28 15:29:56 +01:00
|
|
|
static void rna_Mesh_flip_normals(Mesh *mesh)
|
|
|
|
{
|
|
|
|
BKE_mesh_polygons_flip(mesh->mpoly, mesh->mloop, &mesh->ldata, mesh->totpoly);
|
|
|
|
BKE_mesh_tessface_clear(mesh);
|
|
|
|
BKE_mesh_calc_normals(mesh);
|
|
|
|
|
|
|
|
DAG_id_tag_update(&mesh->id, 0);
|
|
|
|
}
|
|
|
|
|
2017-02-22 10:53:28 +01:00
|
|
|
static void rna_Mesh_split_faces(Mesh *mesh, int free_loop_normals)
|
|
|
|
{
|
|
|
|
BKE_mesh_split_faces(mesh, free_loop_normals != 0);
|
|
|
|
}
|
|
|
|
|
2009-07-16 20:10:33 +00:00
|
|
|
#else
|
|
|
|
|
|
|
|
void RNA_api_mesh(StructRNA *srna)
|
|
|
|
{
|
|
|
|
FunctionRNA *func;
|
|
|
|
PropertyRNA *parm;
|
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
|
|
|
const int normals_array_dim[] = {1, 3};
|
2009-07-16 20:10:33 +00:00
|
|
|
|
2013-12-17 22:13:15 +11:00
|
|
|
func = RNA_def_function(srna, "transform", "rna_Mesh_transform");
|
2016-02-28 15:29:56 +01:00
|
|
|
RNA_def_function_ui_description(func, "Transform mesh vertices by a matrix "
|
|
|
|
"(Warning: inverts normals if matrix is negative)");
|
2012-03-05 23:30:41 +00:00
|
|
|
parm = RNA_def_float_matrix(func, "matrix", 4, 4, NULL, 0.0f, 0.0f, "", "Matrix", 0.0f, 0.0f);
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
|
2014-09-01 20:09:31 +10:00
|
|
|
RNA_def_boolean(func, "shape_keys", 0, "", "Transform Shape Keys");
|
2009-10-22 23:22:05 +00:00
|
|
|
|
2016-02-28 15:29:56 +01:00
|
|
|
func = RNA_def_function(srna, "flip_normals", "rna_Mesh_flip_normals");
|
|
|
|
RNA_def_function_ui_description(func, "Invert winding of all polygons "
|
|
|
|
"(clears tessellation, does not handle custom normals)");
|
|
|
|
|
2013-05-28 14:23:07 +00:00
|
|
|
func = RNA_def_function(srna, "calc_normals", "BKE_mesh_calc_normals");
|
2011-09-19 13:23:58 +00:00
|
|
|
RNA_def_function_ui_description(func, "Calculate vertex normals");
|
2009-10-22 23:22:05 +00: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
|
|
|
func = RNA_def_function(srna, "create_normals_split", "rna_Mesh_create_normals_split");
|
|
|
|
RNA_def_function_ui_description(func, "Empty split vertex normals");
|
|
|
|
|
2015-03-20 12:41:31 +05:00
|
|
|
func = RNA_def_function(srna, "calc_normals_split", "BKE_mesh_calc_normals_split");
|
2013-09-10 15:26:12 +00:00
|
|
|
RNA_def_function_ui_description(func, "Calculate split vertex normals, which preserve sharp edges");
|
|
|
|
|
2013-09-13 12:13:30 +00:00
|
|
|
func = RNA_def_function(srna, "free_normals_split", "rna_Mesh_free_normals_split");
|
2013-09-10 15:26:12 +00:00
|
|
|
RNA_def_function_ui_description(func, "Free split vertex normals");
|
|
|
|
|
2017-02-22 10:53:28 +01:00
|
|
|
func = RNA_def_function(srna, "split_faces", "rna_Mesh_split_faces");
|
2017-01-12 23:36:08 -05:00
|
|
|
RNA_def_function_ui_description(func, "Split faces based on the edge angle");
|
2017-02-22 10:53:28 +01:00
|
|
|
RNA_def_boolean(func, "free_loop_normals", 1, "Free Loop Notmals",
|
|
|
|
"Free loop normals custom data layer");
|
2017-01-11 15:59:32 +01:00
|
|
|
|
2014-01-11 11:31:44 +01:00
|
|
|
func = RNA_def_function(srna, "calc_tangents", "rna_Mesh_calc_tangents");
|
|
|
|
RNA_def_function_flag(func, FUNC_USE_REPORTS);
|
|
|
|
RNA_def_function_ui_description(func,
|
|
|
|
"Compute tangents and bitangent signs, to be used together with the split normals "
|
|
|
|
"to get a complete tangent space for normal mapping "
|
|
|
|
"(split normals are also computed if not yet present)");
|
2014-01-16 21:43:22 +11:00
|
|
|
parm = RNA_def_string(func, "uvmap", NULL, MAX_CUSTOMDATA_LAYER_NAME, "",
|
2014-01-11 11:31:44 +01:00
|
|
|
"Name of the UV map to use for tangent space computation");
|
|
|
|
|
|
|
|
func = RNA_def_function(srna, "free_tangents", "rna_Mesh_free_tangents");
|
|
|
|
RNA_def_function_ui_description(func, "Free tangents");
|
|
|
|
|
2015-02-18 22:47:23 +05:00
|
|
|
func = RNA_def_function(srna, "calc_tessface", "rna_Mesh_calc_tessface");
|
2012-03-29 13:44:30 +00:00
|
|
|
RNA_def_function_ui_description(func, "Calculate face tessellation (supports editmode too)");
|
2015-02-18 22:47:23 +05:00
|
|
|
RNA_def_boolean(func, "free_mpoly", 0, "Free MPoly", "Free data used by polygons and loops. "
|
|
|
|
"WARNING: This destructive operation removes regular faces, "
|
|
|
|
"only used on temporary mesh data-blocks to reduce memory footprint of render "
|
2015-03-16 09:37:00 +11:00
|
|
|
"engines and export scripts");
|
2012-03-29 13:44:30 +00:00
|
|
|
|
2013-06-14 09:59:09 +00:00
|
|
|
func = RNA_def_function(srna, "calc_smooth_groups", "rna_Mesh_calc_smooth_groups");
|
|
|
|
RNA_def_function_ui_description(func, "Calculate smooth groups from sharp edges");
|
2013-09-02 18:33:06 +00:00
|
|
|
RNA_def_boolean(func, "use_bitflags", false, "", "Produce bitflags groups instead of simple numeric values");
|
2013-06-14 09:59:09 +00:00
|
|
|
/* return values */
|
|
|
|
parm = RNA_def_int_array(func, "poly_groups", 1, NULL, 0, 0, "", "Smooth Groups", 0, 0);
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, PROP_DYNAMIC, PARM_OUTPUT);
|
2013-06-14 09:59:09 +00:00
|
|
|
parm = RNA_def_int(func, "groups", 0, 0, INT_MAX, "groups", "Total number of groups", 0, INT_MAX);
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, 0, PARM_OUTPUT);
|
2013-06-14 09:59:09 +00: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
|
|
|
func = RNA_def_function(srna, "normals_split_custom_set", "rna_Mesh_normals_split_custom_set");
|
|
|
|
RNA_def_function_ui_description(func,
|
|
|
|
"Define custom split normals of this mesh "
|
|
|
|
"(use zero-vectors to keep auto ones)");
|
|
|
|
RNA_def_function_flag(func, FUNC_USE_REPORTS);
|
|
|
|
/* TODO, see how array size of 0 works, this shouldnt be used */
|
|
|
|
parm = RNA_def_float_array(func, "normals", 1, NULL, -1.0f, 1.0f, "", "Normals", 0.0f, 0.0f);
|
|
|
|
RNA_def_property_multi_array(parm, 2, normals_array_dim);
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, PROP_DYNAMIC, PARM_REQUIRED);
|
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
|
|
|
|
|
|
|
func = RNA_def_function(srna, "normals_split_custom_set_from_vertices",
|
|
|
|
"rna_Mesh_normals_split_custom_set_from_vertices");
|
|
|
|
RNA_def_function_ui_description(func,
|
|
|
|
"Define custom split normals of this mesh, from vertices' normals "
|
|
|
|
"(use zero-vectors to keep auto ones)");
|
|
|
|
RNA_def_function_flag(func, FUNC_USE_REPORTS);
|
|
|
|
/* TODO, see how array size of 0 works, this shouldnt be used */
|
|
|
|
parm = RNA_def_float_array(func, "normals", 1, NULL, -1.0f, 1.0f, "", "Normals", 0.0f, 0.0f);
|
|
|
|
RNA_def_property_multi_array(parm, 2, normals_array_dim);
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, PROP_DYNAMIC, PARM_REQUIRED);
|
2013-06-14 09:59:09 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
func = RNA_def_function(srna, "update", "ED_mesh_update");
|
2011-09-19 13:23:58 +00:00
|
|
|
RNA_def_boolean(func, "calc_edges", 0, "Calculate Edges", "Force recalculation of edges");
|
2012-03-02 16:05:54 +00:00
|
|
|
RNA_def_boolean(func, "calc_tessface", 0, "Calculate Tessellation", "Force recalculation of tessellation faces");
|
2009-07-16 20:10:33 +00:00
|
|
|
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
|
2010-10-27 02:22:55 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
func = RNA_def_function(srna, "unit_test_compare", "rna_Mesh_unit_test_compare");
|
2012-11-01 09:54:00 +00:00
|
|
|
RNA_def_pointer(func, "mesh", "Mesh", "", "Mesh to compare to");
|
2010-10-27 02:22:55 +00:00
|
|
|
/* return value */
|
2012-03-05 23:30:41 +00:00
|
|
|
parm = RNA_def_string(func, "result", "nothing", 64, "Return value", "String description of result of comparison");
|
2010-10-27 02:22:55 +00:00
|
|
|
RNA_def_function_return(func, parm);
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
func = RNA_def_function(srna, "validate", "BKE_mesh_validate");
|
2014-07-17 17:12:12 +02:00
|
|
|
RNA_def_function_ui_description(func, "Validate geometry, return True when the mesh has had "
|
2012-05-12 11:01:29 +00:00
|
|
|
"invalid geometry corrected/removed");
|
2015-02-05 14:03:01 +01:00
|
|
|
RNA_def_boolean(func, "verbose", false, "Verbose", "Output information about the errors found");
|
2015-03-04 12:58:14 +11:00
|
|
|
RNA_def_boolean(func, "clean_customdata", true, "Clean Custom Data",
|
|
|
|
"Remove temp/cached custom-data layers, like e.g. normals...");
|
2012-03-05 23:30:41 +00:00
|
|
|
parm = RNA_def_boolean(func, "result", 0, "Result", "");
|
2011-02-10 09:29:31 +00:00
|
|
|
RNA_def_function_return(func, parm);
|
2014-07-17 17:12:12 +02:00
|
|
|
|
|
|
|
func = RNA_def_function(srna, "validate_material_indices", "BKE_mesh_validate_material_indices");
|
|
|
|
RNA_def_function_ui_description(func, "Validate material indices of polygons, return True when the mesh has had "
|
|
|
|
"invalid indices corrected (to default 0)");
|
|
|
|
parm = RNA_def_boolean(func, "result", 0, "Result", "");
|
|
|
|
RNA_def_function_return(func, parm);
|
2009-07-16 20:10:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|