=== Snap Menu ===
New Cursor-> Active option Useful on Edit Mesh too!
This commit is contained in:
@@ -1518,6 +1518,57 @@ void snap_curs_to_sel()
|
||||
allqueue(REDRAWVIEW3D, 0);
|
||||
}
|
||||
|
||||
void snap_curs_to_active()
|
||||
{
|
||||
float *curs;
|
||||
curs = give_cursor();
|
||||
|
||||
if (G.obedit)
|
||||
{
|
||||
if (G.obedit->type == OB_MESH)
|
||||
{
|
||||
/* check active */
|
||||
if (G.editMesh->selected.last) {
|
||||
EditSelection *ese = G.editMesh->selected.last;
|
||||
if ( ese->type == EDITVERT ) {
|
||||
EditVert *eve = (EditVert *)ese->data;
|
||||
VECCOPY(curs, eve->co);
|
||||
}
|
||||
else if ( ese->type == EDITEDGE ) {
|
||||
EditEdge *eed = (EditEdge *)ese->data;
|
||||
VecAddf(curs, eed->v1->co, eed->v2->co);
|
||||
VecMulf(curs, 0.5f);
|
||||
}
|
||||
else if ( ese->type == EDITFACE ) {
|
||||
EditFace *efa = (EditFace *)ese->data;
|
||||
|
||||
if (efa->v4)
|
||||
{
|
||||
VecAddf(curs, efa->v1->co, efa->v2->co);
|
||||
VecAddf(curs, curs, efa->v3->co);
|
||||
VecAddf(curs, curs, efa->v4->co);
|
||||
VecMulf(curs, 0.25f);
|
||||
}
|
||||
else
|
||||
{
|
||||
VecAddf(curs, efa->v1->co, efa->v2->co);
|
||||
VecAddf(curs, curs, efa->v3->co);
|
||||
VecMulf(curs, 1/3.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
Mat4MulVecfl(G.obedit->obmat, curs);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (BASACT)
|
||||
{
|
||||
VECCOPY(curs, BASACT->object->obmat[3]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void snap_curs_to_firstsel()
|
||||
{
|
||||
TransVert *tv;
|
||||
@@ -1776,7 +1827,7 @@ void snapmenu()
|
||||
{
|
||||
short event;
|
||||
|
||||
event = pupmenu("Snap %t|Selection -> Grid%x1|Selection -> Cursor%x2|Cursor-> Grid%x3|Cursor-> Selection%x4|Selection-> Center%x5");
|
||||
event = pupmenu("Snap %t|Selection -> Grid%x1|Selection -> Cursor%x2|Cursor-> Grid%x3|Cursor-> Selection%x4|Selection-> Center%x5|Cursor-> Active%x6");
|
||||
|
||||
switch (event) {
|
||||
case 1: /*Selection to grid*/
|
||||
@@ -1797,6 +1848,10 @@ void snapmenu()
|
||||
snap_to_center();
|
||||
BIF_undo_push("Snap selection to center");
|
||||
break;
|
||||
case 6: /*Cursor to Active*/
|
||||
snap_curs_to_active();
|
||||
BIF_undo_push("Snap selection to center");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user