Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2018-09-06 15:28:14 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2018-10-10 18:43:44 +0300
commite65784a0519e25e9ca560ab63758287cea45f123 (patch)
tree2452488152b951d029f68b34f20803254066b27b /source
parent468474a653c976615306254dfcc33a85a0b872a1 (diff)
Python API: add loop triangles access, remove tessfaces.
Loop triangles are tessellated triangles create from polygons, for renderers or exporters that need to match Blender's polygon tesselation exactly. These are a read-only runtime cache. Tessfaces are a legacy data structure from before Blender supported n-gons, and were already mostly removed from the C code. Details on porting code to loop triangles is in the release notes. Differential Revision: https://developer.blender.org/D3539
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/BKE_mesh.h2
-rw-r--r--source/blender/blenkernel/intern/mesh_convert.c6
-rw-r--r--source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp4
-rw-r--r--source/blender/makesdna/DNA_meshdata_types.h2
-rw-r--r--source/blender/makesrna/RNA_access.h2
-rw-r--r--source/blender/makesrna/intern/rna_internal.h2
-rw-r--r--source/blender/makesrna/intern/rna_main_api.c6
-rw-r--r--source/blender/makesrna/intern/rna_mesh.c893
-rw-r--r--source/blender/makesrna/intern/rna_mesh_api.c16
-rw-r--r--source/blender/makesrna/intern/rna_object_api.c6
-rw-r--r--source/blender/python/bmesh/bmesh_py_api.c14
-rw-r--r--source/blender/python/bmesh/bmesh_py_types.c8
-rw-r--r--source/blender/render/intern/source/bake_api.c45
13 files changed, 132 insertions, 874 deletions
diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h
index 9f86c16bae8..c7232015059 100644
--- a/source/blender/blenkernel/BKE_mesh.h
+++ b/source/blender/blenkernel/BKE_mesh.h
@@ -179,7 +179,7 @@ void BKE_mesh_split_faces(struct Mesh *mesh, bool free_loop_normals);
struct Mesh *BKE_mesh_new_from_object(
struct Depsgraph *depsgraph, struct Main *bmain, struct Scene *sce, struct Object *ob,
- const bool apply_modifiers, const bool calc_tessface, const bool calc_undeformed);
+ const bool apply_modifiers, const bool calc_loop_triangles, const bool calc_undeformed);
struct Mesh *BKE_mesh_create_derived_for_modifier(
struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob,
struct ModifierData *md, int build_shapekey_layers);
diff --git a/source/blender/blenkernel/intern/mesh_convert.c b/source/blender/blenkernel/intern/mesh_convert.c
index 7cc7095361c..bb52ed79b53 100644
--- a/source/blender/blenkernel/intern/mesh_convert.c
+++ b/source/blender/blenkernel/intern/mesh_convert.c
@@ -840,7 +840,7 @@ void BKE_mesh_to_curve(Main *bmain, Depsgraph *depsgraph, Scene *scene, Object *
/* settings: 1 - preview, 2 - render */
Mesh *BKE_mesh_new_from_object(
Depsgraph *depsgraph, Main *bmain, Scene *sce, Object *ob,
- const bool apply_modifiers, const bool calc_tessface, const bool calc_undeformed)
+ const bool apply_modifiers, const bool calc_loop_triangles, const bool calc_undeformed)
{
Mesh *tmpmesh;
Curve *tmpcu = NULL, *copycu;
@@ -1069,9 +1069,9 @@ Mesh *BKE_mesh_new_from_object(
break;
} /* end copy materials */
- if (calc_tessface) {
+ if (calc_loop_triangles) {
/* cycles and exporters rely on this still */
- BKE_mesh_tessface_ensure(tmpmesh);
+ BKE_mesh_runtime_looptri_ensure(tmpmesh);
}
return tmpmesh;
diff --git a/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp b/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp
index a0b97b817fd..016637f8002 100644
--- a/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp
+++ b/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp
@@ -107,13 +107,13 @@ NodeGroup *BlenderFileLoader::Load()
bool apply_modifiers = false;
bool calc_undeformed = false;
- bool calc_tessface = false;
+ bool calc_loop_triangles = false;
Mesh *mesh = BKE_mesh_new_from_object(depsgraph,
_re->main,
_re->scene,
ob,
apply_modifiers,
- calc_tessface,
+ calc_loop_triangles,
calc_undeformed);
if (mesh) {
diff --git a/source/blender/makesdna/DNA_meshdata_types.h b/source/blender/makesdna/DNA_meshdata_types.h
index 0b24c1cfb67..636377ffd36 100644
--- a/source/blender/makesdna/DNA_meshdata_types.h
+++ b/source/blender/makesdna/DNA_meshdata_types.h
@@ -174,8 +174,6 @@ typedef struct MLoop {
*
* \note A #MLoopTri may be in the middle of an ngon and not reference **any** edges.
*/
-#
-#
typedef struct MLoopTri {
unsigned int tri[3];
unsigned int poly;
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h
index ccce54227fe..a90248ee53e 100644
--- a/source/blender/makesrna/RNA_access.h
+++ b/source/blender/makesrna/RNA_access.h
@@ -390,7 +390,7 @@ extern StructRNA RNA_MeshLoopColorLayer;
extern StructRNA RNA_MeshDeformModifier;
extern StructRNA RNA_MeshEdge;
extern StructRNA RNA_MeshPolygon;
-extern StructRNA RNA_MeshTessFace;
+extern StructRNA RNA_MeshLoopTriangle;
extern StructRNA RNA_MeshLoop;
extern StructRNA RNA_MeshFloatProperty;
extern StructRNA RNA_MeshFloatPropertyLayer;
diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h
index 2578f88a520..7087be9de2d 100644
--- a/source/blender/makesrna/intern/rna_internal.h
+++ b/source/blender/makesrna/intern/rna_internal.h
@@ -490,7 +490,7 @@ int rna_parameter_size(struct PropertyRNA *parm);
struct Mesh *rna_Main_meshes_new_from_object(
struct Main *bmain, struct ReportList *reports, struct Depsgraph *depsgraph,
- struct Object *ob, bool apply_modifiers, bool calc_tessface, bool calc_undeformed);
+ struct Object *ob, bool apply_modifiers, bool calc_loop_triangles, bool calc_undeformed);
/* XXX, these should not need to be defined here~! */
struct MTex *rna_mtex_texture_slots_add(struct ID *self, struct bContext *C, struct ReportList *reports);
diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c
index 70dcf20dcc6..48ced4df0b4 100644
--- a/source/blender/makesrna/intern/rna_main_api.c
+++ b/source/blender/makesrna/intern/rna_main_api.c
@@ -310,7 +310,7 @@ static Mesh *rna_Main_meshes_new(Main *bmain, const char *name)
/* copied from Mesh_getFromObject and adapted to RNA interface */
Mesh *rna_Main_meshes_new_from_object(
Main *bmain, ReportList *reports, Depsgraph *depsgraph,
- Object *ob, bool apply_modifiers, bool calc_tessface, bool calc_undeformed)
+ Object *ob, bool apply_modifiers, bool calc_loop_triangles, bool calc_undeformed)
{
Scene *sce = DEG_get_evaluated_scene(depsgraph);
@@ -326,7 +326,7 @@ Mesh *rna_Main_meshes_new_from_object(
return NULL;
}
- return BKE_mesh_new_from_object(depsgraph, bmain, sce, ob, apply_modifiers, calc_tessface, calc_undeformed);
+ return BKE_mesh_new_from_object(depsgraph, bmain, sce, ob, apply_modifiers, calc_loop_triangles, calc_undeformed);
}
static Lamp *rna_Main_lights_new(Main *bmain, const char *name, int type)
@@ -893,7 +893,7 @@ void RNA_def_main_meshes(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
parm = RNA_def_boolean(func, "apply_modifiers", 0, "", "Apply modifiers");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
- RNA_def_boolean(func, "calc_tessface", true, "Calculate Tessellation", "Calculate tessellation faces");
+ RNA_def_boolean(func, "calc_loop_triangles", true, "Calculate Triangles", "Calculate tesselated triangles");
RNA_def_boolean(func, "calc_undeformed", false, "Calculate Undeformed", "Calculate undeformed vertex coordinates");
parm = RNA_def_pointer(func, "mesh", "Mesh", "",
"Mesh created from object, remove it if it is only used for export");
diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c
index 24896570fb5..a5bae7115f9 100644
--- a/source/blender/makesrna/intern/rna_mesh.c
+++ b/source/blender/makesrna/intern/rna_mesh.c
@@ -70,6 +70,7 @@ const EnumPropertyItem rna_enum_mesh_delimit_mode_items[] = {
#include "BKE_customdata.h"
#include "BKE_main.h"
#include "BKE_mesh.h"
+#include "BKE_mesh_runtime.h"
#include "BKE_report.h"
#include "DEG_depsgraph.h"
@@ -139,12 +140,6 @@ static CustomData *rna_mesh_ldata(PointerRNA *ptr)
return rna_mesh_ldata_helper(me);
}
-static CustomData *rna_mesh_fdata(PointerRNA *ptr)
-{
- Mesh *me = rna_mesh(ptr);
- return rna_mesh_fdata_helper(me);
-}
-
/* -------------------------------------------------------------------- */
/* Generic CustomData Layer Functions */
@@ -195,12 +190,6 @@ static void rna_MeshLoopLayer_name_set(PointerRNA *ptr, const char *value)
{
rna_cd_layer_name_set(rna_mesh_ldata(ptr), (CustomDataLayer *)ptr->data, value);
}
-#if 0
-static void rna_MeshTessfaceLayer_name_set(PointerRNA *ptr, const char *value)
-{
- rna_cd_layer_name_set(rna_mesh_fdata(ptr), (CustomDataLayer *)ptr->data, value);
-}
-#endif
/* only for layers shared between types */
static void rna_MeshAnyLayer_name_set(PointerRNA *ptr, const char *value)
{
@@ -435,232 +424,57 @@ static void rna_MeshPolygon_flip(ID *id, MPoly *mp)
BKE_mesh_polygon_flip(mp, me->mloop, &me->ldata);
BKE_mesh_tessface_clear(me);
+ BKE_mesh_runtime_clear_geometry(me);
}
-static void rna_MeshTessFace_normal_get(PointerRNA *ptr, float *values)
+static void rna_MeshLoopTriangle_verts_get(PointerRNA *ptr, int *values)
{
Mesh *me = rna_mesh(ptr);
- MFace *mface = (MFace *)ptr->data;
-
- if (mface->v4)
- normal_quad_v3(values, me->mvert[mface->v1].co, me->mvert[mface->v2].co,
- me->mvert[mface->v3].co, me->mvert[mface->v4].co);
- else
- normal_tri_v3(values, me->mvert[mface->v1].co, me->mvert[mface->v2].co, me->mvert[mface->v3].co);
+ MLoopTri *lt = (MLoopTri *)ptr->data;
+ values[0] = me->mloop[lt->tri[0]].v;
+ values[1] = me->mloop[lt->tri[1]].v;
+ values[2] = me->mloop[lt->tri[2]].v;
}
-static void rna_MeshTessFace_split_normals_get(PointerRNA *ptr, float *values)
-{
- Mesh *me = rna_mesh(ptr);
- MFace *mface = (MFace *)ptr->data;
- const short (*vec)[4][3] = CustomData_get(&me->fdata, (int)(mface - me->mface), CD_TESSLOOPNORMAL);
- int i = 4;
-
- if (!vec) {
- while (i--) zero_v3(&values[i * 3]);
- }
- else {
- while (i--) normal_short_to_float_v3(&values[i * 3], (const short *)(*vec)[i]);
- }
-}
-static float rna_MeshTessFace_area_get(PointerRNA *ptr)
+static void rna_MeshLoopTriangle_normal_get(PointerRNA *ptr, float *values)
{
Mesh *me = rna_mesh(ptr);
- MFace *mface = (MFace *)ptr->data;
-
- if (mface->v4)
- return area_quad_v3(me->mvert[mface->v1].co, me->mvert[mface->v2].co, me->mvert[mface->v3].co,
- me->mvert[mface->v4].co);
- else
- return area_tri_v3(me->mvert[mface->v1].co, me->mvert[mface->v2].co, me->mvert[mface->v3].co);
-}
-
-static void rna_MeshTextureFace_uv1_get(PointerRNA *ptr, float *values)
-{
- MTFace *mtface = (MTFace *)ptr->data;
-
- values[0] = mtface->uv[0][0];
- values[1] = mtface->uv[0][1];
-}
-
-static void rna_MeshTextureFace_uv1_set(PointerRNA *ptr, const float *values)
-{
- MTFace *mtface = (MTFace *)ptr->data;
-
- mtface->uv[0][0] = values[0];
- mtface->uv[0][1] = values[1];
-}
-
-static void rna_MeshTextureFace_uv2_get(PointerRNA *ptr, float *values)
-{
- MTFace *mtface = (MTFace *)ptr->data;
-
- values[0] = mtface->uv[1][0];
- values[1] = mtface->uv[1][1];
-}
-
-static void rna_MeshTextureFace_uv2_set(PointerRNA *ptr, const float *values)
-{
- MTFace *mtface = (MTFace *)ptr->data;
-
- mtface->uv[1][0] = values[0];
- mtface->uv[1][1] = values[1];
-}
-
-static void rna_MeshTextureFace_uv3_get(PointerRNA *ptr, float *values)
-{
- MTFace *mtface = (MTFace *)ptr->data;
-
- values[0] = mtface->uv[2][0];
- values[1] = mtface->uv[2][1];
-}
-
-static void rna_MeshTextureFace_uv3_set(PointerRNA *ptr, const float *values)
-{
- MTFace *mtface = (MTFace *)ptr->data;
-
- mtface->uv[2][0] = values[0];
- mtface->uv[2][1] = values[1];
-}
-
-static void rna_MeshTextureFace_uv4_get(PointerRNA *ptr, float *values)
-{
- MTFace *mtface = (MTFace *)ptr->data;
-
- values[0] = mtface->uv[3][0];
- values[1] = mtface->uv[3][1];
-}
+ MLoopTri *lt = (MLoopTri *)ptr->data;
+ unsigned int v1 = me->mloop[lt->tri[0]].v;
+ unsigned int v2 = me->mloop[lt->tri[1]].v;
+ unsigned int v3 = me->mloop[lt->tri[2]].v;
-static void rna_MeshTextureFace_uv4_set(PointerRNA *ptr, const float *values)
-{
- MTFace *mtface = (MTFace *)ptr->data;
-
- mtface->uv[3][0] = values[0];
- mtface->uv[3][1] = values[1];
+ normal_tri_v3(values, me->mvert[v1].co, me->mvert[v2].co, me->mvert[v3].co);
}
-static int rna_CustomDataData_numverts(PointerRNA *ptr, int type)
+static void rna_MeshLoopTriangle_split_normals_get(PointerRNA *ptr, float *values)
{
Mesh *me = rna_mesh(ptr);
- CustomData *fdata = rna_mesh_fdata(ptr);
- CustomDataLayer *cdl;
- int a, b;
+ const float (*lnors)[3] = CustomData_get_layer(&me->ldata, CD_NORMAL);
- for (cdl = fdata->layers, a = 0; a < fdata->totlayer; cdl++, a++) {
- if (cdl->type == type) {
- b = ((char *)ptr->data - ((char *)cdl->data)) / CustomData_sizeof(type);
- if (b >= 0 && b < me->totface) {
- return (me->mface[b].v4 ? 4 : 3);
- }
- }
+ if (!lnors) {
+ zero_v3(values + 0);
+ zero_v3(values + 3);
+ zero_v3(values + 6);
+ }
+ else {
+ MLoopTri *lt = (MLoopTri *)ptr->data;
+ copy_v3_v3(values + 0, lnors[lt->tri[0]]);
+ copy_v3_v3(values + 3, lnors[lt->tri[1]]);
+ copy_v3_v3(values + 6, lnors[lt->tri[2]]);
}
-
- return 0;
-}
-
-static int rna_MeshTextureFace_uv_get_length(PointerRNA *ptr, int length[RNA_MAX_ARRAY_DIMENSION])
-{
- length[0] = rna_CustomDataData_numverts(ptr, CD_MTFACE);
- length[1] = 2;
- return length[0] * length[1];
-}
-
-static void rna_MeshTextureFace_uv_get(PointerRNA *ptr, float *values)
-{
- MTFace *mtface = (MTFace *)ptr->data;
- int totvert = rna_CustomDataData_numverts(ptr, CD_MTFACE);
-
- memcpy(values, mtface->uv, totvert * 2 * sizeof(float));
-}
-
-static void rna_MeshTextureFace_uv_set(PointerRNA *ptr, const float *values)
-{
- MTFace *mtface = (MTFace *)ptr->data;
- int totvert = rna_CustomDataData_numverts(ptr, CD_MTFACE);
-
- memcpy(mtface->uv, values, totvert * 2 * sizeof(float));
-}
-
-/* notice red and blue are swapped */
-static void rna_MeshColor_color1_get(PointerRNA *ptr, float *values)
-{
- MCol *mcol = (MCol *)ptr->data;
-
- values[3] = mcol[0].a / 255.0f;
- values[2] = mcol[0].r / 255.0f;
- values[1] = mcol[0].g / 255.0f;
- values[0] = mcol[0].b / 255.0f;
-}
-
-static void rna_MeshColor_color1_set(PointerRNA *ptr, const float *values)
-{
- MCol *mcol = (MCol *)ptr->data;
-
- mcol[0].a = round_fl_to_uchar_clamp(values[3] * 255.0f);
- mcol[0].r = round_fl_to_uchar_clamp(values[2] * 255.0f);
- mcol[0].g = round_fl_to_uchar_clamp(values[1] * 255.0f);
- mcol[0].b = round_fl_to_uchar_clamp(values[0] * 255.0f);
-}
-
-static void rna_MeshColor_color2_get(PointerRNA *ptr, float *values)
-{
- MCol *mcol = (MCol *)ptr->data;
-
- values[3] = mcol[1].a / 255.0f;
- values[2] = mcol[1].r / 255.0f;
- values[1] = mcol[1].g / 255.0f;
- values[0] = mcol[1].b / 255.0f;
-}
-
-static void rna_MeshColor_color2_set(PointerRNA *ptr, const float *values)
-{
- MCol *mcol = (MCol *)ptr->data;
-
- mcol[1].a = round_fl_to_uchar_clamp(values[3] * 255.0f);
- mcol[1].r = round_fl_to_uchar_clamp(values[2] * 255.0f);
- mcol[1].g = round_fl_to_uchar_clamp(values[1] * 255.0f);
- mcol[1].b = round_fl_to_uchar_clamp(values[0] * 255.0f);
-}
-
-static void rna_MeshColor_color3_get(PointerRNA *ptr, float *values)
-{
- MCol *mcol = (MCol *)ptr->data;
-
- values[3] = mcol[2].a / 255.0f;
- values[2] = mcol[2].r / 255.0f;
- values[1] = mcol[2].g / 255.0f;
- values[0] = mcol[2].b / 255.0f;
-}
-
-static void rna_MeshColor_color3_set(PointerRNA *ptr, const float *values)
-{
- MCol *mcol = (MCol *)ptr->data;
-
- mcol[2].a = round_fl_to_uchar_clamp(values[3] * 255.0f);
- mcol[2].r = round_fl_to_uchar_clamp(values[2] * 255.0f);
- mcol[2].g = round_fl_to_uchar_clamp(values[1] * 255.0f);
- mcol[2].b = round_fl_to_uchar_clamp(values[0] * 255.0f);
-}
-
-static void rna_MeshColor_color4_get(PointerRNA *ptr, float *values)
-{
- MCol *mcol = (MCol *)ptr->data;
-
- values[3] = mcol[3].a / 255.0f;
- values[2] = mcol[3].r / 255.0f;
- values[1] = mcol[3].g / 255.0f;
- values[0] = mcol[3].b / 255.0f;
}
-static void rna_MeshColor_color4_set(PointerRNA *ptr, const float *values)
+static float rna_MeshLoopTriangle_area_get(PointerRNA *ptr)
{
- MCol *mcol = (MCol *)ptr->data;
+ Mesh *me = rna_mesh(ptr);
+ MLoopTri *lt = (MLoopTri *)ptr->data;
+ unsigned int v1 = me->mloop[lt->tri[0]].v;
+ unsigned int v2 = me->mloop[lt->tri[1]].v;
+ unsigned int v3 = me->mloop[lt->tri[2]].v;
- mcol[3].a = round_fl_to_uchar_clamp(values[3] * 255.0f);
- mcol[3].r = round_fl_to_uchar_clamp(values[2] * 255.0f);
- mcol[3].g = round_fl_to_uchar_clamp(values[1] * 255.0f);
- mcol[3].b = round_fl_to_uchar_clamp(values[0] * 255.0f);
+ return area_tri_v3(me->mvert[v1].co, me->mvert[v2].co, me->mvert[v3].co);
}
static void rna_MeshLoopColor_color_get(PointerRNA *ptr, float *values)
@@ -902,93 +716,8 @@ static void rna_MeshUVLoopLayer_clone_set(PointerRNA *ptr, bool value)
rna_CustomDataLayer_clone_set(ptr, rna_mesh_ldata(ptr), value, CD_MLOOPUV);
}
-/* face uv_textures */
-
-DEFINE_CUSTOMDATA_LAYER_COLLECTION(tessface_uv_texture, fdata, CD_MTFACE)
-DEFINE_CUSTOMDATA_LAYER_COLLECTION_ACTIVEITEM(tessface_uv_texture, fdata, CD_MTFACE, active, MeshTextureFaceLayer)
-
-static void rna_MeshTextureFaceLayer_data_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
-{
- Mesh *me = rna_mesh(ptr);
- CustomDataLayer *layer = (CustomDataLayer *)ptr->data;
- rna_iterator_array_begin(iter, layer->data, sizeof(MTFace), (me->edit_btmesh) ? 0 : me->totface, 0, NULL);
-}
-
-static int rna_MeshTextureFaceLayer_data_length(PointerRNA *ptr)
-{
- Mesh *me = rna_mesh(ptr);
- return (me->edit_btmesh) ? 0 : me->totface;
-}
-
-static bool rna_MeshTextureFaceLayer_active_render_get(PointerRNA *ptr)
-{
- return rna_CustomDataLayer_active_get(ptr, rna_mesh_fdata(ptr), CD_MTFACE, 1);
-}
-
-static bool rna_MeshTextureFaceLayer_active_get(PointerRNA *ptr)
-{
- return rna_CustomDataLayer_active_get(ptr, rna_mesh_fdata(ptr), CD_MTFACE, 0);
-}
-
-static bool rna_MeshTextureFaceLayer_clone_get(PointerRNA *ptr)
-{
- return rna_CustomDataLayer_clone_get(ptr, rna_mesh_fdata(ptr), CD_MTFACE);
-}
-
-static void rna_MeshTextureFaceLayer_active_render_set(PointerRNA *ptr, bool value)
-{
- rna_CustomDataLayer_active_set(ptr, rna_mesh_fdata(ptr), value, CD_MTFACE, 1);
-}
-
-static void rna_MeshTextureFaceLayer_active_set(PointerRNA *ptr, int value)
-{
- rna_CustomDataLayer_active_set(ptr, rna_mesh_fdata(ptr), value, CD_MTFACE, 0);
-}
-
-static void rna_MeshTextureFaceLayer_clone_set(PointerRNA *ptr, int value)
-{
- rna_CustomDataLayer_clone_set(ptr, rna_mesh_fdata(ptr), value, CD_MTFACE);
-}
-
/* vertex_color_layers */
-DEFINE_CUSTOMDATA_LAYER_COLLECTION(tessface_vertex_color, fdata, CD_MCOL)
-DEFINE_CUSTOMDATA_LAYER_COLLECTION_ACTIVEITEM(tessface_vertex_color, fdata, CD_MCOL, active, MeshColorLayer)
-DEFINE_CUSTOMDATA_LAYER_COLLECTION_ACTIVEITEM(tessface_vertex_color, fdata, CD_MCOL, render, MeshColorLayer)
-
-static void rna_MeshColorLayer_data_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
-{
- Mesh *me = rna_mesh(ptr);
- CustomDataLayer *layer = (CustomDataLayer *)ptr->data;
- rna_iterator_array_begin(iter, layer->data, sizeof(MCol) * 4, me->totface, 0, NULL);
-}
-
-static int rna_MeshColorLayer_data_length(PointerRNA *ptr)
-{
- Mesh *me = rna_mesh(ptr);
- return me->totface;
-}
-
-static bool rna_MeshColorLayer_active_render_get(PointerRNA *ptr)
-{
- return rna_CustomDataLayer_active_get(ptr, rna_mesh_fdata(ptr), CD_MCOL, 1);
-}
-
-static bool rna_MeshColorLayer_active_get(PointerRNA *ptr)
-{
- return rna_CustomDataLayer_active_get(ptr, rna_mesh_fdata(ptr), CD_MCOL, 0);
-}
-
-static void rna_MeshColorLayer_active_render_set(PointerRNA *ptr, bool value)
-{
- rna_CustomDataLayer_active_set(ptr, rna_mesh_fdata(ptr), value, CD_MCOL, 1);
-}
-
-static void rna_MeshColorLayer_active_set(PointerRNA *ptr, int value)
-{
- rna_CustomDataLayer_active_set(ptr, rna_mesh_fdata(ptr), value, CD_MCOL, 0);
-}
-
DEFINE_CUSTOMDATA_LAYER_COLLECTION(vertex_color, ldata, CD_MLOOPCOL)
DEFINE_CUSTOMDATA_LAYER_COLLECTION_ACTIVEITEM(vertex_color, ldata, CD_MLOOPCOL, active, MeshLoopColorLayer)
DEFINE_CUSTOMDATA_LAYER_COLLECTION_ACTIVEITEM(vertex_color, ldata, CD_MLOOPCOL, render, MeshLoopColorLayer)
@@ -1242,30 +971,6 @@ static void rna_Mesh_face_map_remove(struct Mesh *me, ReportList *reports, struc
/* End face maps */
-static int rna_MeshTessFace_verts_get_length(PointerRNA *ptr, int length[RNA_MAX_ARRAY_DIMENSION])
-{
- MFace *face = (MFace *)ptr->data;
-
- if (face)
- length[0] = (face->v4) ? 4 : 3;
- else
- length[0] = 4; /* XXX rna_raw_access wants the length of a dummy face. this needs fixing. - Campbell */
-
- return length[0];
-}
-
-static void rna_MeshTessFace_verts_get(PointerRNA *ptr, int *values)
-{
- MFace *face = (MFace *)ptr->data;
- memcpy(values, &face->v1, (face->v4 ? 4 : 3) * sizeof(int));
-}
-
-static void rna_MeshTessFace_verts_set(PointerRNA *ptr, const int *values)
-{
- MFace *face = (MFace *)ptr->data;
- memcpy(&face->v1, values, (face->v4 ? 4 : 3) * sizeof(int));
-}
-
/* poly.vertices - this is faked loop access for convenience */
static int rna_MeshPoly_vertices_get_length(PointerRNA *ptr, int length[RNA_MAX_ARRAY_DIMENSION])
{
@@ -1320,11 +1025,25 @@ static int rna_MeshEdge_index_get(PointerRNA *ptr)
return (int)(edge - me->medge);
}
-static int rna_MeshTessFace_index_get(PointerRNA *ptr)
+static int rna_MeshLoopTriangle_index_get(PointerRNA *ptr)
+{
+ Mesh *me = rna_mesh(ptr);
+ MLoopTri *ltri = (MLoopTri *)ptr->data;
+ return (int)(ltri - me->runtime.looptris.array);
+}
+
+static int rna_MeshLoopTriangle_material_index_get(PointerRNA *ptr)
+{
+ Mesh *me = rna_mesh(ptr);
+ MLoopTri *ltri = (MLoopTri *)ptr->data;
+ return me->mpoly[ltri->poly].mat_nr;
+}
+
+static bool rna_MeshLoopTriangle_use_smooth_get(PointerRNA *ptr)
{
Mesh *me = rna_mesh(ptr);
- MFace *face = (MFace *)ptr->data;
- return (int)(face - me->mface);
+ MLoopTri *ltri = (MLoopTri *)ptr->data;
+ return me->mpoly[ltri->poly].flag & ME_SMOOTH;
}
static int rna_MeshPolygon_index_get(PointerRNA *ptr)
@@ -1363,9 +1082,9 @@ static char *rna_MeshPolygon_path(PointerRNA *ptr)
return BLI_sprintfN("polygons[%d]", (int)((MPoly *)ptr->data - rna_mesh(ptr)->mpoly));
}
-static char *rna_MeshTessFace_path(PointerRNA *ptr)
+static char *rna_MeshLoopTriangle_path(PointerRNA *ptr)
{
- return BLI_sprintfN("tessfaces[%d]", (int)((MFace *)ptr->data - rna_mesh(ptr)->mface));
+ return BLI_sprintfN("loop_triangles[%d]", (int)((MLoopTri *)ptr->data - rna_mesh(ptr)->runtime.looptris.array));
}
static char *rna_MeshEdge_path(PointerRNA *ptr)
@@ -1384,14 +1103,6 @@ static char *rna_MeshVertex_path(PointerRNA *ptr)
return BLI_sprintfN("vertices[%d]", (int)((MVert *)ptr->data - rna_mesh(ptr)->mvert));
}
-static char *rna_MeshTextureFaceLayer_path(PointerRNA *ptr)
-{
- CustomDataLayer *cdl = ptr->data;
- char name_esc[sizeof(cdl->name) * 2];
- BLI_strescape(name_esc, cdl->name, sizeof(name_esc));
- return BLI_sprintfN("tessface_uv_textures[\"%s\"]", name_esc);
-}
-
static char *rna_VertCustomData_data_path(PointerRNA *ptr, const char *collection, int type)
{
CustomDataLayer *cdl;
@@ -1455,46 +1166,11 @@ static char *rna_LoopCustomData_data_path(PointerRNA *ptr, const char *collectio
return NULL;
}
-static char *rna_FaceCustomData_data_path(PointerRNA *ptr, const char *collection, int type)
-{
- CustomDataLayer *cdl;
- Mesh *me = rna_mesh(ptr);
- CustomData *fdata = rna_mesh_fdata(ptr);
- int a, b, totloop = (me->edit_btmesh) ? 0 : me->totloop;
-
- for (cdl = fdata->layers, a = 0; a < fdata->totlayer; cdl++, a++) {
- if (cdl->type == type) {
- b = ((char *)ptr->data - ((char *)cdl->data)) / CustomData_sizeof(type);
- if (b >= 0 && b < totloop) {
- char name_esc[sizeof(cdl->name) * 2];
- BLI_strescape(name_esc, cdl->name, sizeof(name_esc));
- return BLI_sprintfN("%s[\"%s\"].data[%d]", collection, name_esc, b);
- }
- }
- }
-
- return NULL;
-}
-
-
static char *rna_MeshUVLoop_path(PointerRNA *ptr)
{
return rna_LoopCustomData_data_path(ptr, "uv_layers", CD_MLOOPUV);
}
-static char *rna_MeshTextureFace_path(PointerRNA *ptr)
-{
- return rna_FaceCustomData_data_path(ptr, "tessface_uv_textures", CD_MTFACE);
-}
-
-static char *rna_MeshColorLayer_path(PointerRNA *ptr)
-{
- CustomDataLayer *cdl = ptr->data;
- char name_esc[sizeof(cdl->name) * 2];
- BLI_strescape(name_esc, cdl->name, sizeof(name_esc));
- return BLI_sprintfN("tessface_vertex_colors[\"%s\"]", name_esc);
-}
-
static char *rna_MeshLoopColorLayer_path(PointerRNA *ptr)
{
CustomDataLayer *cdl = ptr->data;
@@ -1721,34 +1397,6 @@ static void rna_Mesh_vertex_color_remove(struct Mesh *me, ReportList *reports, C
}
}
-static PointerRNA rna_Mesh_tessface_vertex_color_new(struct Mesh *me, ReportList *reports, const char *name)
-{
- PointerRNA ptr;
- CustomData *fdata;
- CustomDataLayer *cdl = NULL;
- int index;
-
- if (me->edit_btmesh) {
- BKE_report(reports, RPT_ERROR, "Cannot add tessface colors in edit mode");
- return PointerRNA_NULL;
- }
-
- if (me->mpoly) {
- BKE_report(reports, RPT_ERROR, "Cannot add tessface colors when MPoly's exist");
- return PointerRNA_NULL;
- }
-
- index = ED_mesh_color_add(me, name, false);
-
- if (index != -1) {
- fdata = rna_mesh_fdata_helper(me);
- cdl = &fdata->layers[CustomData_get_layer_index_n(fdata, CD_MCOL, index)];
- }
-
- RNA_pointer_create(&me->id, &RNA_MeshColorLayer, cdl, &ptr);
- return ptr;
-}
-
#define DEFINE_CUSTOMDATA_PROPERTY_API(elemname, datatype, cd_prop_type, cdata, countvar, layertype) \
static PointerRNA rna_Mesh_##elemname##_##datatype##_property_new(struct Mesh *me, const char *name) \
{ \
@@ -1796,38 +1444,6 @@ static void rna_Mesh_uv_layers_remove(struct Mesh *me, ReportList *reports, Cust
}
}
-/* while this is supposed to be readonly,
- * keep it to support importers that only make tessfaces */
-
-static PointerRNA rna_Mesh_tessface_uv_texture_new(struct Mesh *me, ReportList *reports, const char *name)
-{
- PointerRNA ptr;
- CustomData *fdata;
- CustomDataLayer *cdl = NULL;
- int index;
-
- if (me->edit_btmesh) {
- BKE_report(reports, RPT_ERROR, "Cannot add tessface uv's in edit mode");
- return PointerRNA_NULL;
- }
-
- if (me->mpoly) {
- BKE_report(reports, RPT_ERROR, "Cannot add tessface uv's when MPoly's exist");
- return PointerRNA_NULL;
- }
-
- index = ED_mesh_uv_texture_add(me, name, false);
-
- if (index != -1) {
- fdata = rna_mesh_fdata_helper(me);
- cdl = &fdata->layers[CustomData_get_layer_index_n(fdata, CD_MTFACE, index)];
- }
-
- RNA_pointer_create(&me->id, &RNA_MeshTextureFaceLayer, cdl, &ptr);
- return ptr;
-}
-
-
static bool rna_Mesh_is_editmode_get(PointerRNA *ptr)
{
Mesh *me = rna_mesh(ptr);
@@ -1840,14 +1456,6 @@ static void UNUSED_FUNCTION(rna_mesh_unused)(void)
/* unused functions made by macros */
(void)rna_Mesh_skin_vertice_index_range;
(void)rna_Mesh_vertex_paint_mask_index_range;
- (void)rna_Mesh_tessface_uv_texture_active_set;
- (void)rna_Mesh_tessface_uv_texture_index_range;
- (void)rna_Mesh_tessface_vertex_color_active_set;
- (void)rna_Mesh_tessface_vertex_color_index_range;
- (void)rna_Mesh_tessface_vertex_color_render_get;
- (void)rna_Mesh_tessface_vertex_color_render_index_get;
- (void)rna_Mesh_tessface_vertex_color_render_index_set;
- (void)rna_Mesh_tessface_vertex_color_render_set;
(void)rna_Mesh_uv_layer_render_get;
(void)rna_Mesh_uv_layer_render_index_get;
(void)rna_Mesh_uv_layer_render_index_set;
@@ -2009,83 +1617,70 @@ static void rna_def_medge(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Index", "Index of this edge");
}
-static void rna_def_mface(BlenderRNA *brna)
+static void rna_def_mlooptri(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
- const int splitnor_dim[] = {4, 3};
+ const int splitnor_dim[] = {3, 3};
- srna = RNA_def_struct(brna, "MeshTessFace", NULL);
- RNA_def_struct_sdna(srna, "MFace");
- RNA_def_struct_ui_text(srna, "Mesh TessFace", "TessFace in a Mesh data-block");
- RNA_def_struct_path_func(srna, "rna_MeshTessFace_path");
+ srna = RNA_def_struct(brna, "MeshLoopTriangle", NULL);
+ RNA_def_struct_sdna(srna, "MLoopTri");
+ RNA_def_struct_ui_text(srna, "Mesh Loop Triangle", "Tessellated triangle in a Mesh data-block");
+ RNA_def_struct_path_func(srna, "rna_MeshLoopTriangle_path");
RNA_def_struct_ui_icon(srna, ICON_FACESEL);
- /* XXX allows creating invalid meshes */
prop = RNA_def_property(srna, "vertices", PROP_INT, PROP_UNSIGNED);
- RNA_def_property_array(prop, 4);
- RNA_def_property_flag(prop, PROP_DYNAMIC);
- RNA_def_property_dynamic_array_funcs(prop, "rna_MeshTessFace_verts_get_length");
- RNA_def_property_int_funcs(prop, "rna_MeshTessFace_verts_get", "rna_MeshTessFace_verts_set", NULL);
- RNA_def_property_ui_text(prop, "Vertices", "Vertex indices");
-
- /* leaving this fixed size array for foreach_set used in import scripts */
- prop = RNA_def_property(srna, "vertices_raw", PROP_INT, PROP_UNSIGNED);
- RNA_def_property_int_sdna(prop, NULL, "v1");
- RNA_def_property_array(prop, 4);
- RNA_def_property_ui_text(prop, "Vertices", "Fixed size vertex indices array");
-
- prop = RNA_def_property(srna, "material_index", PROP_INT, PROP_UNSIGNED);
- RNA_def_property_int_sdna(prop, NULL, "mat_nr");
- RNA_def_property_ui_text(prop, "Material Index", "");
-#if 0
- RNA_def_property_int_funcs(prop, NULL, NULL, "rna_MeshPoly_material_index_range"); /* reuse for tessface is ok */
-#endif
- RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
-
- prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", ME_FACE_SEL);
- RNA_def_property_ui_text(prop, "Select", "");
- RNA_def_property_update(prop, 0, "rna_Mesh_update_select");
+ RNA_def_property_array(prop, 3);
+ RNA_def_property_int_funcs(prop, "rna_MeshLoopTriangle_verts_get", NULL, NULL);
+ RNA_def_property_ui_text(prop, "Vertices", "Indices of triangle vertices");
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", ME_HIDE);
- RNA_def_property_ui_text(prop, "Hide", "");
- RNA_def_property_update(prop, 0, "rna_Mesh_update_select");
+ prop = RNA_def_property(srna, "loops", PROP_INT, PROP_UNSIGNED);
+ RNA_def_property_int_sdna(prop, NULL, "tri");
+ RNA_def_property_ui_text(prop, "Loops", "Indices of mesh loops that make up the triangle");
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- prop = RNA_def_property(srna, "use_smooth", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", ME_SMOOTH);
- RNA_def_property_ui_text(prop, "Smooth", "");
- RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
+ prop = RNA_def_property(srna, "polygon_index", PROP_INT, PROP_UNSIGNED);
+ RNA_def_property_int_sdna(prop, NULL, "poly");
+ RNA_def_property_ui_text(prop, "Polygon", "Index of mesh polygon that the triangle is a part of");
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
prop = RNA_def_property(srna, "normal", PROP_FLOAT, PROP_DIRECTION);
RNA_def_property_array(prop, 3);
RNA_def_property_range(prop, -1.0f, 1.0f);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- RNA_def_property_float_funcs(prop, "rna_MeshTessFace_normal_get", NULL, NULL);
- RNA_def_property_ui_text(prop, "Face Normal", "Local space unit length normal vector for this face");
+ RNA_def_property_float_funcs(prop, "rna_MeshLoopTriangle_normal_get", NULL, NULL);
+ RNA_def_property_ui_text(prop, "Triangle Normal", "Local space unit length normal vector for this triangle");
prop = RNA_def_property(srna, "split_normals", PROP_FLOAT, PROP_DIRECTION);
RNA_def_property_multi_array(prop, 2, splitnor_dim);
RNA_def_property_range(prop, -1.0f, 1.0f);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- RNA_def_property_float_funcs(prop, "rna_MeshTessFace_split_normals_get", NULL, NULL);
+ RNA_def_property_float_funcs(prop, "rna_MeshLoopTriangle_split_normals_get", NULL, NULL);
RNA_def_property_ui_text(prop, "Split Normals",
- "Local space unit length split normals vectors of the vertices of this face "
- "(must be computed beforehand using calc_normals_split or calc_tangents, "
- "and then calc_tessface)");
+ "Local space unit length split normals vectors of the vertices of this triangle "
+ "(must be computed beforehand using calc_normals_split or calc_tangents)");
prop = RNA_def_property(srna, "area", PROP_FLOAT, PROP_UNSIGNED);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- RNA_def_property_float_funcs(prop, "rna_MeshTessFace_area_get", NULL, NULL);
- RNA_def_property_ui_text(prop, "Face Area", "Read only area of this face");
+ RNA_def_property_float_funcs(prop, "rna_MeshLoopTriangle_area_get", NULL, NULL);
+ RNA_def_property_ui_text(prop, "Triangle Area", "Area of this triangle");
prop = RNA_def_property(srna, "index", PROP_INT, PROP_UNSIGNED);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- RNA_def_property_int_funcs(prop, "rna_MeshTessFace_index_get", NULL, NULL);
- RNA_def_property_ui_text(prop, "Index", "Index of this face");
-}
+ RNA_def_property_int_funcs(prop, "rna_MeshLoopTriangle_index_get", NULL, NULL);
+ RNA_def_property_ui_text(prop, "Index", "Index of this loop triangle");
+ prop = RNA_def_property(srna, "material_index", PROP_INT, PROP_UNSIGNED);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_int_funcs(prop, "rna_MeshLoopTriangle_material_index_get", NULL, NULL);
+ RNA_def_property_ui_text(prop, "Material Index", "");
+
+ prop = RNA_def_property(srna, "use_smooth", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_boolean_funcs(prop, "rna_MeshLoopTriangle_use_smooth_get", NULL);
+ RNA_def_property_ui_text(prop, "Smooth", "");
+}
static void rna_def_mloop(BlenderRNA *brna)
{
@@ -2295,179 +1890,6 @@ static void rna_def_mloopuv(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "UV Edge Select", "");
}
-static void rna_def_mtface(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
- const int uv_dim[] = {4, 2};
-
- srna = RNA_def_struct(brna, "MeshTextureFaceLayer", NULL);
- RNA_def_struct_ui_text(srna, "Mesh UV Map", "UV map with assigned image textures in a Mesh data-block");
- RNA_def_struct_sdna(srna, "CustomDataLayer");
- RNA_def_struct_path_func(srna, "rna_MeshTextureFaceLayer_path");
- RNA_def_struct_ui_icon(srna, ICON_GROUP_UVS);
-
- prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
- RNA_def_struct_name_property(srna, prop);
- RNA_def_property_string_funcs(prop, NULL, NULL, "rna_MeshUVLayer_name_set");
- RNA_def_property_ui_text(prop, "Name", "Name of UV map");
- RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
-
- prop = RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_funcs(prop, "rna_MeshTextureFaceLayer_active_get", "rna_MeshTextureFaceLayer_active_set");
- RNA_def_property_ui_text(prop, "Active", "Set the map as active for display and editing");
- RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
-
- prop = RNA_def_property(srna, "active_render", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "active_rnd", 0);
- RNA_def_property_boolean_funcs(prop, "rna_MeshTextureFaceLayer_active_render_get",
- "rna_MeshTextureFaceLayer_active_render_set");
- RNA_def_property_ui_text(prop, "Active Render", "Set the map as active for rendering");
- RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
-
- prop = RNA_def_property(srna, "active_clone", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "active_clone", 0);
- RNA_def_property_boolean_funcs(prop, "rna_MeshTextureFaceLayer_clone_get", "rna_MeshTextureFaceLayer_clone_set");
- RNA_def_property_ui_text(prop, "Active Clone", "Set the map as active for cloning");
- RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
-
- prop = RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE);
- RNA_def_property_struct_type(prop, "MeshTextureFace");
- RNA_def_property_ui_text(prop, "Data", "");
- RNA_def_property_collection_funcs(prop, "rna_MeshTextureFaceLayer_data_begin", "rna_iterator_array_next",
- "rna_iterator_array_end", "rna_iterator_array_get",
- "rna_MeshTextureFaceLayer_data_length", NULL, NULL, NULL);
-
- srna = RNA_def_struct(brna, "MeshTextureFace", NULL);
- RNA_def_struct_sdna(srna, "MTFace");
- RNA_def_struct_ui_text(srna, "Mesh UV Map Face", "UV map and image texture for a face");
- RNA_def_struct_path_func(srna, "rna_MeshTextureFace_path");
- RNA_def_struct_ui_icon(srna, ICON_FACESEL_HLT);
-
- /* these are for editing only, access at loops now */
-#if 0
- prop = RNA_def_property(srna, "select_uv", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag", TF_SEL1);
- RNA_def_property_array(prop, 4);
- RNA_def_property_ui_text(prop, "UV Selected", "");
- RNA_def_property_update(prop, 0, "rna_Mesh_update_select");
-
- prop = RNA_def_property(srna, "pin_uv", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "unwrap", TF_PIN1);
- RNA_def_property_array(prop, 4);
- RNA_def_property_ui_text(prop, "UV Pinned", "");
- RNA_def_property_update(prop, 0, "rna_Mesh_update_select");
-#endif
-
- prop = RNA_def_property(srna, "uv1", PROP_FLOAT, PROP_XYZ);
- RNA_def_property_array(prop, 2);
- RNA_def_property_float_funcs(prop, "rna_MeshTextureFace_uv1_get", "rna_MeshTextureFace_uv1_set", NULL);
- RNA_def_property_ui_text(prop, "UV 1", "");
- RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
-
- prop = RNA_def_property(srna, "uv2", PROP_FLOAT, PROP_XYZ);
- RNA_def_property_array(prop, 2);
- RNA_def_property_float_funcs(prop, "rna_MeshTextureFace_uv2_get", "rna_MeshTextureFace_uv2_set", NULL);
- RNA_def_property_ui_text(prop, "UV 2", "");
- RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
-
- prop = RNA_def_property(srna, "uv3", PROP_FLOAT, PROP_XYZ);
- RNA_def_property_array(prop, 2);
- RNA_def_property_float_funcs(prop, "rna_MeshTextureFace_uv3_get", "rna_MeshTextureFace_uv3_set", NULL);
- RNA_def_property_ui_text(prop, "UV 3", "");
- RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
-
- prop = RNA_def_property(srna, "uv4", PROP_FLOAT, PROP_XYZ);
- RNA_def_property_array(prop, 2);
- RNA_def_property_float_funcs(prop, "rna_MeshTextureFace_uv4_get", "rna_MeshTextureFace_uv4_set", NULL);
- RNA_def_property_ui_text(prop, "UV 4", "");
- RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
-
- prop = RNA_def_property(srna, "uv", PROP_FLOAT, PROP_NONE);
- RNA_def_property_multi_array(prop, 2, uv_dim);
- RNA_def_property_flag(prop, PROP_DYNAMIC);
- RNA_def_property_dynamic_array_funcs(prop, "rna_MeshTextureFace_uv_get_length");
- RNA_def_property_float_funcs(prop, "rna_MeshTextureFace_uv_get", "rna_MeshTextureFace_uv_set", NULL);
- RNA_def_property_ui_text(prop, "UV", "");
- RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
-
- prop = RNA_def_property(srna, "uv_raw", PROP_FLOAT, PROP_NONE);
- RNA_def_property_multi_array(prop, 2, uv_dim);
- RNA_def_property_float_sdna(prop, NULL, "uv");
- RNA_def_property_ui_text(prop, "UV Raw", "Fixed size UV coordinates array");
-
-}
-
-static void rna_def_mcol(BlenderRNA *brna)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- srna = RNA_def_struct(brna, "MeshColorLayer", NULL);
- RNA_def_struct_ui_text(srna, "Mesh Vertex Color Layer", "Layer of vertex colors in a Mesh data-block");
- RNA_def_struct_sdna(srna, "CustomDataLayer");
- RNA_def_struct_path_func(srna, "rna_MeshColorLayer_path");
- RNA_def_struct_ui_icon(srna, ICON_GROUP_VCOL);
-
- prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
- RNA_def_struct_name_property(srna, prop);
- RNA_def_property_string_funcs(prop, NULL, NULL, NULL);
- RNA_def_property_ui_text(prop, "Name", "Name of Vertex color layer");
- RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
-
- prop = RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_funcs(prop, "rna_MeshColorLayer_active_get", "rna_MeshColorLayer_active_set");
- RNA_def_property_ui_text(prop, "Active", "Sets the layer as active for display and editing");
- RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
-
- prop = RNA_def_property(srna, "active_render", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "active_rnd", 0);
- RNA_def_property_boolean_funcs(prop, "rna_MeshColorLayer_active_render_get",
- "rna_MeshColorLayer_active_render_set");
- RNA_def_property_ui_text(prop, "Active Render", "Sets the layer as active for rendering");
- RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
-
- prop = RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE);
- RNA_def_property_struct_type(prop, "MeshColor");
- RNA_def_property_ui_text(prop, "Data", "");
- RNA_def_property_collection_funcs(prop, "rna_MeshColorLayer_data_begin", "rna_iterator_array_next",
- "rna_iterator_array_end", "rna_iterator_array_get",
- "rna_MeshColorLayer_data_length", NULL, NULL, NULL);
-
- srna = RNA_def_struct(brna, "MeshColor", NULL);
- RNA_def_struct_sdna(srna, "MCol");
- RNA_def_struct_ui_text(srna, "Mesh Vertex Color", "Vertex colors for a face in a Mesh");
- RNA_def_struct_path_func(srna, "rna_MeshColor_path");
-
- prop = RNA_def_property(srna, "color1", PROP_FLOAT, PROP_COLOR);
- RNA_def_property_array(prop, 4);
- RNA_def_property_range(prop, 0.0f, 1.0f);
- RNA_def_property_float_funcs(prop, "rna_MeshColor_color1_get", "rna_MeshColor_color1_set", NULL);
- RNA_def_property_ui_text(prop, "Color 1", "");
- RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
-
- prop = RNA_def_property(srna, "color2", PROP_FLOAT, PROP_COLOR);
- RNA_def_property_array(prop, 4);
- RNA_def_property_range(prop, 0.0f, 1.0f);
- RNA_def_property_float_funcs(prop, "rna_MeshColor_color2_get", "rna_MeshColor_color2_set", NULL);
- RNA_def_property_ui_text(prop, "Color 2", "");
- RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
-
- prop = RNA_def_property(srna, "color3", PROP_FLOAT, PROP_COLOR);
- RNA_def_property_array(prop, 4);
- RNA_def_property_range(prop, 0.0f, 1.0f);
- RNA_def_property_float_funcs(prop, "rna_MeshColor_color3_get", "rna_MeshColor_color3_set", NULL);
- RNA_def_property_ui_text(prop, "Color 3", "");
- RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
-
- prop = RNA_def_property(srna, "color4", PROP_FLOAT, PROP_COLOR);
- RNA_def_property_array(prop, 4);
- RNA_def_property_range(prop, 0.0f, 1.0f);
- RNA_def_property_float_funcs(prop, "rna_MeshColor_color4_get", "rna_MeshColor_color4_set", NULL);
- RNA_def_property_ui_text(prop, "Color 4", "");
- RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
-}
-
static void rna_def_mloopcol(BlenderRNA *brna)
{
StructRNA *srna;
@@ -2723,33 +2145,15 @@ static void rna_def_mesh_edges(BlenderRNA *brna, PropertyRNA *cprop)
#endif
}
-/* mesh.faces */
-static void rna_def_mesh_tessfaces(BlenderRNA *brna, PropertyRNA *cprop)
+/* mesh.loop_triangles */
+static void rna_def_mesh_looptris(BlenderRNA *brna, PropertyRNA *cprop)
{
StructRNA *srna;
- PropertyRNA *prop;
- FunctionRNA *func;
- PropertyRNA *parm;
-
- RNA_def_property_srna(cprop, "MeshTessFaces");
- srna = RNA_def_struct(brna, "MeshTessFaces", NULL);
+ RNA_def_property_srna(cprop, "MeshLoopTriangle");
+ srna = RNA_def_struct(brna, "MeshLoopTriangles", NULL);
RNA_def_struct_sdna(srna, "Mesh");
- RNA_def_struct_ui_text(srna, "Mesh Faces", "Collection of mesh faces");
-
- prop = RNA_def_property(srna, "active", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "act_face");
- RNA_def_property_ui_text(prop, "Active Face", "The active face for this mesh");
-
- func = RNA_def_function(srna, "add", "ED_mesh_tessfaces_add");
- RNA_def_function_flag(func, FUNC_USE_REPORTS);
- parm = RNA_def_int(func, "count", 0, 0, INT_MAX, "Count", "Number of faces to add", 0, INT_MAX);
- RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
-#if 0 /* BMESH_TODO Remove until BMesh merge */
- func = RNA_def_function(srna, "remove", "ED_mesh_faces_remove");
- RNA_def_function_flag(func, FUNC_USE_REPORTS);
- RNA_def_int(func, "count", 0, 0, INT_MAX, "Count", "Number of faces to remove", 0, INT_MAX);
-#endif
+ RNA_def_struct_ui_text(srna, "Mesh Loop Triangles", "Tessellation of mesh polygons into triangles");
}
/* mesh.loops */
@@ -2799,43 +2203,6 @@ static void rna_def_mesh_polygons(BlenderRNA *brna, PropertyRNA *cprop)
}
-/* mesh.vertex_colors */
-static void rna_def_tessface_vertex_colors(BlenderRNA *brna, PropertyRNA *cprop)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- FunctionRNA *func;
- PropertyRNA *parm;
-
- RNA_def_property_srna(cprop, "VertexColors");
- srna = RNA_def_struct(brna, "VertexColors", NULL);
- RNA_def_struct_sdna(srna, "Mesh");
- RNA_def_struct_ui_text(srna, "Vertex Colors", "Collection of vertex colors");
-
- /* eventually deprecate this */
- func = RNA_def_function(srna, "new", "rna_Mesh_tessface_vertex_color_new");
- RNA_def_function_flag(func, FUNC_USE_REPORTS);
- RNA_def_function_ui_description(func, "Add a vertex color layer to Mesh");
- RNA_def_string(func, "name", "Col", 0, "", "Vertex color name");
- parm = RNA_def_pointer(func, "layer", "MeshColorLayer", "", "The newly created layer");
- RNA_def_parameter_flags(parm, 0, PARM_RNAPTR);
- RNA_def_function_return(func, parm);
-
- prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
- RNA_def_property_struct_type(prop, "MeshColorLayer");
- RNA_def_property_pointer_funcs(prop, "rna_Mesh_tessface_vertex_color_active_get",
- "rna_Mesh_tessface_vertex_color_active_set", NULL, NULL);
- RNA_def_property_ui_text(prop, "Active Vertex Color Layer", "Active vertex color layer");
- RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
-
- prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED);
- RNA_def_property_int_funcs(prop, "rna_Mesh_tessface_vertex_color_active_index_get",
- "rna_Mesh_tessface_vertex_color_active_index_set", "rna_Mesh_vertex_color_index_range");
- RNA_def_property_ui_text(prop, "Active Vertex Color Index", "Active vertex color index");
- RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
-}
-
static void rna_def_loop_colors(BlenderRNA *brna, PropertyRNA *cprop)
{
StructRNA *srna;
@@ -3045,43 +2412,6 @@ static void rna_def_polygon_string_layers(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_return(func, parm);
}
-/* mesh.tessface_uv_layers */
-static void rna_def_tessface_uv_textures(BlenderRNA *brna, PropertyRNA *cprop)
-{
- StructRNA *srna;
- PropertyRNA *prop;
-
- FunctionRNA *func;
- PropertyRNA *parm;
-
- RNA_def_property_srna(cprop, "TessfaceUVTextures");
- srna = RNA_def_struct(brna, "TessfaceUVTextures", NULL);
- RNA_def_struct_sdna(srna, "Mesh");
- RNA_def_struct_ui_text(srna, "UV Maps", "Collection of UV maps for tessellated faces");
-
- /* eventually deprecate this */
- func = RNA_def_function(srna, "new", "rna_Mesh_tessface_uv_texture_new");
- RNA_def_function_flag(func, FUNC_USE_REPORTS);
- RNA_def_function_ui_description(func, "Add a UV tessface-texture layer to Mesh (only for meshes with no polygons)");
- RNA_def_string(func, "name", "UVMap", 0, "", "UV map name");
- parm = RNA_def_pointer(func, "layer", "MeshTextureFaceLayer", "", "The newly created layer");
- RNA_def_parameter_flags(parm, 0, PARM_RNAPTR);
- RNA_def_function_return(func, parm);
-
- prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
- RNA_def_property_struct_type(prop, "MeshTextureFaceLayer");
- RNA_def_property_pointer_funcs(prop, "rna_Mesh_tessface_uv_texture_active_get",
- "rna_Mesh_tessface_uv_texture_active_set", NULL, NULL);
- RNA_def_property_ui_text(prop, "Active UV Map", "Active UV Map");
- RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
-
- prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED);
- RNA_def_property_int_funcs(prop, "rna_Mesh_tessface_uv_texture_active_index_get",
- "rna_Mesh_tessface_uv_texture_active_index_set", "rna_Mesh_uv_layer_index_range");
- RNA_def_property_ui_text(prop, "Active UV Map Index", "Active UV Map index");
- RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
-}
-
static void rna_def_skin_vertices(BlenderRNA *brna, PropertyRNA *UNUSED(cprop))
{
StructRNA *srna;
@@ -3256,12 +2586,6 @@ static void rna_def_mesh(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Edges", "Edges of the mesh");
rna_def_mesh_edges(brna, prop);
- prop = RNA_def_property(srna, "tessfaces", PROP_COLLECTION, PROP_NONE);
- RNA_def_property_collection_sdna(prop, NULL, "mface", "totface");
- RNA_def_property_struct_type(prop, "MeshTessFace");
- RNA_def_property_ui_text(prop, "TessFaces", "Tessellated faces of the mesh (derived from polygons)");
- rna_def_mesh_tessfaces(brna, prop);
-
prop = RNA_def_property(srna, "loops", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "mloop", "totloop");
RNA_def_property_struct_type(prop, "MeshLoop");
@@ -3274,6 +2598,12 @@ static void rna_def_mesh(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Polygons", "Polygons of the mesh");
rna_def_mesh_polygons(brna, prop);
+ prop = RNA_def_property(srna, "loop_triangles", PROP_COLLECTION, PROP_NONE);
+ RNA_def_property_collection_sdna(prop, NULL, "runtime.looptris.array", "runtime.looptris.len");
+ RNA_def_property_struct_type(prop, "MeshLoopTriangle");
+ RNA_def_property_ui_text(prop, "Loop Triangles", "Tessellation of mesh polygons into triangles");
+ rna_def_mesh_looptris(brna, prop);
+
/* TODO, should this be allowed to be its self? */
prop = RNA_def_property(srna, "texture_mesh", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "texcomesh");
@@ -3314,27 +2644,6 @@ static void rna_def_mesh(BlenderRNA *brna)
"rna_Mesh_uv_layer_stencil_index_set", "rna_Mesh_uv_layer_index_range");
RNA_def_property_ui_text(prop, "Mask UV loop layer Index", "Mask UV loop layer index");
- /* Tessellated face UV maps - used by renderers */
- prop = RNA_def_property(srna, "tessface_uv_textures", PROP_COLLECTION, PROP_NONE);
- RNA_def_property_collection_sdna(prop, NULL, "fdata.layers", "fdata.totlayer");
- RNA_def_property_collection_funcs(prop, "rna_Mesh_tessface_uv_textures_begin", NULL, NULL, NULL,
- "rna_Mesh_tessface_uv_textures_length", NULL, NULL, NULL);
- RNA_def_property_struct_type(prop, "MeshTextureFaceLayer");
- RNA_def_property_ui_text(prop, "Tessellated Face UV Maps",
- "All UV maps for tessellated faces (read-only, for use by renderers)");
- rna_def_tessface_uv_textures(brna, prop);
-
- /* Tessellated face colors - used by renderers */
-
- prop = RNA_def_property(srna, "tessface_vertex_colors", PROP_COLLECTION, PROP_NONE);
- RNA_def_property_collection_sdna(prop, NULL, "fdata.layers", "fdata.totlayer");
- RNA_def_property_collection_funcs(prop, "rna_Mesh_tessface_vertex_colors_begin", NULL, NULL, NULL,
- "rna_Mesh_tessface_vertex_colors_length", NULL, NULL, NULL);
- RNA_def_property_struct_type(prop, "MeshColorLayer");
- RNA_def_property_ui_text(prop, "Tessellated Face Colors",
- "All tessellated face colors (read-only, for use by renderers)");
- rna_def_tessface_vertex_colors(brna, prop);
-
/* Vertex colors */
prop = RNA_def_property(srna, "vertex_colors", PROP_COLLECTION, PROP_NONE);
@@ -3570,12 +2879,10 @@ void RNA_def_mesh(BlenderRNA *brna)
rna_def_mvert(brna);
rna_def_mvert_group(brna);
rna_def_medge(brna);
- rna_def_mface(brna);
+ rna_def_mlooptri(brna);
rna_def_mloop(brna);
rna_def_mpolygon(brna);
rna_def_mloopuv(brna);
- rna_def_mtface(brna);
- rna_def_mcol(brna);
rna_def_mloopcol(brna);
rna_def_mproperties(brna);
rna_def_face_map(brna);
diff --git a/source/blender/makesrna/intern/rna_mesh_api.c b/source/blender/makesrna/intern/rna_mesh_api.c
index 7328686af7f..b1556edd4b7 100644
--- a/source/blender/makesrna/intern/rna_mesh_api.c
+++ b/source/blender/makesrna/intern/rna_mesh_api.c
@@ -50,6 +50,7 @@
#include "BKE_mesh.h"
#include "BKE_mesh_tangent.h"
#include "BKE_mesh_mapping.h"
+#include "BKE_mesh_runtime.h"
#include "ED_mesh.h"
static const char *rna_Mesh_unit_test_compare(struct Mesh *mesh, struct Mesh *mesh2)
@@ -101,9 +102,9 @@ static void rna_Mesh_free_tangents(Mesh *mesh)
CustomData_free_layers(&mesh->ldata, CD_MLOOPTANGENT, mesh->totloop);
}
-static void rna_Mesh_calc_tessface(Mesh *mesh, bool free_mpoly)
+static void rna_Mesh_calc_looptri(Mesh *mesh)
{
- ED_mesh_calc_tessface(mesh, free_mpoly != 0);
+ BKE_mesh_runtime_looptri_ensure(mesh);
}
static void rna_Mesh_calc_smooth_groups(Mesh *mesh, bool use_bitflags, int *r_poly_group_len,
@@ -206,6 +207,7 @@ 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);
+ BKE_mesh_runtime_clear_geometry(mesh);
DEG_id_tag_update(&mesh->id, 0);
}
@@ -269,12 +271,8 @@ void RNA_api_mesh(StructRNA *srna)
func = RNA_def_function(srna, "free_tangents", "rna_Mesh_free_tangents");
RNA_def_function_ui_description(func, "Free tangents");
- func = RNA_def_function(srna, "calc_tessface", "rna_Mesh_calc_tessface");
- RNA_def_function_ui_description(func, "Calculate face tessellation (supports editmode too)");
- 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 "
- "engines and export scripts");
+ func = RNA_def_function(srna, "calc_loop_triangles", "rna_Mesh_calc_looptri");
+ RNA_def_function_ui_description(func, "Calculate loop triangle tessellation (supports editmode too)");
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");
@@ -308,7 +306,7 @@ void RNA_api_mesh(StructRNA *srna)
func = RNA_def_function(srna, "update", "ED_mesh_update");
RNA_def_boolean(func, "calc_edges", 0, "Calculate Edges", "Force recalculation of edges");
- RNA_def_boolean(func, "calc_tessface", 0, "Calculate Tessellation", "Force recalculation of tessellation faces");
+ RNA_def_boolean(func, "calc_loop_triangles", 0, "Calculate Triangules", "Force recalculation of triangle tessellation");
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
RNA_def_function(srna, "update_gpu_tag", "rna_Mesh_update_gpu_tag");
diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c
index b5e3ce4fd28..de4dfbbdae7 100644
--- a/source/blender/makesrna/intern/rna_object_api.c
+++ b/source/blender/makesrna/intern/rna_object_api.c
@@ -224,11 +224,11 @@ static void rna_Object_camera_fit_coords(
/* settings: 0 - preview, 1 - render */
static Mesh *rna_Object_to_mesh(
Object *ob, bContext *C, ReportList *reports, Depsgraph *depsgraph,
- bool apply_modifiers, bool calc_tessface, bool calc_undeformed)
+ bool apply_modifiers, bool calc_loop_triangles, bool calc_undeformed)
{
Main *bmain = CTX_data_main(C);
- return rna_Main_meshes_new_from_object(bmain, reports, depsgraph, ob, apply_modifiers, calc_tessface, calc_undeformed);
+ return rna_Main_meshes_new_from_object(bmain, reports, depsgraph, ob, apply_modifiers, calc_loop_triangles, calc_undeformed);
}
static PointerRNA rna_Object_shape_key_add(Object *ob, bContext *C, ReportList *reports,
@@ -594,7 +594,7 @@ void RNA_api_object(StructRNA *srna)
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
parm = RNA_def_boolean(func, "apply_modifiers", 0, "", "Apply modifiers");
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
- RNA_def_boolean(func, "calc_tessface", true, "Calculate Tessellation", "Calculate tessellation faces");
+ RNA_def_boolean(func, "calc_loop_triangles", true, "Calculate Loop Triangles", "Calculate triangle tessellation");
RNA_def_boolean(func, "calc_undeformed", false, "Calculate Undeformed", "Calculate undeformed vertex coordinates");
parm = RNA_def_pointer(func, "mesh", "Mesh", "",
"Mesh created from object, remove it if it is only used for export");
diff --git a/source/blender/python/bmesh/bmesh_py_api.c b/source/blender/python/bmesh/bmesh_py_api.c
index 3edd2bac244..235ede1e8fd 100644
--- a/source/blender/python/bmesh/bmesh_py_api.c
+++ b/source/blender/python/bmesh/bmesh_py_api.c
@@ -113,30 +113,30 @@ static PyObject *bpy_bm_from_edit_mesh(PyObject *UNUSED(self), PyObject *value)
}
PyDoc_STRVAR(bpy_bm_update_edit_mesh_doc,
-".. method:: update_edit_mesh(mesh, tessface=True, destructive=True)\n"
+".. method:: update_edit_mesh(mesh, loop_triangles=True, destructive=True)\n"
"\n"
" Update the mesh after changes to the BMesh in editmode, \n"
" optionally recalculating n-gon tessellation.\n"
"\n"
" :arg mesh: The editmode mesh.\n"
" :type mesh: :class:`bpy.types.Mesh`\n"
-" :arg tessface: Option to recalculate n-gon tessellation.\n"
-" :type tessface: boolean\n"
+" :arg loop_triangles: Option to recalculate n-gon tessellation.\n"
+" :type loop_triangles: boolean\n"
" :arg destructive: Use when geometry has been added or removed.\n"
" :type destructive: boolean\n"
);
static PyObject *bpy_bm_update_edit_mesh(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
{
- static const char *kwlist[] = {"mesh", "tessface", "destructive", NULL};
+ static const char *kwlist[] = {"mesh", "loop_triangles", "destructive", NULL};
PyObject *py_me;
Mesh *me;
- bool do_tessface = true;
+ bool do_loop_triangles = true;
bool is_destructive = true;
if (!PyArg_ParseTupleAndKeywords(
args, kw, "O|O&O&:update_edit_mesh", (char **)kwlist,
&py_me,
- PyC_ParseBool, &do_tessface,
+ PyC_ParseBool, &do_loop_triangles,
PyC_ParseBool, &is_destructive))
{
return NULL;
@@ -157,7 +157,7 @@ static PyObject *bpy_bm_update_edit_mesh(PyObject *UNUSED(self), PyObject *args,
{
extern void EDBM_update_generic(BMEditMesh *em, const bool do_tessface, const bool is_destructive);
- EDBM_update_generic(me->edit_btmesh, do_tessface, is_destructive);
+ EDBM_update_generic(me->edit_btmesh, do_loop_triangles, is_destructive);
}
Py_RETURN_NONE;
diff --git a/source/blender/python/bmesh/bmesh_py_types.c b/source/blender/python/bmesh/bmesh_py_types.c
index b380fbd416e..3ce5a26de90 100644
--- a/source/blender/python/bmesh/bmesh_py_types.c
+++ b/source/blender/python/bmesh/bmesh_py_types.c
@@ -1246,15 +1246,15 @@ static PyObject *bpy_bmesh_calc_volume(BPy_BMElem *self, PyObject *args, PyObjec
}
}
-PyDoc_STRVAR(bpy_bmesh_calc_tessface_doc,
-".. method:: calc_tessface()\n"
+PyDoc_STRVAR(bpy_bmesh_calc_loop_triangles_doc,
+".. method:: calc_loop_triangles()\n"
"\n"
" Calculate triangle tessellation from quads/ngons.\n"
"\n"
" :return: The triangulated faces.\n"
" :rtype: list of :class:`BMLoop` tuples\n"
);
-static PyObject *bpy_bmesh_calc_tessface(BPy_BMElem *self)
+static PyObject *bpy_bmesh_calc_loop_triangles(BPy_BMElem *self)
{
BMesh *bm;
@@ -2733,7 +2733,7 @@ static struct PyMethodDef bpy_bmesh_methods[] = {
/* calculations */
{"calc_volume", (PyCFunction)bpy_bmesh_calc_volume, METH_VARARGS | METH_KEYWORDS, bpy_bmesh_calc_volume_doc},
- {"calc_tessface", (PyCFunction)bpy_bmesh_calc_tessface, METH_NOARGS, bpy_bmesh_calc_tessface_doc},
+ {"calc_loop_triangles", (PyCFunction)bpy_bmesh_calc_loop_triangles, METH_NOARGS, bpy_bmesh_calc_loop_triangles_doc},
{NULL, NULL, 0, NULL}
};
diff --git a/source/blender/render/intern/source/bake_api.c b/source/blender/render/intern/source/bake_api.c
index f60105e029d..12c13bcac81 100644
--- a/source/blender/render/intern/source/bake_api.c
+++ b/source/blender/render/intern/source/bake_api.c
@@ -86,9 +86,6 @@
#include "render_types.h"
#include "zbuf.h"
-/* Remove when Cycles moves from MFace to MLoopTri */
-#define USE_MFACE_WORKAROUND
-
typedef struct BakeDataZSpan {
BakePixel *pixel_array;
int primitive_id;
@@ -393,27 +390,6 @@ static bool cast_ray_highpoly(
return hit_mesh != -1;
}
-#ifdef USE_MFACE_WORKAROUND
-/**
- * Until cycles moves to #MLoopTri, we need to keep face-rotation in sync with #test_index_face
- *
- * We only need to consider quads since #BKE_mesh_recalc_tessellation doesn't execute this on triangles.
- */
-static void test_index_face_looptri(const MPoly *mp, MLoop *mloop, MLoopTri *lt)
-{
- if (mp->totloop == 4) {
- if (UNLIKELY((mloop[mp->loopstart + 2].v == 0) ||
- (mloop[mp->loopstart + 3].v == 0)))
- {
- /* remap: (2, 3, 0, 1) */
- unsigned int l = mp->loopstart;
- ARRAY_SET_ITEMS(lt[0].tri, l + 2, l + 3, l + 0);
- ARRAY_SET_ITEMS(lt[1].tri, l + 2, l + 0, l + 1);
- }
- }
-}
-#endif
-
/**
* This function populates an array of verts for the triangles of a mesh
* Tangent and Normals are also stored
@@ -433,10 +409,6 @@ static TriTessFace *mesh_calc_tri_tessface(
unsigned int mpoly_prev = UINT_MAX;
float no[3];
-#ifdef USE_MFACE_WORKAROUND
- unsigned int mpoly_prev_testindex = UINT_MAX;
-#endif
-
mvert = CustomData_get_layer(&me->vdata, CD_MVERT);
looptri = MEM_mallocN(sizeof(*looptri) * tottri, __func__);
triangles = MEM_mallocN(sizeof(TriTessFace) * tottri, __func__);
@@ -463,13 +435,6 @@ static TriTessFace *mesh_calc_tri_tessface(
const MLoopTri *lt = &looptri[i];
const MPoly *mp = &me->mpoly[lt->poly];
-#ifdef USE_MFACE_WORKAROUND
- if (lt->poly != mpoly_prev_testindex) {
- test_index_face_looptri(mp, me->mloop, &looptri[i]);
- mpoly_prev_testindex = lt->poly;
- }
-#endif
-
triangles[i].mverts[0] = &mvert[me->mloop[lt->tri[0]].v];
triangles[i].mverts[1] = &mvert[me->mloop[lt->tri[1]].v];
triangles[i].mverts[2] = &mvert[me->mloop[lt->tri[2]].v];
@@ -662,9 +627,6 @@ void RE_bake_pixels_populate(
const MLoopUV *mloopuv;
const int tottri = poly_to_tri_count(me->totpoly, me->totloop);
MLoopTri *looptri;
-#ifdef USE_MFACE_WORKAROUND
- unsigned int mpoly_prev_testindex = UINT_MAX;
-#endif
if ((uv_layer == NULL) || (uv_layer[0] == '\0')) {
mloopuv = CustomData_get_layer(&me->ldata, CD_MLOOPUV);
@@ -714,13 +676,6 @@ void RE_bake_pixels_populate(
bd.bk_image = &bake_images->data[image_id];
bd.primitive_id = ++p_id;
-#ifdef USE_MFACE_WORKAROUND
- if (lt->poly != mpoly_prev_testindex) {
- test_index_face_looptri(mp, me->mloop, &looptri[i]);
- mpoly_prev_testindex = lt->poly;
- }
-#endif
-
for (a = 0; a < 3; a++) {
const float *uv = mloopuv[lt->tri[a]].uv;