Game Development Community

dev|Pro Game Development Curriculum

World Editor Precision Movment

by Pascal · 12/26/2003 (9:42 am) · 3 comments

When dragging objects in the world editor with your mouse, (either by just moving the bounding box or by selecting one of the axes) the object will always move a set amount. How far the move is controled by the
"mouseMoveScale" field of the WorldEditor and is adjustable in the
"World Editor Settings" dialog found on the edit menu.

I've often found that this value is usually for precisely placing objects, but whenever I make it smaller, moving objects larger distances
is a pain. Here's a quick two line fix to allow more precise movement:

In engine/editor/worldEditor.cc , in the on3DMouseDragged function (around line 1980), make the bolded addition:
if( mAxisGizmoSelAxis != 2 ) {
    offset = ( event.mousePoint.x - mHitMousePos.x ) * mMouseMoveScale;
    [b]offset *= ((event.modifier & SI_SHIFT)?0.25f:((event.modifier & SI_ALT)?0.05:1.0f));[/b]
               
    Point3F cv, camVector, objVector;   
    S32 col = ( mAxisGizmoSelAxis != 0 ); 
               
    smCamMatrix.getColumn( 1, &camVector );
    mSelected[0]->getTransform().getColumn( col, &objVector );
               
    mCross( objVector, camVector, &cv );
    if( cv.z < 0 )
      offset *= -1;
}
else [b]{[/b]
    offset = ( event.mousePoint.y - mHitMousePos.y ) * mMouseMoveScale * -1;
    [b]offset *= ((event.modifier & SI_SHIFT)?0.25f:((event.modifier & SI_ALT)?0.05:1.0f));[/b]
[b]}[/b]

(Dont forget the new curly brackets on the else)

What this change does is scale the movement depending on whether the shift key (1/4 distance) or alt key (1/20 distance) is being pressed while the mouse is dragged. Since these modifier keys have different meanings onMouseDown, they only work if the mouse button has already been pressed (in other words when you are already dragging the object around).

Hope this helps someone out as it was a timesaver for me.

-Pascal

#1
12/28/2003 (1:40 pm)
Bravo Pascal! I've been thinking that some kind of nudge action would help in placement also. For instance, if you are moving the x-axis a certain key would move it a certain predetermined distance to the left. Another key for the right, and so on for the y and z-axes. I suppose this would implement a total of six keys, but maybe a modifier key could be implemented for the z-axis. This implementation would override the need for the mouse which requires steady movement.

Another nifty feature would be a "magnet" effect to bring items in alignment with others. The magnet feature could be toggled on or off depending on when it is needed and it could be set to various tolerances.

I don't know how to code, but I've seen these features in various editing programs and they're a timesaver.

In any case, your snippet adds much more functionality to the World Editor. Thanks!


solo
#2
02/20/2004 (9:20 am)
Pascal.

Just so you know ... I've implemented this to my build. Thanks for sharing it. :)

Alex
#3
06/09/2005 (2:48 pm)
Hi,

thank You.

As SI_SHIFT is in use for worldtransition, one should use SI_CTRL, which worked fine for me.

Starvanger