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
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2014-04-13 14:18:51 +0400
committerBastien Montagne <montagne29@wanadoo.fr>2014-04-13 14:19:00 +0400
commit18e4224142261cd8a1086c5872efb406b82f8330 (patch)
treea1a9f7680ab45158ec2c2755f76a966532cad8b8 /source/blender/makesrna/intern/rna_mesh.c
parenta872d0b414f406a7d53ce77f7b43e7a831a68fa7 (diff)
Split Normals I (1/5): basis for split normals (nearly nothing user-visible here):
* Add a new calcLoopNormals function to DerivedMesh struct, and implement it for CDDM and CCGDM (subsurf). EditDerivedBMesh (edit mode DM) only gets a dummy one in this commit. * Add a tessellated version of CD_LOOPNORMAL layer (CD_TESSLOOPNORMAL), with relevant code to handle it (tessellation, rna access, etc.). * Change auto_smooth options of Mesh (angle now in radian internaly, and toggle is now used to enable/disable split normals in DM creation process). Note BI render code is not touched here, hence its behavior regarding this option is now incoherent, will be addressed in a separate commit. Reviewers: campbellbarton CC: brecht Differential Revision: https://developer.blender.org/D365
Diffstat (limited to 'source/blender/makesrna/intern/rna_mesh.c')
-rw-r--r--source/blender/makesrna/intern/rna_mesh.c61
1 files changed, 38 insertions, 23 deletions
diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c
index bdd94b73c44..99c35bdcff2 100644
--- a/source/blender/makesrna/intern/rna_mesh.c
+++ b/source/blender/makesrna/intern/rna_mesh.c
@@ -413,6 +413,21 @@ static void rna_MeshTessFace_normal_get(PointerRNA *ptr, float *values)
normal_tri_v3(values, me->mvert[mface->v1].co, me->mvert[mface->v2].co, me->mvert[mface->v3].co);
}
+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)
{
Mesh *me = rna_mesh(ptr);
@@ -1105,20 +1120,6 @@ static void rna_TextureFace_image_set(PointerRNA *ptr, PointerRNA value)
tf->tpage = (struct Image *)id;
}
-static void rna_Mesh_auto_smooth_angle_set(PointerRNA *ptr, float value)
-{
- Mesh *me = rna_mesh(ptr);
- value = RAD2DEGF(value);
- CLAMP(value, 1.0f, 80.0f);
- me->smoothresh = (int)value;
-}
-
-static float rna_Mesh_auto_smooth_angle_get(PointerRNA *ptr)
-{
- Mesh *me = rna_mesh(ptr);
- return DEG2RADF((float)me->smoothresh);
-}
-
static int rna_MeshTessFace_verts_get_length(PointerRNA *ptr, int length[RNA_MAX_ARRAY_DIMENSION])
{
MFace *face = (MFace *)ptr->data;
@@ -1817,6 +1818,7 @@ static void rna_def_mface(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
+ const int splitnor_dim[] = {4, 3};
srna = RNA_def_struct(brna, "MeshTessFace", NULL);
RNA_def_struct_sdna(srna, "MFace");
@@ -1868,6 +1870,16 @@ static void rna_def_mface(BlenderRNA *brna)
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");
+ 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_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)");
+
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);
@@ -3113,19 +3125,17 @@ static void rna_def_mesh(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "flag", ME_AUTOSMOOTH);
RNA_def_property_ui_text(prop, "Auto Smooth",
"Treat all set-smoothed faces with angles less than the specified angle "
- "as 'smooth' during render");
+ "as 'smooth', unless they are linked by a sharp edge");
+ RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
-#if 1 /* expose as radians */
prop = RNA_def_property(srna, "auto_smooth_angle", PROP_FLOAT, PROP_ANGLE);
- RNA_def_property_float_funcs(prop, "rna_Mesh_auto_smooth_angle_get", "rna_Mesh_auto_smooth_angle_set", NULL);
- RNA_def_property_ui_range(prop, DEG2RAD(1.0), DEG2RAD(80), 1.0, 1);
-#else
- prop = RNA_def_property(srna, "auto_smooth_angle", PROP_INT, PROP_NONE);
- RNA_def_property_int_sdna(prop, NULL, "smoothresh");
- RNA_def_property_range(prop, 1, 80);
-#endif
+ RNA_def_property_float_sdna(prop, NULL, "smoothresh");
+ RNA_def_property_float_default(prop, DEG2RADF(180.0f));
+ RNA_def_property_range(prop, 0.0f, DEG2RADF(180.0f));
+ RNA_def_property_ui_range(prop, DEG2RADF(0.0f), DEG2RADF(180.0f), 1.0, 1);
RNA_def_property_ui_text(prop, "Auto Smooth Angle",
"Maximum angle between face normals that 'Auto Smooth' will operate on");
+ RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
prop = RNA_def_property(srna, "show_double_sided", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", ME_TWOSIDED);
@@ -3183,6 +3193,11 @@ static void rna_def_mesh(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Draw Normals", "Display face normals as lines");
RNA_def_property_update(prop, 0, "rna_Mesh_update_draw");
+ prop = RNA_def_property(srna, "show_normal_loop", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAW_LNORMALS);
+ RNA_def_property_ui_text(prop, "Draw Split Normals", "Display vertex-per-face normals as lines");
+ RNA_def_property_update(prop, 0, "rna_Mesh_update_draw");
+
prop = RNA_def_property(srna, "show_normal_vertex", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAW_VNORMALS);
RNA_def_property_ui_text(prop, "Draw Vertex Normals", "Display vertex normals as lines");