[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [60909] branches/soc-2013-sketch_mesh: Style cleanup: Coding Style.
Alexander Pinzon
apinzonf at gmail.com
Wed Oct 23 22:12:16 CEST 2013
Revision: 60909
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=60909
Author: apinzonf
Date: 2013-10-23 20:12:15 +0000 (Wed, 23 Oct 2013)
Log Message:
-----------
Style cleanup: Coding Style.
Modified Paths:
--------------
branches/soc-2013-sketch_mesh/release/scripts/startup/bl_ui/properties_data_modifier.py
branches/soc-2013-sketch_mesh/source/blender/makesrna/intern/rna_modifier.c
branches/soc-2013-sketch_mesh/source/blender/modifiers/intern/MOD_laplaciandeform.c
Modified: branches/soc-2013-sketch_mesh/release/scripts/startup/bl_ui/properties_data_modifier.py
===================================================================
--- branches/soc-2013-sketch_mesh/release/scripts/startup/bl_ui/properties_data_modifier.py 2013-10-23 18:40:29 UTC (rev 60908)
+++ branches/soc-2013-sketch_mesh/release/scripts/startup/bl_ui/properties_data_modifier.py 2013-10-23 20:12:15 UTC (rev 60909)
@@ -374,7 +374,7 @@
row.operator("object.hook_assign", text="Assign")
def LAPLACIANDEFORM(self, layout, ob, md):
- layout.prop(md, "iterations")
+ layout.prop(md, "repetitions")
layout.label(text="Anchors Vertex Group:")
layout.prop_search(md, "vertex_group", ob, "vertex_groups", text="")
Modified: branches/soc-2013-sketch_mesh/source/blender/makesrna/intern/rna_modifier.c
===================================================================
--- branches/soc-2013-sketch_mesh/source/blender/makesrna/intern/rna_modifier.c 2013-10-23 18:40:29 UTC (rev 60908)
+++ branches/soc-2013-sketch_mesh/source/blender/makesrna/intern/rna_modifier.c 2013-10-23 20:12:15 UTC (rev 60909)
@@ -3684,7 +3684,7 @@
"Name of Vertex Group which determines Anchors");
RNA_def_property_string_funcs(prop, NULL, NULL, "rna_LaplacianDeformModifier_vgroup_set");
- prop = RNA_def_property(srna, "iterations", PROP_INT, PROP_NONE);
+ prop = RNA_def_property(srna, "repetitions", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "repeat");
RNA_def_property_ui_range(prop, 1, 50, 1, -1);
RNA_def_property_ui_text(prop, "Repeat", "");
Modified: branches/soc-2013-sketch_mesh/source/blender/modifiers/intern/MOD_laplaciandeform.c
===================================================================
--- branches/soc-2013-sketch_mesh/source/blender/modifiers/intern/MOD_laplaciandeform.c 2013-10-23 18:40:29 UTC (rev 60908)
+++ branches/soc-2013-sketch_mesh/source/blender/modifiers/intern/MOD_laplaciandeform.c 2013-10-23 20:12:15 UTC (rev 60909)
@@ -53,18 +53,18 @@
int total_edges;
int total_anchors;
int repeat;
- char anchor_grp_name[64]; /* Vertex Group name*/
+ char anchor_grp_name[64]; /* Vertex Group name*/
float (*co)[3]; /* Original vertex coordinates*/
float (*no)[3]; /* Original vertex normal*/
float (*delta)[3]; /* Differential Coordinates*/
int *index_anchors; /* Static vertex index list*/
- int *unit_verts; /* Unit vectors of projected edges onto the plane orthogonal to n*/
+ int *unit_verts; /* Unit vectors of projected edges onto the plane orthogonal to n*/
BMVert **verts; /* Vertex order by index*/
BMesh *bm; /* Bmesh structure pointer*/
NLContext *context; /* System for solve general implicit rotations*/
} LaplacianSystem;
-static LaplacianSystem *newLaplacianSystem()
+static LaplacianSystem *newLaplacianSystem(void)
{
LaplacianSystem *sys;
sys = MEM_callocN(sizeof(LaplacianSystem), "DeformCache");
@@ -89,7 +89,7 @@
return sys;
}
-static LaplacianSystem *initLaplacianSystem(int totalVerts, int totalEdges, int totalFaces, int totalAnchors,
+static LaplacianSystem *initLaplacianSystem(int totalVerts, int totalEdges, int totalAnchors,
char defgrpName[64], int iterations)
{
LaplacianSystem *sys = newLaplacianSystem();
@@ -103,14 +103,14 @@
sys->total_anchors = totalAnchors;
sys->repeat = iterations;
BLI_strncpy(sys->anchor_grp_name, defgrpName, sizeof(sys->anchor_grp_name));
- sys->co = (float (*)[3])MEM_callocN(sizeof(float)*(totalVerts * 3), "DeformCoordinates");
- sys->no = (float (*)[3])MEM_callocN(sizeof(float)*(totalVerts * 3), "DeformNormals");
- sys->delta = (float (*)[3])MEM_callocN(sizeof(float)*totalVerts * 3, "DeformDeltas");
- sys->index_anchors = (int *)MEM_callocN(sizeof(int)*(totalAnchors), "DeformAnchors");
- sys->unit_verts = (int *)MEM_callocN(sizeof(int)*totalVerts, "DeformUnitVerts");
- sys->verts = (BMVert**)MEM_callocN(sizeof(BMVert*)*(totalVerts), "DeformVerts");
- memset(sys->no, 0.0, sizeof(float)*totalVerts * 3);
- memset(sys->delta, 0.0, sizeof(float)*totalVerts * 3);
+ sys->co = (float (*)[3]) MEM_callocN(sizeof(float) * (totalVerts * 3), "DeformCoordinates");
+ sys->no = (float (*)[3]) MEM_callocN(sizeof(float) * (totalVerts * 3), "DeformNormals");
+ sys->delta = (float (*)[3]) MEM_callocN(sizeof(float) * totalVerts * 3, "DeformDeltas");
+ sys->index_anchors = (int *) MEM_callocN(sizeof(int) * (totalAnchors), "DeformAnchors");
+ sys->unit_verts = (int *) MEM_callocN(sizeof(int) * totalVerts, "DeformUnitVerts");
+ sys->verts = (BMVert**) MEM_callocN(sizeof(BMVert*) * (totalVerts), "DeformVerts");
+ memset(sys->no, 0.0, sizeof(float) * totalVerts * 3);
+ memset(sys->delta, 0.0, sizeof(float) * totalVerts * 3);
return sys;
}
@@ -150,13 +150,41 @@
cross_v3_v3v3(c, a, b);
clen = len_v3(c);
- if (clen < FLT_EPSILON){
+ if (clen < FLT_EPSILON) {
return 0.0f;
}
return dot_v3v3(a, b) / clen;
}
+/**
+* This method computes the Laplacian Matrix and Differential Coordinates for all vertex in the mesh.
+* The Linear system is LV = d
+* Where L is Laplacian Matrix, V as the vertexes in Mesh, d is the differential coordinates
+* The Laplacian Matrix is computes as a
+* Lij = sum(Wij) (if i == j)
+* Lij = Wij (if i != j)
+* Wij is weight between vertex Vi and vertex Vj, we use cotangent weight
+*
+* The Differential Coordinate is computes as a
+* di = Vi * sum(Wij) - sum(Wij * Vj)
+* Where :
+* di is the Differential Coordinate i
+* sum (Wij) is the sum of all weights between vertex Vi and its vertexes neighbors (Vj)
+* sum (Wij * Vj) is the sum of the product between vertex neighbor Vj and weight Wij for all neighborhood.
+*
+* This Laplacian Matrix is described in the paper:
+* Desbrun M. et.al, Implicit fairing of irregular meshes using diffusion and curvature flow, SIGGRAPH '99, pag 317-324,
+* New York, USA
+*
+* The computation of Laplace Beltrami operator on Hybrid Triangle/Quad Meshes is described in the paper:
+* Pinzon A., Romero E., Shape Inflation With an Adapted Laplacian Operator For Hybrid Quad/Triangle Meshes,
+* Conference on Graphics Patterns and Images, SIBGRAPI, 2013
+*
+* The computation of Differential Coordinates is described in the paper:
+* Sorkine, O. Laplacian Surface Editing. Proceedings of the EUROGRAPHICS/ACM SIGGRAPH Symposium on Geometry Processing,
+* 2004. p. 179-188.
+*/
static void initLaplacianMatrix( LaplacianSystem *sys)
{
float v1[3], v2[3], v3[3], v4[3], no[3];
@@ -265,8 +293,8 @@
BM_ITER_MESH (v, &viter, sys->bm, BM_VERTS_OF_MESH) {
i = BM_elem_index_get(v);
- normalize_v3( sys->no[i]);
- BM_ITER_ELEM(e, &eiter, v, BM_EDGES_OF_VERT) {
+ normalize_v3(sys->no[i]);
+ BM_ITER_ELEM (e, &eiter, v, BM_EDGES_OF_VERT) {
vid = BM_elem_index_get(e->v1);
if (vid == i) {
vid = BM_elem_index_get(e->v2);
@@ -322,16 +350,16 @@
cross_v3_v3v3(e2, ni, uij);
copy_v3_v3(di, sys->delta[i]);
alpha = dot_v3v3(ni, di);
- beta = dot_v3v3(uij, di);
- gamma = dot_v3v3(e2, di);
+ beta = dot_v3v3(uij, di);
+ gamma = dot_v3v3(e2, di);
pi[0] = nlGetVariable(0, i);
pi[1] = nlGetVariable(1, i);
pi[2] = nlGetVariable(2, i);
ni[0] = 0.0f; ni[1] = 0.0f; ni[2] = 0.0f;
num_fni = 0;
- BM_ITER_ELEM_INDEX(f, &fiter, v, BM_FACES_OF_VERT, num_fni) {
- BM_ITER_ELEM_INDEX(v2, &viter2, f, BM_VERTS_OF_FACE, j) {
+ BM_ITER_ELEM_INDEX (f, &fiter, v, BM_FACES_OF_VERT, num_fni) {
+ BM_ITER_ELEM_INDEX (v2, &viter2, f, BM_VERTS_OF_FACE, j) {
vin[j] = BM_elem_index_get(v2);
}
lvin = j;
@@ -359,9 +387,9 @@
sub_v3_v3(uij, dun);
normalize_v3(uij);
cross_v3_v3v3(e2, ni, uij);
- fni[0] = alpha*ni[0] + beta * uij[0] + gamma * e2[0];
- fni[1] = alpha*ni[1] + beta * uij[1] + gamma * e2[1];
- fni[2] = alpha*ni[2] + beta * uij[2] + gamma * e2[2];
+ fni[0] = alpha * ni[0] + beta * uij[0] + gamma * e2[0];
+ fni[1] = alpha * ni[1] + beta * uij[1] + gamma * e2[1];
+ fni[2] = alpha * ni[2] + beta * uij[2] + gamma * e2[2];
if (len_v3(fni) > FLT_EPSILON) {
nlRightHandSideSet(0, i, fni[0]);
@@ -378,9 +406,7 @@
static void laplacianDeformPreview(LaplacianSystem *sys, float (*vertexCos)[3])
{
- struct BMesh *bm;
int vid, i, j, n, na;
- bm = sys->bm;
n = sys->total_verts;
na = sys->total_anchors;
@@ -534,7 +560,6 @@
{
int defgrp_index;
MDeformVert *dvert = NULL;
- MDeformVert *dv = NULL;
modifier_get_vgroup(ob, dm, smd->anchor_grp_name, &dvert, &defgrp_index);
if (!dvert) return false;
dvert = NULL;
@@ -575,7 +600,7 @@
}
}
total_anchors = BLI_array_count(index_anchors);
- smd->cacheSystem = initLaplacianSystem(numVerts, bm->totedge, bm->totface, total_anchors, smd->anchor_grp_name, smd->repeat);
+ smd->cacheSystem = initLaplacianSystem(numVerts, bm->totedge, total_anchors, smd->anchor_grp_name, smd->repeat);
sys = (LaplacianSystem *)smd->cacheSystem;
sys->bm = bm;
for (i = 0; i < total_anchors; i++) {
@@ -590,8 +615,8 @@
sys->verts[vertID] = v;
}
BLI_array_free(index_anchors);
- smd->vertexco = (float *)MEM_callocN(sizeof(float)*(numVerts*3), "ModDeformCoordinates");
- memcpy(smd->vertexco, vertexCos, sizeof(float) * numVerts*3);
+ smd->vertexco = (float *) MEM_callocN(sizeof(float) * (numVerts * 3), "ModDeformCoordinates");
+ memcpy(smd->vertexco, vertexCos, sizeof(float) * numVerts * 3);
smd->total_verts = numVerts;
}
}
@@ -640,7 +665,7 @@
return false;
}
-static bool onlyChangueAnchors(LaplacianDeformModifierData *smd, Object *ob, DerivedMesh *dm, int numVerts)
+static bool onlyChangeAnchors(LaplacianDeformModifierData *smd, Object *ob, DerivedMesh *dm, int numVerts)
{
int i;
int defgrp_index;
@@ -684,7 +709,7 @@
return false;
}
-static bool onlyChangueGroup(LaplacianDeformModifierData *smd, Object *ob, DerivedMesh *dm, int numVerts)
+static bool onlyChangeGroup(LaplacianDeformModifierData *smd, Object *ob, DerivedMesh *dm, int numVerts)
{
LaplacianSystem *sys = (LaplacianSystem *)smd->cacheSystem;
if (sys->total_verts != numVerts) {
@@ -728,7 +753,7 @@
if (smd->cacheSystem) {
if (isSystemDifferent(smd, ob, dm,numVerts)) {
- if (onlyChangueAnchors(smd, ob, dm,numVerts) || onlyChangueGroup(smd, ob, dm,numVerts)) {
+ if (onlyChangeAnchors(smd, ob, dm,numVerts) || onlyChangeGroup(smd, ob, dm,numVerts)) {
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list