[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [46226] trunk/blender/source/blender: Fix #31139: fractal mesh subdivide was only working along normal where previously
Brecht Van Lommel
brechtvanlommel at pandora.be
Thu May 3 12:14:09 CEST 2012
Revision: 46226
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=46226
Author: blendix
Date: 2012-05-03 10:14:08 +0000 (Thu, 03 May 2012)
Log Message:
-----------
Fix #31139: fractal mesh subdivide was only working along normal where previously
it would displace in all directions. Now there's an operator option to control this.
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/bmesh/operators/bmo_subdivide.h
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 2012-05-03 09:51:12 UTC (rev 46225)
+++ trunk/blender/source/blender/bmesh/intern/bmesh_opdefines.c 2012-05-03 10:14:08 UTC (rev 46226)
@@ -696,6 +696,7 @@
{{BMO_OP_SLOT_ELEMENT_BUF, "edges"},
{BMO_OP_SLOT_FLT, "smooth"},
{BMO_OP_SLOT_FLT, "fractal"},
+ {BMO_OP_SLOT_FLT, "along_normal"},
{BMO_OP_SLOT_INT, "numcuts"},
{BMO_OP_SLOT_INT, "seed"},
{BMO_OP_SLOT_MAPPING, "custompatterns"},
Modified: trunk/blender/source/blender/bmesh/intern/bmesh_operators.h
===================================================================
--- trunk/blender/source/blender/bmesh/intern/bmesh_operators.h 2012-05-03 09:51:12 UTC (rev 46225)
+++ trunk/blender/source/blender/bmesh/intern/bmesh_operators.h 2012-05-03 10:14:08 UTC (rev 46226)
@@ -98,7 +98,7 @@
struct Object;
void BM_mesh_esubdivide(BMesh *bm, const char edge_hflag,
- float smooth, float fractal,
+ float smooth, float fractal, float along_normal,
int numcuts,
int seltype, int cornertype,
const short use_singleedge, const short use_gridfill,
Modified: trunk/blender/source/blender/bmesh/operators/bmo_subdivide.c
===================================================================
--- trunk/blender/source/blender/bmesh/operators/bmo_subdivide.c 2012-05-03 09:51:12 UTC (rev 46225)
+++ trunk/blender/source/blender/bmesh/operators/bmo_subdivide.c 2012-05-03 10:14:08 UTC (rev 46226)
@@ -141,23 +141,24 @@
if (params->use_fractal) {
float len = len_v3v3(vsta->co, vend->co);
- float vec2[3] = {0.0f, 0.0f, 0.0f}, co2[3];
+ float normal[3] = {0.0f, 0.0f, 0.0f}, co2[3], base1[3], base2[3];
fac = params->fractal * len;
- add_v3_v3(vec2, vsta->no);
- add_v3_v3(vec2, vend->no);
- mul_v3_fl(vec2, 0.5f);
+ mid_v3_v3v3(normal, vsta->no, vend->no);
+ ortho_basis_v3v3_v3(base1, base2, normal);
add_v3_v3v3(co2, v->co, params->off);
- tvec[0] = fac * (BLI_gTurbulence(1.0, co2[0], co2[1], co2[2], 15, 0, 1) - 0.5f);
- tvec[1] = fac * (BLI_gTurbulence(1.0, co2[0], co2[1], co2[2], 15, 0, 1) - 0.5f);
- tvec[2] = fac * (BLI_gTurbulence(1.0, co2[0], co2[1], co2[2], 15, 0, 1) - 0.5f);
+ mul_v3_fl(co2, 10.0f);
- mul_v3_v3(vec2, tvec);
+ tvec[0] = fac * (BLI_gTurbulence(1.0, co2[0], co2[1], co2[2], 15, 0, 2) - 0.5f);
+ tvec[1] = fac * (BLI_gTurbulence(1.0, co2[1], co2[0], co2[2], 15, 0, 2) - 0.5f);
+ tvec[2] = fac * (BLI_gTurbulence(1.0, co2[1], co2[2], co2[0], 15, 0, 2) - 0.5f);
/* add displacement */
- add_v3_v3v3(co, co, vec2);
+ madd_v3_v3fl(co, normal, tvec[0]);
+ madd_v3_v3fl(co, base1, tvec[1] * (1.0f - params->along_normal));
+ madd_v3_v3fl(co, base2, tvec[2] * (1.0f - params->along_normal));
}
/* apply the new difference to the rest of the shape keys,
@@ -687,7 +688,7 @@
BLI_array_declare(facedata);
BLI_array_declare(edges);
BLI_array_declare(verts);
- float smooth, fractal;
+ float smooth, fractal, along_normal;
int use_sphere, cornertype, use_singleedge, use_gridfill;
int skey, seed, i, j, matched, a, b, numcuts, totesel;
@@ -697,6 +698,7 @@
seed = BMO_slot_int_get(op, "seed");
smooth = BMO_slot_float_get(op, "smooth");
fractal = BMO_slot_float_get(op, "fractal");
+ along_normal = BMO_slot_float_get(op, "along_normal");
cornertype = BMO_slot_int_get(op, "quadcornertype");
use_singleedge = BMO_slot_bool_get(op, "use_singleedge");
@@ -754,6 +756,7 @@
params.smooth = smooth;
params.seed = seed;
params.fractal = fractal;
+ params.along_normal = along_normal;
params.use_smooth = (smooth != 0.0f);
params.use_fractal = (fractal != 0.0f);
params.use_sphere = use_sphere;
@@ -1025,7 +1028,7 @@
/* editmesh-emulating function */
void BM_mesh_esubdivide(BMesh *bm, const char edge_hflag,
- float smooth, float fractal,
+ float smooth, float fractal, float along_normal,
int numcuts,
int seltype, int cornertype,
const short use_singleedge, const short use_gridfill,
@@ -1036,13 +1039,13 @@
/* use_sphere isnt exposed here since its only used for new primitives */
BMO_op_initf(bm, &op,
"esubd edges=%he "
- "smooth=%f fractal=%f "
+ "smooth=%f fractal=%f along_normal=%f "
"numcuts=%i "
"quadcornertype=%i "
"use_singleedge=%b use_gridfill=%b "
"seed=%i",
edge_hflag,
- smooth, fractal,
+ smooth, fractal, along_normal,
numcuts,
cornertype,
use_singleedge, use_gridfill,
Modified: trunk/blender/source/blender/bmesh/operators/bmo_subdivide.h
===================================================================
--- trunk/blender/source/blender/bmesh/operators/bmo_subdivide.h 2012-05-03 09:51:12 UTC (rev 46225)
+++ trunk/blender/source/blender/bmesh/operators/bmo_subdivide.h 2012-05-03 10:14:08 UTC (rev 46226)
@@ -31,6 +31,7 @@
int numcuts;
float smooth;
float fractal;
+ float along_normal;
//int beauty;
short use_smooth;
short use_sphere;
Modified: trunk/blender/source/blender/editors/mesh/editmesh_loopcut.c
===================================================================
--- trunk/blender/source/blender/editors/mesh/editmesh_loopcut.c 2012-05-03 09:51:12 UTC (rev 46225)
+++ trunk/blender/source/blender/editors/mesh/editmesh_loopcut.c 2012-05-03 10:14:08 UTC (rev 46226)
@@ -314,7 +314,7 @@
if (lcd->do_cut) {
BM_mesh_esubdivide(em->bm, BM_ELEM_SELECT,
- 0.0f, 0.0f,
+ 0.0f, 0.0f, 0.0f,
cuts,
SUBDIV_SELECT_LOOPCUT, SUBD_PATH, 0, FALSE, 0);
Modified: trunk/blender/source/blender/editors/mesh/editmesh_tools.c
===================================================================
--- trunk/blender/source/blender/editors/mesh/editmesh_tools.c 2012-05-03 09:51:12 UTC (rev 46225)
+++ trunk/blender/source/blender/editors/mesh/editmesh_tools.c 2012-05-03 10:14:08 UTC (rev 46226)
@@ -87,6 +87,7 @@
int cuts = RNA_int_get(op->ptr, "number_cuts");
float smooth = 0.292f * RNA_float_get(op->ptr, "smoothness");
float fractal = RNA_float_get(op->ptr, "fractal") / 2.5f;
+ float along_normal = RNA_float_get(op->ptr, "fractal_along_normal");
if (RNA_boolean_get(op->ptr, "quadtri") &&
RNA_enum_get(op->ptr, "quadcorner") == SUBD_STRAIGHT_CUT)
@@ -95,7 +96,7 @@
}
BM_mesh_esubdivide(em->bm, BM_ELEM_SELECT,
- smooth, fractal,
+ smooth, fractal, along_normal,
cuts,
SUBDIV_SELECT_ORIG, RNA_enum_get(op->ptr, "quadcorner"),
RNA_boolean_get(op->ptr, "quadtri"), TRUE,
@@ -143,6 +144,7 @@
"Quad Corner Type", "How to subdivide quad corners (anything other than Straight Cut will prevent ngons)");
RNA_def_float(ot->srna, "fractal", 0.0f, 0.0f, FLT_MAX, "Fractal", "Fractal randomness factor", 0.0f, 1000.0f);
+ RNA_def_float(ot->srna, "fractal_along_normal", 0.0f, 0.0f, 1.0f, "Along Normal", "Apply fractal displacement along normal only", 0.0f, 1.0f);
RNA_def_int(ot->srna, "seed", 0, 0, 10000, "Random Seed", "Seed for the random number generator", 0, 50);
}
More information about the Bf-blender-cvs
mailing list