MCPcopy Create free account
hub / github.com/GarageGames/Torque3D / registerSnap

Method registerSnap

Engine/source/gui/editor/guiEditCtrl.cpp:1865–1895  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1863//-----------------------------------------------------------------------------
1864
1865void GuiEditCtrl::registerSnap( snappingAxis axis, const Point2I& mousePoint, const Point2I& point, snappingEdges edge, GuiControl* ctrl )
1866{
1867 bool takeNewSnap = false;
1868 const Point2I globalPoint = getContentControl()->localToGlobalCoord( point );
1869
1870 // If we have no snap yet, just take this one.
1871
1872 if( !mSnapped[ axis ] )
1873 takeNewSnap = true;
1874
1875 // Otherwise see if this snap is the better one.
1876
1877 else
1878 {
1879 // Compare deltas to pointer.
1880
1881 S32 deltaCurrent = mAbs( mSnapOffset[ axis ] - mousePoint[ axis ] );
1882 S32 deltaNew = mAbs( globalPoint[ axis ] - mousePoint[ axis ] );
1883
1884 if( deltaCurrent > deltaNew )
1885 takeNewSnap = true;
1886 }
1887
1888 if( takeNewSnap )
1889 {
1890 mSnapped[ axis ] = true;
1891 mSnapOffset[ axis ] = globalPoint[ axis ];
1892 mSnapEdge[ axis ] = edge;
1893 mSnapTargets[ axis ] = ctrl;
1894 }
1895}
1896
1897//-----------------------------------------------------------------------------
1898

Callers

nothing calls this directly

Calls 3

getContentControlFunction · 0.85
mAbsFunction · 0.85
localToGlobalCoordMethod · 0.80

Tested by

no test coverage detected