[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [60653] branches/soc-2013-sketch_mesh/ source/blender: Code was clean, some problems were fixed.
Alexander Pinzon
apinzonf at gmail.com
Thu Oct 10 04:04:28 CEST 2013
Revision: 60653
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=60653
Author: apinzonf
Date: 2013-10-10 02:04:27 +0000 (Thu, 10 Oct 2013)
Log Message:
-----------
Code was clean, some problems were fixed.
The system can store and retrieve the cache information from a file.
Modified Paths:
--------------
branches/soc-2013-sketch_mesh/source/blender/blenloader/intern/readfile.c
branches/soc-2013-sketch_mesh/source/blender/blenloader/intern/writefile.c
branches/soc-2013-sketch_mesh/source/blender/makesdna/DNA_modifier_types.h
branches/soc-2013-sketch_mesh/source/blender/modifiers/intern/MOD_laplaciandeform.c
Modified: branches/soc-2013-sketch_mesh/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/soc-2013-sketch_mesh/source/blender/blenloader/intern/readfile.c 2013-10-09 21:19:25 UTC (rev 60652)
+++ branches/soc-2013-sketch_mesh/source/blender/blenloader/intern/readfile.c 2013-10-10 02:04:27 UTC (rev 60653)
@@ -4820,6 +4820,15 @@
if (wmd->cmap_curve)
direct_link_curvemapping(fd, wmd->cmap_curve);
}
+ else if (md->type == eModifierType_LaplacianDeform) {
+ LaplacianDeformModifierData *wmd = (LaplacianDeformModifierData *)md;
+
+ wmd->vertexco = newdataadr(fd, wmd->vertexco);
+ if (fd->flags & FD_FLAGS_SWITCH_ENDIAN) {
+ BLI_endian_switch_float_array(wmd->vertexco, wmd->total_verts*3);
+ }
+ wmd->cacheSystem = NULL;
+ }
}
}
Modified: branches/soc-2013-sketch_mesh/source/blender/blenloader/intern/writefile.c
===================================================================
--- branches/soc-2013-sketch_mesh/source/blender/blenloader/intern/writefile.c 2013-10-09 21:19:25 UTC (rev 60652)
+++ branches/soc-2013-sketch_mesh/source/blender/blenloader/intern/writefile.c 2013-10-10 02:04:27 UTC (rev 60653)
@@ -1474,6 +1474,11 @@
if (wmd->cmap_curve)
write_curvemapping(wd, wmd->cmap_curve);
}
+ else if(md->type==eModifierType_LaplacianDeform) {
+ LaplacianDeformModifierData *ldmd = (LaplacianDeformModifierData*) md;
+
+ writedata(wd, DATA, sizeof(float)*ldmd->total_verts*3, ldmd->vertexco);
+ }
}
}
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-09 21:19:25 UTC (rev 60652)
+++ branches/soc-2013-sketch_mesh/source/blender/makesdna/DNA_modifier_types.h 2013-10-10 02:04:27 UTC (rev 60653)
@@ -1281,7 +1281,10 @@
typedef struct LaplacianDeformModifierData {
ModifierData modifier;
char defgrp_name[64]; /* MAX_VGROUP_NAME */
- void * custom_data;
+ int total_verts, pad1;
+ float *vertexco;
+ void *cacheSystem;
+
} LaplacianDeformModifierData;
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-09 21:19:25 UTC (rev 60652)
+++ branches/soc-2013-sketch_mesh/source/blender/modifiers/intern/MOD_laplaciandeform.c 2013-10-10 02:04:27 UTC (rev 60653)
@@ -42,291 +42,103 @@
#include "BKE_cdderivedmesh.h"
#include "BKE_particle.h"
#include "BKE_deform.h"
-
#include "BKE_DerivedMesh.h"
#include "BKE_context.h"
#include "BKE_editmesh.h"
#include "BKE_editmesh_bvh.h"
+
#include "MOD_modifiertypes.h"
#include "MOD_util.h"
#include "ONL_opennl.h"
-struct BAnchors {
- int numAnchors; /* Number of static anchors*/
- int numVerts; /* Number of verts*/
- int * list_index; /* Static vertex index list*/
+struct BLaplacianSystem {
+ bool is_matrix_computed;
+ int total_verts;
+ int total_edges;
+ int total_faces;
+ int total_anchors;
+ char defgrp_name[64]; /* Vertex Group name*/
float (*co)[3]; /* Original vertex coordinates*/
float (*no)[3]; /* Original vertex normal*/
- BMVert ** list_verts; /* Vertex order by index*/
- BMesh *bm;
-};
-typedef struct BAnchors Anchors;
-
-struct BLaplacianSystem {
float (*delta)[3]; /* Differential Coordinates*/
- int *list_uverts; /* Unit vectors of projected edges onto the plane orthogonal to n*/
- /* Pointers to data*/
- int numVerts;
- int numAnchors;
+ int *index_anchors; /* Static vertex index list*/
+ 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*/
};
typedef struct BLaplacianSystem LaplacianSystem;
-enum {
- LAP_STATE_INIT = 1,
- LAP_STATE_HAS_ANCHORS,
- LAP_STATE_HAS_L_COMPUTE,
- LAP_STATE_UPDATE_REQUIRED
-};
-
-struct BSystemCustomData {
+static LaplacianSystem * newLaplacianSystem()
+{
LaplacianSystem * sys;
- Anchors * achs;
- int stateSystem;
- bool update_required;
-};
-
-typedef struct BSystemCustomData SystemCustomData;
-
-static Anchors * init_anchors(int numv, int numa);
-static LaplacianSystem * init_laplacian_system(int numv, int numa);
-static float cotan_weight(float *v1, float *v2, float *v3);
-static void compute_implict_rotations(SystemCustomData * data);
-static void delete_void_pointer(void *data);
-static void delete_anchors(Anchors * sa);
-static void delete_laplacian_system(LaplacianSystem *sys);
-static void init_laplacian_matrix( SystemCustomData * data);
-static void rotate_differential_coordinates(SystemCustomData * data);
-static void update_system_state(SystemCustomData * data, int state);
-static void laplacian_deform_preview(SystemCustomData * data, DerivedMesh *dm, float (*vertexCos)[3]);
-static void freeData(ModifierData *md);
-
-static void delete_void_pointer(void *data)
-{
- if (data) {
- MEM_freeN(data);
+ sys = MEM_callocN(sizeof(LaplacianSystem), "DeformCache");
+ if (!sys) {
+ return NULL;
}
+ sys->is_matrix_computed = false;
+ sys->total_verts = 0;
+ sys->total_edges = 0;
+ sys->total_faces = 0;
+ sys->total_anchors = 0;
+ sys->defgrp_name[0] = '\0';
+ sys->co = NULL;
+ sys->no = NULL;
+ sys->delta = NULL;
+ sys->index_anchors = NULL;
+ sys->unit_verts = NULL;
+ sys->verts = NULL;
+ sys->bm = NULL;
+ sys->context = NULL;
+ return sys;
}
-static Anchors * init_anchors(int numv, int numa)
+static LaplacianSystem * initLaplacianSystem(int totalVerts, int totalEdges, int totalFaces, int totalAnchors, char defgrpName[64])
{
- Anchors * sa;
- sa = (Anchors *)MEM_callocN(sizeof(Anchors), "LapAnchors");
- sa->numVerts = numv;
- sa->numAnchors = numa;
- sa->list_index = (int *)MEM_callocN(sizeof(int)*(sa->numAnchors), "LapListAnchors");
- sa->list_verts = (BMVert**)MEM_callocN(sizeof(BMVert*)*(sa->numVerts), "LapListverts");
- sa->co = (float (*)[3])MEM_callocN(sizeof(float)*(sa->numVerts*3), "LapCoordinates");
- sa->no = (float (*)[3])MEM_callocN(sizeof(float)*(sa->numVerts*3), "LapNormals");
- memset(sa->no, 0.0, sizeof(float) * sa->numVerts * 3);
- return sa;
-}
-
-static LaplacianSystem * init_laplacian_system(int numv, int numa)
-{
- LaplacianSystem *sys;
- int rows, cols;
- sys = (LaplacianSystem *)MEM_callocN(sizeof(LaplacianSystem), "LapSystem");
+ LaplacianSystem *sys = newLaplacianSystem();
if (!sys) {
return NULL;
}
- sys->numVerts = numv;
- sys->numAnchors = numa;
- rows = (sys->numVerts + sys->numAnchors) * 3;
- cols = sys->numVerts * 3;
- sys->list_uverts = (int *)MEM_callocN(sizeof(BMVert *) * sys->numVerts, "LapUverts");
- sys->delta = (float (*)[3])MEM_callocN(sizeof(float) * sys->numVerts * 3, "LapDelta");
- memset(sys->delta, 0.0, sizeof(float) * sys->numVerts * 3);
+ sys->is_matrix_computed = false;
+ sys->total_verts = totalVerts;
+ sys->total_edges = totalEdges;
+ sys->total_faces = totalFaces;
+ sys->total_anchors = totalAnchors;
+ 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");
+ 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;
}
-static void delete_anchors(Anchors * sa)
+static void deleteVoidPointer(void *data)
{
- if (!sa) return;
- delete_void_pointer(sa->co);
- delete_void_pointer(sa->list_index);
- delete_void_pointer(sa->no);
- delete_void_pointer(sa->list_verts);
- if (sa->bm) BM_mesh_free(sa->bm);
- delete_void_pointer(sa);
- sa = NULL;
+ if (data) {
+ MEM_freeN(data);
+ data = NULL;
+ }
}
-static void delete_laplacian_system(LaplacianSystem *sys)
+static void deleteLaplacianSystem(LaplacianSystem * sys)
{
if (!sys) return;
- delete_void_pointer(sys->delta);
- delete_void_pointer(sys->list_uverts);
+ deleteVoidPointer(sys->co);
+ deleteVoidPointer(sys->no);
+ deleteVoidPointer(sys->delta);
+ deleteVoidPointer(sys->index_anchors);
+ deleteVoidPointer(sys->unit_verts);
+ deleteVoidPointer(sys->verts);
+ if (sys->bm) BM_mesh_free(sys->bm);
if (sys->context) nlDeleteContext(sys->context);
- delete_void_pointer(sys);
- sys = NULL;
+ deleteVoidPointer(sys);
}
-
-static void update_system_state(SystemCustomData * data, int state)
-{
- if (!data) return;
- switch(data->stateSystem) {
- case LAP_STATE_INIT:
- if (state == LAP_STATE_HAS_ANCHORS) {
- data->stateSystem = state;
- }
- break;
- case LAP_STATE_HAS_ANCHORS:
- if (state == LAP_STATE_HAS_L_COMPUTE) {
- data->stateSystem = LAP_STATE_HAS_L_COMPUTE;
- }
- break;
- case LAP_STATE_HAS_L_COMPUTE:
- if (state == LAP_STATE_HAS_ANCHORS) {
- data->stateSystem = LAP_STATE_HAS_ANCHORS;
- }
- break;
- }
-
-}
-
-static void initData(ModifierData *md)
-{
- LaplacianDeformModifierData *smd = (LaplacianDeformModifierData *) md;
- SystemCustomData * sys;
- sys = smd->custom_data = MEM_callocN(sizeof(SystemCustomData), "LapSystemCustomData");
- if (!sys) {
- return;
- }
- sys->achs = NULL;
- sys->stateSystem = LAP_STATE_INIT;
-}
-
-static void copyData(ModifierData *md, ModifierData *target)
-{
- LaplacianDeformModifierData *smd = (LaplacianDeformModifierData *) md;
- LaplacianDeformModifierData *tsmd = (LaplacianDeformModifierData *) target;
- //tsmd->scale = smd->scale;
- tsmd->custom_data = smd->custom_data;
-}
-
-static bool isDisabled(ModifierData *md, int UNUSED(useRenderParams))
-{
- LaplacianDeformModifierData *smd = (LaplacianDeformModifierData *) md;
- /* disable if modifier is 1.0 for scale*/
- //if (smd->scale == 1.0f) return 1;
- return 0;
-}
-
-static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
-{
- LaplacianDeformModifierData *smd = (LaplacianDeformModifierData *)md;
- CustomDataMask dataMask = 0;
- return dataMask;
-}
-
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list