[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [11748] branches/soc-2007-red_fox/source/ blender: Final GSoC submission
Levi Schooley
redfox at hhofministries.org
Mon Aug 20 21:05:31 CEST 2007
Revision: 11748
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=11748
Author: red_fox
Date: 2007-08-20 21:05:31 +0200 (Mon, 20 Aug 2007)
Log Message:
-----------
Final GSoC submission
Most of this is little code changes and bug fixes. I'm not sure, I didn't think I changed any math, but spikes seem to be back. I will need to fix those soon. Changes included suggestions from Geoffrey Bantle (Briggs), my mentor, and Martin Poirier (theeth).
Levi
Modified Paths:
--------------
branches/soc-2007-red_fox/source/blender/blenkernel/BKE_bmesh.h
branches/soc-2007-red_fox/source/blender/blenkernel/intern/BME_conversions.c
branches/soc-2007-red_fox/source/blender/blenkernel/intern/BME_tools.c
branches/soc-2007-red_fox/source/blender/blenkernel/intern/modifier.c
branches/soc-2007-red_fox/source/blender/include/BIF_transform.h
branches/soc-2007-red_fox/source/blender/include/transform.h
branches/soc-2007-red_fox/source/blender/src/buttons_editing.c
branches/soc-2007-red_fox/source/blender/src/editmesh_tools.c
branches/soc-2007-red_fox/source/blender/src/transform.c
branches/soc-2007-red_fox/source/blender/src/transform_conversions.c
branches/soc-2007-red_fox/source/blender/src/transform_generics.c
Modified: branches/soc-2007-red_fox/source/blender/blenkernel/BKE_bmesh.h
===================================================================
--- branches/soc-2007-red_fox/source/blender/blenkernel/BKE_bmesh.h 2007-08-20 17:53:55 UTC (rev 11747)
+++ branches/soc-2007-red_fox/source/blender/blenkernel/BKE_bmesh.h 2007-08-20 19:05:31 UTC (rev 11748)
@@ -201,6 +201,7 @@
#define BME_BEVEL_EMIN (1<<7)
#define BME_BEVEL_EMAX (1<<8)
#define BME_BEVEL_RUNNING (1<<9)
+#define BME_BEVEL_RES (1<<10)
typedef struct BME_TransData {
BME_Mesh *bm; /* the bmesh the vert belongs to */
@@ -212,7 +213,6 @@
float factor; /* primary scaling factor; also accumulates number of weighted edges for beveling tool */
float weight; /* another scaling factor; used primarily for propogating vertex weights to transforms; */
/* weight is also used across recursive bevels to help with the math */
- float maxfactor; /* used during recursive beveling to ensure factor does not overshoot */
float max; /* the maximum distance this vert can be transformed; negative is infinite */
} BME_TransData;
Modified: branches/soc-2007-red_fox/source/blender/blenkernel/intern/BME_conversions.c
===================================================================
--- branches/soc-2007-red_fox/source/blender/blenkernel/intern/BME_conversions.c 2007-08-20 17:53:55 UTC (rev 11747)
+++ branches/soc-2007-red_fox/source/blender/blenkernel/intern/BME_conversions.c 2007-08-20 19:05:31 UTC (rev 11748)
@@ -244,7 +244,7 @@
MFace *mface, *mf;
int totface,totedge,totvert,i,len;
- BME_Vert *v1=NULL,*v2=NULL;
+ BME_Vert *v1=NULL,*v2=NULL, **vert_array;
BME_Edge *e=NULL;
BME_Poly *f=NULL;
@@ -257,6 +257,8 @@
medge = dm->getEdgeArray(dm);
mface = dm->getFaceArray(dm);
+ vert_array = MEM_mallocN(sizeof(*vert_array)*totvert,"BME_derivedmesh_to_bmesh BME_Vert* array");
+
/*custom data*/
/* NOTE: I haven't tested whether or not custom data is being copied correctly */
CustomData_copy(&dm->vertData, &bm->vdata, CD_MASK_DERIVEDMESH,
@@ -268,13 +270,14 @@
/*add verts*/
for(i=0,mv = mvert; i < totvert;i++,mv++){
v1 = BME_MV(bm,mv->co);
+ vert_array[i] = v1;
v1->flag = mv->flag;
CustomData_to_em_block(&dm->vertData, &bm->vdata, i, &v1->data);
}
/*add edges*/
for(i=0,me = medge; i < totedge;i++,me++){
- v1 = BLI_findlink(&(bm->verts),me->v1);
- v2 = BLI_findlink(&(bm->verts),me->v2);
+ v1 = vert_array[me->v1];
+ v2 = vert_array[me->v2];
e = BME_ME(bm, v1, v2);
e->crease = me->crease;
e->flag = (unsigned char)me->flag;
@@ -297,8 +300,8 @@
edar[2] = BLI_edgehash_lookup(edge_hash,mf->v3,mf->v1);
/*find v1 and v2*/
- v1 = BLI_findlink(&(bm->verts),mf->v1);
- v2 = BLI_findlink(&(bm->verts),mf->v2);
+ v1 = vert_array[mf->v1];
+ v2 = vert_array[mf->v2];
f = BME_MF(bm,v1,v2,edar,len);
f->mat_nr = mf->mat_nr;
@@ -307,6 +310,7 @@
}
BLI_edgehash_free(edge_hash, NULL);
+ MEM_freeN(vert_array);
return bm;
}
Modified: branches/soc-2007-red_fox/source/blender/blenkernel/intern/BME_tools.c
===================================================================
--- branches/soc-2007-red_fox/source/blender/blenkernel/intern/BME_tools.c 2007-08-20 17:53:55 UTC (rev 11747)
+++ branches/soc-2007-red_fox/source/blender/blenkernel/intern/BME_tools.c 2007-08-20 19:05:31 UTC (rev 11748)
@@ -193,7 +193,7 @@
BME_TransData *BME_assign_transdata(BME_TransData_Head *td, BME_Mesh *bm, BME_Vert *v,
float *co, float *org, float *vec, float *loc,
- float factor, float weight, float maxfactor, float max) {
+ float factor, float weight, float max) {
BME_TransData *vtd;
int is_new = 0;
@@ -223,7 +223,6 @@
vtd->factor = factor;
vtd->weight = weight;
- vtd->maxfactor = maxfactor;
vtd->max = max;
return vtd;
@@ -403,7 +402,7 @@
factor = 0.0f;
}
else {
- factor = c1/c2;
+ factor = c2/c1;
}
return factor;
@@ -416,7 +415,7 @@
BME_Vert *BME_bevel_split_edge(BME_Mesh *bm, BME_Vert *v, BME_Vert *v1, BME_Loop *l, float *up_vec, float value, BME_TransData_Head *td) {
BME_TransData *vtd, *vtd1, *vtd2;
BME_Vert *sv, *v2, *v3;
- BME_Loop *lv1;
+ BME_Loop *lv1, *lv2;
BME_Edge *ne, *e1, *e2;
float factor, scale, len, dis, vec1[3], vec2[3], t_up_vec[3];
int is_edge, forward, is_split_vert;
@@ -450,7 +449,7 @@
e1 = e2;
}
sv = BME_split_edge(bm,v,e1,&ne,0);
- BME_assign_transdata(td, bm, sv, sv->co, sv->co, NULL, sv->co, 0, 0, -1, -1); /* quick default */
+ BME_assign_transdata(td, bm, sv, sv->co, sv->co, NULL, sv->co, 0, -1, -1); /* quick default */
sv->tflag1 |= BME_BEVEL_BEVEL;
ne->tflag1 = BME_BEVEL_ORIG; /* mark edge as original, even though it isn't */
BME_bevel_get_vec(vec1,v1,v,td);
@@ -464,12 +463,14 @@
if (l->v == v) {
forward = 1;
lv1 = l->next;
+ lv2 = l->prev;
v1 = l->next->v;
v2 = l->prev->v;
}
else if (l->next->v == v) {
forward = 0;
lv1 = l;
+ lv2 = l->next->next;
v1 = l->v;
v2 = l->next->next->v;
}
@@ -487,10 +488,15 @@
else {
is_split_vert = 0;
sv = BME_split_edge(bm,v,l->e,&ne,0);
- BME_assign_transdata(td, bm, sv, sv->co, sv->co, NULL, sv->co, 0, 0, -1, -1); /* quick default */
+ BME_assign_transdata(td, bm, sv, sv->co, sv->co, NULL, sv->co, 0, -1, -1); /* quick default */
sv->tflag1 |= BME_BEVEL_BEVEL;
ne->tflag1 = BME_BEVEL_ORIG; /* mark edge as original, even though it isn't */
}
+
+ if (BME_bevel_is_split_vert(lv2)) {
+ if (forward) v2 = lv2->prev->v;
+ else v2 = lv2->next->v;
+ }
}
is_edge = BME_bevel_get_vec(vec1,v,v1,td); /* get the vector we will be projecting onto */
@@ -504,6 +510,9 @@
if (vtd1->loc == NULL) {
/* this is a vert with data only for calculating initial weights */
+ if (vtd1->weight < 0) {
+ vtd1->weight = 0;
+ }
scale = vtd1->weight/vtd1->factor;
}
else {
@@ -513,13 +522,15 @@
}
if (is_edge && vtd1->loc != NULL) {
- factor = vtd1->maxfactor;
+ factor = vtd1->factor;
}
else {
- factor = BME_bevel_project_vec(vec1,vec2,up_vec,forward,td);
+ factor = scale*BME_bevel_project_vec(vec1,vec2,up_vec,forward,td);
}
- factor *= scale;
+ if (vtd->factor > 0 && vtd->factor < factor) {
+ factor = vtd->factor;
+ }
dis = (v1->tflag1 & BME_BEVEL_ORIG)? len/3 : len/2;
if (is_edge || dis > factor*value) {
@@ -529,7 +540,7 @@
VECSUB(vec1,sv->co,vtd1->org);
dis = VecLength(vec1);
Normalize(vec1);
- BME_assign_transdata(td, bm, sv, vtd1->org, vtd1->org, vec1, sv->co, dis, scale, factor, vtd1->max);
+ BME_assign_transdata(td, bm, sv, vtd1->org, vtd1->org, vec1, sv->co, dis, scale, vtd1->max);
return sv;
}
@@ -636,9 +647,11 @@
}
}
- BME_split_face(bm,f,v2,v1,&l,e);
- l->e->tflag1 = BME_BEVEL_BEVEL;
- l = l->radial.next->data;
+ if ((v1->tflag1 & BME_BEVEL_NONMAN)==0 || (v2->tflag1 & BME_BEVEL_NONMAN)==0) {
+ BME_split_face(bm,f,v2,v1,&l,e);
+ l->e->tflag1 = BME_BEVEL_BEVEL;
+ l = l->radial.next->data;
+ }
if (l->f != f) printf("Whoops! You got something out of order in BME_bevel_edge()!\n");
@@ -710,7 +723,7 @@
l = BME_bevel_vert(bm, l, value, options, up_vec, td);
}
}
-
+
/* max pass */
if (value > 0.5 && max > 0) {
max = -1;
@@ -764,7 +777,7 @@
if (vtd = BME_get_transdata(td, v)) {
if (options & BME_BEVEL_EMIN) {
vtd->factor = 1.0;
- if (weight < vtd->weight) {
+ if (vtd->weight < 0 || weight < vtd->weight) {
vtd->weight = weight;
}
}
@@ -774,14 +787,18 @@
vtd->weight = weight;
}
}
+ else if (vtd->weight < 0) {
+ vtd->factor = factor;
+ vtd->weight = weight;
+ }
else {
+ vtd->factor += factor; /* increment number of edges with weights (will be averaged) */
vtd->weight += weight; /* accumulate all the weights */
- vtd->factor += factor; /* increment number of edges with weights (will be averaged) */
}
}
else {
/* we'll use vtd->loc == NULL to mark that this vert is not moving */
- vtd = BME_assign_transdata(td, bm, v, v->co, NULL, NULL, NULL, factor, weight, -1, -1);
+ vtd = BME_assign_transdata(td, bm, v, v->co, NULL, NULL, NULL, factor, weight, -1);
}
}
@@ -832,7 +849,7 @@
else {
len = BME_cycle_length(BME_disk_getpointer(v->edge,v));
/* we'll assign a default transform data to every vert (except the loose ones) */
- vtd = BME_assign_transdata(td, bm, v, v->co, v->co, NULL, NULL, 0, 0, -1, -1);
+ vtd = BME_assign_transdata(td, bm, v, v->co, v->co, NULL, NULL, 0, -1, -1);
}
/* check for non-manifold vert */
@@ -859,11 +876,11 @@
}
}
if (!dw || dw->weight == 0.0) continue;
- vtd = BME_assign_transdata(td, bm, v, v->co, v->co, NULL, NULL, 1.0, dw->weight, -1, -1);
+ vtd = BME_assign_transdata(td, bm, v, v->co, v->co, NULL, NULL, 1.0, dw->weight, -1);
v->tflag1 |= BME_BEVEL_BEVEL;
}
else {
- vtd = BME_assign_transdata(td, bm, v, v->co, v->co, NULL, NULL, 1.0, 1.0, -1, -1);
+ vtd = BME_assign_transdata(td, bm, v, v->co, v->co, NULL, NULL, 1.0, 1.0, -1);
v->tflag1 |= BME_BEVEL_BEVEL;
}
}
@@ -999,7 +1016,8 @@
}
/* here we will loop through all the verts to clean up the left over geometry */
- for (v = bm->verts.first; v; /* we may kill v, so increment in-loop */) {
+ /* crazy idea. when res == 0, don't remove the original geometry */
+ for (v = bm->verts.first; v && res; /* we may kill v, so increment in-loop */) {
nv = v->next;
if ((v->tflag1 & BME_BEVEL_NONMAN) && (v->tflag1 & BME_BEVEL_BEVEL) && (v->tflag1 & BME_BEVEL_ORIG)) {
v = BME_bevel_wire(bm, v, value, res, options, td);
@@ -1122,11 +1140,13 @@
BME_bevel_initialize(bm, options, defgrp_index, td);
+ /* recursion math curtesy of Martin Poirier (theeth) */
for (i=0; i<res-1; i++) {
if (i==0) fac += 1.0f/3.0f; else fac += 1.0f/(3 * i * 2.0f);
}
d = 1.0f/fac;
- for (i=0; i<res; i++) {
+ /* crazy idea. if res == 0, don't remove original geometry */
+ for (i=0; i<res || (res==0 && i==0); i++) {
if (i != 0) BME_bevel_reinitialize(bm);
BME_bevel_mesh(bm,d,res,options,defgrp_index,td);
if (i==0) d /= 3; else d /= 2;
Modified: branches/soc-2007-red_fox/source/blender/blenkernel/intern/modifier.c
===================================================================
--- branches/soc-2007-red_fox/source/blender/blenkernel/intern/modifier.c 2007-08-20 17:53:55 UTC (rev 11747)
+++ branches/soc-2007-red_fox/source/blender/blenkernel/intern/modifier.c 2007-08-20 19:05:31 UTC (rev 11748)
@@ -2635,6 +2635,8 @@
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list