[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [60785] branches/soc-2013-sketch_mesh: The system can now iterates to improve the solution found.
Alexander Pinzon
apinzonf at gmail.com
Tue Oct 15 19:17:27 CEST 2013
Revision: 60785
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=60785
Author: apinzonf
Date: 2013-10-15 17:17:27 +0000 (Tue, 15 Oct 2013)
Log Message:
-----------
The system can now iterates to improve the solution found.
The system at each iteration estimated in a better way the rotation of the differential coordinates
Modified Paths:
--------------
branches/soc-2013-sketch_mesh/release/scripts/startup/bl_ui/properties_data_modifier.py
branches/soc-2013-sketch_mesh/source/blender/makesdna/DNA_modifier_types.h
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-15 17:11:15 UTC (rev 60784)
+++ branches/soc-2013-sketch_mesh/release/scripts/startup/bl_ui/properties_data_modifier.py 2013-10-15 17:17:27 UTC (rev 60785)
@@ -374,6 +374,7 @@
row.operator("object.hook_assign", text="Assign")
def LAPLACIANDEFORM(self, layout, ob, md):
+ layout.prop(md, "iterations")
layout.label(text="Anchors Vertex Group:")
layout.prop_search(md, "vertex_group", ob, "vertex_groups", text="")
Modified: branches/soc-2013-sketch_mesh/source/blender/makesdna/DNA_modifier_types.h
===================================================================
--- branches/soc-2013-sketch_mesh/source/blender/makesdna/DNA_modifier_types.h 2013-10-15 17:11:15 UTC (rev 60784)
+++ branches/soc-2013-sketch_mesh/source/blender/makesdna/DNA_modifier_types.h 2013-10-15 17:17:27 UTC (rev 60785)
@@ -1281,7 +1281,7 @@
typedef struct LaplacianDeformModifierData {
ModifierData modifier;
char defgrp_name[64]; /* MAX_VGROUP_NAME */
- int total_verts, pad1;
+ int total_verts, repeat;
float *vertexco;
void *cacheSystem;
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-15 17:11:15 UTC (rev 60784)
+++ branches/soc-2013-sketch_mesh/source/blender/makesrna/intern/rna_modifier.c 2013-10-15 17:17:27 UTC (rev 60785)
@@ -3672,7 +3672,14 @@
RNA_def_property_ui_text(prop, "Vertex Group for Anchors",
"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);
+ 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", "");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+ RNA_def_property_update(prop, 0, "rna_Modifier_update");
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-15 17:11:15 UTC (rev 60784)
+++ branches/soc-2013-sketch_mesh/source/blender/modifiers/intern/MOD_laplaciandeform.c 2013-10-15 17:17:27 UTC (rev 60785)
@@ -51,6 +51,7 @@
int total_verts;
int total_edges;
int total_anchors;
+ int repeat;
char defgrp_name[64]; /* Vertex Group name*/
float (*co)[3]; /* Original vertex coordinates*/
float (*no)[3]; /* Original vertex normal*/
@@ -75,6 +76,7 @@
sys->total_verts = 0;
sys->total_edges = 0;
sys->total_anchors = 0;
+ sys->repeat = 1;
sys->defgrp_name[0] = '\0';
sys->co = NULL;
sys->no = NULL;
@@ -87,7 +89,7 @@
return sys;
}
-static LaplacianSystem * initLaplacianSystem(int totalVerts, int totalEdges, int totalFaces, int totalAnchors, char defgrpName[64])
+static LaplacianSystem * initLaplacianSystem(int totalVerts, int totalEdges, int totalFaces, int totalAnchors, char defgrpName[64], int iterations)
{
LaplacianSystem *sys = newLaplacianSystem();
if (!sys) {
@@ -98,6 +100,7 @@
sys->total_verts = totalVerts;
sys->total_edges = totalEdges;
sys->total_anchors = totalAnchors;
+ sys->repeat = iterations;
BLI_strncpy(sys->defgrp_name, defgrpName, sizeof(sys->defgrp_name));
sys->co = (float (*)[3])MEM_callocN(sizeof(float)*(totalVerts*3), "DeformCoordinates");
sys->no = (float (*)[3])MEM_callocN(sizeof(float)*(totalVerts*3), "DeformNormals");
@@ -366,7 +369,7 @@
static void laplacianDeformPreview(LaplacianSystem * sys, float (*vertexCos)[3])
{
struct BMesh *bm;
- int vid, i, n, na;
+ int vid, i, j, n, na;
bm = sys->bm;
n = sys->total_verts;
na = sys->total_anchors;
@@ -420,21 +423,26 @@
if (nlSolveAdvanced(NULL, NL_TRUE) ) {
sys->has_solution = true;
- nlBegin(NL_SYSTEM);
- nlBegin(NL_MATRIX);
- rotateDifferentialCoordinates(sys);
+ for (j=1; j<= sys->repeat; j++) {
+ nlBegin(NL_SYSTEM);
+ nlBegin(NL_MATRIX);
+ rotateDifferentialCoordinates(sys);
- for (i=0; i<na; i++) {
- vid = sys->index_anchors[i];
- nlRightHandSideSet(0, n + i , sys->co[vid][0]);
- nlRightHandSideSet(1, n + i , sys->co[vid][1]);
- nlRightHandSideSet(2, n + i , sys->co[vid][2]);
+ for (i=0; i<na; i++) {
+ vid = sys->index_anchors[i];
+ nlRightHandSideSet(0, n + i , sys->co[vid][0]);
+ nlRightHandSideSet(1, n + i , sys->co[vid][1]);
+ nlRightHandSideSet(2, n + i , sys->co[vid][2]);
+ }
+
+ nlEnd(NL_MATRIX);
+ nlEnd(NL_SYSTEM);
+ if (!nlSolveAdvanced(NULL, NL_FALSE) ) {
+ sys->has_solution = false;
+ break;
+ }
}
-
- nlEnd(NL_MATRIX);
- nlEnd(NL_SYSTEM);
- if (nlSolveAdvanced(NULL, NL_FALSE) ) {
- sys->has_solution = true;
+ if (sys->has_solution) {
for (vid=0; vid<sys->total_verts; vid++) {
vertexCos[vid][0] = nlGetVariable(0, vid);
vertexCos[vid][1] = nlGetVariable(1, vid);
@@ -443,6 +451,7 @@
} else {
sys->has_solution = false;
}
+
} else {
sys->has_solution = false;
}
@@ -471,22 +480,26 @@
if (nlSolveAdvanced(NULL, NL_FALSE) ) {
sys->has_solution = true;
-
- nlBegin(NL_SYSTEM);
- nlBegin(NL_MATRIX);
- rotateDifferentialCoordinates(sys);
+ for (j=1; j<= sys->repeat; j++) {
+ nlBegin(NL_SYSTEM);
+ nlBegin(NL_MATRIX);
+ rotateDifferentialCoordinates(sys);
- for (i=0; i<na; i++)
- {
- vid = sys->index_anchors[i];
- nlRightHandSideSet(0, n + i , vertexCos[vid][0]);
- nlRightHandSideSet(1, n + i , vertexCos[vid][1]);
- nlRightHandSideSet(2, n + i , vertexCos[vid][2]);
+ for (i=0; i<na; i++)
+ {
+ vid = sys->index_anchors[i];
+ nlRightHandSideSet(0, n + i , vertexCos[vid][0]);
+ nlRightHandSideSet(1, n + i , vertexCos[vid][1]);
+ nlRightHandSideSet(2, n + i , vertexCos[vid][2]);
+ }
+ nlEnd(NL_MATRIX);
+ nlEnd(NL_SYSTEM);
+ if (!nlSolveAdvanced(NULL, NL_FALSE) ) {
+ sys->has_solution = false;
+ break;
+ }
}
- nlEnd(NL_MATRIX);
- nlEnd(NL_SYSTEM);
- if (nlSolveAdvanced(NULL, NL_FALSE) ) {
- sys->has_solution = true;
+ if (sys->has_solution) {
for (vid=0; vid<sys->total_verts; vid++) {
vertexCos[vid][0] = nlGetVariable(0, vid);
vertexCos[vid][1] = nlGetVariable(1, vid);
@@ -544,7 +557,7 @@
}
}
total_anchors = BLI_array_count(index_anchors);
- smd->cacheSystem = initLaplacianSystem(numVerts, bm->totedge, bm->totface, total_anchors, smd->defgrp_name);
+ smd->cacheSystem = initLaplacianSystem(numVerts, bm->totedge, bm->totface, total_anchors, smd->defgrp_name, smd->repeat);
sys = (LaplacianSystem *)smd->cacheSystem;
sys->bm = bm;
for (i=0; i<total_anchors; i++) {
@@ -672,6 +685,7 @@
laplacianDeformPreview((LaplacianSystem *)smd->cacheSystem, vertexCos);
}
} else {
+ ((LaplacianSystem *)smd->cacheSystem)->repeat = smd->repeat;
laplacianDeformPreview((LaplacianSystem *)smd->cacheSystem, vertexCos);
}
}else {
@@ -701,6 +715,7 @@
LaplacianDeformModifierData *smd = (LaplacianDeformModifierData *) md;
smd->defgrp_name[0] = '\0';
smd->total_verts = 0;
+ smd->repeat = 1;
smd->vertexco = NULL;
smd->cacheSystem = NULL;
}
@@ -710,6 +725,7 @@
LaplacianDeformModifierData *smd = (LaplacianDeformModifierData *) md;
LaplacianDeformModifierData *tsmd = (LaplacianDeformModifierData *) target;
tsmd->total_verts = smd->total_verts;
+ tsmd->repeat = smd->repeat;
BLI_strncpy(tsmd->defgrp_name, smd->defgrp_name, sizeof(tsmd->defgrp_name));
tsmd->vertexco = MEM_dupallocN(smd->vertexco);
tsmd->cacheSystem = MEM_dupallocN(smd->cacheSystem);
More information about the Bf-blender-cvs
mailing list