Changeset View
Standalone View
source/blender/editors/transform/transform_snap.c
| Context not available. | |||||
| t->tsnap.applySnap(t, vec); | t->tsnap.applySnap(t, vec); | ||||
| } | } | ||||
| else if ((t->tsnap.mode != SCE_SNAP_MODE_INCREMENT) && activeSnap(t)) { | else if (!ELEM(t->tsnap.mode, SCE_SNAP_MODE_INCREMENT, SCE_SNAP_MODE_GRID) && activeSnap(t)) { | ||||
| double current = PIL_check_seconds_timer(); | double current = PIL_check_seconds_timer(); | ||||
| // Time base quirky code to go around findnearest slowness | // Time base quirky code to go around findnearest slowness | ||||
| Context not available. | |||||
| GearsType action; | GearsType action; | ||||
| // Only do something if using Snap to Grid | // Only do something if using Snap to Grid | ||||
| if (t->tsnap.mode != SCE_SNAP_MODE_INCREMENT) | if (t->tsnap.mode != SCE_SNAP_MODE_INCREMENT && t->tsnap.mode != SCE_SNAP_MODE_GRID) | ||||
| return; | return; | ||||
| action = activeSnap(t) ? BIG_GEARS : NO_GEARS; | action = activeSnap(t) ? BIG_GEARS : NO_GEARS; | ||||
Severin: If you use:
```
else {
BLI_assert(0)
}
```
The next one who wants to add a snap mode into… | |||||
| Context not available. | |||||
| ED_space_image_get_uv_aspect(t->sa->spacedata.first, asp, asp + 1); | ED_space_image_get_uv_aspect(t->sa->spacedata.first, asp, asp + 1); | ||||
| } | } | ||||
| } | } | ||||
| for (i = 0; i <= max_index; i++) { | if (t->tsnap.mode == SCE_SNAP_MODE_GRID) { // absolute snapping on grid based in (0, 0, 0) of center | ||||
| val[i] = fac[action] * asp[i] * floorf(val[i] / (fac[action] * asp[i]) + 0.5f); | for (i = 0; i <= max_index; i++) { | ||||
| if (!(t->con.mode & CON_APPLY) || t->con.mode & (CON_AXIS0 << i)) { // respect constrains | |||||
| val[i] = fac[action] * asp[i] * (floorf(t->center[i] + val[i] / (fac[action] * asp[i]) + 0.5f) - t->center[i]); | |||||
| } | |||||
| } | |||||
| } else if (t->tsnap.mode == SCE_SNAP_MODE_INCREMENT) { // relative snapping in fixed increments | |||||
| for (i = 0; i <= max_index; i++) { | |||||
| val[i] = fac[action] * asp[i] * floorf(val[i] / (fac[action] * asp[i]) + 0.5f); | |||||
| } | |||||
| } else { | |||||
| printf("applyGridIncrement: invalid snap mode %d\n", t->tsnap.mode); | |||||
| } | } | ||||
Not Done Inline ActionsNot sure about disabling for rotate/scale. It's the same as with other transformation orientations: If snap mode is set to grid it should snap to grid. (At least for scale, rotation might be considered a bit special here) @Jonathan Williamson (carter2422), @Paweł Łyczkowski (plyczkowski), @Sebastian Koenig (sebastian_k), or anyone else, what do you think, how would you expect it to behave with rotate/scale? Severin: Not sure about disabling for rotate/scale. It's the same as with other transformation… | |||||
| } | } | ||||
| Context not available. | |||||
Not Done Inline ActionsI'm not sure why this needs to be changed? If the patch is about adding new snapping mode existing ones should behave the same. If there's some issues involved here this is to be addressed separately in master branch. sergey: I'm not sure why this needs to be changed?
If the patch is about adding new snapping mode… | |||||
Not Done Inline ActionsThis only makes sense for absolute snapping, think its fine to do this. campbellbarton: This only makes sense for absolute snapping, think its fine to do this. | |||||
Done Inline ActionsUse t->center_global here fixes editmode behavior. campbellbarton: Use `t->center_global` here fixes editmode behavior. | |||||
Done Inline ActionsAlso really minor but it keeps annoying me ;P: Codestyle convention would be else {
foo_other();
}See http://wiki.blender.org/index.php/Dev:Doc/Code_Style#Braces Severin: Also really minor but it keeps annoying me ;P: Codestyle convention would be
else {… | |||||
If you use:
else { BLI_assert(0) }The next one who wants to add a snap mode into this function doesn't need to update the BLI_assert (which he even might miss/forget)