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:
Diffstat (limited to 'source/blender/editors/transform/transform_generics.c')
-rw-r--r--source/blender/editors/transform/transform_generics.c584
1 files changed, 361 insertions, 223 deletions
diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c
index d79fe98b563..3fc9fe73a5b 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -59,13 +59,10 @@
//#include "BIF_screen.h"
//#include "BIF_mywindow.h"
#include "BIF_gl.h"
-//#include "BIF_editaction.h"
//#include "BIF_editmesh.h"
-//#include "BIF_editnla.h"
//#include "BIF_editsima.h"
//#include "BIF_editparticle.h"
//#include "BIF_meshtools.h"
-#include "BIF_retopo.h"
#include "BKE_action.h"
#include "BKE_anim.h"
@@ -82,6 +79,7 @@
#include "BKE_key.h"
#include "BKE_mesh.h"
#include "BKE_modifier.h"
+#include "BKE_nla.h"
#include "BKE_object.h"
#include "BKE_utildefines.h"
#include "BKE_context.h"
@@ -91,7 +89,9 @@
#include "ED_armature.h"
#include "ED_image.h"
#include "ED_keyframing.h"
+#include "ED_markers.h"
#include "ED_mesh.h"
+#include "ED_retopo.h"
#include "ED_space_api.h"
#include "ED_uvedit.h"
#include "ED_view3d.h"
@@ -103,6 +103,8 @@
#include "BLI_editVert.h"
#include "BLI_rand.h"
+#include "RNA_access.h"
+
#include "WM_types.h"
#include "UI_resources.h"
@@ -115,8 +117,6 @@
extern ListBase editelems;
-extern TransInfo Trans; /* From transform.c */
-
/* ************************** Functions *************************** */
void getViewVector(TransInfo *t, float coord[3], float vec[3])
@@ -155,8 +155,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) {
@@ -175,7 +175,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];
@@ -192,10 +192,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);
@@ -206,22 +206,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;
@@ -248,7 +248,7 @@ static void editbmesh_apply_to_mirror(TransInfo *t)
BMVert *eve;
BMIter iter;
int i;
-
+
for(i = 0 ; i < t->total; i++, td++) {
if (td->flag & TD_NOACTION)
break;
@@ -256,108 +256,45 @@ static void editbmesh_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 */
-void recalcData(TransInfo *t)
+/* tags the given ID block for refreshes (if applicable) due to
+ * Animation Editor editing
+ */
+static void animedit_refresh_id_tags (ID *id)
{
- Scene *scene = t->scene;
- Base *base;
+ AnimData *adt= BKE_animdata_from_id(id);
-#if 0 // TRANSFORM_FIX_ME
- if (t->spacetype == SPACE_ACTION) {
- Object *ob= OBACT;
- void *data;
- short context;
-
- /* determine what type of data we are operating on */
- data = get_action_context(&context);
- if (data == NULL) return;
+ /* tag AnimData for refresh so that other views will update in realtime with these changes */
+ if (adt)
+ adt->recalc |= ADT_RECALC_ANIM;
- /* always flush data if gpencil context */
- if (context == ACTCONT_GPENCIL) {
- flushTransGPactionData(t);
- }
-
- if (G.saction->lock) {
- if (context == ACTCONT_ACTION) {
- if(ob) {
- ob->ctime= -1234567.0f;
- if(ob->pose || ob_get_key(ob))
- DAG_object_flush_update(G.scene, ob, OB_RECALC);
- else
- DAG_object_flush_update(G.scene, ob, OB_RECALC_OB);
- }
- }
- else if (context == ACTCONT_SHAPEKEY) {
- DAG_object_flush_update(G.scene, OBACT, OB_RECALC_OB|OB_RECALC_DATA);
- }
- }
- }
- else if (t->spacetype == SPACE_NLA) {
- if (G.snla->lock) {
- for (base=G.scene->base.first; base; base=base->next) {
- if (base->flag & BA_HAS_RECALC_OB)
- base->object->recalc |= OB_RECALC_OB;
- if (base->flag & BA_HAS_RECALC_DATA)
- base->object->recalc |= OB_RECALC_DATA;
-
- if (base->object->recalc)
- base->object->ctime= -1234567.0f; // eveil!
-
- /* recalculate scale of selected nla-strips */
- if (base->object->nlastrips.first) {
- Object *bob= base->object;
- bActionStrip *strip;
-
- for (strip= bob->nlastrips.first; strip; strip= strip->next) {
- if (strip->flag & ACTSTRIP_SELECT) {
- float actlen= strip->actend - strip->actstart;
- float len= strip->end - strip->start;
-
- strip->scale= len / (actlen * strip->repeat);
- }
- }
- }
- }
-
- DAG_scene_flush_update(G.scene, screen_view3d_layers(), 0);
- }
- else {
- for (base=G.scene->base.first; base; base=base->next) {
- /* recalculate scale of selected nla-strips */
- if (base->object && base->object->nlastrips.first) {
- Object *bob= base->object;
- bActionStrip *strip;
-
- for (strip= bob->nlastrips.first; strip; strip= strip->next) {
- if (strip->flag & ACTSTRIP_SELECT) {
- float actlen= strip->actend - strip->actstart;
- float len= strip->end - strip->start;
-
- /* prevent 'negative' scaling */
- if (len < 0) {
- SWAP(float, strip->start, strip->end);
- len= fabs(len);
- }
-
- /* calculate new scale */
- strip->scale= len / (actlen * strip->repeat);
- }
- }
- }
- }
+ /* if ID-block is Object, set recalc flags */
+ // TODO: this should probably go through the depsgraph instead... but for now, let's be lazy
+ switch (GS(id->name)) {
+ case ID_OB:
+ {
+ Object *ob= (Object *)id;
+ ob->recalc |= OB_RECALC;
}
+ break;
}
-#endif
+}
+
+/* called for updating while transform acts, once per redraw */
+void recalcData(TransInfo *t)
+{
+ Scene *scene = t->scene;
+ Base *base;
+
if (t->obedit) {
}
else if(G.f & G_PARTICLEEDIT) {
@@ -369,6 +306,41 @@ void recalcData(TransInfo *t)
else if (t->spacetype==SPACE_SEQ) {
flushTransSeq(t);
}
+ else if (t->spacetype == SPACE_ACTION) {
+ SpaceAction *sact= (SpaceAction *)t->sa->spacedata.first;
+ Scene *scene;
+
+ bAnimContext ac;
+ ListBase anim_data = {NULL, NULL};
+ bAnimListElem *ale;
+ int filter;
+
+ /* 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);
+
+ /* get animdata blocks visible in editor, assuming that these will be the ones where things changed */
+ filter= (ANIMFILTER_VISIBLE | ANIMFILTER_ANIMDATA);
+ ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
+
+ /* just tag these animdata-blocks to recalc, assuming that some data there changed */
+ for (ale= anim_data.first; ale; ale= ale->next) {
+ /* set refresh tags for objects using this animation */
+ animedit_refresh_id_tags(ale->id);
+ }
+
+ /* now free temp channels */
+ BLI_freelistN(&anim_data);
+ }
else if (t->spacetype == SPACE_IPO) {
SpaceIpo *sipo= (SpaceIpo *)t->sa->spacedata.first;
Scene *scene;
@@ -404,33 +376,207 @@ void recalcData(TransInfo *t)
/* 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;
+ AnimData *adt= BKE_animdata_from_id(ale->id);
/* watch it: if the time is wrong: do not correct handles yet */
if (test_time_fcurve(fcu))
dosort++;
else
calchandles_fcurve(fcu);
+
+ /* set refresh tags for objects using this animation */
+ animedit_refresh_id_tags(ale->id);
}
/* 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);
+ }
+ else if (t->spacetype == SPACE_NLA) {
+ TransDataNla *tdn= (TransDataNla *)t->customData;
+ SpaceNla *snla= (SpaceNla *)t->sa->spacedata.first;
+ Scene *scene= t->scene;
+ double secf= FPS;
+ int i;
- /* update realtime - not working? */
- if (sipo->lock) {
-
+ /* 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)
+ */
+ for (i = 0; i < t->total; i++, tdn++) {
+ NlaStrip *strip= tdn->strip;
+ 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;
+
+ /* set refresh tags for objects using this animation */
+ animedit_refresh_id_tags(tdn->id);
+
+ /* 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
+ * 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
+ * (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)
+ */
+ 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
+ * - if there were no neighbours, clear the transforms (make it default to the strip's current values)
+ */
+ if (strip->prev && strip->next) {
+ tdn->h1[0]= strip->prev->end;
+ tdn->h2[0]= strip->next->start;
+ }
+ else {
+ tdn->h1[0]= strip->start;
+ tdn->h2[0]= strip->end;
+ }
+ }
+ 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 */
+ if (snla->flag & SNLA_DRAWTIME) {
+ tdn->h1[0]= (float)( floor((tdn->h1[0]/secf) + 0.5f) * secf );
+ tdn->h2[0]= (float)( floor((tdn->h2[0]/secf) + 0.5f) * secf );
+ }
+ else {
+ tdn->h1[0]= (float)( floor(tdn->h1[0]+0.5f) );
+ 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
+ * - 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,
+ * stopping on the last track available or that we're able to fit in
+ */
+ if (delta > 0) {
+ for (track=tdn->nlt->next, n=0; (track) && (n < delta); track=track->next, 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 */
+ }
+ else /* can't move any further */
+ break;
+ }
+ }
+ 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 */
+ }
+ else /* can't move any further */
+ break;
+ }
+ }
+ }
}
}
else if (t->obedit) {
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 */
@@ -450,7 +596,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) {
@@ -460,7 +606,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 {
BMEditMesh *em = ((Mesh*)t->obedit->data)->edit_btmesh;
@@ -475,11 +621,11 @@ void recalcData(TransInfo *t)
}
if((t->options & CTX_NO_MIRROR) == 0 && (t->flag & T_MIRROR))
editbmesh_apply_to_mirror(t);
-
+
DAG_object_flush_update(scene, t->obedit, OB_RECALC_DATA); /* sets recalc flags */
-
- BMEdit_RecalcTesselation(em);
+
EDBM_RecalcNormals(em);
+ BMEdit_RecalcTesselation(em);
}
}
else if(t->obedit->type==OB_ARMATURE) { /* no recalc flag, does pose */
@@ -488,10 +634,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){
@@ -504,7 +650,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) {
@@ -524,8 +670,8 @@ void recalcData(TransInfo *t)
ebo->oldlength= ebo->length;
}
}
-
-
+
+
if (t->mode != TFM_BONE_ROLL)
{
/* fix roll */
@@ -535,10 +681,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);
@@ -550,15 +696,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 */
@@ -566,7 +712,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)
@@ -577,7 +723,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 */
@@ -588,13 +734,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,
@@ -607,13 +753,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 */
@@ -625,22 +771,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;
}
@@ -649,13 +795,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();
}
}
@@ -668,20 +814,22 @@ void resetTransRestrictions(TransInfo *t)
int initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event)
{
Scene *sce = CTX_data_scene(C);
+ ToolSettings *ts = CTX_data_tool_settings(C);
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;
t->obedit = obedit;
+ t->settings = ts;
t->data = NULL;
t->ext = NULL;
@@ -689,14 +837,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
@@ -704,7 +852,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];
@@ -721,27 +869,27 @@ 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;
if (op && RNA_struct_find_property(op->ptr, "constraint_axis") && RNA_property_is_set(op->ptr, "constraint_orientation"))
{
- t->current_orientation = RNA_int_get(op->ptr, "constraint_orientation");
+ t->current_orientation = RNA_enum_get(op->ptr, "constraint_orientation");
if (t->current_orientation >= V3D_MANIP_CUSTOM + BIF_countTransformOrientation(C) - 1)
{
@@ -755,15 +903,16 @@ int initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event)
}
else if(t->spacetype==SPACE_IMAGE || t->spacetype==SPACE_NODE)
{
+ SpaceImage *sima = sa->spacedata.first;
// XXX for now, get View2D from the active region
t->view = &ar->v2d;
- t->around = ar->v2d.around;
+ t->around = sima->around;
}
else
{
// XXX for now, get View2D from the active region
t->view = &ar->v2d;
-
+
t->around = V3D_CENTER;
}
@@ -777,7 +926,7 @@ int initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event)
// Need stuff to take it from edit mesh or whatnot here
else
{
- if (t->obedit && t->obedit->type == OB_MESH && sce->toolsettings->editbutflag & B_MESH_X_MIRROR)
+ if (t->obedit && t->obedit->type == OB_MESH && ts->editbutflag & B_MESH_X_MIRROR)
{
t->flag |= T_MIRROR;
}
@@ -797,10 +946,10 @@ int initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event)
}
else
{
- if ((t->options & CTX_NO_PET) == 0 && (sce->proportional)) {
+ if ((t->options & CTX_NO_PET) == 0 && (ts->proportional)) {
t->flag |= T_PROP_EDIT;
-
- if(sce->proportional == 2)
+
+ if(ts->proportional == 2)
t->flag |= T_PROP_CONNECTED; // yes i know, has to become define
}
}
@@ -811,16 +960,16 @@ int initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event)
}
else
{
- t->prop_size = sce->toolsettings->proportional_size;
+ 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");
}
else
{
- t->prop_mode = sce->prop_mode;
+ t->prop_mode = ts->prop_mode;
}
/* TRANSFORM_FIX_ME rna restrictions */
@@ -832,12 +981,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;
@@ -845,7 +994,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;
@@ -853,7 +1002,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);
}
@@ -869,21 +1018,15 @@ void postTrans (TransInfo *t)
if(sima->flag & SI_LIVE_UNWRAP)
ED_uvedit_live_unwrap_end(t->state == TRANS_CANCEL);
}
- else if(t->spacetype==SPACE_ACTION) {
+ else if(ELEM(t->spacetype, SPACE_ACTION, SPACE_NLA)) {
if (t->customData)
MEM_freeN(t->customData);
- } else if (t->spacetype==SPACE_VIEW3D) {
- if (t->obedit) {
- /*retesselate*/
- //EDBM_Tesselate(((Mesh*)t->obedit->data)->edit_mesh);
- }
- }
-}
+ }}
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) {
@@ -892,9 +1035,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)
@@ -927,15 +1070,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);
@@ -943,7 +1086,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);
@@ -953,13 +1096,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);
}
@@ -968,7 +1111,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);
@@ -989,13 +1132,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);
}
@@ -1003,13 +1146,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);
@@ -1020,7 +1163,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))
@@ -1030,8 +1173,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;
@@ -1056,8 +1199,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;
@@ -1074,7 +1217,7 @@ void calculateCenterBound(TransInfo *t)
calculateCenter2D(t);
}
-void calculateCenter(TransInfo *t)
+void calculateCenter(TransInfo *t)
{
switch(t->around) {
case V3D_CENTER:
@@ -1106,7 +1249,7 @@ void calculateCenter(TransInfo *t)
break;
} /* END EDIT MODE ACTIVE ELEMENT */
#endif
-
+
calculateCenterMedian(t);
if((t->flag & (T_EDIT|T_POSE))==0)
{
@@ -1118,7 +1261,7 @@ void calculateCenter(TransInfo *t)
projectIntView(t, t->center, t->center2d);
}
}
-
+
}
}
@@ -1138,21 +1281,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)
{
@@ -1161,7 +1304,7 @@ void calculateCenter(TransInfo *t)
}
}
}
- }
+ }
if(t->spacetype==SPACE_VIEW3D)
{
@@ -1169,14 +1312,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]);
- }
+ }
}
}
@@ -1186,18 +1329,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.
*/
@@ -1209,7 +1352,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
@@ -1217,7 +1360,7 @@ void calculatePropRatio(TransInfo *t)
*/
if (dist < 0.0f)
dist = 0.0f;
-
+
switch(t->prop_mode) {
case PROP_SHARP:
td->factor= dist*dist;
@@ -1280,24 +1423,19 @@ void calculatePropRatio(TransInfo *t)
}
}
-TransInfo *BIF_GetTransInfo()
-{
- return NULL;
-}
-
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 */