|
@@ -162,8 +162,9 @@ void la_PopulateSelectPoints(MSelectData* sd, tnsShapeObject* so){
|
|
|
if(so->Base.Type!=TNS_OBJECT_SHAPE||!so->Shapes.pFirst){ return; }
|
|
|
for(tnsShape*s=so->Shapes.pFirst;s;s=s->Item.pNext){
|
|
|
for(tnsSPoint*sp=s->Points.pFirst;sp;sp=sp->Item.pNext){
|
|
|
- arrEnsureLength(&sd->RefsV, sd->nextV, &sd->maxV, sizeof(tnsSPoint*));
|
|
|
- sd->RefsV[sd->nextV]=sp; sd->nextV++;
|
|
|
+ arrEnsureLength(&sd->RefsV, sd->nextV+3, &sd->maxV, sizeof(tnsSPoint*));
|
|
|
+ sd->RefsV[sd->nextV]=sp; sd->RefsV[sd->nextV+1]=sp; sd->RefsV[sd->nextV+2]=sp;
|
|
|
+ sd->nextV+=3;
|
|
|
}
|
|
|
}
|
|
|
sd->nextV++;
|
|
@@ -326,8 +327,8 @@ void la_DoMeshSelect(tnsMeshObject* mo, void* p, int WhatPrim, int DeselectAll,
|
|
|
if(p){ if(WhatPrim==LA_CANVAS_SELECT_MODE_VERTS) tnsMMeshSelectVert(mo,p,Select,Toggle);
|
|
|
elif(WhatPrim==LA_CANVAS_SELECT_MODE_EDGES) tnsMMeshSelectEdge(mo,p,Select,Toggle); }
|
|
|
}
|
|
|
-void la_DoShapeSelect(tnsShapeObject* so, void* p, int DeselectAll, int Select, int Toggle){
|
|
|
- if(DeselectAll){ tnsShapeDeselectAll(so); } if(p) tnsShapeSelectPoint(so,p,Select,Toggle);
|
|
|
+void la_DoShapeSelect(tnsShapeObject* so, void* p, int lr, int DeselectAll, int Select, int Toggle){
|
|
|
+ if(DeselectAll){ tnsShapeDeselectAll(so); } if(p) tnsShapeSelectPoint(so,p,Select,Toggle,lr);
|
|
|
}
|
|
|
|
|
|
#define LA_SELECT_MODE_BOX 1
|
|
@@ -397,7 +398,7 @@ int OPINV_Select(laOperator *a, laEvent *e){
|
|
|
}
|
|
|
int elemtype,id=la_SelectGetClosest(sd, e->x-ui->L, e->y-ui->U, LA_RH,&elemtype)-1;
|
|
|
void* p=la_SelectGetRef(sd,id,elemtype);
|
|
|
- la_DoShapeSelect(mo, p, DeselectAll, 1, 1);
|
|
|
+ la_DoShapeSelect(mo, p, id%3, DeselectAll, 1, 1);
|
|
|
if(ring_band && p){ tnsShapeSelectRingFrom(mo,p,1,Append); }
|
|
|
laNotifyUsers("tns.world"); laRecordAndPush(0,"tns.world","Shape selection",TNS_HINT_GEOMETRY);
|
|
|
}else{
|
|
@@ -446,11 +447,11 @@ int OPMOD_Select(laOperator *a, laEvent *e){
|
|
|
tnsMMeshEnsureSelection(mo,ex->SelectMode);
|
|
|
tnsInvalidateMeshBatch(mo);
|
|
|
}elif(o && o->Type==TNS_OBJECT_SHAPE && so->Mode==TNS_MESH_EDIT_MODE){ is_geo=1;
|
|
|
- la_DoShapeSelect(so, 0, DeselectAll, 0, 0);
|
|
|
+ la_DoShapeSelect(so, 0, 0, DeselectAll, 0, 0);
|
|
|
int len; int* ids=la_SelectGetBox(se->sd, ex->ClickedX-ui->L, ex->ClickedY-ui->U, e->x-ui->L, e->y-ui->U, &len);
|
|
|
for(int i=0;i<len;i++){
|
|
|
int id=ids[i]-1; void* p=la_SelectGetRef(se->sd,id,ex->SelectMode==LA_CANVAS_SELECT_MODE_EDGES?TNS_MMESH_EDGE_BIT:0);
|
|
|
- la_DoShapeSelect(so, p, 0, !Remove, 0);
|
|
|
+ la_DoShapeSelect(so, p, id%3, 0, !Remove, 0);
|
|
|
}
|
|
|
}else{
|
|
|
la_DoObjectSelect(se->root, 0, ex, DeselectAll, 0, 0);
|
|
@@ -491,8 +492,8 @@ STRUCTURE(MTOrigMVert){
|
|
|
tnsMVert* mv;
|
|
|
};
|
|
|
STRUCTURE(MTOrigSPoint){
|
|
|
- tnsVector2d p;
|
|
|
- tnsVector2d origp;
|
|
|
+ tnsVector2d p,pl,pr;
|
|
|
+ tnsVector2d origp,origdl,origdr;
|
|
|
tnsSPoint* sp;
|
|
|
};
|
|
|
STRUCTURE(MTransformData){
|
|
@@ -533,6 +534,9 @@ MTransformData* la_InitTransformData(int w, int h, tnsCamera* c, int CanvasDelta
|
|
|
void la_GetTransformInitialScale(MTransformData* td, laUiItem* ui, int x, int y){ td->Initial=tnsDistIdv2(x-ui->L,y-ui->U,td->CenterX,td->CenterY); }
|
|
|
void la_GetTransformInitialRotation(MTransformData* td, laUiItem* ui, int x, int y){ td->Initial=atan2(y-ui->U-td->CenterY,x-ui->L-td->CenterX); }
|
|
|
void la_GetTransformCenter2D(MTransformData* td){
|
|
|
+ if(td->Is2D||td->so){
|
|
|
+ { td->CenterX=td->w/2; td->CenterY=td->h/2; } return;
|
|
|
+ }
|
|
|
tnsVector4d vp; tnsApplyTransform44d(vp,td->ViewProjection,td->TCenter);
|
|
|
if(td->c->CameraType==TNS_CAMERA_PERSP){ tnsVectorMultiSelf3d(vp, 1/vp[3]); }
|
|
|
td->CenterX = (vp[0]/2+0.5f)*td->w; td->CenterY=(-vp[1]/2+0.5f)*td->h;
|
|
@@ -559,7 +563,7 @@ int la_PopulateTransformObjects(MTransformData* td, tnsObject* root){
|
|
|
return any;
|
|
|
}
|
|
|
int la_PopulateTransformVerticies(MTransformData* td, tnsMeshObject* mo){
|
|
|
- int any=0; td->mo=mo;
|
|
|
+ int any=0; td->mo=mo; td->next=0;
|
|
|
arrEnsureLength(&td->Originals, 0, &td->max, sizeof(MTOrigMVert));
|
|
|
tnsInverse44d(td->obmatinv, mo->Base.GlobalTransform);
|
|
|
tnsInverse44d(td->deltainv, mo->Base.DeltaTransform);
|
|
@@ -586,12 +590,22 @@ int la_PopulateTransformPoints(MTransformData* td, tnsShapeObject* so){
|
|
|
tnsInverse44d(td->deltainv, so->Base.DeltaTransform);
|
|
|
for(tnsShape* s=so->Shapes.pFirst;s;s=s->Item.pNext){
|
|
|
for(tnsSPoint* sp=s->Points.pFirst;sp;sp=sp->Item.pNext){
|
|
|
- if(!(sp->flags&TNS_MESH_FLAG_SELECTED)) continue;
|
|
|
+ if(!(sp->flags&TNS_SPOINT_SELECTED)) continue;
|
|
|
+ int addl=0,addr=0,addmain=0;
|
|
|
+ if(sp->flags&TNS_MESH_FLAG_SELECTED) addmain=1;
|
|
|
+ elif(sp->flags&TNS_SPOINT_BEZIER){
|
|
|
+ if(sp->flags&TNS_SPOINT_SELECTED_L) addl=1; if(sp->flags&TNS_SPOINT_SELECTED_R) addr=1;
|
|
|
+ if(sp->flags&TNS_SPOINT_ALIGNED){ if(addl&&addr){ addmain=1; } }
|
|
|
+ }
|
|
|
arrEnsureLength(&td->Originals, td->next, &td->max, sizeof(MTOrigSPoint));
|
|
|
MTOrigSPoint* to=arrElement(td->Originals, td->next, sizeof(MTOrigSPoint)); td->next++; to->sp=sp;
|
|
|
- tnsVector3d tp; tnsVector3d fp={sp->p[0],sp->p[1],0};
|
|
|
- tnsApplyTransform43d(tp, so->Base.GlobalTransform, fp);
|
|
|
- tnsVectorSet2v(to->p,tp); tnsVectorSet2v(to->origp,sp->p); any++;
|
|
|
+ tnsVector3d tp; tnsVector3d fp={sp->p[0],sp->p[1],0},
|
|
|
+ fpl={sp->p[0]+sp->dl[0],sp->p[1]+sp->dl[1],0},fpr={sp->p[0]+sp->dr[0],sp->p[1]+sp->dr[1],0};
|
|
|
+ tnsApplyTransform43d(tp, so->Base.GlobalTransform, fp); tnsVectorSet2v(to->p,tp);
|
|
|
+ tnsApplyTransform43d(tp, so->Base.GlobalTransform, fpl); tnsVectorSet2v(to->pl,tp);
|
|
|
+ tnsApplyTransform43d(tp, so->Base.GlobalTransform, fpr); tnsVectorSet2v(to->pr,tp);
|
|
|
+ tnsVectorSet2v(to->origp,sp->p); tnsVectorSet2v(to->origdl,sp->dl); tnsVectorSet2v(to->origdr,sp->dr);
|
|
|
+ any++;
|
|
|
tnsVectorAccum2d(td->TCenter,to->p);
|
|
|
tnsVectorAccum2d(td->TLCenter,sp->p);
|
|
|
}
|
|
@@ -604,7 +618,7 @@ int la_PopulateTransformPoints(MTransformData* td, tnsShapeObject* so){
|
|
|
void la_ApplyTranslation(MTransformData* td, int x, int y){
|
|
|
tnsMatrix44d trans; tnsVector3d deltay,delta; tnsVector3d gp; tnsVector3d use_delta;
|
|
|
if(td->Is2D || td->so){
|
|
|
- use_delta[0]=x*(td->so?(1.0f/LA_RH):td->zoomx); use_delta[1]=-y*(td->so?(1.0f/LA_RH):td->zoomy); use_delta[2]=0;
|
|
|
+ use_delta[0]=x*(td->Is2D?td->zoomx:(1.0f/LA_RH)); use_delta[1]=-y*(td->Is2D?td->zoomy:(1.0f/LA_RH)); use_delta[2]=0;
|
|
|
if(td->LockAxis[0]){ use_delta[1]=0; } if(td->LockAxis[1]){ use_delta[0]=0; }
|
|
|
}else{
|
|
|
tnsVectorMulti3d(delta, td->Right, x); tnsVectorMulti3d(deltay, td->Up, y); tnsVectorAccum3d(delta, deltay);
|
|
@@ -637,8 +651,21 @@ void la_ApplyTranslation(MTransformData* td, int x, int y){
|
|
|
if(!td->UseLocal) tnsMultiply44d(final,td->obmatinv,trans);
|
|
|
else tnsMultiply44d(final,trans,td->obmatinv);
|
|
|
for(int i=0;i<td->next;i++){ MTOrigSPoint* to=arrElement(td->Originals, i, sizeof(MTOrigSPoint));
|
|
|
- tnsVector3d fp={to->p[0],to->p[1],0}, tp;
|
|
|
- tnsApplyTransform43d(tp, final, fp); tnsVectorSet3v(to->sp->p,tp);
|
|
|
+ tnsVector3d fp={to->p[0],to->p[1],0}, tp, tpl, tpr, fpl={to->pl[0],to->pl[1],0},fpr={to->pr[0],to->pr[1],0};
|
|
|
+ if((to->sp->flags&TNS_SPOINT_BEZIER) && (!(to->sp->flags&TNS_MESH_FLAG_SELECTED))){
|
|
|
+ if(to->sp->flags&TNS_SPOINT_SELECTED_L){ tnsApplyTransform43d(tpl, final, fpl); tnsVectorMinus2d(to->sp->dl,tpl,to->sp->p);
|
|
|
+ if(to->sp->flags&TNS_SPOINT_ALIGNED){ real len=tnsLength2d(to->origdr);
|
|
|
+ tnsVectorMulti2d(to->sp->dr,to->sp->dl,-1*len/tnsLength2d(to->sp->dl));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(to->sp->flags&TNS_SPOINT_SELECTED_R){ tnsApplyTransform43d(tpr, final, fpr); tnsVectorMinus2d(to->sp->dr,tpr,to->sp->p);
|
|
|
+ if(to->sp->flags&TNS_SPOINT_ALIGNED){ real len=tnsLength2d(to->origdl);
|
|
|
+ tnsVectorMulti2d(to->sp->dl,to->sp->dr,-1*len/tnsLength2d(to->sp->dr));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ tnsApplyTransform43d(tp, final, fp); tnsVectorSet2v(to->sp->p,tp);
|
|
|
+ }
|
|
|
}
|
|
|
}else{
|
|
|
for(int i=0;i<td->next;i++){
|
|
@@ -681,8 +708,23 @@ void la_ApplyScale(MTransformData* td, int uix, int uiy){
|
|
|
tnsInvalidateMeshBatch(td->mo); tnsMMeshCalculateNormal(td->mo);
|
|
|
}elif(td->so){
|
|
|
for(int i=0;i<td->next;i++){ MTOrigSPoint* to=arrElement(td->Originals, i, sizeof(MTOrigSPoint));
|
|
|
- tnsVector3d fp={to->p[0],to->p[1],0}, tp;
|
|
|
- tnsApplyTransform43d(tp, final, fp); tnsVectorSet3v(to->sp->p,tp);
|
|
|
+ tnsVector3d fp={to->p[0],to->p[1],0}, tp, tpl, tpr, fpl={to->pl[0],to->pl[1],0},fpr={to->pr[0],to->pr[1],0};
|
|
|
+ int domain=0;
|
|
|
+ if(to->sp->flags&TNS_MESH_FLAG_SELECTED){
|
|
|
+ tnsApplyTransform43d(tp, final, fp); tnsVectorSet2v(to->sp->p,tp); domain=1;
|
|
|
+ }
|
|
|
+ if((to->sp->flags&TNS_SPOINT_BEZIER)){
|
|
|
+ if((to->sp->flags&TNS_SPOINT_SELECTED_L) || domain){ tnsApplyTransform43d(tpl, final, fpl); tnsVectorMinus2d(to->sp->dl,tpl,to->sp->p);
|
|
|
+ if((to->sp->flags&TNS_SPOINT_ALIGNED) && (!domain)){ real len=tnsLength2d(to->origdr);
|
|
|
+ tnsVectorMulti2d(to->sp->dr,to->sp->dl,-1*len/tnsLength2d(to->sp->dl));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if((to->sp->flags&TNS_SPOINT_SELECTED_R) || domain){ tnsApplyTransform43d(tpr, final, fpr); tnsVectorMinus2d(to->sp->dr,tpr,to->sp->p);
|
|
|
+ if((to->sp->flags&TNS_SPOINT_ALIGNED) && (!domain)){ real len=tnsLength2d(to->origdl);
|
|
|
+ tnsVectorMulti2d(to->sp->dl,to->sp->dr,-1*len/tnsLength2d(to->sp->dr));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}else{
|
|
|
for(int i=0;i<td->next;i++){
|
|
@@ -718,8 +760,23 @@ void la_ApplyRotation(MTransformData* td, int uix, int uiy){
|
|
|
tnsInvalidateMeshBatch(td->mo); tnsMMeshCalculateNormal(td->mo);
|
|
|
}elif(td->so){
|
|
|
for(int i=0;i<td->next;i++){ MTOrigSPoint* to=arrElement(td->Originals, i, sizeof(MTOrigSPoint));
|
|
|
- tnsVector3d fp={to->p[0],to->p[1],0}, tp;
|
|
|
- tnsApplyTransform43d(tp, final, fp); tnsVectorSet3v(to->sp->p,tp);
|
|
|
+ tnsVector3d fp={to->p[0],to->p[1],0}, tp, tpl, tpr, fpl={to->pl[0],to->pl[1],0},fpr={to->pr[0],to->pr[1],0};
|
|
|
+ int domain=0;
|
|
|
+ if(to->sp->flags&TNS_MESH_FLAG_SELECTED){
|
|
|
+ tnsApplyTransform43d(tp, final, fp); tnsVectorSet2v(to->sp->p,tp); domain=1;
|
|
|
+ }
|
|
|
+ if((to->sp->flags&TNS_SPOINT_BEZIER)){
|
|
|
+ if((to->sp->flags&TNS_SPOINT_SELECTED_L) || domain){ tnsApplyTransform43d(tpl, final, fpl); tnsVectorMinus2d(to->sp->dl,tpl,to->sp->p);
|
|
|
+ if((to->sp->flags&TNS_SPOINT_ALIGNED) && (!domain)){ real len=tnsLength2d(to->origdr);
|
|
|
+ tnsVectorMulti2d(to->sp->dr,to->sp->dl,-1*len/tnsLength2d(to->sp->dl));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if((to->sp->flags&TNS_SPOINT_SELECTED_R) || domain){ tnsApplyTransform43d(tpr, final, fpr); tnsVectorMinus2d(to->sp->dr,tpr,to->sp->p);
|
|
|
+ if((to->sp->flags&TNS_SPOINT_ALIGNED) && (!domain)){ real len=tnsLength2d(to->origdl);
|
|
|
+ tnsVectorMulti2d(to->sp->dl,to->sp->dr,-1*len/tnsLength2d(to->sp->dr));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}else{
|
|
|
for(int i=0;i<td->next;i++){
|
|
@@ -741,7 +798,9 @@ void la_CancelTransformObjects(MTransformData* td){
|
|
|
for(int i=0;i<td->next;i++){ MTOrigMVert* to=arrElement(td->Originals, i, sizeof(MTOrigMVert)); tnsVectorCopy3d(to->origp,to->mv->p); }
|
|
|
tnsInvalidateMeshBatch(td->mo);
|
|
|
}elif(td->so){
|
|
|
- for(int i=0;i<td->next;i++){ MTOrigSPoint* to=arrElement(td->Originals, i, sizeof(MTOrigSPoint)); tnsVectorCopy2d(to->origp,to->sp->p); }
|
|
|
+ for(int i=0;i<td->next;i++){ MTOrigSPoint* to=arrElement(td->Originals, i, sizeof(MTOrigSPoint));
|
|
|
+ tnsVectorCopy2d(to->origp,to->sp->p); tnsVectorCopy2d(to->origdl,to->sp->dl); tnsVectorCopy2d(to->origdr,to->sp->dr);
|
|
|
+ }
|
|
|
}else{
|
|
|
for(int i=0;i<td->next;i++){ MTOrigObject* to=arrElement(td->Originals, i, sizeof(MTOrigObject));
|
|
|
if(to->Discard){ tnsSelfMatrixChanged(to->o,1); continue; }
|
|
@@ -749,7 +808,6 @@ void la_CancelTransformObjects(MTransformData* td){
|
|
|
if(td->CanvasDeltaMode) tnsGlobalMatrixChangedForDelta(to->o, 1);
|
|
|
else tnsGlobalMatrixChanged(to->o, 1);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
void la_RecordTransformDifferences(MTransformData* td){
|
|
@@ -816,7 +874,7 @@ int la_InitTransform(laOperator* a, laEvent* e, int mode, int restore_type, int
|
|
|
int ret=0;
|
|
|
if(o && o->Type==TNS_OBJECT_MESH && mo->Mode==TNS_MESH_EDIT_MODE){
|
|
|
if(la_PopulateTransformVerticies(td, mo)){ ex->ClickedX=e->x; ex->ClickedY=e->y; ret=1; }
|
|
|
- }if(o && o->Type==TNS_OBJECT_SHAPE && so->Mode==TNS_MESH_EDIT_MODE){
|
|
|
+ }elif(o && o->Type==TNS_OBJECT_SHAPE && so->Mode==TNS_MESH_EDIT_MODE){
|
|
|
if(la_PopulateTransformPoints(td, so)){ ex->ClickedX=e->x; ex->ClickedY=e->y; ret=1; }
|
|
|
}else{
|
|
|
if(la_PopulateTransformObjects(td,root)){ ex->ClickedX=e->x; ex->ClickedY=e->y; ret=1; }
|