From d63a2760b07ead3287f45267e3bfb08dfe1348ad Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Sun, 31 Dec 2006 11:31:39 +0000 Subject: [PATCH] Extended the brush texture rotate option to work with Tile mode. --- source/blender/src/buttons_editing.c | 2 +- source/blender/src/sculptmode.c | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/source/blender/src/buttons_editing.c b/source/blender/src/buttons_editing.c index ce29c821083..ef76626c875 100644 --- a/source/blender/src/buttons_editing.c +++ b/source/blender/src/buttons_editing.c @@ -4346,7 +4346,7 @@ void sculptmode_draw_interface_textures(uiBlock *block, unsigned short cx, unsig uiDefButC(block,ROW, REDRAWBUTSEDIT, "3D", cx+78,cy,37,19, &sd->texrept, 18,SCULPTREPT_3D, 0,0,"Use vertex coords as texture coordinates"); cy-= 20; - if(sd->texrept == SCULPTREPT_DRAG) { + if(sd->texrept != SCULPTREPT_3D) { uiBlockBeginAlign(block); uiDefButF(block,NUM,0, "Rot", cx,cy,115,19, &mtex->warpfac, 0,360,100,0, "Rotate texture clockwise"); } diff --git a/source/blender/src/sculptmode.c b/source/blender/src/sculptmode.c index c265c94c629..f66ba795701 100644 --- a/source/blender/src/sculptmode.c +++ b/source/blender/src/sculptmode.c @@ -1045,6 +1045,7 @@ float tex_strength(EditData *e, float *point, const float len,const unsigned vin else if(ss->texrndr) { const short bsize= sculptmode_brush()->size * 2; const short half= sculptmode_brush()->size; + const float rot= sd->mtex[sd->texact]->warpfac * (M_PI/180.0f); int px, py; unsigned i, *p; RenderInfo *ri= ss->texrndr; @@ -1063,14 +1064,23 @@ float tex_strength(EditData *e, float *point, const float len,const unsigned vin const float sx= sd->mtex[sd->texact]->size[0]; const float sy= sd->texsep ? sd->mtex[sd->texact]->size[1] : sx; - px= pv.co[0]; - py= pv.co[1]; + float fx= pv.co[0]; + float fy= pv.co[1]; + + float angle= atan2(fy, fx) + rot; + float len= sqrtf(fx*fx + fy*fy); + + if(rot<0.001 && rot>-0.001) { + px= pv.co[0]; + py= pv.co[1]; + } else { + px= len * cos(angle) + 2000; + py= len * sin(angle) + 2000; + } px%= (int)sx; py%= (int)sy; p= get_ri_pixel(ri, ri->pr_rectx*px/sx, ri->pr_recty*py/sy); } else { - const float rot= sd->mtex[sd->texact]->warpfac * (M_PI/180.0f); - float fx= (pv.co[0] - e->mouse[0] + half) * (ri->pr_rectx*1.0f/bsize) - ri->pr_rectx/2; float fy= (pv.co[1] - e->mouse[1] + half) * (ri->pr_recty*1.0f/bsize) - ri->pr_recty/2;