[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [35806] branches/bmesh/blender/source/ blender: =bmesh=
Joseph Eagar
joeedh at gmail.com
Sun Mar 27 04:56:41 CEST 2011
Revision: 35806
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=35806
Author: joeedh
Date: 2011-03-27 02:56:41 +0000 (Sun, 27 Mar 2011)
Log Message:
-----------
=bmesh=
Multires interpolation. It's quite usable yet; I wanted to avoid
subsurfing the multires data and ray tracing original/new
topology. The result is kindof like trunk's interpolation.
I'll see how much better I can get it. I might have to go with
the full-on ray tracing solution. Right now, it's not very good.
Also made it so trunk files with multires open correctly.
Modified Paths:
--------------
branches/bmesh/blender/source/blender/blenkernel/intern/customdata.c
branches/bmesh/blender/source/blender/blenkernel/intern/multires.c
branches/bmesh/blender/source/blender/blenkernel/intern/subsurf_ccg.c
branches/bmesh/blender/source/blender/blenlib/BLI_cellalloc.h
branches/bmesh/blender/source/blender/blenlib/intern/math_geom.c
branches/bmesh/blender/source/blender/blenloader/intern/readfile.c
branches/bmesh/blender/source/blender/bmesh/bmesh.h
branches/bmesh/blender/source/blender/bmesh/bmesh_class.h
branches/bmesh/blender/source/blender/bmesh/intern/bmesh_construct.c
branches/bmesh/blender/source/blender/bmesh/intern/bmesh_interp.c
branches/bmesh/blender/source/blender/bmesh/intern/bmesh_mods.c
branches/bmesh/blender/source/blender/bmesh/intern/bmesh_newcore.c
branches/bmesh/blender/source/blender/bmesh/operators/bevel.c
branches/bmesh/blender/source/blender/bmesh/operators/dissolveops.c
branches/bmesh/blender/source/blender/editors/mesh/bmesh_select.c
branches/bmesh/blender/source/blender/editors/mesh/mesh_intern.h
branches/bmesh/blender/source/blender/editors/mesh/mesh_ops.c
branches/bmesh/blender/source/blender/editors/object/object_intern.h
branches/bmesh/blender/source/blender/editors/object/object_modifier.c
branches/bmesh/blender/source/blender/editors/object/object_ops.c
Modified: branches/bmesh/blender/source/blender/blenkernel/intern/customdata.c
===================================================================
--- branches/bmesh/blender/source/blender/blenkernel/intern/customdata.c 2011-03-26 23:55:54 UTC (rev 35805)
+++ branches/bmesh/blender/source/blender/blenkernel/intern/customdata.c 2011-03-27 02:56:41 UTC (rev 35806)
@@ -462,9 +462,13 @@
float (*disps)[3], (*out)[3];
/* happens when flipping normals of newly created mesh */
- if(!d->totdisp)
- return;
-
+ if(!d->totdisp) {
+ d->totdisp = ((MDisps*)sources[0])->totdisp;
+ }
+
+ if (!d->disps && d->totdisp)
+ d->disps = BLI_cellalloc_calloc(sizeof(float)*3*d->totdisp, "blank mdisps in layerInterp_mdisps");
+#if 0
s = sources[0];
dst_corners = multires_mdisp_corners(d);
src_corners = multires_mdisp_corners(s);
@@ -561,6 +565,7 @@
BLI_cellalloc_free(d->disps);
d->disps = disps;
+#endif
}
static void layerCopy_mdisps(const void *source, void *dest, int count)
@@ -1457,7 +1462,7 @@
return NULL;
}
- if (alloctype == CD_DUPLICATE) {
+ if (alloctype == CD_DUPLICATE && layerdata) {
if(typeInfo->copy)
typeInfo->copy(layerdata, newlayerdata, totelem);
else
@@ -2229,6 +2234,8 @@
}
else if(fdata->layers[i].type == CD_MCOL)
CustomData_add_layer(ldata, CD_MLOOPCOL, CD_CALLOC, &(fdata->layers[i].name), totloop);
+ else if(fdata->layers[i].type == CD_MDISPS)
+ CustomData_add_layer(ldata, CD_MDISPS, CD_CALLOC, &(fdata->layers[i].name), totloop);
}
}
void CustomData_from_bmeshpoly(CustomData *fdata, CustomData *pdata, CustomData *ldata, int total){
Modified: branches/bmesh/blender/source/blender/blenkernel/intern/multires.c
===================================================================
--- branches/bmesh/blender/source/blender/blenkernel/intern/multires.c 2011-03-26 23:55:54 UTC (rev 35805)
+++ branches/bmesh/blender/source/blender/blenkernel/intern/multires.c 2011-03-27 02:56:41 UTC (rev 35806)
@@ -680,7 +680,7 @@
multires_subdivide(mmd, ob, mmd->totlvl+1, updateblock, simple);
}
-static void grid_tangent(int gridSize, int index, int x, int y, int axis, DMGridData **gridData, float t[3])
+void grid_tangent(int gridSize, int index, int x, int y, int axis, DMGridData **gridData, float t[3])
{
if(axis == 0) {
if(x == gridSize - 1) {
Modified: branches/bmesh/blender/source/blender/blenkernel/intern/subsurf_ccg.c
===================================================================
--- branches/bmesh/blender/source/blender/blenkernel/intern/subsurf_ccg.c 2011-03-26 23:55:54 UTC (rev 35805)
+++ branches/bmesh/blender/source/blender/blenkernel/intern/subsurf_ccg.c 2011-03-27 02:56:41 UTC (rev 35806)
@@ -497,6 +497,8 @@
if (wtable->weight_table[i].valid)
MEM_freeN(wtable->weight_table[i].w);
}
+
+ MEM_freeN(wtable->weight_table);
}
static DerivedMesh *ss_to_cdderivedmesh(CCGSubSurf *ss, int ssFromEditmesh,
Modified: branches/bmesh/blender/source/blender/blenlib/BLI_cellalloc.h
===================================================================
--- branches/bmesh/blender/source/blender/blenlib/BLI_cellalloc.h 2011-03-26 23:55:54 UTC (rev 35805)
+++ branches/bmesh/blender/source/blender/blenlib/BLI_cellalloc.h 2011-03-27 02:56:41 UTC (rev 35806)
@@ -27,21 +27,15 @@
*/
/*
- I wrote this as a hack so vgroups won't be quite so slow. I really
- should replace it with something else, but I need to spend some time
- thinking as to what the proper solution would be (other then totally
- rewriting vgroups, of course).
-
- this is just a simple allocator that spawns mempools for unique size
- requests. hardly ideal, I know. *something* like this may be
- unavoidable, but it should certainly be possible to make it
- non-global and internal to the vgroup code.
-
- -joeedh sep. 17 2009
+ this evil bit of code is necassary for vgroups and multires to run fast
+ enough. it is surprisingly tricky allocate MDeformWeights and MDisps in
+ a way that doesn't cause severe performance problems. once a better solution
+ is found we can get rid of this code, but until then this is necassary
+ (though, disabling it if jedmalloc is in use might be feasible).
+
+ - joeedh
*/
-//BMESH_TODO: kill this library before merging with trunk. it's evil! -joeedh
-
void *BLI_cellalloc_malloc(long size, const char *tag);
void *BLI_cellalloc_calloc(long size, const char *tag);
void BLI_cellalloc_free(void *mem);
Modified: branches/bmesh/blender/source/blender/blenlib/intern/math_geom.c
===================================================================
--- branches/bmesh/blender/source/blender/blenlib/intern/math_geom.c 2011-03-26 23:55:54 UTC (rev 35805)
+++ branches/bmesh/blender/source/blender/blenlib/intern/math_geom.c 2011-03-27 02:56:41 UTC (rev 35806)
@@ -272,7 +272,7 @@
}
/* get intersection point of two 2D segments and return intersection type:
- -1: colliniar
+ -1: colliniar or out-of-segment intersection
1: intersection */
int isect_seg_seg_v2_point(const float *v1, const float *v2, const float *v3, const float *v4, float vi[2])
{
Modified: branches/bmesh/blender/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/bmesh/blender/source/blender/blenloader/intern/readfile.c 2011-03-26 23:55:54 UTC (rev 35805)
+++ branches/bmesh/blender/source/blender/blenloader/intern/readfile.c 2011-03-27 02:56:41 UTC (rev 35806)
@@ -3547,6 +3547,27 @@
mloopcol->r = mcol[3].r; mloopcol->g = mcol[3].g; mloopcol->b = mcol[3].b; mloopcol->a = mcol[3].a; mloopcol++;
}
}
+
+ if (CustomData_has_layer(&me->fdata, CD_MDISPS)) {
+ MDisps *ld = CustomData_get(&me->ldata, loopstart, CD_MDISPS);
+ MDisps *fd = CustomData_get(&me->fdata, findex, CD_MDISPS);
+ float (*disps)[3] = fd->disps;
+ int i, tot = mf->v4 ? 4 : 3;
+ int side, corners;
+
+ corners = multires_mdisp_corners(fd);
+ side = sqrt(fd->totdisp / corners);
+
+ for (i=0; i<tot; i++, disps += side*side, ld++) {
+ ld->totdisp = side*side;
+
+ if (ld->disps)
+ BLI_cellalloc_free(ld->disps);
+
+ ld->disps = BLI_cellalloc_malloc(sizeof(float)*3*side*side, "converted loop mdisps");
+ memcpy(ld->disps, disps, sizeof(float)*3*side*side);
+ }
+ }
}
static void convert_mfaces_to_mpolys(Mesh *mesh)
Modified: branches/bmesh/blender/source/blender/bmesh/bmesh.h
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/bmesh.h 2011-03-26 23:55:54 UTC (rev 35805)
+++ branches/bmesh/blender/source/blender/bmesh/bmesh.h 2011-03-27 02:56:41 UTC (rev 35806)
@@ -218,13 +218,18 @@
/*Interpolation*/
/*projects target onto source for customdata interpolation. note: only
- does loop customdata.*/
+ does loop customdata. note that multires is handled.*/
void BM_face_interp_from_face(BMesh *bm, BMFace *target, BMFace *source);
/*same as BM_face_interp_from_face, but only interpolates one loop, instead
of all loops in a face*/
void BM_loop_interp_from_face(BMesh *bm, BMLoop *target, BMFace *source);
+/*smoothes boundaries between multires grids, including some borders in adjacent faces*/
+void BM_multires_smooth_bounds(BMesh *bm, BMFace *f);
+/*project the multires grid in target onto source's set of multires grids*/
+void BM_loop_interp_multires(BMesh *bm, BMLoop *target, BMFace *source);
+
void BM_Data_Interp_From_Verts ( struct BMesh *bm, struct BMVert *v1, struct BMVert *v2, struct BMVert *v, float fac );
void BM_Data_Facevert_Edgeinterp ( struct BMesh *bm, struct BMVert *v1, struct BMVert *v2, struct BMVert *v, struct BMEdge *e1, float fac );
void BM_add_data_layer ( BMesh *em, CustomData *data, int type );
@@ -271,6 +276,14 @@
void BM_Kill_Edge(BMesh *bm, BMEdge *e);
void BM_Kill_Vert(BMesh *bm, BMVert *v);
+/*kills all edges associated with f, along with any other faces containing
+ those edges*/
+void BM_Kill_Face_Edges(BMesh *bm, BMFace *f);
+
+/*kills all verts associated with f, along with any other faces containing
+ those vertices*/
+void BM_Kill_Face_Verts(BMesh *bm, BMFace *f) ;
+
#define bm_firstfaceloop(p) ((BMLoopList*)(p->loops.first))->first
/*include the rest of the API*/
Modified: branches/bmesh/blender/source/blender/bmesh/bmesh_class.h
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/bmesh_class.h 2011-03-26 23:55:54 UTC (rev 35805)
+++ branches/bmesh/blender/source/blender/bmesh/bmesh_class.h 2011-03-27 02:56:41 UTC (rev 35806)
@@ -255,10 +255,7 @@
ListBase errorstack;
} BMesh;
-void BM_Copy_Vert(BMesh *bm, BMVert *destv, BMVert *source);
-void BM_Copy_Edge(BMesh *bm, BMEdge *deste, BMEdge *source);
-void BM_Copy_Loop(BMesh *bm, BMLoop *destl, BMLoop *source);
-void BM_Copy_Face(BMesh *bm, BMFace *destf, BMFace *source);
+BMFace *BM_Copy_Face(BMesh *bm, BMFace *f, int copyedges, int copyverts);
#define LAYER_BASE 1
#define LAYER_TOOL 2
Modified: branches/bmesh/blender/source/blender/bmesh/intern/bmesh_construct.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/intern/bmesh_construct.c 2011-03-26 23:55:54 UTC (rev 35805)
+++ branches/bmesh/blender/source/blender/bmesh/intern/bmesh_construct.c 2011-03-27 02:56:41 UTC (rev 35806)
@@ -413,6 +413,7 @@
static void bm_copy_vert_attributes(BMesh *source_mesh, BMesh *target_mesh, BMVert *source_vertex, BMVert *target_vertex)
{
+ copy_v3_v3(target_vertex->no, source_vertex->no);
CustomData_bmesh_copy_data(&source_mesh->vdata, &target_mesh->vdata, source_vertex->head.data, &target_vertex->head.data);
}
@@ -428,6 +429,7 @@
static void bm_copy_face_attributes(BMesh *source_mesh, BMesh *target_mesh, BMFace *source_face, BMFace *target_face)
{
+ copy_v3_v3(target_face->no, source_face->no);
CustomData_bmesh_copy_data(&source_mesh->pdata, &target_mesh->pdata, source_face->head.data, &target_face->head.data);
target_face->mat_nr = source_face->mat_nr;
}
Modified: branches/bmesh/blender/source/blender/bmesh/intern/bmesh_interp.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/intern/bmesh_interp.c 2011-03-26 23:55:54 UTC (rev 35805)
+++ branches/bmesh/blender/source/blender/bmesh/intern/bmesh_interp.c 2011-03-27 02:56:41 UTC (rev 35806)
@@ -37,9 +37,11 @@
#include "BKE_customdata.h"
#include "BKE_utildefines.h"
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list