[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [56562] trunk/blender/source/blender: smooth falloff options for loopcut.
Campbell Barton
ideasman42 at gmail.com
Wed May 8 14:58:28 CEST 2013
Revision: 56562
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=56562
Author: campbellbarton
Date: 2013-05-08 12:58:28 +0000 (Wed, 08 May 2013)
Log Message:
-----------
smooth falloff options for loopcut.
Modified Paths:
--------------
trunk/blender/source/blender/bmesh/intern/bmesh_opdefines.c
trunk/blender/source/blender/bmesh/intern/bmesh_operators.h
trunk/blender/source/blender/bmesh/operators/bmo_subdivide.c
trunk/blender/source/blender/editors/mesh/editmesh_loopcut.c
trunk/blender/source/blender/editors/mesh/editmesh_tools.c
Modified: trunk/blender/source/blender/bmesh/intern/bmesh_opdefines.c
===================================================================
--- trunk/blender/source/blender/bmesh/intern/bmesh_opdefines.c 2013-05-08 12:58:11 UTC (rev 56561)
+++ trunk/blender/source/blender/bmesh/intern/bmesh_opdefines.c 2013-05-08 12:58:28 UTC (rev 56562)
@@ -969,6 +969,7 @@
/* slots_in */
{{"edges", BMO_OP_SLOT_ELEMENT_BUF, {BM_EDGE}},
{"smooth", BMO_OP_SLOT_FLT},
+ {"smooth_falloff", BMO_OP_SLOT_INT}, /* SUBD_FALLOFF_ROOT and friends */
{"fractal", BMO_OP_SLOT_FLT},
{"along_normal", BMO_OP_SLOT_FLT},
{"cuts", BMO_OP_SLOT_INT},
Modified: trunk/blender/source/blender/bmesh/intern/bmesh_operators.h
===================================================================
--- trunk/blender/source/blender/bmesh/intern/bmesh_operators.h 2013-05-08 12:58:11 UTC (rev 56561)
+++ trunk/blender/source/blender/bmesh/intern/bmesh_operators.h 2013-05-08 12:58:28 UTC (rev 56562)
@@ -39,7 +39,16 @@
SUBD_STRAIGHT_CUT
};
+/* aligned with PROP_SMOOTH and friends */
enum {
+ SUBD_FALLOFF_SMOOTH = 0,
+ SUBD_FALLOFF_SPHERE,
+ SUBD_FALLOFF_ROOT,
+ SUBD_FALLOFF_SHARP,
+ SUBD_FALLOFF_LIN,
+};
+
+enum {
SUBDIV_SELECT_ORIG,
SUBDIV_SELECT_INNER,
SUBDIV_SELECT_INNER_SEL,
@@ -107,12 +116,13 @@
/*------specific operator helper functions-------*/
void BM_mesh_esubdivide(BMesh *bm, const char edge_hflag,
- float smooth, float fractal, float along_normal,
- int numcuts,
- int seltype, int cornertype,
+ const float smooth, const short smooth_falloff,
+ const float fractal, const float along_normal,
+ const int numcuts,
+ const int seltype, const int cornertype,
const short use_single_edge, const short use_grid_fill,
const short use_only_quads,
- int seed);
+ const int seed);
#include "intern/bmesh_operator_api_inline.h"
Modified: trunk/blender/source/blender/bmesh/operators/bmo_subdivide.c
===================================================================
--- trunk/blender/source/blender/bmesh/operators/bmo_subdivide.c 2013-05-08 12:58:11 UTC (rev 56561)
+++ trunk/blender/source/blender/bmesh/operators/bmo_subdivide.c 2013-05-08 12:58:28 UTC (rev 56562)
@@ -44,6 +44,7 @@
typedef struct SubDParams {
int numcuts;
float smooth;
+ int smooth_falloff;
float fractal;
float along_normal;
//int beauty;
@@ -159,7 +160,7 @@
}
else if (params->use_smooth) {
/* we calculate an offset vector vec1[], to be added to *co */
- float len, nor[3], nor1[3], nor2[3], smooth = params->smooth;
+ float len, nor[3], nor1[3], nor2[3], val;
sub_v3_v3v3(nor, vsta->co, vend->co);
len = 0.5f * normalize_v3(nor);
@@ -176,10 +177,29 @@
madd_v3_v3fl(tvec, nor2, fac);
/* falloff for multi subdivide */
- smooth *= sqrtf(fabsf(1.0f - 2.0f * fabsf(0.5f - perc)));
+ val = fabsf(1.0f - 2.0f * fabsf(0.5f - perc));
- mul_v3_fl(tvec, smooth * len);
+ switch (params->smooth_falloff) {
+ case SUBD_FALLOFF_SMOOTH:
+ val = 3.0f * val * val - 2.0f * val * val * val;
+ break;
+ case SUBD_FALLOFF_SPHERE:
+ val = sqrtf(2.0f * val - val * val);
+ break;
+ case SUBD_FALLOFF_ROOT:
+ val = sqrtf(val);
+ break;
+ case SUBD_FALLOFF_SHARP:
+ val = val * val;
+ break;
+ case SUBD_FALLOFF_LIN:
+ break;
+ default:
+ BLI_assert(0);
+ }
+ mul_v3_fl(tvec, params->smooth * val * len);
+
add_v3_v3(co, tvec);
}
@@ -757,13 +777,14 @@
BLI_array_declare(verts);
float smooth, fractal, along_normal;
bool use_sphere, use_single_edge, use_grid_fill, use_only_quads;
- int cornertype, skey, seed, i, j, matched, a, b, numcuts, totesel;
+ int cornertype, skey, seed, i, j, matched, a, b, numcuts, totesel, smooth_falloff;
BMO_slot_buffer_flag_enable(bm, op->slots_in, "edges", BM_EDGE, SUBD_SPLIT);
numcuts = BMO_slot_int_get(op->slots_in, "cuts");
seed = BMO_slot_int_get(op->slots_in, "seed");
smooth = BMO_slot_float_get(op->slots_in, "smooth");
+ smooth_falloff = BMO_slot_int_get(op->slots_in, "smooth_falloff");
fractal = BMO_slot_float_get(op->slots_in, "fractal");
along_normal = BMO_slot_float_get(op->slots_in, "along_normal");
cornertype = BMO_slot_int_get(op->slots_in, "quad_corner_type");
@@ -822,6 +843,7 @@
params.slot_edge_percents = BMO_slot_get(op->slots_in, "edge_percents");
params.slot_custom_patterns = BMO_slot_get(op->slots_in, "custom_patterns");
params.smooth = smooth;
+ params.smooth_falloff = smooth_falloff;
params.seed = seed;
params.fractal = fractal;
params.along_normal = along_normal;
@@ -1142,26 +1164,29 @@
/* editmesh-emulating function */
void BM_mesh_esubdivide(BMesh *bm, const char edge_hflag,
- float smooth, float fractal, float along_normal,
- int numcuts,
- int seltype, int cornertype,
+ const float smooth, const short smooth_falloff,
+ const float fractal, const float along_normal,
+ const int numcuts,
+ const int seltype, const int cornertype,
const short use_single_edge, const short use_grid_fill,
const short use_only_quads,
- int seed)
+ const int seed)
{
BMOperator op;
/* use_sphere isnt exposed here since its only used for new primitives */
BMO_op_initf(bm, &op, BMO_FLAG_DEFAULTS,
"subdivide_edges edges=%he "
- "smooth=%f fractal=%f along_normal=%f "
+ "smooth=%f smooth_falloff=%i "
+ "fractal=%f along_normal=%f "
"cuts=%i "
"quad_corner_type=%i "
"use_single_edge=%b use_grid_fill=%b "
"use_only_quads=%b "
"seed=%i",
edge_hflag,
- smooth, fractal, along_normal,
+ smooth, smooth_falloff,
+ fractal, along_normal,
numcuts,
cornertype,
use_single_edge, use_grid_fill,
Modified: trunk/blender/source/blender/editors/mesh/editmesh_loopcut.c
===================================================================
--- trunk/blender/source/blender/editors/mesh/editmesh_loopcut.c 2013-05-08 12:58:11 UTC (rev 56561)
+++ trunk/blender/source/blender/editors/mesh/editmesh_loopcut.c 2013-05-08 12:58:28 UTC (rev 56562)
@@ -53,6 +53,7 @@
#include "RNA_access.h"
#include "RNA_define.h"
+#include "RNA_enum_types.h"
#include "WM_api.h"
#include "WM_types.h"
@@ -276,6 +277,7 @@
RingSelOpData *lcd = op->customdata;
const int cuts = RNA_int_get(op->ptr, "number_cuts");
const float smoothness = 0.292f * RNA_float_get(op->ptr, "smoothness");
+ const int smooth_falloff = RNA_enum_get(op->ptr, "falloff");
#ifdef BMW_EDGERING_NGON
const bool use_only_quads = false;
#else
@@ -293,7 +295,7 @@
* Note though that it will break edgeslide in this specific case.
* See [#31939]. */
BM_mesh_esubdivide(em->bm, BM_ELEM_SELECT,
- smoothness, 0.0f, 0.0f,
+ smoothness, smooth_falloff, 0.0f, 0.0f,
cuts,
SUBDIV_SELECT_LOOPCUT, SUBD_PATH, 0, true,
use_only_quads, 0);
@@ -650,6 +652,12 @@
"Smoothness", "Smoothness factor", -SUBD_SMOOTH_MAX, SUBD_SMOOTH_MAX);
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
+ prop = RNA_def_property(ot->srna, "falloff", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_items(prop, proportional_falloff_curve_only_items);
+ RNA_def_property_enum_default(prop, PROP_ROOT);
+ RNA_def_property_ui_text(prop, "Falloff", "Falloff type the feather");
+ RNA_def_property_translation_context(prop, BLF_I18NCONTEXT_ID_CURVE); /* Abusing id_curve :/ */
+
prop = RNA_def_int(ot->srna, "edge_index", -1, -1, INT_MAX, "Number of Cuts", "", 0, INT_MAX);
RNA_def_property_flag(prop, PROP_HIDDEN);
}
Modified: trunk/blender/source/blender/editors/mesh/editmesh_tools.c
===================================================================
--- trunk/blender/source/blender/editors/mesh/editmesh_tools.c 2013-05-08 12:58:11 UTC (rev 56561)
+++ trunk/blender/source/blender/editors/mesh/editmesh_tools.c 2013-05-08 12:58:28 UTC (rev 56562)
@@ -90,7 +90,8 @@
}
BM_mesh_esubdivide(em->bm, BM_ELEM_SELECT,
- smooth, fractal, along_normal,
+ smooth, SUBD_FALLOFF_ROOT,
+ fractal, along_normal,
cuts,
SUBDIV_SELECT_ORIG, RNA_enum_get(op->ptr, "quadcorner"),
RNA_boolean_get(op->ptr, "quadtri"), true, false,
More information about the Bf-blender-cvs
mailing list