Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Poirier <theeth@yahoo.com>2009-07-12 06:01:13 +0400
committerMartin Poirier <theeth@yahoo.com>2009-07-12 06:01:13 +0400
commit8b9bb47a3faf753cb0ca2ec0e9c6a741c7af31c2 (patch)
treeb3057453770db9d237c9b204c192bec07fd91e90 /source/blender/editors
parent42469ba1e51c639c3fd317b812c486913d803fde (diff)
Cleaning up manipulator code a bit
Made transform confirm or cancel on mouse up. More inline with button clicking and better for tablets. Add operator params to make sure Rip and Extrude turn off PET and Mirror correctly. Note: sorry for all the whitespace changes, I need to reconfigure this editor not to do autocleanup.
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/include/ED_transform.h10
-rw-r--r--source/blender/editors/mesh/editmesh_tools.c2417
-rw-r--r--source/blender/editors/transform/transform.c1197
-rw-r--r--source/blender/editors/transform/transform.h30
-rw-r--r--source/blender/editors/transform/transform_constraints.c207
-rw-r--r--source/blender/editors/transform/transform_conversions.c1236
-rw-r--r--source/blender/editors/transform/transform_generics.c316
-rw-r--r--source/blender/editors/transform/transform_manipulator.c84
8 files changed, 2658 insertions, 2839 deletions
diff --git a/source/blender/editors/include/ED_transform.h b/source/blender/editors/include/ED_transform.h
index d2185854a95..768040597a4 100644
--- a/source/blender/editors/include/ED_transform.h
+++ b/source/blender/editors/include/ED_transform.h
@@ -1,5 +1,5 @@
/**
- * $Id: ED_transform.h 21450 2009-07-09 02:45:48Z theeth $
+ * $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
*
@@ -119,12 +119,16 @@ struct EnumPropertyItem *BIF_enumTransformOrientation(struct bContext *C);
char * BIF_menustringTransformOrientation(const struct bContext *C, char *title); /* the returned value was allocated and needs to be freed after use */
int BIF_countTransformOrientation(const struct bContext *C);
-void BIF_getPropCenter(float *center);
-
void BIF_TransformSetUndo(char *str);
void BIF_selectOrientation(void);
+/* to be able to add operator properties to other operators */
+
+void Properties_Proportional(struct wmOperatorType *ot);
+void Properties_Snapping(struct wmOperatorType *ot, short align);
+void Properties_Constraints(struct wmOperatorType *ot);
+
/* view3d manipulators */
void initManipulator(int mode);
void ManipulatorTransform();
diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c
index 682b1ee4a64..eab06444a79 100644
--- a/source/blender/editors/mesh/editmesh_tools.c
+++ b/source/blender/editors/mesh/editmesh_tools.c
@@ -1,4 +1,4 @@
- /* $Id:
+ /* $Id:
*
* ***** BEGIN GPL LICENSE BLOCK *****
*
@@ -133,7 +133,7 @@ struct facesort {
static int vergface(const void *v1, const void *v2)
{
const struct facesort *x1=v1, *x2=v2;
-
+
if( x1->x > x2->x ) return 1;
else if( x1->x < x2->x) return -1;
return 0;
@@ -146,7 +146,7 @@ void convert_to_triface(EditMesh *em, int direction)
{
EditFace *efa, *efan, *next;
float fac;
-
+
efa= em->faces.last;
while(efa) {
next= efa->prev;
@@ -167,17 +167,17 @@ void convert_to_triface(EditMesh *em, int direction)
efan= EM_face_from_faces(em, efa, NULL, 1, 2, 3, -1);
if(efa->f & SELECT) EM_select_face(efan, 1);
}
-
+
BLI_remlink(&em->faces, efa);
free_editface(em, efa);
}
}
efa= next;
}
-
+
EM_fgon_flags(em); // redo flags and indices for fgons
-
+
}
int removedoublesflag(EditMesh *em, short flag, short automerge, float limit) /* return amount */
@@ -188,7 +188,7 @@ int removedoublesflag(EditMesh *em, short flag, short automerge, float limit) /
Used for "Auto Weld" mode. warning.
limit - Quick manhattan distance between verts.
*/
-
+
/* all verts with (flag & 'flag') are being evaluated */
EditVert *eve, *v1, *nextve;
EditEdge *eed, *e1, *nexted;
@@ -196,8 +196,8 @@ int removedoublesflag(EditMesh *em, short flag, short automerge, float limit) /
xvertsort *sortblock, *sb, *sb1;
struct facesort *vlsortblock, *vsb, *vsb1;
int a, b, test, amount;
-
-
+
+
/* flag 128 is cleared, count */
/* Normal non weld operation */
@@ -223,9 +223,9 @@ int removedoublesflag(EditMesh *em, short flag, short automerge, float limit) /
}
qsort(sortblock, amount, sizeof(xvertsort), vergxco);
-
+
/* test for doubles */
- sb= sortblock;
+ sb= sortblock;
if (automerge) {
for(a=0; a<amount; a++, sb++) {
eve= sb->v1;
@@ -233,12 +233,12 @@ int removedoublesflag(EditMesh *em, short flag, short automerge, float limit) /
sb1= sb+1;
for(b=a+1; b<amount && (eve->f & 128)==0; b++, sb1++) {
if(sb1->x - sb->x > limit) break;
-
+
/* when automarge, only allow unselected->selected */
v1= sb1->v1;
if( (v1->f & 128)==0 ) {
if ((eve->f & flag)==0 && (v1->f & flag)==1) {
- if( (float)fabs(v1->co[0]-eve->co[0])<=limit &&
+ if( (float)fabs(v1->co[0]-eve->co[0])<=limit &&
(float)fabs(v1->co[1]-eve->co[1])<=limit &&
(float)fabs(v1->co[2]-eve->co[2])<=limit)
{ /* unique bit */
@@ -246,7 +246,7 @@ int removedoublesflag(EditMesh *em, short flag, short automerge, float limit) /
eve->tmp.v = v1;
}
} else if( (eve->f & flag)==1 && (v1->f & flag)==0 ) {
- if( (float)fabs(v1->co[0]-eve->co[0])<=limit &&
+ if( (float)fabs(v1->co[0]-eve->co[0])<=limit &&
(float)fabs(v1->co[1]-eve->co[1])<=limit &&
(float)fabs(v1->co[2]-eve->co[2])<=limit)
{ /* unique bit */
@@ -267,10 +267,10 @@ int removedoublesflag(EditMesh *em, short flag, short automerge, float limit) /
/* first test: simpel dist */
if(sb1->x - sb->x > limit) break;
v1= sb1->v1;
-
+
/* second test: is vertex allowed */
if( (v1->f & 128)==0 ) {
- if( (float)fabs(v1->co[0]-eve->co[0])<=limit &&
+ if( (float)fabs(v1->co[0]-eve->co[0])<=limit &&
(float)fabs(v1->co[1]-eve->co[1])<=limit &&
(float)fabs(v1->co[2]-eve->co[2])<=limit)
{
@@ -283,12 +283,12 @@ int removedoublesflag(EditMesh *em, short flag, short automerge, float limit) /
}
}
MEM_freeN(sortblock);
-
+
if (!automerge)
for(eve = em->verts.first; eve; eve=eve->next)
if((eve->f & flag) && (eve->f & 128))
EM_data_interp_from_verts(em, eve, eve->tmp.v, eve->tmp.v, 0.5f);
-
+
/* test edges and insert again */
eed= em->edges.first;
while(eed) {
@@ -327,7 +327,7 @@ int removedoublesflag(EditMesh *em, short flag, short automerge, float limit) /
else if(efa->v2->f & 128) efa->f1= 1;
else if(efa->v3->f & 128) efa->f1= 1;
else if(efa->v4 && (efa->v4->f & 128)) efa->f1= 1;
-
+
if(efa->f1==1) amount++;
efa= efa->next;
}
@@ -337,12 +337,12 @@ int removedoublesflag(EditMesh *em, short flag, short automerge, float limit) /
while(efa) {
nextvl= efa->next;
if(efa->f1==1) {
-
+
if(efa->v1->f & 128) efa->v1= efa->v1->tmp.v;
if(efa->v2->f & 128) efa->v2= efa->v2->tmp.v;
if(efa->v3->f & 128) efa->v3= efa->v3->tmp.v;
if(efa->v4 && (efa->v4->f & 128)) efa->v4= efa->v4->tmp.v;
-
+
test= 0;
if(efa->v1==efa->v2) test+=1;
if(efa->v2==efa->v3) test+=2;
@@ -350,7 +350,7 @@ int removedoublesflag(EditMesh *em, short flag, short automerge, float limit) /
if(efa->v4==efa->v1) test+=8;
if(efa->v3==efa->v4) test+=16;
if(efa->v2==efa->v4) test+=32;
-
+
if(test) {
if(efa->v4) {
if(test==1 || test==2) {
@@ -378,7 +378,7 @@ int removedoublesflag(EditMesh *em, short flag, short automerge, float limit) /
amount--;
}
}
-
+
if(test==0) {
/* set edge pointers */
efa->e1= findedgelist(em, efa->v1, efa->v2);
@@ -423,9 +423,9 @@ int removedoublesflag(EditMesh *em, short flag, short automerge, float limit) /
}
efa= efa->next;
}
-
+
qsort(vlsortblock, amount, sizeof(struct facesort), vergface);
-
+
vsb= vlsortblock;
for(a=0; a<amount; a++) {
efa= vsb->efa;
@@ -433,24 +433,24 @@ int removedoublesflag(EditMesh *em, short flag, short automerge, float limit) /
vsb1= vsb+1;
for(b=a+1; b<amount; b++) {
-
+
/* first test: same pointer? */
if(vsb->x != vsb1->x) break;
-
+
/* second test: is test permitted? */
efa= vsb1->efa;
if( (efa->f1 & 128)==0 ) {
if( compareface(efa, vsb->efa)) efa->f1 |= 128;
-
+
}
vsb1++;
}
}
vsb++;
}
-
+
MEM_freeN(vlsortblock);
-
+
/* remove double faces */
efa= (struct EditFace *)em->faces.first;
while(efa) {
@@ -462,7 +462,7 @@ int removedoublesflag(EditMesh *em, short flag, short automerge, float limit) /
efa= nextvl;
}
}
-
+
/* remove double vertices */
a= 0;
eve= (struct EditVert *)em->verts.first;
@@ -495,12 +495,12 @@ static int removedoublesflag_exec(bContext *C, wmOperator *op)
sprintf(msg, "Removed %d vertices", cnt);
BKE_report(op->reports, RPT_INFO, msg);
}
-
+
DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
-
+
BKE_mesh_end_editmesh(obedit->data, em);
- return OPERATOR_FINISHED;
+ return OPERATOR_FINISHED;
}
void MESH_OT_remove_doubles(wmOperatorType *ot)
@@ -508,11 +508,11 @@ void MESH_OT_remove_doubles(wmOperatorType *ot)
/* identifiers */
ot->name= "Remove Doubles";
ot->idname= "MESH_OT_remove_doubles";
-
+
/* api callbacks */
ot->exec= removedoublesflag_exec;
ot->poll= ED_operator_editmesh;
-
+
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
}
@@ -534,18 +534,18 @@ void xsortvert_flag(bContext *C, int flag)
xvertsort *sortblock;
ListBase tbase;
int i, amount;
-
+
em_setup_viewcontext(C, &vc);
-
+
amount = BLI_countlist(&vc.em->verts);
sortblock = MEM_callocN(sizeof(xvertsort)*amount,"xsort");
for (i=0,eve= vc.em->verts.first; eve; i++,eve=eve->next)
if(eve->f & flag)
sortblock[i].v1 = eve;
-
+
mesh_foreachScreenVert(&vc, xsortvert_flag__doSetX, sortblock, 0);
qsort(sortblock, amount, sizeof(xvertsort), vergxco);
-
+
/* make temporal listbase */
tbase.first= tbase.last= 0;
for (i=0; i<amount; i++) {
@@ -556,9 +556,9 @@ void xsortvert_flag(bContext *C, int flag)
BLI_addtail(&tbase, eve);
}
}
-
+
addlisttolist(&vc.em->verts, &tbase);
-
+
MEM_freeN(sortblock);
}
@@ -571,7 +571,7 @@ void hashvert_flag(EditMesh *em, int flag)
struct xvertsort *sortblock, *sb, onth, *newsort;
ListBase tbase;
int amount, a, b;
-
+
/* count */
eve= em->verts.first;
amount= 0;
@@ -580,7 +580,7 @@ void hashvert_flag(EditMesh *em, int flag)
eve= eve->next;
}
if(amount==0) return;
-
+
/* allocate memory */
sb= sortblock= (struct xvertsort *)MEM_mallocN(sizeof(struct xvertsort)*amount,"sortremovedoub");
eve= em->verts.first;
@@ -593,7 +593,7 @@ void hashvert_flag(EditMesh *em, int flag)
}
BLI_srand(1);
-
+
sb= sortblock;
for(a=0; a<amount; a++, sb++) {
b= (int)(amount*BLI_drand());
@@ -614,9 +614,9 @@ void hashvert_flag(EditMesh *em, int flag)
BLI_addtail(&tbase, eve);
sb++;
}
-
+
addlisttolist(&em->verts, &tbase);
-
+
MEM_freeN(sortblock);
}
@@ -632,11 +632,11 @@ void extrude_mesh(Object *obedit, EditMesh *em, wmOperator *op)
if(em->totvertsel==0) nr= 0;
else if(em->totvertsel==1) nr= 4;
else if(em->totedgesel==0) nr= 4;
- else if(em->totfacesel==0)
+ else if(em->totfacesel==0)
nr= 3; // pupmenu("Extrude %t|Only Edges%x3|Only Vertices%x4");
else if(em->totfacesel==1)
nr= 1; // pupmenu("Extrude %t|Region %x1|Only Edges%x3|Only Vertices%x4");
- else
+ else
nr= 1; // pupmenu("Extrude %t|Region %x1||Individual Faces %x2|Only Edges%x3|Only Vertices%x4");
}
else if(em->selectmode & SCE_SELECT_EDGE) {
@@ -654,27 +654,27 @@ void extrude_mesh(Object *obedit, EditMesh *em, wmOperator *op)
else
nr= 1; // pupmenu("Extrude %t|Region %x1||Individual Faces %x2");
}
-
+
if(nr<1) return;
if(nr==1) transmode= extrudeflag(obedit, em, SELECT, nor);
else if(nr==4) transmode= extrudeflag_verts_indiv(em, SELECT, nor);
else if(nr==3) transmode= extrudeflag_edges_indiv(em, SELECT, nor);
else transmode= extrudeflag_face_indiv(em, SELECT, nor);
-
+
if(transmode==0) {
BKE_report(op->reports, RPT_ERROR, "Not a valid selection for extrude");
}
else {
EM_fgon_flags(em);
-
- /* We need to force immediate calculation here because
+
+ /* We need to force immediate calculation here because
* transform may use derived objects (which are now stale).
*
* This shouldn't be necessary, derived queries should be
* automatically building this data if invalid. Or something.
*/
-// DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
+// DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
object_handle_update(scene, obedit);
/* individual faces? */
@@ -709,11 +709,12 @@ static int mesh_extrude_invoke(bContext *C, wmOperator *op, wmEvent *event)
DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
-
- RNA_int_set(op->ptr, "mode", TFM_TRANSLATION);
- WM_operator_name_call(C, "TFM_OT_transform", WM_OP_INVOKE_REGION_WIN, op->ptr);
-
- return OPERATOR_FINISHED;
+
+ RNA_enum_set(op->ptr, "proportional", 0);
+ RNA_boolean_set(op->ptr, "mirror", 0);
+ WM_operator_name_call(C, "TFM_OT_translation", WM_OP_INVOKE_REGION_WIN, op->ptr);
+
+ return OPERATOR_FINISHED;
}
/* extrude without transform */
@@ -722,14 +723,14 @@ static int mesh_extrude_exec(bContext *C, wmOperator *op)
Scene *scene= CTX_data_scene(C);
Object *obedit= CTX_data_edit_object(C);
EditMesh *em= BKE_mesh_get_editmesh(obedit->data);
-
+
extrude_mesh(obedit,em, op);
-
+
DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
-
+
BKE_mesh_end_editmesh(obedit->data, em);
- return OPERATOR_FINISHED;
+ return OPERATOR_FINISHED;
}
@@ -738,17 +739,18 @@ void MESH_OT_extrude(wmOperatorType *ot)
/* identifiers */
ot->name= "Extrude";
ot->idname= "MESH_OT_extrude";
-
+
/* api callbacks */
ot->invoke= mesh_extrude_invoke;
ot->exec= mesh_extrude_exec;
ot->poll= ED_operator_editmesh;
-
+
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
/* to give to transform */
- RNA_def_int(ot->srna, "mode", TFM_TRANSLATION, 0, INT_MAX, "Mode", "", 0, INT_MAX);
+ Properties_Proportional(ot);
+ RNA_def_boolean(ot->srna, "mirror", 0, "Mirror Editing", "");
}
static int split_mesh(bContext *C, wmOperator *op)
@@ -779,11 +781,11 @@ void MESH_OT_split(wmOperatorType *ot)
/* identifiers */
ot->name= "Split";
ot->idname= "MESH_OT_split";
-
+
/* api callbacks */
ot->exec= split_mesh;
ot->poll= ED_operator_editmesh;
-
+
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
}
@@ -795,10 +797,10 @@ static int extrude_repeat_mesh(bContext *C, wmOperator *op)
Object *obedit= CTX_data_edit_object(C);
EditMesh *em= BKE_mesh_get_editmesh((Mesh *)obedit->data);
- RegionView3D *rv3d = ED_view3d_context_rv3d(C);
-
+ RegionView3D *rv3d = ED_view3d_context_rv3d(C);
+
int steps = RNA_int_get(op->ptr,"steps");
-
+
float offs = RNA_float_get(op->ptr,"offset");
float dvec[3], tmat[3][3], bmat[3][3], nor[3]= {0.0, 0.0, 0.0};
@@ -822,11 +824,11 @@ static int extrude_repeat_mesh(bContext *C, wmOperator *op)
extrudeflag(obedit, em, SELECT, nor);
translateflag(em, SELECT, dvec);
}
-
+
recalc_editnormals(em);
-
+
EM_fgon_flags(em);
-
+
DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
@@ -839,14 +841,14 @@ void MESH_OT_extrude_repeat(wmOperatorType *ot)
/* identifiers */
ot->name= "Extrude Repeat Mesh";
ot->idname= "MESH_OT_extrude_repeat";
-
+
/* api callbacks */
ot->exec= extrude_repeat_mesh;
ot->poll= ED_operator_editmesh;
-
+
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
-
+
/* props */
RNA_def_float(ot->srna, "offset", 2.0f, 0.0f, 100.0f, "Offset", "", 0.0f, FLT_MAX);
RNA_def_int(ot->srna, "steps", 10, 0, 180, "Steps", "", 0, INT_MAX);
@@ -868,7 +870,7 @@ static int spin_mesh(bContext *C, wmOperator *op, float *dvec, int steps, float
short a, ok= 1;
RNA_float_get_array(op->ptr, "center", cent);
-
+
/* imat and center and size */
Mat3CpyMat4(bmat, obedit->obmat);
Mat3Inv(imat,bmat);
@@ -895,14 +897,14 @@ static int spin_mesh(bContext *C, wmOperator *op, float *dvec, int steps, float
Mat3MulMat3(tmat,cmat,bmat);
Mat3MulMat3(bmat,imat,tmat);
- if(dupli==0)
- if(scene->toolsettings->editbutflag & B_KEEPORIG)
+ if(dupli==0)
+ if(scene->toolsettings->editbutflag & B_KEEPORIG)
adduplicateflag(em, 1);
for(a=0; a<steps; a++) {
if(dupli==0) ok= extrudeflag(obedit, em, SELECT, nor);
else adduplicateflag(em, SELECT);
-
+
if(ok==0)
break;
@@ -932,7 +934,7 @@ static int spin_mesh(bContext *C, wmOperator *op, float *dvec, int steps, float
DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
}
-
+
BKE_mesh_end_editmesh(obedit->data, em);
return ok;
}
@@ -942,7 +944,7 @@ static int spin_mesh_exec(bContext *C, wmOperator *op)
Scene *scene= CTX_data_scene(C);
Object *obedit= CTX_data_edit_object(C);
int ok;
-
+
ok= spin_mesh(C, op, NULL, RNA_int_get(op->ptr,"steps"), RNA_float_get(op->ptr,"degrees"), RNA_boolean_get(op->ptr,"dupli"));
if(ok==0) {
BKE_report(op->reports, RPT_ERROR, "No valid vertices are selected");
@@ -961,10 +963,10 @@ static int spin_mesh_invoke(bContext *C, wmOperator *op, wmEvent *event)
Scene *scene = CTX_data_scene(C);
View3D *v3d = CTX_wm_view3d(C);
RegionView3D *rv3d= ED_view3d_context_rv3d(C);
-
+
RNA_float_set_array(op->ptr, "center", give_cursor(scene, v3d));
RNA_float_set_array(op->ptr, "axis", rv3d->viewinv[2]);
-
+
return spin_mesh_exec(C, op);
}
@@ -973,20 +975,20 @@ void MESH_OT_spin(wmOperatorType *ot)
/* identifiers */
ot->name= "Spin";
ot->idname= "MESH_OT_spin";
-
+
/* api callbacks */
ot->invoke= spin_mesh_invoke;
ot->exec= spin_mesh_exec;
ot->poll= EM_view3d_poll;
-
+
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
-
+
/* props */
RNA_def_int(ot->srna, "steps", 9, 0, INT_MAX, "Steps", "Steps", 0, INT_MAX);
RNA_def_boolean(ot->srna, "dupli", 0, "Dupli", "Make Duplicates");
RNA_def_float(ot->srna, "degrees", 90.0f, -FLT_MAX, FLT_MAX, "Degrees", "Degrees", -360.0f, 360.0f);
-
+
RNA_def_float_vector(ot->srna, "center", 3, NULL, -FLT_MAX, FLT_MAX, "Center", "Center in global view space", -FLT_MAX, FLT_MAX);
RNA_def_float_vector(ot->srna, "axis", 3, NULL, -1.0f, 1.0f, "Axis", "Axis in global view space", -FLT_MAX, FLT_MAX);
@@ -1004,7 +1006,7 @@ static int screw_mesh_exec(bContext *C, wmOperator *op)
turns= RNA_int_get(op->ptr, "turns");
steps= RNA_int_get(op->ptr, "steps");
-
+
/* clear flags */
for(eve= em->verts.first; eve; eve= eve->next)
eve->f1= 0;
@@ -1048,12 +1050,12 @@ static int screw_mesh_exec(bContext *C, wmOperator *op)
dvec[1]= -dvec[1];
dvec[2]= -dvec[2];
}
-
+
if(spin_mesh(C, op, dvec, turns*steps, 360.0f*turns, 0)) {
DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
- BKE_mesh_end_editmesh(obedit->data, em);
+ BKE_mesh_end_editmesh(obedit->data, em);
return OPERATOR_FINISHED;
}
else {
@@ -1069,10 +1071,10 @@ static int screw_mesh_invoke(bContext *C, wmOperator *op, wmEvent *event)
Scene *scene = CTX_data_scene(C);
View3D *v3d = CTX_wm_view3d(C);
RegionView3D *rv3d= ED_view3d_context_rv3d(C);
-
+
RNA_float_set_array(op->ptr, "center", give_cursor(scene, v3d));
RNA_float_set_array(op->ptr, "axis", rv3d->viewinv[1]);
-
+
return screw_mesh_exec(C, op);
}
@@ -1081,15 +1083,15 @@ void MESH_OT_screw(wmOperatorType *ot)
/* identifiers */
ot->name= "Screw";
ot->idname= "MESH_OT_screw";
-
+
/* api callbacks */
ot->invoke= screw_mesh_invoke;
ot->exec= screw_mesh_exec;
ot->poll= EM_view3d_poll;
-
+
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
-
+
/*props */
RNA_def_int(ot->srna, "steps", 9, 0, INT_MAX, "Steps", "Steps", 0, 256);
RNA_def_int(ot->srna, "turns", 1, 0, INT_MAX, "Turns", "Turns", 0, 256);
@@ -1101,7 +1103,7 @@ void MESH_OT_screw(wmOperatorType *ot)
static void erase_edges(EditMesh *em, ListBase *l)
{
EditEdge *ed, *nexted;
-
+
ed = (EditEdge *) l->first;
while(ed) {
nexted= ed->next;
@@ -1127,7 +1129,7 @@ static void erase_faces(EditMesh *em, ListBase *l)
}
f = nextf;
}
-}
+}
static void erase_vertices(EditMesh *em, ListBase *l)
{
@@ -1152,7 +1154,7 @@ void delete_mesh(Object *obedit, EditMesh *em, wmOperator *op, int event)
int count;
char *str="Erase";
-
+
if(event<1) return;
if(event==10 ) {
@@ -1160,7 +1162,7 @@ void delete_mesh(Object *obedit, EditMesh *em, wmOperator *op, int event)
erase_edges(em, &em->edges);
erase_faces(em, &em->faces);
erase_vertices(em, &em->verts);
- }
+ }
else if(event==6) {
if(!EdgeLoopDelete(em, op))
return;
@@ -1201,14 +1203,14 @@ void delete_mesh(Object *obedit, EditMesh *em, wmOperator *op, int event)
if( efa->v2->f & SELECT) event++;
if( efa->v3->f & SELECT) event++;
if(efa->v4 && (efa->v4->f & SELECT)) event++;
-
+
if(event>1) {
BLI_remlink(&em->faces, efa);
free_editface(em, efa);
}
efa= nextvl;
}
- }
+ }
else if(event==1) {
str= "Erase Edges";
// faces first
@@ -1220,7 +1222,7 @@ void delete_mesh(Object *obedit, EditMesh *em, wmOperator *op, int event)
if( efa->e2->f & SELECT) event++;
if( efa->e3->f & SELECT) event++;
if(efa->e4 && (efa->e4->f & SELECT)) event++;
-
+
if(event) {
BLI_remlink(&em->faces, efa);
free_editface(em, efa);
@@ -1298,12 +1300,12 @@ static int delete_mesh_exec(bContext *C, wmOperator *op)
Scene *scene= CTX_data_scene(C);
Object *obedit= CTX_data_edit_object(C);
EditMesh *em= BKE_mesh_get_editmesh((Mesh *)obedit->data);
-
+
delete_mesh(obedit, em, op, RNA_enum_get(op->ptr, "type"));
-
+
DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
-
+
BKE_mesh_end_editmesh(obedit->data, em);
return OPERATOR_FINISHED;
}
@@ -1313,16 +1315,16 @@ void MESH_OT_delete(wmOperatorType *ot)
/* identifiers */
ot->name= "Delete";
ot->idname= "MESH_OT_delete";
-
+
/* api callbacks */
ot->invoke= WM_menu_invoke;
ot->exec= delete_mesh_exec;
-
+
ot->poll= ED_operator_editmesh;
-
+
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
-
+
/*props */
RNA_def_enum(ot->srna, "type", prop_mesh_delete_types, 10, "Type", "Method used for deleting mesh data");
}
@@ -1344,38 +1346,38 @@ void MESH_OT_delete(wmOperatorType *ot)
static void alter_co(float *co, EditEdge *edge, float smooth, float fractal, int beauty, float perc)
{
float vec1[3], fac;
-
+
if(beauty & B_SMOOTH) {
/* we calculate an offset vector vec1[], to be added to *co */
float len, fac, nor[3], nor1[3], nor2[3];
-
+
VecSubf(nor, edge->v1->co, edge->v2->co);
len= 0.5f*Normalize(nor);
-
+
VECCOPY(nor1, edge->v1->no);
VECCOPY(nor2, edge->v2->no);
-
+
/* cosine angle */
fac= nor[0]*nor1[0] + nor[1]*nor1[1] + nor[2]*nor1[2] ;
-
+
vec1[0]= fac*nor1[0];
vec1[1]= fac*nor1[1];
vec1[2]= fac*nor1[2];
-
+
/* cosine angle */
fac= -nor[0]*nor2[0] - nor[1]*nor2[1] - nor[2]*nor2[2] ;
-
+
vec1[0]+= fac*nor2[0];
vec1[1]+= fac*nor2[1];
vec1[2]+= fac*nor2[2];
/* falloff for multi subdivide */
smooth *= sqrt(fabs(1.0f - 2.0f*fabs(0.5f-perc)));
-
+
vec1[0]*= smooth*len;
vec1[1]*= smooth*len;
vec1[2]*= smooth*len;
-
+
co[0] += vec1[0];
co[1] += vec1[1];
co[2] += vec1[2];
@@ -1403,14 +1405,14 @@ static EditVert *subdivide_edge_addvert(EditMesh *em, EditEdge *edge, float smoo
{
EditVert *ev;
float co[3];
-
+
co[0] = (edge->v2->co[0]-edge->v1->co[0])*percent + edge->v1->co[0];
co[1] = (edge->v2->co[1]-edge->v1->co[1])*percent + edge->v1->co[1];
- co[2] = (edge->v2->co[2]-edge->v1->co[2])*percent + edge->v1->co[2];
-
+ co[2] = (edge->v2->co[2]-edge->v1->co[2])*percent + edge->v1->co[2];
+
/* offset for smooth or sphere or fractal */
alter_co(co, edge, smooth, fractal, beauty, percent);
-
+
/* clip if needed by mirror modifier */
if (edge->v1->f2) {
if ( edge->v1->f2 & edge->v2->f2 & 1) {
@@ -1423,18 +1425,18 @@ static EditVert *subdivide_edge_addvert(EditMesh *em, EditEdge *edge, float smoo
co[2]= 0.0f;
}
}
-
+
ev = addvertlist(em, co, NULL);
-
+
/* vert data (vgroups, ..) */
EM_data_interp_from_verts(em, edge->v1, edge->v2, ev, percent);
-
+
/* normal */
ev->no[0] = (edge->v2->no[0]-edge->v1->no[0])*percent + edge->v1->no[0];
ev->no[1] = (edge->v2->no[1]-edge->v1->no[1])*percent + edge->v1->no[1];
ev->no[2] = (edge->v2->no[2]-edge->v1->no[2])*percent + edge->v1->no[2];
Normalize(ev->no);
-
+
return ev;
}
@@ -1442,11 +1444,11 @@ static void flipvertarray(EditVert** arr, short size)
{
EditVert *hold;
int i;
-
+
for(i=0; i<size/2; i++) {
hold = arr[i];
arr[i] = arr[size-i-1];
- arr[size-i-1] = hold;
+ arr[size-i-1] = hold;
}
}
@@ -1459,15 +1461,15 @@ static void facecopy(EditMesh *em, EditFace *source, EditFace *target)
CustomData_em_copy_data(&em->fdata, &em->fdata, source->data, &target->data);
target->mat_nr = source->mat_nr;
- target->flag = source->flag;
+ target->flag = source->flag;
target->h = source->h;
-
+
InterpWeightsQ3Dfl(v1, v2, v3, v4, target->v1->co, w[0]);
InterpWeightsQ3Dfl(v1, v2, v3, v4, target->v2->co, w[1]);
InterpWeightsQ3Dfl(v1, v2, v3, v4, target->v3->co, w[2]);
if (target->v4)
InterpWeightsQ3Dfl(v1, v2, v3, v4, target->v4->co, w[3]);
-
+
CustomData_em_interp(&em->fdata, &source->data, NULL, (float*)w, 1, target->data);
}
@@ -1476,17 +1478,17 @@ static void fill_quad_single(EditMesh *em, EditFace *efa, struct GHash *gh, int
EditEdge *cedge=NULL;
EditVert *v[4], **verts;
EditFace *hold;
- short start=0, end, left, right, vertsize,i;
-
+ short start=0, end, left, right, vertsize,i;
+
v[0] = efa->v1;
v[1] = efa->v2;
v[2] = efa->v3;
- v[3] = efa->v4;
+ v[3] = efa->v4;
if(efa->e1->f & SELECT) { cedge = efa->e1; start = 0;}
- else if(efa->e2->f & SELECT) { cedge = efa->e2; start = 1;}
- else if(efa->e3->f & SELECT) { cedge = efa->e3; start = 2;}
- else if(efa->e4->f & SELECT) { cedge = efa->e4; start = 3;}
+ else if(efa->e2->f & SELECT) { cedge = efa->e2; start = 1;}
+ else if(efa->e3->f & SELECT) { cedge = efa->e3; start = 2;}
+ else if(efa->e4->f & SELECT) { cedge = efa->e4; start = 3;}
// Point verts to the array of new verts for cedge
verts = BLI_ghash_lookup(gh, cedge);
@@ -1500,30 +1502,30 @@ static void fill_quad_single(EditMesh *em, EditFace *efa, struct GHash *gh, int
if(verts[0] != v[start]) {flipvertarray(verts,numcuts+2);}
end = (start+1)%4;
left = (start+2)%4;
- right = (start+3)%4;
-
+ right = (start+3)%4;
+
/*
We should have something like this now
- end start
- 3 2 1 0
+ end start
+ 3 2 1 0
|---*---*---|
| |
- | |
| |
- -------------
+ | |
+ -------------
left right
where start,end,left, right are indexes of EditFace->v1, etc (stored in v)
and 0,1,2... are the indexes of the new verts stored in verts
We will fill this case like this or this depending on even or odd cuts
-
+
|---*---*---| |---*---|
| / \ | | / \ |
- | / \ | | / \ |
+ | / \ | | / \ |
|/ \| |/ \|
- ------------- ---------
+ ------------- ---------
*/
// Make center face
@@ -1532,7 +1534,7 @@ static void fill_quad_single(EditMesh *em, EditFace *efa, struct GHash *gh, int
hold->e2->f2 |= EDGEINNER;
hold->e4->f2 |= EDGEINNER;
}else{
- hold = addfacelist(em, verts[(vertsize-1)/2],v[left],v[right],NULL, NULL,NULL);
+ hold = addfacelist(em, verts[(vertsize-1)/2],v[left],v[right],NULL, NULL,NULL);
hold->e1->f2 |= EDGEINNER;
hold->e3->f2 |= EDGEINNER;
}
@@ -1540,21 +1542,21 @@ static void fill_quad_single(EditMesh *em, EditFace *efa, struct GHash *gh, int
// Make side faces
for(i=0;i<(vertsize-1)/2;i++) {
- hold = addfacelist(em, verts[i],verts[i+1],v[right],NULL,NULL,NULL);
+ hold = addfacelist(em, verts[i],verts[i+1],v[right],NULL,NULL,NULL);
facecopy(em, efa,hold);
if(i+1 != (vertsize-1)/2) {
if(seltype == SUBDIV_SELECT_INNER) {
hold->e2->f2 |= EDGEINNER;
}
}
- hold = addfacelist(em, verts[vertsize-2-i],verts[vertsize-1-i],v[left],NULL,NULL,NULL);
+ hold = addfacelist(em, verts[vertsize-2-i],verts[vertsize-1-i],v[left],NULL,NULL,NULL);
facecopy(em, efa,hold);
if(i+1 != (vertsize-1)/2) {
if(seltype == SUBDIV_SELECT_INNER) {
hold->e3->f2 |= EDGEINNER;
}
}
- }
+ }
}
static void fill_tri_single(EditMesh *em, EditFace *efa, struct GHash *gh, int numcuts, int seltype)
@@ -1562,15 +1564,15 @@ static void fill_tri_single(EditMesh *em, EditFace *efa, struct GHash *gh, int n
EditEdge *cedge=NULL;
EditVert *v[3], **verts;
EditFace *hold;
- short start=0, end, op, vertsize,i;
-
+ short start=0, end, op, vertsize,i;
+
v[0] = efa->v1;
v[1] = efa->v2;
- v[2] = efa->v3;
+ v[2] = efa->v3;
if(efa->e1->f & SELECT) { cedge = efa->e1; start = 0;}
- else if(efa->e2->f & SELECT) { cedge = efa->e2; start = 1;}
- else if(efa->e3->f & SELECT) { cedge = efa->e3; start = 2;}
+ else if(efa->e2->f & SELECT) { cedge = efa->e2; start = 1;}
+ else if(efa->e3->f & SELECT) { cedge = efa->e3; start = 2;}
// Point verts to the array of new verts for cedge
verts = BLI_ghash_lookup(gh, cedge);
@@ -1584,30 +1586,30 @@ static void fill_tri_single(EditMesh *em, EditFace *efa, struct GHash *gh, int n
if(verts[0] != v[start]) {flipvertarray(verts,numcuts+2);}
end = (start+1)%3;
op = (start+2)%3;
-
+
/*
We should have something like this now
- end start
- 3 2 1 0
+ end start
+ 3 2 1 0
|---*---*---|
\ |
- \ |
+ \ |
\ |
\ |
\ |
\ |
|op
-
+
where start,end,op are indexes of EditFace->v1, etc (stored in v)
and 0,1,2... are the indexes of the new verts stored in verts
We will fill this case like this or this depending on even or odd cuts
-
- 3 2 1 0
+
+ 3 2 1 0
|---*---*---|
\ \ \ |
- \ \ \ |
+ \ \ \ |
\ \ \ |
\ \ \|
\ \\|
@@ -1617,14 +1619,14 @@ static void fill_tri_single(EditMesh *em, EditFace *efa, struct GHash *gh, int n
// Make side faces
for(i=0;i<(vertsize-1);i++) {
- hold = addfacelist(em, verts[i],verts[i+1],v[op],NULL,NULL,NULL);
+ hold = addfacelist(em, verts[i],verts[i+1],v[op],NULL,NULL,NULL);
if(i+1 != vertsize-1) {
if(seltype == SUBDIV_SELECT_INNER) {
hold->e2->f2 |= EDGEINNER;
}
}
facecopy(em, efa,hold);
- }
+ }
}
static void fill_quad_double_op(EditMesh *em, EditFace *efa, struct GHash *gh, int numcuts)
@@ -1633,11 +1635,11 @@ static void fill_quad_double_op(EditMesh *em, EditFace *efa, struct GHash *gh, i
EditVert *v[4], **verts[2];
EditFace *hold;
short start=0, end, left, right, vertsize,i;
-
+
v[0] = efa->v1;
v[1] = efa->v2;
v[2] = efa->v3;
- v[3] = efa->v4;
+ v[3] = efa->v4;
if(efa->e1->f & SELECT) { cedge[0] = efa->e1; cedge[1] = efa->e3; start = 0;}
else if(efa->e2->f & SELECT) { cedge[0] = efa->e2; cedge[1] = efa->e4; start = 1;}
@@ -1655,39 +1657,39 @@ static void fill_quad_double_op(EditMesh *em, EditFace *efa, struct GHash *gh, i
if(verts[0][0] != v[start]) {flipvertarray(verts[0],numcuts+2);}
end = (start+1)%4;
left = (start+2)%4;
- right = (start+3)%4;
- if(verts[1][0] != v[left]) {flipvertarray(verts[1],numcuts+2);}
+ right = (start+3)%4;
+ if(verts[1][0] != v[left]) {flipvertarray(verts[1],numcuts+2);}
/*
We should have something like this now
- end start
- 3 2 1 0
+ end start
+ 3 2 1 0
|---*---*---|
| |
- | |
| |
- |---*---*---|
+ | |
+ |---*---*---|
0 1 2 3
left right
We will fill this case like this or this depending on even or odd cuts
-
+
|---*---*---|
| | | |
- | | | |
| | | |
- |---*---*---|
+ | | | |
+ |---*---*---|
*/
-
+
// Make side faces
for(i=0;i<vertsize-1;i++) {
- hold = addfacelist(em, verts[0][i],verts[0][i+1],verts[1][vertsize-2-i],verts[1][vertsize-1-i],NULL,NULL);
+ hold = addfacelist(em, verts[0][i],verts[0][i+1],verts[1][vertsize-2-i],verts[1][vertsize-1-i],NULL,NULL);
if(i < vertsize-2) {
hold->e2->f2 |= EDGEINNER;
hold->e2->f2 |= DOUBLEOPFILL;
}
facecopy(em, efa,hold);
- }
+ }
}
static void fill_quad_double_adj_path(EditMesh *em, EditFace *efa, struct GHash *gh, int numcuts)
@@ -1697,11 +1699,11 @@ static void fill_quad_double_adj_path(EditMesh *em, EditFace *efa, struct GHash
EditFace *hold;
short start=0, start2=0, vertsize,i;
int ctrl= 0; // XXX
-
+
v[0] = efa->v1;
v[1] = efa->v2;
v[2] = efa->v3;
- v[3] = efa->v4;
+ v[3] = efa->v4;
if(efa->e1->f & SELECT && efa->e2->f & SELECT) {cedge[0] = efa->e1; cedge[1] = efa->e2; start = 0; start2 = 1;}
if(efa->e2->f & SELECT && efa->e3->f & SELECT) {cedge[0] = efa->e2; cedge[1] = efa->e3; start = 1; start2 = 2;}
@@ -1719,53 +1721,53 @@ static void fill_quad_double_adj_path(EditMesh *em, EditFace *efa, struct GHash
// the array to the correct direction
if(verts[0][0] != v[start]) {flipvertarray(verts[0],numcuts+2);}
- if(verts[1][0] != v[start2]) {flipvertarray(verts[1],numcuts+2);}
+ if(verts[1][0] != v[start2]) {flipvertarray(verts[1],numcuts+2);}
/*
We should have something like this now
- end start
- 3 2 1 0
+ end start
+ 3 2 1 0
start2 0|---*---*---|
| |
1* |
| |
- 2* |
+ 2* |
| |
- end2 3|-----------|
+ end2 3|-----------|
We will fill this case like this or this depending on even or odd cuts
|---*---*---|
| / / / |
* / / |
| / / |
- * / |
+ * / |
| / |
- |-----------|
+ |-----------|
*/
// Make outside tris
- hold = addfacelist(em, verts[0][vertsize-2],verts[0][vertsize-1],verts[1][1],NULL,NULL,NULL);
+ hold = addfacelist(em, verts[0][vertsize-2],verts[0][vertsize-1],verts[1][1],NULL,NULL,NULL);
/* when ctrl is depressed, only want verts on the cutline selected */
if (ctrl)
hold->e3->f2 |= EDGEINNER;
- facecopy(em, efa,hold);
+ facecopy(em, efa,hold);
hold = addfacelist(em, verts[0][0],verts[1][vertsize-1],v[(start2+2)%4],NULL,NULL,NULL);
/* when ctrl is depressed, only want verts on the cutline selected */
if (ctrl)
- hold->e1->f2 |= EDGEINNER;
- facecopy(em, efa,hold);
+ hold->e1->f2 |= EDGEINNER;
+ facecopy(em, efa,hold);
//if(scene->toolsettings->editbutflag & B_AUTOFGON) {
// hold->e1->h |= EM_FGON;
- //}
+ //}
// Make side faces
for(i=0;i<numcuts;i++) {
- hold = addfacelist(em, verts[0][i],verts[0][i+1],verts[1][vertsize-1-(i+1)],verts[1][vertsize-1-i],NULL,NULL);
+ hold = addfacelist(em, verts[0][i],verts[0][i+1],verts[1][vertsize-1-(i+1)],verts[1][vertsize-1-i],NULL,NULL);
hold->e2->f2 |= EDGEINNER;
facecopy(em, efa,hold);
}
//EM_fgon_flags(em);
-
+
}
static void fill_quad_double_adj_fan(EditMesh *em, EditFace *efa, struct GHash *gh, int numcuts)
@@ -1774,18 +1776,18 @@ static void fill_quad_double_adj_fan(EditMesh *em, EditFace *efa, struct GHash *
EditVert *v[4], *op=NULL, **verts[2];
EditFace *hold;
short start=0, start2=0, vertsize,i;
-
+
v[0] = efa->v1;
v[1] = efa->v2;
v[2] = efa->v3;
- v[3] = efa->v4;
+ v[3] = efa->v4;
if(efa->e1->f & SELECT && efa->e2->f & SELECT) {cedge[0] = efa->e1; cedge[1] = efa->e2; start = 0; start2 = 1; op = efa->v4;}
if(efa->e2->f & SELECT && efa->e3->f & SELECT) {cedge[0] = efa->e2; cedge[1] = efa->e3; start = 1; start2 = 2; op = efa->v1;}
if(efa->e3->f & SELECT && efa->e4->f & SELECT) {cedge[0] = efa->e3; cedge[1] = efa->e4; start = 2; start2 = 3; op = efa->v2;}
if(efa->e4->f & SELECT && efa->e1->f & SELECT) {cedge[0] = efa->e4; cedge[1] = efa->e1; start = 3; start2 = 0; op = efa->v3;}
-
+
// Point verts[0] and [1] to the array of new verts for cedge[0] and cedge[1]
verts[0] = BLI_ghash_lookup(gh, cedge[0]);
verts[1] = BLI_ghash_lookup(gh, cedge[1]);
@@ -1797,39 +1799,39 @@ static void fill_quad_double_adj_fan(EditMesh *em, EditFace *efa, struct GHash *
// the array to the correct direction
if(verts[0][0] != v[start]) {flipvertarray(verts[0],numcuts+2);}
- if(verts[1][0] != v[start2]) {flipvertarray(verts[1],numcuts+2);}
+ if(verts[1][0] != v[start2]) {flipvertarray(verts[1],numcuts+2);}
/*
We should have something like this now
- end start
- 3 2 1 0
+ end start
+ 3 2 1 0
start2 0|---*---*---|
| |
1* |
| |
- 2* |
+ 2* |
| |
- end2 3|-----------|op
+ end2 3|-----------|op
We will fill this case like this or this (warning horrible ascii art follows)
|---*---*---|
| \ \ \ |
*---\ \ \ |
| \ \ \ \|
- *---- \ \ \ |
+ *---- \ \ \ |
| --- \\\|
- |-----------|
+ |-----------|
*/
for(i=0;i<=numcuts;i++) {
- hold = addfacelist(em, op,verts[1][numcuts-i],verts[1][numcuts-i+1],NULL,NULL,NULL);
+ hold = addfacelist(em, op,verts[1][numcuts-i],verts[1][numcuts-i+1],NULL,NULL,NULL);
hold->e1->f2 |= EDGEINNER;
facecopy(em, efa,hold);
- hold = addfacelist(em, op,verts[0][i],verts[0][i+1],NULL,NULL,NULL);
+ hold = addfacelist(em, op,verts[0][i],verts[0][i+1],NULL,NULL,NULL);
hold->e3->f2 |= EDGEINNER;
facecopy(em, efa,hold);
- }
+ }
}
static void fill_quad_double_adj_inner(EditMesh *em, EditFace *efa, struct GHash *gh, int numcuts)
@@ -1839,18 +1841,18 @@ static void fill_quad_double_adj_inner(EditMesh *em, EditFace *efa, struct GHash
EditFace *hold;
short start=0, start2=0, vertsize,i;
float co[3];
-
+
v[0] = efa->v1;
v[1] = efa->v2;
v[2] = efa->v3;
- v[3] = efa->v4;
+ v[3] = efa->v4;
if(efa->e1->f & SELECT && efa->e2->f & SELECT) {cedge[0] = efa->e1; cedge[1] = efa->e2; start = 0; start2 = 1; op = efa->v4;}
if(efa->e2->f & SELECT && efa->e3->f & SELECT) {cedge[0] = efa->e2; cedge[1] = efa->e3; start = 1; start2 = 2; op = efa->v1;}
if(efa->e3->f & SELECT && efa->e4->f & SELECT) {cedge[0] = efa->e3; cedge[1] = efa->e4; start = 2; start2 = 3; op = efa->v2;}
if(efa->e4->f & SELECT && efa->e1->f & SELECT) {cedge[0] = efa->e4; cedge[1] = efa->e1; start = 3; start2 = 0; op = efa->v3;}
-
+
// Point verts[0] and [1] to the array of new verts for cedge[0] and cedge[1]
verts[0] = BLI_ghash_lookup(gh, cedge[0]);
verts[1] = BLI_ghash_lookup(gh, cedge[1]);
@@ -1862,19 +1864,19 @@ static void fill_quad_double_adj_inner(EditMesh *em, EditFace *efa, struct GHash
// the array to the correct direction
if(verts[0][0] != v[start]) {flipvertarray(verts[0],numcuts+2);}
- if(verts[1][0] != v[start2]) {flipvertarray(verts[1],numcuts+2);}
+ if(verts[1][0] != v[start2]) {flipvertarray(verts[1],numcuts+2);}
/*
We should have something like this now
- end start
- 3 2 1 0
+ end start
+ 3 2 1 0
start2 0|---*---*---|
| |
1* |
| |
- 2* |
+ 2* |
| |
- end2 3|-----------|op
+ end2 3|-----------|op
We will fill this case like this or this (warning horrible ascii art follows)
|---*-----*---|
@@ -1882,14 +1884,14 @@ static void fill_quad_double_adj_inner(EditMesh *em, EditFace *efa, struct GHash
* \ / |
| * |
| / \ |
- * \ |
+ * \ |
| \ |
- |-------------|
+ |-------------|
*/
// Add Inner Vert(s)
inner = MEM_mallocN(sizeof(EditVert*)*numcuts,"New inner verts");
-
+
for(i=0;i<numcuts;i++) {
co[0] = (verts[0][numcuts-i]->co[0] + verts[1][i+1]->co[0] ) / 2 ;
co[1] = (verts[0][numcuts-i]->co[1] + verts[1][i+1]->co[1] ) / 2 ;
@@ -1899,45 +1901,45 @@ static void fill_quad_double_adj_inner(EditMesh *em, EditFace *efa, struct GHash
EM_data_interp_from_verts(em, verts[0][numcuts-i], verts[1][i+1], inner[i], 0.5f);
}
-
+
// Add Corner Quad
- hold = addfacelist(em, verts[0][numcuts+1],verts[1][1],inner[0],verts[0][numcuts],NULL,NULL);
+ hold = addfacelist(em, verts[0][numcuts+1],verts[1][1],inner[0],verts[0][numcuts],NULL,NULL);
hold->e2->f2 |= EDGEINNER;
hold->e3->f2 |= EDGEINNER;
- facecopy(em, efa,hold);
+ facecopy(em, efa,hold);
// Add Bottom Quads
- hold = addfacelist(em, verts[0][0],verts[0][1],inner[numcuts-1],op,NULL,NULL);
+ hold = addfacelist(em, verts[0][0],verts[0][1],inner[numcuts-1],op,NULL,NULL);
hold->e2->f2 |= EDGEINNER;
- facecopy(em, efa,hold);
+ facecopy(em, efa,hold);
- hold = addfacelist(em, op,inner[numcuts-1],verts[1][numcuts],verts[1][numcuts+1],NULL,NULL);
+ hold = addfacelist(em, op,inner[numcuts-1],verts[1][numcuts],verts[1][numcuts+1],NULL,NULL);
hold->e2->f2 |= EDGEINNER;
- facecopy(em, efa,hold);
-
+ facecopy(em, efa,hold);
+
//if(scene->toolsettings->editbutflag & B_AUTOFGON) {
// hold->e1->h |= EM_FGON;
- //}
+ //}
// Add Fill Quads (if # cuts > 1)
for(i=0;i<numcuts-1;i++) {
- hold = addfacelist(em, inner[i],verts[1][i+1],verts[1][i+2],inner[i+1],NULL,NULL);
+ hold = addfacelist(em, inner[i],verts[1][i+1],verts[1][i+2],inner[i+1],NULL,NULL);
hold->e1->f2 |= EDGEINNER;
hold->e3->f2 |= EDGEINNER;
facecopy(em, efa,hold);
- hold = addfacelist(em, inner[i],inner[i+1],verts[0][numcuts-1-i],verts[0][numcuts-i],NULL,NULL);
+ hold = addfacelist(em, inner[i],inner[i+1],verts[0][numcuts-1-i],verts[0][numcuts-i],NULL,NULL);
hold->e2->f2 |= EDGEINNER;
hold->e4->f2 |= EDGEINNER;
- facecopy(em, efa,hold);
-
+ facecopy(em, efa,hold);
+
//if(scene->toolsettings->editbutflag & B_AUTOFGON) {
// hold->e1->h |= EM_FGON;
- //}
- }
-
+ //}
+ }
+
//EM_fgon_flags(em);
-
- MEM_freeN(inner);
+
+ MEM_freeN(inner);
}
static void fill_tri_double(EditMesh *em, EditFace *efa, struct GHash *gh, int numcuts)
@@ -1946,7 +1948,7 @@ static void fill_tri_double(EditMesh *em, EditFace *efa, struct GHash *gh, int n
EditVert *v[3], **verts[2];
EditFace *hold;
short start=0, start2=0, vertsize,i;
-
+
v[0] = efa->v1;
v[1] = efa->v2;
v[2] = efa->v3;
@@ -1966,41 +1968,41 @@ static void fill_tri_double(EditMesh *em, EditFace *efa, struct GHash *gh, int n
// the array to the correct direction
if(verts[0][0] != v[start]) {flipvertarray(verts[0],numcuts+2);}
- if(verts[1][0] != v[start2]) {flipvertarray(verts[1],numcuts+2);}
+ if(verts[1][0] != v[start2]) {flipvertarray(verts[1],numcuts+2);}
/*
We should have something like this now
- end start
- 3 2 1 0
+ end start
+ 3 2 1 0
start2 0|---*---*---|
- | /
- 1* /
- | /
- 2* /
- | /
- end2 3|
+ | /
+ 1* /
+ | /
+ 2* /
+ | /
+ end2 3|
We will fill this case like this or this depending on even or odd cuts
|---*---*---|
- | / / /
- * / /
- | / /
- * /
- | /
+ | / / /
+ * / /
+ | / /
+ * /
+ | /
|
*/
// Make outside tri
- hold = addfacelist(em, verts[0][vertsize-2],verts[0][vertsize-1],verts[1][1],NULL,NULL,NULL);
+ hold = addfacelist(em, verts[0][vertsize-2],verts[0][vertsize-1],verts[1][1],NULL,NULL,NULL);
hold->e3->f2 |= EDGEINNER;
- facecopy(em, efa,hold);
+ facecopy(em, efa,hold);
// Make side faces
for(i=0;i<numcuts;i++) {
- hold = addfacelist(em, verts[0][i],verts[0][i+1],verts[1][vertsize-1-(i+1)],verts[1][vertsize-1-i],NULL,NULL);
+ hold = addfacelist(em, verts[0][i],verts[0][i+1],verts[1][vertsize-1-(i+1)],verts[1][vertsize-1-i],NULL,NULL);
hold->e2->f2 |= EDGEINNER;
facecopy(em, efa,hold);
- }
+ }
}
static void fill_quad_triple(EditMesh *em, EditFace *efa, struct GHash *gh, int numcuts)
@@ -2009,133 +2011,133 @@ static void fill_quad_triple(EditMesh *em, EditFace *efa, struct GHash *gh, int
EditVert *v[4], **verts[3];
EditFace *hold;
short start=0, start2=0, start3=0, vertsize, i, repeats;
-
+
v[0] = efa->v1;
v[1] = efa->v2;
v[2] = efa->v3;
- v[3] = efa->v4;
-
+ v[3] = efa->v4;
+
if(!(efa->e1->f & SELECT)) {
- cedge[0] = efa->e2;
- cedge[1] = efa->e3;
+ cedge[0] = efa->e2;
+ cedge[1] = efa->e3;
cedge[2] = efa->e4;
- start = 1;start2 = 2;start3 = 3;
+ start = 1;start2 = 2;start3 = 3;
}
if(!(efa->e2->f & SELECT)) {
- cedge[0] = efa->e3;
- cedge[1] = efa->e4;
+ cedge[0] = efa->e3;
+ cedge[1] = efa->e4;
cedge[2] = efa->e1;
- start = 2;start2 = 3;start3 = 0;
+ start = 2;start2 = 3;start3 = 0;
}
if(!(efa->e3->f & SELECT)) {
- cedge[0] = efa->e4;
- cedge[1] = efa->e1;
+ cedge[0] = efa->e4;
+ cedge[1] = efa->e1;
cedge[2] = efa->e2;
- start = 3;start2 = 0;start3 = 1;
+ start = 3;start2 = 0;start3 = 1;
}
if(!(efa->e4->f & SELECT)) {
- cedge[0] = efa->e1;
- cedge[1] = efa->e2;
+ cedge[0] = efa->e1;
+ cedge[1] = efa->e2;
cedge[2] = efa->e3;
- start = 0;start2 = 1;start3 = 2;
- }
+ start = 0;start2 = 1;start3 = 2;
+ }
// Point verts[0] and [1] to the array of new verts for cedge[0] and cedge[1]
verts[0] = BLI_ghash_lookup(gh, cedge[0]);
verts[1] = BLI_ghash_lookup(gh, cedge[1]);
verts[2] = BLI_ghash_lookup(gh, cedge[2]);
//This is the index size of the verts array
vertsize = numcuts+2;
-
+
// Is the original v1 the same as the first vert on the selected edge?
// if not, the edge is running the opposite direction in this face so flip
// the array to the correct direction
-
+
if(verts[0][0] != v[start]) {flipvertarray(verts[0],numcuts+2);}
- if(verts[1][0] != v[start2]) {flipvertarray(verts[1],numcuts+2);}
- if(verts[2][0] != v[start3]) {flipvertarray(verts[2],numcuts+2);}
+ if(verts[1][0] != v[start2]) {flipvertarray(verts[1],numcuts+2);}
+ if(verts[2][0] != v[start3]) {flipvertarray(verts[2],numcuts+2);}
/*
We should have something like this now
-
- start2
- 3 2 1 0
- start3 0|---*---*---|3
+
+ start2
+ 3 2 1 0
+ start3 0|---*---*---|3
| |
1* *2
| |
- 2* *1
+ 2* *1
| |
- 3|-----------|0 start
-
- We will fill this case like this or this depending on even or odd cuts
+ 3|-----------|0 start
+
+ We will fill this case like this or this depending on even or odd cuts
there are a couple of differences. For odd cuts, there is a tri in the
middle as well as 1 quad at the bottom (not including the extra quads
- for odd cuts > 1
-
+ for odd cuts > 1
+
For even cuts, there is a quad in the middle and 2 quads on the bottom
-
+
they are numbered here for clarity
-
+
1 outer tris and bottom quads
2 inner tri or quad
3 repeating quads
-
+
|---*---*---*---|
|1/ / \ \ 1|
|/ 3 / \ 3 \|
* / 2 \ *
| / \ |
- |/ \ |
+ |/ \ |
*---------------*
| 3 |
- | |
+ | |
*---------------*
| |
- | 1 |
+ | 1 |
| |
|---------------|
-
+
|---*---*---*---*---|
- | 1/ / \ \ 1|
- | / / \ \ |
+ | 1/ / \ \ 1|
+ | / / \ \ |
|/ 3 / \ 3 \|
* / \ *
- | / \ |
- | / 2 \ |
+ | / \ |
+ | / 2 \ |
|/ \|
*-------------------*
| |
| 3 |
- | |
+ | |
*-------------------*
| |
| 1 |
- | |
+ | |
*-------------------*
| |
| 1 |
- | |
+ | |
|-------------------|
-
+
*/
// Make outside tris
- hold = addfacelist(em, verts[0][vertsize-2],verts[0][vertsize-1],verts[1][1],NULL,NULL,NULL);
+ hold = addfacelist(em, verts[0][vertsize-2],verts[0][vertsize-1],verts[1][1],NULL,NULL,NULL);
hold->e3->f2 |= EDGEINNER;
- facecopy(em, efa,hold);
- hold = addfacelist(em, verts[1][vertsize-2],verts[1][vertsize-1],verts[2][1],NULL,NULL,NULL);
+ facecopy(em, efa,hold);
+ hold = addfacelist(em, verts[1][vertsize-2],verts[1][vertsize-1],verts[2][1],NULL,NULL,NULL);
hold->e3->f2 |= EDGEINNER;
- facecopy(em, efa,hold);
+ facecopy(em, efa,hold);
// Make bottom quad
- hold = addfacelist(em, verts[0][0],verts[0][1],verts[2][vertsize-2],verts[2][vertsize-1],NULL,NULL);
+ hold = addfacelist(em, verts[0][0],verts[0][1],verts[2][vertsize-2],verts[2][vertsize-1],NULL,NULL);
hold->e2->f2 |= EDGEINNER;
- facecopy(em, efa,hold);
+ facecopy(em, efa,hold);
//If it is even cuts, add the 2nd lower quad
if(numcuts % 2 == 0) {
- hold = addfacelist(em, verts[0][1],verts[0][2],verts[2][vertsize-3],verts[2][vertsize-2],NULL,NULL);
+ hold = addfacelist(em, verts[0][1],verts[0][2],verts[2][vertsize-3],verts[2][vertsize-2],NULL,NULL);
hold->e2->f2 |= EDGEINNER;
- facecopy(em, efa,hold);
+ facecopy(em, efa,hold);
// Also Make inner quad
- hold = addfacelist(em, verts[1][numcuts/2],verts[1][(numcuts/2)+1],verts[2][numcuts/2],verts[0][(numcuts/2)+1],NULL,NULL);
+ hold = addfacelist(em, verts[1][numcuts/2],verts[1][(numcuts/2)+1],verts[2][numcuts/2],verts[0][(numcuts/2)+1],NULL,NULL);
hold->e3->f2 |= EDGEINNER;
//if(scene->toolsettings->editbutflag & B_AUTOFGON) {
// hold->e3->h |= EM_FGON;
@@ -2143,47 +2145,47 @@ static void fill_quad_triple(EditMesh *em, EditFace *efa, struct GHash *gh, int
facecopy(em, efa,hold);
repeats = (numcuts / 2) -1;
} else {
- // Make inner tri
- hold = addfacelist(em, verts[1][(numcuts/2)+1],verts[2][(numcuts/2)+1],verts[0][(numcuts/2)+1],NULL,NULL,NULL);
+ // Make inner tri
+ hold = addfacelist(em, verts[1][(numcuts/2)+1],verts[2][(numcuts/2)+1],verts[0][(numcuts/2)+1],NULL,NULL,NULL);
hold->e2->f2 |= EDGEINNER;
//if(scene->toolsettings->editbutflag & B_AUTOFGON) {
// hold->e2->h |= EM_FGON;
//}
- facecopy(em, efa,hold);
+ facecopy(em, efa,hold);
repeats = ((numcuts+1) / 2)-1;
}
-
+
// cuts for 1 and 2 do not have the repeating quads
if(numcuts < 3) {repeats = 0;}
for(i=0;i<repeats;i++) {
//Make side repeating Quads
- hold = addfacelist(em, verts[1][i+1],verts[1][i+2],verts[0][vertsize-i-3],verts[0][vertsize-i-2],NULL,NULL);
- hold->e2->f2 |= EDGEINNER;
- facecopy(em, efa,hold);
- hold = addfacelist(em, verts[1][vertsize-i-3],verts[1][vertsize-i-2],verts[2][i+1],verts[2][i+2],NULL,NULL);
+ hold = addfacelist(em, verts[1][i+1],verts[1][i+2],verts[0][vertsize-i-3],verts[0][vertsize-i-2],NULL,NULL);
+ hold->e2->f2 |= EDGEINNER;
+ facecopy(em, efa,hold);
+ hold = addfacelist(em, verts[1][vertsize-i-3],verts[1][vertsize-i-2],verts[2][i+1],verts[2][i+2],NULL,NULL);
hold->e4->f2 |= EDGEINNER;
- facecopy(em, efa,hold);
+ facecopy(em, efa,hold);
}
- // Do repeating bottom quads
+ // Do repeating bottom quads
for(i=0;i<repeats;i++) {
- if(numcuts % 2 == 1) {
- hold = addfacelist(em, verts[0][1+i],verts[0][2+i],verts[2][vertsize-3-i],verts[2][vertsize-2-i],NULL,NULL);
+ if(numcuts % 2 == 1) {
+ hold = addfacelist(em, verts[0][1+i],verts[0][2+i],verts[2][vertsize-3-i],verts[2][vertsize-2-i],NULL,NULL);
} else {
- hold = addfacelist(em, verts[0][2+i],verts[0][3+i],verts[2][vertsize-4-i],verts[2][vertsize-3-i],NULL,NULL);
+ hold = addfacelist(em, verts[0][2+i],verts[0][3+i],verts[2][vertsize-4-i],verts[2][vertsize-3-i],NULL,NULL);
}
hold->e2->f2 |= EDGEINNER;
- facecopy(em, efa,hold);
- }
+ facecopy(em, efa,hold);
+ }
//EM_fgon_flags(em);
}
static void fill_quad_quadruple(EditMesh *em, EditFace *efa, struct GHash *gh, int numcuts, float smooth, float fractal, int beauty)
{
EditVert **verts[4], ***innerverts;
- EditFace *hold;
+ EditFace *hold;
EditEdge temp;
short vertsize, i, j;
-
+
// Point verts[0] and [1] to the array of new verts for cedge[0] and cedge[1]
verts[0] = BLI_ghash_lookup(gh, efa->e1);
verts[1] = BLI_ghash_lookup(gh, efa->e2);
@@ -2198,79 +2200,79 @@ static void fill_quad_quadruple(EditMesh *em, EditFace *efa, struct GHash *gh, i
// the array to the correct direction
if(verts[0][0] != efa->v1) {flipvertarray(verts[0],numcuts+2);}
- if(verts[1][0] != efa->v2) {flipvertarray(verts[1],numcuts+2);}
+ if(verts[1][0] != efa->v2) {flipvertarray(verts[1],numcuts+2);}
if(verts[2][0] == efa->v3) {flipvertarray(verts[2],numcuts+2);}
- if(verts[3][0] == efa->v4) {flipvertarray(verts[3],numcuts+2);}
+ if(verts[3][0] == efa->v4) {flipvertarray(verts[3],numcuts+2);}
/*
We should have something like this now
1
-
- 3 2 1 0
- 0|---*---*---|0
+
+ 3 2 1 0
+ 0|---*---*---|0
| |
1* *1
2 | | 4
- 2* *2
+ 2* *2
| |
- 3|---*---*---|3
+ 3|---*---*---|3
3 2 1 0
3
// we will fill a 2 dim array of editvert*s to make filling easier
// the innervert order is shown
- 0 0---1---2---3
+ 0 0---1---2---3
| | | |
- 1 0---1---2---3
+ 1 0---1---2---3
| | | |
- 2 0---1---2---3
+ 2 0---1---2---3
| | | |
- 3 0---1---2---3
-
+ 3 0---1---2---3
+
*/
- innerverts = MEM_mallocN(sizeof(EditVert*)*(numcuts+2),"quad-quad subdiv inner verts outer array");
+ innerverts = MEM_mallocN(sizeof(EditVert*)*(numcuts+2),"quad-quad subdiv inner verts outer array");
for(i=0;i<numcuts+2;i++) {
innerverts[i] = MEM_mallocN(sizeof(EditVert*)*(numcuts+2),"quad-quad subdiv inner verts inner array");
- }
-
+ }
+
// first row is e1 last row is e3
for(i=0;i<numcuts+2;i++) {
innerverts[0][i] = verts[0][(numcuts+1)-i];
innerverts[numcuts+1][i] = verts[2][(numcuts+1)-i];
}
-
+
for(i=1;i<=numcuts;i++) {
/* we create a fake edge for the next loop */
temp.v2 = innerverts[i][0] = verts[1][i];
temp.v1 = innerverts[i][numcuts+1] = verts[3][i];
-
- for(j=1;j<=numcuts;j++) {
+
+ for(j=1;j<=numcuts;j++) {
float percent= (float)j/(float)(numcuts+1);
innerverts[i][(numcuts+1)-j]= subdivide_edge_addvert(em, &temp, smooth, fractal, beauty, percent);
- }
- }
+ }
+ }
// Fill with faces
for(i=0;i<numcuts+1;i++) {
for(j=0;j<numcuts+1;j++) {
- hold = addfacelist(em, innerverts[i][j+1],innerverts[i][j],innerverts[i+1][j],innerverts[i+1][j+1],NULL,NULL);
- hold->e1->f2 = EDGENEW;
- hold->e2->f2 = EDGENEW;
- hold->e3->f2 = EDGENEW;
- hold->e4->f2 = EDGENEW;
-
+ hold = addfacelist(em, innerverts[i][j+1],innerverts[i][j],innerverts[i+1][j],innerverts[i+1][j+1],NULL,NULL);
+ hold->e1->f2 = EDGENEW;
+ hold->e2->f2 = EDGENEW;
+ hold->e3->f2 = EDGENEW;
+ hold->e4->f2 = EDGENEW;
+
if(i != 0) { hold->e1->f2 |= EDGEINNER; }
if(j != 0) { hold->e2->f2 |= EDGEINNER; }
if(i != numcuts) { hold->e3->f2 |= EDGEINNER; }
if(j != numcuts) { hold->e4->f2 |= EDGEINNER; }
-
- facecopy(em, efa,hold);
- }
+
+ facecopy(em, efa,hold);
+ }
}
// Clean up our dynamic multi-dim array
for(i=0;i<numcuts+2;i++) {
- MEM_freeN(innerverts[i]);
- }
+ MEM_freeN(innerverts[i]);
+ }
MEM_freeN(innerverts);
}
@@ -2278,7 +2280,7 @@ static void fill_tri_triple(EditMesh *em, EditFace *efa, struct GHash *gh, int n
{
EditVert **verts[3], ***innerverts;
short vertsize, i, j;
- EditFace *hold;
+ EditFace *hold;
EditEdge temp;
// Point verts[0] and [1] to the array of new verts for cedge[0] and cedge[1]
@@ -2294,20 +2296,20 @@ static void fill_tri_triple(EditMesh *em, EditFace *efa, struct GHash *gh, int n
// the array to the correct direction
if(verts[0][0] != efa->v1) {flipvertarray(verts[0],numcuts+2);}
- if(verts[1][0] != efa->v2) {flipvertarray(verts[1],numcuts+2);}
- if(verts[2][0] != efa->v3) {flipvertarray(verts[2],numcuts+2);}
+ if(verts[1][0] != efa->v2) {flipvertarray(verts[1],numcuts+2);}
+ if(verts[2][0] != efa->v3) {flipvertarray(verts[2],numcuts+2);}
/*
We should have something like this now
3
-
- 3 2 1 0
- 0|---*---*---|3
- | /
- 1 1* *2
- | /
- 2* *1 2
- | /
- 3|/
+
+ 3 2 1 0
+ 0|---*---*---|3
+ | /
+ 1 1* *2
+ | /
+ 2* *1 2
+ | /
+ 3|/
0
we will fill a 2 dim array of editvert*s to make filling easier
@@ -2315,33 +2317,33 @@ static void fill_tri_triple(EditMesh *em, EditFace *efa, struct GHash *gh, int n
3
0 0---1---2---3---4
- | / | / |/ | /
- 1 0---1----2---3
- 1 | / | / | /
+ | / | / |/ | /
+ 1 0---1----2---3
+ 1 | / | / | /
2 0----1---2 2
- | / | /
- |/ |/
- 3 0---1
+ | / | /
+ |/ |/
+ 3 0---1
| /
|/
- 4 0
-
+ 4 0
+
*/
-
- innerverts = MEM_mallocN(sizeof(EditVert*)*(numcuts+2),"tri-tri subdiv inner verts outer array");
+
+ innerverts = MEM_mallocN(sizeof(EditVert*)*(numcuts+2),"tri-tri subdiv inner verts outer array");
for(i=0;i<numcuts+2;i++) {
innerverts[i] = MEM_mallocN(sizeof(EditVert*)*((numcuts+2)-i),"tri-tri subdiv inner verts inner array");
}
//top row is e3 backwards
for(i=0;i<numcuts+2;i++) {
innerverts[0][i] = verts[2][(numcuts+1)-i];
- }
-
+ }
+
for(i=1;i<=numcuts+1;i++) {
//fake edge, first vert is from e1, last is from e2
temp.v1= innerverts[i][0] = verts[0][i];
temp.v2= innerverts[i][(numcuts+1)-i] = verts[1][(numcuts+1)-i];
-
+
for(j=1;j<(numcuts+1)-i;j++) {
float percent= (float)j/(float)((numcuts+1)-i);
@@ -2351,32 +2353,32 @@ static void fill_tri_triple(EditMesh *em, EditFace *efa, struct GHash *gh, int n
// Now fill the verts with happy little tris :)
for(i=0;i<=numcuts+1;i++) {
- for(j=0;j<(numcuts+1)-i;j++) {
+ for(j=0;j<(numcuts+1)-i;j++) {
//We always do the first tri
- hold = addfacelist(em, innerverts[i][j+1],innerverts[i][j],innerverts[i+1][j],NULL,NULL,NULL);
- hold->e1->f2 |= EDGENEW;
- hold->e2->f2 |= EDGENEW;
- hold->e3->f2 |= EDGENEW;
+ hold = addfacelist(em, innerverts[i][j+1],innerverts[i][j],innerverts[i+1][j],NULL,NULL,NULL);
+ hold->e1->f2 |= EDGENEW;
+ hold->e2->f2 |= EDGENEW;
+ hold->e3->f2 |= EDGENEW;
if(i != 0) { hold->e1->f2 |= EDGEINNER; }
if(j != 0) { hold->e2->f2 |= EDGEINNER; }
if(j+1 != (numcuts+1)-i) {hold->e3->f2 |= EDGEINNER;}
-
- facecopy(em, efa,hold);
- //if there are more to come, we do the 2nd
+
+ facecopy(em, efa,hold);
+ //if there are more to come, we do the 2nd
if(j+1 <= numcuts-i) {
- hold = addfacelist(em, innerverts[i+1][j],innerverts[i+1][j+1],innerverts[i][j+1],NULL,NULL,NULL);
- facecopy(em, efa,hold);
- hold->e1->f2 |= EDGENEW;
- hold->e2->f2 |= EDGENEW;
- hold->e3->f2 |= EDGENEW;
+ hold = addfacelist(em, innerverts[i+1][j],innerverts[i+1][j+1],innerverts[i][j+1],NULL,NULL,NULL);
+ facecopy(em, efa,hold);
+ hold->e1->f2 |= EDGENEW;
+ hold->e2->f2 |= EDGENEW;
+ hold->e3->f2 |= EDGENEW;
}
- }
+ }
}
// Clean up our dynamic multi-dim array
for(i=0;i<numcuts+2;i++) {
- MEM_freeN(innerverts[i]);
- }
+ MEM_freeN(innerverts[i]);
+ }
MEM_freeN(innerverts);
}
@@ -2394,7 +2396,7 @@ static void fill_quad_doublevert(EditMesh *em, EditFace *efa, int v1, int v2)
| \ | | / |
--------X X--------
*/
-
+
if(v1 == 1 && v2 == 3){
hold= addfacelist(em, efa->v1, efa->v2, efa->v3, 0, efa, NULL);
hold->e1->f2 |= EDGENEW;
@@ -2402,7 +2404,7 @@ static void fill_quad_doublevert(EditMesh *em, EditFace *efa, int v1, int v2)
hold->e3->f2 |= EDGENEW;
hold->e3->f2 |= EDGEINNER;
facecopy(em, efa, hold);
-
+
hold= addfacelist(em, efa->v1, efa->v3, efa->v4, 0, efa, NULL);
hold->e1->f2 |= EDGENEW;
hold->e2->f2 |= EDGENEW;
@@ -2417,7 +2419,7 @@ static void fill_quad_doublevert(EditMesh *em, EditFace *efa, int v1, int v2)
hold->e3->f2 |= EDGENEW;
hold->e2->f2 |= EDGEINNER;
facecopy(em, efa, hold);
-
+
hold= addfacelist(em, efa->v2, efa->v3, efa->v4, 0, efa, NULL);
hold->e1->f2 |= EDGENEW;
hold->e2->f2 |= EDGENEW;
@@ -2432,17 +2434,17 @@ static void fill_quad_singlevert(EditMesh *em, EditFace *efa, struct GHash *gh)
EditEdge *cedge=NULL;
EditVert *v[4], **verts;
EditFace *hold;
- short start=0, end, left, right, vertsize;
-
+ short start=0, end, left, right, vertsize;
+
v[0] = efa->v1;
v[1] = efa->v2;
v[2] = efa->v3;
- v[3] = efa->v4;
+ v[3] = efa->v4;
if(efa->e1->f & SELECT) { cedge = efa->e1; start = 0;}
- else if(efa->e2->f & SELECT) { cedge = efa->e2; start = 1;}
- else if(efa->e3->f & SELECT) { cedge = efa->e3; start = 2;}
- else if(efa->e4->f & SELECT) { cedge = efa->e4; start = 3;}
+ else if(efa->e2->f & SELECT) { cedge = efa->e2; start = 1;}
+ else if(efa->e3->f & SELECT) { cedge = efa->e3; start = 2;}
+ else if(efa->e4->f & SELECT) { cedge = efa->e4; start = 3;}
// Point verts to the array of new verts for cedge
verts = BLI_ghash_lookup(gh, cedge);
@@ -2456,25 +2458,25 @@ static void fill_quad_singlevert(EditMesh *em, EditFace *efa, struct GHash *gh)
if(verts[0] != v[start]) {flipvertarray(verts,3);}
end = (start+1)%4;
left = (start+2)%4;
- right = (start+3)%4;
+ right = (start+3)%4;
/*
We should have something like this now
- end start
- 2 1 0
+ end start
+ 2 1 0
|-----*-----|
| |
- | |
| |
- -------------
+ | |
+ -------------
left right
where start,end,left, right are indexes of EditFace->v1, etc (stored in v)
and 0,1,2 are the indexes of the new verts stored in verts. We fill like
this, depending on whether its vertex 'left' or vertex 'right' thats
been knifed through...
-
+
|---*---| |---*---|
| / | | \ |
| / | | \ |
@@ -2490,7 +2492,7 @@ static void fill_quad_singlevert(EditMesh *em, EditFace *efa, struct GHash *gh)
hold->e3->f2 |= EDGENEW;
hold->e3->f2 |= EDGEINNER;
facecopy(em, efa, hold);
-
+
//quad is composed of cutvert, left, right and start
hold = addfacelist(em, verts[1],v[left],v[right],v[start], NULL, NULL);
hold->e1->f2 |= EDGENEW;
@@ -2517,17 +2519,17 @@ static void fill_quad_singlevert(EditMesh *em, EditFace *efa, struct GHash *gh)
hold->e4->f2 |= EDGEINNER;
facecopy(em, efa, hold);
}
-
-}
-// This function takes an example edge, the current point to create and
+}
+
+// This function takes an example edge, the current point to create and
// the total # of points to create, then creates the point and return the
// editvert pointer to it.
static EditVert *subdivideedgenum(EditMesh *em, EditEdge *edge, int curpoint, int totpoint, float smooth, float fractal, int beauty)
{
EditVert *ev;
float percent;
-
+
if (beauty & (B_PERCENTSUBD) && totpoint == 1)
//percent=(float)(edge->tmp.l)/32768.0f;
percent= edge->tmp.fp;
@@ -2536,7 +2538,7 @@ static EditVert *subdivideedgenum(EditMesh *em, EditEdge *edge, int curpoint, in
ev= subdivide_edge_addvert(em, edge, smooth, fractal, beauty, percent);
ev->f = edge->v1->f;
-
+
return ev;
}
@@ -2550,7 +2552,7 @@ void esubdivideflag(Object *obedit, EditMesh *em, int flag, float smooth, float
int i, j, edgecount, touchcount, facetype,hold;
ModifierData *md= obedit->modifiers.first;
int ctrl= 0; // XXX
-
+
//Set faces f1 to 0 cause we need it later
for(ef=em->faces.first;ef;ef = ef->next) ef->f1 = 0;
for(eve=em->verts.first; eve; eve=eve->next) {
@@ -2561,8 +2563,8 @@ void esubdivideflag(Object *obedit, EditMesh *em, int flag, float smooth, float
for (; md; md=md->next) {
if (md->type==eModifierType_Mirror) {
- MirrorModifierData *mmd = (MirrorModifierData*) md;
-
+ MirrorModifierData *mmd = (MirrorModifierData*) md;
+
if(mmd->flag & MOD_MIR_CLIPPING) {
for (eve= em->verts.first; eve; eve= eve->next) {
eve->f2= 0;
@@ -2584,23 +2586,23 @@ void esubdivideflag(Object *obedit, EditMesh *em, int flag, float smooth, float
}
}
}
-
+
//Flush vertex flags upward to the edges
for(eed = em->edges.first;eed;eed = eed->next) {
//if(eed->f & flag && eed->v1->f == eed->v2->f) {
- // eed->f |= eed->v1->f;
+ // eed->f |= eed->v1->f;
// }
- eed->f2 = 0;
+ eed->f2 = 0;
if(eed->f & flag) {
eed->f2 |= EDGEOLD;
}
}
-
+
// We store an array of verts for each edge that is subdivided,
// we put this array as a value in a ghash which is keyed by the EditEdge*
// Now for beauty subdivide deselect edges based on length
- if(beauty & B_BEAUTY) {
+ if(beauty & B_BEAUTY) {
for(ef = em->faces.first;ef;ef = ef->next) {
if(!ef->v4) {
continue;
@@ -2609,12 +2611,12 @@ void esubdivideflag(Object *obedit, EditMesh *em, int flag, float smooth, float
VECCOPY(v1mat, ef->v1->co);
VECCOPY(v2mat, ef->v2->co);
VECCOPY(v3mat, ef->v3->co);
- VECCOPY(v4mat, ef->v4->co);
+ VECCOPY(v4mat, ef->v4->co);
Mat4Mul3Vecfl(obedit->obmat, v1mat);
- Mat4Mul3Vecfl(obedit->obmat, v2mat);
+ Mat4Mul3Vecfl(obedit->obmat, v2mat);
Mat4Mul3Vecfl(obedit->obmat, v3mat);
Mat4Mul3Vecfl(obedit->obmat, v4mat);
-
+
length[0] = VecLenf(v1mat, v2mat);
length[1] = VecLenf(v2mat, v3mat);
length[2] = VecLenf(v3mat, v4mat);
@@ -2623,20 +2625,20 @@ void esubdivideflag(Object *obedit, EditMesh *em, int flag, float smooth, float
sort[1] = ef->e2;
sort[2] = ef->e3;
sort[3] = ef->e4;
-
-
+
+
// Beauty Short Edges
if(beauty & B_BEAUTY_SHORT) {
for(j=0;j<2;j++) {
hold = -1;
for(i=0;i<4;i++) {
if(length[i] < 0) {
- continue;
- } else if(hold == -1) {
- hold = i;
+ continue;
+ } else if(hold == -1) {
+ hold = i;
} else {
if(length[hold] < length[i]) {
- hold = i;
+ hold = i;
}
}
}
@@ -2647,19 +2649,19 @@ void esubdivideflag(Object *obedit, EditMesh *em, int flag, float smooth, float
}
}
}
-
+
// Beauty Long Edges
else {
for(j=0;j<2;j++) {
hold = -1;
for(i=0;i<4;i++) {
if(length[i] < 0) {
- continue;
- } else if(hold == -1) {
- hold = i;
+ continue;
+ } else if(hold == -1) {
+ hold = i;
} else {
if(length[hold] > length[i]) {
- hold = i;
+ hold = i;
}
}
}
@@ -2674,18 +2676,18 @@ void esubdivideflag(Object *obedit, EditMesh *em, int flag, float smooth, float
}
}
- gh = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp);
+ gh = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp);
// If we are knifing, We only need the selected edges that were cut, so deselect if it was not cut
- if(beauty & B_KNIFE) {
- for(eed= em->edges.first;eed;eed=eed->next) {
+ if(beauty & B_KNIFE) {
+ for(eed= em->edges.first;eed;eed=eed->next) {
if( eed->tmp.fp == 0 ) {
EM_select_edge(eed,0);
}
}
- }
+ }
// So for each edge, if it is selected, we allocate an array of size cuts+2
- // so we can have a place for the v1, the new verts and v2
+ // so we can have a place for the v1, the new verts and v2
for(eed=em->edges.first;eed;eed = eed->next) {
if(eed->f & flag) {
templist = MEM_mallocN(sizeof(EditVert*)*(numcuts+2),"vertlist");
@@ -2703,9 +2705,9 @@ void esubdivideflag(Object *obedit, EditMesh *em, int flag, float smooth, float
//Do the last edge too
cedge = addedgelist(em, templist[i],templist[i+1],eed);
cedge->f2 = EDGENEW;
- // Now that the edge is subdivided, we can put its verts in the ghash
- BLI_ghash_insert(gh, eed, templist);
- }
+ // Now that the edge is subdivided, we can put its verts in the ghash
+ BLI_ghash_insert(gh, eed, templist);
+ }
}
// DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
@@ -2720,7 +2722,7 @@ void esubdivideflag(Object *obedit, EditMesh *em, int flag, float smooth, float
if(ef->v4) {
facetype = 4;
if(ef->e4->f & flag) {edgecount++;}
- }
+ }
if(facetype == 4) {
switch(edgecount) {
case 0:
@@ -2732,9 +2734,9 @@ void esubdivideflag(Object *obedit, EditMesh *em, int flag, float smooth, float
if(ef->v3->f1) touchcount++;
if(ef->v4->f1) touchcount++;
if(touchcount == 2){
- if(ef->v1->f1 && ef->v3->f1){
+ if(ef->v1->f1 && ef->v3->f1){
ef->f1 = SELECT;
- fill_quad_doublevert(em, ef, 1, 3);
+ fill_quad_doublevert(em, ef, 1, 3);
}
else if(ef->v2->f1 && ef->v4->f1){
ef->f1 = SELECT;
@@ -2742,9 +2744,9 @@ void esubdivideflag(Object *obedit, EditMesh *em, int flag, float smooth, float
}
}
}
- break;
-
- case 1:
+ break;
+
+ case 1:
if(beauty & B_KNIFE && numcuts == 1){
/*Test for when knifing through an edge and one vert*/
touchcount = 0;
@@ -2752,14 +2754,14 @@ void esubdivideflag(Object *obedit, EditMesh *em, int flag, float smooth, float
if(ef->v2->f1) touchcount++;
if(ef->v3->f1) touchcount++;
if(ef->v4->f1) touchcount++;
-
+
if(touchcount == 1){
if( (ef->e1->f & flag && ( !ef->e1->v1->f1 && !ef->e1->v2->f1 )) ||
(ef->e2->f & flag && ( !ef->e2->v1->f1 && !ef->e2->v2->f1 )) ||
(ef->e3->f & flag && ( !ef->e3->v1->f1 && !ef->e3->v2->f1 )) ||
(ef->e4->f & flag && ( !ef->e4->v1->f1 && !ef->e4->v2->f1 )) ){
-
- ef->f1 = SELECT;
+
+ ef->f1 = SELECT;
fill_quad_singlevert(em, ef, gh);
}
else{
@@ -2767,64 +2769,64 @@ void esubdivideflag(Object *obedit, EditMesh *em, int flag, float smooth, float
fill_quad_single(em, ef, gh, numcuts, seltype);
}
}
- else{
- ef->f1 = SELECT;
+ else{
+ ef->f1 = SELECT;
fill_quad_single(em, ef, gh, numcuts, seltype);
}
}
- else{
+ else{
ef->f1 = SELECT;
fill_quad_single(em, ef, gh, numcuts, seltype);
}
- break;
+ break;
case 2: ef->f1 = SELECT;
// if there are 2, we check if edge 1 and 3 are either both on or off that way
// we can tell if the selected pair is Adjacent or Opposite of each other
- if((ef->e1->f & flag && ef->e3->f & flag) ||
+ if((ef->e1->f & flag && ef->e3->f & flag) ||
(ef->e2->f & flag && ef->e4->f & flag)) {
- fill_quad_double_op(em, ef, gh, numcuts);
+ fill_quad_double_op(em, ef, gh, numcuts);
}else{
switch(0) { // XXX scene->toolsettings->cornertype) {
case 0: fill_quad_double_adj_path(em, ef, gh, numcuts); break;
case 1: fill_quad_double_adj_inner(em, ef, gh, numcuts); break;
case 2: fill_quad_double_adj_fan(em, ef, gh, numcuts); break;
}
-
+
}
- break;
+ break;
case 3: ef->f1 = SELECT;
- fill_quad_triple(em, ef, gh, numcuts);
- break;
+ fill_quad_triple(em, ef, gh, numcuts);
+ break;
case 4: ef->f1 = SELECT;
- fill_quad_quadruple(em, ef, gh, numcuts, smooth, fractal, beauty);
- break;
+ fill_quad_quadruple(em, ef, gh, numcuts, smooth, fractal, beauty);
+ break;
}
} else {
switch(edgecount) {
case 0: break;
case 1: ef->f1 = SELECT;
fill_tri_single(em, ef, gh, numcuts, seltype);
- break;
+ break;
case 2: ef->f1 = SELECT;
fill_tri_double(em, ef, gh, numcuts);
- break;
+ break;
case 3: ef->f1 = SELECT;
fill_tri_triple(em, ef, gh, numcuts, smooth, fractal, beauty);
- break;
- }
- }
+ break;
+ }
+ }
}
-
+
// Delete Old Edges and Faces
for(eed = em->edges.first;eed;eed = eed->next) {
if(BLI_ghash_haskey(gh,eed)) {
- eed->f1 = SELECT;
+ eed->f1 = SELECT;
} else {
- eed->f1 = 0;
+ eed->f1 = 0;
}
- }
- free_tagged_edges_faces(em, em->edges.first, em->faces.first);
-
+ }
+ free_tagged_edges_faces(em, em->edges.first, em->faces.first);
+
if(seltype == SUBDIV_SELECT_ORIG && !ctrl) {
/* bugfix: vertex could get flagged as "not-selected"
// solution: clear flags before, not at the same time as setting SELECT flag -dg
@@ -2832,7 +2834,7 @@ void esubdivideflag(Object *obedit, EditMesh *em, int flag, float smooth, float
for(eed = em->edges.first;eed;eed = eed->next) {
if(!(eed->f2 & EDGENEW || eed->f2 & EDGEOLD)) {
eed->f &= !flag;
- EM_select_edge(eed,0);
+ EM_select_edge(eed,0);
}
}
for(eed = em->edges.first;eed;eed = eed->next) {
@@ -2845,14 +2847,14 @@ void esubdivideflag(Object *obedit, EditMesh *em, int flag, float smooth, float
for(eed = em->edges.first;eed;eed = eed->next) {
if(eed->f2 & EDGEINNER) {
eed->f |= flag;
- EM_select_edge(eed,1);
+ EM_select_edge(eed,1);
if(eed->v1->f & EDGEINNER) eed->v1->f |= SELECT;
if(eed->v2->f & EDGEINNER) eed->v2->f |= SELECT;
}else{
eed->f &= !flag;
- EM_select_edge(eed,0);
+ EM_select_edge(eed,0);
}
- }
+ }
} else if(seltype == SUBDIV_SELECT_LOOPCUT){
for(eed = em->edges.first;eed;eed = eed->next) {
if(eed->f2 & DOUBLEOPFILL){
@@ -2863,16 +2865,16 @@ void esubdivideflag(Object *obedit, EditMesh *em, int flag, float smooth, float
EM_select_edge(eed,0);
}
}
- }
+ }
if(em->selectmode & SCE_SELECT_VERTEX) {
for(eed = em->edges.first;eed;eed = eed->next) {
if(eed->f & SELECT) {
eed->v1->f |= SELECT;
eed->v2->f |= SELECT;
}
- }
+ }
}
-
+
//fix hide flags for edges. First pass, hide edges of hidden faces
for(ef=em->faces.first; ef; ef=ef->next){
if(ef->h){
@@ -2891,25 +2893,25 @@ void esubdivideflag(Object *obedit, EditMesh *em, int flag, float smooth, float
if(ef->e4) ef->e4->h &= ~1;
}
}
-
- // Free the ghash and call MEM_freeN on all the value entries to return
+
+ // Free the ghash and call MEM_freeN on all the value entries to return
// that memory
- BLI_ghash_free(gh, NULL, (GHashValFreeFP)MEM_freeN);
-
+ BLI_ghash_free(gh, NULL, (GHashValFreeFP)MEM_freeN);
+
EM_selectmode_flush(em);
for(ef=em->faces.first;ef;ef = ef->next) {
if(ef->e4) {
if( (ef->e1->f & SELECT && ef->e2->f & SELECT) &&
(ef->e3->f & SELECT && ef->e4->f & SELECT) ) {
- ef->f |= SELECT;
- }
+ ef->f |= SELECT;
+ }
} else {
if( (ef->e1->f & SELECT && ef->e2->f & SELECT) && ef->e3->f & SELECT) {
- ef->f |= SELECT;
+ ef->f |= SELECT;
}
}
}
-
+
recalc_editnormals(em);
}
@@ -2948,15 +2950,15 @@ static int collect_quadedges(EVPTuple *efaa, EditEdge *eed, EditFace *efa)
i++;
}
else eed->tmp.p = NULL;
-
+
eed= eed->next;
}
-
-
+
+
/* find edges pointing to 2 faces by procedure:
-
+
- run through faces and their edges, increase
- face counter e->f1 for each face
+ face counter e->f1 for each face
*/
while(efa) {
@@ -3001,20 +3003,20 @@ static int collect_quadedges(EVPTuple *efaa, EditEdge *eed, EditFace *efa)
}
-/* returns vertices of two adjacent triangles forming a quad
+/* returns vertices of two adjacent triangles forming a quad
- can be righthand or lefthand
4-----3
|\ |
| \ 2 | <- efa1
- | \ |
- efa-> | 1 \ |
- | \|
+ | \ |
+ efa-> | 1 \ |
+ | \|
1-----2
*/
#define VTEST(face, num, other) \
- (face->v##num != other->v1 && face->v##num != other->v2 && face->v##num != other->v3)
+ (face->v##num != other->v1 && face->v##num != other->v2 && face->v##num != other->v3)
static void givequadverts(EditFace *efa, EditFace *efa1, EditVert **v1, EditVert **v2, EditVert **v3, EditVert **v4, int *vindex)
{
@@ -3036,7 +3038,7 @@ static void givequadverts(EditFace *efa, EditFace *efa1, EditVert **v1, EditVert
vindex[0]= 2;
vindex[1]= 0;
}
-
+
if VTEST(efa1, 1, efa) {
*v3= efa1->v1;
*v4= efa1->v2;
@@ -3093,65 +3095,65 @@ static void free_tagged_edges_faces(EditMesh *em, EditEdge *eed, EditFace *efa)
free_editedge(em, eed);
}
eed= nexted;
- }
-}
+ }
+}
/* ******************** BEGIN TRIANGLE TO QUAD ************************************* */
static float measure_facepair(EditVert *v1, EditVert *v2, EditVert *v3, EditVert *v4, float limit)
{
-
+
/*gives a 'weight' to a pair of triangles that join an edge to decide how good a join they would make*/
/*Note: this is more complicated than it needs to be and should be cleaned up...*/
float measure = 0.0, noA1[3], noA2[3], noB1[3], noB2[3], normalADiff, normalBDiff,
edgeVec1[3], edgeVec2[3], edgeVec3[3], edgeVec4[3], diff,
minarea, maxarea, areaA, areaB;
-
+
/*First Test: Normal difference*/
CalcNormFloat(v1->co, v2->co, v3->co, noA1);
CalcNormFloat(v1->co, v3->co, v4->co, noA2);
-
+
if(noA1[0] == noA2[0] && noA1[1] == noA2[1] && noA1[2] == noA2[2]) normalADiff = 0.0;
else normalADiff = VecAngle2(noA1, noA2);
//if(!normalADiff) normalADiff = 179;
CalcNormFloat(v2->co, v3->co, v4->co, noB1);
CalcNormFloat(v4->co, v1->co, v2->co, noB2);
-
+
if(noB1[0] == noB2[0] && noB1[1] == noB2[1] && noB1[2] == noB2[2]) normalBDiff = 0.0;
else normalBDiff = VecAngle2(noB1, noB2);
//if(!normalBDiff) normalBDiff = 179;
-
+
measure += (normalADiff/360) + (normalBDiff/360);
if(measure > limit) return measure;
-
+
/*Second test: Colinearity*/
VecSubf(edgeVec1, v1->co, v2->co);
VecSubf(edgeVec2, v2->co, v3->co);
VecSubf(edgeVec3, v3->co, v4->co);
VecSubf(edgeVec4, v4->co, v1->co);
-
+
diff = 0.0;
-
+
diff = (
fabs(VecAngle2(edgeVec1, edgeVec2) - 90) +
- fabs(VecAngle2(edgeVec2, edgeVec3) - 90) +
- fabs(VecAngle2(edgeVec3, edgeVec4) - 90) +
+ fabs(VecAngle2(edgeVec2, edgeVec3) - 90) +
+ fabs(VecAngle2(edgeVec3, edgeVec4) - 90) +
fabs(VecAngle2(edgeVec4, edgeVec1) - 90)) / 360;
if(!diff) return 0.0;
-
+
measure += diff;
if(measure > limit) return measure;
/*Third test: Concavity*/
areaA = AreaT3Dfl(v1->co, v2->co, v3->co) + AreaT3Dfl(v1->co, v3->co, v4->co);
areaB = AreaT3Dfl(v2->co, v3->co, v4->co) + AreaT3Dfl(v4->co, v1->co, v2->co);
-
+
if(areaA <= areaB) minarea = areaA;
else minarea = areaB;
-
+
if(areaA >= areaB) maxarea = areaA;
else maxarea = areaB;
-
+
if(!maxarea) measure += 1;
else measure += (1 - (minarea / maxarea));
@@ -3160,38 +3162,38 @@ static float measure_facepair(EditVert *v1, EditVert *v2, EditVert *v3, EditVert
#define T2QUV_LIMIT 0.005
#define T2QCOL_LIMIT 3
-static int compareFaceAttribs(EditMesh *em, EditFace *f1, EditFace *f2, EditEdge *eed)
+static int compareFaceAttribs(EditMesh *em, EditFace *f1, EditFace *f2, EditEdge *eed)
{
- /*Test to see if the per-face attributes for the joining edge match within limit*/
+ /*Test to see if the per-face attributes for the joining edge match within limit*/
MTFace *tf1, *tf2;
unsigned int *col1, *col2;
short i,attrok=0, flag = 0, /* XXX scene->toolsettings->editbutflag,*/ fe1[2], fe2[2];
-
+
tf1 = CustomData_em_get(&em->fdata, f1->data, CD_MTFACE);
tf2 = CustomData_em_get(&em->fdata, f2->data, CD_MTFACE);
col1 = CustomData_em_get(&em->fdata, f1->data, CD_MCOL);
col2 = CustomData_em_get(&em->fdata, f2->data, CD_MCOL);
-
+
/*store indices for faceedges*/
f1->v1->f1 = 0;
f1->v2->f1 = 1;
f1->v3->f1 = 2;
-
+
fe1[0] = eed->v1->f1;
fe1[1] = eed->v2->f1;
-
+
f2->v1->f1 = 0;
f2->v2->f1 = 1;
f2->v3->f1 = 2;
-
+
fe2[0] = eed->v1->f1;
fe2[1] = eed->v2->f1;
-
+
/*compare faceedges for each face attribute. Additional per face attributes can be added later*/
/*do UVs*/
if(flag & B_JOINTRIA_UV){
-
+
if(tf1 == NULL || tf2 == NULL) attrok |= B_JOINTRIA_UV;
else if(tf1->tpage != tf2->tpage); /*do nothing*/
else{
@@ -3201,7 +3203,7 @@ static int compareFaceAttribs(EditMesh *em, EditFace *f1, EditFace *f2, EditEdge
}
}
}
-
+
/*do VCOLs*/
if(flag & B_JOINTRIA_VCOL){
if(!col1 || !col2) attrok |= B_JOINTRIA_VCOL;
@@ -3210,7 +3212,7 @@ static int compareFaceAttribs(EditMesh *em, EditFace *f1, EditFace *f2, EditEdge
for(i = 0; i < 2; i++){
f1vcol = (char *)&(col1[fe1[i]]);
f2vcol = (char *)&(col2[fe2[i]]);
-
+
/*compare f1vcol with f2vcol*/
if( f1vcol[1] + T2QCOL_LIMIT > f2vcol[1] && f1vcol[1] - T2QCOL_LIMIT < f2vcol[1] &&
f1vcol[2] + T2QCOL_LIMIT > f2vcol[2] && f1vcol[2] - T2QCOL_LIMIT < f2vcol[2] &&
@@ -3218,18 +3220,18 @@ static int compareFaceAttribs(EditMesh *em, EditFace *f1, EditFace *f2, EditEdge
}
}
}
-
+
if( ((attrok & B_JOINTRIA_UV) == (flag & B_JOINTRIA_UV)) && ((attrok & B_JOINTRIA_VCOL) == (flag & B_JOINTRIA_VCOL)) ) return 1;
return 0;
-}
-
+}
+
static int fplcmp(const void *v1, const void *v2)
{
const EditEdge *e1= *((EditEdge**)v1), *e2=*((EditEdge**)v2);
-
+
if( e1->crease > e2->crease) return 1;
else if( e1->crease < e2->crease) return -1;
-
+
return 0;
}
@@ -3248,21 +3250,21 @@ void join_triangles(EditMesh *em)
float measure; /*Used to set tolerance*/
float limit = 0.0f; // XXX scene->toolsettings->jointrilimit;
int i, ok, totedge=0, totseledge=0, complexedges, vindex[4];
-
+
/*if we take a long time on very dense meshes we want waitcursor to display*/
waitcursor(1);
-
+
totseledge = count_selected_edges(em->edges.first);
if(totseledge==0) return;
-
+
/*abusing crease value to store weights for edge pairs. Nasty*/
for(eed=em->edges.first; eed; eed=eed->next) totedge++;
- if(totedge) creases = MEM_callocN(sizeof(float) * totedge, "Join Triangles Crease Array");
+ if(totedge) creases = MEM_callocN(sizeof(float) * totedge, "Join Triangles Crease Array");
for(eed=em->edges.first, i = 0; eed; eed=eed->next, i++){
- creases[i] = eed->crease;
+ creases[i] = eed->crease;
eed->crease = 0.0;
}
-
+
/*clear temp flags*/
for(eve=em->verts.first; eve; eve=eve->next) eve->f1 = eve->f2 = 0;
for(eed=em->edges.first; eed; eed=eed->next) eed->f2 = eed->f1 = 0;
@@ -3272,11 +3274,11 @@ void join_triangles(EditMesh *em)
efaar= (EVPTuple *) MEM_callocN(totseledge * sizeof(EVPTuple), "Tri2Quad");
ok = collect_quadedges(efaar, em->edges.first, em->faces.first);
complexedges = 0;
-
+
if(ok){
-
-
- /*clear tmp.l flag and store number of faces that are selected and coincident to current face here.*/
+
+
+ /*clear tmp.l flag and store number of faces that are selected and coincident to current face here.*/
for(eed=em->edges.first; eed; eed=eed->next){
/* eed->f2 is 2 only if this edge is part of exactly two
triangles, and both are selected, and it has EVPTuple assigned */
@@ -3286,7 +3288,7 @@ void join_triangles(EditMesh *em)
efaa[1]->tmp.l++;
}
}
-
+
for(eed=em->edges.first; eed; eed=eed->next){
if(eed->f2 == 2){
efaa= (EVPtr *) eed->tmp.p;
@@ -3299,30 +3301,30 @@ void join_triangles(EditMesh *em)
efaa[0]->f1 = 1; //mark for join
efaa[1]->f1 = 1; //mark for join
}
- else{
-
+ else{
+
/* The face pair is part of a 'complex' island, so the rules for dealing with it are more involved.
Depending on what options the user has chosen, this face pair can be 'thrown out' based upon the following criteria:
-
+
1: the two faces do not share the same material
2: the edge joining the two faces is marked as sharp.
3: the two faces UV's do not make a good match
4: the two faces Vertex colors do not make a good match
-
+
If the face pair passes all the applicable tests, it is then given a 'weight' with the measure_facepair() function.
This measures things like concavity, colinearity ect. If this weight is below the threshold set by the user
the edge joining them is marked as being 'complex' and will be compared against other possible pairs which contain one of the
same faces in the current pair later.
-
+
This technique is based upon an algorithm that Campbell Barton developed for his Tri2Quad script that was previously part of
the python scripts bundled with Blender releases.
*/
-
+
// XXX if(scene->toolsettings->editbutflag & B_JOINTRIA_SHARP && eed->sharp); /*do nothing*/
// else if(scene->toolsettings->editbutflag & B_JOINTRIA_MAT && efaa[0]->mat_nr != efaa[1]->mat_nr); /*do nothing*/
// else if(((scene->toolsettings->editbutflag & B_JOINTRIA_UV) || (scene->toolsettings->editbutflag & B_JOINTRIA_VCOL)) &&
compareFaceAttribs(em, efaa[0], efaa[1], eed); // XXX == 0); /*do nothing*/
-// else{
+// else{
measure = measure_facepair(v1, v2, v3, v4, limit);
if(measure < limit){
complexedges++;
@@ -3334,7 +3336,7 @@ void join_triangles(EditMesh *em)
}
}
}
-
+
/*Quicksort the complex edges according to their weighting*/
if(complexedges){
edsortblock = edb = MEM_callocN(sizeof(EditEdge*) * complexedges, "Face Pairs quicksort Array");
@@ -3346,7 +3348,7 @@ void join_triangles(EditMesh *em)
}
qsort(edsortblock, complexedges, sizeof(EditEdge*), fplcmp);
/*now go through and mark the edges who get the highest weighting*/
- for(edb=edsortblock, i=0; i < complexedges; edb++, i++){
+ for(edb=edsortblock, i=0; i < complexedges; edb++, i++){
efaa = (EVPtr *)((*edb)->tmp.p); /*suspect!*/
if( !efaa[0]->f1 && !efaa[1]->f1){
efaa[0]->f1 = 1; //mark for join
@@ -3355,8 +3357,8 @@ void join_triangles(EditMesh *em)
}
}
}
-
- /*finally go through all edges marked for join (simple and complex) and create new faces*/
+
+ /*finally go through all edges marked for join (simple and complex) and create new faces*/
for(eed=em->edges.first; eed; eed=eed->next){
if(eed->f1 & T2QJOIN){
efaa= (EVPtr *)eed->tmp.p;
@@ -3376,10 +3378,10 @@ void join_triangles(EditMesh *em)
}
}
}
-
+
/*free data and cleanup*/
if(creases){
- for(eed=em->edges.first, i = 0; eed; eed=eed->next, i++) eed->crease = creases[i];
+ for(eed=em->edges.first, i = 0; eed; eed=eed->next, i++) eed->crease = creases[i];
MEM_freeN(creases);
}
for(eed=em->edges.first; eed; eed=eed->next){
@@ -3389,7 +3391,7 @@ void join_triangles(EditMesh *em)
free_tagged_edges_faces(em, em->edges.first, em->faces.first);
if(efaar) MEM_freeN(efaar);
if(edsortblock) MEM_freeN(edsortblock);
-
+
EM_selectmode_flush(em);
}
@@ -3407,7 +3409,7 @@ void edge_flip(EditMesh *em)
EVPTuple *efaar;
EVPtr *efaa;
int totedge, ok, vindex[4];
-
+
/* - all selected edges with two faces
* - find the faces: store them in edges (using datablock)
* - per edge: - test convex
@@ -3415,7 +3417,7 @@ void edge_flip(EditMesh *em)
- if true: remedge, addedge, all edges at the edge get new face pointers
*/
- EM_selectmode_flush(em); // makes sure in selectmode 'face' the edges of selected faces are selected too
+ EM_selectmode_flush(em); // makes sure in selectmode 'face' the edges of selected faces are selected too
totedge = count_selected_edges(em->edges.first);
if(totedge==0) return;
@@ -3424,15 +3426,15 @@ void edge_flip(EditMesh *em)
efaar= (EVPTuple *) MEM_callocN(totedge * sizeof(EVPTuple), "edgeflip");
ok = collect_quadedges(efaar, em->edges.first, em->faces.first);
-
+
eed= em->edges.first;
while(eed) {
nexted= eed->next;
-
+
if(eed->f2==2) { /* points to 2 faces */
-
+
efaa= (EVPtr *) eed->tmp.p;
-
+
/* don't do it if flagged */
ok= 1;
@@ -3440,7 +3442,7 @@ void edge_flip(EditMesh *em)
if(efa->e1->f1 || efa->e2->f1 || efa->e3->f1) ok= 0;
efa= efaa[1];
if(efa->e1->f1 || efa->e2->f1 || efa->e3->f1) ok= 0;
-
+
if(ok) {
/* test convex */
givequadverts(efaa[0], efaa[1], &v1, &v2, &v3, &v4, vindex);
@@ -3449,8 +3451,8 @@ void edge_flip(EditMesh *em)
4-----3 4-----3
|\ | | /|
| \ 1 | | 1 / |
- | \ | -> | / |
- | 0 \ | | / 0 |
+ | \ | -> | / |
+ | 0 \ | | / 0 |
| \| |/ |
1-----2 1-----2
*/
@@ -3458,7 +3460,7 @@ void edge_flip(EditMesh *em)
if (v1 && v2 && v3) {
if( convex(v1->co, v2->co, v3->co, v4->co) ) {
if(exist_face(em, v1, v2, v3, v4)==0) {
- /* outch this may break seams */
+ /* outch this may break seams */
w= EM_face_from_faces(em, efaa[0], efaa[1], vindex[0],
vindex[1], 4+vindex[2], -1);
@@ -3473,8 +3475,8 @@ void edge_flip(EditMesh *em)
/* tag as to-be-removed */
FACE_MARKCLEAR(efaa[1]);
FACE_MARKCLEAR(efaa[0]);
- eed->f1 = 1;
-
+ eed->f1 = 1;
+
} /* endif test convex */
}
}
@@ -3484,7 +3486,7 @@ void edge_flip(EditMesh *em)
/* clear tagged edges and faces: */
free_tagged_edges_faces(em, em->edges.first, em->faces.first);
-
+
MEM_freeN(efaar);
}
@@ -3511,7 +3513,7 @@ static void edge_rotate(EditMesh *em, wmOperator *op, EditEdge *eed, int dir)
EditEdge **edges[2], **hiddenedges, *srchedge;
int facecount, p1, p2, p3, p4, fac1, fac2, i, j;
int numhidden, numshared, p[2][4];
-
+
/* check to make sure that the edge is only part of 2 faces */
facecount = 0;
for(efa = em->faces.first;efa;efa = efa->next) {
@@ -3526,7 +3528,7 @@ static void edge_rotate(EditMesh *em, wmOperator *op, EditEdge *eed, int dir)
}
}
}
-
+
if(facecount < 2)
return;
@@ -3536,7 +3538,7 @@ static void edge_rotate(EditMesh *em, wmOperator *op, EditEdge *eed, int dir)
if(face[1]->e4) fac2= 4;
else fac2= 3;
-
+
/* make a handy array for verts and edges */
verts[0]= &face[0]->v1;
edges[0]= &face[0]->e1;
@@ -3552,7 +3554,7 @@ static void edge_rotate(EditMesh *em, wmOperator *op, EditEdge *eed, int dir)
if(numshared > 1)
return;
-
+
/* we want to construct an array of vertex indicis in both faces, starting at
the last vertex of the edge being rotated.
- first we find the two vertices that lie on the rotating edge
@@ -3566,12 +3568,12 @@ static void edge_rotate(EditMesh *em, wmOperator *op, EditEdge *eed, int dir)
if(eed->v1 == verts[1][i]) p3 = i;
if(eed->v2 == verts[1][i]) p4 = i;
}
-
+
if((p1+1)%fac1 == p2)
SWAP(int, p1, p2);
if((p3+1)%fac2 == p4)
SWAP(int, p3, p4);
-
+
for (i = 0; i < 4; i++) {
p[0][i]= (p1 + i)%fac1;
p[1][i]= (p3 + i)%fac2;
@@ -3586,7 +3588,7 @@ static void edge_rotate(EditMesh *em, wmOperator *op, EditEdge *eed, int dir)
hiddenedges = MEM_mallocN(sizeof(EditVert*)*numhidden+1, "RotateEdgeHiddenVerts");
if(!hiddenedges) {
BKE_report(op->reports, RPT_ERROR, "Memory allocation failed");
- return;
+ return;
}
numhidden = 0;
@@ -3608,9 +3610,9 @@ static void edge_rotate(EditMesh *em, wmOperator *op, EditEdge *eed, int dir)
} else if (dir == DIRECTION_CCW) {
newFace[0]= EM_face_from_faces(em, face[0], face[1], p[0][2], 4+p[1][1], p[0][0], p[0][1]);
newFace[1]= EM_face_from_faces(em, face[1], face[0], 4+p[0][2], p[1][0], p[1][1], -1);
-
+
verts[0][p[0][2]]->f |= SELECT;
- verts[1][p[1][1]]->f |= SELECT;
+ verts[1][p[1][1]]->f |= SELECT;
}
}
else if(fac1 == 3 && fac2 == 4) {
@@ -3620,11 +3622,11 @@ static void edge_rotate(EditMesh *em, wmOperator *op, EditEdge *eed, int dir)
} else if (dir == DIRECTION_CCW) {
newFace[0]= EM_face_from_faces(em, face[0], face[1], p[0][0], p[0][1], 4+p[1][2], -1);
newFace[1]= EM_face_from_faces(em, face[1], face[0], p[1][1], p[1][2], 4+p[0][1], 4+p[0][2]);
-
+
verts[0][p[0][1]]->f |= SELECT;
- verts[1][p[1][2]]->f |= SELECT;
+ verts[1][p[1][2]]->f |= SELECT;
}
-
+
}
else if(fac1 == 4 && fac2 == 4) {
if(dir == DIRECTION_CW) {
@@ -3633,11 +3635,11 @@ static void edge_rotate(EditMesh *em, wmOperator *op, EditEdge *eed, int dir)
} else if (dir == DIRECTION_CCW) {
newFace[0]= EM_face_from_faces(em, face[0], face[1], p[0][2], p[0][3], 4+p[1][1], 4+p[1][2]);
newFace[1]= EM_face_from_faces(em, face[1], face[0], p[1][2], p[1][3], 4+p[0][1], 4+p[0][2]);
-
+
verts[0][p[0][2]]->f |= SELECT;
- verts[1][p[1][2]]->f |= SELECT;
+ verts[1][p[1][2]]->f |= SELECT;
}
- }
+ }
else
return; /* This should never happen */
@@ -3645,7 +3647,7 @@ static void edge_rotate(EditMesh *em, wmOperator *op, EditEdge *eed, int dir)
verts[0][p[0][1]]->f |= SELECT;
verts[1][p[1][1]]->f |= SELECT;
}
-
+
/* copy old edge's flags to new center edge*/
for(srchedge=em->edges.first;srchedge;srchedge=srchedge->next) {
if((srchedge->v1->f & SELECT) && (srchedge->v2->f & SELECT)) {
@@ -3657,25 +3659,25 @@ static void edge_rotate(EditMesh *em, wmOperator *op, EditEdge *eed, int dir)
srchedge->bweight = eed->bweight;
}
}
-
+
/* resetting hidden flag */
for(numhidden--; numhidden>=0; numhidden--)
hiddenedges[numhidden]->h= 1;
-
+
/* check for orhphan edges */
for(srchedge=em->edges.first; srchedge; srchedge=srchedge->next)
- srchedge->f1= -1;
-
+ srchedge->f1= -1;
+
/* cleanup */
MEM_freeN(hiddenedges);
-
+
/* get rid of the old edge and faces*/
remedge(em, eed);
- free_editedge(em, eed);
+ free_editedge(em, eed);
BLI_remlink(&em->faces, face[0]);
- free_editface(em, face[0]);
+ free_editface(em, face[0]);
BLI_remlink(&em->faces, face[1]);
- free_editface(em, face[1]);
+ free_editface(em, face[1]);
}
// XXX ton please check
@@ -3689,14 +3691,14 @@ static int edge_rotate_selected(bContext *C, wmOperator *op)
EditFace *efa;
int dir = RNA_int_get(op->ptr, "direction"); // dir == 2 when clockwise and ==1 for counter CW.
short edgeCount = 0;
-
+
/*clear new flag for new edges, count selected edges */
for(eed= em->edges.first; eed; eed= eed->next) {
eed->f1= 0;
eed->f2 &= ~2;
- if(eed->f & SELECT) edgeCount++;
+ if(eed->f & SELECT) edgeCount++;
}
-
+
if(edgeCount>1) {
/* more selected edges, check faces */
for(efa= em->faces.first; efa; efa= efa->next) {
@@ -3719,7 +3721,7 @@ static int edge_rotate_selected(bContext *C, wmOperator *op)
}
}
}
- else
+ else
{
BKE_report(op->reports, RPT_ERROR, "Select one edge or two adjacent faces");
BKE_mesh_end_editmesh(obedit->data, em);
@@ -3735,7 +3737,7 @@ static int edge_rotate_selected(bContext *C, wmOperator *op)
}
}
}
- else {
+ else {
BKE_report(op->reports, RPT_ERROR, "Select one edge or two adjacent faces");
BKE_mesh_end_editmesh(obedit->data, em);
return OPERATOR_CANCELLED;
@@ -3743,7 +3745,7 @@ static int edge_rotate_selected(bContext *C, wmOperator *op)
/* flush selected vertices (again) to edges/faces */
EM_select_flush(em);
-
+
BKE_mesh_end_editmesh(obedit->data, em);
DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
@@ -3757,14 +3759,14 @@ void MESH_OT_edge_rotate(wmOperatorType *ot)
/* identifiers */
ot->name= "Rotate Selected Edge";
ot->idname= "MESH_OT_edge_rotate";
-
+
/* api callbacks */
ot->exec= edge_rotate_selected;
ot->poll= ED_operator_editmesh;
-
+
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
-
+
/* props */
RNA_def_enum(ot->srna, "direction", direction_items, DIRECTION_CW, "direction", "direction to rotate edge around.");
}
@@ -3774,7 +3776,7 @@ void MESH_OT_edge_rotate(wmOperatorType *ot)
/* XXX old bevel not ported yet */
-void bevel_menu(EditMesh *em)
+void bevel_menu(EditMesh *em)
{
BME_Mesh *bm;
BME_TransData_Head *td;
@@ -3829,7 +3831,7 @@ returns 0 if they do not, or if the function is passed the same edge 2 times
short sharesFace(EditMesh *em, EditEdge* e1, EditEdge* e2)
{
EditFace *search=NULL;
-
+
search = em->faces.first;
if (e1 == e2){
return 0 ;
@@ -3880,38 +3882,38 @@ useless:
float shiftlabda= 0.0f,len = 0.0f;
int i = 0,j, numsel, numadded=0, timesthrough = 0, vertsel=0, prop=1, cancel = 0,flip=0;
int wasshift = 0;
-
+
/* UV correction vars */
GHash **uvarray= NULL;
int uvlay_tot= CustomData_number_of_layers(&em->fdata, CD_MTFACE);
int uvlay_idx;
- SlideUv *slideuvs=NULL, *suv=NULL, *suv_last=NULL;
+ SlideUv *slideuvs=NULL, *suv=NULL, *suv_last=NULL;
float uv_tmp[2];
LinkNode *fuv_link;
-
+
short event, draw=1;
short mval[2], mvalo[2];
- char str[128];
+ char str[128];
float labda = 0.0f;
-
+
// initNumInput(&num);
-
+
// view3d_get_object_project_mat(curarea, obedit, projectMat);
-
- mvalo[0] = -1; mvalo[1] = -1;
- numsel =0;
-
+
+ mvalo[0] = -1; mvalo[1] = -1;
+ numsel =0;
+
// Get number of selected edges and clear some flags
for(eed=em->edges.first;eed;eed=eed->next) {
eed->f1 = 0;
- eed->f2 = 0;
+ eed->f2 = 0;
if(eed->f & SELECT) numsel++;
}
-
+
for(ev=em->verts.first;ev;ev=ev->next) {
- ev->f1 = 0;
- }
-
+ ev->f1 = 0;
+ }
+
//Make sure each edge only has 2 faces
// make sure loop doesn't cross face
for(efa=em->faces.first;efa;efa=efa->next) {
@@ -3921,7 +3923,7 @@ useless:
efa->e1->f1++;
if(efa->e1->f1 > 2) {
BKE_report(op->reports, RPT_ERROR, "3+ face edge");
- return 0;
+ return 0;
}
}
if(efa->e2->f & SELECT) {
@@ -3929,7 +3931,7 @@ useless:
efa->e2->f1++;
if(efa->e2->f1 > 2) {
BKE_report(op->reports, RPT_ERROR, "3+ face edge");
- return 0;
+ return 0;
}
}
if(efa->e3->f & SELECT) {
@@ -3937,7 +3939,7 @@ useless:
efa->e3->f1++;
if(efa->e3->f1 > 2) {
BKE_report(op->reports, RPT_ERROR, "3+ face edge");
- return 0;
+ return 0;
}
}
if(efa->e4 && efa->e4->f & SELECT) {
@@ -3945,26 +3947,26 @@ useless:
efa->e4->f1++;
if(efa->e4->f1 > 2) {
BKE_report(op->reports, RPT_ERROR, "3+ face edge");
- return 0;
+ return 0;
}
- }
- // Make sure loop is not 2 edges of same face
+ }
+ // Make sure loop is not 2 edges of same face
if(ct > 1) {
BKE_report(op->reports, RPT_ERROR, "Loop crosses itself");
- return 0;
+ return 0;
}
- }
+ }
// Get # of selected verts
- for(ev=em->verts.first;ev;ev=ev->next) {
+ for(ev=em->verts.first;ev;ev=ev->next) {
if(ev->f & SELECT) vertsel++;
- }
-
+ }
+
// Test for multiple segments
if(vertsel > numsel+1) {
BKE_report(op->reports, RPT_ERROR, "Please choose a single edge loop");
- return 0;
- }
-
+ return 0;
+ }
+
// Get the edgeloop in order - mark f1 with SELECT once added
for(eed=em->edges.first;eed;eed=eed->next) {
if((eed->f & SELECT) && !(eed->f1 & SELECT)) {
@@ -3973,35 +3975,35 @@ useless:
BLI_linklist_prepend(&edgelist,eed);
numadded++;
first = eed;
- last = eed;
+ last = eed;
eed->f1 = SELECT;
- } else {
+ } else {
if(editedge_getSharedVert(eed, last)) {
BLI_linklist_append(&edgelist,eed);
eed->f1 = SELECT;
numadded++;
- last = eed;
+ last = eed;
} else if(editedge_getSharedVert(eed, first)) {
BLI_linklist_prepend(&edgelist,eed);
eed->f1 = SELECT;
numadded++;
- first = eed;
- }
+ first = eed;
+ }
}
- }
+ }
if(eed->next == NULL && numadded != numsel) {
- eed=em->edges.first;
+ eed=em->edges.first;
timesthrough++;
}
-
+
// It looks like there was an unexpected case - Hopefully should not happen
if(timesthrough >= numsel*2) {
- BLI_linklist_free(edgelist,NULL);
+ BLI_linklist_free(edgelist,NULL);
BKE_report(op->reports, RPT_ERROR, "Could not order loop");
- return 0;
+ return 0;
}
}
-
+
// Put the verts in order in a linklist
look = edgelist;
while(look) {
@@ -4012,33 +4014,33 @@ useless:
//This is the first entry takes care of extra vert
if(eed->v1 != temp->v1 && eed->v1 != temp->v2) {
- BLI_linklist_append(&vertlist,eed->v1);
- eed->v1->f1 = 1;
+ BLI_linklist_append(&vertlist,eed->v1);
+ eed->v1->f1 = 1;
} else {
- BLI_linklist_append(&vertlist,eed->v2);
- eed->v2->f1 = 1;
- }
+ BLI_linklist_append(&vertlist,eed->v2);
+ eed->v2->f1 = 1;
+ }
} else {
//This is the case that we only have 1 edge
- BLI_linklist_append(&vertlist,eed->v1);
- eed->v1->f1 = 1;
+ BLI_linklist_append(&vertlist,eed->v1);
+ eed->v1->f1 = 1;
}
- }
+ }
// for all the entries
if(eed->v1->f1 != 1) {
- BLI_linklist_append(&vertlist,eed->v1);
- eed->v1->f1 = 1;
+ BLI_linklist_append(&vertlist,eed->v1);
+ eed->v1->f1 = 1;
} else if(eed->v2->f1 != 1) {
- BLI_linklist_append(&vertlist,eed->v2);
- eed->v2->f1 = 1;
- }
- look = look->next;
- }
-
+ BLI_linklist_append(&vertlist,eed->v2);
+ eed->v2->f1 = 1;
+ }
+ look = look->next;
+ }
+
// populate the SlideVerts
-
- vertgh = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp);
- look = vertlist;
+
+ vertgh = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp);
+ look = vertlist;
while(look) {
i=0;
j=0;
@@ -4054,14 +4056,14 @@ useless:
tempsv->origvert.no[2] = ev->no[2];
// i is total edges that vert is on
// j is total selected edges that vert is on
-
+
for(eed=em->edges.first;eed;eed=eed->next) {
if(eed->v1 == ev || eed->v2 == ev) {
- i++;
+ i++;
if(eed->f & SELECT) {
- j++;
+ j++;
}
- }
+ }
}
// If the vert is in the middle of an edge loop, it touches 2 selected edges and 2 unselected edges
if(i == 4 && j == 2) {
@@ -4071,11 +4073,11 @@ useless:
if(!tempsv->up) {
tempsv->up = eed;
} else if (!(tempsv->down)) {
- tempsv->down = eed;
+ tempsv->down = eed;
}
}
- }
- }
+ }
+ }
}
// If it is on the end of the loop, it touches 1 selected and as least 2 more unselected
if(i >= 3 && j == 1) {
@@ -4087,63 +4089,63 @@ useless:
if(!tempsv->up) {
tempsv->up = efa->e1;
} else if (!(tempsv->down)) {
- tempsv->down = efa->e1;
- }
+ tempsv->down = efa->e1;
+ }
}
if(editedge_containsVert(efa->e2, ev) && efa->e2 != eed) {
if(!tempsv->up) {
tempsv->up = efa->e2;
} else if (!(tempsv->down)) {
- tempsv->down = efa->e2;
- }
- }
+ tempsv->down = efa->e2;
+ }
+ }
if(editedge_containsVert(efa->e3, ev) && efa->e3 != eed) {
if(!tempsv->up) {
tempsv->up = efa->e3;
} else if (!(tempsv->down)) {
- tempsv->down = efa->e3;
- }
- }
+ tempsv->down = efa->e3;
+ }
+ }
if(efa->e4) {
if(editedge_containsVert(efa->e4, ev) && efa->e4 != eed) {
if(!tempsv->up) {
tempsv->up = efa->e4;
} else if (!(tempsv->down)) {
- tempsv->down = efa->e4;
- }
+ tempsv->down = efa->e4;
+ }
}
- }
-
+ }
+
}
}
- }
- }
- }
+ }
+ }
+ }
if(i > 4 && j == 2) {
BLI_ghash_free(vertgh, NULL, (GHashValFreeFP)MEM_freeN);
- BLI_linklist_free(vertlist,NULL);
- BLI_linklist_free(edgelist,NULL);
- return 0;
+ BLI_linklist_free(vertlist,NULL);
+ BLI_linklist_free(edgelist,NULL);
+ return 0;
}
BLI_ghash_insert(vertgh,ev,tempsv);
-
- look = look->next;
- }
-
+
+ look = look->next;
+ }
+
// make sure the UPs nad DOWNs are 'faceloops'
// Also find the nearest slidevert to the cursor
// XXX getmouseco_areawin(mval);
- look = vertlist;
+ look = vertlist;
nearest = NULL;
- vertdist = -1;
- while(look) {
+ vertdist = -1;
+ while(look) {
tempsv = BLI_ghash_lookup(vertgh,(EditVert*)look->link);
-
+
if(!tempsv->up || !tempsv->down) {
BKE_report(op->reports, RPT_ERROR, "Missing rails");
BLI_ghash_free(vertgh, NULL, (GHashValFreeFP)MEM_freeN);
- BLI_linklist_free(vertlist,NULL);
- BLI_linklist_free(edgelist,NULL);
+ BLI_linklist_free(vertlist,NULL);
+ BLI_linklist_free(edgelist,NULL);
return 0;
}
@@ -4174,39 +4176,39 @@ useless:
EditEdge *swap;
swap = sv->up;
sv->up = sv->down;
- sv->down = swap;
+ sv->down = swap;
}
// view3d_project_float(curarea, tempsv->origvert.co, co, projectMat);
-
+
tempdist = sqrt(pow(co[0] - mval[0],2)+pow(co[1] - mval[1],2));
if(vertdist < 0) {
vertdist = tempdist;
- nearest = (EditVert*)look->link;
+ nearest = (EditVert*)look->link;
} else if ( tempdist < vertdist ) {
vertdist = tempdist;
- nearest = (EditVert*)look->link;
- }
- }
- }
-
-
-
- look = look->next;
- }
-
-
+ nearest = (EditVert*)look->link;
+ }
+ }
+ }
+
+
+
+ look = look->next;
+ }
+
+
if (uvlay_tot) { // XXX && (scene->toolsettings->uvcalc_flag & UVCALC_TRANSFORM_CORRECT)) {
int maxnum = 0;
uvarray = MEM_callocN( uvlay_tot * sizeof(GHash *), "SlideUVs Array");
suv_last = slideuvs = MEM_callocN( uvlay_tot * (numadded+1) * sizeof(SlideUv), "SlideUVs"); /* uvLayers * verts */
suv = NULL;
-
+
for (uvlay_idx=0; uvlay_idx<uvlay_tot; uvlay_idx++) {
-
- uvarray[uvlay_idx] = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp);
-
+
+ uvarray[uvlay_idx] = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp);
+
for(ev=em->verts.first;ev;ev=ev->next) {
ev->tmp.l = 0;
}
@@ -4214,25 +4216,25 @@ useless:
while(look) {
float *uv_new;
tempsv = BLI_ghash_lookup(vertgh,(EditVert*)look->link);
-
+
ev = look->link;
suv = NULL;
for(efa = em->faces.first;efa;efa=efa->next) {
if (ev->tmp.l != -1) { /* test for self, in this case its invalid */
int k=-1; /* face corner */
-
+
/* Is this vert in the faces corner? */
if (efa->v1==ev) k=0;
else if (efa->v2==ev) k=1;
else if (efa->v3==ev) k=2;
else if (efa->v4 && efa->v4==ev) k=3;
-
+
if (k != -1) {
MTFace *tf = CustomData_em_get_n(&em->fdata, efa->data, CD_MTFACE, uvlay_idx);
EditVert *ev_up, *ev_down;
-
+
uv_new = tf->uv[k];
-
+
if (ev->tmp.l) {
if (fabs(suv->origuv[0]-uv_new[0]) > 0.0001 || fabs(suv->origuv[1]-uv_new[1])) {
ev->tmp.l = -1; /* Tag as invalid */
@@ -4250,14 +4252,14 @@ useless:
suv->uv_up = suv->uv_down = NULL;
suv->origuv[0] = uv_new[0];
suv->origuv[1] = uv_new[1];
-
+
BLI_linklist_prepend(&suv->fuv_list, uv_new);
BLI_ghash_insert(uvarray[uvlay_idx],ev,suv);
-
+
suv_last++; /* advance to next slide UV */
maxnum++;
}
-
+
/* Now get the uvs along the up or down edge if we can */
if (suv) {
if (!suv->uv_up) {
@@ -4274,7 +4276,7 @@ useless:
else if (efa->v3==ev_down) suv->uv_down = tf->uv[2];
else if (efa->v4 && efa->v4==ev_down) suv->uv_down = tf->uv[3];
}
-
+
/* Copy the pointers to the face UV's */
BLI_linklist_prepend(&suv->fuv_list, uv_new);
}
@@ -4285,32 +4287,32 @@ useless:
}
} /* end uv layer loop */
} /* end uvlay_tot */
-
-
-
+
+
+
// we should have enough info now to slide
- len = 0.0f;
-
+ len = 0.0f;
+
percp = -1;
while(draw) {
- /* For the % calculation */
- short mval[2];
+ /* For the % calculation */
+ short mval[2];
float rc[2];
float v2[2], v3[2];
EditVert *centerVert, *upVert, *downVert;
-
-// XXX getmouseco_areawin(mval);
-
+
+// XXX getmouseco_areawin(mval);
+
if (!immediate && (mval[0] == mvalo[0] && mval[1] == mvalo[1])) {
PIL_sleep_ms(10);
} else {
char *p = str;
int ctrl= 0, shift= 0; // XXX
-
+
mvalo[0] = mval[0];
mvalo[1] = mval[1];
-
+
tempsv = BLI_ghash_lookup(vertgh,nearest);
@@ -4321,31 +4323,31 @@ useless:
// view3d_project_float(curarea, upVert->co, v2, projectMat);
// view3d_project_float(curarea, downVert->co, v3, projectMat);
- /* Determine the % on which the loop should be cut */
+ /* Determine the % on which the loop should be cut */
- rc[0]= v3[0]-v2[0];
- rc[1]= v3[1]-v2[1];
+ rc[0]= v3[0]-v2[0];
+ rc[1]= v3[1]-v2[1];
len= rc[0]*rc[0]+ rc[1]*rc[1];
if (len==0) {len = 0.0001;}
if (shift) {
wasshift = 0;
- labda= ( rc[0]*((mval[0]-v2[0])) + rc[1]*((mval[1]-v2[1])) )/len;
+ labda= ( rc[0]*((mval[0]-v2[0])) + rc[1]*((mval[1]-v2[1])) )/len;
}
else {
if (wasshift==0) {
wasshift = 1;
shiftlabda = labda;
- }
- labda= ( rc[0]*((mval[0]-v2[0])) + rc[1]*((mval[1]-v2[1])) )/len / 10.0 + shiftlabda;
+ }
+ labda= ( rc[0]*((mval[0]-v2[0])) + rc[1]*((mval[1]-v2[1])) )/len / 10.0 + shiftlabda;
}
-
- if(labda<=0.0) labda=0.0;
- else if(labda>=1.0)labda=1.0;
- perc=((1-labda)*2)-1;
-
+ if(labda<=0.0) labda=0.0;
+ else if(labda>=1.0)labda=1.0;
+
+ perc=((1-labda)*2)-1;
+
if(shift == 0 && ctrl==0) {
perc *= 100;
perc = floor(perc);
@@ -4353,20 +4355,20 @@ useless:
} else if (ctrl) {
perc *= 10;
perc = floor(perc);
- perc /= 10;
- }
-
+ perc /= 10;
+ }
+
if(prop == 0) {
len = VecLenf(upVert->co,downVert->co)*((perc+1)/2);
if(flip == 1) {
len = VecLenf(upVert->co,downVert->co) - len;
- }
+ }
}
-
+
if (0) // XXX hasNumInput(&num))
{
// XXX applyNumInput(&num, &perc);
-
+
if (prop)
{
perc = MIN2(perc, 1);
@@ -4381,19 +4383,19 @@ useless:
//Adjust Edgeloop
if(immediate) {
- perc = imperc;
+ perc = imperc;
}
percp = perc;
if(prop) {
- look = vertlist;
- while(look) {
+ look = vertlist;
+ while(look) {
EditVert *tempev;
ev = look->link;
tempsv = BLI_ghash_lookup(vertgh,ev);
-
+
tempev = editedge_getOtherVert((perc>=0)?tempsv->up:tempsv->down, ev);
VecLerpf(ev->co, tempsv->origvert.co, tempev->co, fabs(perc));
-
+
if (0) { // XXX scene->toolsettings->uvcalc_flag & UVCALC_TRANSFORM_CORRECT) {
for (uvlay_idx=0; uvlay_idx<uvlay_tot; uvlay_idx++) {
suv = BLI_ghash_lookup( uvarray[uvlay_idx], ev );
@@ -4407,14 +4409,14 @@ useless:
}
}
}
-
- look = look->next;
+
+ look = look->next;
}
}
else {
- //Non prop code
- look = vertlist;
- while(look) {
+ //Non prop code
+ look = vertlist;
+ while(look) {
float newlen;
ev = look->link;
tempsv = BLI_ghash_lookup(vertgh,ev);
@@ -4422,7 +4424,7 @@ useless:
if(newlen > 1.0) {newlen = 1.0;}
if(newlen < 0.0) {newlen = 0.0;}
if(flip == 0) {
- VecLerpf(ev->co, editedge_getOtherVert(tempsv->down,ev)->co, editedge_getOtherVert(tempsv->up,ev)->co, fabs(newlen));
+ VecLerpf(ev->co, editedge_getOtherVert(tempsv->down,ev)->co, editedge_getOtherVert(tempsv->up,ev)->co, fabs(newlen));
if (0) { // XXX scene->toolsettings->uvcalc_flag & UVCALC_TRANSFORM_CORRECT) {
/* dont do anything if no UVs */
for (uvlay_idx=0; uvlay_idx<uvlay_tot; uvlay_idx++) {
@@ -4438,8 +4440,8 @@ useless:
}
}
} else{
- VecLerpf(ev->co, editedge_getOtherVert(tempsv->up,ev)->co, editedge_getOtherVert(tempsv->down,ev)->co, fabs(newlen));
-
+ VecLerpf(ev->co, editedge_getOtherVert(tempsv->up,ev)->co, editedge_getOtherVert(tempsv->down,ev)->co, fabs(newlen));
+
if (0) { // XXX scene->toolsettings->uvcalc_flag & UVCALC_TRANSFORM_CORRECT) {
/* dont do anything if no UVs */
for (uvlay_idx=0; uvlay_idx<uvlay_tot; uvlay_idx++) {
@@ -4455,23 +4457,23 @@ useless:
}
}
}
- look = look->next;
+ look = look->next;
}
}
-
+
// Highlight the Control Edges
-// scrarea_do_windraw(curarea);
-// persp(PERSP_VIEW);
-// glPushMatrix();
+// scrarea_do_windraw(curarea);
+// persp(PERSP_VIEW);
+// glPushMatrix();
// mymultmatrix(obedit->obmat);
- glColor3ub(0, 255, 0);
+ glColor3ub(0, 255, 0);
glBegin(GL_LINES);
glVertex3fv(upVert->co);
glVertex3fv(downVert->co);
- glEnd();
-
+ glEnd();
+
if(prop == 0) {
// draw start edge for non-prop
glPointSize(5);
@@ -4480,24 +4482,24 @@ useless:
if(flip) {
glVertex3fv(upVert->co);
} else {
- glVertex3fv(downVert->co);
+ glVertex3fv(downVert->co);
}
- glEnd();
+ glEnd();
}
-
-
- glPopMatrix();
+
+
+ glPopMatrix();
if(prop) {
p += sprintf(str, "(P)ercentage: ");
} else {
p += sprintf(str, "Non (P)rop Length: ");
}
-
+
if (0) // XXX hasNumInput(&num))
{
char num_str[20];
-
+
// XX outputNumInput(&num, num_str);
p += sprintf(p, "%s", num_str);
}
@@ -4512,20 +4514,20 @@ useless:
p += sprintf(p, "%f", len);
}
}
-
-
+
+
if (prop == 0) {
p += sprintf(p, ", Press (F) to flip control side");
}
// headerprint(str);
-// screen_swapbuffers();
+// screen_swapbuffers();
}
if(!immediate) {
while(qtest()) {
- short val=0;
- event= extern_qread(&val); // extern_qread stores important events for the mainloop to handle
-
+ short val=0;
+ event= extern_qread(&val); // extern_qread stores important events for the mainloop to handle
+
/* val==0 on key-release event */
if (val) {
if(ELEM(event, ESCKEY, RIGHTMOUSE)) {
@@ -4537,7 +4539,7 @@ useless:
} else if(ELEM3(event, PADENTER, LEFTMOUSE, RETKEY)) {
draw = 0; // End looping now
} else if(event==MIDDLEMOUSE) {
- perc = 0;
+ perc = 0;
immediate = 1;
} else if(event==PKEY) {
// XXX initNumInput(&num); /* reset num input */
@@ -4548,61 +4550,61 @@ useless:
else {
prop = 1;
}
- mvalo[0] = -1;
+ mvalo[0] = -1;
} else if(event==FKEY) {
- (flip == 1) ? (flip = 0):(flip = 1);
- mvalo[0] = -1;
+ (flip == 1) ? (flip = 0):(flip = 1);
+ mvalo[0] = -1;
} else if(ELEM(event, RIGHTARROWKEY, WHEELUPMOUSE)) { // Scroll through Control Edges
- look = vertlist;
- while(look) {
+ look = vertlist;
+ while(look) {
if(nearest == (EditVert*)look->link) {
if(look->next == NULL) {
- nearest = (EditVert*)vertlist->link;
+ nearest = (EditVert*)vertlist->link;
} else {
nearest = (EditVert*)look->next->link;
- }
+ }
mvalo[0] = -1;
- break;
+ break;
}
- look = look->next;
- }
+ look = look->next;
+ }
} else if(ELEM(event, LEFTARROWKEY, WHEELDOWNMOUSE)) { // Scroll through Control Edges
- look = vertlist;
- while(look) {
+ look = vertlist;
+ while(look) {
if(look->next) {
if(look->next->link == nearest) {
nearest = (EditVert*)look->link;
mvalo[0] = -1;
break;
- }
+ }
} else {
if((EditVert*)vertlist->link == nearest) {
nearest = look->link;
mvalo[0] = -1;
- break;
- }
- }
- look = look->next;
- }
+ break;
+ }
+ }
+ look = look->next;
+ }
}
-
+
// XXX if (handleNumInput(&num, event))
{
mvalo[0] = -1; /* NEED A BETTER WAY TO TRIGGER REDRAW */
}
}
-
- }
+
+ }
} else {
draw = 0;
}
-// DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
+// DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
}
-
-
+
+
if(me->drawflag & ME_DRAW_EDGELEN) {
look = vertlist;
- while(look) {
+ while(look) {
tempsv = BLI_ghash_lookup(vertgh,(EditVert*)look->link);
if(tempsv != NULL) {
tempsv->up->f &= !SELECT;
@@ -4611,26 +4613,26 @@ useless:
look = look->next;
}
}
-
+
// force_draw(0);
-
+
if(!immediate)
EM_automerge(0);
// DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
-// scrarea_queue_winredraw(curarea);
-
- //BLI_ghash_free(edgesgh, freeGHash, NULL);
+// scrarea_queue_winredraw(curarea);
+
+ //BLI_ghash_free(edgesgh, freeGHash, NULL);
BLI_ghash_free(vertgh, NULL, (GHashValFreeFP)MEM_freeN);
- BLI_linklist_free(vertlist,NULL);
- BLI_linklist_free(edgelist,NULL);
-
+ BLI_linklist_free(vertlist,NULL);
+ BLI_linklist_free(edgelist,NULL);
+
if (uvlay_tot) { // XXX && (scene->toolsettings->uvcalc_flag & UVCALC_TRANSFORM_CORRECT)) {
for (uvlay_idx=0; uvlay_idx<uvlay_tot; uvlay_idx++) {
BLI_ghash_free(uvarray[uvlay_idx], NULL, NULL);
}
MEM_freeN(uvarray);
MEM_freeN(slideuvs);
-
+
suv = suv_last-1;
while (suv >= slideuvs) {
if (suv->fuv_list) {
@@ -4648,21 +4650,21 @@ useless:
#endif // END OF XXX
}
-int EdgeLoopDelete(EditMesh *em, wmOperator *op)
+int EdgeLoopDelete(EditMesh *em, wmOperator *op)
{
-
+
/* temporal flag setting so we keep UVs when deleting edge loops,
* this is a bit of a hack but it works how you would want in almost all cases */
- // short uvcalc_flag_orig = 0; // XXX scene->toolsettings->uvcalc_flag;
+ // short uvcalc_flag_orig = 0; // XXX scene->toolsettings->uvcalc_flag;
// scene->toolsettings->uvcalc_flag |= UVCALC_TRANSFORM_CORRECT;
-
+
if(!EdgeSlide(em, op, 1, 1)) {
return 0;
}
-
+
/* restore uvcalc flag */
// scene->toolsettings->uvcalc_flag = uvcalc_flag_orig;
-
+
EM_select_more(em);
removedoublesflag(em, 1,0, 0.001);
EM_select_flush(em);
@@ -4683,12 +4685,12 @@ void mesh_set_face_flags(EditMesh *em, short mode)
m_billboard=0, m_shadow=0, m_text=0,
m_sort=0;
short flag = 0, change = 0;
-
+
// XXX if (!EM_texFaceCheck()) {
// error("not a mesh with uv/image layers");
// return;
// }
-
+
add_numbut(0, TOG|SHO, "Texture", 0, 0, &m_tex, NULL);
add_numbut(2, TOG|SHO, "Light", 0, 0, &m_light, NULL);
add_numbut(3, TOG|SHO, "Invisible", 0, 0, &m_invis, NULL);
@@ -4701,15 +4703,15 @@ void mesh_set_face_flags(EditMesh *em, short mode)
add_numbut(10, TOG|SHO, "Shadow", 0, 0, &m_shadow, NULL);
add_numbut(11, TOG|SHO, "Text", 0, 0, &m_text, NULL);
add_numbut(12, TOG|SHO, "Sort", 0, 0, &m_sort, NULL);
-
+
if (!do_clever_numbuts((mode ? "Set Flags" : "Clear Flags"), 13, REDRAW))
return;
-
+
/* these 2 cant both be on */
if (mode) /* are we seeting*/
if (m_halo)
m_billboard = 0;
-
+
if (m_tex) flag |= TF_TEX;
if (m_shared) flag |= TF_SHAREDCOL;
if (m_light) flag |= TF_LIGHT;
@@ -4722,10 +4724,10 @@ void mesh_set_face_flags(EditMesh *em, short mode)
if (m_shadow) flag |= TF_SHADOW;
if (m_text) flag |= TF_BMFONT;
if (m_sort) flag |= TF_ALPHASORT;
-
+
if (flag==0)
return;
-
+
efa= em->faces.first;
while(efa) {
if(efa->f & SELECT) {
@@ -4736,7 +4738,7 @@ void mesh_set_face_flags(EditMesh *em, short mode)
}
efa= efa->next;
}
-
+
}
#endif
@@ -4746,12 +4748,12 @@ void mesh_set_face_flags(EditMesh *em, short mode)
static float mesh_rip_edgedist(ARegion *ar, float mat[][4], float *co1, float *co2, short *mval)
{
float vec1[3], vec2[3], mvalf[2];
-
+
view3d_project_float(ar, co1, vec1, mat);
view3d_project_float(ar, co2, vec2, mat);
mvalf[0]= (float)mval[0];
mvalf[1]= (float)mval[1];
-
+
return PdistVL2Dfl(mvalf, vec1, vec2);
}
@@ -4763,16 +4765,16 @@ static void mesh_rip_setface(EditMesh *em, EditFace *sefa)
if(sefa->v2->tmp.v) sefa->v2= sefa->v2->tmp.v;
if(sefa->v3->tmp.v) sefa->v3= sefa->v3->tmp.v;
if(sefa->v4 && sefa->v4->tmp.v) sefa->v4= sefa->v4->tmp.v;
-
+
sefa->e1= addedgelist(em, sefa->v1, sefa->v2, sefa->e1);
sefa->e2= addedgelist(em, sefa->v2, sefa->v3, sefa->e2);
if(sefa->v4) {
sefa->e3= addedgelist(em, sefa->v3, sefa->v4, sefa->e3);
sefa->e4= addedgelist(em, sefa->v4, sefa->v1, sefa->e4);
}
- else
+ else
sefa->e3= addedgelist(em, sefa->v3, sefa->v1, sefa->e3);
-
+
}
/* based on mouse cursor position, it defines how is being ripped */
@@ -4787,32 +4789,26 @@ static int mesh_rip_invoke(bContext *C, wmOperator *op, wmEvent *event)
EditEdge *eed, *seed= NULL;
EditFace *efa, *sefa= NULL;
float projectMat[4][4], vec[3], dist, mindist;
- short doit= 1, *mval= event->mval; // XXX ,propmode,prop;
-
-
-// XXX propmode = scene->prop_mode;
-// scene->prop_mode = 0;
-// prop = scene->proportional;
-// scene->proportional = 0;
-
+ short doit= 1, *mval= event->mval;
+
/* select flush... vertices are important */
EM_selectmode_set(em);
-
+
view3d_get_object_project_mat(rv3d, obedit, projectMat);
/* find best face, exclude triangles and break on face select or faces with 2 edges select */
mindist= 1000000.0f;
for(efa= em->faces.first; efa; efa=efa->next) {
- if( efa->f & 1)
+ if( efa->f & 1)
break;
if(efa->v4 && faceselectedOR(efa, SELECT) ) {
int totsel=0;
-
+
if(efa->e1->f & SELECT) totsel++;
if(efa->e2->f & SELECT) totsel++;
if(efa->e3->f & SELECT) totsel++;
if(efa->e4->f & SELECT) totsel++;
-
+
if(totsel>1)
break;
view3d_project_float(ar, efa->cent, vec, projectMat);
@@ -4823,7 +4819,7 @@ static int mesh_rip_invoke(bContext *C, wmOperator *op, wmEvent *event)
}
}
}
-
+
if(efa) {
BKE_report(op->reports, RPT_ERROR, "Can't perform ripping with faces selected this way");
BKE_mesh_end_editmesh(obedit->data, em);
@@ -4834,7 +4830,7 @@ static int mesh_rip_invoke(bContext *C, wmOperator *op, wmEvent *event)
BKE_mesh_end_editmesh(obedit->data, em);
return OPERATOR_CANCELLED;
}
-
+
/* duplicate vertices, new vertices get selected */
for(eve = em->verts.last; eve; eve= eve->prev) {
@@ -4845,20 +4841,20 @@ static int mesh_rip_invoke(bContext *C, wmOperator *op, wmEvent *event)
eve->tmp.v->f |= SELECT;
}
}
-
+
/* find the best candidate edge */
/* or one of sefa edges is selected... */
if(sefa->e1->f & SELECT) seed= sefa->e2;
if(sefa->e2->f & SELECT) seed= sefa->e1;
if(sefa->e3->f & SELECT) seed= sefa->e2;
if(sefa->e4 && sefa->e4->f & SELECT) seed= sefa->e3;
-
+
/* or we do the distance trick */
if(seed==NULL) {
mindist= 1000000.0f;
if(sefa->e1->v1->tmp.v || sefa->e1->v2->tmp.v) {
- dist = mesh_rip_edgedist(ar, projectMat,
- sefa->e1->v1->co,
+ dist = mesh_rip_edgedist(ar, projectMat,
+ sefa->e1->v1->co,
sefa->e1->v2->co, mval);
if(dist<mindist) {
seed= sefa->e1;
@@ -4867,7 +4863,7 @@ static int mesh_rip_invoke(bContext *C, wmOperator *op, wmEvent *event)
}
if(sefa->e2->v1->tmp.v || sefa->e2->v2->tmp.v) {
dist = mesh_rip_edgedist(ar, projectMat,
- sefa->e2->v1->co,
+ sefa->e2->v1->co,
sefa->e2->v2->co, mval);
if(dist<mindist) {
seed= sefa->e2;
@@ -4875,8 +4871,8 @@ static int mesh_rip_invoke(bContext *C, wmOperator *op, wmEvent *event)
}
}
if(sefa->e3->v1->tmp.v || sefa->e3->v2->tmp.v) {
- dist= mesh_rip_edgedist(ar, projectMat,
- sefa->e3->v1->co,
+ dist= mesh_rip_edgedist(ar, projectMat,
+ sefa->e3->v1->co,
sefa->e3->v2->co, mval);
if(dist<mindist) {
seed= sefa->e3;
@@ -4884,8 +4880,8 @@ static int mesh_rip_invoke(bContext *C, wmOperator *op, wmEvent *event)
}
}
if(sefa->e4 && (sefa->e4->v1->tmp.v || sefa->e4->v2->tmp.v)) {
- dist= mesh_rip_edgedist(ar, projectMat,
- sefa->e4->v1->co,
+ dist= mesh_rip_edgedist(ar, projectMat,
+ sefa->e4->v1->co,
sefa->e4->v2->co, mval);
if(dist<mindist) {
seed= sefa->e4;
@@ -4893,13 +4889,13 @@ static int mesh_rip_invoke(bContext *C, wmOperator *op, wmEvent *event)
}
}
}
-
+
if(seed==NULL) { // never happens?
BKE_report(op->reports, RPT_ERROR, "No proper edge found to start");
BKE_mesh_end_editmesh(obedit->data, em);
return OPERATOR_CANCELLED;
}
-
+
faceloop_select(em, seed, 2); // tmp abuse for finding all edges that need duplicated, returns OK faces with f1
/* duplicate edges in the loop, with at least 1 vertex selected, needed for selection flip */
@@ -4907,8 +4903,8 @@ static int mesh_rip_invoke(bContext *C, wmOperator *op, wmEvent *event)
eed->tmp.v = NULL;
if((eed->v1->tmp.v) || (eed->v2->tmp.v)) {
EditEdge *newed;
-
- newed= addedgelist(em, eed->v1->tmp.v?eed->v1->tmp.v:eed->v1,
+
+ newed= addedgelist(em, eed->v1->tmp.v?eed->v1->tmp.v:eed->v1,
eed->v2->tmp.v?eed->v2->tmp.v:eed->v2, eed);
if(eed->f & SELECT) {
EM_select_edge(eed, 0);
@@ -4924,16 +4920,16 @@ static int mesh_rip_invoke(bContext *C, wmOperator *op, wmEvent *event)
/* put new vertices & edges && flag in best face */
mesh_rip_setface(em, sefa);
-
+
/* starting with neighbours of best face, we loop over the seam */
sefa->f1= 2;
doit= 1;
while(doit) {
doit= 0;
-
+
for(efa= em->faces.first; efa; efa=efa->next) {
/* new vert in face */
- if (efa->v1->tmp.v || efa->v2->tmp.v ||
+ if (efa->v1->tmp.v || efa->v2->tmp.v ||
efa->v3->tmp.v || (efa->v4 && efa->v4->tmp.v)) {
/* face is tagged with loop */
if(efa->f1==1) {
@@ -4942,9 +4938,9 @@ static int mesh_rip_invoke(bContext *C, wmOperator *op, wmEvent *event)
doit= 1;
}
}
- }
+ }
}
-
+
/* remove loose edges, that were part of a ripped face */
for(eve = em->verts.first; eve; eve= eve->next) eve->f1= 0;
for(eed = em->edges.last; eed; eed= eed->prev) eed->f1= 0;
@@ -4954,11 +4950,11 @@ static int mesh_rip_invoke(bContext *C, wmOperator *op, wmEvent *event)
efa->e3->f1= 1;
if(efa->e4) efa->e4->f1= 1;
}
-
+
for(eed = em->edges.last; eed; eed= seed) {
seed= eed->prev;
if(eed->f1==0) {
- if(eed->v1->tmp.v || eed->v2->tmp.v ||
+ if(eed->v1->tmp.v || eed->v2->tmp.v ||
(eed->v1->f & SELECT) || (eed->v2->f & SELECT)) {
remedge(em, eed);
free_editedge(em, eed);
@@ -4970,7 +4966,7 @@ static int mesh_rip_invoke(bContext *C, wmOperator *op, wmEvent *event)
eed->v2->f1= 1;
}
}
-
+
/* and remove loose selected vertices, that got duplicated accidentally */
for(eve = em->verts.first; eve; eve= nextve) {
nextve= eve->next;
@@ -4979,17 +4975,15 @@ static int mesh_rip_invoke(bContext *C, wmOperator *op, wmEvent *event)
free_editvert(em, eve);
}
}
-
+
DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
BKE_mesh_end_editmesh(obedit->data, em);
- RNA_int_set(op->ptr, "mode", TFM_TRANSLATION);
- WM_operator_name_call(C, "TFM_OT_transform", WM_OP_INVOKE_REGION_WIN, op->ptr);
-
-// scene->prop_mode = propmode;
-// XXX scene->proportional = prop;
+ RNA_enum_set(op->ptr, "proportional", 0);
+ RNA_boolean_set(op->ptr, "mirror", 0);
+ WM_operator_name_call(C, "TFM_OT_translation", WM_OP_INVOKE_REGION_WIN, op->ptr);
return OPERATOR_FINISHED;
}
@@ -4999,16 +4993,17 @@ void MESH_OT_rip(wmOperatorType *ot)
/* identifiers */
ot->name= "Rip";
ot->idname= "MESH_OT_rip";
-
+
/* api callbacks */
ot->invoke= mesh_rip_invoke;
ot->poll= EM_view3d_poll;
-
+
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
-
+
/* to give to transform */
- RNA_def_int(ot->srna, "mode", TFM_TRANSLATION, 0, INT_MAX, "Mode", "", 0, INT_MAX);
+ Properties_Proportional(ot);
+ RNA_def_boolean(ot->srna, "mirror", 0, "Mirror Editing", "");
}
@@ -5021,39 +5016,39 @@ void shape_propagate(Scene *scene, Object *obedit, EditMesh *em, wmOperator *op)
Key* ky = NULL;
KeyBlock* kb = NULL;
Base* base=NULL;
-
-
+
+
if(me->key){
ky = me->key;
} else {
- BKE_report(op->reports, RPT_ERROR, "Object Has No Key");
+ BKE_report(op->reports, RPT_ERROR, "Object Has No Key");
return;
- }
+ }
if(ky->block.first){
for(ev = em->verts.first; ev ; ev = ev->next){
if(ev->f & SELECT){
for(kb=ky->block.first;kb;kb = kb->next){
- float *data;
- data = kb->data;
- VECCOPY(data+(ev->keyindex*3),ev->co);
+ float *data;
+ data = kb->data;
+ VECCOPY(data+(ev->keyindex*3),ev->co);
}
- }
- }
+ }
+ }
} else {
- BKE_report(op->reports, RPT_ERROR, "Object Has No Blendshapes");
- return;
+ BKE_report(op->reports, RPT_ERROR, "Object Has No Blendshapes");
+ return;
}
-
+
//TAG Mesh Objects that share this data
for(base = scene->base.first; base; base = base->next){
if(base->object && base->object->data == me){
base->object->recalc = OB_RECALC_DATA;
}
- }
+ }
DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
- return;
+ return;
}
void shape_copy_from_lerp(EditMesh *em, KeyBlock* thisBlock, KeyBlock* fromBlock)
@@ -5063,10 +5058,10 @@ void shape_copy_from_lerp(EditMesh *em, KeyBlock* thisBlock, KeyBlock* fromBlock
float perc = 0;
char str[64];
float *data, *odata;
-
+
data = fromBlock->data;
odata = thisBlock->data;
-
+
// XXX getmouseco_areawin(mval);
curval[0] = mval[0] + 1; curval[1] = mval[1] + 1;
@@ -5075,55 +5070,55 @@ void shape_copy_from_lerp(EditMesh *em, KeyBlock* thisBlock, KeyBlock* fromBlock
// XXX getmouseco_areawin(mval);
if (mval[0] != curval[0] || mval[1] != curval[1])
{
-
+
if(mval[0] > curval[0])
perc += 0.1;
else if(mval[0] < curval[0])
perc -= 0.1;
-
+
if(perc < 0) perc = 0;
if(perc > 1) perc = 1;
-
+
curval[0] = mval[0];
curval[1] = mval[1];
if(fullcopy == 1){
- perc = 1;
+ perc = 1;
}
for(ev = em->verts.first; ev ; ev = ev->next){
if(ev->f & SELECT){
VecLerpf(ev->co,odata+(ev->keyindex*3),data+(ev->keyindex*3),perc);
- }
- }
+ }
+ }
sprintf(str,"Blending at %d%c MMB to Copy at 100%c",(int)(perc*100),'%','%');
// DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
// headerprint(str);
-// force_draw(0);
+// force_draw(0);
if(fullcopy == 1){
- break;
+ break;
}
} else {
- PIL_sleep_ms(10);
+ PIL_sleep_ms(10);
}
while(qtest()) {
- short val=0;
- event= extern_qread(&val);
+ short val=0;
+ event= extern_qread(&val);
if(val){
if(ELEM3(event, PADENTER, LEFTMOUSE, RETKEY)){
finished = 1;
}
else if (event == MIDDLEMOUSE){
- fullcopy = 1;
+ fullcopy = 1;
}
else if (ELEM3(event,ESCKEY,RIGHTMOUSE,RIGHTMOUSE)){
canceled = 1;
finished = 1;
}
- }
+ }
}
}
if(!canceled);
@@ -5131,7 +5126,7 @@ void shape_copy_from_lerp(EditMesh *em, KeyBlock* thisBlock, KeyBlock* fromBlock
for(ev = em->verts.first; ev ; ev = ev->next){
if(ev->f & SELECT){
VECCOPY(ev->co, odata+(ev->keyindex*3));
- }
+ }
}
return;
}
@@ -5143,63 +5138,63 @@ void shape_copy_select_from(Object *obedit, EditMesh *em, wmOperator *op)
Mesh* me = (Mesh*)obedit->data;
EditVert *ev = NULL;
int totverts = 0,curshape = obedit->shapenr;
-
+
Key* ky = NULL;
KeyBlock *kb = NULL,*thisBlock = NULL;
int maxlen=32, nr=0, a=0;
char *menu;
-
+
if(me->key){
ky = me->key;
} else {
- BKE_report(op->reports, RPT_ERROR, "Object Has No Key");
+ BKE_report(op->reports, RPT_ERROR, "Object Has No Key");
return;
}
-
+
if(ky->block.first){
for(kb=ky->block.first;kb;kb = kb->next){
maxlen += 40; // Size of a block name
if(a == curshape-1){
- thisBlock = kb;
+ thisBlock = kb;
}
-
+
a++;
}
a=0;
menu = MEM_callocN(maxlen, "Copy Shape Menu Text");
strcpy(menu, "Copy Vert Positions from Shape %t|");
for(kb=ky->block.first;kb;kb = kb->next){
- if(a != curshape-1){
+ if(a != curshape-1){
sprintf(menu,"%s %s %cx%d|",menu,kb->name,'%',a);
}
a++;
}
// XXX nr = pupmenu_col(menu, 20);
- MEM_freeN(menu);
+ MEM_freeN(menu);
} else {
- BKE_report(op->reports, RPT_ERROR, "Object Has No Blendshapes");
- return;
+ BKE_report(op->reports, RPT_ERROR, "Object Has No Blendshapes");
+ return;
}
-
+
a = 0;
-
+
for(kb=ky->block.first;kb;kb = kb->next){
if(a == nr){
-
+
for(ev = em->verts.first;ev;ev = ev->next){
totverts++;
}
-
+
if(me->totvert != totverts){
BKE_report(op->reports, RPT_ERROR, "Shape Has had Verts Added/Removed, please cycle editmode before copying");
- return;
+ return;
}
- shape_copy_from_lerp(em, thisBlock,kb);
-
+ shape_copy_from_lerp(em, thisBlock,kb);
+
return;
}
a++;
- }
+ }
return;
}
@@ -5228,17 +5223,17 @@ static void build_edgecollection(EditMesh *em, ListBase *allcollections)
EditEdge *eed;
Collection *edgecollection, *newcollection;
CollectedEdge *newedge;
-
+
int currtag = 1;
short ebalanced = 0;
short collectionfound = 0;
-
- for (eed=em->edges.first; eed; eed = eed->next){
+
+ for (eed=em->edges.first; eed; eed = eed->next){
eed->tmp.l = 0;
eed->v1->tmp.l = 0;
eed->v2->tmp.l = 0;
}
-
+
/*1st pass*/
for(eed=em->edges.first; eed; eed=eed->next){
if(eed->f&SELECT){
@@ -5247,26 +5242,26 @@ static void build_edgecollection(EditMesh *em, ListBase *allcollections)
currtag +=1;
}
}
-
+
/*2nd pass - Brute force. Loop through selected faces until there are no 'unbalanced' edges left (those with both vertices 'tmp.l' tag matching */
while(ebalanced == 0){
ebalanced = 1;
for(eed=em->edges.first; eed; eed = eed->next){
if(eed->f&SELECT){
if(eed->v1->tmp.l != eed->v2->tmp.l) /*unbalanced*/{
- if(eed->v1->tmp.l > eed->v2->tmp.l && eed->v2->tmp.l !=0) eed->v1->tmp.l = eed->v2->tmp.l;
- else if(eed->v1 != 0) eed->v2->tmp.l = eed->v1->tmp.l;
+ if(eed->v1->tmp.l > eed->v2->tmp.l && eed->v2->tmp.l !=0) eed->v1->tmp.l = eed->v2->tmp.l;
+ else if(eed->v1 != 0) eed->v2->tmp.l = eed->v1->tmp.l;
ebalanced = 0;
}
}
}
}
-
+
/*3rd pass, set all the edge flags (unnessecary?)*/
for(eed=em->edges.first; eed; eed = eed->next){
if(eed->f&SELECT) eed->tmp.l = eed->v1->tmp.l;
}
-
+
for(eed=em->edges.first; eed; eed=eed->next){
if(eed->f&SELECT){
if(allcollections->first){
@@ -5286,28 +5281,28 @@ static void build_edgecollection(EditMesh *em, ListBase *allcollections)
newcollection->index = eed->tmp.l;
newcollection->collectionbase.first = 0;
newcollection->collectionbase.last = 0;
-
+
newedge = MEM_mallocN(sizeof(CollectedEdge), "collected edge");
newedge->eed = eed;
-
+
BLI_addtail(&(newcollection->collectionbase), newedge);
BLI_addtail(allcollections, newcollection);
}
}
-
+
}
}
static void freecollections(ListBase *allcollections)
{
struct Collection *curcollection;
-
+
for(curcollection = allcollections->first; curcollection; curcollection = curcollection->next)
BLI_freelistN(&(curcollection->collectionbase));
BLI_freelistN(allcollections);
}
-/*Begin UV Edge Collapse Code
+/*Begin UV Edge Collapse Code
Like Edge subdivide, Edge Collapse should handle UV's intelligently, but since UV's are a per-face attribute, normal edge collapse will fail
in areas such as the boundries of 'UV islands'. So for each edge collection we need to build a set of 'welded' UV vertices and edges for it.
The welded UV edges can then be sorted and collapsed.
@@ -5337,7 +5332,7 @@ typedef struct wUVEdge{
typedef struct wUVEdgeCollect{ /*used for grouping*/
struct wUVEdgeCollect *next, *prev;
wUVEdge *uved;
- int id;
+ int id;
} wUVEdgeCollect;
static void append_weldedUV(EditMesh *em, EditFace *efa, EditVert *eve, int tfindex, ListBase *uvverts)
@@ -5346,9 +5341,9 @@ static void append_weldedUV(EditMesh *em, EditFace *efa, EditVert *eve, int tfin
wUVNode *newnode;
int found;
MTFace *tf = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
-
+
found = 0;
-
+
for(curwvert=uvverts->first; curwvert; curwvert=curwvert->next){
if(curwvert->eve == eve && curwvert->u == tf->uv[tfindex][0] && curwvert->v == tf->uv[tfindex][1]){
newnode = MEM_callocN(sizeof(wUVNode), "Welded UV Vert Node");
@@ -5359,20 +5354,20 @@ static void append_weldedUV(EditMesh *em, EditFace *efa, EditVert *eve, int tfin
break;
}
}
-
+
if(!found){
newnode = MEM_callocN(sizeof(wUVNode), "Welded UV Vert Node");
newnode->u = &(tf->uv[tfindex][0]);
newnode->v = &(tf->uv[tfindex][1]);
-
+
newwvert = MEM_callocN(sizeof(wUV), "Welded UV Vert");
newwvert->u = *(newnode->u);
newwvert->v = *(newnode->v);
newwvert->eve = eve;
-
+
BLI_addtail(&(newwvert->nodes), newnode);
BLI_addtail(uvverts, newwvert);
-
+
}
}
@@ -5392,14 +5387,14 @@ static void append_weldedUVEdge(EditMesh *em, EditFace *efa, EditEdge *eed, List
wUVEdge *curwedge, *newwedge;
int v1tfindex, v2tfindex, found;
MTFace *tf = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
-
+
found = 0;
-
+
if(eed->v1 == efa->v1) v1tfindex = 0;
else if(eed->v1 == efa->v2) v1tfindex = 1;
else if(eed->v1 == efa->v3) v1tfindex = 2;
else /* if(eed->v1 == efa->v4) */ v1tfindex = 3;
-
+
if(eed->v2 == efa->v1) v2tfindex = 0;
else if(eed->v2 == efa->v2) v2tfindex = 1;
else if(eed->v2 == efa->v3) v2tfindex = 2;
@@ -5411,7 +5406,7 @@ static void append_weldedUVEdge(EditMesh *em, EditFace *efa, EditEdge *eed, List
break; //do nothing, we don't need another welded uv edge
}
}
-
+
if(!found){
newwedge = MEM_callocN(sizeof(wUVEdge), "Welded UV Edge");
newwedge->v1uv[0] = tf->uv[v1tfindex][0];
@@ -5419,7 +5414,7 @@ static void append_weldedUVEdge(EditMesh *em, EditFace *efa, EditEdge *eed, List
newwedge->v2uv[0] = tf->uv[v2tfindex][0];
newwedge->v2uv[1] = tf->uv[v2tfindex][1];
newwedge->eed = eed;
-
+
BLI_addtail(uvedges, newwedge);
}
}
@@ -5429,15 +5424,15 @@ static void build_weldedUVEdges(EditMesh *em, ListBase *uvedges, ListBase *uvver
wUV *curwvert;
wUVEdge *curwedge;
EditFace *efa;
-
+
for(efa=em->faces.first; efa; efa=efa->next){
if(efa->e1->f1) append_weldedUVEdge(em, efa, efa->e1, uvedges);
if(efa->e2->f1) append_weldedUVEdge(em, efa, efa->e2, uvedges);
if(efa->e3->f1) append_weldedUVEdge(em, efa, efa->e3, uvedges);
if(efa->e4 && efa->e4->f1) append_weldedUVEdge(em, efa, efa->e4, uvedges);
}
-
-
+
+
//link vertices: for each uvedge, search uvverts to populate v1 and v2 pointers
for(curwedge=uvedges->first; curwedge; curwedge=curwedge->next){
for(curwvert=uvverts->first; curwvert; curwvert=curwvert->next){
@@ -5474,20 +5469,20 @@ static void collapse_edgeuvs(EditMesh *em)
if (!EM_texFaceCheck(em))
return;
-
+
uvverts.first = uvverts.last = uvedges.first = uvedges.last = allcollections.first = allcollections.last = NULL;
-
+
build_weldedUVs(em, &uvverts);
build_weldedUVEdges(em, &uvedges, &uvverts);
-
+
curtag = 0;
-
+
for(curwedge=uvedges.first; curwedge; curwedge=curwedge->next){
curwedge->v1->f = curtag;
curwedge->v2->f = curtag;
curtag +=1;
}
-
+
balanced = 0;
while(!balanced){
balanced = 1;
@@ -5499,10 +5494,10 @@ static void collapse_edgeuvs(EditMesh *em)
}
}
}
-
+
for(curwedge=uvedges.first; curwedge; curwedge=curwedge->next) curwedge->f = curwedge->v1->f;
-
-
+
+
for(curwedge=uvedges.first; curwedge; curwedge=curwedge->next){
if(allcollections.first){
for(wuvecollection = allcollections.first; wuvecollection; wuvecollection=wuvecollection->next){
@@ -5513,7 +5508,7 @@ static void collapse_edgeuvs(EditMesh *em)
collectionfound = 1;
break;
}
-
+
else collectionfound = 0;
}
}
@@ -5522,32 +5517,32 @@ static void collapse_edgeuvs(EditMesh *em)
newcollection->index = curwedge->f;
newcollection->collectionbase.first = 0;
newcollection->collectionbase.last = 0;
-
+
newcollectedwuve = MEM_callocN(sizeof(wUVEdgeCollect), "Collected Welded UV Edge");
newcollectedwuve->uved = curwedge;
-
+
BLI_addtail(&(newcollection->collectionbase), newcollectedwuve);
BLI_addtail(&allcollections, newcollection);
}
}
-
+
for(wuvecollection=allcollections.first; wuvecollection; wuvecollection=wuvecollection->next){
-
+
vcount = avg[0] = avg[1] = 0;
-
+
for(collectedwuve= wuvecollection->collectionbase.first; collectedwuve; collectedwuve = collectedwuve->next){
avg[0] += collectedwuve->uved->v1uv[0];
avg[1] += collectedwuve->uved->v1uv[1];
-
+
avg[0] += collectedwuve->uved->v2uv[0];
avg[1] += collectedwuve->uved->v2uv[1];
-
+
vcount +=2;
-
+
}
-
+
avg[0] /= vcount; avg[1] /= vcount;
-
+
for(collectedwuve= wuvecollection->collectionbase.first; collectedwuve; collectedwuve = collectedwuve->next){
for(curwnode=collectedwuve->uved->v1->nodes.first; curwnode; curwnode=curwnode->next){
*(curwnode->u) = avg[0];
@@ -5559,7 +5554,7 @@ static void collapse_edgeuvs(EditMesh *em)
}
}
}
-
+
free_weldedUVs(&uvverts);
BLI_freelistN(&uvedges);
freecollections(&allcollections);
@@ -5576,11 +5571,11 @@ static void collapseuvs(EditMesh *em, EditVert *mergevert)
if (!EM_texFaceCheck(em))
return;
-
+
uvcount = 0;
uvav[0] = 0;
uvav[1] = 0;
-
+
for(efa = em->faces.first; efa; efa=efa->next){
tf = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
@@ -5590,7 +5585,7 @@ static void collapseuvs(EditMesh *em, EditVert *mergevert)
uvcount += 1;
}
if(efa->v2->f1 && ELEM(mergevert, NULL, efa->v2)){
- uvav[0] += tf->uv[1][0];
+ uvav[0] += tf->uv[1][0];
uvav[1] += tf->uv[1][1];
uvcount += 1;
}
@@ -5605,11 +5600,11 @@ static void collapseuvs(EditMesh *em, EditVert *mergevert)
uvcount += 1;
}
}
-
+
if(uvcount > 0) {
- uvav[0] /= uvcount;
+ uvav[0] /= uvcount;
uvav[1] /= uvcount;
-
+
for(efa = em->faces.first; efa; efa=efa->next){
tf = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
@@ -5618,7 +5613,7 @@ static void collapseuvs(EditMesh *em, EditVert *mergevert)
tf->uv[0][1] = uvav[1];
}
if(efa->v2->f1){
- tf->uv[1][0] = uvav[0];
+ tf->uv[1][0] = uvav[0];
tf->uv[1][1] = uvav[1];
}
if(efa->v3->f1){
@@ -5637,49 +5632,49 @@ int collapseEdges(EditMesh *em)
{
EditVert *eve;
EditEdge *eed;
-
+
ListBase allcollections;
CollectedEdge *curredge;
Collection *edgecollection;
-
+
int totedges, groupcount, mergecount,vcount;
float avgcount[3];
-
+
allcollections.first = 0;
allcollections.last = 0;
-
+
mergecount = 0;
-
+
build_edgecollection(em, &allcollections);
groupcount = BLI_countlist(&allcollections);
-
-
+
+
for(edgecollection = allcollections.first; edgecollection; edgecollection = edgecollection->next){
totedges = BLI_countlist(&(edgecollection->collectionbase));
mergecount += totedges;
avgcount[0] = 0; avgcount[1] = 0; avgcount[2] = 0;
-
+
vcount = 0;
-
+
for(curredge = edgecollection->collectionbase.first; curredge; curredge = curredge->next){
avgcount[0] += ((EditEdge*)curredge->eed)->v1->co[0];
avgcount[1] += ((EditEdge*)curredge->eed)->v1->co[1];
avgcount[2] += ((EditEdge*)curredge->eed)->v1->co[2];
-
+
avgcount[0] += ((EditEdge*)curredge->eed)->v2->co[0];
avgcount[1] += ((EditEdge*)curredge->eed)->v2->co[1];
avgcount[2] += ((EditEdge*)curredge->eed)->v2->co[2];
-
+
vcount +=2;
}
-
+
avgcount[0] /= vcount; avgcount[1] /=vcount; avgcount[2] /= vcount;
-
+
for(curredge = edgecollection->collectionbase.first; curredge; curredge = curredge->next){
VECCOPY(((EditEdge*)curredge->eed)->v1->co,avgcount);
VECCOPY(((EditEdge*)curredge->eed)->v2->co,avgcount);
}
-
+
if (EM_texFaceCheck(em)) {
/*uv collapse*/
for(eve=em->verts.first; eve; eve=eve->next) eve->f1 = 0;
@@ -5691,7 +5686,7 @@ int collapseEdges(EditMesh *em)
}
collapse_edgeuvs(em);
}
-
+
}
freecollections(&allcollections);
removedoublesflag(em, 1, 0, MERGELIMIT);
@@ -5703,44 +5698,44 @@ int merge_firstlast(EditMesh *em, int first, int uvmerge)
{
EditVert *eve,*mergevert;
EditSelection *ese;
-
+
/* do sanity check in mergemenu in edit.c ?*/
- if(first == 0){
+ if(first == 0){
ese = em->selected.last;
mergevert= (EditVert*)ese->data;
}
- else{
+ else{
ese = em->selected.first;
mergevert = (EditVert*)ese->data;
}
-
+
if(mergevert->f&SELECT){
for (eve=em->verts.first; eve; eve=eve->next){
if (eve->f&SELECT)
VECCOPY(eve->co,mergevert->co);
}
}
-
+
if(uvmerge && CustomData_has_layer(&em->fdata, CD_MTFACE)){
-
+
for(eve=em->verts.first; eve; eve=eve->next) eve->f1 = 0;
for(eve=em->verts.first; eve; eve=eve->next){
if(eve->f&SELECT) eve->f1 = 1;
}
collapseuvs(em, mergevert);
}
-
+
return removedoublesflag(em, 1, 0, MERGELIMIT);
}
int merge_target(EditMesh *em, int target, int uvmerge)
{
EditVert *eve;
-
+
// XXX not working
if(target) snap_sel_to_curs();
else snap_to_center();
-
+
if(uvmerge && CustomData_has_layer(&em->fdata, CD_MTFACE)){
for(eve=em->verts.first; eve; eve=eve->next) eve->f1 = 0;
for(eve=em->verts.first; eve; eve=eve->next){
@@ -5804,19 +5799,19 @@ static EnumPropertyItem *merge_type_itemf(bContext *C, PointerRNA *ptr, int *fre
Object *obedit= CTX_data_edit_object(C);
if(obedit && obedit->type == OB_MESH) {
- EditMesh *em= BKE_mesh_get_editmesh(obedit->data);
+ EditMesh *em= BKE_mesh_get_editmesh(obedit->data);
EnumPropertyItem *item= NULL;
int totitem= 0;
if(em->selectmode & SCE_SELECT_VERTEX) {
- if(em->selected.first && em->selected.last &&
+ if(em->selected.first && em->selected.last &&
((EditSelection*)em->selected.first)->type == EDITVERT && ((EditSelection*)em->selected.last)->type == EDITVERT) {
RNA_enum_item_add(&item, &totitem, &merge_type_items[0]);
RNA_enum_item_add(&item, &totitem, &merge_type_items[1]);
}
- else if(em->selected.first && ((EditSelection*)em->selected.first)->type == EDITVERT)
+ else if(em->selected.first && ((EditSelection*)em->selected.first)->type == EDITVERT)
RNA_enum_item_add(&item, &totitem, &merge_type_items[1]);
- else if(em->selected.last && ((EditSelection*)em->selected.last)->type == EDITVERT)
+ else if(em->selected.last && ((EditSelection*)em->selected.last)->type == EDITVERT)
RNA_enum_item_add(&item, &totitem, &merge_type_items[0]);
}
@@ -5840,12 +5835,12 @@ void MESH_OT_merge(wmOperatorType *ot)
/* identifiers */
ot->name= "Merge";
ot->idname= "MESH_OT_merge";
-
+
/* api callbacks */
ot->exec= merge_exec;
ot->invoke= WM_menu_invoke;
ot->poll= ED_operator_editmesh;
-
+
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -5887,30 +5882,30 @@ int select_vertex_path_exec(bContext *C, wmOperator *op)
short physical;
float *cost;
Heap *heap; /*binary heap for sorting pointers to PathNodes based upon a 'cost'*/
-
+
s = t = NULL;
-
+
ese = ((EditSelection*)em->selected.last);
if(ese && ese->type == EDITVERT && ese->prev && ese->prev->type == EDITVERT){
physical= pupmenu("Distance Method? %t|Edge Length%x1|Topological%x0");
-
+
t = (EditVert*)ese->data;
s = (EditVert*)ese->prev->data;
-
+
/*need to find out if t is actually reachable by s....*/
- for(eve=em->verts.first; eve; eve=eve->next){
+ for(eve=em->verts.first; eve; eve=eve->next){
eve->f1 = 0;
}
-
+
s->f1 = 1;
-
+
unbalanced = 1;
totnodes = 1;
while(unbalanced){
unbalanced = 0;
for(eed=em->edges.first; eed; eed=eed->next){
if(!eed->h){
- if(eed->v1->f1 && !eed->v2->f1){
+ if(eed->v1->f1 && !eed->v2->f1){
eed->v2->f1 = 1;
totnodes++;
unbalanced = 1;
@@ -5923,7 +5918,7 @@ int select_vertex_path_exec(bContext *C, wmOperator *op)
}
}
}
-
+
if(s->f1 && t->f1){ /* t can be reached by s */
Q = MEM_callocN(sizeof(PathNode)*totnodes, "Path Select Nodes");
totnodes = 0;
@@ -5938,12 +5933,12 @@ int select_vertex_path_exec(bContext *C, wmOperator *op)
}
else eve->tmp.p = NULL;
}
-
+
for(eed=em->edges.first; eed; eed=eed->next){
if(!eed->h){
if(eed->v1->f1){
currpn = ((PathNode*)eed->v1->tmp.p);
-
+
newpe = MEM_mallocN(sizeof(PathEdge), "Path Edge");
newpe->v = ((PathNode*)eed->v2->tmp.p)->u;
if(physical){
@@ -5953,9 +5948,9 @@ int select_vertex_path_exec(bContext *C, wmOperator *op)
newpe->next = 0;
newpe->prev = 0;
BLI_addtail(&(currpn->edges), newpe);
- }
+ }
if(eed->v2->f1){
- currpn = ((PathNode*)eed->v2->tmp.p);
+ currpn = ((PathNode*)eed->v2->tmp.p);
newpe = MEM_mallocN(sizeof(PathEdge), "Path Edge");
newpe->v = ((PathNode*)eed->v1->tmp.p)->u;
if(physical){
@@ -5968,28 +5963,28 @@ int select_vertex_path_exec(bContext *C, wmOperator *op)
}
}
}
-
+
heap = BLI_heap_new();
cost = MEM_callocN(sizeof(float)*totnodes, "Path Select Costs");
previous = MEM_callocN(sizeof(int)*totnodes, "PathNode indices");
-
+
for(v=0; v < totnodes; v++){
cost[v] = 1000000;
previous[v] = -1; /*array of indices*/
}
-
+
pnindex = ((PathNode*)s->tmp.p)->u;
cost[pnindex] = 0;
BLI_heap_insert(heap, 0.0f, SET_INT_IN_POINTER(pnindex));
-
+
while( !BLI_heap_empty(heap) ){
-
+
pnindex = GET_INT_FROM_POINTER(BLI_heap_popmin(heap));
currpn = &(Q[pnindex]);
-
+
if(currpn == (PathNode*)t->tmp.p) /*target has been reached....*/
break;
-
+
for(currpe=currpn->edges.first; currpe; currpe=currpe->next){
if(!Q[currpe->v].visited){
if( cost[currpe->v] > (cost[currpn->u ] + currpe->w) ){
@@ -6001,7 +5996,7 @@ int select_vertex_path_exec(bContext *C, wmOperator *op)
}
}
}
-
+
pathvert = ((PathNode*)t->tmp.p)->u;
while(pathvert != -1){
for(eve=em->verts.first; eve; eve=eve->next){
@@ -6011,7 +6006,7 @@ int select_vertex_path_exec(bContext *C, wmOperator *op)
}
pathvert = previous[pathvert];
}
-
+
for(v=0; v < totnodes; v++) BLI_freelistN(&(Q[v].edges));
MEM_freeN(Q);
MEM_freeN(cost);
@@ -6025,7 +6020,7 @@ int select_vertex_path_exec(bContext *C, wmOperator *op)
BKE_report(op->reports, RPT_ERROR, "Path Selection requires that exactly two vertices be selected");
return OPERATOR_CANCELLED;
}
-
+
WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
BKE_mesh_end_editmesh(obedit->data, em);
@@ -6042,12 +6037,12 @@ void MESH_OT_select_vertex_path(wmOperatorType *ot)
/* identifiers */
ot->name= "Select Vertex Path";
ot->idname= "MESH_OT_select_vertex_path";
-
+
/* api callbacks */
ot->exec= select_vertex_path_exec;
ot->invoke= WM_menu_invoke;
ot->poll= ED_operator_editmesh;
-
+
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -6064,9 +6059,9 @@ static int region_to_loop(bContext *C, wmOperator *op)
EditEdge *eed;
EditFace *efa;
int selected= 0;
-
+
for(eed=em->edges.first; eed; eed=eed->next) eed->f1 = 0;
-
+
for(efa=em->faces.first; efa; efa=efa->next){
if(efa->f&SELECT){
efa->e1->f1++;
@@ -6081,20 +6076,20 @@ static int region_to_loop(bContext *C, wmOperator *op)
if(!selected)
return OPERATOR_CANCELLED;
-
+
EM_clear_flag_all(em, SELECT);
-
+
for(eed=em->edges.first; eed; eed=eed->next){
if(eed->f1 == 1) EM_select_edge(eed, 1);
}
-
+
em->selectmode = SCE_SELECT_EDGE;
EM_selectmode_set(em);
-
+
BKE_mesh_end_editmesh(obedit->data, em);
WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
-
+
return OPERATOR_FINISHED;
}
@@ -6103,11 +6098,11 @@ void MESH_OT_region_to_loop(wmOperatorType *ot)
/* identifiers */
ot->name= "Region to Loop";
ot->idname= "MESH_OT_region_to_loop";
-
+
/* api callbacks */
ot->exec= region_to_loop;
ot->poll= ED_operator_editmesh;
-
+
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
}
@@ -6117,7 +6112,7 @@ static int validate_loop(EditMesh *em, Collection *edgecollection)
EditEdge *eed;
EditFace *efa;
CollectedEdge *curredge;
-
+
/*1st test*/
for(curredge = (CollectedEdge*)edgecollection->collectionbase.first; curredge; curredge=curredge->next){
curredge->eed->v1->f1 = 0;
@@ -6131,7 +6126,7 @@ static int validate_loop(EditMesh *em, Collection *edgecollection)
if(curredge->eed->v1->f1 > 2) return(0); else
if(curredge->eed->v2->f1 > 2) return(0);
}
-
+
/*2nd test*/
for(eed = em->edges.first; eed; eed=eed->next) eed->f1 = 0;
for(efa=em->faces.first; efa; efa=efa->next){
@@ -6147,20 +6142,20 @@ static int validate_loop(EditMesh *em, Collection *edgecollection)
}
static int loop_bisect(EditMesh *em, Collection *edgecollection){
-
+
EditFace *efa, *sf1, *sf2;
EditEdge *eed, *sed;
CollectedEdge *curredge;
int totsf1, totsf2, unbalanced,balancededges;
-
+
for(eed=em->edges.first; eed; eed=eed->next) eed->f1 = eed->f2 = 0;
- for(efa=em->faces.first; efa; efa=efa->next) efa->f1 = 0;
-
+ for(efa=em->faces.first; efa; efa=efa->next) efa->f1 = 0;
+
for(curredge = (CollectedEdge*)edgecollection->collectionbase.first; curredge; curredge=curredge->next) curredge->eed->f1 = 1;
-
+
sf1 = sf2 = NULL;
sed = ((CollectedEdge*)edgecollection->collectionbase.first)->eed;
-
+
for(efa=em->faces.first; efa; efa=efa->next){
if(sf2) break;
else if(sf1){
@@ -6170,24 +6165,24 @@ static int loop_bisect(EditMesh *em, Collection *edgecollection){
if(efa->e1 == sed || efa->e2 == sed || efa->e3 == sed || ( (efa->e4) ? efa->e4 == sed : 0) ) sf1 = efa;
}
}
-
+
if(sf1==NULL || sf2==NULL)
return(-1);
-
+
if(!(sf1->e1->f1)) sf1->e1->f2 = 1;
if(!(sf1->e2->f1)) sf1->e2->f2 = 1;
if(!(sf1->e3->f1)) sf1->e3->f2 = 1;
if(sf1->e4 && !(sf1->e4->f1)) sf1->e4->f2 = 1;
sf1->f1 = 1;
totsf1 = 1;
-
+
if(!(sf2->e1->f1)) sf2->e1->f2 = 2;
if(!(sf2->e2->f1)) sf2->e2->f2 = 2;
if(!(sf2->e3->f1)) sf2->e3->f2 = 2;
if(sf2->e4 && !(sf2->e4->f1)) sf2->e4->f2 = 2;
sf2->f1 = 2;
totsf2 = 1;
-
+
/*do sf1*/
unbalanced = 1;
while(unbalanced){
@@ -6209,7 +6204,7 @@ static int loop_bisect(EditMesh *em, Collection *edgecollection){
}
}
}
-
+
/*do sf2*/
unbalanced = 1;
while(unbalanced){
@@ -6231,7 +6226,7 @@ static int loop_bisect(EditMesh *em, Collection *edgecollection){
}
}
}
-
+
if(totsf1 < totsf2) return(1);
else return(2);
}
@@ -6246,9 +6241,9 @@ static int loop_to_region(bContext *C, wmOperator *op)
ListBase allcollections={NULL,NULL};
Collection *edgecollection;
int testflag;
-
+
build_edgecollection(em, &allcollections);
-
+
for(edgecollection = (Collection *)allcollections.first; edgecollection; edgecollection=edgecollection->next){
if(validate_loop(em, edgecollection)){
testflag = loop_bisect(em, edgecollection);
@@ -6260,11 +6255,11 @@ static int loop_to_region(bContext *C, wmOperator *op)
}
}
}
-
+
for(efa=em->faces.first; efa; efa=efa->next){ /*fix this*/
if(efa->f&SELECT) EM_select_face(efa,1);
}
-
+
freecollections(&allcollections);
BKE_mesh_end_editmesh(obedit->data, em);
@@ -6278,11 +6273,11 @@ void MESH_OT_loop_to_region(wmOperatorType *ot)
/* identifiers */
ot->name= "Loop to Region";
ot->idname= "MESH_OT_loop_to_region";
-
+
/* api callbacks */
ot->exec= loop_to_region;
ot->poll= ED_operator_editmesh;
-
+
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
}
@@ -6309,41 +6304,41 @@ static int mesh_rotate_uvs(bContext *C, wmOperator *op)
BKE_mesh_end_editmesh(obedit->data, em);
return OPERATOR_CANCELLED;
}
-
+
for(efa=em->faces.first; efa; efa=efa->next) {
if (efa->f & SELECT) {
tf = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
u1= tf->uv[0][0];
v1= tf->uv[0][1];
-
+
if (dir == DIRECTION_CCW) {
if(efa->v4) {
tf->uv[0][0]= tf->uv[3][0];
tf->uv[0][1]= tf->uv[3][1];
-
+
tf->uv[3][0]= tf->uv[2][0];
tf->uv[3][1]= tf->uv[2][1];
} else {
tf->uv[0][0]= tf->uv[2][0];
tf->uv[0][1]= tf->uv[2][1];
}
-
+
tf->uv[2][0]= tf->uv[1][0];
tf->uv[2][1]= tf->uv[1][1];
-
+
tf->uv[1][0]= u1;
tf->uv[1][1]= v1;
- } else {
+ } else {
tf->uv[0][0]= tf->uv[1][0];
tf->uv[0][1]= tf->uv[1][1];
-
+
tf->uv[1][0]= tf->uv[2][0];
tf->uv[1][1]= tf->uv[2][1];
-
+
if(efa->v4) {
tf->uv[2][0]= tf->uv[3][0];
tf->uv[2][1]= tf->uv[3][1];
-
+
tf->uv[3][0]= u1;
tf->uv[3][1]= v1;
}
@@ -6355,7 +6350,7 @@ static int mesh_rotate_uvs(bContext *C, wmOperator *op)
change = 1;
}
}
-
+
BKE_mesh_end_editmesh(obedit->data, em);
if(!change)
@@ -6363,7 +6358,7 @@ static int mesh_rotate_uvs(bContext *C, wmOperator *op)
DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
-
+
return OPERATOR_FINISHED;
}
@@ -6378,13 +6373,13 @@ static int mesh_mirror_uvs(bContext *C, wmOperator *op)
MTFace *tf;
float u1, v1;
int axis= RNA_enum_get(op->ptr, "axis");
-
+
if (!EM_texFaceCheck(em)) {
BKE_report(op->reports, RPT_ERROR, "Mesh has no uv/image layers.");
BKE_mesh_end_editmesh(obedit->data, em);
return OPERATOR_CANCELLED;
}
-
+
for(efa=em->faces.first; efa; efa=efa->next) {
if (efa->f & SELECT) {
tf = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
@@ -6392,10 +6387,10 @@ static int mesh_mirror_uvs(bContext *C, wmOperator *op)
u1= tf->uv[1][0];
v1= tf->uv[1][1];
if(efa->v4) {
-
+
tf->uv[1][0]= tf->uv[2][0];
tf->uv[1][1]= tf->uv[2][1];
-
+
tf->uv[2][0]= u1;
tf->uv[2][1]= v1;
@@ -6404,7 +6399,7 @@ static int mesh_mirror_uvs(bContext *C, wmOperator *op)
tf->uv[3][0]= tf->uv[0][0];
tf->uv[3][1]= tf->uv[0][1];
-
+
tf->uv[0][0]= u1;
tf->uv[0][1]= v1;
}
@@ -6414,15 +6409,15 @@ static int mesh_mirror_uvs(bContext *C, wmOperator *op)
tf->uv[2][0]= u1;
tf->uv[2][1]= v1;
}
-
+
} else {
u1= tf->uv[0][0];
v1= tf->uv[0][1];
if(efa->v4) {
-
+
tf->uv[0][0]= tf->uv[1][0];
tf->uv[0][1]= tf->uv[1][1];
-
+
tf->uv[1][0]= u1;
tf->uv[1][1]= v1;
@@ -6431,7 +6426,7 @@ static int mesh_mirror_uvs(bContext *C, wmOperator *op)
tf->uv[3][0]= tf->uv[2][0];
tf->uv[3][1]= tf->uv[2][1];
-
+
tf->uv[2][0]= u1;
tf->uv[2][1]= v1;
}
@@ -6445,7 +6440,7 @@ static int mesh_mirror_uvs(bContext *C, wmOperator *op)
change = 1;
}
}
-
+
BKE_mesh_end_editmesh(obedit->data, em);
if(!change)
@@ -6467,18 +6462,18 @@ static int mesh_rotate_colors(bContext *C, wmOperator *op)
short change = 0;
MCol tmpcol, *mcol;
int dir= RNA_enum_get(op->ptr, "direction");
-
+
if (!EM_vertColorCheck(em)) {
BKE_report(op->reports, RPT_ERROR, "Mesh has no color layers.");
BKE_mesh_end_editmesh(obedit->data, em);
return OPERATOR_CANCELLED;
}
-
+
for(efa=em->faces.first; efa; efa=efa->next) {
if (efa->f & SELECT) {
mcol = CustomData_em_get(&em->fdata, efa->data, CD_MCOL);
tmpcol= mcol[0];
-
+
if (dir == DIRECTION_CCW) {
if(efa->v4) {
mcol[0]= mcol[3];
@@ -6491,7 +6486,7 @@ static int mesh_rotate_colors(bContext *C, wmOperator *op)
} else {
mcol[0]= mcol[1];
mcol[1]= mcol[2];
-
+
if(efa->v4) {
mcol[2]= mcol[3];
mcol[3]= tmpcol;
@@ -6502,7 +6497,7 @@ static int mesh_rotate_colors(bContext *C, wmOperator *op)
change = 1;
}
}
-
+
BKE_mesh_end_editmesh(obedit->data, em);
if(!change)
@@ -6525,13 +6520,13 @@ static int mesh_mirror_colors(bContext *C, wmOperator *op)
short change = 0;
MCol tmpcol, *mcol;
int axis= RNA_enum_get(op->ptr, "axis");
-
+
if (!EM_vertColorCheck(em)) {
BKE_report(op->reports, RPT_ERROR, "Mesh has no color layers");
BKE_mesh_end_editmesh(obedit->data, em);
return OPERATOR_CANCELLED;
}
-
+
for(efa=em->faces.first; efa; efa=efa->next) {
if (efa->f & SELECT) {
mcol = CustomData_em_get(&em->fdata, efa->data, CD_MCOL);
@@ -6539,7 +6534,7 @@ static int mesh_mirror_colors(bContext *C, wmOperator *op)
tmpcol= mcol[1];
mcol[1]= mcol[2];
mcol[2]= tmpcol;
-
+
if(efa->v4) {
tmpcol= mcol[0];
mcol[0]= mcol[3];
@@ -6549,7 +6544,7 @@ static int mesh_mirror_colors(bContext *C, wmOperator *op)
tmpcol= mcol[0];
mcol[0]= mcol[1];
mcol[1]= tmpcol;
-
+
if(efa->v4) {
tmpcol= mcol[2];
mcol[2]= mcol[3];
@@ -6559,7 +6554,7 @@ static int mesh_mirror_colors(bContext *C, wmOperator *op)
change = 1;
}
}
-
+
BKE_mesh_end_editmesh(obedit->data, em);
if(!change)
@@ -6576,11 +6571,11 @@ void MESH_OT_uvs_rotate(wmOperatorType *ot)
/* identifiers */
ot->name= "Rotate UVs";
ot->idname= "MESH_OT_uvs_rotate";
-
+
/* api callbacks */
ot->exec= mesh_rotate_uvs;
ot->poll= ED_operator_editmesh;
-
+
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -6593,14 +6588,14 @@ void MESH_OT_uvs_mirror(wmOperatorType *ot)
/* identifiers */
ot->name= "Mirror UVs";
ot->idname= "MESH_OT_uvs_mirror";
-
+
/* api callbacks */
ot->exec= mesh_mirror_uvs;
ot->poll= ED_operator_editmesh;
-
+
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
-
+
/* props */
RNA_def_enum(ot->srna, "axis", axis_items, DIRECTION_CW, "Axis", "Axis to mirror UVs around.");
}
@@ -6610,14 +6605,14 @@ void MESH_OT_colors_rotate(wmOperatorType *ot)
/* identifiers */
ot->name= "Rotate Colors";
ot->idname= "MESH_OT_colors_rotate";
-
+
/* api callbacks */
ot->exec= mesh_rotate_colors;
ot->poll= ED_operator_editmesh;
-
+
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
-
+
/* props */
RNA_def_enum(ot->srna, "direction", direction_items, DIRECTION_CW, "Direction", "Direction to rotate edge around.");
}
@@ -6627,14 +6622,14 @@ void MESH_OT_colors_mirror(wmOperatorType *ot)
/* identifiers */
ot->name= "Mirror Colors";
ot->idname= "MESH_OT_colors_mirror";
-
+
/* api callbacks */
ot->exec= mesh_mirror_colors;
ot->poll= ED_operator_editmesh;
-
+
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
-
+
/* props */
RNA_def_enum(ot->srna, "axis", axis_items, DIRECTION_CW, "Axis", "Axis to mirror colors around.");
}
@@ -6642,7 +6637,7 @@ void MESH_OT_colors_mirror(wmOperatorType *ot)
/********************** Subdivide Operator *************************/
static int subdivide_exec(bContext *C, wmOperator *op)
-{
+{
Scene *scene = CTX_data_scene(C);
Object *obedit= CTX_data_edit_object(C);
EditMesh *em= BKE_mesh_get_editmesh((Mesh *)obedit->data);
@@ -6660,7 +6655,7 @@ static int subdivide_exec(bContext *C, wmOperator *op)
DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
-
+
return OPERATOR_FINISHED;
}
@@ -6669,14 +6664,14 @@ void MESH_OT_subdivide(wmOperatorType *ot)
/* identifiers */
ot->name= "Subdivide";
ot->idname= "MESH_OT_subdivide";
-
+
/* api callbacks */
ot->exec= subdivide_exec;
ot->poll= ED_operator_editmesh;
-
+
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
-
+
/* properties */
RNA_def_int(ot->srna, "number_cuts", 1, 1, 10, "Number of Cuts", "", 1, INT_MAX);
RNA_def_float(ot->srna, "fractal", 0.0, 0.0f, FLT_MAX, "Fractal", "Fractal randomness factor.", 0.0f, 1000.0f);
@@ -6698,39 +6693,39 @@ static void beauty_fill(EditMesh *em)
EVPtr *efaa;
float len1, len2, len3, len4, len5, len6, opp1, opp2, fac1, fac2;
int totedge, ok, notbeauty=8, onedone, vindex[4];
-
+
/* - all selected edges with two faces
* - find the faces: store them in edges (using datablock)
* - per edge: - test convex
* - test edge: flip?
* - if true: remedge, addedge, all edges at the edge get new face pointers
*/
-
- EM_selectmode_set(em); // makes sure in selectmode 'face' the edges of selected faces are selected too
-
+
+ EM_selectmode_set(em); // makes sure in selectmode 'face' the edges of selected faces are selected too
+
totedge = count_selected_edges(em->edges.first);
if(totedge==0) return;
-
+
/* temp block with face pointers */
efaar= (EVPTuple *) MEM_callocN(totedge * sizeof(EVPTuple), "beautyfill");
-
+
while (notbeauty) {
notbeauty--;
-
+
ok = collect_quadedges(efaar, em->edges.first, em->faces.first);
-
+
/* there we go */
onedone= 0;
-
+
eed= em->edges.first;
while(eed) {
nexted= eed->next;
-
+
/* f2 is set in collect_quadedges() */
if(eed->f2==2 && eed->h==0) {
-
+
efaa = (EVPtr *) eed->tmp.p;
-
+
/* none of the faces should be treated before, nor be part of fgon */
ok= 1;
efa= efaa[0];
@@ -6739,13 +6734,13 @@ static void beauty_fill(EditMesh *em)
efa= efaa[1];
if(efa->e1->f1 || efa->e2->f1 || efa->e3->f1) ok= 0;
if(efa->fgonf) ok= 0;
-
+
if(ok) {
/* test convex */
givequadverts(efaa[0], efaa[1], &v1, &v2, &v3, &v4, vindex);
if(v1 && v2 && v3 && v4) {
if( convex(v1->co, v2->co, v3->co, v4->co) ) {
-
+
/* test edges */
if( (v1) > (v3) ) {
dia1.v1= v3;
@@ -6755,7 +6750,7 @@ static void beauty_fill(EditMesh *em)
dia1.v1= v1;
dia1.v2= v3;
}
-
+
if( (v2) > (v4) ) {
dia2.v1= v4;
dia2.v2= v2;
@@ -6764,28 +6759,28 @@ static void beauty_fill(EditMesh *em)
dia2.v1= v2;
dia2.v2= v4;
}
-
+
/* testing rule:
* the area divided by the total edge lengths
*/
-
+
len1= VecLenf(v1->co, v2->co);
len2= VecLenf(v2->co, v3->co);
len3= VecLenf(v3->co, v4->co);
len4= VecLenf(v4->co, v1->co);
len5= VecLenf(v1->co, v3->co);
len6= VecLenf(v2->co, v4->co);
-
+
opp1= AreaT3Dfl(v1->co, v2->co, v3->co);
opp2= AreaT3Dfl(v1->co, v3->co, v4->co);
-
+
fac1= opp1/(len1+len2+len5) + opp2/(len3+len4+len5);
-
+
opp1= AreaT3Dfl(v2->co, v3->co, v4->co);
opp2= AreaT3Dfl(v2->co, v4->co, v1->co);
-
+
fac2= opp1/(len2+len3+len6) + opp2/(len4+len1+len6);
-
+
ok= 0;
if(fac1 > fac2) {
if(dia2.v1==eed->v1 && dia2.v2==eed->v2) {
@@ -6794,16 +6789,16 @@ static void beauty_fill(EditMesh *em)
efa->f1= 1;
efa= efaa[1];
efa->f1= 1;
-
+
w= EM_face_from_faces(em, efaa[0], efaa[1],
vindex[0], vindex[1], 4+vindex[2], -1);
w->f |= SELECT;
-
-
+
+
w= EM_face_from_faces(em, efaa[0], efaa[1],
vindex[0], 4+vindex[2], 4+vindex[3], -1);
w->f |= SELECT;
-
+
onedone= 1;
}
}
@@ -6814,39 +6809,39 @@ static void beauty_fill(EditMesh *em)
efa->f1= 1;
efa= efaa[1];
efa->f1= 1;
-
-
+
+
w= EM_face_from_faces(em, efaa[0], efaa[1],
vindex[1], 4+vindex[2], 4+vindex[3], -1);
w->f |= SELECT;
-
-
+
+
w= EM_face_from_faces(em, efaa[0], efaa[1],
vindex[0], 4+vindex[1], 4+vindex[3], -1);
w->f |= SELECT;
-
+
onedone= 1;
}
}
}
}
}
-
+
}
eed= nexted;
}
-
+
free_tagged_edges_faces(em, em->edges.first, em->faces.first);
-
+
if(onedone==0) break;
-
+
EM_selectmode_set(em); // new edges/faces were added
}
-
+
MEM_freeN(efaar);
-
+
EM_select_flush(em);
-
+
}
/* Got this from scanfill.c. You will need to juggle around the
@@ -6857,10 +6852,10 @@ static void fill_mesh(EditMesh *em)
EditEdge *eed,*e1,*nexted;
EditFace *efa,*nextvl, *efan;
short ok;
-
+
if(em==NULL) return;
waitcursor(1);
-
+
/* copy all selected vertices */
eve= em->verts.first;
while(eve) {
@@ -6877,7 +6872,7 @@ static void fill_mesh(EditMesh *em)
while(eed) {
if( (eed->v1->f & SELECT) && (eed->v2->f & SELECT) ) {
e1= BLI_addfilledge(eed->v1->tmp.v, eed->v2->tmp.v);
- e1->v1->xs++;
+ e1->v1->xs++;
e1->v2->xs++;
}
eed= eed->next;
@@ -6895,7 +6890,7 @@ static void fill_mesh(EditMesh *em)
efa->v3->tmp.v->xs--;
if(efa->v4) efa->v4->tmp.v->xs--;
ok= 1;
-
+
}
efa= nextvl;
}
@@ -6914,7 +6909,7 @@ static void fill_mesh(EditMesh *em)
efa= fillfacebase.first;
while(efa) {
/* normals default pointing up */
- efan= addfacelist(em, efa->v3->tmp.v, efa->v2->tmp.v,
+ efan= addfacelist(em, efa->v3->tmp.v, efa->v2->tmp.v,
efa->v1->tmp.v, 0, NULL, NULL);
if(efan) EM_select_face(efan, 1);
efa= efa->next;
@@ -6934,16 +6929,16 @@ static int fill_mesh_exec(bContext *C, wmOperator *op)
Scene *scene= CTX_data_scene(C);
Object *obedit= CTX_data_edit_object(C);
EditMesh *em= BKE_mesh_get_editmesh((Mesh *)obedit->data);
-
+
fill_mesh(em);
BKE_mesh_end_editmesh(obedit->data, em);
DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
-
+
return OPERATOR_FINISHED;
-
+
}
void MESH_OT_fill(wmOperatorType *ot)
@@ -6951,11 +6946,11 @@ void MESH_OT_fill(wmOperatorType *ot)
/* identifiers */
ot->name= "Fill";
ot->idname= "MESH_OT_fill";
-
+
/* api callbacks */
ot->exec= fill_mesh_exec;
ot->poll= ED_operator_editmesh;
-
+
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
}
@@ -6965,14 +6960,14 @@ static int beauty_fill_exec(bContext *C, wmOperator *op)
Scene *scene = CTX_data_scene(C);
Object *obedit= CTX_data_edit_object(C);
EditMesh *em= BKE_mesh_get_editmesh((Mesh *)obedit->data);
-
+
beauty_fill(em);
-
+
BKE_mesh_end_editmesh(obedit->data, em);
DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
-
+
return OPERATOR_FINISHED;
}
@@ -6981,11 +6976,11 @@ void MESH_OT_beauty_fill(wmOperatorType *ot)
/* identifiers */
ot->name= "Beauty Fill";
ot->idname= "MESH_OT_beauty_fill";
-
+
/* api callbacks */
ot->exec= beauty_fill_exec;
ot->poll= ED_operator_editmesh;
-
+
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
}
@@ -6997,12 +6992,12 @@ static int quads_convert_to_tris_exec(bContext *C, wmOperator *op)
Scene *scene= CTX_data_scene(C);
Object *obedit= CTX_data_edit_object(C);
EditMesh *em= BKE_mesh_get_editmesh((Mesh *)obedit->data);
-
+
convert_to_triface(em,0);
-
+
DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
-
+
BKE_mesh_end_editmesh(obedit->data, em);
return OPERATOR_FINISHED;
}
@@ -7012,11 +7007,11 @@ void MESH_OT_quads_convert_to_tris(wmOperatorType *ot)
/* identifiers */
ot->name= "Quads to Tris";
ot->idname= "MESH_OT_quads_convert_to_tris";
-
+
/* api callbacks */
ot->exec= quads_convert_to_tris_exec;
ot->poll= ED_operator_editmesh;
-
+
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
}
@@ -7028,10 +7023,10 @@ static int tris_convert_to_quads_exec(bContext *C, wmOperator *op)
EditMesh *em= BKE_mesh_get_editmesh((Mesh *)obedit->data);
join_triangles(em);
-
+
DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
-
+
BKE_mesh_end_editmesh(obedit->data, em);
return OPERATOR_FINISHED;
}
@@ -7041,11 +7036,11 @@ void MESH_OT_tris_convert_to_quads(wmOperatorType *ot)
/* identifiers */
ot->name= "Tris to Quads";
ot->idname= "MESH_OT_tris_convert_to_quads";
-
+
/* api callbacks */
ot->exec= tris_convert_to_quads_exec;
ot->poll= ED_operator_editmesh;
-
+
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
}
@@ -7055,12 +7050,12 @@ static int edge_flip_exec(bContext *C, wmOperator *op)
Scene *scene= CTX_data_scene(C);
Object *obedit= CTX_data_edit_object(C);
EditMesh *em= BKE_mesh_get_editmesh((Mesh *)obedit->data);
-
+
edge_flip(em);
-
+
DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
-
+
BKE_mesh_end_editmesh(obedit->data, em);
return OPERATOR_FINISHED;
}
@@ -7070,11 +7065,11 @@ void MESH_OT_edge_flip(wmOperatorType *ot)
/* identifiers */
ot->name= "Edge Flip";
ot->idname= "MESH_OT_edge_flip";
-
+
/* api callbacks */
ot->exec= edge_flip_exec;
ot->poll= ED_operator_editmesh;
-
+
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
}
@@ -7086,7 +7081,7 @@ void mesh_set_smooth_faces(EditMesh *em, short smooth)
EditFace *efa;
if(em==NULL) return;
-
+
for(efa= em->faces.first; efa; efa=efa->next) {
if(efa->f & SELECT) {
if(smooth) efa->flag |= ME_SMOOTH;
@@ -7100,14 +7095,14 @@ static int mesh_faces_shade_smooth_exec(bContext *C, wmOperator *op)
Scene *scene= CTX_data_scene(C);
Object *obedit= CTX_data_edit_object(C);
EditMesh *em= BKE_mesh_get_editmesh((Mesh *)obedit->data);
-
+
mesh_set_smooth_faces(em, 1);
-
+
BKE_mesh_end_editmesh(obedit->data, em);
DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
-
+
return OPERATOR_FINISHED;
}
@@ -7116,11 +7111,11 @@ void MESH_OT_faces_shade_smooth(wmOperatorType *ot)
/* identifiers */
ot->name= "Shade Smooth";
ot->idname= "MESH_OT_faces_shade_smooth";
-
+
/* api callbacks */
ot->exec= mesh_faces_shade_smooth_exec;
ot->poll= ED_operator_editmesh;
-
+
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
}
@@ -7130,12 +7125,12 @@ static int mesh_faces_shade_solid_exec(bContext *C, wmOperator *op)
Scene *scene = CTX_data_scene(C);
Object *obedit= CTX_data_edit_object(C);
EditMesh *em= BKE_mesh_get_editmesh((Mesh *)obedit->data);
-
+
mesh_set_smooth_faces(em, 0);
-
+
DAG_object_flush_update(scene, obedit, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
-
+
return OPERATOR_FINISHED;
}
@@ -7144,11 +7139,11 @@ void MESH_OT_faces_shade_solid(wmOperatorType *ot)
/* identifiers */
ot->name= "Shade Flat";
ot->idname= "MESH_OT_faces_shade_solid";
-
+
/* api callbacks */
ot->exec= mesh_faces_shade_solid_exec;
ot->poll= ED_operator_editmesh;
-
+
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
}
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index 016400e0fa9..888a15e2534 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -123,7 +123,7 @@ void setTransformViewMatrices(TransInfo *t)
{
if(t->spacetype==SPACE_VIEW3D && t->ar->regiontype == RGN_TYPE_WINDOW) {
RegionView3D *rv3d = t->ar->regiondata;
-
+
Mat4CpyMat4(t->viewmat, rv3d->viewmat);
Mat4CpyMat4(t->viewinv, rv3d->viewinv);
Mat4CpyMat4(t->persmat, rv3d->persmat);
@@ -137,7 +137,7 @@ void setTransformViewMatrices(TransInfo *t)
Mat4One(t->persinv);
t->persp = V3D_ORTHO;
}
-
+
calculateCenter2D(t);
}
@@ -152,12 +152,12 @@ void convertViewVec(TransInfo *t, float *vec, short dx, short dy)
else if(t->spacetype==SPACE_IMAGE) {
View2D *v2d = t->view;
float divx, divy, aspx, aspy;
-
+
ED_space_image_uv_aspect(t->sa->spacedata.first, &aspx, &aspy);
-
+
divx= v2d->mask.xmax-v2d->mask.xmin;
divy= v2d->mask.ymax-v2d->mask.ymin;
-
+
vec[0]= aspx*(v2d->cur.xmax-v2d->cur.xmin)*(dx)/divx;
vec[1]= aspy*(v2d->cur.ymax-v2d->cur.ymin)*(dy)/divy;
vec[2]= 0.0f;
@@ -165,10 +165,10 @@ void convertViewVec(TransInfo *t, float *vec, short dx, short dy)
else if(ELEM(t->spacetype, SPACE_IPO, SPACE_NLA)) {
View2D *v2d = t->view;
float divx, divy;
-
+
divx= v2d->mask.xmax-v2d->mask.xmin;
divy= v2d->mask.ymax-v2d->mask.ymin;
-
+
vec[0]= (v2d->cur.xmax-v2d->cur.xmin)*(dx) / (divx);
vec[1]= (v2d->cur.ymax-v2d->cur.ymin)*(dy) / (divy);
vec[2]= 0.0f;
@@ -176,10 +176,10 @@ void convertViewVec(TransInfo *t, float *vec, short dx, short dy)
else if(t->spacetype==SPACE_NODE) {
View2D *v2d = &t->ar->v2d;
float divx, divy;
-
+
divx= v2d->mask.xmax-v2d->mask.xmin;
divy= v2d->mask.ymax-v2d->mask.ymin;
-
+
vec[0]= (v2d->cur.xmax-v2d->cur.xmin)*(dx)/divx;
vec[1]= (v2d->cur.ymax-v2d->cur.ymin)*(dy)/divy;
vec[2]= 0.0f;
@@ -205,23 +205,23 @@ void projectIntView(TransInfo *t, float *vec, int *adr)
}
else if(t->spacetype==SPACE_IMAGE) {
float aspx, aspy, v[2];
-
+
ED_space_image_uv_aspect(t->sa->spacedata.first, &aspx, &aspy);
v[0]= vec[0]/aspx;
v[1]= vec[1]/aspy;
-
+
UI_view2d_to_region_no_clip(t->view, v[0], v[1], adr, adr+1);
}
else if(ELEM(t->spacetype, SPACE_IPO, SPACE_NLA)) {
int out[2] = {0, 0};
-
- UI_view2d_view_to_region((View2D *)t->view, vec[0], vec[1], out, out+1);
+
+ UI_view2d_view_to_region((View2D *)t->view, vec[0], vec[1], out, out+1);
adr[0]= out[0];
adr[1]= out[1];
}
else if(t->spacetype==SPACE_SEQ) { /* XXX not tested yet, but should work */
int out[2] = {0, 0};
-
+
UI_view2d_view_to_region((View2D *)t->view, vec[0], vec[1], out, out+1);
adr[0]= out[0];
adr[1]= out[1];
@@ -236,14 +236,14 @@ void projectFloatView(TransInfo *t, float *vec, float *adr)
}
else if(t->spacetype==SPACE_IMAGE) {
int a[2];
-
+
projectIntView(t, vec, a);
adr[0]= a[0];
adr[1]= a[1];
}
else if(ELEM(t->spacetype, SPACE_IPO, SPACE_NLA)) {
int a[2];
-
+
projectIntView(t, vec, a);
adr[0]= a[0];
adr[1]= a[1];
@@ -296,7 +296,7 @@ static void viewRedrawForce(bContext *C, TransInfo *t)
{
if (t->spacetype == SPACE_VIEW3D)
{
- /* Do we need more refined tags? */
+ /* Do we need more refined tags? */
WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL);
}
else if (t->spacetype == SPACE_ACTION) {
@@ -334,7 +334,7 @@ static void viewRedrawForce(bContext *C, TransInfo *t)
static void viewRedrawPost(TransInfo *t)
{
ED_area_headerprint(t->sa, NULL);
-
+
#if 0 // TRANSFORM_FIX_ME
if(t->spacetype==SPACE_VIEW3D) {
allqueue(REDRAWBUTSOBJECT, 0);
@@ -365,7 +365,7 @@ void BIF_selectOrientation() {
char *str_menu = BIF_menustringTransformOrientation("Orientation");
val= pupmenu(str_menu);
MEM_freeN(str_menu);
-
+
if(val >= 0) {
G.vd->twmode = val;
}
@@ -381,18 +381,18 @@ static void view_editmove(unsigned short event)
/* Ctrl: Scroll right */
/* Alt-Shift: Rotate up */
/* Alt-Ctrl: Rotate right */
-
+
/* only work in 3D window for now
* In the end, will have to send to event to a 2D window handler instead
*/
if (Trans.flag & T_2D_EDIT)
return;
-
+
switch(event) {
case WHEELUPMOUSE:
-
+
if( G.qual & LR_SHIFTKEY ) {
- if( G.qual & LR_ALTKEY ) {
+ if( G.qual & LR_ALTKEY ) {
G.qual &= ~LR_SHIFTKEY;
persptoetsen(PAD2);
G.qual |= LR_SHIFTKEY;
@@ -400,23 +400,23 @@ static void view_editmove(unsigned short event)
persptoetsen(PAD2);
}
} else if( G.qual & LR_CTRLKEY ) {
- if( G.qual & LR_ALTKEY ) {
+ if( G.qual & LR_ALTKEY ) {
G.qual &= ~LR_CTRLKEY;
persptoetsen(PAD4);
G.qual |= LR_CTRLKEY;
} else {
persptoetsen(PAD4);
}
- } else if(U.uiflag & USER_WHEELZOOMDIR)
+ } else if(U.uiflag & USER_WHEELZOOMDIR)
persptoetsen(PADMINUS);
else
persptoetsen(PADPLUSKEY);
-
+
refresh = 1;
break;
case WHEELDOWNMOUSE:
if( G.qual & LR_SHIFTKEY ) {
- if( G.qual & LR_ALTKEY ) {
+ if( G.qual & LR_ALTKEY ) {
G.qual &= ~LR_SHIFTKEY;
persptoetsen(PAD8);
G.qual |= LR_SHIFTKEY;
@@ -424,18 +424,18 @@ static void view_editmove(unsigned short event)
persptoetsen(PAD8);
}
} else if( G.qual & LR_CTRLKEY ) {
- if( G.qual & LR_ALTKEY ) {
+ if( G.qual & LR_ALTKEY ) {
G.qual &= ~LR_CTRLKEY;
persptoetsen(PAD6);
G.qual |= LR_CTRLKEY;
} else {
persptoetsen(PAD6);
}
- } else if(U.uiflag & USER_WHEELZOOMDIR)
+ } else if(U.uiflag & USER_WHEELZOOMDIR)
persptoetsen(PADPLUSKEY);
else
persptoetsen(PADMINUS);
-
+
refresh = 1;
break;
}
@@ -500,19 +500,19 @@ void transformEvent(TransInfo *t, wmEvent *event)
{
float mati[3][3] = {{1.0f, 0.0f, 0.0f}, {0.0f, 1.0f, 0.0f}, {0.0f, 0.0f, 1.0f}};
char cmode = constraintModeToChar(t);
-
+
t->redraw |= handleMouseInput(t, &t->mouse, event);
if (event->type == MOUSEMOVE)
{
t->mval[0] = event->x - t->ar->winrct.xmin;
t->mval[1] = event->y - t->ar->winrct.ymin;
-
+
t->redraw = 1;
-
+
applyMouseInput(t, &t->mouse, t->mval, t->values);
}
-
+
if (event->val) {
switch (event->type){
/* enforce redraw of transform when modifiers are used */
@@ -521,7 +521,7 @@ void transformEvent(TransInfo *t, wmEvent *event)
t->modifiers |= MOD_SNAP_GEARS;
t->redraw = 1;
break;
-
+
case LEFTSHIFTKEY:
case RIGHTSHIFTKEY:
t->modifiers |= MOD_CONSTRAINT_PLANE;
@@ -532,7 +532,7 @@ void transformEvent(TransInfo *t, wmEvent *event)
if ((t->spacetype==SPACE_VIEW3D) && event->alt) {
#if 0 // TRANSFORM_FIX_ME
short mval[2];
-
+
getmouseco_sc(mval);
BIF_selectOrientation();
calc_manipulator_stats(curarea);
@@ -544,7 +544,7 @@ void transformEvent(TransInfo *t, wmEvent *event)
t->state = TRANS_CONFIRM;
}
break;
-
+
case MIDDLEMOUSE:
if ((t->flag & T_NO_CONSTRAINT)==0) {
/* exception for switching to dolly, or trackball, in camera view */
@@ -577,19 +577,16 @@ void transformEvent(TransInfo *t, wmEvent *event)
}
break;
case ESCKEY:
- case RIGHTMOUSE:
- printf("cancelled\n");
t->state = TRANS_CANCEL;
break;
- case LEFTMOUSE:
case PADENTER:
case RETKEY:
t->state = TRANS_CONFIRM;
break;
case GKEY:
/* only switch when... */
- if( ELEM3(t->mode, TFM_ROTATION, TFM_RESIZE, TFM_TRACKBALL) ) {
- resetTransRestrictions(t);
+ if( ELEM3(t->mode, TFM_ROTATION, TFM_RESIZE, TFM_TRACKBALL) ) {
+ resetTransRestrictions(t);
restoreTransObjects(t);
initTranslation(t);
initSnapping(t, NULL); // need to reinit after mode change
@@ -598,8 +595,8 @@ void transformEvent(TransInfo *t, wmEvent *event)
break;
case SKEY:
/* only switch when... */
- if( ELEM3(t->mode, TFM_ROTATION, TFM_TRANSLATION, TFM_TRACKBALL) ) {
- resetTransRestrictions(t);
+ if( ELEM3(t->mode, TFM_ROTATION, TFM_TRANSLATION, TFM_TRACKBALL) ) {
+ resetTransRestrictions(t);
restoreTransObjects(t);
initResize(t);
initSnapping(t, NULL); // need to reinit after mode change
@@ -609,9 +606,9 @@ void transformEvent(TransInfo *t, wmEvent *event)
case RKEY:
/* only switch when... */
if( ELEM4(t->mode, TFM_ROTATION, TFM_RESIZE, TFM_TRACKBALL, TFM_TRANSLATION) ) {
-
- resetTransRestrictions(t);
-
+
+ resetTransRestrictions(t);
+
if (t->mode == TFM_ROTATION) {
restoreTransObjects(t);
initTrackball(t);
@@ -771,10 +768,10 @@ void transformEvent(TransInfo *t, wmEvent *event)
// viewmoveNDOF(1);
// break;
}
-
+
// Numerical input events
t->redraw |= handleNumInput(&(t->num), event);
-
+
// NDof input events
switch(handleNDofInput(&(t->ndof), event))
{
@@ -789,7 +786,7 @@ void transformEvent(TransInfo *t, wmEvent *event)
if (t->options & CTX_NDOF)
{
/* Cancel on pure NDOF transform */
- t->state = TRANS_CANCEL;
+ t->state = TRANS_CANCEL;
}
else
{
@@ -807,16 +804,22 @@ void transformEvent(TransInfo *t, wmEvent *event)
case NDOF_REFRESH:
t->redraw = 1;
break;
-
+
}
-
+
// Snapping events
t->redraw |= handleSnapping(t, event);
-
+
//arrows_move_cursor(event->type);
}
else {
switch (event->type){
+ case RIGHTMOUSE:
+ t->state = TRANS_CANCEL;
+ break;
+ case LEFTMOUSE:
+ t->state = TRANS_CONFIRM;
+ break;
case LEFTSHIFTKEY:
case RIGHTSHIFTKEY:
t->modifiers &= ~MOD_CONSTRAINT_PLANE;
@@ -826,7 +829,7 @@ void transformEvent(TransInfo *t, wmEvent *event)
case LEFTCTRLKEY:
case RIGHTCTRLKEY:
t->modifiers &= ~MOD_SNAP_GEARS;
- /* no redraw on release modifier keys! this makes sure you can assign the 'grid' still
+ /* no redraw on release modifier keys! this makes sure you can assign the 'grid' still
after releasing modifer key */
//t->redraw = 1;
break;
@@ -837,15 +840,15 @@ void transformEvent(TransInfo *t, wmEvent *event)
t->redraw = 1;
}
break;
- case LEFTMOUSE:
- case RIGHTMOUSE:
- if(WM_modal_tweak_exit(event, t->event_type))
-// if (t->options & CTX_TWEAK)
- t->state = TRANS_CONFIRM;
- break;
+// case LEFTMOUSE:
+// case RIGHTMOUSE:
+// if(WM_modal_tweak_exit(event, t->event_type))
+//// if (t->options & CTX_TWEAK)
+// t->state = TRANS_CONFIRM;
+// break;
}
}
-
+
// Per transform event, if present
if (t->handleEvent)
t->redraw |= t->handleEvent(t, event);
@@ -859,7 +862,7 @@ int calculateTransformCenter(bContext *C, wmEvent *event, int centerMode, float
t->state = TRANS_RUNNING;
t->options = CTX_NONE;
-
+
t->mode = TFM_DUMMY;
initTransInfo(C, t, NULL, event); // internal data, mouse, vectors
@@ -873,10 +876,10 @@ int calculateTransformCenter(bContext *C, wmEvent *event, int centerMode, float
}
else {
success = 1;
-
+
calculateCenter(t);
-
- // Copy center from constraint center. Transform center can be local
+
+ // Copy center from constraint center. Transform center can be local
VECCOPY(vec, t->con.center);
}
@@ -884,9 +887,9 @@ int calculateTransformCenter(bContext *C, wmEvent *event, int centerMode, float
/* aftertrans does insert ipos and action channels, and clears base flags, doesnt read transdata */
special_aftertrans_update(t);
-
+
MEM_freeN(t);
-
+
return success;
}
@@ -905,28 +908,28 @@ static void drawArrow(ArrowDirection d, short offset, short length, short size)
length = -length;
size = -size;
case RIGHT:
- glBegin(GL_LINES);
- glVertex2s( offset, 0);
- glVertex2s( offset + length, 0);
- glVertex2s( offset + length, 0);
- glVertex2s( offset + length - size, -size);
- glVertex2s( offset + length, 0);
+ glBegin(GL_LINES);
+ glVertex2s( offset, 0);
+ glVertex2s( offset + length, 0);
+ glVertex2s( offset + length, 0);
+ glVertex2s( offset + length - size, -size);
+ glVertex2s( offset + length, 0);
glVertex2s( offset + length - size, size);
- glEnd();
+ glEnd();
break;
case DOWN:
offset = -offset;
length = -length;
size = -size;
case UP:
- glBegin(GL_LINES);
- glVertex2s( 0, offset);
- glVertex2s( 0, offset + length);
- glVertex2s( 0, offset + length);
- glVertex2s(-size, offset + length - size);
- glVertex2s( 0, offset + length);
+ glBegin(GL_LINES);
+ glVertex2s( 0, offset);
+ glVertex2s( 0, offset + length);
+ glVertex2s( 0, offset + length);
+ glVertex2s(-size, offset + length - size);
+ glVertex2s( 0, offset + length);
glVertex2s( size, offset + length - size);
- glEnd();
+ glEnd();
break;
}
}
@@ -938,22 +941,22 @@ static void drawArrowHead(ArrowDirection d, short size)
case LEFT:
size = -size;
case RIGHT:
- glBegin(GL_LINES);
- glVertex2s( 0, 0);
- glVertex2s( -size, -size);
- glVertex2s( 0, 0);
+ glBegin(GL_LINES);
+ glVertex2s( 0, 0);
+ glVertex2s( -size, -size);
+ glVertex2s( 0, 0);
glVertex2s( -size, size);
- glEnd();
+ glEnd();
break;
case DOWN:
size = -size;
case UP:
- glBegin(GL_LINES);
- glVertex2s( 0, 0);
- glVertex2s(-size, -size);
- glVertex2s( 0, 0);
+ glBegin(GL_LINES);
+ glVertex2s( 0, 0);
+ glVertex2s(-size, -size);
+ glVertex2s( 0, 0);
glVertex2s( size, -size);
- glEnd();
+ glEnd();
break;
}
}
@@ -962,15 +965,15 @@ static void drawArc(float size, float angle_start, float angle_end, int segments
{
float delta = (angle_end - angle_start) / segments;
float angle;
-
+
glBegin(GL_LINE_STRIP);
-
+
for( angle = angle_start; angle < angle_end; angle += delta)
{
glVertex2f( cosf(angle) * size, sinf(angle) * size);
}
glVertex2f( cosf(angle_end) * size, sinf(angle_end) * size);
-
+
glEnd();
}
@@ -979,7 +982,7 @@ void drawHelpline(const struct bContext *C, TransInfo *t)
if (t->helpline != HLP_NONE && !(t->flag & T_USES_MANIPULATOR))
{
float vecrot[3], cent[2];
-
+
VECCOPY(vecrot, t->center);
if(t->flag & T_EDIT) {
Object *ob= t->obedit;
@@ -989,9 +992,9 @@ void drawHelpline(const struct bContext *C, TransInfo *t)
Object *ob=t->poseobj;
if(ob) Mat4MulVecfl(ob->obmat, vecrot);
}
-
+
projectFloatView(t, vecrot, cent); // no overflow in extreme cases
-
+
glDisable(GL_DEPTH_TEST);
glMatrixMode(GL_PROJECTION);
@@ -1000,16 +1003,16 @@ void drawHelpline(const struct bContext *C, TransInfo *t)
glPushMatrix();
ED_region_pixelspace(t->ar);
-
+
switch(t->helpline)
{
case HLP_SPRING:
UI_ThemeColor(TH_WIRE);
-
+
setlinestyle(3);
- glBegin(GL_LINE_STRIP);
- glVertex2sv(t->mval);
- glVertex2fv(cent);
+ glBegin(GL_LINE_STRIP);
+ glVertex2sv(t->mval);
+ glVertex2fv(cent);
glEnd();
glTranslatef(t->mval[0], t->mval[1], 0);
@@ -1037,7 +1040,7 @@ void drawHelpline(const struct bContext *C, TransInfo *t)
glTranslatef(t->mval[0], t->mval[1], 0);
glLineWidth(3.0);
- glBegin(GL_LINES);
+ glBegin(GL_LINES);
drawArrow(UP, 5, 10, 5);
drawArrow(DOWN, 5, 10, 5);
glLineWidth(1.0);
@@ -1050,27 +1053,27 @@ void drawHelpline(const struct bContext *C, TransInfo *t)
float delta_angle = MIN2(15 / dist, M_PI/4);
float spacing_angle = MIN2(5 / dist, M_PI/12);
UI_ThemeColor(TH_WIRE);
-
+
setlinestyle(3);
- glBegin(GL_LINE_STRIP);
- glVertex2sv(t->mval);
- glVertex2fv(cent);
+ glBegin(GL_LINE_STRIP);
+ glVertex2sv(t->mval);
+ glVertex2fv(cent);
glEnd();
-
+
glTranslatef(cent[0], cent[1], 0);
-
+
setlinestyle(0);
glLineWidth(3.0);
drawArc(dist, angle - delta_angle, angle - spacing_angle, 10);
drawArc(dist, angle + spacing_angle, angle + delta_angle, 10);
-
+
glPushMatrix();
glTranslatef(cosf(angle - delta_angle) * dist, sinf(angle - delta_angle) * dist, 0);
glRotatef(180 / M_PI * (angle - delta_angle), 0, 0, 1);
-
+
drawArrowHead(DOWN, 5);
-
+
glPopMatrix();
glTranslatef(cosf(angle + delta_angle) * dist, sinf(angle + delta_angle) * dist, 0);
@@ -1085,32 +1088,32 @@ void drawHelpline(const struct bContext *C, TransInfo *t)
{
char col[3], col2[3];
UI_GetThemeColor3ubv(TH_GRID, col);
-
+
glTranslatef(t->mval[0], t->mval[1], 0);
-
+
glLineWidth(3.0);
-
+
UI_make_axis_color(col, col2, 'x');
glColor3ubv((GLubyte *)col2);
-
+
drawArrow(RIGHT, 5, 10, 5);
drawArrow(LEFT, 5, 10, 5);
-
+
UI_make_axis_color(col, col2, 'y');
glColor3ubv((GLubyte *)col2);
-
+
drawArrow(UP, 5, 10, 5);
drawArrow(DOWN, 5, 10, 5);
glLineWidth(1.0);
break;
}
}
-
+
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
-
+
glEnable(GL_DEPTH_TEST);
}
}
@@ -1118,7 +1121,7 @@ void drawHelpline(const struct bContext *C, TransInfo *t)
void drawTransform(const struct bContext *C, struct ARegion *ar, void *arg)
{
TransInfo *t = arg;
-
+
drawConstraint(C, t);
drawPropCircle(C, t);
drawSnapping(C, t);
@@ -1164,7 +1167,7 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
{
RNA_boolean_set(op->ptr, "mirror", t->flag & T_MIRROR);
}
-
+
if (RNA_struct_find_property(op->ptr, "constraint_axis"))
{
RNA_int_set(op->ptr, "constraint_orientation", t->current_orientation);
@@ -1194,7 +1197,7 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
if(t->spacetype == SPACE_VIEW3D)
{
View3D *v3d = t->view;
-
+
v3d->twmode = t->current_orientation;
}
}
@@ -1209,7 +1212,7 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int
t->state = TRANS_RUNNING;
t->options = options;
-
+
t->mode = mode;
if (!initTransInfo(C, t, op, event)) // internal data, mouse, vectors
@@ -1221,7 +1224,7 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int
{
//calc_manipulator_stats(curarea);
initTransformOrientation(C, t);
-
+
t->draw_handle = ED_region_draw_cb_activate(t->ar->type, drawTransform, t, REGION_DRAW_POST);
}
else if(t->spacetype == SPACE_IMAGE) {
@@ -1244,10 +1247,10 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int
/* EVIL2: we gave as argument also texture space context bit... was cleared */
/* EVIL3: extend mode for animation editors also switches modes... but is best way to avoid duplicate code */
mode = t->mode;
-
+
calculatePropRatio(t);
calculateCenter(t);
-
+
initMouseInput(t, &t->mouse, t->center2d, t->imval);
switch (mode) {
@@ -1311,11 +1314,11 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int
case TFM_TIME_SCALE:
initTimeScale(t);
break;
- case TFM_TIME_EXTEND:
+ case TFM_TIME_EXTEND:
/* now that transdata has been made, do like for TFM_TIME_TRANSLATE (for most Animation
* Editors because they have only 1D transforms for time values) or TFM_TRANSLATION
* (for Graph/NLA Editors only since they uses 'standard' transforms to get 2D movement)
- * depending on which editor this was called from
+ * depending on which editor this was called from
*/
if ELEM(t->spacetype, SPACE_IPO, SPACE_NLA)
initTranslation(t);
@@ -1369,11 +1372,11 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int
if (constraint_axis[2]) {
t->con.mode |= CON_AXIS2;
}
-
- setUserConstraint(t, t->con.mode, "%s");
+
+ setUserConstraint(t, t->con.mode, "%s");
}
}
-
+
return 1;
}
@@ -1392,7 +1395,7 @@ void transformApply(bContext *C, TransInfo *t)
t->redraw = 0;
}
- /* If auto confirm is on, break after one pass */
+ /* If auto confirm is on, break after one pass */
if (t->options & CTX_AUTOCONFIRM)
{
t->state = TRANS_CONFIRM;
@@ -1409,7 +1412,7 @@ void transformApply(bContext *C, TransInfo *t)
int transformEnd(bContext *C, TransInfo *t)
{
int exit_code = OPERATOR_RUNNING_MODAL;
-
+
if (t->state != TRANS_RUNNING)
{
/* handle restoring objects */
@@ -1422,16 +1425,16 @@ int transformEnd(bContext *C, TransInfo *t)
{
exit_code = OPERATOR_FINISHED;
}
-
+
/* free data */
postTrans(t);
-
+
/* aftertrans does insert keyframes, and clears base flags, doesnt read transdata */
special_aftertrans_update(t);
-
+
/* send events out for redraws */
viewRedrawPost(t);
-
+
/* Undo as last, certainly after special_trans_update! */
if(t->state == TRANS_CANCEL) {
@@ -1445,7 +1448,7 @@ int transformEnd(bContext *C, TransInfo *t)
viewRedrawForce(C, t);
}
-
+
return exit_code;
}
@@ -1454,14 +1457,14 @@ int transformEnd(bContext *C, TransInfo *t)
void initManipulator(int mode)
{
printf("init manipulator mode %d\n", mode);
-
+
#if 0 // TRANSFORM_FIX_ME
Trans.state = TRANS_RUNNING;
Trans.options = CTX_NONE;
-
+
Trans.mode = mode;
-
+
/* automatic switch to scaling bone envelopes */
if(mode==TFM_RESIZE && t->obedit && t->obedit->type==OB_ARMATURE) {
bArmature *arm= t->obedit->data;
@@ -1482,7 +1485,7 @@ void initManipulator(int mode)
/* EVIL! posemode code can switch translation to rotate when 1 bone is selected. will be removed (ton) */
/* EVIL2: we gave as argument also texture space context bit... was cleared */
mode = Trans.mode;
-
+
calculatePropRatio(&Trans);
calculateCenter(&Trans);
@@ -1505,7 +1508,7 @@ void initManipulator(int mode)
#endif
}
-void ManipulatorTransform()
+void ManipulatorTransform()
{
#if 0 // TRANSFORM_FIX_ME
int mouse_moved = 0;
@@ -1518,9 +1521,9 @@ void ManipulatorTransform()
Trans.redraw = 1; /* initial draw */
while (Trans.state == TRANS_RUNNING) {
-
+
getmouseco_areawin(mval);
-
+
if (mval[0] != pmval[0] || mval[1] != pmval[1]) {
Trans.redraw = 1;
}
@@ -1534,7 +1537,7 @@ void ManipulatorTransform()
}
Trans.redraw = 0;
}
-
+
/* essential for idling subloop */
if( qtest()==0) PIL_sleep_ms(2);
@@ -1559,9 +1562,9 @@ void ManipulatorTransform()
Trans.flag |= T_SHIFT_MOD;
Trans.redraw = 1;
}
- else Trans.flag &= ~T_SHIFT_MOD;
+ else Trans.flag &= ~T_SHIFT_MOD;
break;
-
+
case ESCKEY:
case RIGHTMOUSE:
Trans.state = TRANS_CANCEL;
@@ -1619,23 +1622,23 @@ void ManipulatorTransform()
Trans.redraw= 1;
break;
}
-
+
// Numerical input events
Trans.redraw |= handleNumInput(&(Trans.num), event);
}
}
}
-
+
if(Trans.state == TRANS_CANCEL) {
restoreTransObjects(&Trans);
}
-
+
/* free data, reset vars */
postTrans(&Trans);
-
+
/* aftertrans does insert ipos and action channels, and clears base flags */
special_aftertrans_update(&Trans);
-
+
/* send events out for redraws */
viewRedrawPost(&Trans);
@@ -1681,21 +1684,21 @@ static void protectedQuaternionBits(short protectflag, float *quat, float *oldqu
{
/* quaternions get limited with euler... */
/* this function only does the delta rotation */
-
+
if(protectflag) {
float eul[3], oldeul[3], quat1[4];
-
+
QUATCOPY(quat1, quat);
QuatToEul(quat, eul);
QuatToEul(oldquat, oldeul);
-
+
if(protectflag & OB_LOCK_ROTX)
eul[0]= oldeul[0];
if(protectflag & OB_LOCK_ROTY)
eul[1]= oldeul[1];
if(protectflag & OB_LOCK_ROTZ)
eul[2]= oldeul[2];
-
+
EulToQuat(eul, quat);
/* quaternions flip w sign to accumulate rotations correctly */
if( (quat1[0]<0.0f && quat[0]>0.0f) || (quat1[0]>0.0f && quat[0]<0.0f) ) {
@@ -1712,8 +1715,8 @@ static void constraintTransLim(TransInfo *t, TransData *td)
bConstraintTypeInfo *cti= get_constraint_typeinfo(CONSTRAINT_TYPE_LOCLIMIT);
bConstraintOb cob;
bConstraint *con;
-
- /* Make a temporary bConstraintOb for using these limit constraints
+
+ /* Make a temporary bConstraintOb for using these limit constraints
* - they only care that cob->matrix is correctly set ;-)
* - current space should be local
*/
@@ -1728,22 +1731,22 @@ static void constraintTransLim(TransInfo *t, TransData *td)
else {
VECCOPY(cob.matrix[3], td->loc);
}
-
+
/* Evaluate valid constraints */
for (con= td->con; con; con= con->next) {
float tmat[4][4];
-
+
/* only consider constraint if enabled */
if (con->flag & CONSTRAINT_DISABLE) continue;
if (con->enforce == 0.0f) continue;
-
+
/* only use it if it's tagged for this purpose (and the right type) */
if (con->type == CONSTRAINT_TYPE_LOCLIMIT) {
bLocLimitConstraint *data= con->data;
-
- if ((data->flag2 & LIMIT_TRANSFORM)==0)
+
+ if ((data->flag2 & LIMIT_TRANSFORM)==0)
continue;
-
+
/* do space conversions */
if (con->ownspace == CONSTRAINT_SPACE_WORLD) {
/* just multiply by td->mtx (this should be ok) */
@@ -1754,10 +1757,10 @@ static void constraintTransLim(TransInfo *t, TransData *td)
/* skip... incompatable spacetype */
continue;
}
-
+
/* do constraint */
cti->evaluate_constraint(con, &cob, NULL);
-
+
/* convert spaces again */
if (con->ownspace == CONSTRAINT_SPACE_WORLD) {
/* just multiply by td->mtx (this should be ok) */
@@ -1766,7 +1769,7 @@ static void constraintTransLim(TransInfo *t, TransData *td)
}
}
}
-
+
/* copy results from cob->matrix */
if (td->tdi) {
TransDataIpokey *tdi= td->tdi;
@@ -1786,8 +1789,8 @@ static void constraintRotLim(TransInfo *t, TransData *td)
bConstraintTypeInfo *cti= get_constraint_typeinfo(CONSTRAINT_TYPE_ROTLIMIT);
bConstraintOb cob;
bConstraint *con;
-
- /* Make a temporary bConstraintOb for using these limit constraints
+
+ /* Make a temporary bConstraintOb for using these limit constraints
* - they only care that cob->matrix is correctly set ;-)
* - current space should be local
*/
@@ -1803,11 +1806,11 @@ static void constraintRotLim(TransInfo *t, TransData *td)
/* ipo-keys eulers */
TransDataIpokey *tdi= td->tdi;
float eul[3];
-
+
eul[0]= tdi->rotx[0];
eul[1]= tdi->roty[0];
eul[2]= tdi->rotz[0];
-
+
EulToMat4(eul, cob.matrix);
}
else {
@@ -1817,22 +1820,22 @@ static void constraintRotLim(TransInfo *t, TransData *td)
else
return;
}
-
+
/* Evaluate valid constraints */
for (con= td->con; con; con= con->next) {
/* only consider constraint if enabled */
if (con->flag & CONSTRAINT_DISABLE) continue;
if (con->enforce == 0.0f) continue;
-
+
/* we're only interested in Limit-Rotation constraints */
if (con->type == CONSTRAINT_TYPE_ROTLIMIT) {
bRotLimitConstraint *data= con->data;
float tmat[4][4];
-
+
/* only use it if it's tagged for this purpose */
- if ((data->flag2 & LIMIT_TRANSFORM)==0)
+ if ((data->flag2 & LIMIT_TRANSFORM)==0)
continue;
-
+
/* do space conversions */
if (con->ownspace == CONSTRAINT_SPACE_WORLD) {
/* just multiply by td->mtx (this should be ok) */
@@ -1843,10 +1846,10 @@ static void constraintRotLim(TransInfo *t, TransData *td)
/* skip... incompatable spacetype */
continue;
}
-
+
/* do constraint */
cti->evaluate_constraint(con, &cob, NULL);
-
+
/* convert spaces again */
if (con->ownspace == CONSTRAINT_SPACE_WORLD) {
/* just multiply by td->mtx (this should be ok) */
@@ -1855,7 +1858,7 @@ static void constraintRotLim(TransInfo *t, TransData *td)
}
}
}
-
+
/* copy results from cob->matrix */
if (td->flag & TD_USEQUAT) {
/* quats */
@@ -1865,9 +1868,9 @@ static void constraintRotLim(TransInfo *t, TransData *td)
/* ipo-keys eulers */
TransDataIpokey *tdi= td->tdi;
float eul[3];
-
+
Mat4ToEul(cob.matrix, eul);
-
+
tdi->rotx[0]= eul[0];
tdi->roty[0]= eul[1];
tdi->rotz[0]= eul[2];
@@ -1885,8 +1888,8 @@ static void constraintSizeLim(TransInfo *t, TransData *td)
bConstraintTypeInfo *cti= get_constraint_typeinfo(CONSTRAINT_TYPE_SIZELIMIT);
bConstraintOb cob;
bConstraint *con;
-
- /* Make a temporary bConstraintOb for using these limit constraints
+
+ /* Make a temporary bConstraintOb for using these limit constraints
* - they only care that cob->matrix is correctly set ;-)
* - current space should be local
*/
@@ -1894,12 +1897,12 @@ static void constraintSizeLim(TransInfo *t, TransData *td)
if (td->tdi) {
TransDataIpokey *tdi= td->tdi;
float size[3];
-
+
size[0]= tdi->sizex[0];
size[1]= tdi->sizey[0];
size[2]= tdi->sizez[0];
SizeToMat4(size, cob.matrix);
- }
+ }
else if ((td->flag & TD_SINGLESIZE) && !(t->con.mode & CON_APPLY)) {
/* scale val and reset size */
return; // TODO: fix this case
@@ -1908,25 +1911,25 @@ static void constraintSizeLim(TransInfo *t, TransData *td)
/* Reset val if SINGLESIZE but using a constraint */
if (td->flag & TD_SINGLESIZE)
return;
-
+
SizeToMat4(td->ext->size, cob.matrix);
}
-
+
/* Evaluate valid constraints */
for (con= td->con; con; con= con->next) {
/* only consider constraint if enabled */
if (con->flag & CONSTRAINT_DISABLE) continue;
if (con->enforce == 0.0f) continue;
-
+
/* we're only interested in Limit-Scale constraints */
if (con->type == CONSTRAINT_TYPE_SIZELIMIT) {
bSizeLimitConstraint *data= con->data;
float tmat[4][4];
-
+
/* only use it if it's tagged for this purpose */
- if ((data->flag2 & LIMIT_TRANSFORM)==0)
+ if ((data->flag2 & LIMIT_TRANSFORM)==0)
continue;
-
+
/* do space conversions */
if (con->ownspace == CONSTRAINT_SPACE_WORLD) {
/* just multiply by td->mtx (this should be ok) */
@@ -1937,10 +1940,10 @@ static void constraintSizeLim(TransInfo *t, TransData *td)
/* skip... incompatable spacetype */
continue;
}
-
+
/* do constraint */
cti->evaluate_constraint(con, &cob, NULL);
-
+
/* convert spaces again */
if (con->ownspace == CONSTRAINT_SPACE_WORLD) {
/* just multiply by td->mtx (this should be ok) */
@@ -1949,18 +1952,18 @@ static void constraintSizeLim(TransInfo *t, TransData *td)
}
}
}
-
+
/* copy results from cob->matrix */
if (td->tdi) {
TransDataIpokey *tdi= td->tdi;
float size[3];
-
+
Mat4ToSize(cob.matrix, size);
-
+
tdi->sizex[0]= size[0];
tdi->sizey[0]= size[1];
tdi->sizez[0]= size[2];
- }
+ }
else if ((td->flag & TD_SINGLESIZE) && !(t->con.mode & CON_APPLY)) {
/* scale val and reset size */
return; // TODO: fix this case
@@ -1969,7 +1972,7 @@ static void constraintSizeLim(TransInfo *t, TransData *td)
/* Reset val if SINGLESIZE but using a constraint */
if (td->flag & TD_SINGLESIZE)
return;
-
+
Mat4ToSize(cob.matrix, td->ext->size);
}
}
@@ -1977,15 +1980,15 @@ static void constraintSizeLim(TransInfo *t, TransData *td)
/* ************************** WARP *************************** */
-void initWarp(TransInfo *t)
+void initWarp(TransInfo *t)
{
float max[3], min[3];
int i;
-
+
t->mode = TFM_WARP;
t->transform = Warp;
t->handleEvent = handleEventWarp;
-
+
initMouseInputMode(t, &t->mouse, INPUT_HORIZONTAL_RATIO);
t->idx_max = 0;
@@ -1993,9 +1996,9 @@ void initWarp(TransInfo *t)
t->snap[0] = 0.0f;
t->snap[1] = 5.0f;
t->snap[2] = 1.0f;
-
+
t->flag |= T_NO_CONSTRAINT;
-
+
/* we need min/max in view space */
for(i = 0; i < t->total; i++) {
float center[3];
@@ -2010,11 +2013,11 @@ void initWarp(TransInfo *t)
VECCOPY(min, center);
}
}
-
+
t->center[0]= (min[0]+max[0])/2.0f;
t->center[1]= (min[1]+max[1])/2.0f;
t->center[2]= (min[2]+max[2])/2.0f;
-
+
if (max[0] == min[0]) max[0] += 0.1; /* not optimal, but flipping is better than invalid garbage (i.e. division by zero!) */
t->val= (max[0]-min[0])/2.0f; /* t->val is X dimension projected boundbox */
}
@@ -2022,7 +2025,7 @@ void initWarp(TransInfo *t)
int handleEventWarp(TransInfo *t, wmEvent *event)
{
int status = 0;
-
+
if (event->type == MIDDLEMOUSE && event->val)
{
// Use customData pointer to signal warp direction
@@ -2030,10 +2033,10 @@ int handleEventWarp(TransInfo *t, wmEvent *event)
t->customData = (void*)1;
else
t->customData = 0;
-
+
status = 1;
}
-
+
return status;
}
@@ -2043,7 +2046,7 @@ int Warp(TransInfo *t, short mval[2])
float vec[3], circumfac, dist, phi0, co, si, *curs, cursor[3], gcursor[3];
int i;
char str[50];
-
+
curs= give_cursor(t->scene, t->view);
/*
* gcursor is the one used for helpline.
@@ -2056,7 +2059,7 @@ int Warp(TransInfo *t, short mval[2])
* into account if in Edit mode.
*/
VECCOPY(cursor, curs);
- VECCOPY(gcursor, cursor);
+ VECCOPY(gcursor, cursor);
if (t->flag & T_EDIT) {
VecSubf(cursor, cursor, t->obedit->obmat[3]);
VecSubf(gcursor, gcursor, t->obedit->obmat[3]);
@@ -2067,7 +2070,7 @@ int Warp(TransInfo *t, short mval[2])
/* amount of degrees for warp */
circumfac = 360.0f * t->values[0];
-
+
if (t->customData) /* non-null value indicates reversed input */
{
circumfac *= -1;
@@ -2075,22 +2078,22 @@ int Warp(TransInfo *t, short mval[2])
snapGrid(t, &circumfac);
applyNumInput(&t->num, &circumfac);
-
+
/* header print for NumInput */
if (hasNumInput(&t->num)) {
char c[20];
-
+
outputNumInput(&(t->num), c);
-
+
sprintf(str, "Warp: %s", c);
}
else {
/* default header print */
sprintf(str, "Warp: %.3f", circumfac);
}
-
+
circumfac*= (float)(-M_PI/360.0);
-
+
for(i = 0; i < t->total; i++, td++) {
float loc[3];
if (td->flag & TD_NOACTION)
@@ -2098,65 +2101,65 @@ int Warp(TransInfo *t, short mval[2])
if (td->flag & TD_SKIP)
continue;
-
+
/* translate point to center, rotate in such a way that outline==distance */
VECCOPY(vec, td->iloc);
Mat3MulVecfl(td->mtx, vec);
Mat4MulVecfl(t->viewmat, vec);
VecSubf(vec, vec, t->viewmat[3]);
-
+
dist= vec[0]-cursor[0];
-
+
/* t->val is X dimension projected boundbox */
- phi0= (circumfac*dist/t->val);
-
+ phi0= (circumfac*dist/t->val);
+
vec[1]= (vec[1]-cursor[1]);
-
+
co= (float)cos(phi0);
si= (float)sin(phi0);
loc[0]= -si*vec[1]+cursor[0];
loc[1]= co*vec[1]+cursor[1];
loc[2]= vec[2];
-
+
Mat4MulVecfl(t->viewinv, loc);
VecSubf(loc, loc, t->viewinv[3]);
Mat3MulVecfl(td->smtx, loc);
-
+
VecSubf(loc, loc, td->iloc);
VecMulf(loc, td->factor);
VecAddf(td->loc, td->iloc, loc);
}
recalcData(t);
-
+
ED_area_headerprint(t->sa, str);
-
+
return 1;
}
/* ************************** SHEAR *************************** */
-void initShear(TransInfo *t)
+void initShear(TransInfo *t)
{
t->mode = TFM_SHEAR;
t->transform = Shear;
t->handleEvent = handleEventShear;
-
+
initMouseInputMode(t, &t->mouse, INPUT_HORIZONTAL_ABSOLUTE);
-
+
t->idx_max = 0;
t->num.idx_max = 0;
t->snap[0] = 0.0f;
t->snap[1] = 0.1f;
t->snap[2] = t->snap[1] * 0.1f;
-
+
t->flag |= T_NO_CONSTRAINT;
}
int handleEventShear(TransInfo *t, wmEvent *event)
{
int status = 0;
-
+
if (event->type == MIDDLEMOUSE && event->val)
{
// Use customData pointer to signal Shear direction
@@ -2170,15 +2173,15 @@ int handleEventShear(TransInfo *t, wmEvent *event)
initMouseInputMode(t, &t->mouse, INPUT_HORIZONTAL_ABSOLUTE);
t->customData = 0;
}
-
+
status = 1;
}
-
+
return status;
}
-int Shear(TransInfo *t, short mval[2])
+int Shear(TransInfo *t, short mval[2])
{
TransData *td = t->data;
float vec[3];
@@ -2208,18 +2211,18 @@ int Shear(TransInfo *t, short mval[2])
/* default header print */
sprintf(str, "Shear: %.3f %s", value, t->proptext);
}
-
+
Mat3One(smat);
-
+
// Custom data signals shear direction
if (t->customData == 0)
smat[1][0] = value;
else
smat[0][1] = value;
-
+
Mat3MulMat3(tmat, smat, persmat);
Mat3MulMat3(totmat, persinv, tmat);
-
+
for(i = 0 ; i < t->total; i++, td++) {
if (td->flag & TD_NOACTION)
break;
@@ -2256,13 +2259,13 @@ int Shear(TransInfo *t, short mval[2])
/* ************************** RESIZE *************************** */
-void initResize(TransInfo *t)
+void initResize(TransInfo *t)
{
t->mode = TFM_RESIZE;
t->transform = Resize;
-
+
initMouseInputMode(t, &t->mouse, INPUT_SPRING_FLIP);
-
+
t->flag |= T_NULL_ONE;
t->num.flag |= NUM_NULL_ONE;
t->num.flag |= NUM_AFFECT_ALL;
@@ -2270,7 +2273,7 @@ void initResize(TransInfo *t)
t->flag |= T_NO_ZERO;
t->num.flag |= NUM_NO_ZERO;
}
-
+
t->idx_max = 2;
t->num.idx_max = 2;
t->snap[0] = 0.0f;
@@ -2316,18 +2319,18 @@ static void headerResize(TransInfo *t, float vec[3], char *str) {
static void TransMat3ToSize( float mat[][3], float smat[][3], float *size)
{
float vec[3];
-
+
VecCopyf(vec, mat[0]);
size[0]= Normalize(vec);
VecCopyf(vec, mat[1]);
size[1]= Normalize(vec);
VecCopyf(vec, mat[2]);
size[2]= Normalize(vec);
-
+
/* first tried with dotproduct... but the sign flip is crucial */
- if( VECSIGNFLIP(mat[0], smat[0]) ) size[0]= -size[0];
- if( VECSIGNFLIP(mat[1], smat[1]) ) size[1]= -size[1];
- if( VECSIGNFLIP(mat[2], smat[2]) ) size[2]= -size[2];
+ if( VECSIGNFLIP(mat[0], smat[0]) ) size[0]= -size[0];
+ if( VECSIGNFLIP(mat[1], smat[1]) ) size[1]= -size[1];
+ if( VECSIGNFLIP(mat[2], smat[2]) ) size[2]= -size[2];
}
@@ -2353,7 +2356,7 @@ static void ElementResize(TransInfo *t, TransData *td, float mat[3][3]) {
VECCOPY(center, td->center);
}
else if (t->flag & T_EDIT) {
-
+
if(t->around==V3D_LOCAL && (t->settings->selectmode & SCE_SELECT_FACE)) {
VECCOPY(center, td->center);
}
@@ -2371,7 +2374,7 @@ static void ElementResize(TransInfo *t, TransData *td, float mat[3][3]) {
if (td->ext) {
float fsize[3];
-
+
if (t->flag & (T_OBJECT|T_TEXTURE|T_POSE)) {
float obsizemat[3][3];
// Reorient the size mat to fit the oriented object.
@@ -2383,28 +2386,28 @@ static void ElementResize(TransInfo *t, TransData *td, float mat[3][3]) {
else {
Mat3ToSize(tmat, fsize);
}
-
+
protectedSizeBits(td->protectflag, fsize);
-
+
if ((t->flag & T_V3D_ALIGN)==0) { // align mode doesn't resize objects itself
/* handle ipokeys? */
if(td->tdi) {
TransDataIpokey *tdi= td->tdi;
/* calculate delta size (equal for size and dsize) */
-
+
vec[0]= (tdi->oldsize[0])*(fsize[0] -1.0f) * td->factor;
vec[1]= (tdi->oldsize[1])*(fsize[1] -1.0f) * td->factor;
vec[2]= (tdi->oldsize[2])*(fsize[2] -1.0f) * td->factor;
-
+
add_tdi_poin(tdi->sizex, tdi->oldsize, vec[0]);
add_tdi_poin(tdi->sizey, tdi->oldsize+1, vec[1]);
add_tdi_poin(tdi->sizez, tdi->oldsize+2, vec[2]);
-
- }
+
+ }
else if((td->flag & TD_SINGLESIZE) && !(t->con.mode & CON_APPLY)){
/* scale val and reset size */
*td->val = td->ival * fsize[0] * td->factor;
-
+
td->ext->size[0] = td->ext->isize[0];
td->ext->size[1] = td->ext->isize[1];
td->ext->size[2] = td->ext->isize[2];
@@ -2413,16 +2416,16 @@ static void ElementResize(TransInfo *t, TransData *td, float mat[3][3]) {
/* Reset val if SINGLESIZE but using a constraint */
if (td->flag & TD_SINGLESIZE)
*td->val = td->ival;
-
+
td->ext->size[0] = td->ext->isize[0] * (fsize[0]) * td->factor;
td->ext->size[1] = td->ext->isize[1] * (fsize[1]) * td->factor;
td->ext->size[2] = td->ext->isize[2] * (fsize[2]) * td->factor;
}
}
-
+
constraintSizeLim(t, td);
}
-
+
/* For individual element center, Editmode need to use iloc */
if (t->flag & T_POINTS)
VecSubf(vec, td->iloc, center);
@@ -2452,11 +2455,11 @@ static void ElementResize(TransInfo *t, TransData *td, float mat[3][3]) {
add_tdi_poin(tdi->locz, tdi->oldloc+2, vec[2]);
}
else VecAddf(td->loc, td->iloc, vec);
-
+
constraintTransLim(t, td);
}
-int Resize(TransInfo *t, short mval[2])
+int Resize(TransInfo *t, short mval[2])
{
TransData *td;
float size[3], mat[3][3];
@@ -2473,7 +2476,7 @@ int Resize(TransInfo *t, short mval[2])
{
ratio = t->values[0];
}
-
+
size[0] = size[1] = size[2] = ratio;
snapGrid(t, size);
@@ -2499,7 +2502,7 @@ int Resize(TransInfo *t, short mval[2])
}
Mat3CpyMat3(t->mat, mat); // used in manipulator
-
+
headerResize(t, size, str);
for(i = 0, td=t->data; i < t->total; i++, td++) {
@@ -2508,7 +2511,7 @@ int Resize(TransInfo *t, short mval[2])
if (td->flag & TD_SKIP)
continue;
-
+
ElementResize(t, td, mat);
}
@@ -2532,14 +2535,14 @@ int Resize(TransInfo *t, short mval[2])
/* ************************** TOSPHERE *************************** */
-void initToSphere(TransInfo *t)
+void initToSphere(TransInfo *t)
{
TransData *td = t->data;
int i;
t->mode = TFM_TOSPHERE;
t->transform = ToSphere;
-
+
initMouseInputMode(t, &t->mouse, INPUT_HORIZONTAL_RATIO);
t->idx_max = 0;
@@ -2547,10 +2550,10 @@ void initToSphere(TransInfo *t)
t->snap[0] = 0.0f;
t->snap[1] = 0.1f;
t->snap[2] = t->snap[1] * 0.1f;
-
+
t->num.flag |= NUM_NULL_ONE | NUM_NO_NEGATIVE;
t->flag |= T_NO_CONSTRAINT;
-
+
// Calculate average radius
for(i = 0 ; i < t->total; i++, td++) {
t->val += VecLenf(t->center, td->iloc);
@@ -2559,7 +2562,7 @@ void initToSphere(TransInfo *t)
t->val /= (float)t->total;
}
-int ToSphere(TransInfo *t, short mval[2])
+int ToSphere(TransInfo *t, short mval[2])
{
float vec[3];
float ratio, radius;
@@ -2590,8 +2593,8 @@ int ToSphere(TransInfo *t, short mval[2])
/* default header print */
sprintf(str, "To Sphere: %.4f %s", ratio, t->proptext);
}
-
-
+
+
for(i = 0 ; i < t->total; i++, td++) {
float tratio;
if (td->flag & TD_NOACTION)
@@ -2610,7 +2613,7 @@ int ToSphere(TransInfo *t, short mval[2])
VecAddf(td->loc, t->center, vec);
}
-
+
recalcData(t);
@@ -2622,23 +2625,23 @@ int ToSphere(TransInfo *t, short mval[2])
/* ************************** ROTATION *************************** */
-void initRotation(TransInfo *t)
+void initRotation(TransInfo *t)
{
t->mode = TFM_ROTATION;
t->transform = Rotation;
-
+
initMouseInputMode(t, &t->mouse, INPUT_ANGLE);
-
+
t->ndof.axis = 16;
/* Scale down and flip input for rotation */
t->ndof.factor[0] = -0.2f;
-
+
t->idx_max = 0;
t->num.idx_max = 0;
t->snap[0] = 0.0f;
t->snap[1] = (float)((5.0/180)*M_PI);
t->snap[2] = t->snap[1] * 0.2f;
-
+
if (t->flag & T_2D_EDIT)
t->flag |= T_NO_CONSTRAINT;
}
@@ -2647,7 +2650,7 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short
float vec[3], totmat[3][3], smat[3][3];
float eul[3], fmat[3][3], quat[4];
float *center = t->center;
-
+
/* local constraint shouldn't alter center */
if (around == V3D_LOCAL) {
if (t->flag & (T_OBJECT|T_POSE)) {
@@ -2660,14 +2663,14 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short
}
}
}
-
+
if (t->flag & T_POINTS) {
Mat3MulMat3(totmat, mat, td->mtx);
Mat3MulMat3(smat, td->smtx, totmat);
-
+
VecSubf(vec, td->iloc, center);
Mat3MulVecfl(smat, vec);
-
+
VecAddf(td->loc, vec, center);
VecSubf(vec,td->loc,td->iloc);
@@ -2677,10 +2680,10 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short
if(td->flag & TD_USEQUAT) {
Mat3MulSerie(fmat, td->mtx, mat, td->smtx, 0, 0, 0, 0, 0);
Mat3ToQuat(fmat, quat); // Actual transform
-
+
if(td->ext->quat){
QuatMul(td->ext->quat, quat, td->ext->iquat);
-
+
/* is there a reason not to have this here? -jahka */
protectedQuaternionBits(td->protectflag, td->ext->quat, td->ext->iquat);
}
@@ -2688,11 +2691,11 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short
}
/**
* HACK WARNING
- *
+ *
* This is some VERY ugly special case to deal with pose mode.
- *
+ *
* The problem is that mtx and smtx include each bone orientation.
- *
+ *
* That is needed to rotate each bone properly, HOWEVER, to calculate
* the translation component, we only need the actual armature object's
* matrix (and inverse). That is not all though. Once the proper translation
@@ -2701,65 +2704,65 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short
else if (t->flag & T_POSE) {
float pmtx[3][3], imtx[3][3];
- // Extract and invert armature object matrix
+ // Extract and invert armature object matrix
Mat3CpyMat4(pmtx, t->poseobj->obmat);
Mat3Inv(imtx, pmtx);
-
+
if ((td->flag & TD_NO_LOC) == 0)
{
VecSubf(vec, td->center, center);
-
+
Mat3MulVecfl(pmtx, vec); // To Global space
Mat3MulVecfl(mat, vec); // Applying rotation
Mat3MulVecfl(imtx, vec); // To Local space
-
+
VecAddf(vec, vec, center);
/* vec now is the location where the object has to be */
-
+
VecSubf(vec, vec, td->center); // Translation needed from the initial location
-
+
Mat3MulVecfl(pmtx, vec); // To Global space
Mat3MulVecfl(td->smtx, vec);// To Pose space
-
+
protectedTransBits(td->protectflag, vec);
-
+
VecAddf(td->loc, td->iloc, vec);
-
+
constraintTransLim(t, td);
}
-
+
/* rotation */
if ((t->flag & T_V3D_ALIGN)==0) { // align mode doesn't rotate objects itself
/* euler or quaternion? */
if (td->flag & TD_USEQUAT) {
Mat3MulSerie(fmat, td->mtx, mat, td->smtx, 0, 0, 0, 0, 0);
-
+
Mat3ToQuat(fmat, quat); // Actual transform
-
+
QuatMul(td->ext->quat, quat, td->ext->iquat);
/* this function works on end result */
protectedQuaternionBits(td->protectflag, td->ext->quat, td->ext->iquat);
}
else {
float eulmat[3][3];
-
+
Mat3MulMat3(totmat, mat, td->mtx);
Mat3MulMat3(smat, td->smtx, totmat);
-
+
/* calculate the total rotatation in eulers */
VECCOPY(eul, td->ext->irot);
EulToMat3(eul, eulmat);
-
+
/* mat = transform, obmat = bone rotation */
Mat3MulMat3(fmat, smat, eulmat);
-
+
Mat3ToCompatibleEul(fmat, eul, td->ext->rot);
-
+
/* and apply (to end result only) */
protectedRotateBits(td->protectflag, eul, td->ext->irot);
VECCOPY(td->ext->rot, eul);
}
-
+
constraintRotLim(t, td);
}
}
@@ -2773,9 +2776,9 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short
/* vec now is the location where the object has to be */
VecSubf(vec, vec, td->center);
Mat3MulVecfl(td->smtx, vec);
-
+
protectedTransBits(td->protectflag, vec);
-
+
if(td->tdi) {
TransDataIpokey *tdi= td->tdi;
add_tdi_poin(tdi->locx, tdi->oldloc, vec[0]);
@@ -2784,8 +2787,8 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short
}
else VecAddf(td->loc, td->iloc, vec);
}
-
-
+
+
constraintTransLim(t, td);
/* rotation */
@@ -2794,34 +2797,34 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short
if (td->flag & TD_USEQUAT) {
Mat3MulSerie(fmat, td->mtx, mat, td->smtx, 0, 0, 0, 0, 0);
Mat3ToQuat(fmat, quat); // Actual transform
-
+
QuatMul(td->ext->quat, quat, td->ext->iquat);
/* this function works on end result */
protectedQuaternionBits(td->protectflag, td->ext->quat, td->ext->iquat);
}
else {
float obmat[3][3];
-
+
/* are there ipo keys? */
if(td->tdi) {
TransDataIpokey *tdi= td->tdi;
float current_rot[3];
float rot[3];
-
+
/* current IPO value for compatible euler */
current_rot[0] = (tdi->rotx) ? tdi->rotx[0] : 0.0f;
current_rot[1] = (tdi->roty) ? tdi->roty[0] : 0.0f;
current_rot[2] = (tdi->rotz) ? tdi->rotz[0] : 0.0f;
VecMulf(current_rot, (float)(M_PI_2 / 9.0));
-
+
/* calculate the total rotatation in eulers */
VecAddf(eul, td->ext->irot, td->ext->drot);
EulToMat3(eul, obmat);
/* mat = transform, obmat = object rotation */
Mat3MulMat3(fmat, mat, obmat);
-
+
Mat3ToCompatibleEul(fmat, eul, current_rot);
-
+
/* correct back for delta rot */
if(tdi->flag & TOB_IPODROT) {
VecSubf(rot, eul, td->ext->irot);
@@ -2829,12 +2832,12 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short
else {
VecSubf(rot, eul, td->ext->drot);
}
-
+
VecMulf(rot, (float)(9.0/M_PI_2));
VecSubf(rot, rot, tdi->oldrot);
-
+
protectedRotateBits(td->protectflag, rot, tdi->oldrot);
-
+
add_tdi_poin(tdi->rotx, tdi->oldrot, rot[0]);
add_tdi_poin(tdi->roty, tdi->oldrot+1, rot[1]);
add_tdi_poin(tdi->rotz, tdi->oldrot+2, rot[2]);
@@ -2842,37 +2845,37 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short
else {
Mat3MulMat3(totmat, mat, td->mtx);
Mat3MulMat3(smat, td->smtx, totmat);
-
+
/* calculate the total rotatation in eulers */
VecAddf(eul, td->ext->irot, td->ext->drot); /* we have to correct for delta rot */
EulToMat3(eul, obmat);
/* mat = transform, obmat = object rotation */
Mat3MulMat3(fmat, smat, obmat);
-
+
Mat3ToCompatibleEul(fmat, eul, td->ext->rot);
-
+
/* correct back for delta rot */
VecSubf(eul, eul, td->ext->drot);
-
+
/* and apply */
protectedRotateBits(td->protectflag, eul, td->ext->irot);
VECCOPY(td->ext->rot, eul);
}
}
-
+
constraintRotLim(t, td);
}
}
}
-static void applyRotation(TransInfo *t, float angle, float axis[3])
+static void applyRotation(TransInfo *t, float angle, float axis[3])
{
TransData *td = t->data;
float mat[3][3];
int i;
VecRotToMat3(axis, angle, mat);
-
+
for(i = 0 ; i < t->total; i++, td++) {
if (td->flag & TD_NOACTION)
@@ -2880,7 +2883,7 @@ static void applyRotation(TransInfo *t, float angle, float axis[3])
if (td->flag & TD_SKIP)
continue;
-
+
if (t->con.applyRot) {
t->con.applyRot(t, td, axis, NULL);
VecRotToMat3(axis, angle * td->factor, mat);
@@ -2893,7 +2896,7 @@ static void applyRotation(TransInfo *t, float angle, float axis[3])
}
}
-int Rotation(TransInfo *t, short mval[2])
+int Rotation(TransInfo *t, short mval[2])
{
char str[64];
@@ -2909,13 +2912,13 @@ int Rotation(TransInfo *t, short mval[2])
final = t->values[0];
applyNDofInput(&t->ndof, &final);
-
+
snapGrid(t, &final);
if (t->con.applyRot) {
t->con.applyRot(t, NULL, axis, &final);
}
-
+
applySnapping(t, &final);
if (hasNumInput(&t->num)) {
@@ -2930,7 +2933,7 @@ int Rotation(TransInfo *t, short mval[2])
/* Clamp between -180 and 180 */
while (final >= 180.0)
final -= 360.0;
-
+
while (final <= -180.0)
final += 360.0;
@@ -2945,9 +2948,9 @@ int Rotation(TransInfo *t, short mval[2])
// TRANSFORM_FIX_ME
// t->values[0] = final; // used in manipulator
// Mat3CpyMat3(t->mat, mat); // used in manipulator
-
+
applyRotation(t, final, axis);
-
+
recalcData(t);
ED_area_headerprint(t->sa, str);
@@ -2958,13 +2961,13 @@ int Rotation(TransInfo *t, short mval[2])
/* ************************** TRACKBALL *************************** */
-void initTrackball(TransInfo *t)
+void initTrackball(TransInfo *t)
{
t->mode = TFM_TRACKBALL;
t->transform = Trackball;
-
+
initMouseInputMode(t, &t->mouse, INPUT_TRACKBALL);
-
+
t->ndof.axis = 40;
/* Scale down input for rotation */
t->ndof.factor[0] = 0.2f;
@@ -2975,7 +2978,7 @@ void initTrackball(TransInfo *t)
t->snap[0] = 0.0f;
t->snap[1] = (float)((5.0/180)*M_PI);
t->snap[2] = t->snap[1] * 0.2f;
-
+
t->flag |= T_NO_CONSTRAINT;
}
@@ -2987,7 +2990,7 @@ static void applyTrackball(TransInfo *t, float axis1[3], float axis2[3], float a
VecRotToMat3(axis1, angles[0], smat);
VecRotToMat3(axis2, angles[1], totmat);
-
+
Mat3MulMat3(mat, smat, totmat);
for(i = 0 ; i < t->total; i++, td++) {
@@ -2996,46 +2999,46 @@ static void applyTrackball(TransInfo *t, float axis1[3], float axis2[3], float a
if (td->flag & TD_SKIP)
continue;
-
+
if (t->flag & T_PROP_EDIT) {
VecRotToMat3(axis1, td->factor * angles[0], smat);
VecRotToMat3(axis2, td->factor * angles[1], totmat);
-
+
Mat3MulMat3(mat, smat, totmat);
}
-
+
ElementRotation(t, td, mat, t->around);
}
}
-int Trackball(TransInfo *t, short mval[2])
+int Trackball(TransInfo *t, short mval[2])
{
char str[128];
float axis1[3], axis2[3];
float mat[3][3], totmat[3][3], smat[3][3];
float phi[2];
-
+
VECCOPY(axis1, t->persinv[0]);
VECCOPY(axis2, t->persinv[1]);
Normalize(axis1);
Normalize(axis2);
-
+
phi[0] = t->values[0];
phi[1] = t->values[1];
-
+
applyNDofInput(&t->ndof, phi);
-
+
snapGrid(t, phi);
-
+
if (hasNumInput(&t->num)) {
char c[40];
-
+
applyNumInput(&t->num, phi);
-
+
outputNumInput(&(t->num), c);
-
+
sprintf(str, "Trackball: %s %s %s", &c[0], &c[20], t->proptext);
-
+
phi[0] *= (float)(M_PI / 180.0);
phi[1] *= (float)(M_PI / 180.0);
}
@@ -3045,34 +3048,34 @@ int Trackball(TransInfo *t, short mval[2])
VecRotToMat3(axis1, phi[0], smat);
VecRotToMat3(axis2, phi[1], totmat);
-
+
Mat3MulMat3(mat, smat, totmat);
-
+
// TRANSFORM_FIX_ME
//Mat3CpyMat3(t->mat, mat); // used in manipulator
-
+
applyTrackball(t, axis1, axis2, phi);
-
+
recalcData(t);
-
+
ED_area_headerprint(t->sa, str);
-
+
return 1;
}
/* ************************** TRANSLATION *************************** */
-
-void initTranslation(TransInfo *t)
+
+void initTranslation(TransInfo *t)
{
t->mode = TFM_TRANSLATION;
t->transform = Translation;
-
+
initMouseInputMode(t, &t->mouse, INPUT_VECTOR);
t->idx_max = (t->flag & T_2D_EDIT)? 1: 2;
t->num.flag = 0;
t->num.idx_max = t->idx_max;
-
+
t->ndof.axis = (t->flag & T_2D_EDIT)? 1|2: 1|2|4;
if(t->spacetype == SPACE_VIEW3D) {
@@ -3098,7 +3101,7 @@ static void headerTranslation(TransInfo *t, float vec[3], char *str) {
char distvec[20];
char autoik[20];
float dist;
-
+
if (hasNumInput(&t->num)) {
outputNumInput(&(t->num), tvec);
dist = VecLength(t->num.val);
@@ -3119,10 +3122,10 @@ static void headerTranslation(TransInfo *t, float vec[3], char *str) {
sprintf(distvec, "%.4e", dist);
else
sprintf(distvec, "%.4f", dist);
-
+
if(t->flag & T_AUTOIK) {
short chainlen= t->settings->autoik_chainlen;
-
+
if(chainlen)
sprintf(autoik, "AutoIK-Len: %d", chainlen);
else
@@ -3159,10 +3162,10 @@ static void applyTranslation(TransInfo *t, float vec[3]) {
for(i = 0 ; i < t->total; i++, td++) {
if (td->flag & TD_NOACTION)
break;
-
+
if (td->flag & TD_SKIP)
continue;
-
+
/* handle snapping rotation before doing the translation */
if (usingSnappingNormal(t))
{
@@ -3173,22 +3176,22 @@ static void applyTranslation(TransInfo *t, float vec[3]) {
float quat[4];
float mat[3][3];
float angle;
-
+
Crossf(axis, original_normal, t->tsnap.snapNormal);
angle = saacos(Inpf(original_normal, t->tsnap.snapNormal));
-
+
AxisAngleToQuat(quat, axis, angle);
-
+
QuatToMat3(quat, mat);
-
+
ElementRotation(t, td, mat, V3D_LOCAL);
}
else
{
float mat[3][3];
-
+
Mat3One(mat);
-
+
ElementRotation(t, td, mat, V3D_LOCAL);
}
}
@@ -3200,12 +3203,12 @@ static void applyTranslation(TransInfo *t, float vec[3]) {
else {
VECCOPY(tvec, vec);
}
-
+
Mat3MulVecfl(td->smtx, tvec);
VecMulf(tvec, td->factor);
-
+
protectedTransBits(td->protectflag, tvec);
-
+
/* transdata ipokey */
if(td->tdi) {
TransDataIpokey *tdi= td->tdi;
@@ -3214,17 +3217,17 @@ static void applyTranslation(TransInfo *t, float vec[3]) {
add_tdi_poin(tdi->locz, tdi->oldloc+2, tvec[2]);
}
else VecAddf(td->loc, td->iloc, tvec);
-
+
constraintTransLim(t, td);
}
}
/* uses t->vec to store actual translation in */
-int Translation(TransInfo *t, short mval[2])
+int Translation(TransInfo *t, short mval[2])
{
float tvec[3];
char str[250];
-
+
if (t->con.mode & CON_APPLY) {
float pvec[3] = {0.0f, 0.0f, 0.0f};
applySnapping(t, t->values);
@@ -3240,11 +3243,11 @@ int Translation(TransInfo *t, short mval[2])
{
removeAspectRatio(t, t->values);
}
-
+
applySnapping(t, t->values);
headerTranslation(t, t->values, str);
}
-
+
applyTranslation(t, t->values);
/* evil hack - redo translation if clipping needed */
@@ -3260,7 +3263,7 @@ int Translation(TransInfo *t, short mval[2])
/* ************************** SHRINK/FATTEN *************************** */
-void initShrinkFatten(TransInfo *t)
+void initShrinkFatten(TransInfo *t)
{
// If not in mesh edit mode, fallback to Resize
if (t->obedit==NULL || t->obedit->type != OB_MESH) {
@@ -3269,22 +3272,22 @@ void initShrinkFatten(TransInfo *t)
else {
t->mode = TFM_SHRINKFATTEN;
t->transform = ShrinkFatten;
-
+
initMouseInputMode(t, &t->mouse, INPUT_VERTICAL_ABSOLUTE);
-
+
t->idx_max = 0;
t->num.idx_max = 0;
t->snap[0] = 0.0f;
t->snap[1] = 1.0f;
t->snap[2] = t->snap[1] * 0.1f;
-
+
t->flag |= T_NO_CONSTRAINT;
}
}
-int ShrinkFatten(TransInfo *t, short mval[2])
+int ShrinkFatten(TransInfo *t, short mval[2])
{
float vec[3];
float distance;
@@ -3310,8 +3313,8 @@ int ShrinkFatten(TransInfo *t, short mval[2])
/* default header print */
sprintf(str, "Shrink/Fatten: %.4f %s", distance, t->proptext);
}
-
-
+
+
for(i = 0 ; i < t->total; i++, td++) {
if (td->flag & TD_NOACTION)
break;
@@ -3335,11 +3338,11 @@ int ShrinkFatten(TransInfo *t, short mval[2])
/* ************************** TILT *************************** */
-void initTilt(TransInfo *t)
+void initTilt(TransInfo *t)
{
t->mode = TFM_TILT;
t->transform = Tilt;
-
+
initMouseInputMode(t, &t->mouse, INPUT_ANGLE);
t->ndof.axis = 16;
@@ -3351,13 +3354,13 @@ void initTilt(TransInfo *t)
t->snap[0] = 0.0f;
t->snap[1] = (float)((5.0/180)*M_PI);
t->snap[2] = t->snap[1] * 0.2f;
-
+
t->flag |= T_NO_CONSTRAINT;
}
-int Tilt(TransInfo *t, short mval[2])
+int Tilt(TransInfo *t, short mval[2])
{
TransData *td = t->data;
int i;
@@ -3366,7 +3369,7 @@ int Tilt(TransInfo *t, short mval[2])
float final;
final = t->values[0];
-
+
applyNDofInput(&t->ndof, &final);
snapGrid(t, &final);
@@ -3412,72 +3415,72 @@ void initCurveShrinkFatten(TransInfo *t)
{
t->mode = TFM_CURVE_SHRINKFATTEN;
t->transform = CurveShrinkFatten;
-
+
initMouseInputMode(t, &t->mouse, INPUT_SPRING);
-
+
t->idx_max = 0;
t->num.idx_max = 0;
t->snap[0] = 0.0f;
t->snap[1] = 0.1f;
t->snap[2] = t->snap[1] * 0.1f;
-
+
t->flag |= T_NO_CONSTRAINT;
}
-int CurveShrinkFatten(TransInfo *t, short mval[2])
+int CurveShrinkFatten(TransInfo *t, short mval[2])
{
TransData *td = t->data;
float ratio;
int i;
char str[50];
-
+
ratio = t->values[0];
-
+
snapGrid(t, &ratio);
-
+
applyNumInput(&t->num, &ratio);
-
+
/* header print for NumInput */
if (hasNumInput(&t->num)) {
char c[20];
-
+
outputNumInput(&(t->num), c);
sprintf(str, "Shrink/Fatten: %s", c);
}
else {
sprintf(str, "Shrink/Fatten: %3f", ratio);
}
-
+
for(i = 0 ; i < t->total; i++, td++) {
if (td->flag & TD_NOACTION)
break;
if (td->flag & TD_SKIP)
continue;
-
+
if(td->val) {
//*td->val= ratio;
*td->val= td->ival*ratio;
if (*td->val <= 0.0f) *td->val = 0.0001f;
}
}
-
+
recalcData(t);
-
+
ED_area_headerprint(t->sa, str);
-
+
return 1;
}
/* ************************** PUSH/PULL *************************** */
-void initPushPull(TransInfo *t)
+void initPushPull(TransInfo *t)
{
t->mode = TFM_PUSHPULL;
t->transform = PushPull;
-
+
initMouseInputMode(t, &t->mouse, INPUT_VERTICAL_ABSOLUTE);
-
+
t->ndof.axis = 4;
/* Flip direction */
t->ndof.factor[0] = -1.0f;
@@ -3490,7 +3493,7 @@ void initPushPull(TransInfo *t)
}
-int PushPull(TransInfo *t, short mval[2])
+int PushPull(TransInfo *t, short mval[2])
{
float vec[3], axis[3];
float distance;
@@ -3499,7 +3502,7 @@ int PushPull(TransInfo *t, short mval[2])
TransData *td = t->data;
distance = t->values[0];
-
+
applyNDofInput(&t->ndof, &distance);
snapGrid(t, &distance);
@@ -3518,11 +3521,11 @@ int PushPull(TransInfo *t, short mval[2])
/* default header print */
sprintf(str, "Push/Pull: %.4f%s %s", distance, t->con.text, t->proptext);
}
-
+
if (t->con.applyRot && t->con.mode & CON_APPLY) {
t->con.applyRot(t, NULL, axis, NULL);
}
-
+
for(i = 0 ; i < t->total; i++, td++) {
if (td->flag & TD_NOACTION)
break;
@@ -3558,11 +3561,11 @@ int PushPull(TransInfo *t, short mval[2])
/* ************************** BEVEL **************************** */
-void initBevel(TransInfo *t)
+void initBevel(TransInfo *t)
{
t->transform = Bevel;
t->handleEvent = handleEventBevel;
-
+
initMouseInputMode(t, &t->mouse, INPUT_HORIZONTAL_ABSOLUTE);
t->mode = TFM_BEVEL;
@@ -3631,7 +3634,7 @@ int Bevel(TransInfo *t, short mval[2])
mode = (G.editBMesh->options & BME_BEVEL_VERT) ? "verts only" : "normal";
distance = t->values[0] / 4; /* 4 just seemed a nice value to me, nothing special */
-
+
distance = fabs(distance);
snapGrid(t, &distance);
@@ -3650,7 +3653,7 @@ int Bevel(TransInfo *t, short mval[2])
/* default header print */
sprintf(str, "Bevel - Dist: %.4f, Mode: %s (MMB to toggle))", distance, mode);
}
-
+
if (distance < 0) distance = -distance;
for(i = 0 ; i < t->total; i++, td++) {
if (td->axismtx[1][0] > 0 && distance > td->axismtx[1][0]) {
@@ -3671,23 +3674,23 @@ int Bevel(TransInfo *t, short mval[2])
/* ************************** BEVEL WEIGHT *************************** */
-void initBevelWeight(TransInfo *t)
+void initBevelWeight(TransInfo *t)
{
t->mode = TFM_BWEIGHT;
t->transform = BevelWeight;
-
+
initMouseInputMode(t, &t->mouse, INPUT_SPRING);
-
+
t->idx_max = 0;
t->num.idx_max = 0;
t->snap[0] = 0.0f;
t->snap[1] = 0.1f;
t->snap[2] = t->snap[1] * 0.1f;
-
+
t->flag |= T_NO_CONSTRAINT;
}
-int BevelWeight(TransInfo *t, short mval[2])
+int BevelWeight(TransInfo *t, short mval[2])
{
TransData *td = t->data;
float weight;
@@ -3721,7 +3724,7 @@ int BevelWeight(TransInfo *t, short mval[2])
else
sprintf(str, "Bevel Weight: %.3f %s", weight, t->proptext);
}
-
+
for(i = 0 ; i < t->total; i++, td++) {
if (td->flag & TD_NOACTION)
break;
@@ -3742,23 +3745,23 @@ int BevelWeight(TransInfo *t, short mval[2])
/* ************************** CREASE *************************** */
-void initCrease(TransInfo *t)
+void initCrease(TransInfo *t)
{
t->mode = TFM_CREASE;
t->transform = Crease;
-
+
initMouseInputMode(t, &t->mouse, INPUT_SPRING);
-
+
t->idx_max = 0;
t->num.idx_max = 0;
t->snap[0] = 0.0f;
t->snap[1] = 0.1f;
t->snap[2] = t->snap[1] * 0.1f;
-
+
t->flag |= T_NO_CONSTRAINT;
}
-int Crease(TransInfo *t, short mval[2])
+int Crease(TransInfo *t, short mval[2])
{
TransData *td = t->data;
float crease;
@@ -3792,7 +3795,7 @@ int Crease(TransInfo *t, short mval[2])
else
sprintf(str, "Crease: %.3f %s", crease, t->proptext);
}
-
+
for(i = 0 ; i < t->total; i++, td++) {
if (td->flag & TD_NOACTION)
break;
@@ -3820,9 +3823,9 @@ void initBoneSize(TransInfo *t)
{
t->mode = TFM_BONESIZE;
t->transform = BoneSize;
-
+
initMouseInputMode(t, &t->mouse, INPUT_SPRING_FLIP);
-
+
t->idx_max = 2;
t->num.idx_max = 2;
t->num.flag |= NUM_NULL_ONE;
@@ -3846,7 +3849,7 @@ static void headerBoneSize(TransInfo *t, float vec[3], char *str) {
if (t->con.mode & CON_APPLY) {
if (t->num.idx_max == 0)
sprintf(str, "ScaleB: %s%s %s", &tvec[0], t->con.text, t->proptext);
- else
+ else
sprintf(str, "ScaleB: %s : %s : %s%s %s", &tvec[0], &tvec[20], &tvec[40], t->con.text, t->proptext);
}
else {
@@ -3854,18 +3857,18 @@ static void headerBoneSize(TransInfo *t, float vec[3], char *str) {
}
}
-static void ElementBoneSize(TransInfo *t, TransData *td, float mat[3][3])
+static void ElementBoneSize(TransInfo *t, TransData *td, float mat[3][3])
{
float tmat[3][3], smat[3][3], oldy;
float sizemat[3][3];
-
+
Mat3MulMat3(smat, mat, td->mtx);
Mat3MulMat3(tmat, td->smtx, smat);
-
+
if (t->con.applySize) {
t->con.applySize(t, td, tmat);
}
-
+
/* we've tucked the scale in loc */
oldy= td->iloc[1];
SizeToMat3(td->iloc, sizemat);
@@ -3874,14 +3877,14 @@ static void ElementBoneSize(TransInfo *t, TransData *td, float mat[3][3])
td->loc[1]= oldy;
}
-int BoneSize(TransInfo *t, short mval[2])
+int BoneSize(TransInfo *t, short mval[2])
{
TransData *td = t->data;
float size[3], mat[3][3];
float ratio;
int i;
char str[60];
-
+
// TRANSFORM_FIX_ME MOVE TO MOUSE INPUT
/* for manipulator, center handle, the scaling can't be done relative to center */
if( (t->flag & T_USES_MANIPULATOR) && t->con.mode==0)
@@ -3892,40 +3895,40 @@ int BoneSize(TransInfo *t, short mval[2])
{
ratio = t->values[0];
}
-
+
size[0] = size[1] = size[2] = ratio;
-
+
snapGrid(t, size);
-
+
if (hasNumInput(&t->num)) {
applyNumInput(&t->num, size);
constraintNumInput(t, size);
}
-
+
SizeToMat3(size, mat);
-
+
if (t->con.applySize) {
t->con.applySize(t, NULL, mat);
}
-
+
Mat3CpyMat3(t->mat, mat); // used in manipulator
-
+
headerBoneSize(t, size, str);
-
+
for(i = 0 ; i < t->total; i++, td++) {
if (td->flag & TD_NOACTION)
break;
if (td->flag & TD_SKIP)
continue;
-
+
ElementBoneSize(t, td, mat);
}
-
+
recalcData(t);
-
+
ED_area_headerprint(t->sa, str);
-
+
return 1;
}
@@ -3936,9 +3939,9 @@ void initBoneEnvelope(TransInfo *t)
{
t->mode = TFM_BONE_ENVELOPE;
t->transform = BoneEnvelope;
-
+
initMouseInputMode(t, &t->mouse, INPUT_SPRING);
-
+
t->idx_max = 0;
t->num.idx_max = 0;
t->snap[0] = 0.0f;
@@ -3948,37 +3951,37 @@ void initBoneEnvelope(TransInfo *t)
t->flag |= T_NO_CONSTRAINT;
}
-int BoneEnvelope(TransInfo *t, short mval[2])
+int BoneEnvelope(TransInfo *t, short mval[2])
{
TransData *td = t->data;
float ratio;
int i;
char str[50];
-
+
ratio = t->values[0];
-
+
snapGrid(t, &ratio);
-
+
applyNumInput(&t->num, &ratio);
-
+
/* header print for NumInput */
if (hasNumInput(&t->num)) {
char c[20];
-
+
outputNumInput(&(t->num), c);
sprintf(str, "Envelope: %s", c);
}
else {
sprintf(str, "Envelope: %3f", ratio);
}
-
+
for(i = 0 ; i < t->total; i++, td++) {
if (td->flag & TD_NOACTION)
break;
if (td->flag & TD_SKIP)
continue;
-
+
if (td->val) {
/* if the old/original value was 0.0f, then just use ratio */
if (td->ival)
@@ -3987,11 +3990,11 @@ int BoneEnvelope(TransInfo *t, short mval[2])
*td->val= ratio;
}
}
-
+
recalcData(t);
-
+
ED_area_headerprint(t->sa, str);
-
+
return 1;
}
@@ -4002,7 +4005,7 @@ void initBoneRoll(TransInfo *t)
{
t->mode = TFM_BONE_ROLL;
t->transform = BoneRoll;
-
+
initMouseInputMode(t, &t->mouse, INPUT_ANGLE);
t->idx_max = 0;
@@ -4010,11 +4013,11 @@ void initBoneRoll(TransInfo *t)
t->snap[0] = 0.0f;
t->snap[1] = (float)((5.0/180)*M_PI);
t->snap[2] = t->snap[1] * 0.2f;
-
+
t->flag |= T_NO_CONSTRAINT;
}
-int BoneRoll(TransInfo *t, short mval[2])
+int BoneRoll(TransInfo *t, short mval[2])
{
TransData *td = t->data;
int i;
@@ -4040,18 +4043,18 @@ int BoneRoll(TransInfo *t, short mval[2])
else {
sprintf(str, "Roll: %.2f", 180.0*final/M_PI);
}
-
+
/* set roll values */
- for (i = 0; i < t->total; i++, td++) {
+ for (i = 0; i < t->total; i++, td++) {
if (td->flag & TD_NOACTION)
break;
if (td->flag & TD_SKIP)
continue;
-
+
*(td->val) = td->ival - final;
}
-
+
recalcData(t);
ED_area_headerprint(t->sa, str);
@@ -4061,11 +4064,11 @@ int BoneRoll(TransInfo *t, short mval[2])
/* ************************** BAKE TIME ******************* */
-void initBakeTime(TransInfo *t)
+void initBakeTime(TransInfo *t)
{
t->transform = BakeTime;
initMouseInputMode(t, &t->mouse, INPUT_NONE);
-
+
t->idx_max = 0;
t->num.idx_max = 0;
t->snap[0] = 0.0f;
@@ -4073,15 +4076,15 @@ void initBakeTime(TransInfo *t)
t->snap[2] = t->snap[1] * 0.1f;
}
-int BakeTime(TransInfo *t, short mval[2])
+int BakeTime(TransInfo *t, short mval[2])
{
TransData *td = t->data;
float time;
int i;
char str[50];
-
+
float fac = 0.1f;
-
+
if(t->mouse.precision) {
/* calculate ratio for shiftkey pos, and for total, and blend these for precision */
time= (float)(t->center2d[0] - t->mouse.precision_mval[0]) * fac;
@@ -4113,7 +4116,7 @@ int BakeTime(TransInfo *t, short mval[2])
else
sprintf(str, "Time: %.3f %s", time, t->proptext);
}
-
+
for(i = 0 ; i < t->total; i++, td++) {
if (td->flag & TD_NOACTION)
break;
@@ -4137,7 +4140,7 @@ int BakeTime(TransInfo *t, short mval[2])
/* ************************** MIRROR *************************** */
-void initMirror(TransInfo *t)
+void initMirror(TransInfo *t)
{
t->transform = Mirror;
initMouseInputMode(t, &t->mouse, INPUT_NONE);
@@ -4148,7 +4151,7 @@ void initMirror(TransInfo *t)
}
}
-int Mirror(TransInfo *t, short mval[2])
+int Mirror(TransInfo *t, short mval[2])
{
TransData *td;
float size[3], mat[3][3];
@@ -4164,47 +4167,47 @@ int Mirror(TransInfo *t, short mval[2])
/* if an axis has been selected */
if (t->con.mode & CON_APPLY) {
size[0] = size[1] = size[2] = -1;
-
+
SizeToMat3(size, mat);
-
+
if (t->con.applySize) {
t->con.applySize(t, NULL, mat);
}
-
+
sprintf(str, "Mirror%s", t->con.text);
-
+
for(i = 0, td=t->data; i < t->total; i++, td++) {
if (td->flag & TD_NOACTION)
break;
-
+
if (td->flag & TD_SKIP)
continue;
-
+
ElementResize(t, td, mat);
}
-
+
recalcData(t);
-
+
ED_area_headerprint(t->sa, str);
}
else
{
size[0] = size[1] = size[2] = 1;
-
+
SizeToMat3(size, mat);
-
+
for(i = 0, td=t->data; i < t->total; i++, td++) {
if (td->flag & TD_NOACTION)
break;
-
+
if (td->flag & TD_SKIP)
continue;
-
+
ElementResize(t, td, mat);
}
-
+
recalcData(t);
-
+
ED_area_headerprint(t->sa, "Select a mirror axis (X, Y, Z)");
}
@@ -4213,12 +4216,12 @@ int Mirror(TransInfo *t, short mval[2])
/* ************************** ALIGN *************************** */
-void initAlign(TransInfo *t)
+void initAlign(TransInfo *t)
{
t->flag |= T_NO_CONSTRAINT;
-
+
t->transform = Align;
-
+
initMouseInputMode(t, &t->mouse, INPUT_NONE);
}
@@ -4234,13 +4237,13 @@ int Align(TransInfo *t, short mval[2])
for(i = 0 ; i < t->total; i++, td++)
{
float mat[3][3], invmat[3][3];
-
+
if (td->flag & TD_NOACTION)
break;
if (td->flag & TD_SKIP)
continue;
-
+
/* around local centers */
if (t->flag & (T_OBJECT|T_POSE)) {
VECCOPY(t->center, td->center);
@@ -4252,19 +4255,19 @@ int Align(TransInfo *t, short mval[2])
}
Mat3Inv(invmat, td->axismtx);
-
- Mat3MulMat3(mat, t->spacemtx, invmat);
+
+ Mat3MulMat3(mat, t->spacemtx, invmat);
ElementRotation(t, td, mat, t->around);
}
/* restoring original center */
VECCOPY(t->center, center);
-
+
recalcData(t);
ED_area_headerprint(t->sa, "Align");
-
+
return 1;
}
@@ -4273,37 +4276,37 @@ int Align(TransInfo *t, short mval[2])
/* ---------------- Special Helpers for Various Settings ------------- */
-/* This function returns the snapping 'mode' for Animation Editors only
+/* This function returns the snapping 'mode' for Animation Editors only
* We cannot use the standard snapping due to NLA-strip scaling complexities.
*/
// XXX these modifier checks should be keymappable
static short getAnimEdit_SnapMode(TransInfo *t)
{
short autosnap= SACTSNAP_OFF;
-
+
/* currently, some of these are only for the action editor */
if (t->spacetype == SPACE_ACTION) {
SpaceAction *saction= (SpaceAction *)t->sa->spacedata.first;
-
+
if (saction)
autosnap= saction->autosnap;
}
else if (t->spacetype == SPACE_IPO) {
SpaceIpo *sipo= (SpaceIpo *)t->sa->spacedata.first;
-
+
if (sipo)
autosnap= sipo->autosnap;
}
else if (t->spacetype == SPACE_NLA) {
SpaceNla *snla= (SpaceNla *)t->sa->spacedata.first;
-
+
if (snla)
autosnap= snla->autosnap;
}
else {
// TRANSFORM_FIX_ME This needs to use proper defines for t->modifiers
// // FIXME: this still toggles the modes...
-// if (ctrl)
+// if (ctrl)
// autosnap= SACTSNAP_STEP;
// else if (shift)
// autosnap= SACTSNAP_FRAME;
@@ -4312,38 +4315,38 @@ static short getAnimEdit_SnapMode(TransInfo *t)
// else
autosnap= SACTSNAP_OFF;
}
-
+
return autosnap;
}
/* This function is used for testing if an Animation Editor is displaying
* its data in frames or seconds (and the data needing to be edited as such).
- * Returns 1 if in seconds, 0 if in frames
+ * Returns 1 if in seconds, 0 if in frames
*/
static short getAnimEdit_DrawTime(TransInfo *t)
{
short drawtime;
-
+
/* currently, some of these are only for the action editor */
if (t->spacetype == SPACE_ACTION) {
SpaceAction *saction= (SpaceAction *)t->sa->spacedata.first;
-
+
drawtime = (saction->flag & SACTION_DRAWTIME)? 1 : 0;
}
else if (t->spacetype == SPACE_NLA) {
SpaceNla *snla= (SpaceNla *)t->sa->spacedata.first;
-
+
drawtime = (snla->flag & SNLA_DRAWTIME)? 1 : 0;
}
else {
drawtime = 0;
}
-
+
return drawtime;
-}
+}
-/* This function is used by Animation Editor specific transform functions to do
+/* This function is used by Animation Editor specific transform functions to do
* the Snap Keyframe to Nearest Frame/Marker
*/
static void doAnimEdit_SnapFrame(TransInfo *t, TransData *td, AnimData *adt, short autosnap)
@@ -4354,19 +4357,19 @@ static void doAnimEdit_SnapFrame(TransInfo *t, TransData *td, AnimData *adt, sho
const short doTime= getAnimEdit_DrawTime(t);
const double secf= FPS;
double val;
-
+
/* convert frame to nla-action time (if needed) */
- if (adt)
+ if (adt)
val= BKE_nla_tweakedit_remap(adt, *(td->val), NLATIME_CONVERT_MAP);
else
val= *(td->val);
-
+
/* do the snapping to nearest frame/second */
if (doTime)
val= (float)( floor((val/secf) + 0.5f) * secf );
else
val= (float)( floor(val+0.5f) );
-
+
/* convert frame out of nla-action time */
if (adt)
*(td->val)= BKE_nla_tweakedit_remap(adt, val, NLATIME_CONVERT_UNMAP);
@@ -4376,17 +4379,17 @@ static void doAnimEdit_SnapFrame(TransInfo *t, TransData *td, AnimData *adt, sho
/* snap key to nearest marker? */
else if (autosnap == SACTSNAP_MARKER) {
float val;
-
+
/* convert frame to nla-action time (if needed) */
- if (adt)
+ if (adt)
val= BKE_nla_tweakedit_remap(adt, *(td->val), NLATIME_CONVERT_MAP);
else
val= *(td->val);
-
+
/* snap to nearest marker */
// TODO: need some more careful checks for where data comes from
val= (float)ED_markers_find_nearest_marker_time(&t->scene->markers, val);
-
+
/* convert frame out of nla-action time */
if (adt)
*(td->val)= BKE_nla_tweakedit_remap(adt, val, NLATIME_CONVERT_UNMAP);
@@ -4397,27 +4400,27 @@ static void doAnimEdit_SnapFrame(TransInfo *t, TransData *td, AnimData *adt, sho
/* ----------------- Translation ----------------------- */
-void initTimeTranslate(TransInfo *t)
+void initTimeTranslate(TransInfo *t)
{
t->mode = TFM_TIME_TRANSLATE;
t->transform = TimeTranslate;
-
+
initMouseInputMode(t, &t->mouse, INPUT_NONE);
/* num-input has max of (n-1) */
t->idx_max = 0;
t->num.flag = 0;
t->num.idx_max = t->idx_max;
-
+
/* initialise snap like for everything else */
- t->snap[0] = 0.0f;
+ t->snap[0] = 0.0f;
t->snap[1] = t->snap[2] = 1.0f;
}
-static void headerTimeTranslate(TransInfo *t, char *str)
+static void headerTimeTranslate(TransInfo *t, char *str)
{
char tvec[60];
-
+
/* if numeric input is active, use results from that, otherwise apply snapping to result */
if (hasNumInput(&t->num)) {
outputNumInput(&(t->num), tvec);
@@ -4428,7 +4431,7 @@ static void headerTimeTranslate(TransInfo *t, char *str)
const short doTime = getAnimEdit_DrawTime(t);
const double secf= FPS;
float val = t->values[0];
-
+
/* apply snapping + frame->seconds conversions */
if (autosnap == SACTSNAP_STEP) {
if (doTime)
@@ -4440,86 +4443,86 @@ static void headerTimeTranslate(TransInfo *t, char *str)
if (doTime)
val= val / secf;
}
-
+
sprintf(&tvec[0], "%.4f", val);
}
-
+
sprintf(str, "DeltaX: %s", &tvec[0]);
}
-static void applyTimeTranslate(TransInfo *t, float sval)
+static void applyTimeTranslate(TransInfo *t, float sval)
{
TransData *td = t->data;
Scene *scene = t->scene;
int i;
-
+
const short doTime= getAnimEdit_DrawTime(t);
const double secf= FPS;
-
+
const short autosnap= getAnimEdit_SnapMode(t);
-
+
float deltax, val;
-
+
/* it doesn't matter whether we apply to t->data or t->data2d, but t->data2d is more convenient */
for (i = 0 ; i < t->total; i++, td++) {
/* it is assumed that td->extra is a pointer to the AnimData,
- * whose active action is where this keyframe comes from
+ * whose active action is where this keyframe comes from
* (this is only valid when not in NLA)
*/
AnimData *adt= (t->spacetype != SPACE_NLA) ? td->extra : NULL;
-
+
/* check if any need to apply nla-mapping */
if (adt) {
deltax = t->values[0];
-
+
if (autosnap == SACTSNAP_STEP) {
- if (doTime)
+ if (doTime)
deltax= (float)( floor((deltax/secf) + 0.5f) * secf );
else
deltax= (float)( floor(deltax + 0.5f) );
}
-
+
val = BKE_nla_tweakedit_remap(adt, td->ival, NLATIME_CONVERT_MAP);
val += deltax;
*(td->val) = BKE_nla_tweakedit_remap(adt, val, NLATIME_CONVERT_UNMAP);
}
else {
deltax = val = t->values[0];
-
+
if (autosnap == SACTSNAP_STEP) {
if (doTime)
val= (float)( floor((deltax/secf) + 0.5f) * secf );
else
val= (float)( floor(val + 0.5f) );
}
-
+
*(td->val) = td->ival + val;
}
-
+
/* apply nearest snapping */
doAnimEdit_SnapFrame(t, td, adt, autosnap);
}
}
-int TimeTranslate(TransInfo *t, short mval[2])
+int TimeTranslate(TransInfo *t, short mval[2])
{
View2D *v2d = (View2D *)t->view;
float cval[2], sval[2];
char str[200];
-
+
/* calculate translation amount from mouse movement - in 'time-grid space' */
UI_view2d_region_to_view(v2d, mval[0], mval[0], &cval[0], &cval[1]);
UI_view2d_region_to_view(v2d, t->imval[0], t->imval[0], &sval[0], &sval[1]);
-
+
/* we only need to calculate effect for time (applyTimeTranslate only needs that) */
t->values[0] = cval[0] - sval[0];
-
+
/* handle numeric-input stuff */
t->vec[0] = t->values[0];
applyNumInput(&t->num, &t->vec[0]);
t->values[0] = t->vec[0];
headerTimeTranslate(t, str);
-
+
applyTimeTranslate(t, sval[0]);
recalcData(t);
@@ -4531,36 +4534,36 @@ int TimeTranslate(TransInfo *t, short mval[2])
/* ----------------- Time Slide ----------------------- */
-void initTimeSlide(TransInfo *t)
+void initTimeSlide(TransInfo *t)
{
/* this tool is only really available in the Action Editor... */
if (t->spacetype == SPACE_ACTION) {
SpaceAction *saction= (SpaceAction *)t->sa->spacedata.first;
-
+
/* set flag for drawing stuff */
saction->flag |= SACTION_MOVING;
}
-
+
t->mode = TFM_TIME_SLIDE;
t->transform = TimeSlide;
t->flag |= T_FREE_CUSTOMDATA;
-
+
initMouseInputMode(t, &t->mouse, INPUT_NONE);
/* num-input has max of (n-1) */
t->idx_max = 0;
t->num.flag = 0;
t->num.idx_max = t->idx_max;
-
+
/* initialise snap like for everything else */
- t->snap[0] = 0.0f;
+ t->snap[0] = 0.0f;
t->snap[1] = t->snap[2] = 1.0f;
}
-static void headerTimeSlide(TransInfo *t, float sval, char *str)
+static void headerTimeSlide(TransInfo *t, float sval, char *str)
{
char tvec[60];
-
+
if (hasNumInput(&t->num)) {
outputNumInput(&(t->num), tvec);
}
@@ -4569,50 +4572,50 @@ static void headerTimeSlide(TransInfo *t, float sval, char *str)
float maxx= *((float *)(t->customData) + 1);
float cval= t->values[0];
float val;
-
+
val= 2.0f*(cval-sval) / (maxx-minx);
CLAMP(val, -1.0f, 1.0f);
-
+
sprintf(&tvec[0], "%.4f", val);
}
-
+
sprintf(str, "TimeSlide: %s", &tvec[0]);
}
-static void applyTimeSlide(TransInfo *t, float sval)
+static void applyTimeSlide(TransInfo *t, float sval)
{
TransData *td = t->data;
int i;
-
+
float minx= *((float *)(t->customData));
float maxx= *((float *)(t->customData) + 1);
-
+
/* set value for drawing black line */
if (t->spacetype == SPACE_ACTION) {
SpaceAction *saction= (SpaceAction *)t->sa->spacedata.first;
float cvalf = t->values[0];
-
+
saction->timeslide= cvalf;
}
-
+
/* it doesn't matter whether we apply to t->data or t->data2d, but t->data2d is more convenient */
for (i = 0 ; i < t->total; i++, td++) {
/* it is assumed that td->extra is a pointer to the AnimData,
- * whose active action is where this keyframe comes from
+ * whose active action is where this keyframe comes from
* (this is only valid when not in NLA)
*/
AnimData *adt= (t->spacetype != SPACE_NLA) ? td->extra : NULL;
float cval = t->values[0];
-
+
/* apply NLA-mapping to necessary values */
if (adt)
cval= BKE_nla_tweakedit_remap(adt, cval, NLATIME_CONVERT_UNMAP);
-
+
/* only apply to data if in range */
if ((sval > minx) && (sval < maxx)) {
float cvalc= CLAMPIS(cval, minx, maxx);
float timefac;
-
+
/* left half? */
if (td->ival < sval) {
timefac= (sval - td->ival) / (sval - minx);
@@ -4626,26 +4629,26 @@ static void applyTimeSlide(TransInfo *t, float sval)
}
}
-int TimeSlide(TransInfo *t, short mval[2])
+int TimeSlide(TransInfo *t, short mval[2])
{
View2D *v2d = (View2D *)t->view;
float cval[2], sval[2];
float minx= *((float *)(t->customData));
float maxx= *((float *)(t->customData) + 1);
char str[200];
-
+
/* calculate mouse co-ordinates */
UI_view2d_region_to_view(v2d, mval[0], mval[0], &cval[0], &cval[1]);
UI_view2d_region_to_view(v2d, t->imval[0], t->imval[0], &sval[0], &sval[1]);
-
+
/* t->values[0] stores cval[0], which is the current mouse-pointer location (in frames) */
t->values[0] = cval[0];
-
+
/* handle numeric-input stuff */
t->vec[0] = 2.0f*(cval[0]-sval[0]) / (maxx-minx);
applyNumInput(&t->num, &t->vec[0]);
t->values[0] = (maxx-minx) * t->vec[0] / 2.0 + sval[0];
-
+
headerTimeSlide(t, sval[0], str);
applyTimeSlide(t, sval[0]);
@@ -4658,35 +4661,35 @@ int TimeSlide(TransInfo *t, short mval[2])
/* ----------------- Scaling ----------------------- */
-void initTimeScale(TransInfo *t)
+void initTimeScale(TransInfo *t)
{
t->mode = TFM_TIME_SCALE;
t->transform = TimeScale;
-
+
initMouseInputMode(t, &t->mouse, INPUT_NONE);
t->helpline = HLP_SPRING; /* set manually because we don't use a predefined input */
t->flag |= T_NULL_ONE;
t->num.flag |= NUM_NULL_ONE;
-
+
/* num-input has max of (n-1) */
t->idx_max = 0;
t->num.flag = 0;
t->num.idx_max = t->idx_max;
-
+
/* initialise snap like for everything else */
- t->snap[0] = 0.0f;
+ t->snap[0] = 0.0f;
t->snap[1] = t->snap[2] = 1.0f;
}
static void headerTimeScale(TransInfo *t, char *str) {
char tvec[60];
-
+
if (hasNumInput(&t->num))
outputNumInput(&(t->num), tvec);
else
sprintf(&tvec[0], "%.4f", t->values[0]);
-
+
sprintf(str, "ScaleX: %s", &tvec[0]);
}
@@ -4694,63 +4697,63 @@ static void applyTimeScale(TransInfo *t) {
Scene *scene = t->scene;
TransData *td = t->data;
int i;
-
+
const short autosnap= getAnimEdit_SnapMode(t);
const short doTime= getAnimEdit_DrawTime(t);
const double secf= FPS;
-
-
+
+
for (i = 0 ; i < t->total; i++, td++) {
/* it is assumed that td->extra is a pointer to the AnimData,
- * whose active action is where this keyframe comes from
+ * whose active action is where this keyframe comes from
* (this is only valid when not in NLA)
*/
AnimData *adt= (t->spacetype != SPACE_NLA) ? td->extra : NULL;
float startx= CFRA;
float fac= t->values[0];
-
+
if (autosnap == SACTSNAP_STEP) {
if (doTime)
fac= (float)( floor(fac/secf + 0.5f) * secf );
else
fac= (float)( floor(fac + 0.5f) );
}
-
+
/* check if any need to apply nla-mapping */
if (adt)
startx= BKE_nla_tweakedit_remap(adt, startx, NLATIME_CONVERT_UNMAP);
-
+
/* now, calculate the new value */
*(td->val) = td->ival - startx;
*(td->val) *= fac;
*(td->val) += startx;
-
+
/* apply nearest snapping */
doAnimEdit_SnapFrame(t, td, adt, autosnap);
}
}
-int TimeScale(TransInfo *t, short mval[2])
+int TimeScale(TransInfo *t, short mval[2])
{
float cval, sval;
float deltax, startx;
float width= 0.0f;
char str[200];
-
+
sval= t->imval[0];
cval= mval[0];
-
+
/* calculate scaling factor */
startx= sval-(width/2+(t->ar->winx)/2);
deltax= cval-(width/2+(t->ar->winx)/2);
t->values[0] = deltax / startx;
-
+
/* handle numeric-input stuff */
t->vec[0] = t->values[0];
applyNumInput(&t->num, &t->vec[0]);
t->values[0] = t->vec[0];
headerTimeScale(t, str);
-
+
applyTimeScale(t);
recalcData(t);
@@ -4789,7 +4792,7 @@ void NDofTransform()
maxval = val;
}
}
-
+
switch(axis)
{
case -1:
@@ -4810,7 +4813,7 @@ void NDofTransform()
default:
printf("ndof: what we are doing here ?");
}
-
+
if (mode != 0)
{
initTransform(mode, CTX_NDOF);
diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h
index 74cf1df1fa5..ed825886a05 100644
--- a/source/blender/editors/transform/transform.h
+++ b/source/blender/editors/transform/transform.h
@@ -71,7 +71,7 @@ typedef struct NumInput {
/*
The ctrl value has different meaning:
0 : No value has been typed
-
+
otherwise, |value| - 1 is where the cursor is located after the period
Positive : number is positive
Negative : number is negative
@@ -100,7 +100,7 @@ typedef struct TransCon {
float mtx[3][3]; /* Matrix of the Constraint space */
float imtx[3][3]; /* Inverse Matrix of the Constraint space */
float pmtx[3][3]; /* Projection Constraint Matrix (same as imtx with some axis == 0) */
- float center[3]; /* transformation center to define where to draw the view widget
+ float center[3]; /* transformation center to define where to draw the view widget
ALWAYS in global space. Unlike the transformation center */
short imval[2]; /* initial mouse value for visual calculation */
/* the one in TransInfo is not garanty to stay the same (Rotates change it) */
@@ -138,7 +138,7 @@ typedef struct TransDataExtension {
float iquat[4]; /* Initial rotation quaternion */
float *size; /* Size of the data to transform (Faculative) */
float isize[3]; /* Initial size */
- float obmat[4][4]; /* Object matrix */
+ float obmat[4][4]; /* Object matrix */
} TransDataExtension;
typedef struct TransData2D {
@@ -158,7 +158,7 @@ typedef struct TransDataSeq {
int flag; /* a copy of seq->flag that may be modified for nested strips */
short start_offset; /* use this so we can have transform data at the strips start, but apply correctly to the start frame */
short sel_flag; /* one of SELECT, SEQ_LEFTSEL and SEQ_RIGHTSEL */
-
+
} TransDataSeq;
/* for NLA transform (stored in td->extra pointer) */
@@ -200,9 +200,9 @@ typedef struct TransData {
typedef struct MouseInput {
void (*apply)(struct TransInfo *, struct MouseInput *, short [2], float [3]);
-
+
short imval[2]; /* initial mouse position */
- char precision;
+ char precision;
short precision_mval[2]; /* mouse position when precision key was pressed */
int center[2];
float factor;
@@ -239,7 +239,7 @@ typedef struct TransInfo {
short idx_max; /* maximum index on the input vector */
float snap[3]; /* Snapping Gears */
char frame_side; /* Mouse side of the cfra, 'L', 'R' or 'B' */
-
+
float viewmat[4][4]; /* copy from G.vd, prevents feedback, */
float viewinv[4][4]; /* and to make sure we don't have to */
float persmat[4][4]; /* access G.vd from other space types */
@@ -248,16 +248,16 @@ typedef struct TransInfo {
short around;
char spacetype; /* spacetype where transforming is */
char helpline; /* helpline modes (not to be confused with hotline) */
-
+
float vec[3]; /* translation, to show for widget */
float mat[3][3]; /* rot/rescale, to show for widget */
-
+
char *undostr; /* if set, uses this string for undo */
float spacemtx[3][3]; /* orientation matrix of the current space */
char spacename[32]; /* name of the current space */
-
+
struct Object *poseobj; /* if t->flag & T_POSE, this denotes pose object */
-
+
void *customData; /* Per Transform custom data */
/*************** NEW STUFF *********************/
@@ -303,7 +303,7 @@ typedef struct TransInfo {
#define T_POSE (1 << 2)
#define T_TEXTURE (1 << 3)
#define T_CAMERA (1 << 4)
- // trans on points, having no rotation/scale
+ // trans on points, having no rotation/scale
#define T_POINTS (1 << 6)
// for manipulator exceptions, like scaling using center point, drawing help lines
#define T_USES_MANIPULATOR (1 << 7)
@@ -319,7 +319,7 @@ typedef struct TransInfo {
#define T_V3D_ALIGN (1 << 14)
/* for 2d views like uv or ipo */
-#define T_2D_EDIT (1 << 15)
+#define T_2D_EDIT (1 << 15)
#define T_CLIP_UV (1 << 16)
#define T_FREE_CUSTOMDATA (1 << 17)
@@ -507,6 +507,8 @@ void special_aftertrans_update(TransInfo *t);
void transform_autoik_update(TransInfo *t, short mode);
+int count_set_pose_transflags(int *out_mode, short around, struct Object *ob);
+
/* auto-keying stuff used by special_aftertrans_update */
short autokeyframe_cfra_can_key(struct Scene *scene, struct Object *ob);
void autokeyframe_ob_cb_func(struct Scene *scene, struct View3D *v3d, struct Object *ob, int tmode);
@@ -607,8 +609,6 @@ void calculatePropRatio(TransInfo *t);
void getViewVector(TransInfo *t, float coord[3], float vec[3]);
-TransInfo * BIF_GetTransInfo(void);
-
/*********************** NumInput ********************************/
void initNumInput(NumInput *n);
diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c
index 7f47bfd25af..158ea98c090 100644
--- a/source/blender/editors/transform/transform_constraints.c
+++ b/source/blender/editors/transform/transform_constraints.c
@@ -183,7 +183,7 @@ static void postConstraintChecks(TransInfo *t, float vec[3], float pvec[3]) {
VECCOPY(vec, t->auto_values);
constraintAutoValues(t, vec);
}
-
+
if (t->con.mode & CON_AXIS0) {
pvec[i++] = vec[0];
}
@@ -199,10 +199,10 @@ static void postConstraintChecks(TransInfo *t, float vec[3], float pvec[3]) {
static void axisProjection(TransInfo *t, float axis[3], float in[3], float out[3]) {
float norm[3], vec[3], factor;
-
+
if(in[0]==0.0f && in[1]==0.0f && in[2]==0.0f)
return;
-
+
/* For when view is parallel to constraint... will cause NaNs otherwise
So we take vertical motion in 3D space and apply it to the
constraint axis. Nice for camera grab + MMB */
@@ -212,30 +212,30 @@ static void axisProjection(TransInfo *t, float axis[3], float in[3], float out[3
/* since camera distance is quite relative, use quadratic relationship. holding shift can compensate */
if(factor<0.0f) factor*= -factor;
else factor*= factor;
-
+
VECCOPY(out, axis);
Normalize(out);
VecMulf(out, -factor); /* -factor makes move down going backwards */
}
else {
float cb[3], ab[3];
-
+
VECCOPY(out, axis);
-
+
/* Get view vector on axis to define a plane */
VecAddf(vec, t->con.center, in);
getViewVector(t, vec, norm);
-
+
Crossf(vec, norm, axis);
-
+
/* Project input vector on the plane passing on axis */
Projf(vec, in, vec);
VecSubf(vec, in, vec);
-
+
/* intersect the two lines: axis and norm */
Crossf(cb, vec, norm);
Crossf(ab, axis, norm);
-
+
VecMulf(out, Inpf(cb, ab) / Inpf(ab, ab));
}
}
@@ -262,7 +262,7 @@ static void planeProjection(TransInfo *t, float in[3], float out[3]) {
/*
* Generic callback for constant spacial constraints applied to linear motion
- *
+ *
* The IN vector in projected into the constrained space and then further
* projected along the view vector.
* (in perspective mode, the view vector is relative to the position on screen)
@@ -274,7 +274,7 @@ static void applyAxisConstraintVec(TransInfo *t, TransData *td, float in[3], flo
VECCOPY(out, in);
if (!td && t->con.mode & CON_APPLY) {
Mat3MulVecfl(t->con.pmtx, out);
-
+
// With snap, a projection is alright, no need to correct for view alignment
if ((t->tsnap.status & SNAP_ON) == 0) {
if (getConstraintSpaceDimension(t) == 2) {
@@ -284,7 +284,7 @@ static void applyAxisConstraintVec(TransInfo *t, TransData *td, float in[3], flo
}
else if (getConstraintSpaceDimension(t) == 1) {
float c[3];
-
+
if (t->con.mode & CON_AXIS0) {
VECCOPY(c, t->con.mtx[0]);
}
@@ -303,7 +303,7 @@ static void applyAxisConstraintVec(TransInfo *t, TransData *td, float in[3], flo
/*
* Generic callback for object based spacial constraints applied to linear motion
- *
+ *
* At first, the following is applied to the first data in the array
* The IN vector in projected into the constrained space and then further
* projected along the view vector.
@@ -360,7 +360,7 @@ static void applyObjectConstraintVec(TransInfo *t, TransData *td, float in[3], f
/*
* Generic callback for constant spacial constraints applied to resize motion
- *
+ *
*
*/
@@ -386,7 +386,7 @@ static void applyAxisConstraintSize(TransInfo *t, TransData *td, float smat[3][3
/*
* Callback for object based spacial constraints applied to resize motion
- *
+ *
*
*/
@@ -415,7 +415,7 @@ static void applyObjectConstraintSize(TransInfo *t, TransData *td, float smat[3]
/*
* Generic callback for constant spacial constraints applied to rotations
- *
+ *
* The rotation axis is copied into VEC.
*
* In the case of single axis constraints, the rotation axis is directly the one constrained to.
@@ -457,7 +457,7 @@ static void applyAxisConstraintRot(TransInfo *t, TransData *td, float vec[3], fl
/*
* Callback for object based spacial constraints applied to rotations
- *
+ *
* The rotation axis is copied into VEC.
*
* In the case of single axis constraints, the rotation axis is directly the one constrained to.
@@ -473,7 +473,7 @@ static void applyObjectConstraintRot(TransInfo *t, TransData *td, float vec[3],
{
if (t->con.mode & CON_APPLY) {
int mode = t->con.mode & (CON_AXIS0|CON_AXIS1|CON_AXIS2);
-
+
/* on setup call, use first object */
if (td == NULL) {
td= t->data;
@@ -585,128 +585,6 @@ void setUserConstraint(TransInfo *t, int mode, const char ftext[]) {
t->con.mode |= CON_USER;
}
-/*--------------------- EXTERNAL SETUP CALLS ------------------*/
-
-void BIF_setLocalLockConstraint(char axis, char *text) {
- TransInfo *t = BIF_GetTransInfo();
-
- if (t->total == 0) {
- return;
- }
-
- switch (axis) {
- case 'x':
- setLocalConstraint(t, (CON_AXIS1|CON_AXIS2), text);
- break;
- case 'y':
- setLocalConstraint(t, (CON_AXIS0|CON_AXIS2), text);
- break;
- case 'z':
- setLocalConstraint(t, (CON_AXIS0|CON_AXIS1), text);
- break;
- }
-}
-
-void BIF_setLocalAxisConstraint(char axis, char *text) {
- TransInfo *t = BIF_GetTransInfo();
-
- if (t->total == 0) {
- return;
- }
-
- switch (axis) {
- case 'X':
- setLocalConstraint(t, CON_AXIS0, text);
- break;
- case 'Y':
- setLocalConstraint(t, CON_AXIS1, text);
- break;
- case 'Z':
- setLocalConstraint(t, CON_AXIS2, text);
- break;
- }
-}
-
-/* text is optional, for header print */
-void BIF_setSingleAxisConstraint(float vec[3], char *text) {
- TransInfo *t = BIF_GetTransInfo();
- float space[3][3], v[3];
-
- if (t->total == 0) {
- return;
- }
-
- VECCOPY(space[0], vec);
-
- v[0] = vec[2];
- v[1] = vec[0];
- v[2] = vec[1];
-
- Crossf(space[1], vec, v);
- Crossf(space[2], vec, space[1]);
- Mat3Ortho(space);
-
- Mat3CpyMat3(t->con.mtx, space);
- t->con.mode = CON_AXIS0;
-
- getConstraintMatrix(t);
-
- startConstraint(t);
-
- /* start copying with an offset of 1, to reserve a spot for the SPACE char */
- if(text)
- {
- strncpy(t->con.text+1, text, 48); /* 50 in struct */
- }
- else
- {
- t->con.text[1] = '\0'; /* No text */
- }
-
- t->con.drawExtra = NULL;
- t->con.applyVec = applyAxisConstraintVec;
- t->con.applySize = applyAxisConstraintSize;
- t->con.applyRot = applyAxisConstraintRot;
- t->redraw = 1;
-}
-
-void BIF_setDualAxisConstraint(float vec1[3], float vec2[3], char *text) {
- TransInfo *t = BIF_GetTransInfo();
- float space[3][3];
-
- if (t->total == 0) {
- return;
- }
-
- VECCOPY(space[0], vec1);
- VECCOPY(space[1], vec2);
- Crossf(space[2], space[0], space[1]);
- Mat3Ortho(space);
-
- Mat3CpyMat3(t->con.mtx, space);
- t->con.mode = CON_AXIS0|CON_AXIS1;
-
- getConstraintMatrix(t);
-
- startConstraint(t);
-
- /* start copying with an offset of 1, to reserve a spot for the SPACE char */
- if(text)
- {
- strncpy(t->con.text+1, text, 48); /* 50 in struct */
- }
- else
- {
- t->con.text[1] = '\0'; /* No text */
- }
-
- t->con.drawExtra = NULL;
- t->con.applyVec = applyAxisConstraintVec;
- t->con.applySize = applyAxisConstraintSize;
- t->con.applyRot = applyAxisConstraintRot;
- t->redraw = 1;
-}
-
/*----------------- DRAWING CONSTRAINTS -------------------*/
void drawConstraint(const struct bContext *C, TransInfo *t)
@@ -721,10 +599,10 @@ void drawConstraint(const struct bContext *C, TransInfo *t)
return;
if (t->flag & T_NO_CONSTRAINT)
return;
-
+
/* nasty exception for Z constraint in camera view */
// TRANSFORM_FIX_ME
-// if((t->flag & T_OBJECT) && G.vd->camera==OBACT && G.vd->persp==V3D_CAMOB)
+// if((t->flag & T_OBJECT) && G.vd->camera==OBACT && G.vd->persp==V3D_CAMOB)
// return;
if (tc->drawExtra) {
@@ -742,17 +620,17 @@ void drawConstraint(const struct bContext *C, TransInfo *t)
drawLine(t, tc->center, tc->mtx[2], 'z', 0);
glColor3ubv((GLubyte *)col2);
-
+
glDisable(GL_DEPTH_TEST);
setlinestyle(1);
- glBegin(GL_LINE_STRIP);
- glVertex3fv(tc->center);
- glVertex3fv(vec);
+ glBegin(GL_LINE_STRIP);
+ glVertex3fv(tc->center);
+ glVertex3fv(vec);
glEnd();
setlinestyle(0);
// TRANSFORM_FIX_ME
//if(G.vd->zbuf)
- glEnable(GL_DEPTH_TEST);
+ glEnable(GL_DEPTH_TEST);
}
if (tc->mode & CON_AXIS0) {
@@ -775,7 +653,7 @@ void drawPropCircle(const struct bContext *C, TransInfo *t)
float tmat[4][4], imat[4][4];
UI_ThemeColor(TH_GRID);
-
+
if(t->spacetype == SPACE_VIEW3D && rv3d != NULL)
{
Mat4CpyMat4(tmat, rv3d->viewmat);
@@ -804,20 +682,9 @@ void drawPropCircle(const struct bContext *C, TransInfo *t)
set_inverted_drawing(1);
drawcircball(GL_LINE_LOOP, t->center, t->prop_size, imat);
set_inverted_drawing(0);
-
- glPopMatrix();
- }
-}
-void BIF_getPropCenter(float *center)
-{
- TransInfo *t = BIF_GetTransInfo();
-
- if (t && t->flag & T_PROP_EDIT) {
- VECCOPY(center, t->center);
+ glPopMatrix();
}
- else
- center[0] = center[1] = center[2] = 0.0f;
}
static void drawObjectConstraint(TransInfo *t) {
@@ -839,7 +706,7 @@ static void drawObjectConstraint(TransInfo *t) {
if (t->con.mode & CON_AXIS2) {
drawLine(t, td->ob->obmat[3], td->axismtx[2], 'z', DRAWLIGHT);
}
-
+
td++;
for(i=1;i<t->total;i++,td++) {
@@ -954,12 +821,12 @@ static void setNearestAxis3d(TransInfo *t)
float mvec[3], axis[3], proj[3];
float len[3];
int i, icoord[2];
-
+
/* calculate mouse movement */
mvec[0] = (float)(t->mval[0] - t->con.imval[0]);
mvec[1] = (float)(t->mval[1] - t->con.imval[1]);
mvec[2] = 0.0f;
-
+
/* we need to correct axis length for the current zoomlevel of view,
this to prevent projected values to be clipped behind the camera
and to overflow the short integers.
@@ -972,12 +839,12 @@ static void setNearestAxis3d(TransInfo *t)
for (i = 0; i<3; i++) {
VECCOPY(axis, t->con.mtx[i]);
-
+
VecMulf(axis, zfac);
/* now we can project to get window coordinate */
VecAddf(axis, axis, t->con.center);
projectIntView(t, axis, icoord);
-
+
axis[0] = (float)(icoord[0] - t->center2d[0]);
axis[1] = (float)(icoord[1] - t->center2d[1]);
axis[2] = 0.0f;
@@ -1034,13 +901,13 @@ void setNearestAxis(TransInfo *t)
/* constraint setting - depends on spacetype */
if (t->spacetype == SPACE_VIEW3D) {
/* 3d-view */
- setNearestAxis3d(t);
+ setNearestAxis3d(t);
}
else {
/* assume that this means a 2D-Editor */
setNearestAxis2d(t);
}
-
+
getConstraintMatrix(t);
}
@@ -1083,7 +950,7 @@ int isLockConstraint(TransInfo *t) {
/*
* Returns the dimension of the constraint space.
- *
+ *
* For that reason, the flags always needs to be set to properly evaluate here,
* even if they aren't actually used in the callback function. (Which could happen
* for weird constraints not yet designed. Along a path for example.)
@@ -1107,7 +974,7 @@ int getConstraintSpaceDimension(TransInfo *t)
Someone willing to do it criptically could do the following instead:
return t->con & (CON_AXIS0|CON_AXIS1|CON_AXIS2);
-
+
Based on the assumptions that the axis flags are one after the other and start at 1
*/
}
diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c
index 47f9159d87f..60d209ae2db 100644
--- a/source/blender/editors/transform/transform_conversions.c
+++ b/source/blender/editors/transform/transform_conversions.c
@@ -216,7 +216,7 @@ void sort_trans_data_dist(TransInfo *t) {
qsort_trans_data(t, start, t->data + t->total - 1);
}
-static void sort_trans_data(TransInfo *t)
+static void sort_trans_data(TransInfo *t)
{
TransData *sel, *unsel;
TransData temp;
@@ -252,16 +252,16 @@ static void set_prop_dist(TransInfo *t, short with_dist)
int a;
for(a=0, tob= t->data; a<t->total; a++, tob++) {
-
+
tob->rdist= 0.0f; // init, it was mallocced
-
+
if((tob->flag & TD_SELECTED)==0) {
TransData *td;
int i;
float dist, vec[3];
tob->rdist = -1.0f; // signal for next loop
-
+
for (i = 0, td= t->data; i < t->total; i++, td++) {
if(td->flag & TD_SELECTED) {
VecSubf(vec, tob->center, td->center);
@@ -279,7 +279,7 @@ static void set_prop_dist(TransInfo *t, short with_dist)
if (with_dist) {
tob->dist = tob->rdist;
}
- }
+ }
}
}
@@ -294,9 +294,9 @@ static void createTransTexspace(bContext *C, TransInfo *t)
Object *ob;
ID *id;
int *texflag;
-
+
ob = OBACT;
-
+
if (ob == NULL) { // Shouldn't logically happen, but still...
t->total = 0;
return;
@@ -311,20 +311,20 @@ static void createTransTexspace(bContext *C, TransInfo *t)
t->total = 1;
td= t->data= MEM_callocN(sizeof(TransData), "TransTexspace");
td->ext= t->ext= MEM_callocN(sizeof(TransDataExtension), "TransTexspace");
-
+
td->flag= TD_SELECTED;
VECCOPY(td->center, ob->obmat[3]);
td->ob = ob;
-
+
Mat3CpyMat4(td->mtx, ob->obmat);
Mat3CpyMat4(td->axismtx, ob->obmat);
Mat3Ortho(td->axismtx);
Mat3Inv(td->smtx, td->mtx);
-
+
if (give_obdata_texspace(ob, &texflag, &td->loc, &td->ext->size, &td->ext->rot)) {
*texflag &= ~AUTOSPACE;
}
-
+
VECCOPY(td->iloc, td->loc);
VECCOPY(td->ext->irot, td->ext->rot);
VECCOPY(td->ext->isize, td->ext->size);
@@ -371,7 +371,7 @@ static void createTransEdge(bContext *C, TransInfo *t) {
td->loc= NULL;
if (eed->f & SELECT)
td->flag= TD_SELECTED;
- else
+ else
td->flag= 0;
@@ -400,14 +400,14 @@ static void createTransEdge(bContext *C, TransInfo *t) {
static bKinematicConstraint *has_targetless_ik(bPoseChannel *pchan)
{
bConstraint *con= pchan->constraints.first;
-
+
for(;con; con= con->next) {
if(con->type==CONSTRAINT_TYPE_KINEMATIC && (con->enforce!=0.0)) {
bKinematicConstraint *data= con->data;
-
- if(data->tar==NULL)
+
+ if(data->tar==NULL)
return data;
- if(data->tar->type==OB_ARMATURE && data->subtarget[0]==0)
+ if(data->tar->type==OB_ARMATURE && data->subtarget[0]==0)
return data;
}
}
@@ -419,67 +419,67 @@ static short apply_targetless_ik(Object *ob)
bPoseChannel *pchan, *parchan, *chanlist[256];
bKinematicConstraint *data;
int segcount, apply= 0;
-
+
/* now we got a difficult situation... we have to find the
- target-less IK pchans, and apply transformation to the all
+ target-less IK pchans, and apply transformation to the all
pchans that were in the chain */
-
+
for (pchan=ob->pose->chanbase.first; pchan; pchan=pchan->next) {
data= has_targetless_ik(pchan);
if(data && (data->flag & CONSTRAINT_IK_AUTO)) {
-
+
/* fill the array with the bones of the chain (armature.c does same, keep it synced) */
segcount= 0;
-
+
/* exclude tip from chain? */
if(!(data->flag & CONSTRAINT_IK_TIP))
parchan= pchan->parent;
else
parchan= pchan;
-
+
/* Find the chain's root & count the segments needed */
for (; parchan; parchan=parchan->parent){
chanlist[segcount]= parchan;
segcount++;
-
+
if(segcount==data->rootbone || segcount>255) break; // 255 is weak
}
for(;segcount;segcount--) {
Bone *bone;
float rmat[4][4], tmat[4][4], imat[4][4];
-
+
/* pose_mat(b) = pose_mat(b-1) * offs_bone * channel * constraint * IK */
/* we put in channel the entire result of rmat= (channel * constraint * IK) */
/* pose_mat(b) = pose_mat(b-1) * offs_bone * rmat */
/* rmat = pose_mat(b) * inv( pose_mat(b-1) * offs_bone ) */
-
+
parchan= chanlist[segcount-1];
bone= parchan->bone;
bone->flag |= BONE_TRANSFORM; /* ensures it gets an auto key inserted */
-
+
if(parchan->parent) {
Bone *parbone= parchan->parent->bone;
float offs_bone[4][4];
-
+
/* offs_bone = yoffs(b-1) + root(b) + bonemat(b) */
Mat4CpyMat3(offs_bone, bone->bone_mat);
-
+
/* The bone's root offset (is in the parent's coordinate system) */
VECCOPY(offs_bone[3], bone->head);
-
+
/* Get the length translation of parent (length along y axis) */
offs_bone[3][1]+= parbone->length;
-
+
/* pose_mat(b-1) * offs_bone */
if(parchan->bone->flag & BONE_HINGE) {
/* the rotation of the parent restposition */
Mat4CpyMat4(rmat, parbone->arm_mat); /* rmat used as temp */
-
+
/* the location of actual parent transform */
VECCOPY(rmat[3], offs_bone[3]);
offs_bone[3][0]= offs_bone[3][1]= offs_bone[3][2]= 0.0f;
Mat4MulVecfl(parchan->parent->pose_mat, rmat[3]);
-
+
Mat4MulMat4(tmat, offs_bone, rmat);
}
else if(parchan->bone->flag & BONE_NO_SCALE) {
@@ -488,7 +488,7 @@ static short apply_targetless_ik(Object *ob)
}
else
Mat4MulMat4(tmat, offs_bone, parchan->parent->pose_mat);
-
+
Mat4Invert(imat, tmat);
}
else {
@@ -499,16 +499,16 @@ static short apply_targetless_ik(Object *ob)
}
/* result matrix */
Mat4MulMat4(rmat, parchan->pose_mat, imat);
-
+
/* apply and decompose, doesn't work for constraints or non-uniform scale well */
{
float rmat3[3][3], qmat[3][3], imat[3][3], smat[3][3];
-
+
Mat3CpyMat4(rmat3, rmat);
-
+
/* quaternion */
Mat3ToQuat(rmat3, parchan->quat);
-
+
/* for size, remove rotation */
/* causes problems with some constraints (so apply only if needed) */
if (data->flag & CONSTRAINT_IK_STRETCH) {
@@ -517,19 +517,19 @@ static short apply_targetless_ik(Object *ob)
Mat3MulMat3(smat, rmat3, imat);
Mat3ToSize(smat, parchan->size);
}
-
+
/* causes problems with some constraints (e.g. childof), so disable this */
/* as it is IK shouldn't affect location directly */
/* VECCOPY(parchan->loc, rmat[3]); */
}
-
+
}
-
+
apply= 1;
data->flag &= ~CONSTRAINT_IK_AUTO;
}
- }
-
+ }
+
return apply;
}
@@ -542,7 +542,7 @@ static void add_pose_transdata(TransInfo *t, bPoseChannel *pchan, Object *ob, Tr
VECCOPY(vec, pchan->pose_mat[3]);
VECCOPY(td->center, vec);
-
+
td->ob = ob;
td->flag = TD_SELECTED;
if (pchan->rotmode == PCHAN_ROT_QUAT)
@@ -553,43 +553,43 @@ static void add_pose_transdata(TransInfo *t, bPoseChannel *pchan, Object *ob, Tr
{
td->flag |= TD_NOCENTER;
}
-
+
if (bone->flag & BONE_TRANSFORM_CHILD)
{
td->flag |= TD_NOCENTER;
td->flag |= TD_NO_LOC;
}
-
+
td->protectflag= pchan->protectflag;
-
+
td->loc = pchan->loc;
VECCOPY(td->iloc, pchan->loc);
-
+
td->ext->size= pchan->size;
VECCOPY(td->ext->isize, pchan->size);
-
+
if (pchan->rotmode) {
td->ext->rot= pchan->eul;
td->ext->quat= NULL;
-
+
VECCOPY(td->ext->irot, pchan->eul);
}
else {
td->ext->rot= NULL;
td->ext->quat= pchan->quat;
-
+
QUATCOPY(td->ext->iquat, pchan->quat);
}
/* proper way to get parent transform + own transform + constraints transform */
Mat3CpyMat4(omat, ob->obmat);
-
- if (pchan->parent) {
- if(pchan->bone->flag & BONE_HINGE)
- Mat3CpyMat4(pmat, pchan->parent->bone->arm_mat);
- else
+
+ if (pchan->parent) {
+ if(pchan->bone->flag & BONE_HINGE)
+ Mat3CpyMat4(pmat, pchan->parent->bone->arm_mat);
+ else
Mat3CpyMat4(pmat, pchan->parent->pose_mat);
-
+
if (constraints_list_needinv(t, &pchan->constraints)) {
Mat3CpyMat4(tmat, pchan->constinv);
Mat3Inv(cmat, tmat);
@@ -604,20 +604,20 @@ static void add_pose_transdata(TransInfo *t, bPoseChannel *pchan, Object *ob, Tr
Mat3Inv(cmat, tmat);
Mat3MulSerie(td->mtx, pchan->bone->bone_mat, omat, cmat, 0,0,0,0,0); // dang mulserie swaps args
}
- else
- Mat3MulMat3(td->mtx, omat, pchan->bone->bone_mat); // Mat3MulMat3 has swapped args!
+ else
+ Mat3MulMat3(td->mtx, omat, pchan->bone->bone_mat); // Mat3MulMat3 has swapped args!
}
-
+
Mat3Inv(td->smtx, td->mtx);
-
+
/* for axismat we use bone's own transform */
Mat3CpyMat4(pmat, pchan->pose_mat);
Mat3MulMat3(td->axismtx, omat, pmat);
Mat3Ortho(td->axismtx);
-
+
if (t->mode==TFM_BONESIZE) {
bArmature *arm= t->poseobj->data;
-
+
if(arm->drawtype==ARM_ENVELOPE) {
td->loc= NULL;
td->val= &bone->dist;
@@ -630,7 +630,7 @@ static void add_pose_transdata(TransInfo *t, bPoseChannel *pchan, Object *ob, Tr
td->val= NULL;
}
}
-
+
/* in this case we can do target-less IK grabbing */
if (t->mode==TFM_TRANSLATION) {
bKinematicConstraint *data= has_targetless_ik(pchan);
@@ -644,27 +644,27 @@ static void add_pose_transdata(TransInfo *t, bPoseChannel *pchan, Object *ob, Tr
td->loc = data->grabtarget;
VECCOPY(td->iloc, td->loc);
data->flag |= CONSTRAINT_IK_AUTO;
-
+
/* only object matrix correction */
Mat3CpyMat3 (td->mtx, omat);
Mat3Inv (td->smtx, td->mtx);
}
}
-
+
/* store reference to first constraint */
td->con= pchan->constraints.first;
}
-static void bone_children_clear_transflag(TransInfo *t, ListBase *lb)
+static void bone_children_clear_transflag(int mode, short around, ListBase *lb)
{
Bone *bone= lb->first;
-
+
for(;bone;bone= bone->next) {
if((bone->flag & BONE_HINGE) && (bone->flag & BONE_CONNECTED))
{
bone->flag |= BONE_HINGE_CHILD_TRANSFORM;
}
- else if (bone->flag & BONE_TRANSFORM && (t->mode == TFM_ROTATION || t->mode == TFM_TRACKBALL) && t->around == V3D_LOCAL)
+ else if (bone->flag & BONE_TRANSFORM && (mode == TFM_ROTATION || mode == TFM_TRACKBALL) && around == V3D_LOCAL)
{
bone->flag |= BONE_TRANSFORM_CHILD;
}
@@ -673,69 +673,73 @@ static void bone_children_clear_transflag(TransInfo *t, ListBase *lb)
bone->flag &= ~BONE_TRANSFORM;
}
- bone_children_clear_transflag(t, &bone->childbase);
+ bone_children_clear_transflag(mode, around, &bone->childbase);
}
}
/* sets transform flags in the bones, returns total */
-static void set_pose_transflags(TransInfo *t, Object *ob)
+int count_set_pose_transflags(int *out_mode, short around, Object *ob)
{
bArmature *arm= ob->data;
bPoseChannel *pchan;
Bone *bone;
- int hastranslation;
-
- t->total= 0;
-
- for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
- bone= pchan->bone;
+ int mode = *out_mode;
+ int hastranslation = 0;
+ int total = 0;
+
+ for(pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
+ bone = pchan->bone;
if(bone->layer & arm->layer) {
if(bone->flag & BONE_SELECTED)
bone->flag |= BONE_TRANSFORM;
else
bone->flag &= ~BONE_TRANSFORM;
-
+
bone->flag &= ~BONE_HINGE_CHILD_TRANSFORM;
bone->flag &= ~BONE_TRANSFORM_CHILD;
}
}
-
+
/* make sure no bone can be transformed when a parent is transformed */
/* since pchans are depsgraph sorted, the parents are in beginning of list */
- if(t->mode!=TFM_BONESIZE) {
- for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
- bone= pchan->bone;
+ if(mode != TFM_BONESIZE) {
+ for(pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
+ bone = pchan->bone;
if(bone->flag & BONE_TRANSFORM)
- bone_children_clear_transflag(t, &bone->childbase);
+ bone_children_clear_transflag(mode, around, &bone->childbase);
}
- }
+ }
/* now count, and check if we have autoIK or have to switch from translate to rotate */
- hastranslation= 0;
+ hastranslation = 0;
- for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
- bone= pchan->bone;
+ for(pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
+ bone = pchan->bone;
if(bone->flag & BONE_TRANSFORM) {
- t->total++;
-
- if(t->mode==TFM_TRANSLATION) {
+ total++;
+
+ if(mode == TFM_TRANSLATION) {
if( has_targetless_ik(pchan)==NULL ) {
if(pchan->parent && (pchan->bone->flag & BONE_CONNECTED)) {
if(pchan->bone->flag & BONE_HINGE_CHILD_TRANSFORM)
- hastranslation= 1;
+ hastranslation = 1;
}
else if((pchan->protectflag & OB_LOCK_LOC)!=OB_LOCK_LOC)
- hastranslation= 1;
+ hastranslation = 1;
}
else
- hastranslation= 1;
+ hastranslation = 1;
}
}
}
/* if there are no translatable bones, do rotation */
- if(t->mode==TFM_TRANSLATION && !hastranslation)
- t->mode= TFM_ROTATION;
+ if(mode == TFM_TRANSLATION && !hastranslation)
+ {
+ *out_mode = TFM_ROTATION;
+ }
+
+ return total;
}
@@ -745,16 +749,16 @@ static void set_pose_transflags(TransInfo *t, Object *ob)
static void pchan_autoik_adjust (bPoseChannel *pchan, short chainlen)
{
bConstraint *con;
-
+
/* don't bother to search if no valid constraints */
if ((pchan->constflag & (PCHAN_HAS_IK|PCHAN_HAS_TARGET))==0)
return;
-
+
/* check if pchan has ik-constraint */
for (con= pchan->constraints.first; con; con= con->next) {
if (con->type == CONSTRAINT_TYPE_KINEMATIC && (con->enforce!=0.0)) {
bKinematicConstraint *data= con->data;
-
+
/* only accept if a temporary one (for auto-ik) */
if (data->flag & CONSTRAINT_IK_TEMP) {
/* chainlen is new chainlen, but is limited by maximum chainlen */
@@ -772,7 +776,7 @@ void transform_autoik_update (TransInfo *t, short mode)
{
short *chainlen= &t->settings->autoik_chainlen;
bPoseChannel *pchan;
-
+
/* mode determines what change to apply to chainlen */
if (mode == 1) {
/* mode=1 is from WHEELMOUSEDOWN... increases len */
@@ -782,15 +786,15 @@ void transform_autoik_update (TransInfo *t, short mode)
/* mode==-1 is from WHEELMOUSEUP... decreases len */
if (*chainlen > 0) (*chainlen)--;
}
-
+
/* sanity checks (don't assume t->poseobj is set, or that it is an armature) */
if (ELEM(NULL, t->poseobj, t->poseobj->pose))
return;
-
+
/* apply to all pose-channels */
for (pchan=t->poseobj->pose->chanbase.first; pchan; pchan=pchan->next) {
pchan_autoik_adjust(pchan, *chainlen);
- }
+ }
}
/* frees temporal IKs */
@@ -799,11 +803,11 @@ static void pose_grab_with_ik_clear(Object *ob)
bKinematicConstraint *data;
bPoseChannel *pchan;
bConstraint *con, *next;
-
+
for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
/* clear all temporary lock flags */
pchan->ikflag &= ~(BONE_IK_NO_XDOF_TEMP|BONE_IK_NO_YDOF_TEMP|BONE_IK_NO_ZDOF_TEMP);
-
+
pchan->constflag &= ~(PCHAN_HAS_IK|PCHAN_HAS_TARGET);
/* remove all temporary IK-constraints added */
for (con= pchan->constraints.first; con; con= next) {
@@ -830,11 +834,11 @@ static short pose_grab_with_ik_add(bPoseChannel *pchan)
bKinematicConstraint *data;
bConstraint *con;
bConstraint *targetless = 0;
-
+
/* Sanity check */
- if (pchan == NULL)
+ if (pchan == NULL)
return 0;
-
+
/* Rule: not if there's already an IK on this channel */
for (con= pchan->constraints.first; con; con= con->next) {
if (con->type==CONSTRAINT_TYPE_KINEMATIC) {
@@ -851,7 +855,7 @@ static short pose_grab_with_ik_add(bPoseChannel *pchan)
return 0;
}
}
-
+
con = add_new_constraint(CONSTRAINT_TYPE_KINEMATIC);
BLI_addtail(&pchan->constraints, con);
pchan->constflag |= (PCHAN_HAS_IK|PCHAN_HAS_TARGET); /* for draw, but also for detecting while pose solving */
@@ -864,22 +868,22 @@ static short pose_grab_with_ik_add(bPoseChannel *pchan)
data->flag |= CONSTRAINT_IK_TEMP|CONSTRAINT_IK_AUTO;
VECCOPY(data->grabtarget, pchan->pose_tail);
data->rootbone= 1;
-
+
/* we include only a connected chain */
while ((pchan) && (pchan->bone->flag & BONE_CONNECTED)) {
/* here, we set ik-settings for bone from pchan->protectflag */
if (pchan->protectflag & OB_LOCK_ROTX) pchan->ikflag |= BONE_IK_NO_XDOF_TEMP;
if (pchan->protectflag & OB_LOCK_ROTY) pchan->ikflag |= BONE_IK_NO_YDOF_TEMP;
if (pchan->protectflag & OB_LOCK_ROTZ) pchan->ikflag |= BONE_IK_NO_ZDOF_TEMP;
-
+
/* now we count this pchan as being included */
data->rootbone++;
pchan= pchan->parent;
}
-
+
/* make a copy of maximum chain-length */
data->max_rootbone= data->rootbone;
-
+
return 1;
}
@@ -901,7 +905,7 @@ static short pose_grab_with_ik_children(bPose *pose, Bone *bone)
if (pchan)
added+= pose_grab_with_ik_add(pchan);
}
-
+
return added;
}
@@ -912,12 +916,12 @@ static short pose_grab_with_ik(Object *ob)
bPoseChannel *pchan, *parent;
Bone *bonec;
short tot_ik= 0;
-
+
if ((ob==NULL) || (ob->pose==NULL) || (ob->flag & OB_POSEMODE)==0)
return 0;
-
+
arm = ob->data;
-
+
/* Rule: allow multiple Bones (but they must be selected, and only one ik-solver per chain should get added) */
for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
if (pchan->bone->layer & arm->layer) {
@@ -930,7 +934,7 @@ static short pose_grab_with_ik(Object *ob)
}
if ((pchan->bone->flag & BONE_CONNECTED)==0 && (bonec == NULL))
continue;
-
+
/* rule: if selected Bone is not a root bone, it gets a temporal IK */
if (pchan->parent) {
/* only adds if there's no IK yet (and no parent bone was selected) */
@@ -948,9 +952,9 @@ static short pose_grab_with_ik(Object *ob)
}
}
}
-
+
return (tot_ik) ? 1 : 0;
-}
+}
/* only called with pose mode active object now */
@@ -962,13 +966,13 @@ static void createTransPose(bContext *C, TransInfo *t, Object *ob)
TransDataExtension *tdx;
short ik_on= 0;
int i;
-
+
t->total= 0;
-
+
/* check validity of state */
arm= get_armature(ob);
if ((arm==NULL) || (ob->pose==NULL)) return;
-
+
if (arm->flag & ARM_RESTPOS) {
if (ELEM(t->mode, TFM_DUMMY, TFM_BONESIZE)==0) {
// XXX use transform operator reports
@@ -982,15 +986,15 @@ static void createTransPose(bContext *C, TransInfo *t, Object *ob)
ik_on= pose_grab_with_ik(ob);
if (ik_on) t->flag |= T_AUTOIK;
}
-
+
/* set flags and count total (warning, can change transform to rotate) */
- set_pose_transflags(t, ob);
-
- if(t->total==0) return;
+ t->total = count_set_pose_transflags(&t->mode, t->around, ob);
+
+ if(t->total == 0) return;
t->flag |= T_POSE;
t->poseobj= ob; /* we also allow non-active objects to be transformed, in weightpaint */
-
+
/* init trans data */
td = t->data = MEM_callocN(t->total*sizeof(TransData), "TransPoseBone");
tdx = t->ext = MEM_callocN(t->total*sizeof(TransDataExtension), "TransPoseBoneExt");
@@ -998,8 +1002,8 @@ static void createTransPose(bContext *C, TransInfo *t, Object *ob)
td->ext= tdx;
td->tdi = NULL;
td->val = NULL;
- }
-
+ }
+
/* use pose channels to fill trans data */
td= t->data;
for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
@@ -1008,12 +1012,12 @@ static void createTransPose(bContext *C, TransInfo *t, Object *ob)
td++;
}
}
-
+
if(td != (t->data+t->total)) {
// XXX use transform operator reports
// BKE_report(op->reports, RPT_DEBUG, "Bone selection count error.");
}
-
+
/* initialise initial auto=ik chainlen's? */
if (ik_on) transform_autoik_update(t, 0);
}
@@ -1054,16 +1058,16 @@ static void createTransArmatureVerts(bContext *C, TransInfo *t)
}
if (!t->total) return;
-
+
Mat3CpyMat4(mtx, t->obedit->obmat);
Mat3Inv(smtx, mtx);
td = t->data = MEM_callocN(t->total*sizeof(TransData), "TransEditBone");
-
+
for (ebo = edbo->first; ebo; ebo = ebo->next)
{
ebo->oldlength = ebo->length; // length==0.0 on extrude, used for scaling radius of bone points
-
+
if(ebo->layer & arm->layer) {
if (t->mode==TFM_BONE_ENVELOPE)
{
@@ -1071,17 +1075,17 @@ static void createTransArmatureVerts(bContext *C, TransInfo *t)
{
td->val= &ebo->rad_head;
td->ival= *td->val;
-
+
VECCOPY (td->center, ebo->head);
td->flag= TD_SELECTED;
-
+
Mat3CpyMat3(td->smtx, smtx);
Mat3CpyMat3(td->mtx, mtx);
-
+
td->loc = NULL;
td->ext = NULL;
td->tdi = NULL;
-
+
td++;
}
if (ebo->flag & BONE_TIPSEL)
@@ -1090,17 +1094,17 @@ static void createTransArmatureVerts(bContext *C, TransInfo *t)
td->ival= *td->val;
VECCOPY (td->center, ebo->tail);
td->flag= TD_SELECTED;
-
+
Mat3CpyMat3(td->smtx, smtx);
Mat3CpyMat3(td->mtx, mtx);
-
+
td->loc = NULL;
td->ext = NULL;
td->tdi = NULL;
-
+
td++;
}
-
+
}
else if (t->mode==TFM_BONESIZE)
{
@@ -1120,19 +1124,19 @@ static void createTransArmatureVerts(bContext *C, TransInfo *t)
}
VECCOPY (td->center, ebo->head);
td->flag= TD_SELECTED;
-
+
/* use local bone matrix */
- VecSubf(delta, ebo->tail, ebo->head);
+ VecSubf(delta, ebo->tail, ebo->head);
vec_roll_to_mat3(delta, ebo->roll, bonemat);
Mat3MulMat3(td->mtx, mtx, bonemat);
Mat3Inv(td->smtx, td->mtx);
-
+
Mat3CpyMat3(td->axismtx, td->mtx);
Mat3Ortho(td->axismtx);
td->ext = NULL;
td->tdi = NULL;
-
+
td++;
}
}
@@ -1143,13 +1147,13 @@ static void createTransArmatureVerts(bContext *C, TransInfo *t)
td->loc= NULL;
td->val= &(ebo->roll);
td->ival= ebo->roll;
-
+
VECCOPY (td->center, ebo->head);
td->flag= TD_SELECTED;
td->ext = NULL;
td->tdi = NULL;
-
+
td++;
}
}
@@ -1167,7 +1171,7 @@ static void createTransArmatureVerts(bContext *C, TransInfo *t)
Mat3CpyMat3(td->smtx, smtx);
Mat3CpyMat3(td->mtx, mtx);
- VecSubf(delta, ebo->tail, ebo->head);
+ VecSubf(delta, ebo->tail, ebo->head);
vec_roll_to_mat3(delta, ebo->roll, td->axismtx);
if ((ebo->flag & BONE_ROOTSEL) == 0)
@@ -1193,7 +1197,7 @@ static void createTransArmatureVerts(bContext *C, TransInfo *t)
Mat3CpyMat3(td->smtx, smtx);
Mat3CpyMat3(td->mtx, mtx);
- VecSubf(delta, ebo->tail, ebo->head);
+ VecSubf(delta, ebo->tail, ebo->head);
vec_roll_to_mat3(delta, ebo->roll, td->axismtx);
td->extra = ebo; /* to fix roll */
@@ -1230,16 +1234,16 @@ static void createTransMBallVerts(bContext *C, TransInfo *t)
/* note: in prop mode we need at least 1 selected */
if (countsel==0) return;
-
- if(propmode) t->total = count;
+
+ if(propmode) t->total = count;
else t->total = countsel;
-
+
td = t->data= MEM_callocN(t->total*sizeof(TransData), "TransObData(MBall EditMode)");
tx = t->ext = MEM_callocN(t->total*sizeof(TransDataExtension), "MetaElement_TransExtension");
Mat3CpyMat4(mtx, t->obedit->obmat);
Mat3Inv(smtx, mtx);
-
+
for(ml= editelems.first; ml; ml= ml->next) {
if(propmode || (ml->flag & SELECT)) {
td->loc= &ml->x;
@@ -1357,7 +1361,7 @@ static void createTransCurveVerts(bContext *C, TransInfo *t)
/* to be sure */
if(cu->editnurb==NULL) return;
-
+
/* count total of vertices, check identical as in 2nd loop for making transdata! */
for(nu= cu->editnurb->first; nu; nu= nu->next) {
if((nu->type & 7)==CU_BEZIER) {
@@ -1386,14 +1390,14 @@ static void createTransCurveVerts(bContext *C, TransInfo *t)
}
/* note: in prop mode we need at least 1 selected */
if (countsel==0) return;
-
- if(propmode) t->total = count;
+
+ if(propmode) t->total = count;
else t->total = countsel;
t->data= MEM_callocN(t->total*sizeof(TransData), "TransObData(Curve EditMode)");
Mat3CpyMat4(mtx, t->obedit->obmat);
Mat3Inv(smtx, mtx);
-
+
td = t->data;
for(nu= cu->editnurb->first; nu; nu= nu->next) {
if((nu->type & 7)==CU_BEZIER) {
@@ -1402,7 +1406,7 @@ static void createTransCurveVerts(bContext *C, TransInfo *t)
for(a=0, bezt= nu->bezt; a<nu->pntsu; a++, bezt++) {
if(bezt->hide==0) {
TransDataCurveHandleFlags *hdata = NULL;
-
+
if( propmode ||
((bezt->f2 & SELECT) && (G.f & G_HIDDENHANDLES)) ||
((bezt->f1 & SELECT) && (G.f & G_HIDDENHANDLES)==0)
@@ -1420,7 +1424,7 @@ static void createTransCurveVerts(bContext *C, TransInfo *t)
td->ext = NULL;
td->tdi = NULL;
td->val = NULL;
-
+
hdata = initTransDataCurveHandes(td, bezt);
Mat3CpyMat3(td->smtx, smtx);
@@ -1430,7 +1434,7 @@ static void createTransCurveVerts(bContext *C, TransInfo *t)
count++;
tail++;
}
-
+
/* This is the Curve Point, the other two are handles */
if(propmode || (bezt->f2 & SELECT)) {
VECCOPY(td->iloc, bezt->vec[1]);
@@ -1440,7 +1444,7 @@ static void createTransCurveVerts(bContext *C, TransInfo *t)
else td->flag= 0;
td->ext = NULL;
td->tdi = NULL;
-
+
if (t->mode==TFM_CURVE_SHRINKFATTEN) { /* || t->mode==TFM_RESIZE) {*/ /* TODO - make points scale */
td->val = &(bezt->radius);
td->ival = bezt->radius;
@@ -1453,13 +1457,13 @@ static void createTransCurveVerts(bContext *C, TransInfo *t)
Mat3CpyMat3(td->smtx, smtx);
Mat3CpyMat3(td->mtx, mtx);
-
+
if ((bezt->f1&SELECT)==0 && (bezt->f3&SELECT)==0)
/* If the middle is selected but the sides arnt, this is needed */
if (hdata==NULL) { /* if the handle was not saved by the previous handle */
hdata = initTransDataCurveHandes(td, bezt);
}
-
+
td++;
count++;
tail++;
@@ -1485,7 +1489,7 @@ static void createTransCurveVerts(bContext *C, TransInfo *t)
if (hdata==NULL) { /* if the handle was not saved by the previous handle */
hdata = initTransDataCurveHandes(td, bezt);
}
-
+
Mat3CpyMat3(td->smtx, smtx);
Mat3CpyMat3(td->mtx, mtx);
@@ -1501,7 +1505,7 @@ static void createTransCurveVerts(bContext *C, TransInfo *t)
}
if (propmode && head != tail)
calc_distanceCurveVerts(head, tail-1);
-
+
/* TODO - in the case of tilt and radius we can also avoid allocating the initTransDataCurveHandes
* but for now just dont change handle types */
if (ELEM(t->mode, TFM_CURVE_SHRINKFATTEN, TFM_TILT) == 0)
@@ -1520,7 +1524,7 @@ static void createTransCurveVerts(bContext *C, TransInfo *t)
else td->flag= 0;
td->ext = NULL;
td->tdi = NULL;
-
+
if (t->mode==TFM_CURVE_SHRINKFATTEN || t->mode==TFM_RESIZE) {
td->val = &(bp->radius);
td->ival = bp->radius;
@@ -1569,14 +1573,14 @@ static void createTransLatticeVerts(bContext *C, TransInfo *t)
}
bp++;
}
-
+
/* note: in prop mode we need at least 1 selected */
if (countsel==0) return;
-
- if(propmode) t->total = count;
+
+ if(propmode) t->total = count;
else t->total = countsel;
t->data= MEM_callocN(t->total*sizeof(TransData), "TransObData(Lattice EditMode)");
-
+
Mat3CpyMat4(mtx, t->obedit->obmat);
Mat3Inv(smtx, mtx);
@@ -1654,10 +1658,10 @@ static void createTransParticleVerts(bContext *C, TransInfo *t)
pa->flag |= PARS_TRANSFORM;
}
}
-
+
/* note: in prop mode we need at least 1 selected */
if (hasselected==0) return;
-
+
t->total = count;
td = t->data = MEM_callocN(t->total * sizeof(TransData), "TransObData(Particle Mode)");
@@ -1795,13 +1799,13 @@ static void editmesh_set_connectivity_distance(EditMesh *em, int total, float *v
/* Floodfill routine */
/*
- At worst this is n*n of complexity where n is number of edges
+ At worst this is n*n of complexity where n is number of edges
Best case would be n if the list is ordered perfectly.
Estimate is n log n in average (so not too bad)
*/
while(done) {
done= 0;
-
+
for(eed= em->edges.first; eed; eed= eed->next) {
if(eed->h==0) {
EditVert *v1= eed->v1, *v2= eed->v2;
@@ -1882,7 +1886,7 @@ static void editmesh_set_connectivity_distance(EditMesh *em, int total, float *v
static void get_face_center(float *cent, EditMesh *em, EditVert *eve)
{
EditFace *efa;
-
+
for(efa= em->faces.first; efa; efa= efa->next)
if(efa->f & SELECT)
if(efa->v1==eve || efa->v2==eve || efa->v3==eve || efa->v4==eve)
@@ -1901,7 +1905,7 @@ static void VertsToTransData(TransInfo *t, TransData *td, EditMesh *em, EditVert
// td->loc = key->co;
//else
td->loc = eve->co;
-
+
VECCOPY(td->center, td->loc);
if(t->around==V3D_LOCAL && (em->selectmode & SCE_SELECT_FACE))
get_face_center(td->center, em, eve);
@@ -1931,7 +1935,7 @@ static void VertsToTransData(TransInfo *t, TransData *td, EditMesh *em, EditVert
static void make_vertexcos__mapFunc(void *userData, int index, float *co, float *no_f, short *no_s)
{
float *vec = userData;
-
+
vec+= 3*index;
VECCOPY(vec, co);
}
@@ -1940,14 +1944,14 @@ static int modifiers_disable_subsurf_temporary(Object *ob)
{
ModifierData *md;
int disabled = 0;
-
+
for(md=ob->modifiers.first; md; md=md->next)
if(md->type==eModifierType_Subsurf)
if(md->mode & eModifierMode_OnCage) {
md->mode ^= eModifierMode_DisableTemporary;
disabled= 1;
}
-
+
return disabled;
}
@@ -1969,12 +1973,12 @@ static float *get_crazy_mapped_editverts(TransInfo *t)
vertexcos= MEM_mallocN(3*sizeof(float)*me->edit_mesh->totvert, "vertexcos map");
dm->foreachMappedVert(dm, make_vertexcos__mapFunc, vertexcos);
-
+
dm->release(dm);
-
+
/* set back the flag, no new cage needs to be built, transform does it */
modifiers_disable_subsurf_temporary(t->obedit);
-
+
return vertexcos;
}
@@ -1983,15 +1987,15 @@ static void set_crazy_vertex_quat(float *quat, float *v1, float *v2, float *v3,
{
float vecu[3], vecv[3];
float q1[4], q2[4];
-
+
TAN_MAKE_VEC(vecu, v1, v2);
TAN_MAKE_VEC(vecv, v1, v3);
triatoquat(v1, vecu, vecv, q1);
-
+
TAN_MAKE_VEC(vecu, def1, def2);
TAN_MAKE_VEC(vecv, def1, def3);
triatoquat(def1, vecu, vecv, q2);
-
+
QuatSub(quat, q2, q1);
}
#undef TAN_MAKE_VEC
@@ -2002,16 +2006,16 @@ static void set_crazyspace_quats(EditMesh *em, float *origcos, float *mappedcos,
EditFace *efa;
float *v1, *v2, *v3, *v4, *co1, *co2, *co3, *co4;
intptr_t index= 0;
-
+
/* two abused locations in vertices */
for(eve= em->verts.first; eve; eve= eve->next, index++) {
eve->tmp.p = NULL;
eve->prev= (EditVert *)index;
}
-
+
/* first store two sets of tangent vectors in vertices, we derive it just from the face-edges */
for(efa= em->faces.first; efa; efa= efa->next) {
-
+
/* retrieve mapped coordinates */
v1= mappedcos + 3*(intptr_t)(efa->v1->prev);
v2= mappedcos + 3*(intptr_t)(efa->v2->prev);
@@ -2026,7 +2030,7 @@ static void set_crazyspace_quats(EditMesh *em, float *origcos, float *mappedcos,
efa->v2->tmp.p= (void*)quats;
quats+= 4;
}
-
+
if(efa->v4) {
v4= mappedcos + 3*(intptr_t)(efa->v4->prev);
co4= (origcos)? origcos + 3*(intptr_t)(efa->v4->prev): efa->v4->co;
@@ -2114,7 +2118,7 @@ static void createTransEditVerts(bContext *C, TransInfo *t)
// transform now requires awareness for select mode, so we tag the f1 flags in verts
if(ts->selectmode & SCE_SELECT_VERTEX) {
for(eve= em->verts.first; eve; eve= eve->next) {
- if(eve->h==0 && (eve->f & SELECT))
+ if(eve->h==0 && (eve->f & SELECT))
eve->f1= SELECT;
else
eve->f1= 0;
@@ -2138,7 +2142,7 @@ static void createTransEditVerts(bContext *C, TransInfo *t)
}
}
}
-
+
/* now we can count */
for(eve= em->verts.first; eve; eve= eve->next) {
if(eve->h==0) {
@@ -2146,10 +2150,10 @@ static void createTransEditVerts(bContext *C, TransInfo *t)
if(propmode) count++;
}
}
-
+
/* note: in prop mode we need at least 1 selected */
if (countsel==0) return;
-
+
/* check active */
if (em->selected.last) {
EditSelection *ese = em->selected.last;
@@ -2158,22 +2162,22 @@ static void createTransEditVerts(bContext *C, TransInfo *t)
}
}
-
+
if(propmode) {
- t->total = count;
-
+ t->total = count;
+
/* allocating scratch arrays */
vectors = (float *)MEM_mallocN(t->total * 3 * sizeof(float), "scratch vectors");
nears = (EditVert**)MEM_mallocN(t->total * sizeof(EditVert*), "scratch nears");
}
else t->total = countsel;
tob= t->data= MEM_callocN(t->total*sizeof(TransData), "TransObData(Mesh EditMode)");
-
+
Mat3CpyMat4(mtx, t->obedit->obmat);
Mat3Inv(smtx, mtx);
if(propmode) editmesh_set_connectivity_distance(em, t->total, vectors, nears);
-
+
/* detect CrazySpace [tm] */
if(propmode==0) {
if(modifiers_getCageIndex(t->obedit, NULL)>=0) {
@@ -2198,7 +2202,7 @@ static void createTransEditVerts(bContext *C, TransInfo *t)
}
}
}
-
+
/* find out which half we do */
if(mirror) {
for (eve=em->verts.first; eve; eve=eve->next) {
@@ -2209,18 +2213,18 @@ static void createTransEditVerts(bContext *C, TransInfo *t)
}
}
}
-
+
for (a=0, eve=em->verts.first; eve; eve=eve->next, a++) {
if(eve->h==0) {
if(propmode || eve->f1) {
VertsToTransData(t, tob, em, eve);
-
+
/* selected */
if(eve->f1) tob->flag |= TD_SELECTED;
-
+
/* active */
if(eve == eve_act) tob->flag |= TD_ACTIVE;
-
+
if(propmode) {
if (eve->f2) {
float vec[3];
@@ -2233,11 +2237,11 @@ static void createTransEditVerts(bContext *C, TransInfo *t)
tob->dist = MAXFLOAT;
}
}
-
+
/* CrazySpace */
if(defmats || (quats && eve->tmp.p)) {
float mat[3][3], imat[3][3], qmat[3][3];
-
+
/* use both or either quat and defmat correction */
if(quats && eve->tmp.f) {
QuatToMat3(eve->tmp.p, qmat);
@@ -2252,7 +2256,7 @@ static void createTransEditVerts(bContext *C, TransInfo *t)
Mat3MulMat3(mat, mtx, defmats[a]);
Mat3Inv(imat, mat);
-
+
Mat3CpyMat3(tob->smtx, imat);
Mat3CpyMat3(tob->mtx, mat);
}
@@ -2260,7 +2264,7 @@ static void createTransEditVerts(bContext *C, TransInfo *t)
Mat3CpyMat3(tob->smtx, smtx);
Mat3CpyMat3(tob->mtx, mtx);
}
-
+
/* Mirror? */
if( (mirror>0 && tob->iloc[0]>0.0f) || (mirror<0 && tob->iloc[0]<0.0f)) {
EditVert *vmir= editmesh_get_x_mirror_vert(t->obedit, em, tob->iloc); /* initializes octree on first call */
@@ -2268,7 +2272,7 @@ static void createTransEditVerts(bContext *C, TransInfo *t)
}
tob++;
}
- }
+ }
}
if (propmode) {
MEM_freeN(vectors);
@@ -2286,7 +2290,7 @@ void flushTransNodes(TransInfo *t)
{
int a;
TransData2D *td;
-
+
/* flush to 2d vector from internally used 3d vector */
for(a=0, td= t->data2d; a<t->total; a++, td++) {
td->loc2d[0]= td->loc[0];
@@ -2304,7 +2308,7 @@ void flushTransSeq(TransInfo *t)
TransDataSeq *tdsq= NULL;
Sequence *seq;
-
+
/* prevent updating the same seq twice
* if the transdata order is changed this will mess up
@@ -2322,7 +2326,7 @@ void flushTransSeq(TransInfo *t)
case SELECT:
if (seq->type != SEQ_META && seq_tx_test(seq)) /* for meta's, their children move */
seq->start= new_frame - tdsq->start_offset;
-
+
if (seq->depth==0) {
seq->machine= (int)(td2d->loc[1] + 0.5f);
CLAMP(seq->machine, 1, MAXSEQ);
@@ -2346,7 +2350,7 @@ void flushTransSeq(TransInfo *t)
* children are ALWAYS transformed first
* so we dont need to do this in another loop. */
calc_sequence(seq);
-
+
/* test overlap, displayes red outline */
seq->flag &= ~SEQ_OVERLAP;
if( seq_test_overlap(seqbasep, seq) ) {
@@ -2423,7 +2427,7 @@ static void createTransUVs(bContext *C, TransInfo *t)
EditMesh *em = ((Mesh *)t->obedit->data)->edit_mesh;
EditFace *efa;
-
+
if(!ED_uvedit_test(t->obedit)) return;
/* count */
@@ -2432,10 +2436,10 @@ static void createTransUVs(bContext *C, TransInfo *t)
if(uvedit_face_visible(scene, ima, efa, tf)) {
efa->tmp.p = tf;
-
- if (uvedit_uv_selected(scene, efa, tf, 0)) countsel++;
- if (uvedit_uv_selected(scene, efa, tf, 1)) countsel++;
- if (uvedit_uv_selected(scene, efa, tf, 2)) countsel++;
+
+ if (uvedit_uv_selected(scene, efa, tf, 0)) countsel++;
+ if (uvedit_uv_selected(scene, efa, tf, 1)) countsel++;
+ if (uvedit_uv_selected(scene, efa, tf, 2)) countsel++;
if (efa->v4 && uvedit_uv_selected(scene, efa, tf, 3)) countsel++;
if(propmode)
count += (efa->v4)? 4: 3;
@@ -2443,10 +2447,10 @@ static void createTransUVs(bContext *C, TransInfo *t)
efa->tmp.p = NULL;
}
}
-
+
/* note: in prop mode we need at least 1 selected */
if (countsel==0) return;
-
+
t->total= (propmode)? count: countsel;
t->data= MEM_callocN(t->total*sizeof(TransData), "TransObData(UV Editing)");
/* for each 2d uv coord a 3d vector is allocated, so that they can be
@@ -2458,7 +2462,7 @@ static void createTransUVs(bContext *C, TransInfo *t)
td= t->data;
td2d= t->data2d;
-
+
for (efa= em->faces.first; efa; efa= efa->next) {
if ((tf=(MTFace *)efa->tmp.p)) {
if (propmode) {
@@ -2475,7 +2479,7 @@ static void createTransUVs(bContext *C, TransInfo *t)
}
}
}
-
+
if (sima->flag & SI_LIVE_UNWRAP)
ED_uvedit_live_unwrap_begin(t->scene, t->obedit);
}
@@ -2496,7 +2500,7 @@ void flushTransUVs(TransInfo *t)
for(a=0, td= t->data2d; a<t->total; a++, td++) {
td->loc2d[0]= td->loc[0]*invx;
td->loc2d[1]= td->loc[1]*invy;
-
+
if((sima->flag & SI_PIXELSNAP) && (t->state != TRANS_CANCEL)) {
td->loc2d[0]= (float)floor(width*td->loc2d[0] + 0.5f)/width;
td->loc2d[1]= (float)floor(height*td->loc2d[1] + 0.5f)/height;
@@ -2547,7 +2551,7 @@ int clipUVTransform(TransInfo *t, float *vec, int resize)
vec[1] -= max[1]-aspy;
else
clipy= 0;
- }
+ }
return (clipx || clipy);
}
@@ -2559,7 +2563,7 @@ static short FrameOnMouseSide(char side, float frame, float cframe)
{
/* both sides, so it doesn't matter */
if (side == 'B') return 1;
-
+
/* only on the named side */
if (side == 'R')
return (frame >= cframe) ? 1 : 0;
@@ -2574,28 +2578,28 @@ static void createTransNlaData(bContext *C, TransInfo *t)
Scene *scene= CTX_data_scene(C);
TransData *td = NULL;
TransDataNla *tdn = NULL;
-
+
bAnimContext ac;
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
int count=0;
char side;
-
+
/* determine what type of data we are operating on */
if (ANIM_animdata_get_context(C, &ac) == 0)
return;
-
+
/* filter data */
filter= (ANIMFILTER_VISIBLE | ANIMFILTER_NLATRACKS | ANIMFILTER_FOREDIT);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
-
+
/* which side of the current frame should be allowed */
if (t->mode == TFM_TIME_EXTEND) {
/* only side on which mouse is gets transformed */
float xmouse, ymouse;
-
+
UI_view2d_region_to_view(&ac.ar->v2d, t->imval[0], t->imval[1], &xmouse, &ymouse);
side = (xmouse > CFRA) ? 'R' : 'L'; // XXX use t->frame_side
}
@@ -2603,15 +2607,15 @@ static void createTransNlaData(bContext *C, TransInfo *t)
/* normal transform - both sides of current frame are considered */
side = 'B';
}
-
+
/* loop 1: count how many strips are selected (consider each strip as 2 points) */
for (ale= anim_data.first; ale; ale= ale->next) {
NlaTrack *nlt= (NlaTrack *)ale->data;
NlaStrip *strip;
-
+
/* make some meta-strips for chains of selected strips */
BKE_nlastrips_make_metas(&nlt->strips, 1);
-
+
/* only consider selected strips */
for (strip= nlt->strips.first; strip; strip= strip->next) {
// TODO: we can make strips have handles later on...
@@ -2624,29 +2628,29 @@ static void createTransNlaData(bContext *C, TransInfo *t)
}
}
}
-
+
/* stop if trying to build list if nothing selected */
if (count == 0) {
/* cleanup temp list */
BLI_freelistN(&anim_data);
return;
}
-
+
/* allocate memory for data */
t->total= count;
-
+
t->data= MEM_callocN(t->total*sizeof(TransData), "TransData(NLA Editor)");
td= t->data;
t->customData= MEM_callocN(t->total*sizeof(TransDataNla), "TransDataNla (NLA Editor)");
tdn= t->customData;
-
+
/* loop 2: build transdata array */
for (ale= anim_data.first; ale; ale= ale->next) {
/* only if a real NLA-track */
if (ale->type == ANIMTYPE_NLATRACK) {
NlaTrack *nlt= (NlaTrack *)ale->data;
NlaStrip *strip;
-
+
/* only consider selected strips */
for (strip= nlt->strips.first; strip; strip= strip->next) {
// TODO: we can make strips have handles later on...
@@ -2663,44 +2667,44 @@ static void createTransNlaData(bContext *C, TransInfo *t)
* cases, there will need to be 1 of these tdn elements in the array skipped...
*/
float center[3], yval;
-
+
/* firstly, init tdn settings */
tdn->oldTrack= tdn->nlt= nlt;
tdn->strip= strip;
tdn->trackIndex= BLI_findindex(&nlt->strips, strip);
-
+
yval= (float)(tdn->trackIndex * NLACHANNEL_STEP);
-
+
tdn->h1[0]= strip->start;
tdn->h1[1]= yval;
tdn->h2[0]= strip->end;
tdn->h2[1]= yval;
-
+
center[0]= (float)CFRA;
center[1]= yval;
center[2]= 0.0f;
-
+
/* set td's based on which handles are applicable */
- if (FrameOnMouseSide(side, strip->start, (float)CFRA))
+ if (FrameOnMouseSide(side, strip->start, (float)CFRA))
{
/* just set tdn to assume that it only has one handle for now */
tdn->handle= -1;
-
+
/* now, link the transform data up to this data */
if (t->mode == TFM_TRANSLATION) {
td->loc= tdn->h1;
VECCOPY(td->iloc, tdn->h1);
-
+
/* store all the other gunk that is required by transform */
VECCOPY(td->center, center);
memset(td->axismtx, 0, sizeof(td->axismtx));
td->axismtx[2][2] = 1.0f;
-
+
td->ext= NULL; td->tdi= NULL; td->val= NULL;
-
+
td->flag |= TD_SELECTED;
td->dist= 0.0f;
-
+
Mat3One(td->mtx);
Mat3One(td->smtx);
}
@@ -2708,30 +2712,30 @@ static void createTransNlaData(bContext *C, TransInfo *t)
td->val= &tdn->h1[0];
td->ival= tdn->h1[0];
}
-
+
td->extra= tdn;
td++;
}
- if (FrameOnMouseSide(side, strip->end, (float)CFRA))
- {
+ if (FrameOnMouseSide(side, strip->end, (float)CFRA))
+ {
/* if tdn is already holding the start handle, then we're doing both, otherwise, only end */
tdn->handle= (tdn->handle) ? 2 : 1;
-
+
/* now, link the transform data up to this data */
if (t->mode == TFM_TRANSLATION) {
td->loc= tdn->h2;
VECCOPY(td->iloc, tdn->h2);
-
+
/* store all the other gunk that is required by transform */
VECCOPY(td->center, center);
memset(td->axismtx, 0, sizeof(td->axismtx));
td->axismtx[2][2] = 1.0f;
-
+
td->ext= NULL; td->tdi= NULL; td->val= NULL;
-
+
td->flag |= TD_SELECTED;
td->dist= 0.0f;
-
+
Mat3One(td->mtx);
Mat3One(td->smtx);
}
@@ -2739,12 +2743,12 @@ static void createTransNlaData(bContext *C, TransInfo *t)
td->val= &tdn->h2[0];
td->ival= tdn->h2[0];
}
-
+
td->extra= tdn;
td++;
}
-
- /* if both handles were used, skip the next tdn (i.e. leave it blank) since the counting code is dumb...
+
+ /* if both handles were used, skip the next tdn (i.e. leave it blank) since the counting code is dumb...
* otherwise, just advance to the next one...
*/
if (tdn->handle == 2)
@@ -2756,7 +2760,7 @@ static void createTransNlaData(bContext *C, TransInfo *t)
}
}
}
-
+
/* cleanup temp list */
BLI_freelistN(&anim_data);
}
@@ -2772,25 +2776,25 @@ static void createTransNlaData(bContext *C, TransInfo *t)
static void posttrans_gpd_clean (bGPdata *gpd)
{
bGPDlayer *gpl;
-
+
for (gpl= gpd->layers.first; gpl; gpl= gpl->next) {
ListBase sel_buffer = {NULL, NULL};
bGPDframe *gpf, *gpfn;
bGPDframe *gfs, *gfsn;
-
- /* loop 1: loop through and isolate selected gp-frames to buffer
+
+ /* loop 1: loop through and isolate selected gp-frames to buffer
* (these need to be sorted as they are isolated)
*/
for (gpf= gpl->frames.first; gpf; gpf= gpfn) {
short added= 0;
gpfn= gpf->next;
-
+
if (gpf->flag & GP_FRAME_SELECT) {
BLI_remlink(&gpl->frames, gpf);
-
+
/* find place to add them in buffer
* - go backwards as most frames will still be in order,
- * so doing it this way will be faster
+ * so doing it this way will be faster
*/
for (gfs= sel_buffer.last; gfs; gfs= gfs->prev) {
/* if current (gpf) occurs after this one in buffer, add! */
@@ -2804,27 +2808,27 @@ static void posttrans_gpd_clean (bGPdata *gpd)
BLI_addhead(&sel_buffer, gpf);
}
}
-
+
/* error checking: it is unlikely, but may be possible to have none selected */
if (sel_buffer.first == NULL)
continue;
-
+
/* if all were selected (i.e. gpl->frames is empty), then just transfer sel-buf over */
if (gpl->frames.first == NULL) {
gpl->frames.first= sel_buffer.first;
gpl->frames.last= sel_buffer.last;
-
+
continue;
}
-
+
/* loop 2: remove duplicates of frames in buffers */
for (gpf= gpl->frames.first; gpf && sel_buffer.first; gpf= gpfn) {
gpfn= gpf->next;
-
+
/* loop through sel_buffer, emptying stuff from front of buffer if ok */
for (gfs= sel_buffer.first; gfs && gpf; gfs= gfsn) {
gfsn= gfs->next;
-
+
/* if this buffer frame needs to go before current, add it! */
if (gfs->framenum < gpf->framenum) {
/* transfer buffer frame to frames list (before current) */
@@ -2836,18 +2840,18 @@ static void posttrans_gpd_clean (bGPdata *gpd)
/* transfer buffer frame to frames list (before current) */
BLI_remlink(&sel_buffer, gfs);
BLI_insertlinkbefore(&gpl->frames, gpf, gfs);
-
+
/* get rid of current frame */
// TRANSFORM_FIX_ME
//gpencil_layer_delframe(gpl, gpf);
}
}
}
-
+
/* if anything is still in buffer, append to end */
for (gfs= sel_buffer.first; gfs; gfs= gfsn) {
gfsn= gfs->next;
-
+
BLI_remlink(&sel_buffer, gfs);
BLI_addtail(&gpl->frames, gfs);
}
@@ -2862,36 +2866,36 @@ static void posttrans_fcurve_clean (FCurve *fcu)
{
float *selcache; /* cache for frame numbers of selected frames (icu->totvert*sizeof(float)) */
int len, index, i; /* number of frames in cache, item index */
-
+
/* allocate memory for the cache */
// TODO: investigate using GHash for this instead?
- if (fcu->totvert == 0)
+ if (fcu->totvert == 0)
return;
selcache= MEM_callocN(sizeof(float)*fcu->totvert, "FCurveSelFrameNums");
len= 0;
index= 0;
-
- /* We do 2 loops, 1 for marking keyframes for deletion, one for deleting
- * as there is no guarantee what order the keyframes are exactly, even though
+
+ /* We do 2 loops, 1 for marking keyframes for deletion, one for deleting
+ * as there is no guarantee what order the keyframes are exactly, even though
* they have been sorted by time.
*/
-
+
/* Loop 1: find selected keyframes */
for (i = 0; i < fcu->totvert; i++) {
BezTriple *bezt= &fcu->bezt[i];
-
+
if (BEZSELECTED(bezt)) {
selcache[index]= bezt->vec[1][0];
index++;
len++;
}
}
-
+
/* Loop 2: delete unselected keyframes on the same frames (if any keyframes were found) */
if (len) {
for (i = 0; i < fcu->totvert; i++) {
BezTriple *bezt= &fcu->bezt[i];
-
+
if (BEZSELECTED(bezt) == 0) {
/* check beztriple should be removed according to cache */
for (index= 0; index < len; index++) {
@@ -2904,10 +2908,10 @@ static void posttrans_fcurve_clean (FCurve *fcu)
}
}
}
-
+
testhandles_fcurve(fcu);
}
-
+
/* free cache */
MEM_freeN(selcache);
}
@@ -2916,33 +2920,33 @@ static void posttrans_fcurve_clean (FCurve *fcu)
/* Called by special_aftertrans_update to make sure selected keyframes replace
* any other keyframes which may reside on that frame (that is not selected).
- * remake_action_ipos should have already been called
+ * remake_action_ipos should have already been called
*/
static void posttrans_action_clean (bAnimContext *ac, bAction *act)
{
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
/* filter data */
filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVESONLY);
ANIM_animdata_filter(ac, &anim_data, filter, act, ANIMCONT_ACTION);
-
- /* loop through relevant data, removing keyframes from the ipo-blocks that were attached
- * - all keyframes are converted in/out of global time
+
+ /* loop through relevant data, removing keyframes from the ipo-blocks that were attached
+ * - all keyframes are converted in/out of global time
*/
for (ale= anim_data.first; ale; ale= ale->next) {
AnimData *adt= ANIM_nla_mapping_get(ac, ale);
-
+
if (adt) {
- ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1);
+ ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1);
posttrans_fcurve_clean(ale->key_data);
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1);
}
- else
+ else
posttrans_fcurve_clean(ale->key_data);
}
-
+
/* free temp data */
BLI_freelistN(&anim_data);
}
@@ -2954,23 +2958,23 @@ static int count_fcurve_keys(FCurve *fcu, char side, float cfra)
{
BezTriple *bezt;
int i, count = 0;
-
+
if (ELEM(NULL, fcu, fcu->bezt))
return count;
-
+
/* only include points that occur on the right side of cfra */
for (i=0, bezt=fcu->bezt; i < fcu->totvert; i++, bezt++) {
if (bezt->f2 & SELECT) {
/* fully select the other two keys */
bezt->f1 |= SELECT;
bezt->f3 |= SELECT;
-
+
/* increment by 3, as there are 3 points (3 * x-coordinates) that need transform */
if (FrameOnMouseSide(side, bezt->vec[1][0], cfra))
count += 3;
}
}
-
+
return count;
}
@@ -2980,10 +2984,10 @@ static int count_gplayer_frames(bGPDlayer *gpl, char side, float cfra)
{
bGPDframe *gpf;
int count = 0;
-
+
if (gpl == NULL)
return count;
-
+
/* only include points that occur on the right side of cfra */
for (gpf= gpl->frames.first; gpf; gpf= gpf->next) {
if (gpf->flag & GP_FRAME_SELECT) {
@@ -2991,7 +2995,7 @@ static int count_gplayer_frames(bGPDlayer *gpl, char side, float cfra)
count++;
}
}
-
+
return count;
}
#endif
@@ -3002,9 +3006,9 @@ static void TimeToTransData(TransData *td, float *time, AnimData *adt)
/* memory is calloc'ed, so that should zero everything nicely for us */
td->val = time;
td->ival = *(time);
-
- /* store the AnimData where this keyframe exists as a keyframe of the
- * active action as td->extra.
+
+ /* store the AnimData where this keyframe exists as a keyframe of the
+ * active action as td->extra.
*/
td->extra= adt;
}
@@ -3014,16 +3018,16 @@ static void TimeToTransData(TransData *td, float *time, AnimData *adt)
* overwrite the existing ones... i.e. td = IcuToTransData(td, icu, ob, side, cfra);
*
* The 'side' argument is needed for the extend mode. 'B' = both sides, 'R'/'L' mean only data
- * on the named side are used.
+ * on the named side are used.
*/
static TransData *FCurveToTransData(TransData *td, FCurve *fcu, AnimData *adt, char side, float cfra)
{
BezTriple *bezt;
int i;
-
+
if (fcu == NULL)
return td;
-
+
for (i=0, bezt=fcu->bezt; i < fcu->totvert; i++, bezt++) {
/* only add selected keyframes (for now, proportional edit is not enabled) */
if (BEZSELECTED(bezt)) {
@@ -3032,16 +3036,16 @@ static TransData *FCurveToTransData(TransData *td, FCurve *fcu, AnimData *adt, c
/* each control point needs to be added separetely */
TimeToTransData(td, bezt->vec[0], adt);
td++;
-
+
TimeToTransData(td, bezt->vec[1], adt);
td++;
-
+
TimeToTransData(td, bezt->vec[2], adt);
td++;
}
- }
+ }
}
-
+
return td;
}
@@ -3056,17 +3060,17 @@ void flushTransGPactionData (TransInfo *t)
{
tGPFtransdata *tfd;
int i;
-
+
/* find the first one to start from */
if (t->mode == TFM_TIME_SLIDE)
tfd= (tGPFtransdata *)( (float *)(t->customData) + 2 );
else
tfd= (tGPFtransdata *)(t->customData);
-
+
/* flush data! */
for (i = 0; i < t->total; i++, tfd++) {
*(tfd->sdata)= (int)floor(tfd->val + 0.5);
- }
+ }
}
/* This function advances the address to which td points to, so it must return
@@ -3074,14 +3078,14 @@ void flushTransGPactionData (TransInfo *t)
* overwrite the existing ones... i.e. td = GPLayerToTransData(td, ipo, ob, side, cfra);
*
* The 'side' argument is needed for the extend mode. 'B' = both sides, 'R'/'L' mean only data
- * on the named side are used.
+ * on the named side are used.
*/
#if 0
static int GPLayerToTransData (TransData *td, tGPFtransdata *tfd, bGPDlayer *gpl, char side, float cfra)
{
bGPDframe *gpf;
int count= 0;
-
+
/* check for select frames on right side of current frame */
for (gpf= gpl->frames.first; gpf; gpf= gpf->next) {
if (gpf->flag & GP_FRAME_SELECT) {
@@ -3089,10 +3093,10 @@ static int GPLayerToTransData (TransData *td, tGPFtransdata *tfd, bGPDlayer *gpl
/* memory is calloc'ed, so that should zero everything nicely for us */
td->val= &tfd->val;
td->ival= (float)gpf->framenum;
-
+
tfd->val= (float)gpf->framenum;
tfd->sdata= &gpf->framenum;
-
+
/* advance td now */
td++;
tfd++;
@@ -3100,7 +3104,7 @@ static int GPLayerToTransData (TransData *td, tGPFtransdata *tfd, bGPDlayer *gpl
}
}
}
-
+
return count;
}
#endif
@@ -3110,32 +3114,32 @@ static void createTransActionData(bContext *C, TransInfo *t)
Scene *scene= CTX_data_scene(C);
TransData *td = NULL;
tGPFtransdata *tfd = NULL;
-
+
bAnimContext ac;
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
int count=0;
float cfra;
char side;
-
+
/* determine what type of data we are operating on */
if (ANIM_animdata_get_context(C, &ac) == 0)
return;
-
+
/* filter data */
if (ac.datatype == ANIMCONT_GPENCIL)
filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT);
else
filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVESONLY);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
-
+
/* which side of the current frame should be allowed */
if (t->mode == TFM_TIME_EXTEND) {
/* only side on which mouse is gets transformed */
float xmouse, ymouse;
-
+
UI_view2d_region_to_view(&ac.ar->v2d, t->imval[0], t->imval[1], &xmouse, &ymouse);
side = (xmouse > CFRA) ? 'R' : 'L'; // XXX use t->frame_side
}
@@ -3143,38 +3147,38 @@ static void createTransActionData(bContext *C, TransInfo *t)
/* normal transform - both sides of current frame are considered */
side = 'B';
}
-
+
/* loop 1: fully select ipo-keys and count how many BezTriples are selected */
for (ale= anim_data.first; ale; ale= ale->next) {
AnimData *adt= ANIM_nla_mapping_get(&ac, ale);
-
+
/* convert current-frame to action-time (slightly less accurate, espcially under
- * higher scaling ratios, but is faster than converting all points)
+ * higher scaling ratios, but is faster than converting all points)
*/
- if (adt)
+ if (adt)
cfra = BKE_nla_tweakedit_remap(adt, (float)CFRA, NLATIME_CONVERT_UNMAP);
else
cfra = (float)CFRA;
-
+
//if (ale->type == ANIMTYPE_GPLAYER)
// count += count_gplayer_frames(ale->data, side, cfra);
//else
count += count_fcurve_keys(ale->key_data, side, cfra);
}
-
+
/* stop if trying to build list if nothing selected */
if (count == 0) {
/* cleanup temp list */
BLI_freelistN(&anim_data);
return;
}
-
+
/* allocate memory for data */
t->total= count;
-
+
t->data= MEM_callocN(t->total*sizeof(TransData), "TransData(Action Editor)");
td= t->data;
-
+
if (ac.datatype == ANIMCONT_GPENCIL) {
if (t->mode == TFM_TIME_SLIDE) {
t->customData= MEM_callocN((sizeof(float)*2)+(sizeof(tGPFtransdata)*count), "TimeSlide + tGPFtransdata");
@@ -3187,13 +3191,13 @@ static void createTransActionData(bContext *C, TransInfo *t)
}
else if (t->mode == TFM_TIME_SLIDE)
t->customData= MEM_callocN(sizeof(float)*2, "TimeSlide Min/Max");
-
+
/* loop 2: build transdata array */
for (ale= anim_data.first; ale; ale= ale->next) {
//if (ale->type == ANIMTYPE_GPLAYER) {
// bGPDlayer *gpl= (bGPDlayer *)ale->data;
// int i;
- //
+ //
// i = GPLayerToTransData(td, tfd, gpl, side, cfra);
// td += i;
// tfd += i;
@@ -3201,38 +3205,38 @@ static void createTransActionData(bContext *C, TransInfo *t)
//else {
AnimData *adt= ANIM_nla_mapping_get(&ac, ale);
FCurve *fcu= (FCurve *)ale->key_data;
-
+
/* convert current-frame to action-time (slightly less accurate, espcially under
- * higher scaling ratios, but is faster than converting all points)
+ * higher scaling ratios, but is faster than converting all points)
*/
- if (adt)
+ if (adt)
cfra = BKE_nla_tweakedit_remap(adt, (float)CFRA, NLATIME_CONVERT_UNMAP);
else
cfra = (float)CFRA;
-
+
td= FCurveToTransData(td, fcu, adt, side, cfra);
//}
}
-
+
/* check if we're supposed to be setting minx/maxx for TimeSlide */
if (t->mode == TFM_TIME_SLIDE) {
float min=999999999.0f, max=-999999999.0f;
int i;
-
+
td= (t->data + 1);
for (i=1; i < count; i+=3, td+=3) {
if (min > *(td->val)) min= *(td->val);
if (max < *(td->val)) max= *(td->val);
}
-
- /* minx/maxx values used by TimeSlide are stored as a
+
+ /* minx/maxx values used by TimeSlide are stored as a
* calloced 2-float array in t->customData. This gets freed
- * in postTrans (T_FREE_CUSTOMDATA).
+ * in postTrans (T_FREE_CUSTOMDATA).
*/
*((float *)(t->customData)) = min;
*((float *)(t->customData) + 1) = max;
}
-
+
/* cleanup temp list */
BLI_freelistN(&anim_data);
}
@@ -3250,18 +3254,18 @@ static void bezt_to_transdata (TransData *td, TransData2D *td2d, AnimData *adt,
* Due to NLA mapping, we apply NLA mapping to some of the verts here,
* and then that mapping will be undone after transform is done.
*/
-
+
if (adt) {
td2d->loc[0] = BKE_nla_tweakedit_remap(adt, loc[0], NLATIME_CONVERT_UNMAP);
td2d->loc[1] = loc[1];
td2d->loc[2] = 0.0f;
td2d->loc2d = loc;
-
+
td->loc = td2d->loc;
td->center[0] = BKE_nla_tweakedit_remap(adt, cent[0], NLATIME_CONVERT_UNMAP);
td->center[1] = cent[1];
td->center[2] = 0.0f;
-
+
VECCOPY(td->iloc, td->loc);
}
else {
@@ -3269,7 +3273,7 @@ static void bezt_to_transdata (TransData *td, TransData2D *td2d, AnimData *adt,
td2d->loc[1] = loc[1];
td2d->loc[2] = 0.0f;
td2d->loc2d = loc;
-
+
td->loc = td2d->loc;
VECCOPY(td->center, cent);
VECCOPY(td->iloc, td->loc);
@@ -3279,7 +3283,7 @@ static void bezt_to_transdata (TransData *td, TransData2D *td2d, AnimData *adt,
td->axismtx[2][2] = 1.0f;
td->ext= NULL; td->tdi= NULL; td->val= NULL;
-
+
/* store AnimData info in td->extra, for applying mapping when flushing */
td->extra= adt;
@@ -3289,49 +3293,49 @@ static void bezt_to_transdata (TransData *td, TransData2D *td2d, AnimData *adt,
}
else
td->dist= MAXFLOAT;
-
- if (ishandle)
+
+ if (ishandle)
td->flag |= TD_NOTIMESNAP;
if (intvals)
td->flag |= TD_INTVALUES;
-
+
Mat3One(td->mtx);
Mat3One(td->smtx);
-}
+}
static void createTransGraphEditData(bContext *C, TransInfo *t)
{
Scene *scene= CTX_data_scene(C);
ARegion *ar= CTX_wm_region(C);
View2D *v2d= &ar->v2d;
-
+
TransData *td = NULL;
TransData2D *td2d = NULL;
-
+
bAnimContext ac;
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
-
+
BezTriple *bezt, *prevbezt;
int count=0, i;
float cfra;
char side;
-
+
/* determine what type of data we are operating on */
if (ANIM_animdata_get_context(C, &ac) == 0)
return;
-
+
/* filter data */
filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVESONLY | ANIMFILTER_CURVEVISIBLE);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
-
+
/* which side of the current frame should be allowed */
// XXX we still want this mode, but how to get this using standard transform too?
if (t->mode == TFM_TIME_EXTEND) {
/* only side on which mouse is gets transformed */
float xmouse, ymouse;
-
+
UI_view2d_region_to_view(&ac.ar->v2d, t->imval[0], t->imval[1], &xmouse, &ymouse);
side = (xmouse > CFRA) ? 'R' : 'L'; // XXX use t->frame_side
}
@@ -3339,20 +3343,20 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
/* normal transform - both sides of current frame are considered */
side = 'B';
}
-
+
/* loop 1: count how many BezTriples (specifically their verts) are selected (or should be edited) */
for (ale= anim_data.first; ale; ale= ale->next) {
AnimData *adt= ANIM_nla_mapping_get(&ac, ale);
FCurve *fcu= (FCurve *)ale->key_data;
-
+
/* convert current-frame to action-time (slightly less accurate, espcially under
- * higher scaling ratios, but is faster than converting all points)
+ * higher scaling ratios, but is faster than converting all points)
*/
- if (adt)
+ if (adt)
cfra = BKE_nla_tweakedit_remap(adt, (float)CFRA, NLATIME_CONVERT_UNMAP);
else
cfra = (float)CFRA;
-
+
/* only include BezTriples whose 'keyframe' occurs on the same side of the current frame as mouse */
if (fcu->bezt) {
for (i=0, bezt=fcu->bezt; i < fcu->totvert; i++, bezt++) {
@@ -3380,47 +3384,47 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
}
}
}
-
+
/* stop if trying to build list if nothing selected */
if (count == 0) {
/* cleanup temp list */
BLI_freelistN(&anim_data);
return;
}
-
+
/* allocate memory for data */
t->total= count;
-
+
t->data= MEM_callocN(t->total*sizeof(TransData), "TransData (Graph Editor)");
/* for each 2d vert a 3d vector is allocated, so that they can be treated just as if they were 3d verts */
t->data2d= MEM_callocN(t->total*sizeof(TransData2D), "TransData2D (Graph Editor)");
-
+
td= t->data;
td2d= t->data2d;
-
+
/* loop 2: build transdata arrays */
for (ale= anim_data.first; ale; ale= ale->next) {
AnimData *adt= ANIM_nla_mapping_get(&ac, ale);
FCurve *fcu= (FCurve *)ale->key_data;
short intvals= (fcu->flag & FCURVE_INT_VALUES);
-
+
/* convert current-frame to action-time (slightly less accurate, espcially under
- * higher scaling ratios, but is faster than converting all points)
+ * higher scaling ratios, but is faster than converting all points)
*/
- if (adt)
+ if (adt)
cfra = BKE_nla_tweakedit_remap(adt, (float)CFRA, NLATIME_CONVERT_UNMAP);
else
cfra = (float)CFRA;
-
+
/* only include BezTriples whose 'keyframe' occurs on the same side of the current frame as mouse (if applicable) */
bezt= fcu->bezt;
prevbezt= NULL;
-
+
for (i=0; i < fcu->totvert; i++, prevbezt=bezt, bezt++) {
if (FrameOnMouseSide(side, bezt->vec[1][0], cfra)) {
TransDataCurveHandleFlags *hdata = NULL;
short h1=1, h2=1;
-
+
/* only include handles if selected, and interpolaton mode uses beztriples */
if ( (!prevbezt && (bezt->ipo==BEZT_IPO_BEZ)) || (prevbezt && (prevbezt->ipo==BEZT_IPO_BEZ)) ) {
if (bezt->f1 & SELECT) {
@@ -3439,7 +3443,7 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
else
h2= 0;
}
-
+
/* only include main vert if selected */
if (bezt->f2 & SELECT) {
/* if scaling around individuals centers, do no include keyframes */
@@ -3449,13 +3453,13 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
if (hdata == NULL)
hdata = initTransDataCurveHandes(td, bezt);
}
-
+
bezt_to_transdata(td++, td2d++, adt, bezt->vec[1], bezt->vec[1], 1, 0, intvals);
}
-
- /* special hack (must be done after initTransDataCurveHandes(), as that stores handle settings to restore...):
- * - Check if we've got entire BezTriple selected and we're scaling/rotating that point,
- * then check if we're using auto-handles.
+
+ /* special hack (must be done after initTransDataCurveHandes(), as that stores handle settings to restore...):
+ * - Check if we've got entire BezTriple selected and we're scaling/rotating that point,
+ * then check if we're using auto-handles.
* - If so, change them auto-handles to aligned handles so that handles get affected too
*/
if ((bezt->h1 == HD_AUTO) && (bezt->h2 == HD_AUTO) && ELEM(t->mode, TFM_ROTATION, TFM_RESIZE)) {
@@ -3467,11 +3471,11 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
}
}
}
-
+
/* Sets handles based on the selection */
- testhandles_fcurve(fcu);
+ testhandles_fcurve(fcu);
}
-
+
/* cleanup temp list */
BLI_freelistN(&anim_data);
}
@@ -3498,23 +3502,23 @@ static BeztMap *bezt_to_beztmaps (BezTriple *bezts, int totvert)
BezTriple *prevbezt= NULL;
BeztMap *bezm, *bezms;
int i;
-
+
/* allocate memory for this array */
if (totvert==0 || bezts==NULL)
return NULL;
bezm= bezms= MEM_callocN(sizeof(BeztMap)*totvert, "BeztMaps");
-
+
/* assign beztriples to beztmaps */
for (i=0; i < totvert; i++, bezm++, prevbezt=bezt, bezt++) {
bezm->bezt= bezt;
-
+
bezm->oldIndex= i;
bezm->newIndex= i;
-
+
bezm->pipo= (prevbezt) ? prevbezt->ipo : bezt->ipo;
bezm->cipo= bezt->ipo;
}
-
+
return bezms;
}
@@ -3523,11 +3527,11 @@ static void sort_time_beztmaps (BeztMap *bezms, int totvert)
{
BeztMap *bezm;
int i, ok= 1;
-
+
/* keep repeating the process until nothing is out of place anymore */
while (ok) {
ok= 0;
-
+
bezm= bezms;
i= totvert;
while (i--) {
@@ -3536,18 +3540,18 @@ static void sort_time_beztmaps (BeztMap *bezms, int totvert)
if (bezm->bezt->vec[1][0] > (bezm+1)->bezt->vec[1][0]) {
bezm->newIndex++;
(bezm+1)->newIndex--;
-
+
SWAP(BeztMap, *bezm, *(bezm+1));
-
+
ok= 1;
}
}
-
+
/* do we need to check if the handles need to be swapped?
* optimisation: this only needs to be performed in the first loop
*/
if (bezm->swapHs == 0) {
- if ( (bezm->bezt->vec[0][0] > bezm->bezt->vec[1][0]) &&
+ if ( (bezm->bezt->vec[0][0] > bezm->bezt->vec[1][0]) &&
(bezm->bezt->vec[2][0] < bezm->bezt->vec[1][0]) )
{
/* handles need to be swapped */
@@ -3558,9 +3562,9 @@ static void sort_time_beztmaps (BeztMap *bezms, int totvert)
bezm->swapHs = -1;
}
}
-
+
bezm++;
- }
+ }
}
}
@@ -3572,24 +3576,24 @@ static void beztmap_to_data (TransInfo *t, FCurve *fcu, BeztMap *bezms, int totv
TransData2D *td;
int i, j;
char *adjusted;
-
- /* dynamically allocate an array of chars to mark whether an TransData's
+
+ /* dynamically allocate an array of chars to mark whether an TransData's
* pointers have been fixed already, so that we don't override ones that are
* already done
*/
adjusted= MEM_callocN(t->total, "beztmap_adjusted_map");
-
+
/* for each beztmap item, find if it is used anywhere */
bezm= bezms;
for (i= 0; i < totvert; i++, bezm++) {
- /* loop through transdata, testing if we have a hit
+ /* loop through transdata, testing if we have a hit
* for the handles (vec[0]/vec[2]), we must also check if they need to be swapped...
*/
td= t->data2d;
for (j= 0; j < t->total; j++, td++) {
/* skip item if already marked */
if (adjusted[j] != 0) continue;
-
+
/* only selected verts */
if (bezm->pipo == BEZT_IPO_BEZ) {
if (bezm->bezt->f1 & SELECT) {
@@ -3620,42 +3624,42 @@ static void beztmap_to_data (TransInfo *t, FCurve *fcu, BeztMap *bezms, int totv
}
}
}
-
+
}
-
+
/* free temp memory used for 'adjusted' array */
MEM_freeN(adjusted);
}
-/* This function is called by recalcData during the Transform loop to recalculate
+/* This function is called by recalcData during the Transform loop to recalculate
* the handles of curves and sort the keyframes so that the curves draw correctly.
* It is only called if some keyframes have moved out of order.
*
- * anim_data is the list of channels (F-Curves) retrieved already containing the
+ * anim_data is the list of channels (F-Curves) retrieved already containing the
* channels to work on. It should not be freed here as it may still need to be used.
*/
void remake_graph_transdata (TransInfo *t, ListBase *anim_data)
{
bAnimListElem *ale;
-
+
/* sort and reassign verts */
for (ale= anim_data->first; ale; ale= ale->next) {
FCurve *fcu= (FCurve *)ale->key_data;
-
+
if (fcu->bezt) {
BeztMap *bezm;
-
+
/* adjust transform-data pointers */
bezm= bezt_to_beztmaps(fcu->bezt, fcu->totvert);
sort_time_beztmaps(bezm, fcu->totvert);
beztmap_to_data(t, fcu, bezm, fcu->totvert);
-
+
/* free mapping stuff */
MEM_freeN(bezm);
-
+
/* re-sort actual beztriples (perhaps this could be done using the beztmaps to save time?) */
sort_time_fcurve(fcu);
-
+
/* make sure handles are all set correctly */
testhandles_fcurve(fcu);
}
@@ -3663,7 +3667,7 @@ void remake_graph_transdata (TransInfo *t, ListBase *anim_data)
}
/* this function is called on recalcData to apply the transforms applied
- * to the transdata on to the actual keyframe data
+ * to the transdata on to the actual keyframe data
*/
void flushTransGraphData(TransInfo *t)
{
@@ -3673,13 +3677,13 @@ void flushTransGraphData(TransInfo *t)
Scene *scene= t->scene;
double secf= FPS;
int a;
-
+
/* flush to 2d vector from internally used 3d vector */
for (a=0, td= t->data, td2d=t->data2d; a<t->total; a++, td++, td2d++) {
AnimData *adt= (AnimData *)td->extra; /* pointers to relevant AnimData blocks are stored in the td->extra pointers */
-
- /* handle snapping for time values
- * - we should still be in NLA-mapping timespace
+
+ /* handle snapping for time values
+ * - we should still be in NLA-mapping timespace
* - only apply to keyframes (but never to handles)
*/
if ((td->flag & TD_NOTIMESNAP)==0) {
@@ -3690,19 +3694,19 @@ void flushTransGraphData(TransInfo *t)
else
td2d->loc[0]= (float)( floor(td2d->loc[0]+0.5f) );
break;
-
+
case SACTSNAP_MARKER: /* snap to nearest marker */
td2d->loc[0]= (float)ED_markers_find_nearest_marker_time(&t->scene->markers, td2d->loc[0]);
break;
}
}
-
+
/* we need to unapply the nla-scaling from the time in some situations */
if (adt)
td2d->loc2d[0]= BKE_nla_tweakedit_remap(adt, td2d->loc[0], NLATIME_CONVERT_UNMAP);
else
td2d->loc2d[0]= td2d->loc[0];
-
+
/* if int-values only, truncate to integers */
if (td->flag & TD_INTVALUES)
td2d->loc2d[1]= (float)((int)td2d->loc[1]);
@@ -3739,13 +3743,13 @@ static void ipokey_to_transdata(IpoKey *ik, TransData *td)
TransDataIpokey *tdi= td->tdi;
BezTriple *bezt;
int a, delta= 0;
-
+
td->val= NULL; // is read on ESC
-
+
for(a=0; a<OB_TOTIPO; a++) {
if(ik->data[a]) {
bezt= ik->data[a];
-
+
switch( ob_ar[a] ) {
case OB_LOC_X:
case OB_DLOC_X:
@@ -3756,7 +3760,7 @@ static void ipokey_to_transdata(IpoKey *ik, TransData *td)
case OB_LOC_Z:
case OB_DLOC_Z:
tdi->locz= &(bezt->vec[1][1]); break;
-
+
case OB_DROT_X:
delta= 1;
case OB_ROT_X:
@@ -3769,7 +3773,7 @@ static void ipokey_to_transdata(IpoKey *ik, TransData *td)
delta= 1;
case OB_ROT_Z:
tdi->rotz= &(bezt->vec[1][1]); break;
-
+
case OB_SIZE_X:
case OB_DSIZE_X:
tdi->sizex= &(bezt->vec[1][1]); break;
@@ -3778,26 +3782,26 @@ static void ipokey_to_transdata(IpoKey *ik, TransData *td)
tdi->sizey= &(bezt->vec[1][1]); break;
case OB_SIZE_Z:
case OB_DSIZE_Z:
- tdi->sizez= &(bezt->vec[1][1]); break;
- }
+ tdi->sizez= &(bezt->vec[1][1]); break;
+ }
}
}
-
+
/* oldvals for e.g. undo */
if(tdi->locx) set_tdi_old(tdi->oldloc, tdi->locx);
if(tdi->locy) set_tdi_old(tdi->oldloc+1, tdi->locy);
if(tdi->locz) set_tdi_old(tdi->oldloc+2, tdi->locz);
-
+
/* remember, for mapping curves ('1'=10 degrees) */
if(tdi->rotx) set_tdi_old(tdi->oldrot, tdi->rotx);
if(tdi->roty) set_tdi_old(tdi->oldrot+1, tdi->roty);
if(tdi->rotz) set_tdi_old(tdi->oldrot+2, tdi->rotz);
-
+
/* this is not allowed to be dsize! */
if(tdi->sizex) set_tdi_old(tdi->oldsize, tdi->sizex);
if(tdi->sizey) set_tdi_old(tdi->oldsize+1, tdi->sizey);
if(tdi->sizez) set_tdi_old(tdi->oldsize+2, tdi->sizez);
-
+
tdi->flag= TOB_IPO;
if(delta) tdi->flag |= TOB_IPODROT;
}
@@ -3814,8 +3818,8 @@ static void ipokey_to_transdata(IpoKey *ik, TransData *td)
static short constraints_list_needinv(TransInfo *t, ListBase *list)
{
bConstraint *con;
-
- /* loop through constraints, checking if there's one of the mentioned
+
+ /* loop through constraints, checking if there's one of the mentioned
* constraints needing special crazyspace corrections
*/
if (list) {
@@ -3827,19 +3831,19 @@ static short constraints_list_needinv(TransInfo *t, ListBase *list)
if (con->type == CONSTRAINT_TYPE_CHILDOF) return 1;
if (con->type == CONSTRAINT_TYPE_FOLLOWPATH) return 1;
if (con->type == CONSTRAINT_TYPE_CLAMPTO) return 1;
-
+
/* constraints that require this only under special conditions */
if (con->type == CONSTRAINT_TYPE_ROTLIKE) {
/* CopyRot constraint only does this when rotating, and offset is on */
bRotateLikeConstraint *data = (bRotateLikeConstraint *)con->data;
-
+
if ((data->flag & ROTLIKE_OFFSET) && (t->mode == TFM_ROTATION))
return 1;
}
}
}
}
-
+
/* no appropriate candidates found */
return 0;
}
@@ -3871,13 +3875,13 @@ static void SeqTransInfo(TransInfo *t, Sequence *seq, int *recursive, int *count
*flag= 0;
}
else if (seq->type ==SEQ_META) {
-
+
/* for meta's we only ever need to extend their children, no matter what depth
* just check the meta's are in the bounds */
if (t->frame_side=='R' && right <= cfra) *recursive= 0;
else if (t->frame_side=='L' && left >= cfra) *recursive= 0;
else *recursive= 1;
-
+
*count= 0;
*flag= 0;
}
@@ -4001,15 +4005,15 @@ static TransData *SeqToTransData(TransInfo *t, TransData *td, TransData2D *td2d,
td2d->loc[2] = 0.0f;
td2d->loc2d = NULL;
-
+
tdsq->seq= seq;
/* Use instead of seq->flag for nested strips and other
* cases where the selection may need to be modified */
tdsq->flag= flag;
tdsq->sel_flag= sel_flag;
-
-
+
+
td->extra= (void *)tdsq; /* allow us to update the strip from here */
td->flag = 0;
@@ -4031,7 +4035,7 @@ static TransData *SeqToTransData(TransInfo *t, TransData *td, TransData2D *td2d,
/* Time Transform (extend) */
td->val= td2d->loc;
td->ival= td2d->loc[0];
-
+
return td;
}
@@ -4040,15 +4044,15 @@ static int SeqToTransData_Recursive(TransInfo *t, ListBase *seqbase, TransData *
Sequence *seq;
int recursive, count, flag;
int tot= 0;
-
+
for (seq= seqbase->first; seq; seq= seq->next) {
SeqTransInfo(t, seq, &recursive, &count, &flag);
-
+
/* add children first so recalculating metastrips does nested strips first */
if (recursive) {
int tot_children= SeqToTransData_Recursive(t, &seq->seqbase, td, td2d, tdsq);
-
+
td= td + tot_children;
td2d= td2d + tot_children;
tdsq= tdsq + tot_children;
@@ -4081,7 +4085,7 @@ static int SeqToTransData_Recursive(TransInfo *t, ListBase *seqbase, TransData *
static void createTransSeqData(bContext *C, TransInfo *t)
{
-
+
View2D *v2d= UI_view2d_fromcontext(C);
Scene *scene= CTX_data_scene(C);
Editing *ed= seq_give_editing(t->scene, FALSE);
@@ -4119,12 +4123,12 @@ static void createTransSeqData(bContext *C, TransInfo *t)
if (count == 0) {
return;
}
-
+
td = t->data = MEM_callocN(t->total*sizeof(TransData), "TransSeq TransData");
td2d = t->data2d = MEM_callocN(t->total*sizeof(TransData2D), "TransSeq TransData2D");
tdsq = t->customData= MEM_callocN(t->total*sizeof(TransDataSeq), "TransSeq TransDataSeq");
-
+
/* loop 2: build transdata array */
SeqToTransData_Recursive(t, ed->seqbasep, td, td2d, tdsq);
@@ -4132,7 +4136,7 @@ static void createTransSeqData(bContext *C, TransInfo *t)
/* transcribe given object into TransData for Transforming */
-static void ObjectToTransData(bContext *C, TransInfo *t, TransData *td, Object *ob)
+static void ObjectToTransData(bContext *C, TransInfo *t, TransData *td, Object *ob)
{
Scene *scene = CTX_data_scene(C);
Object *track;
@@ -4146,35 +4150,35 @@ static void ObjectToTransData(bContext *C, TransInfo *t, TransData *td, Object *
Mat3Ortho(td->axismtx);
td->con= ob->constraints.first;
-
- /* hack: tempolarily disable tracking and/or constraints when getting
+
+ /* hack: tempolarily disable tracking and/or constraints when getting
* object matrix, if tracking is on, or if constraints don't need
* inverse correction to stop it from screwing up space conversion
* matrix later
*/
constinv = constraints_list_needinv(t, &ob->constraints);
-
+
/* disable constraints inversion for dummy pass */
if (t->mode == TFM_DUMMY)
skip_invert = 1;
-
+
if (skip_invert == 0 && (ob->track || constinv==0)) {
track= ob->track;
ob->track= NULL;
-
+
if (constinv == 0) {
fakecons.first = ob->constraints.first;
fakecons.last = ob->constraints.last;
ob->constraints.first = ob->constraints.last = NULL;
}
-
+
where_is_object(t->scene, ob);
-
+
if (constinv == 0) {
ob->constraints.first = fakecons.first;
ob->constraints.last = fakecons.last;
}
-
+
ob->track= track;
}
else
@@ -4184,23 +4188,23 @@ static void ObjectToTransData(bContext *C, TransInfo *t, TransData *td, Object *
td->loc = ob->loc;
VECCOPY(td->iloc, td->loc);
-
+
td->ext->rot = ob->rot;
VECCOPY(td->ext->irot, ob->rot);
VECCOPY(td->ext->drot, ob->drot);
-
+
td->ext->size = ob->size;
VECCOPY(td->ext->isize, ob->size);
VECCOPY(td->ext->dsize, ob->dsize);
VECCOPY(td->center, ob->obmat[3]);
-
+
Mat4CpyMat4(td->ext->obmat, ob->obmat);
/* is there a need to set the global<->data space conversion matrices? */
if (ob->parent || constinv) {
float totmat[3][3], obinv[3][3];
-
+
/* Get the effect of parenting, and/or certain constraints.
* NOTE: some Constraints, and also Tracking should never get this
* done, as it doesn't work well.
@@ -4216,7 +4220,7 @@ static void ObjectToTransData(bContext *C, TransInfo *t, TransData *td, Object *
Mat3One(td->smtx);
Mat3One(td->mtx);
}
-
+
/* set active flag */
if (ob == OBACT)
{
@@ -4231,39 +4235,39 @@ static void set_trans_object_base_flags(bContext *C, TransInfo *t)
{
Scene *sce = CTX_data_scene(C);
View3D *v3d = t->view;
-
+
/*
if Base selected and has parent selected:
base->flag= BA_WAS_SEL
*/
Base *base;
-
+
/* don't do it if we're not actually going to recalculate anything */
if(t->mode == TFM_DUMMY)
return;
/* makes sure base flags and object flags are identical */
copy_baseflags(t->scene);
-
+
/* handle pending update events, otherwise they got copied below */
for (base= sce->base.first; base; base= base->next) {
- if(base->object->recalc)
+ if(base->object->recalc)
object_handle_update(t->scene, base->object);
}
-
+
for (base= sce->base.first; base; base= base->next) {
base->flag &= ~BA_WAS_SEL;
-
+
if(TESTBASELIB(v3d, base)) {
Object *ob= base->object;
Object *parsel= ob->parent;
-
+
/* if parent selected, deselect */
while(parsel) {
if(parsel->flag & SELECT) break;
parsel= parsel->parent;
}
-
+
if(parsel)
{
if ((t->mode == TFM_ROTATION || t->mode == TFM_TRACKBALL) && t->around == V3D_LOCAL)
@@ -4283,7 +4287,7 @@ static void set_trans_object_base_flags(bContext *C, TransInfo *t)
/* all recalc flags get flushed to all layers, so a layer flip later on works fine */
DAG_scene_flush_update(t->scene, -1, 0);
-
+
/* and we store them temporal in base (only used for transform code) */
/* this because after doing updates, the object->recalc is cleared */
for (base= sce->base.first; base; base= base->next) {
@@ -4298,7 +4302,7 @@ static void clear_trans_object_base_flags(TransInfo *t)
{
Scene *sce = t->scene;
Base *base;
-
+
for (base= sce->base.first; base; base = base->next)
{
if(base->flag & BA_WAS_SEL)
@@ -4313,34 +4317,34 @@ static void clear_trans_object_base_flags(TransInfo *t)
short autokeyframe_cfra_can_key(Scene *scene, Object *ob)
{
float cfra= (float)CFRA; // XXX for now, this will do
-
+
/* only filter if auto-key mode requires this */
if (IS_AUTOKEY_ON(scene) == 0)
return 0;
- else if (IS_AUTOKEY_MODE(scene, NORMAL))
+ else if (IS_AUTOKEY_MODE(scene, NORMAL))
return 1;
- else
+ else
return id_frame_has_keyframe(&ob->id, cfra, ANIMFILTER_KEYS_LOCAL);
}
-/* auto-keyframing feature - for objects
- * tmode: should be a transform mode
+/* auto-keyframing feature - for objects
+ * tmode: should be a transform mode
*/
void autokeyframe_ob_cb_func(Scene *scene, View3D *v3d, Object *ob, int tmode)
{
ID *id= &ob->id;
FCurve *fcu;
-
+
if (autokeyframe_cfra_can_key(scene, ob)) {
AnimData *adt= ob->adt;
float cfra= (float)CFRA; // xxx this will do for now
short flag = 0;
-
+
if (IS_AUTOKEY_FLAG(INSERTNEEDED))
flag |= INSERTKEY_NEEDED;
if (IS_AUTOKEY_FLAG(AUTOMATKEY))
flag |= INSERTKEY_MATRIX;
-
+
if (IS_AUTOKEY_FLAG(INSERTAVAIL)) {
/* only key on available channels */
if (adt && adt->action) {
@@ -4352,7 +4356,7 @@ void autokeyframe_ob_cb_func(Scene *scene, View3D *v3d, Object *ob, int tmode)
}
else if (IS_AUTOKEY_FLAG(INSERTNEEDED)) {
short doLoc=0, doRot=0, doScale=0;
-
+
/* filter the conditions when this happens (assume that curarea->spacetype==SPACE_VIE3D) */
if (tmode == TFM_TRANSLATION) {
doLoc = 1;
@@ -4363,9 +4367,9 @@ void autokeyframe_ob_cb_func(Scene *scene, View3D *v3d, Object *ob, int tmode)
doLoc = 1;
}
else if (v3d->around == V3D_CURSOR)
- doLoc = 1;
-
- if ((v3d->flag & V3D_ALIGN)==0)
+ doLoc = 1;
+
+ if ((v3d->flag & V3D_ALIGN)==0)
doRot = 1;
}
else if (tmode == TFM_RESIZE) {
@@ -4374,12 +4378,12 @@ void autokeyframe_ob_cb_func(Scene *scene, View3D *v3d, Object *ob, int tmode)
doLoc = 1;
}
else if (v3d->around == V3D_CURSOR)
- doLoc = 1;
-
+ doLoc = 1;
+
if ((v3d->flag & V3D_ALIGN)==0)
doScale = 1;
}
-
+
// TODO: the group names here are temporary...
// TODO: should this be made to use the builtin KeyingSets instead?
if (doLoc) {
@@ -4404,22 +4408,22 @@ void autokeyframe_ob_cb_func(Scene *scene, View3D *v3d, Object *ob, int tmode)
insert_keyframe(id, NULL, "Object Transform", "location", 0, cfra, flag);
insert_keyframe(id, NULL, "Object Transform", "location", 1, cfra, flag);
insert_keyframe(id, NULL, "Object Transform", "location", 2, cfra, flag);
-
+
insert_keyframe(id, NULL, "Object Transform", "rotation", 0, cfra, flag);
insert_keyframe(id, NULL, "Object Transform", "rotation", 1, cfra, flag);
insert_keyframe(id, NULL, "Object Transform", "rotation", 2, cfra, flag);
-
+
insert_keyframe(id, NULL, "Object Transform", "scale", 0, cfra, flag);
insert_keyframe(id, NULL, "Object Transform", "scale", 1, cfra, flag);
insert_keyframe(id, NULL, "Object Transform", "scale", 2, cfra, flag);
}
-
+
// XXX todo... find a way to send notifiers from here...
}
}
-/* auto-keyframing feature - for poses/pose-channels
- * tmode: should be a transform mode
+/* auto-keyframing feature - for poses/pose-channels
+ * tmode: should be a transform mode
* targetless_ik: has targetless ik been done on any channels?
*/
void autokeyframe_pose_cb_func(Scene *scene, View3D *v3d, Object *ob, int tmode, short targetless_ik)
@@ -4431,13 +4435,13 @@ void autokeyframe_pose_cb_func(Scene *scene, View3D *v3d, Object *ob, int tmode,
bPose *pose= ob->pose;
bPoseChannel *pchan;
FCurve *fcu;
-
+
if (autokeyframe_cfra_can_key(scene, ob)) {
float cfra= (float)CFRA;
short flag= 0;
char buf[512];
-
- /* flag is initialised from UserPref keyframing settings
+
+ /* flag is initialised from UserPref keyframing settings
* - special exception for targetless IK - INSERTKEY_MATRIX keyframes should get
* visual keyframes even if flag not set, as it's not that useful otherwise
* (for quick animation recording)
@@ -4446,12 +4450,12 @@ void autokeyframe_pose_cb_func(Scene *scene, View3D *v3d, Object *ob, int tmode,
flag |= INSERTKEY_MATRIX;
if (IS_AUTOKEY_FLAG(INSERTNEEDED))
flag |= INSERTKEY_NEEDED;
-
+
for (pchan=pose->chanbase.first; pchan; pchan=pchan->next) {
if (pchan->bone->flag & BONE_TRANSFORM) {
/* clear any 'unkeyed' flag it may have */
pchan->bone->flag &= ~BONE_UNKEYED;
-
+
/* only insert into available channels? */
if (IS_AUTOKEY_FLAG(INSERTAVAIL)) {
if (act) {
@@ -4462,29 +4466,29 @@ void autokeyframe_pose_cb_func(Scene *scene, View3D *v3d, Object *ob, int tmode,
/* only insert keyframe if needed? */
else if (IS_AUTOKEY_FLAG(INSERTNEEDED)) {
short doLoc=0, doRot=0, doScale=0;
-
+
/* filter the conditions when this happens (assume that curarea->spacetype==SPACE_VIE3D) */
if (tmode == TFM_TRANSLATION) {
- if (targetless_ik)
+ if (targetless_ik)
doRot= 1;
- else
+ else
doLoc = 1;
}
else if (tmode == TFM_ROTATION) {
if (ELEM(v3d->around, V3D_CURSOR, V3D_ACTIVE))
doLoc = 1;
-
- if ((v3d->flag & V3D_ALIGN)==0)
+
+ if ((v3d->flag & V3D_ALIGN)==0)
doRot = 1;
}
else if (tmode == TFM_RESIZE) {
if (ELEM(v3d->around, V3D_CURSOR, V3D_ACTIVE))
doLoc = 1;
-
+
if ((v3d->flag & V3D_ALIGN)==0)
doScale = 1;
}
-
+
if (doLoc) {
sprintf(buf, "pose.pose_channels[\"%s\"].location", pchan->name);
insert_keyframe(id, NULL, pchan->name, buf, 0, cfra, flag);
@@ -4519,7 +4523,7 @@ void autokeyframe_pose_cb_func(Scene *scene, View3D *v3d, Object *ob, int tmode,
insert_keyframe(id, NULL, pchan->name, buf, 0, cfra, flag);
insert_keyframe(id, NULL, pchan->name, buf, 1, cfra, flag);
insert_keyframe(id, NULL, pchan->name, buf, 2, cfra, flag);
-
+
if (pchan->rotmode == PCHAN_ROT_QUAT) {
sprintf(buf, "pose.pose_channels[\"%s\"].rotation", pchan->name);
insert_keyframe(id, NULL, pchan->name, buf, 0, cfra, flag);
@@ -4533,7 +4537,7 @@ void autokeyframe_pose_cb_func(Scene *scene, View3D *v3d, Object *ob, int tmode,
insert_keyframe(id, NULL, pchan->name, buf, 1, cfra, flag);
insert_keyframe(id, NULL, pchan->name, buf, 2, cfra, flag);
}
-
+
sprintf(buf, "pose.pose_channels[\"%s\"].scale", pchan->name);
insert_keyframe(id, NULL, pchan->name, buf, 0, cfra, flag);
insert_keyframe(id, NULL, pchan->name, buf, 1, cfra, flag);
@@ -4541,15 +4545,15 @@ void autokeyframe_pose_cb_func(Scene *scene, View3D *v3d, Object *ob, int tmode,
}
}
}
-
+
// XXX todo... figure out way to get appropriate notifiers sent
-
+
/* do the bone paths */
#if 0 // TRANSFORM_FIX_ME
if (arm->pathflag & ARM_PATH_ACFRA) {
pose_clear_paths(ob);
pose_recalculate_paths(ob);
- }
+ }
#endif
}
else {
@@ -4573,7 +4577,7 @@ void special_aftertrans_update(TransInfo *t)
// short redrawipo=0, resetslowpar=1;
int cancelled= (t->state == TRANS_CANCEL);
short duplicate= (t->undostr && strstr(t->undostr, "Duplicate")) ? 1 : 0;
-
+
if (t->spacetype==SPACE_VIEW3D) {
if (t->obedit) {
if (cancelled==0) {
@@ -4596,7 +4600,7 @@ void special_aftertrans_update(TransInfo *t)
#if 0 // TRANSFORM_FIX_ME, Would prefer to use this since the array takes into
// account what where transforming (with extend, locked strips etc)
// But at the moment t->data is freed in postTrans so for now re-shuffeling selected strips works ok. - Campbell
-
+
int a;
TransData *td= t->data;
@@ -4621,7 +4625,7 @@ void special_aftertrans_update(TransInfo *t)
for(seq= seqbasep->first; seq; seq= seq->next) {
max_machine = MAX2(max_machine, seq->machine);
}
-
+
for (machine = 0; machine <= max_machine; machine++)
{
for(seq= seqbasep->first; seq; seq= seq->next) {
@@ -4631,7 +4635,7 @@ void special_aftertrans_update(TransInfo *t)
}
}
#endif
-
+
for(seq= seqbasep->first; seq; seq= seq->next) {
/* We might want to build a list of effects that need to be updated during transform */
if(seq->type & SEQ_EFFECT) {
@@ -4643,7 +4647,7 @@ void special_aftertrans_update(TransInfo *t)
sort_seq(t->scene);
}
-
+
if (t->customData)
MEM_freeN(t->customData);
if (t->data)
@@ -4653,39 +4657,39 @@ void special_aftertrans_update(TransInfo *t)
SpaceAction *saction= (SpaceAction *)t->sa->spacedata.first;
Scene *scene;
bAnimContext ac;
-
+
/* initialise relevant anim-context 'context' data from TransInfo data */
/* NOTE: sync this with the code in ANIM_animdata_get_context() */
memset(&ac, 0, sizeof(bAnimContext));
-
+
scene= ac.scene= t->scene;
ob= ac.obact= OBACT;
ac.sa= t->sa;
ac.ar= t->ar;
ac.spacetype= (t->sa)? t->sa->spacetype : 0;
ac.regiontype= (t->ar)? t->ar->regiontype : 0;
-
+
if (ANIM_animdata_context_getdata(&ac) == 0)
return;
-
+
if (ac.datatype == ANIMCONT_DOPESHEET) {
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
short filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVESONLY);
-
+
/* get channels to work on */
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
-
+
/* these should all be ipo-blocks */
for (ale= anim_data.first; ale; ale= ale->next) {
AnimData *adt= ANIM_nla_mapping_get(&ac, ale);
FCurve *fcu= (FCurve *)ale->key_data;
-
- if ( (saction->flag & SACTION_NOTRANSKEYCULL)==0 &&
+
+ if ( (saction->flag & SACTION_NOTRANSKEYCULL)==0 &&
((cancelled == 0) || (duplicate)) )
{
if (adt) {
- ANIM_nla_mapping_apply_fcurve(adt, fcu, 0, 1);
+ ANIM_nla_mapping_apply_fcurve(adt, fcu, 0, 1);
posttrans_fcurve_clean(fcu);
ANIM_nla_mapping_apply_fcurve(adt, fcu, 1, 1);
}
@@ -4693,7 +4697,7 @@ void special_aftertrans_update(TransInfo *t)
posttrans_fcurve_clean(fcu);
}
}
-
+
/* free temp memory */
BLI_freelistN(&anim_data);
}
@@ -4702,15 +4706,15 @@ void special_aftertrans_update(TransInfo *t)
// fixme... some of this stuff is not good
if (ob) {
ob->ctime= -1234567.0f;
-
+
if (ob->pose || ob_get_key(ob))
DAG_object_flush_update(scene, ob, OB_RECALC);
else
DAG_object_flush_update(scene, ob, OB_RECALC_OB);
}
-
+
/* Do curve cleanups? */
- if ( (saction->flag & SACTION_NOTRANSKEYCULL)==0 &&
+ if ( (saction->flag & SACTION_NOTRANSKEYCULL)==0 &&
((cancelled == 0) || (duplicate)) )
{
posttrans_action_clean(&ac, (bAction *)ac.data);
@@ -4720,16 +4724,16 @@ void special_aftertrans_update(TransInfo *t)
#if 0 // XXX old animation system
/* fix up the Ipocurves and redraw stuff */
Key *key= (Key *)ac.data;
-
+
if (key->ipo) {
- if ( (saction->flag & SACTION_NOTRANSKEYCULL)==0 &&
+ if ( (saction->flag & SACTION_NOTRANSKEYCULL)==0 &&
((cancelled == 0) || (duplicate)) )
{
posttrans_ipo_clean(key->ipo);
}
}
#endif // XXX old animation system
-
+
DAG_object_flush_update(scene, OBACT, OB_RECALC_DATA);
}
#if 0 // XXX future of this is still not clear
@@ -4739,23 +4743,23 @@ void special_aftertrans_update(TransInfo *t)
{
bScreen *sc= (bScreen *)ac.data;
ScrArea *sa;
-
+
/* BAD... we need to loop over all screen areas for current screen...
- * - sync this with actdata_filter_gpencil() in editaction.c
+ * - sync this with actdata_filter_gpencil() in editaction.c
*/
for (sa= sc->areabase.first; sa; sa= sa->next) {
bGPdata *gpd= gpencil_data_getactive(sa);
-
- if (gpd)
+
+ if (gpd)
posttrans_gpd_clean(gpd);
}
}
}
#endif // XXX future of this is still not clear
-
+
/* make sure all F-Curves are set correctly */
ANIM_editkeyframes_refresh(&ac);
-
+
/* clear flag that was set for time-slide drawing */
saction->flag &= ~SACTION_MOVING;
}
@@ -4763,40 +4767,40 @@ void special_aftertrans_update(TransInfo *t)
SpaceIpo *sipo= (SpaceIpo *)t->sa->spacedata.first;
Scene *scene;
bAnimContext ac;
-
+
/* initialise relevant anim-context 'context' data from TransInfo data */
/* NOTE: sync this with the code in ANIM_animdata_get_context() */
memset(&ac, 0, sizeof(bAnimContext));
-
+
scene= ac.scene= t->scene;
ob= ac.obact= OBACT;
ac.sa= t->sa;
ac.ar= t->ar;
ac.spacetype= (t->sa)? t->sa->spacetype : 0;
ac.regiontype= (t->ar)? t->ar->regiontype : 0;
-
+
if (ANIM_animdata_context_getdata(&ac) == 0)
return;
-
- if (ac.datatype)
+
+ if (ac.datatype)
{
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
short filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVESONLY | ANIMFILTER_CURVEVISIBLE);
-
+
/* get channels to work on */
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
-
+
/* these should all be ipo-blocks */
for (ale= anim_data.first; ale; ale= ale->next) {
AnimData *adt= ANIM_nla_mapping_get(&ac, ale);
FCurve *fcu= (FCurve *)ale->key_data;
-
- if ( (sipo->flag & SIPO_NOTRANSKEYCULL)==0 &&
+
+ if ( (sipo->flag & SIPO_NOTRANSKEYCULL)==0 &&
((cancelled == 0) || (duplicate)) )
{
if (adt) {
- ANIM_nla_mapping_apply_fcurve(adt, fcu, 0, 1);
+ ANIM_nla_mapping_apply_fcurve(adt, fcu, 0, 1);
posttrans_fcurve_clean(fcu);
ANIM_nla_mapping_apply_fcurve(adt, fcu, 1, 1);
}
@@ -4804,55 +4808,55 @@ void special_aftertrans_update(TransInfo *t)
posttrans_fcurve_clean(fcu);
}
}
-
+
/* free temp memory */
BLI_freelistN(&anim_data);
}
-
+
/* make sure all F-Curves are set correctly */
ANIM_editkeyframes_refresh(&ac);
}
else if (t->spacetype == SPACE_NLA) {
Scene *scene;
bAnimContext ac;
-
+
/* initialise relevant anim-context 'context' data from TransInfo data */
/* NOTE: sync this with the code in ANIM_animdata_get_context() */
memset(&ac, 0, sizeof(bAnimContext));
-
+
scene= ac.scene= t->scene;
ob= ac.obact= OBACT;
ac.sa= t->sa;
ac.ar= t->ar;
ac.spacetype= (t->sa)? t->sa->spacetype : 0;
ac.regiontype= (t->ar)? t->ar->regiontype : 0;
-
+
if (ANIM_animdata_context_getdata(&ac) == 0)
return;
-
- if (ac.datatype)
+
+ if (ac.datatype)
{
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
short filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NLATRACKS);
-
+
/* get channels to work on */
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
-
+
for (ale= anim_data.first; ale; ale= ale->next) {
NlaTrack *nlt= (NlaTrack *)ale->data;
-
+
/* make sure strips are in order again */
BKE_nlatrack_sort_strips(nlt);
-
+
/* remove the temp metas */
BKE_nlastrips_clear_metas(&nlt->strips, 0, 1);
}
-
+
/* free temp memory */
BLI_freelistN(&anim_data);
}
-
+
// XXX check on the calls below... we need some of these sanity checks
//synchronize_action_strips();
//ANIM_editkeyframes_refresh(&ac);
@@ -4861,7 +4865,7 @@ void special_aftertrans_update(TransInfo *t)
// TRANSFORM_FIX_ME
// if (t->mode==TFM_BONESIZE || t->mode==TFM_BONE_ENVELOPE)
// allqueue(REDRAWBUTSEDIT, 0);
-
+
if (t->obedit->type == OB_MESH)
{
EditMesh *em = ((Mesh *)t->obedit->data)->edit_mesh;
@@ -4874,11 +4878,11 @@ void special_aftertrans_update(TransInfo *t)
bPose *pose;
bPoseChannel *pchan;
short targetless_ik= 0;
-
+
ob= t->poseobj;
arm= ob->data;
pose= ob->pose;
-
+
/* if target-less IK grabbing, we calculate the pchan transforms and clear flag */
if (!cancelled && t->mode==TFM_TRANSLATION)
targetless_ik= apply_targetless_ik(ob);
@@ -4889,10 +4893,10 @@ void special_aftertrans_update(TransInfo *t)
if(data) data->flag &= ~CONSTRAINT_IK_AUTO;
}
}
-
+
if (t->mode==TFM_TRANSLATION)
pose_grab_with_ik_clear(ob);
-
+
/* automatic inserting of keys and unkeyed tagging - only if transform wasn't cancelled (or TFM_DUMMY) */
if (!cancelled && (t->mode != TFM_DUMMY)) {
autokeyframe_pose_cb_func(t->scene, (View3D *)t->view, ob, t->mode, targetless_ik);
@@ -4903,26 +4907,26 @@ void special_aftertrans_update(TransInfo *t)
DAG_object_flush_update(t->scene, ob, OB_RECALC_DATA);
ob->recalc= 0; // is set on OK position already by recalcData()
}
- else
+ else
DAG_object_flush_update(t->scene, ob, OB_RECALC_DATA);
-
+
//if (t->mode==TFM_BONESIZE || t->mode==TFM_BONE_ENVELOPE)
// allqueue(REDRAWBUTSEDIT, 0);
-
+
}
else if(G.f & G_PARTICLEEDIT) {
;
}
- else {
+ else {
/* Objects */
// XXX ideally, this would go through context iterators, but we don't have context iterator access here,
// so we make do with old data + access styles...
Scene *scene= t->scene;
Base *base;
-
+
for (base= FIRSTBASE; base; base= base->next) {
ob= base->object;
-
+
if (base->flag & SELECT && (t->mode != TFM_DUMMY)) {
/* pointcache refresh */
if (BKE_ptcache_object_reset(scene, ob, PTCACHE_RESET_DEPSGRAPH))
@@ -4933,14 +4937,14 @@ void special_aftertrans_update(TransInfo *t)
/* autokey though, probably needed is an anim sys override? */
/* Please remove if some other solution is found. -jahka */
DAG_object_flush_update(scene, ob, OB_RECALC_OB);
-
+
/* Set autokey if necessary */
if (!cancelled)
autokeyframe_ob_cb_func(t->scene, (View3D *)t->view, ob, t->mode);
}
}
}
-
+
clear_trans_object_base_flags(t);
#if 0 // TRANSFORM_FIX_ME
@@ -4949,10 +4953,10 @@ void special_aftertrans_update(TransInfo *t)
allqueue(REDRAWACTION, 0);
allqueue(REDRAWIPO, 0);
}
-
+
if(resetslowpar)
reset_slowparents();
-
+
/* note; should actually only be done for all objects when a lamp is moved... (ton) */
if(t->spacetype==SPACE_VIEW3D && G.vd->drawtype == OB_SHADED)
reshadeall_displist();
@@ -4965,10 +4969,10 @@ static void createTransObject(bContext *C, TransInfo *t)
TransDataExtension *tx;
// IpoKey *ik;
// ListBase elems;
-
+
set_trans_object_base_flags(C, t);
- /* count */
+ /* count */
CTX_DATA_BEGIN(C, Object*, ob, selected_objects)
{
#if 0 // TRANSFORM_FIX_ME
@@ -4976,12 +4980,12 @@ static void createTransObject(bContext *C, TransInfo *t)
if ((ob->id.lib == 0) && (ob->ipo) && (ob->ipo->showkey) && (ob->ipoflag & OB_DRAWKEY)) {
elems.first= elems.last= NULL;
make_ipokey_transform(ob, &elems, 1); /* '1' only selected keys */
-
+
pushdata(&elems, sizeof(ListBase));
-
+
for(ik= elems.first; ik; ik= ik->next)
t->total++;
-
+
if(elems.first==NULL)
t->total++;
}
@@ -4997,24 +5001,24 @@ static void createTransObject(bContext *C, TransInfo *t)
clear_trans_object_base_flags(t);
return;
}
-
+
td = t->data = MEM_callocN(t->total*sizeof(TransData), "TransOb");
tx = t->ext = MEM_callocN(t->total*sizeof(TransDataExtension), "TransObExtension");
CTX_DATA_BEGIN(C, Base*, base, selected_bases)
{
Object *ob= base->object;
-
+
td->flag = TD_SELECTED;
td->protectflag= ob->protectflag;
td->ext = tx;
-
+
if (base->flag & BA_TRANSFORM_CHILD)
{
td->flag |= TD_NOCENTER;
td->flag |= TD_NO_LOC;
}
-
+
/* select linked objects, but skip them later */
if (ob->id.lib != 0) {
td->flag |= TD_SKIP;
@@ -5024,55 +5028,55 @@ static void createTransObject(bContext *C, TransInfo *t)
// TRANSFORM_FIX_ME
#if 0
if((ob->id.lib == 0) && (ob->ipo) && (ob->ipo->showkey) && (ob->ipoflag & OB_DRAWKEY)) {
-
+
popfirst(&elems); // bring back pushed listbase
-
+
if(elems.first) {
int cfraont;
int ipoflag;
-
+
base->flag |= BA_DO_IPO+BA_WAS_SEL;
base->flag &= ~SELECT;
-
+
cfraont= CFRA;
set_no_parent_ipo(1);
ipoflag= ob->ipoflag;
ob->ipoflag &= ~OB_OFFS_OB;
-
+
/*
* This is really EVIL code that pushes down Object values
* (loc, dloc, orig, size, dsize, rot, drot)
* */
-
+
pushdata((void*)ob->loc, 7 * 3 * sizeof(float)); // tsk! tsk!
-
+
for(ik= elems.first; ik; ik= ik->next) {
-
+
/* weak... this doesn't correct for floating values, giving small errors */
CFRA= (int)(ik->val/t->scene->r.framelen);
-
+
do_ob_ipo(ob);
ObjectToTransData(C, t, td, ob); // does where_is_object()
-
+
td->flag= TD_SELECTED;
-
+
td->tdi= MEM_callocN(sizeof(TransDataIpokey), "TransDataIpokey");
/* also does tdi->flag and oldvals, needs to be after ob_to_transob()! */
ipokey_to_transdata(ik, td);
-
+
td++;
tx++;
if(ik->next) td->ext= tx; // prevent corrupting mem!
}
free_ipokey(&elems);
-
+
poplast(ob->loc);
set_no_parent_ipo(0);
-
+
CFRA= cfraont;
ob->ipoflag= ipoflag;
-
- where_is_object(t->scene, ob); // restore
+
+ where_is_object(t->scene, ob); // restore
}
else {
ObjectToTransData(C, t, td, ob);
@@ -5096,7 +5100,7 @@ static void createTransObject(bContext *C, TransInfo *t)
/* transcribe given node into TransData2D for Transforming */
static void NodeToTransData(TransData *td, TransData2D *td2d, bNode *node)
-// static void NodeToTransData(bContext *C, TransInfo *t, TransData2D *td, bNode *node)
+// static void NodeToTransData(bContext *C, TransInfo *t, TransData2D *td, bNode *node)
{
td2d->loc[0] = node->locx; /* hold original location */
td2d->loc[1] = node->locy;
@@ -5124,22 +5128,22 @@ void createTransNodeData(bContext *C, TransInfo *t)
{
TransData *td;
TransData2D *td2d;
-
+
t->total= CTX_DATA_COUNT(C, selected_nodes);
-
+
td = t->data = MEM_callocN(t->total*sizeof(TransData), "TransNode TransData");
td2d = t->data2d = MEM_callocN(t->total*sizeof(TransData2D), "TransNode TransData2D");
-
+
CTX_DATA_BEGIN(C, bNode *, selnode, selected_nodes)
NodeToTransData(td++, td2d++, selnode);
CTX_DATA_END
}
-void createTransData(bContext *C, TransInfo *t)
+void createTransData(bContext *C, TransInfo *t)
{
Scene *scene = CTX_data_scene(C);
Object *ob = OBACT;
-
+
if (t->options == CTX_TEXTURE) {
t->flag |= T_TEXTURE;
createTransTexspace(C, t);
@@ -5183,7 +5187,7 @@ void createTransData(bContext *C, TransInfo *t)
else if (t->spacetype == SPACE_IPO) {
t->flag |= T_POINTS|T_2D_EDIT;
createTransGraphEditData(C, t);
-#if 0
+#if 0
if (t->data && (t->flag & T_PROP_EDIT)) {
sort_trans_data(t); // makes selected become first in array
set_prop_dist(t, 1);
@@ -5203,7 +5207,7 @@ void createTransData(bContext *C, TransInfo *t)
else if (t->obedit) {
t->ext = NULL;
if (t->obedit->type == OB_MESH) {
- createTransEditVerts(C, t);
+ createTransEditVerts(C, t);
}
else if ELEM(t->obedit->type, OB_CURVE, OB_SURF) {
createTransCurveVerts(C, t);
@@ -5217,7 +5221,7 @@ void createTransData(bContext *C, TransInfo *t)
else if (t->obedit->type==OB_ARMATURE) {
t->flag &= ~T_PROP_EDIT;
createTransArmatureVerts(C, t);
- }
+ }
else {
printf("edit type not implemented!\n");
}
@@ -5236,7 +5240,7 @@ void createTransData(bContext *C, TransInfo *t)
}
t->flag |= T_EDIT|T_POINTS;
-
+
/* exception... hackish, we want bonesize to use bone orientation matrix (ton) */
if(t->mode==TFM_BONESIZE) {
t->flag &= ~(T_EDIT|T_POINTS);
@@ -5245,7 +5249,7 @@ void createTransData(bContext *C, TransInfo *t)
}
}
else if (ob && (ob->flag & OB_POSEMODE)) {
- // XXX this is currently limited to active armature only...
+ // XXX this is currently limited to active armature only...
// XXX active-layer checking isn't done as that should probably be checked through context instead
createTransPose(C, t, ob);
}
@@ -5279,7 +5283,7 @@ void createTransData(bContext *C, TransInfo *t)
t->flag &= ~T_PROP_EDIT; /* no proportional edit in object mode */
createTransObject(C, t);
t->flag |= T_OBJECT;
-
+
if (t->ar->regiontype == RGN_TYPE_WINDOW)
{
View3D *v3d = t->view;
diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c
index 3415c266cf1..af56079727f 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -154,8 +154,8 @@ static void clipMirrorModifier(TransInfo *t, Object *ob)
for (; md; md=md->next) {
if (md->type==eModifierType_Mirror) {
- MirrorModifierData *mmd = (MirrorModifierData*) md;
-
+ MirrorModifierData *mmd = (MirrorModifierData*) md;
+
if(mmd->flag & MOD_MIR_CLIPPING) {
axis = 0;
if(mmd->flag & MOD_MIR_AXIS_X) {
@@ -174,7 +174,7 @@ static void clipMirrorModifier(TransInfo *t, Object *ob)
float mtx[4][4], imtx[4][4];
int i;
TransData *td = t->data;
-
+
if (mmd->mirror_ob) {
float obinv[4][4];
@@ -191,10 +191,10 @@ static void clipMirrorModifier(TransInfo *t, Object *ob)
break;
if (td->loc==NULL)
break;
-
+
if (td->flag & TD_SKIP)
continue;
-
+
VecCopyf(loc, td->loc);
VecCopyf(iloc, td->iloc);
@@ -205,22 +205,22 @@ static void clipMirrorModifier(TransInfo *t, Object *ob)
clip = 0;
if(axis & 1) {
- if(fabs(iloc[0])<=tolerance[0] ||
+ if(fabs(iloc[0])<=tolerance[0] ||
loc[0]*iloc[0]<0.0f) {
loc[0]= 0.0f;
clip = 1;
}
}
-
+
if(axis & 2) {
- if(fabs(iloc[1])<=tolerance[1] ||
+ if(fabs(iloc[1])<=tolerance[1] ||
loc[1]*iloc[1]<0.0f) {
loc[1]= 0.0f;
clip = 1;
}
}
if(axis & 4) {
- if(fabs(iloc[2])<=tolerance[2] ||
+ if(fabs(iloc[2])<=tolerance[2] ||
loc[2]*iloc[2]<0.0f) {
loc[2]= 0.0f;
clip = 1;
@@ -246,7 +246,7 @@ static void editmesh_apply_to_mirror(TransInfo *t)
TransData *td = t->data;
EditVert *eve;
int i;
-
+
for(i = 0 ; i < t->total; i++, td++) {
if (td->flag & TD_NOACTION)
break;
@@ -254,14 +254,14 @@ static void editmesh_apply_to_mirror(TransInfo *t)
break;
if (td->flag & TD_SKIP)
continue;
-
+
eve = td->extra;
if(eve) {
eve->co[0]= -td->loc[0];
eve->co[1]= td->loc[1];
eve->co[2]= td->loc[2];
- }
- }
+ }
+ }
}
/* called for updating while transform acts, once per redraw */
@@ -269,7 +269,7 @@ void recalcData(TransInfo *t)
{
Scene *scene = t->scene;
Base *base;
-
+
if (t->obedit) {
}
else if(G.f & G_PARTICLEEDIT) {
@@ -284,56 +284,56 @@ void recalcData(TransInfo *t)
else if (t->spacetype == SPACE_IPO) {
SpaceIpo *sipo= (SpaceIpo *)t->sa->spacedata.first;
Scene *scene;
-
+
ListBase anim_data = {NULL, NULL};
bAnimContext ac;
int filter;
-
+
bAnimListElem *ale;
int dosort = 0;
-
-
+
+
/* initialise relevant anim-context 'context' data from TransInfo data */
/* NOTE: sync this with the code in ANIM_animdata_get_context() */
memset(&ac, 0, sizeof(bAnimContext));
-
+
scene= ac.scene= t->scene;
ac.obact= OBACT;
ac.sa= t->sa;
ac.ar= t->ar;
ac.spacetype= (t->sa)? t->sa->spacetype : 0;
ac.regiontype= (t->ar)? t->ar->regiontype : 0;
-
+
ANIM_animdata_context_getdata(&ac);
-
+
/* do the flush first */
flushTransGraphData(t);
-
+
/* get curves to check if a re-sort is needed */
filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVESONLY | ANIMFILTER_CURVEVISIBLE);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
-
+
/* now test if there is a need to re-sort */
for (ale= anim_data.first; ale; ale= ale->next) {
FCurve *fcu= (FCurve *)ale->key_data;
-
+
/* watch it: if the time is wrong: do not correct handles yet */
if (test_time_fcurve(fcu))
dosort++;
else
calchandles_fcurve(fcu);
}
-
+
/* do resort and other updates? */
if (dosort) remake_graph_transdata(t, &anim_data);
//if (sipo->showkey) update_ipokey_val();
-
+
/* now free temp channels */
BLI_freelistN(&anim_data);
-
+
/* update realtime - not working? */
if (sipo->lock) {
-
+
}
}
else if (t->spacetype == SPACE_NLA) {
@@ -342,8 +342,8 @@ void recalcData(TransInfo *t)
Scene *scene= t->scene;
double secf= FPS;
int i;
-
- /* for each strip we've got, perform some additional validation of the values that got set before
+
+ /* for each strip we've got, perform some additional validation of the values that got set before
* using RNA to set the value (which does some special operations when setting these values to make
* sure that everything works ok)
*/
@@ -352,43 +352,43 @@ void recalcData(TransInfo *t)
PointerRNA strip_ptr;
short pExceeded, nExceeded, iter;
int delta_y1, delta_y2;
-
+
/* if this tdn has no handles, that means it is just a dummy that should be skipped */
if (tdn->handle == 0)
continue;
-
+
/* if cancelling transform, just write the values without validating, then move on */
if (t->state == TRANS_CANCEL) {
- /* clear the values by directly overwriting the originals, but also need to restore
+ /* clear the values by directly overwriting the originals, but also need to restore
* endpoints of neighboring transition-strips
*/
-
+
/* start */
strip->start= tdn->h1[0];
-
+
if ((strip->prev) && (strip->prev->type == NLASTRIP_TYPE_TRANSITION))
strip->prev->end= tdn->h1[0];
-
+
/* end */
strip->end= tdn->h2[0];
-
+
if ((strip->next) && (strip->next->type == NLASTRIP_TYPE_TRANSITION))
strip->next->start= tdn->h2[0];
-
+
/* flush transforms to child strips (since this should be a meta) */
BKE_nlameta_flush_transforms(strip);
-
+
/* restore to original track (if needed) */
if (tdn->oldTrack != tdn->nlt) {
/* just append to end of list for now, since strips get sorted in special_aftertrans_update() */
BLI_remlink(&tdn->nlt->strips, strip);
BLI_addtail(&tdn->oldTrack->strips, strip);
}
-
+
continue;
}
-
- /* firstly, check if the proposed transform locations would overlap with any neighbouring strips
+
+ /* firstly, check if the proposed transform locations would overlap with any neighbouring strips
* (barring transitions) which are absolute barriers since they are not being moved
*
* this is done as a iterative procedure (done 5 times max for now)
@@ -396,10 +396,10 @@ void recalcData(TransInfo *t)
for (iter=0; iter < 5; iter++) {
pExceeded= ((strip->prev) && (strip->prev->type != NLASTRIP_TYPE_TRANSITION) && (tdn->h1[0] < strip->prev->end));
nExceeded= ((strip->next) && (strip->next->type != NLASTRIP_TYPE_TRANSITION) && (tdn->h2[0] > strip->next->start));
-
+
if ((pExceeded && nExceeded) || (iter == 4) ) {
- /* both endpoints exceeded (or iteration ping-pong'd meaning that we need a compromise)
- * - simply crop strip to fit within the bounds of the strips bounding it
+ /* both endpoints exceeded (or iteration ping-pong'd meaning that we need a compromise)
+ * - simply crop strip to fit within the bounds of the strips bounding it
* - if there were no neighbours, clear the transforms (make it default to the strip's current values)
*/
if (strip->prev && strip->next) {
@@ -414,21 +414,21 @@ void recalcData(TransInfo *t)
else if (nExceeded) {
/* move backwards */
float offset= tdn->h2[0] - strip->next->start;
-
+
tdn->h1[0] -= offset;
tdn->h2[0] -= offset;
}
else if (pExceeded) {
/* more forwards */
float offset= strip->prev->end - tdn->h1[0];
-
+
tdn->h1[0] += offset;
tdn->h2[0] += offset;
}
else /* all is fine and well */
break;
}
-
+
/* handle auto-snapping */
switch (snla->autosnap) {
case SACTSNAP_FRAME: /* snap to nearest frame/time */
@@ -441,36 +441,36 @@ void recalcData(TransInfo *t)
tdn->h2[0]= (float)( floor(tdn->h2[0]+0.5f) );
}
break;
-
+
case SACTSNAP_MARKER: /* snap to nearest marker */
tdn->h1[0]= (float)ED_markers_find_nearest_marker_time(&t->scene->markers, tdn->h1[0]);
tdn->h2[0]= (float)ED_markers_find_nearest_marker_time(&t->scene->markers, tdn->h2[0]);
break;
}
-
+
/* use RNA to write the values... */
// TODO: do we need to write in 2 passes to make sure that no truncation goes on?
RNA_pointer_create(NULL, &RNA_NlaStrip, strip, &strip_ptr);
-
+
RNA_float_set(&strip_ptr, "start_frame", tdn->h1[0]);
RNA_float_set(&strip_ptr, "end_frame", tdn->h2[0]);
-
+
/* flush transforms to child strips (since this should be a meta) */
BKE_nlameta_flush_transforms(strip);
-
-
- /* now, check if we need to try and move track
+
+
+ /* now, check if we need to try and move track
* - we need to calculate both, as only one may have been altered by transform if only 1 handle moved
*/
delta_y1= ((int)tdn->h1[1] / NLACHANNEL_STEP - tdn->trackIndex);
delta_y2= ((int)tdn->h2[1] / NLACHANNEL_STEP - tdn->trackIndex);
-
+
if (delta_y1 || delta_y2) {
NlaTrack *track;
int delta = (delta_y2) ? delta_y2 : delta_y1;
int n;
-
- /* move in the requested direction, checking at each layer if there's space for strip to pass through,
+
+ /* move in the requested direction, checking at each layer if there's space for strip to pass through,
* stopping on the last track available or that we're able to fit in
*/
if (delta > 0) {
@@ -480,7 +480,7 @@ void recalcData(TransInfo *t)
/* move strip to this track */
BLI_remlink(&tdn->nlt->strips, strip);
BKE_nlatrack_add_strip(track, strip);
-
+
tdn->nlt= track;
tdn->trackIndex += (n + 1); /* + 1, since n==0 would mean that we didn't change track */
}
@@ -491,14 +491,14 @@ void recalcData(TransInfo *t)
else {
/* make delta 'positive' before using it, since we now know to go backwards */
delta= -delta;
-
+
for (track=tdn->nlt->prev, n=0; (track) && (n < delta); track=track->prev, n++) {
/* check if space in this track for the strip */
if (BKE_nlatrack_has_space(track, strip->start, strip->end)) {
/* move strip to this track */
BLI_remlink(&tdn->nlt->strips, strip);
BKE_nlatrack_add_strip(track, strip);
-
+
tdn->nlt= track;
tdn->trackIndex -= (n - 1); /* - 1, since n==0 would mean that we didn't change track */
}
@@ -513,9 +513,9 @@ void recalcData(TransInfo *t)
if ELEM(t->obedit->type, OB_CURVE, OB_SURF) {
Curve *cu= t->obedit->data;
Nurb *nu= cu->editnurb->first;
-
+
DAG_object_flush_update(scene, t->obedit, OB_RECALC_DATA); /* sets recalc flags */
-
+
if (t->state == TRANS_CANCEL) {
while(nu) {
calchandlesNurb(nu); /* Cant do testhandlesNurb here, it messes up the h1 and h2 flags */
@@ -535,7 +535,7 @@ void recalcData(TransInfo *t)
else if(t->obedit->type==OB_LATTICE) {
Lattice *la= t->obedit->data;
DAG_object_flush_update(scene, t->obedit, OB_RECALC_DATA); /* sets recalc flags */
-
+
if(la->editlatt->flag & LT_OUTSIDE) outside_lattice(la->editlatt);
}
else if (t->obedit->type == OB_MESH) {
@@ -545,7 +545,7 @@ void recalcData(TransInfo *t)
flushTransUVs(t);
if(sima->flag & SI_LIVE_UNWRAP)
ED_uvedit_live_unwrap_re_solve();
-
+
DAG_object_flush_update(scene, t->obedit, OB_RECALC_DATA);
} else {
EditMesh *em = ((Mesh*)t->obedit->data)->edit_mesh;
@@ -560,9 +560,9 @@ void recalcData(TransInfo *t)
}
if((t->options & CTX_NO_MIRROR) == 0 && (t->flag & T_MIRROR))
editmesh_apply_to_mirror(t);
-
+
DAG_object_flush_update(scene, t->obedit, OB_RECALC_DATA); /* sets recalc flags */
-
+
recalc_editnormals(em);
}
}
@@ -572,10 +572,10 @@ void recalcData(TransInfo *t)
EditBone *ebo;
TransData *td = t->data;
int i;
-
+
/* Ensure all bones are correctly adjusted */
for (ebo = edbo->first; ebo; ebo = ebo->next){
-
+
if ((ebo->flag & BONE_CONNECTED) && ebo->parent){
/* If this bone has a parent tip that has been moved */
if (ebo->parent->flag & BONE_TIPSEL){
@@ -588,7 +588,7 @@ void recalcData(TransInfo *t)
if(t->mode==TFM_BONE_ENVELOPE) ebo->parent->rad_tail= ebo->rad_head;
}
}
-
+
/* on extrude bones, oldlength==0.0f, so we scale radius of points */
ebo->length= VecLenf(ebo->head, ebo->tail);
if(ebo->oldlength==0.0f) {
@@ -608,8 +608,8 @@ void recalcData(TransInfo *t)
ebo->oldlength= ebo->length;
}
}
-
-
+
+
if (t->mode != TFM_BONE_ROLL)
{
/* fix roll */
@@ -619,10 +619,10 @@ void recalcData(TransInfo *t)
{
float vec[3], up_axis[3];
float qrot[4];
-
+
ebo = td->extra;
VECCOPY(up_axis, td->axismtx[2]);
-
+
if (t->mode != TFM_ROTATION)
{
VecSubf(vec, ebo->tail, ebo->head);
@@ -634,15 +634,15 @@ void recalcData(TransInfo *t)
{
Mat3MulVecfl(t->mat, up_axis);
}
-
+
ebo->roll = ED_rollBoneToVector(ebo, up_axis);
}
}
}
-
- if(arm->flag & ARM_MIRROR_EDIT)
+
+ if(arm->flag & ARM_MIRROR_EDIT)
transform_armature_mirror_update(t->obedit);
-
+
}
else
DAG_object_flush_update(scene, t->obedit, OB_RECALC_DATA); /* sets recalc flags */
@@ -650,7 +650,7 @@ void recalcData(TransInfo *t)
else if( (t->flag & T_POSE) && t->poseobj) {
Object *ob= t->poseobj;
bArmature *arm= ob->data;
-
+
/* if animtimer is running, and the object already has animation data,
* check if the auto-record feature means that we should record 'samples'
* (i.e. uneditable animation values)
@@ -661,7 +661,7 @@ void recalcData(TransInfo *t)
short targetless_ik= (t->flag & T_AUTOIK); // XXX this currently doesn't work, since flags aren't set yet!
autokeyframe_pose_cb_func(t->scene, (View3D *)t->view, ob, t->mode, targetless_ik);
}
-
+
/* old optimize trick... this enforces to bypass the depgraph */
if (!(arm->flag & ARM_DELAYDEFORM)) {
DAG_object_flush_update(scene, ob, OB_RECALC_DATA); /* sets recalc flags */
@@ -672,13 +672,13 @@ void recalcData(TransInfo *t)
else {
for(base= FIRSTBASE; base; base= base->next) {
Object *ob= base->object;
-
+
/* this flag is from depgraph, was stored in initialize phase, handled in drawview.c */
if(base->flag & BA_HAS_RECALC_OB)
ob->recalc |= OB_RECALC_OB;
if(base->flag & BA_HAS_RECALC_DATA)
ob->recalc |= OB_RECALC_DATA;
-
+
/* if object/base is selected */
if ((base->flag & SELECT) || (ob->flag & SELECT)) {
/* if animtimer is running, and the object already has animation data,
@@ -691,13 +691,13 @@ void recalcData(TransInfo *t)
autokeyframe_ob_cb_func(t->scene, (View3D *)t->view, ob, t->mode);
}
}
-
+
/* proxy exception */
if(ob->proxy)
ob->proxy->recalc |= ob->recalc;
if(ob->proxy_group)
group_tag_recalc(ob->proxy_group->dup_group);
- }
+ }
}
/* update shaded drawmode while transform */
@@ -709,22 +709,22 @@ void drawLine(TransInfo *t, float *center, float *dir, char axis, short options)
{
float v1[3], v2[3], v3[3];
char col[3], col2[3];
-
+
if (t->spacetype == SPACE_VIEW3D)
{
View3D *v3d = t->view;
-
+
glPushMatrix();
-
+
//if(t->obedit) glLoadMatrixf(t->obedit->obmat); // sets opengl viewing
-
-
+
+
VecCopyf(v3, dir);
VecMulf(v3, v3d->far);
-
+
VecSubf(v2, center, v3);
VecAddf(v1, center, v3);
-
+
if (options & DRAWLIGHT) {
col[0] = col[1] = col[2] = 220;
}
@@ -733,13 +733,13 @@ void drawLine(TransInfo *t, float *center, float *dir, char axis, short options)
}
UI_make_axis_color(col, col2, axis);
glColor3ubv((GLubyte *)col2);
-
+
setlinestyle(0);
- glBegin(GL_LINE_STRIP);
- glVertex3fv(v1);
- glVertex3fv(v2);
+ glBegin(GL_LINE_STRIP);
+ glVertex3fv(v1);
+ glVertex3fv(v2);
glEnd();
-
+
glPopMatrix();
}
}
@@ -756,13 +756,13 @@ int initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event)
ARegion *ar = CTX_wm_region(C);
ScrArea *sa = CTX_wm_area(C);
Object *obedit = CTX_data_edit_object(C);
-
+
/* moving: is shown in drawobject() (transform color) */
-// TRANSFORM_FIX_ME
+// TRANSFORM_FIX_ME
// if(obedit || (t->flag & T_POSE) ) G.moving= G_TRANSFORM_EDIT;
// else if(G.f & G_PARTICLEEDIT) G.moving= G_TRANSFORM_PARTICLE;
// else G.moving= G_TRANSFORM_OBJ;
-
+
t->scene = sce;
t->sa = sa;
t->ar = ar;
@@ -775,14 +775,14 @@ int initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event)
t->helpline = HLP_NONE;
t->flag = 0;
-
+
t->redraw = 1; /* redraw first time */
-
+
if (event)
{
t->imval[0] = event->x - t->ar->winrct.xmin;
t->imval[1] = event->y - t->ar->winrct.ymin;
-
+
t->event_type = event->type;
}
else
@@ -790,7 +790,7 @@ int initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event)
t->imval[0] = 0;
t->imval[1] = 0;
}
-
+
t->con.imval[0] = t->imval[0];
t->con.imval[1] = t->imval[1];
@@ -807,21 +807,21 @@ int initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event)
t->vec[0] =
t->vec[1] =
t->vec[2] = 0.0f;
-
+
t->center[0] =
t->center[1] =
t->center[2] = 0.0f;
-
+
Mat3One(t->mat);
-
+
t->spacetype = sa->spacetype;
if(t->spacetype == SPACE_VIEW3D)
{
View3D *v3d = sa->spacedata.first;
-
+
t->view = v3d;
t->animtimer= CTX_wm_screen(C)->animtimer;
-
+
if(v3d->flag & V3D_ALIGN) t->flag |= T_V3D_ALIGN;
t->around = v3d->around;
@@ -850,7 +850,7 @@ int initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event)
{
// XXX for now, get View2D from the active region
t->view = &ar->v2d;
-
+
t->around = V3D_CENTER;
}
@@ -886,7 +886,7 @@ int initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event)
{
if ((t->options & CTX_NO_PET) == 0 && (ts->proportional)) {
t->flag |= T_PROP_EDIT;
-
+
if(ts->proportional == 2)
t->flag |= T_PROP_CONNECTED; // yes i know, has to become define
}
@@ -900,7 +900,7 @@ int initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event)
{
t->prop_size = ts->proportional_size;
}
-
+
if (op && RNA_struct_find_property(op->ptr, "proportional_editing_falloff") && RNA_property_is_set(op->ptr, "proportional_editing_falloff"))
{
t->prop_mode = RNA_enum_get(op->ptr, "proportional_editing_falloff");
@@ -919,12 +919,12 @@ int initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event)
setTransformViewMatrices(t);
initNumInput(&t->num);
initNDofInput(&t->ndof);
-
+
return 1;
}
/* Here I would suggest only TransInfo related issues, like free data & reset vars. Not redraws */
-void postTrans (TransInfo *t)
+void postTrans (TransInfo *t)
{
TransData *td;
@@ -932,7 +932,7 @@ void postTrans (TransInfo *t)
{
ED_region_draw_cb_exit(t->ar->type, t->draw_handle);
}
-
+
/* postTrans can be called when nothing is selected, so data is NULL already */
if (t->data) {
int a;
@@ -940,7 +940,7 @@ void postTrans (TransInfo *t)
/* since ipokeys are optional on objects, we mallocced them per trans-data */
for(a=0, td= t->data; a<t->total; a++, td++) {
if(td->tdi) MEM_freeN(td->tdi);
- if (td->flag & TD_BEZTRIPLE) MEM_freeN(td->hdata);
+ if (td->flag & TD_BEZTRIPLE) MEM_freeN(td->hdata);
}
MEM_freeN(t->data);
}
@@ -965,7 +965,7 @@ void postTrans (TransInfo *t)
void applyTransObjects(TransInfo *t)
{
TransData *td;
-
+
for (td = t->data; td < t->data + t->total; td++) {
VECCOPY(td->iloc, td->loc);
if (td->ext->rot) {
@@ -974,9 +974,9 @@ void applyTransObjects(TransInfo *t)
if (td->ext->size) {
VECCOPY(td->ext->isize, td->ext->size);
}
- }
+ }
recalcData(t);
-}
+}
/* helper for below */
static void restore_ipokey(float *poin, float *old)
@@ -1009,15 +1009,15 @@ static void restoreElement(TransData *td) {
}
}
}
-
+
if (td->flag & TD_BEZTRIPLE) {
*(td->hdata->h1) = td->hdata->ih1;
*(td->hdata->h2) = td->hdata->ih2;
}
-
+
if(td->tdi) {
TransDataIpokey *tdi= td->tdi;
-
+
restore_ipokey(tdi->locx, tdi->oldloc);
restore_ipokey(tdi->locy, tdi->oldloc+1);
restore_ipokey(tdi->locz, tdi->oldloc+2);
@@ -1025,7 +1025,7 @@ static void restoreElement(TransData *td) {
restore_ipokey(tdi->rotx, tdi->oldrot);
restore_ipokey(tdi->roty, tdi->oldrot+1);
restore_ipokey(tdi->rotz, tdi->oldrot+2);
-
+
restore_ipokey(tdi->sizex, tdi->oldsize);
restore_ipokey(tdi->sizey, tdi->oldsize+1);
restore_ipokey(tdi->sizez, tdi->oldsize+2);
@@ -1035,13 +1035,13 @@ static void restoreElement(TransData *td) {
void restoreTransObjects(TransInfo *t)
{
TransData *td;
-
+
for (td = t->data; td < t->data + t->total; td++) {
restoreElement(td);
}
-
+
Mat3One(t->mat);
-
+
recalcData(t);
}
@@ -1050,7 +1050,7 @@ void calculateCenter2D(TransInfo *t)
if (t->flag & (T_EDIT|T_POSE)) {
Object *ob= t->obedit?t->obedit:t->poseobj;
float vec[3];
-
+
VECCOPY(vec, t->center);
Mat4MulVecfl(ob->obmat, vec);
projectIntView(t, vec, t->center2d);
@@ -1071,13 +1071,13 @@ void calculateCenterCursor(TransInfo *t)
if (t->flag & (T_EDIT|T_POSE)) {
Object *ob = t->obedit?t->obedit:t->poseobj;
float mat[3][3], imat[3][3];
-
+
VecSubf(t->center, t->center, ob->obmat[3]);
Mat3CpyMat4(mat, ob->obmat);
Mat3Inv(imat, mat);
Mat3MulVecfl(imat, t->center);
}
-
+
calculateCenter2D(t);
}
@@ -1085,13 +1085,13 @@ void calculateCenterCursor2D(TransInfo *t)
{
View2D *v2d= t->view;
float aspx=1.0, aspy=1.0;
-
+
if(t->spacetype==SPACE_IMAGE) /* only space supported right now but may change */
ED_space_image_uv_aspect(t->sa->spacedata.first, &aspx, &aspy);
if (v2d) {
- t->center[0] = v2d->cursor[0] * aspx;
- t->center[1] = v2d->cursor[1] * aspy;
+ t->center[0] = v2d->cursor[0] * aspx;
+ t->center[1] = v2d->cursor[1] * aspy;
}
calculateCenter2D(t);
@@ -1102,7 +1102,7 @@ void calculateCenterMedian(TransInfo *t)
float partial[3] = {0.0f, 0.0f, 0.0f};
int total = 0;
int i;
-
+
for(i = 0; i < t->total; i++) {
if (t->data[i].flag & TD_SELECTED) {
if (!(t->data[i].flag & TD_NOCENTER))
@@ -1112,8 +1112,8 @@ void calculateCenterMedian(TransInfo *t)
}
}
else {
- /*
- All the selected elements are at the head of the array
+ /*
+ All the selected elements are at the head of the array
which means we can stop when it finds unselected data
*/
break;
@@ -1138,8 +1138,8 @@ void calculateCenterBound(TransInfo *t)
MinMax3(min, max, t->data[i].center);
}
else {
- /*
- All the selected elements are at the head of the array
+ /*
+ All the selected elements are at the head of the array
which means we can stop when it finds unselected data
*/
break;
@@ -1156,7 +1156,7 @@ void calculateCenterBound(TransInfo *t)
calculateCenter2D(t);
}
-void calculateCenter(TransInfo *t)
+void calculateCenter(TransInfo *t)
{
switch(t->around) {
case V3D_CENTER:
@@ -1188,7 +1188,7 @@ void calculateCenter(TransInfo *t)
break;
} /* END EDIT MODE ACTIVE ELEMENT */
#endif
-
+
calculateCenterMedian(t);
if((t->flag & (T_EDIT|T_POSE))==0)
{
@@ -1200,7 +1200,7 @@ void calculateCenter(TransInfo *t)
projectIntView(t, t->center, t->center2d);
}
}
-
+
}
}
@@ -1220,21 +1220,21 @@ void calculateCenter(TransInfo *t)
View3D *v3d = t->view;
Scene *scene = t->scene;
RegionView3D *rv3d = t->ar->regiondata;
-
+
if(v3d->camera == OBACT && rv3d->persp==V3D_CAMOB)
{
float axis[3];
/* persinv is nasty, use viewinv instead, always right */
VECCOPY(axis, t->viewinv[2]);
Normalize(axis);
-
+
/* 6.0 = 6 grid units */
axis[0]= t->center[0]- 6.0f*axis[0];
axis[1]= t->center[1]- 6.0f*axis[1];
axis[2]= t->center[2]- 6.0f*axis[2];
-
+
projectIntView(t, axis, t->center2d);
-
+
/* rotate only needs correct 2d center, grab needs initgrabz() value */
if(t->mode==TFM_TRANSLATION)
{
@@ -1243,7 +1243,7 @@ void calculateCenter(TransInfo *t)
}
}
}
- }
+ }
if(t->spacetype==SPACE_VIEW3D)
{
@@ -1251,14 +1251,14 @@ void calculateCenter(TransInfo *t)
if(t->flag & (T_EDIT|T_POSE)) {
Object *ob= t->obedit?t->obedit:t->poseobj;
float vec[3];
-
+
VECCOPY(vec, t->center);
Mat4MulVecfl(ob->obmat, vec);
initgrabz(t->ar->regiondata, vec[0], vec[1], vec[2]);
}
else {
initgrabz(t->ar->regiondata, t->center[0], t->center[1], t->center[2]);
- }
+ }
}
}
@@ -1268,18 +1268,18 @@ void calculatePropRatio(TransInfo *t)
int i;
float dist;
short connected = t->flag & T_PROP_CONNECTED;
-
+
if (t->flag & T_PROP_EDIT) {
for(i = 0 ; i < t->total; i++, td++) {
if (td->flag & TD_SELECTED) {
td->factor = 1.0f;
}
- else if ((connected &&
+ else if ((connected &&
(td->flag & TD_NOTCONNECTED || td->dist > t->prop_size))
||
(connected == 0 &&
td->rdist > t->prop_size)) {
- /*
+ /*
The elements are sorted according to their dist member in the array,
that means we can stop when it finds one element outside of the propsize.
*/
@@ -1291,7 +1291,7 @@ void calculatePropRatio(TransInfo *t)
/* Use rdist for falloff calculations, it is the real distance */
td->flag &= ~TD_NOACTION;
dist= (t->prop_size-td->rdist)/t->prop_size;
-
+
/*
* Clamp to positive numbers.
* Certain corner cases with connectivity and individual centers
@@ -1299,7 +1299,7 @@ void calculatePropRatio(TransInfo *t)
*/
if (dist < 0.0f)
dist = 0.0f;
-
+
switch(t->prop_mode) {
case PROP_SHARP:
td->factor= dist*dist;
@@ -1362,27 +1362,19 @@ void calculatePropRatio(TransInfo *t)
}
}
-/* XXX only to make manipulators run now */
-TransInfo *BIF_GetTransInfo()
-{
- static struct TransInfo trans;
- memset(&trans, 0, sizeof(struct TransInfo));
- return &trans;
-}
-
float get_drawsize(ARegion *ar, float *co)
{
RegionView3D *rv3d= ar->regiondata;
float size, vec[3], len1, len2;
-
+
/* size calculus, depending ortho/persp settings, like initgrabz() */
size= rv3d->persmat[0][3]*co[0]+ rv3d->persmat[1][3]*co[1]+ rv3d->persmat[2][3]*co[2]+ rv3d->persmat[3][3];
-
+
VECCOPY(vec, rv3d->persinv[0]);
len1= Normalize(vec);
VECCOPY(vec, rv3d->persinv[1]);
len2= Normalize(vec);
-
+
size*= 0.01f*(len1>len2?len1:len2);
/* correct for window size to make widgets appear fixed size */
diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c
index 7c71e89f948..c656b097cb9 100644
--- a/source/blender/editors/transform/transform_manipulator.c
+++ b/source/blender/editors/transform/transform_manipulator.c
@@ -174,37 +174,10 @@ static void stats_editbone(View3D *v3d, EditBone *ebo)
protectflag_to_drawflags(OB_LOCK_LOC|OB_LOCK_ROT|OB_LOCK_SCALE, &v3d->twdrawflag);
}
-/* only counts the parent selection, and tags transform flag */
-/* bad call... should re-use method from transform_conversion once */
-static void count_bone_select(TransInfo *t, bArmature *arm, ListBase *lb, int do_it)
-{
- Bone *bone;
- int do_next;
-
- for(bone= lb->first; bone; bone= bone->next) {
- bone->flag &= ~BONE_TRANSFORM;
- do_next= do_it;
- if(do_it) {
- if(bone->layer & arm->layer) {
- if (bone->flag & BONE_SELECTED) {
- /* We don't let connected children get "grabbed" */
- if ( (t->mode!=TFM_TRANSLATION) || (bone->flag & BONE_CONNECTED)==0 ) {
- bone->flag |= BONE_TRANSFORM;
- t->total++;
- do_next= 0; // no transform on children if one parent bone is selected
- }
- }
- }
- }
- count_bone_select(t, arm, &bone->childbase, do_next);
- }
-}
-
/* centroid, boundbox, of selection */
/* returns total items selected */
int calc_manipulator_stats(const bContext *C)
{
- TransInfo *t= BIF_GetTransInfo(); // XXX
ScrArea *sa= CTX_wm_area(C);
ARegion *ar= CTX_wm_region(C);
Scene *scene= CTX_data_scene(C);
@@ -369,17 +342,12 @@ int calc_manipulator_stats(const bContext *C)
else if(ob && (ob->flag & OB_POSEMODE)) {
bArmature *arm = ob->data;
bPoseChannel *pchan;
- int mode;
+ int mode = TFM_ROTATION; // mislead counting bones... bah. We don't know the manipulator mode, could be mixed
if((ob->lay & v3d->lay)==0) return 0;
- mode = t->mode;
- t->mode = TFM_ROTATION; // mislead counting bones... bah
+ totsel = count_set_pose_transflags(&mode, 0, ob);
- /* count total, we use same method as transform will do */
- t->total= 0;
- count_bone_select(t, arm, &arm->bonebase, 1);
- totsel = t->total;
if(totsel) {
/* use channels to get stats */
for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
@@ -391,8 +359,6 @@ int calc_manipulator_stats(const bContext *C)
Mat4MulVecfl(ob->obmat, scene->twmin);
Mat4MulVecfl(ob->obmat, scene->twmax);
}
- /* restore, mode can be TFM_INIT */
- t->mode = mode;
}
else if(G.f & (G_VERTEXPAINT + G_TEXTUREPAINT + G_WEIGHTPAINT + G_SCULPTMODE)) {
;
@@ -446,17 +412,12 @@ int calc_manipulator_stats(const bContext *C)
if(ob && totsel) {
switch(v3d->twmode) {
- case V3D_MANIP_GLOBAL:
- strcpy(t->spacename, "global");
- break;
case V3D_MANIP_NORMAL:
if(obedit || ob->flag & OB_POSEMODE) {
float mat[3][3];
int type;
- strcpy(t->spacename, "normal");
-
type = getTransformOrientation(C, normal, plane, (v3d->around == V3D_ACTIVE));
switch (type)
@@ -499,7 +460,6 @@ int calc_manipulator_stats(const bContext *C)
}
/* no break we define 'normal' as 'local' in Object mode */
case V3D_MANIP_LOCAL:
- strcpy(t->spacename, "local");
Mat4CpyMat4(rv3d->twmat, ob->obmat);
Mat4Ortho(rv3d->twmat);
break;
@@ -507,14 +467,13 @@ int calc_manipulator_stats(const bContext *C)
case V3D_MANIP_VIEW:
{
float mat[3][3];
- strcpy(t->spacename, "view");
Mat3CpyMat4(mat, rv3d->viewinv);
Mat3Ortho(mat);
Mat4CpyMat3(rv3d->twmat, mat);
}
break;
default: /* V3D_MANIP_CUSTOM */
- applyTransformOrientation(C, t);
+ // XXX applyTransformOrientation(C, t);
break;
}
@@ -710,7 +669,6 @@ static void draw_manipulator_axes(View3D *v3d, int colcode, int flagx, int flagy
/* only called while G.moving */
static void draw_manipulator_rotate_ghost(View3D *v3d, RegionView3D *rv3d, int drawflags)
{
- TransInfo *t= BIF_GetTransInfo(); // XXX
GLUquadricObj *qobj;
float size, phi, startphi, vec[3], svec[3], matt[4][4], cross[3], tmat[3][3];
int arcs= (G.rt!=2);
@@ -726,7 +684,7 @@ static void draw_manipulator_rotate_ghost(View3D *v3d, RegionView3D *rv3d, int d
/* we need both [4][4] transforms, t->mat seems to be premul, not post for mat[][4] */
Mat4CpyMat4(matt, rv3d->twmat); // to copy the parts outside of [3][3]
- Mat4MulMat34(matt, t->mat, rv3d->twmat);
+// XXX Mat4MulMat34(matt, t->mat, rv3d->twmat);
/* Screen aligned view rot circle */
if(drawflags & MAN_ROT_V) {
@@ -735,15 +693,15 @@ static void draw_manipulator_rotate_ghost(View3D *v3d, RegionView3D *rv3d, int d
glPushMatrix();
size= screen_aligned(rv3d, rv3d->twmat);
- vec[0]= (float)(t->con.imval[0] - t->center2d[0]);
- vec[1]= (float)(t->con.imval[1] - t->center2d[1]);
+ vec[0]= 0; // XXX (float)(t->con.imval[0] - t->center2d[0]);
+ vec[1]= 0; // XXX (float)(t->con.imval[1] - t->center2d[1]);
vec[2]= 0.0f;
Normalize(vec);
startphi= saacos( vec[1] );
if(vec[0]<0.0) startphi= -startphi;
- phi= (float)fmod(180.0*t->val/M_PI, 360.0);
+ phi= 0; // XXX (float)fmod(180.0*t->val/M_PI, 360.0);
if(phi > 180.0) phi-= 360.0;
else if(phi<-180.0) phi+= 360.0;
@@ -755,8 +713,8 @@ static void draw_manipulator_rotate_ghost(View3D *v3d, RegionView3D *rv3d, int d
float imat[3][3], ivmat[3][3];
/* try to get the start rotation */
- svec[0]= (float)(t->con.imval[0] - t->center2d[0]);
- svec[1]= (float)(t->con.imval[1] - t->center2d[1]);
+ svec[0]= 0; // XXX (float)(t->con.imval[0] - t->center2d[0]);
+ svec[1]= 0; // XXX (float)(t->con.imval[1] - t->center2d[1]);
svec[2]= 0.0f;
/* screen aligned vec transform back to manipulator space */
@@ -848,7 +806,6 @@ static void draw_manipulator_rotate_ghost(View3D *v3d, RegionView3D *rv3d, int d
static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving, int drawflags, int combo)
{
- TransInfo *t= BIF_GetTransInfo(); // XXX
GLUquadricObj *qobj;
double plane[4];
float size, vec[3], unitmat[4][4];
@@ -900,8 +857,8 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving,
if(moving) {
float vec[3];
- vec[0]= (float)(t->imval[0] - t->center2d[0]);
- vec[1]= (float)(t->imval[1] - t->center2d[1]);
+ vec[0]= 0; // XXX (float)(t->imval[0] - t->center2d[0]);
+ vec[1]= 0; // XXX (float)(t->imval[1] - t->center2d[1]);
vec[2]= 0.0f;
Normalize(vec);
VecMulf(vec, 1.2f*size);
@@ -917,7 +874,7 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving,
if(moving) {
float matt[4][4];
Mat4CpyMat4(matt, rv3d->twmat); // to copy the parts outside of [3][3]
- Mat4MulMat34(matt, t->mat, rv3d->twmat);
+ // XXX Mat4MulMat34(matt, t->mat, rv3d->twmat);
wmMultMatrix(matt);
glFrontFace( is_mat4_flipped(matt)?GL_CW:GL_CCW);
}
@@ -1121,7 +1078,6 @@ static void drawsolidcube(float size)
static void draw_manipulator_scale(View3D *v3d, RegionView3D *rv3d, int moving, int drawflags, int combo, int colcode)
{
- TransInfo *t= BIF_GetTransInfo(); // XXX
float cywid= 0.25f*0.01f*(float)U.tw_handlesize;
float cusize= cywid*0.75f, dz;
@@ -1153,7 +1109,7 @@ static void draw_manipulator_scale(View3D *v3d, RegionView3D *rv3d, int moving,
float matt[4][4];
Mat4CpyMat4(matt, rv3d->twmat); // to copy the parts outside of [3][3]
- Mat4MulMat34(matt, t->mat, rv3d->twmat);
+ // XXX Mat4MulMat34(matt, t->mat, rv3d->twmat);
wmMultMatrix(matt);
glFrontFace( is_mat4_flipped(matt)?GL_CW:GL_CCW);
}
@@ -1238,7 +1194,6 @@ static void draw_cylinder(GLUquadricObj *qobj, float len, float width)
static void draw_manipulator_translate(View3D *v3d, RegionView3D *rv3d, int moving, int drawflags, int combo, int colcode)
{
- TransInfo *t= BIF_GetTransInfo(); // XXX
GLUquadricObj *qobj;
float cylen= 0.01f*(float)U.tw_handlesize;
float cywid= 0.25f*cylen, dz, size;
@@ -1248,7 +1203,7 @@ static void draw_manipulator_translate(View3D *v3d, RegionView3D *rv3d, int movi
/* when called while moving in mixed mode, do not draw when... */
if((drawflags & MAN_TRANS_C)==0) return;
- if(moving) glTranslatef(t->vec[0], t->vec[1], t->vec[2]);
+ // XXX if(moving) glTranslatef(t->vec[0], t->vec[1], t->vec[2]);
glDisable(GL_DEPTH_TEST);
qobj= gluNewQuadric();
@@ -1314,7 +1269,6 @@ static void draw_manipulator_translate(View3D *v3d, RegionView3D *rv3d, int movi
static void draw_manipulator_rotate_cyl(View3D *v3d, RegionView3D *rv3d, int moving, int drawflags, int combo, int colcode)
{
- TransInfo *t= BIF_GetTransInfo(); // XXX
GLUquadricObj *qobj;
float size;
float cylen= 0.01f*(float)U.tw_handlesize;
@@ -1342,8 +1296,8 @@ static void draw_manipulator_rotate_cyl(View3D *v3d, RegionView3D *rv3d, int mov
if(moving) {
float vec[3];
- vec[0]= (float)(t->imval[0] - t->center2d[0]);
- vec[1]= (float)(t->imval[1] - t->center2d[1]);
+ vec[0]= 0; // XXX (float)(t->imval[0] - t->center2d[0]);
+ vec[1]= 0; // XXX (float)(t->imval[1] - t->center2d[1]);
vec[2]= 0.0f;
Normalize(vec);
VecMulf(vec, 1.2f*size);
@@ -1359,9 +1313,9 @@ static void draw_manipulator_rotate_cyl(View3D *v3d, RegionView3D *rv3d, int mov
if(moving) {
float matt[4][4];
Mat4CpyMat4(matt, rv3d->twmat); // to copy the parts outside of [3][3]
- if (t->flag & T_USES_MANIPULATOR) {
- Mat4MulMat34(matt, t->mat, rv3d->twmat);
- }
+ // XXX if (t->flag & T_USES_MANIPULATOR) {
+ // XXX Mat4MulMat34(matt, t->mat, rv3d->twmat);
+ // XXX }
wmMultMatrix(matt);
}
else {