[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [47854] branches/soc-2012-sushi/source/ blender: Add smooth configuration along every axis X, Y, Z.
Alexander Pinzon
apinzonf at gmail.com
Wed Jun 13 23:58:49 CEST 2012
Revision: 47854
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=47854
Author: apinzonf
Date: 2012-06-13 21:58:40 +0000 (Wed, 13 Jun 2012)
Log Message:
-----------
Add smooth configuration along every axis X, Y, Z.
Modified Paths:
--------------
branches/soc-2012-sushi/source/blender/bmesh/intern/bmesh_opdefines.c
branches/soc-2012-sushi/source/blender/bmesh/operators/bmo_smooth_laplacian.c
branches/soc-2012-sushi/source/blender/editors/mesh/editmesh_tools.c
branches/soc-2012-sushi/source/blender/modifiers/intern/MOD_laplaciansmooth.c
Modified: branches/soc-2012-sushi/source/blender/bmesh/intern/bmesh_opdefines.c
===================================================================
--- branches/soc-2012-sushi/source/blender/bmesh/intern/bmesh_opdefines.c 2012-06-13 21:37:39 UTC (rev 47853)
+++ branches/soc-2012-sushi/source/blender/bmesh/intern/bmesh_opdefines.c 2012-06-13 21:58:40 UTC (rev 47854)
@@ -121,10 +121,10 @@
{BMO_OP_SLOT_FLT, "lambda"}, //lambda param
{BMO_OP_SLOT_FLT, "lambda_border"}, //lambda param in border
{BMO_OP_SLOT_FLT, "min_area"}, //Minimun area permited
- {BMO_OP_SLOT_BOOL, "mirror_clip_x"}, //set vertices close to the x axis before the operation to 0
- {BMO_OP_SLOT_BOOL, "mirror_clip_y"}, //set vertices close to the y axis before the operation to 0
- {BMO_OP_SLOT_BOOL, "mirror_clip_z"}, //set vertices close to the z axis before the operation to 0
- {BMO_OP_SLOT_FLT, "clipdist"}, //clipping threshod for the above three slots
+ {BMO_OP_SLOT_BOOL, "use_x"}, //Smooth object along X axis
+ {BMO_OP_SLOT_BOOL, "use_y"}, //Smooth object along Y axis
+ {BMO_OP_SLOT_BOOL, "use_z"}, //Smooth object along Z axis
+ {BMO_OP_SLOT_MAPPING, "vertex_group"}, // Vertex group with weights for every vertice.
{0} /* null-terminating sentinel */,
},
bmo_vertexsmoothlaplacian_exec,
Modified: branches/soc-2012-sushi/source/blender/bmesh/operators/bmo_smooth_laplacian.c
===================================================================
--- branches/soc-2012-sushi/source/blender/bmesh/operators/bmo_smooth_laplacian.c 2012-06-13 21:37:39 UTC (rev 47853)
+++ branches/soc-2012-sushi/source/blender/bmesh/operators/bmo_smooth_laplacian.c 2012-06-13 21:58:40 UTC (rev 47854)
@@ -15,7 +15,8 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Contributor(s): Joseph Eagar.
+ * Contributor(s): Joseph Eagar,
+ * Alexander Pinzon
*
* ***** END GPL LICENSE BLOCK *****
*/
@@ -51,12 +52,13 @@
void compute_weights_in_ring(BMVert *v, float lambda, float min_area);
void compute_weights_in_border(BMVert *v, float lambda, float min_area);
float compute_volume(BMesh *bm, BMOperator *op);
-void volume_preservation(BMesh *bm, BMOperator *op, float vini, float vend);
+void volume_preservation(BMesh *bm, BMOperator *op, float vini, float vend, int usex, int usey, int usez);
void bmo_vertexsmoothlaplacian_exec(BMesh *bm, BMOperator *op)
{
int i;
int m_vertex_id;
+ int usex, usey, usez;
float lambda, lambda_border, min_area;
float vini, vend;
BMOIter siter;
@@ -67,6 +69,10 @@
lambda = BMO_slot_float_get(op, "lambda");
lambda_border = BMO_slot_float_get(op, "lambda_border");
min_area = BMO_slot_float_get(op, "min_area");
+ usex = BMO_slot_bool_get(op, "use_x");
+ usey = BMO_slot_bool_get(op, "use_y");
+ usez = BMO_slot_bool_get(op, "use_z");
+
nlNewContext();
context = nlGetCurrent();
@@ -108,12 +114,18 @@
vini = compute_volume(bm, op);
BMO_ITER (v, &siter, bm, op, "verts", BM_VERT) {
m_vertex_id = BM_elem_index_get(v);
- v->co[0] = nlGetVariable(0, m_vertex_id);
- v->co[1] = nlGetVariable(1, m_vertex_id);
- v->co[2] = nlGetVariable(2, m_vertex_id);
+ if(usex){
+ v->co[0] = nlGetVariable(0, m_vertex_id);
+ }
+ if(usey){
+ v->co[1] = nlGetVariable(1, m_vertex_id);
+ }
+ if(usez){
+ v->co[2] = nlGetVariable(2, m_vertex_id);
+ }
}
vend = compute_volume(bm, op);
- volume_preservation(bm, op, vini, vend);
+ volume_preservation(bm, op, vini, vend, usex, usey, usez);
}
nlDeleteContext(context);
@@ -352,7 +364,7 @@
BLI_array_free(weight);
}
-void volume_preservation(BMesh *bm, BMOperator *op, float vini, float vend)
+void volume_preservation(BMesh *bm, BMOperator *op, float vini, float vend, int usex, int usey, int usez)
{
float beta;
BMOIter siter;
@@ -361,7 +373,16 @@
if (vend != 0.0f) {
beta = pow (vini / vend, 1.0f / 3.0f);
BMO_ITER (v, &siter, bm, op, "verts", BM_VERT) {
- mul_v3_fl(v->co, beta );
+ if(usex){
+ v->co[0] = v->co[0] * beta;
+ }
+ if(usey){
+ v->co[1] = v->co[1] * beta;
+ }
+ if(usez){
+ v->co[2] = v->co[2] * beta;
+ }
+
}
}
}
\ No newline at end of file
Modified: branches/soc-2012-sushi/source/blender/editors/mesh/editmesh_tools.c
===================================================================
--- branches/soc-2012-sushi/source/blender/editors/mesh/editmesh_tools.c 2012-06-13 21:37:39 UTC (rev 47853)
+++ branches/soc-2012-sushi/source/blender/editors/mesh/editmesh_tools.c 2012-06-13 21:58:40 UTC (rev 47854)
@@ -1600,9 +1600,8 @@
Object *obedit = CTX_data_edit_object(C);
BMEditMesh *em = BMEdit_FromObject(obedit);
ModifierData *md;
- int mirrx = FALSE, mirry = FALSE, mirrz = FALSE;
+ int usex = TRUE, usey = TRUE, usez = TRUE;
int i, repeat;
- float clipdist = 0.0f;
float lambda = 0.1f;
float lambda_border = 0.1f;
float min_area = 0.00001f;
@@ -1624,37 +1623,20 @@
EDBM_verts_mirror_cache_begin(em, TRUE);
}
- /* if there is a mirror modifier with clipping, flag the verts that
- * are within tolerance of the plane(s) of reflection
- */
- for (md = obedit->modifiers.first; md; md = md->next) {
- if (md->type == eModifierType_Mirror && (md->mode & eModifierMode_Realtime)) {
- MirrorModifierData *mmd = (MirrorModifierData *)md;
-
- if (mmd->flag & MOD_MIR_CLIPPING) {
- if (mmd->flag & MOD_MIR_AXIS_X)
- mirrx = TRUE;
- if (mmd->flag & MOD_MIR_AXIS_Y)
- mirry = TRUE;
- if (mmd->flag & MOD_MIR_AXIS_Z)
- mirrz = TRUE;
-
- clipdist = mmd->tolerance;
- }
- }
- }
-
repeat = RNA_int_get(op->ptr, "repeat");
lambda = RNA_float_get(op->ptr, "lambda");
lambda_border = RNA_float_get(op->ptr, "lambda_border");
min_area = RNA_float_get(op->ptr, "min_area");
+ usex = RNA_boolean_get(op->ptr, "use_x");
+ usey = RNA_boolean_get(op->ptr, "use_y");
+ usez = RNA_boolean_get(op->ptr, "use_z");
if (!repeat)
repeat = 1;
for (i = 0; i < repeat; i++) {
if (!EDBM_op_callf(em, op,
- "vertexsmoothlaplacian verts=%hv lambda=%f lambda_border=%f min_area=%f mirror_clip_x=%b mirror_clip_y=%b mirror_clip_z=%b clipdist=%f",
- BM_ELEM_SELECT, lambda, lambda_border, min_area, mirrx, mirry, mirrz, clipdist))
+ "vertexsmoothlaplacian verts=%hv lambda=%f lambda_border=%f min_area=%f use_x=%b use_y=%b use_z=%b",
+ BM_ELEM_SELECT, lambda, lambda_border, min_area, usex, usey, usez))
{
return OPERATOR_CANCELLED;
}
@@ -1693,6 +1675,9 @@
"Lambda factor in border", "", 0.0000001f, 100.0f);
RNA_def_float(ot->srna, "min_area", 0.00001f, 0.0000000000000001f, 100.0f,
"Minimum area permitted", "", 0.0000000000000001f, 100.0f);
+ RNA_def_boolean(ot->srna, "use_x", 1, "Smooth X Axis", "Smooth object along X axis");
+ RNA_def_boolean(ot->srna, "use_y", 1, "Smooth Y Axis", "Smooth object along Y axis");
+ RNA_def_boolean(ot->srna, "use_z", 1, "Smooth Z Axis", "Smooth object along Z axis");
}
Modified: branches/soc-2012-sushi/source/blender/modifiers/intern/MOD_laplaciansmooth.c
===================================================================
--- branches/soc-2012-sushi/source/blender/modifiers/intern/MOD_laplaciansmooth.c 2012-06-13 21:37:39 UTC (rev 47853)
+++ branches/soc-2012-sushi/source/blender/modifiers/intern/MOD_laplaciansmooth.c 2012-06-13 21:58:40 UTC (rev 47854)
@@ -22,13 +22,14 @@
* Ton Roosendaal,
* Ben Batt,
* Brecht Van Lommel,
- * Campbell Barton
+ * Campbell Barton,
+ * Alexander Pinzon
*
* ***** END GPL LICENSE BLOCK *****
*
*/
-/** \file blender/modifiers/intern/MOD_smooth.c
+/** \file blender/modifiers/intern/MOD_laplaciansmooth.c
* \ingroup modifiers
*/
@@ -237,7 +238,13 @@
dm->release(dm);
}
+static void laplaciansmoothModifier_do2(
+ LaplacianSmoothModifierData *smd, Object *ob, DerivedMesh *dm,
+ float (*vertexCos)[3], int numVerts)
+{
+}
+
ModifierTypeInfo modifierType_LaplacianSmooth = {
/* name */ "Laplacian Smooth",
/* structName */ "LaplacianSmoothModifierData",
More information about the Bf-blender-cvs
mailing list