Current version:
1.0.0, released on
2008-03-30, compatible with the GMOD update!
If SmartSnap does not work for you, get the latest version first! FPS drops when showing the grid has been FIXED!

●●●● Introduction ●●●●
This is a client-side tool for building contraptions with extreme precision, aligning objects for either aesthetic or functional perfection. To accomplish this task a grid is projected onto the object you are pointing at and by pressing the use-button your weapon will lock onto that point and allow you to place objects with pin-point accuracy. For all entities be them square, round or uneven this tool will bring you perfect precision. This is a remake of the classic AutoSnap with a multitude of improvements. We all loved AutoSnap, and since the development of it had almost come to a halt I decided it was time to bring it back to life, the code has been written from scratch.
If you have any feedback or ideas to improve this addon I would be very happy to hear them!
●●●● Changelog ●●●●
2008-03-30, v1.0.0 (important update):
● FPS drops when the grid is showing have been fixed, it is not directly caused by SmartSnap, but the use of SmartSnap increases per frame memory consumption and the garbage collector obviously handles this very poorly. Please give me some feedback on how this works out for you all.
● "default model offset" has been removed to improve consistency for model addons, it now hardcoded to 0.25 which appears to the default for the source models.
● Bumped to version 1 because it is about time now!
2008-03-30, v0.9.5 (useful update):
● Grid offset only affects the outer border of the grid now and does not scale the entire grids, provides better snapping for "building blocks".
● Per model offsets are now provided for each separate model addon instead, update your model addons! (links above)
● Added "click grid" mode, disables the grid until USE is clicked while looking at a prop, looking away from a prop disables the grid again.
● Fixed a very rare bug that causes SmartSnap errors (thanks kevkev)
2008-01-17, v0.9.4 (compatibility update):
● Using presets for settings instead (also fixes rare cases of the grid not showing)
● Should be fully compatible with the GMod update, complain here otherwise
(Your settings will be reset when updating to this version)
2007-12-23, v0.9.3 (minor update):
● Fixed per-model offsets, broke in last update
● Added default model offsets, should make corners useable on more models (option provided)
● Some minor optimizations
(SmartSnap can be installed on servers and will downloaded to clients automatically)
2007-11-28, v0.9.2 (compatibility update):
● Fixed errors that would appear when running the latest GMod10 beta
● New option to turn off the grid, leaving only the marker
● General optimizations and code improvements
2007-07-22, v0.9.1 (compatibility update):
● Fixed settings not appearing in the spawnmenu since the GMod10 update
2007-05-07, v0.9.0 (major update):
● Custom per-model offsets (more information below)
● New snap mode, perfect precision from "any" angle on any model, even rounded or uneven (more information below)
● New grid system, there are no longer gaps between the black and white lines, and the lines no longer go haywire when you are too close
● Easy access grid toggling, set "toggle delay" to enable, double-click the snap-key within that time to toggle the grid, console command "snaptogglegrid"
● Rewrote the square face picking routines
● Context mouse snapping is available again
● Thick center line for the grid (optional)
● New options (I'm open for more suggestions)
● And a lot of minor fixes everywhere
2007-04-27, v0.8.1 (major changes):
● There is now a "lock snap mode", that will keep the snap without holding a key by binding a key to the "snaplock" (idea by Vampired)
● Based on the previous there is now a "smart snap lock" that will activate after a short delay, off by default and adjustable delay (idea by Vampired)
● The snap button can now be assigned to another key by binding that key to "+snap", "snap_disableuse 1" to disable default snap key
● The settings are no longer lost when restarting the game
2007-04-25, v0.8.0 (initial release):
● The grid is black and white, visible on both light and dark objects
● The cursor indicates potentially bad angle with colors, red/yellow/green (new mode as of 0.9.0)
● The cursor is tilted to provide better visiblited
● The cursor turns turquoise in context mode if you are too far away and the margin of error will be noticeable (the cursor is imprecise)
● The aim now snaps completely to the grid, wobbling the mouse does not affect placement, also allows you to place objects from the other side of the map with pinpoint accuracy
● The snap does not release or shift when moving, it always sticks to the same snap point, you can even walk around the object while still attached to the same point
● The square grid works for all objects, regardless of the model
● The grid has been offset inwards slightly too minimize the common gap that was always present (for most square objects there is no gap now)
● The grid has been offset from the edges so that the outer lines of the grid are useable as well
● The objects' bounding box is made visible by blue markers on each corner
● The grid is selected by the aim/mouse and not the viewing angle, you can now point at any visible side and see the grid without moving
● The grid is smart, for smaller objects, less snap points will be available
● The snap point finding algorithm runs in constant time, meaning that regardless of number of snap points, it will always be as fast
●●●● Suggested improvements ●●●●
● Quickly accessible grid size settings (idea by AfTeRsHoCk)
●●●● Installation ●●●●
Simply unzip the archive into your garrysmod/addons-directory and it should be working, read the instructions on how to use it.
●●●● Instructions ●●●●
If you have used AutoSnap before, there should not be any problem to understand this either, although there are some major improvements that might make it feel different, especially the new ultra precise mouse snap. For the uninitiated, it is very simple to use this addon, simply install it, start a game, spawn a prop, bring up the toolgun, look at the prop and a grid should appear. If you press use (e), the mouse should snap to the point you look at, and will signal with colors how precise the placement will be. Options for this addon is located under "Spawnmenu/Options/Smartsnap Settings". If you have any questions, I will be more than happy to answer them!
●●●● The new snap mode ●●●●
As of v0.9.0, there is now a new technique in place for allowing perfectly placed objects that relies on the curvature of the object to position the mouse. It is now also possible to use the grid on
round/uneven models, the grid will not fold around the model, but the snap will trace from the grid to the model to create a perfect snap.
As of this, the color of the cursor no longer indicates the angle, but the actual distance between the calculated snap and where the object would end up (the error). Green indicated almost perfect precision, yellow means very good placement and red means the view is obstructed or the error will be significant. Turquoise means that it cannot snap because the model does not occupy that snap point and purple indicates that the snap is obstructed or failing to correctly trace a line.
As this below image shows, some of you might think that the new SmartSnap is bugged or incorrect, but it is not, it's the new snapping that shows you where it
actually ends up, this means that the grid will not always align to where the mouse aims as the actual bounding box of the object might be different. As seen above, I place 2 thrusters from two different angles on a round prop and they both end up perfectly horizontal.
Also, very few entities behave oddly when traced as such the trace fails and reverts to the "old snap mode", indicated by a purple cursor. What this means is that certain props reports bad values when traced for certain snap points, this is not caused by my code but is a flaw in HL2 I believe. However, in almost all cases you can fix this by simply rotating the entity a little and it should be able to trace properly.
●●●● Per-model grid offset ●●●●
As of v0.9.0, it is now possible to define individual grid offsets for each model, so that corners can be fully utilized and match the visual representation of the model with the position of the grid. A number of models (mostly PHX) has been predefined in the release with 0.01 precision.
To create custom grid offsets yourself, you will have to bind buttons for "snap_dev_gridoffset <distance>", where distance is the distance to offset the grid for each press, I recommend binding 0.1/0.01/-0.1/-0.01 if you want to create precise grid offsets. To offset the grid, simply look at a face of the prop, and press the button and that grid will be slightly offset inwards (+) or outwards (-) (by using snap_dev_alloffset, all faces of the object will be offset by the same amount). Personal recommendation is to set the material of the object to matte white before starting.
You must point at the object and execute "snap_dev_saveoffset" for it to be saved when you disconnect!
●●●● Demonstration of v0.8.0 ●●●●
To show you how it looks and works I made an untalented video where I show off (in order):
● No gap between the grid and the object (barely visible blue marker)
● Place objects while snapped to the outer line of the grid
● Snap to the grid and walking around while snapped
● Cursor changing color at different angles (barely visible cursor)
● Grid visible on shiny white objects aswell
● Showing that the snap does not release when walking around or pushing the prop
● And the grand finale, placing a nailer with pinpoint accuracy from the other side of the map




Credits goes to Black Phoenix for help with some vector math equations, Robbis_1 as he is the author of Autosnap and Locklear (Leon_307) for being the original inspiration for Autosnap.