Commit: d2638393146c5f746bc873d47eb8c597ee9f9765
Author: Lukas Tönne
Date:   Tue Dec 2 13:28:32 2014 +0100
Branches: hair_immediate_fixes
https://developer.blender.org/rBd2638393146c5f746bc873d47eb8c597ee9f9765

Make sure tool input data is in object space.

===================================================================

M       source/blender/editors/hair/hair_edit.c

===================================================================

diff --git a/source/blender/editors/hair/hair_edit.c 
b/source/blender/editors/hair/hair_edit.c
index d1ef5c5..e2b097c 100644
--- a/source/blender/editors/hair/hair_edit.c
+++ b/source/blender/editors/hair/hair_edit.c
@@ -214,9 +214,6 @@ typedef struct HairStroke {
        bool first;
        float lastmouse[2];
        float zfac;
-       
-       /* optional cached view settings to avoid setting on every mousemove */
-//     PEData data;
 } HairStroke;
 
 static int hair_stroke_init(bContext *C, wmOperator *op)
@@ -262,6 +259,7 @@ static bool hair_stroke_apply(bContext *C, wmOperator *op, 
PointerRNA *itemptr)
        HairEditSettings *settings = &scene->toolsettings->hair_edit;
        ARegion *ar = CTX_wm_region(C);
        
+       float imat[4][4];
        float mouse[2], mdelta[2], zvec[3], delta_max;
        int totsteps, step;
        HairToolData tool_data;
@@ -269,6 +267,8 @@ static bool hair_stroke_apply(bContext *C, wmOperator *op, 
PointerRNA *itemptr)
        
        RNA_float_get_array(itemptr, "mouse", mouse);
        
+       invert_m4_m4(imat, ob->obmat);
+       
        if (stroke->first) {
                copy_v2_v2(stroke->lastmouse, mouse);
                stroke->first = false;
@@ -295,6 +295,9 @@ static bool hair_stroke_apply(bContext *C, wmOperator *op, 
PointerRNA *itemptr)
        zvec[0] = 0.0f; zvec[1] = 0.0f; zvec[2] = stroke->zfac;
        ED_view3d_win_to_3d(ar, zvec, mouse, tool_data.loc);
        ED_view3d_win_to_delta(ar, mdelta, tool_data.delta, stroke->zfac);
+       /* tools work in object space */
+       mul_m4_v3(imat, tool_data.loc);
+       mul_mat3_m4_v3(imat, tool_data.delta);
 
        for (step = 0; step < totsteps; ++step) {
                updated |= hair_brush_step(&tool_data);
@@ -346,7 +349,8 @@ static void hair_stroke_apply_event(bContext *C, wmOperator 
*op, const wmEvent *
        float mouse[2];
        bool updated = false;
 
-       copy_v2_v2(mouse, event->mval);
+       mouse[0] = event->mval[0];
+       mouse[1] = event->mval[1];
 
        /* fill in stroke */
        RNA_collection_add(op->ptr, "stroke", &itemptr);

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to