RNA properties - expose values as radians rather then degrees
- sequencer wipe angle - mesh autosmooth - bevel modifier angle - edge split angle
This commit is contained in:
@@ -40,6 +40,9 @@
|
||||
|
||||
#include "WM_types.h"
|
||||
|
||||
#include "BLI_math_base.h"
|
||||
#include "BLI_math_rotation.h"
|
||||
|
||||
#ifdef RNA_RUNTIME
|
||||
|
||||
#include "DNA_scene_types.h"
|
||||
@@ -912,6 +915,20 @@ 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= (Mesh*)ptr->id.data;
|
||||
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= (Mesh*)ptr->id.data;
|
||||
return DEG2RADF((float)me->smoothresh);
|
||||
}
|
||||
|
||||
static int rna_MeshFace_verts_get_length(PointerRNA *ptr, int length[RNA_MAX_ARRAY_DIMENSION])
|
||||
{
|
||||
MFace *face= (MFace*)ptr->data;
|
||||
@@ -1913,9 +1930,15 @@ 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", "Treats all set-smoothed faces with angles less than the specified angle as 'smooth' during render");
|
||||
|
||||
#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_ui_text(prop, "Auto Smooth Angle", "Defines maximum angle between face normals that 'Auto Smooth' will operate on");
|
||||
|
||||
prop= RNA_def_property(srna, "show_double_sided", PROP_BOOLEAN, PROP_NONE);
|
||||
|
||||
@@ -578,6 +578,34 @@ static void rna_UVProjectModifier_num_projectors_set(PointerRNA *ptr, int value)
|
||||
md->projectors[a]= NULL;
|
||||
}
|
||||
|
||||
static float rna_EdgeSplitModifier_split_angle_get(PointerRNA *ptr)
|
||||
{
|
||||
EdgeSplitModifierData *md= (EdgeSplitModifierData*)ptr->data;
|
||||
return DEG2RADF(md->split_angle);
|
||||
}
|
||||
|
||||
static void rna_EdgeSplitModifier_split_angle_set(PointerRNA *ptr, float value)
|
||||
{
|
||||
EdgeSplitModifierData *md= (EdgeSplitModifierData*)ptr->data;
|
||||
value= RAD2DEGF(value);
|
||||
CLAMP(value, 0.0f, 180.0f);
|
||||
md->split_angle= (int)value;
|
||||
}
|
||||
|
||||
static float rna_BevelModifier_angle_limit_get(PointerRNA *ptr)
|
||||
{
|
||||
BevelModifierData *md= (BevelModifierData*)ptr->data;
|
||||
return DEG2RADF(md->bevel_angle);
|
||||
}
|
||||
|
||||
static void rna_BevelModifier_angle_limit_set(PointerRNA *ptr, float value)
|
||||
{
|
||||
BevelModifierData *md= (BevelModifierData*)ptr->data;
|
||||
value= RAD2DEGF(value);
|
||||
CLAMP(value, 0.0f, 180.0f);
|
||||
md->bevel_angle= (int)value;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static void rna_def_property_subdivision_common(StructRNA *srna, const char type[])
|
||||
@@ -1365,10 +1393,16 @@ static void rna_def_modifier_edgesplit(BlenderRNA *brna)
|
||||
RNA_def_struct_sdna(srna, "EdgeSplitModifierData");
|
||||
RNA_def_struct_ui_icon(srna, ICON_MOD_EDGESPLIT);
|
||||
|
||||
// XXX, convert to radians.
|
||||
#if 1 /* expose as radians */
|
||||
prop= RNA_def_property(srna, "split_angle", PROP_FLOAT, PROP_ANGLE);
|
||||
RNA_def_property_float_funcs(prop, "rna_EdgeSplitModifier_split_angle_get", "rna_EdgeSplitModifier_split_angle_set", NULL);
|
||||
RNA_def_property_range(prop, 0, DEG2RAD(180));
|
||||
RNA_def_property_ui_range(prop, 0, DEG2RAD(180), 100, 2);
|
||||
#else
|
||||
prop= RNA_def_property(srna, "split_angle", PROP_FLOAT, PROP_NONE);
|
||||
RNA_def_property_range(prop, 0, 180);
|
||||
RNA_def_property_ui_range(prop, 0, 180, 100, 2);
|
||||
#endif
|
||||
RNA_def_property_ui_text(prop, "Split Angle", "Angle above which to split edges");
|
||||
RNA_def_property_update(prop, 0, "rna_Modifier_update");
|
||||
|
||||
@@ -1965,10 +1999,17 @@ static void rna_def_modifier_bevel(BlenderRNA *brna)
|
||||
RNA_def_property_ui_text(prop, "Edge Weight Method", "What edge weight to use for weighting a vertex");
|
||||
RNA_def_property_update(prop, 0, "rna_Modifier_update");
|
||||
|
||||
#if 1 /* expose as radians */
|
||||
prop= RNA_def_property(srna, "angle_limit", PROP_FLOAT, PROP_ANGLE);
|
||||
RNA_def_property_float_funcs(prop, "rna_BevelModifier_angle_limit_get", "rna_BevelModifier_angle_limit_set", NULL);
|
||||
RNA_def_property_range(prop, 0, DEG2RAD(180));
|
||||
RNA_def_property_ui_range(prop, 0, DEG2RAD(180), 100, 2);
|
||||
#else
|
||||
prop= RNA_def_property(srna, "angle_limit", PROP_FLOAT, PROP_NONE);
|
||||
RNA_def_property_float_sdna(prop, NULL, "bevel_angle");
|
||||
RNA_def_property_range(prop, 0, 180);
|
||||
RNA_def_property_ui_range(prop, 0, 180, 100, 2);
|
||||
#endif
|
||||
RNA_def_property_ui_text(prop, "Angle", "Angle above which to bevel edges");
|
||||
RNA_def_property_update(prop, 0, "rna_Modifier_update");
|
||||
}
|
||||
|
||||
@@ -680,6 +680,23 @@ static void rna_SequenceEditor_overlay_frame_set(PointerRNA *ptr, int value)
|
||||
ed->over_ofs= value;
|
||||
}
|
||||
|
||||
|
||||
static void rna_WipeSequence_angle_set(PointerRNA *ptr, float value)
|
||||
{
|
||||
Sequence *seq= (Sequence *)(ptr->data);
|
||||
value= RAD2DEGF(value);
|
||||
CLAMP(value, -90.0f, 90.0f);
|
||||
((WipeVars *)seq->effectdata)->angle= value;
|
||||
}
|
||||
|
||||
static float rna_WipeSequence_angle_get(PointerRNA *ptr)
|
||||
{
|
||||
Sequence *seq= (Sequence *)(ptr->data);
|
||||
|
||||
return DEG2RADF(((WipeVars *)seq->effectdata)->angle);
|
||||
}
|
||||
|
||||
|
||||
#else
|
||||
|
||||
static void rna_def_strip_element(BlenderRNA *brna)
|
||||
@@ -1460,10 +1477,16 @@ static void rna_def_wipe(BlenderRNA *brna)
|
||||
RNA_def_property_range(prop, 0.0f, 1.0f);
|
||||
RNA_def_property_ui_text(prop, "Blur Width", "Width of the blur edge, in percentage relative to the image size");
|
||||
RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update");
|
||||
|
||||
|
||||
#if 1 /* expose as radians */
|
||||
prop= RNA_def_property(srna, "angle", PROP_FLOAT, PROP_ANGLE);
|
||||
RNA_def_property_float_funcs(prop, "rna_WipeSequence_angle_get", "rna_WipeSequence_angle_set", NULL);
|
||||
RNA_def_property_range(prop, DEG2RAD(-90.0f), DEG2RAD(90.0f));
|
||||
#else
|
||||
prop= RNA_def_property(srna, "angle", PROP_FLOAT, PROP_NONE);
|
||||
RNA_def_property_float_sdna(prop, NULL, "angle");
|
||||
RNA_def_property_range(prop, -90.0f, 90.0f);
|
||||
#endif
|
||||
RNA_def_property_ui_text(prop, "Angle", "Edge angle");
|
||||
RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user