diff options
author | Antony Riakiotakis <kalast@gmail.com> | 2013-12-12 21:35:33 +0400 |
---|---|---|
committer | Antony Riakiotakis <kalast@gmail.com> | 2013-12-12 21:35:33 +0400 |
commit | b0a3f32ed39dae9340efde10187b23cb0cbdf9e1 (patch) | |
tree | d0bd73bf5a0b3aff47c8e30b4c3b406defd44746 /source | |
parent | c740f1a792fd47995b21422a84bc65f50d0b42ed (diff) |
improvements and simplification to gravity code:
* world to object matrix is calculated for view vector as well, reuse
that.
* if no orientation exists use world negative axis instead of object
negative axis for gravity.
there's also the issue of mirroring, it may be wise to invert the
gravity effect there but it may be better to have artist feedback on
that.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/sculpt_paint/sculpt.c | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 14b6ab8859a..a0b6bd5ca20 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -3873,25 +3873,6 @@ static void sculpt_update_cache_invariants(bContext *C, Sculpt *sd, SculptSessio cache->scale[1] = max_scale / ob->size[1]; cache->scale[2] = max_scale / ob->size[2]; - if (sd->gravity_object) { - Object *gravity_object = sd->gravity_object; - float rmat[3][3], loc[3], size[3]; - - /* get gravity vector in world space */ - copy_v3_v3(cache->gravity_direction, gravity_object->obmat[2]); - normalize_v3(cache->gravity_direction); - - /* transform to sculpted object space by inverting object rotation matrix */ - mat4_to_loc_rot_size(loc, rmat, size, ob->obmat); - /* transposition of orthogonal matrix (rotation), inverts */ - transpose_m3(rmat); - mul_m3_v3(rmat, cache->gravity_direction); - } - else { - cache->gravity_direction[0] = cache->gravity_direction[1] = 0.0; - cache->gravity_direction[2] = sd->gravity_factor; - } - cache->plane_trim_squared = brush->plane_trim * brush->plane_trim; cache->flag = 0; @@ -3957,6 +3938,21 @@ static void sculpt_update_cache_invariants(bContext *C, Sculpt *sd, SculptSessio mul_m3_v3(mat, viewDir); normalize_v3_v3(cache->true_view_normal, viewDir); + /* get gravity vector in world space */ + if (sd->gravity_object) { + Object *gravity_object = sd->gravity_object; + + copy_v3_v3(cache->gravity_direction, gravity_object->obmat[2]); + } + else { + cache->gravity_direction[0] = cache->gravity_direction[1] = 0.0; + cache->gravity_direction[2] = 1.0; + } + + /* transform to sculpted object space by inverting object rotation matrix */ + mul_m3_v3(mat, cache->gravity_direction); + normalize_v3(cache->gravity_direction); + /* Initialize layer brush displacements and persistent coords */ if (brush->sculpt_tool == SCULPT_TOOL_LAYER) { /* not supported yet for multires or dynamic topology */ |