- Pending Hook work; falloff value for soft hook deformation.

Falloff= distance where influence becomes zero.
This commit is contained in:
2004-11-06 21:59:35 +00:00
parent 6e755e5e98
commit 02e838c99b
5 changed files with 33 additions and 17 deletions

View File

@@ -36,6 +36,7 @@
*/
#include <string.h>
#include <math.h>
#include "MEM_guardedalloc.h"
@@ -178,14 +179,21 @@ void hook_object_deform(Object *ob, int index, float *vec)
}
if( hook->indexar[hook->curindex]==index ) {
float fac= hook->force;
totforce+= fac;
float fac= hook->force, len;
VecMat4MulVecfl(vect, hook->mat, vec);
vectot[0]+= fac*vect[0];
vectot[1]+= fac*vect[1];
vectot[2]+= fac*vect[2];
if(hook->falloff!=0.0) {
len= VecLenf(vect, hook->parent->obmat[3]);
if(len > hook->falloff) fac= 0.0;
else if(len>0.0) fac*= sqrt(1.0 - len/hook->falloff);
}
if(fac!=0.0) {
totforce+= fac;
vectot[0]+= fac*vect[0];
vectot[1]+= fac*vect[1];
vectot[2]+= fac*vect[2];
}
}
}
}
@@ -256,6 +264,7 @@ int mesh_modifier(Object *ob, char mode)
float *fp;
if(dl->verts) MEM_freeN(dl->verts);
if(dl->nors) MEM_freeN(dl->nors);
dl->nr= me->totvert;
if(dl->nr) {

View File

@@ -817,6 +817,7 @@ void addnormalsDispList(Object *ob, ListBase *lb)
dl->nr= me->totface;
BLI_addtail(&me->disp, dl);
}
else return;
if(dl->nors==0) {
dl->nors= MEM_mallocN(sizeof(float)*3*me->totface, "meshnormals");

View File

@@ -210,7 +210,7 @@ typedef struct ObHook {
float parentinv[4][4]; /* matrix making current transform unmodified */
float mat[4][4]; /* temp matrix while hooking */
float cent[3]; /* visualization of hook */
int pad;
float falloff; /* if not zero, falloff is distance where influence zero */
char name[32];

View File

@@ -1063,7 +1063,8 @@ void object_panel_hooks(Object *ob)
if(hook->active<1 || hook->active > tothook) hook->active= 1;
active= hook->active;
uiDefButS(block, MENU, B_REDR, cp, 10,180,150,19, &hook->active, 0, 0, 0, 0, "Set active hook");
uiBlockBeginAlign(block);
uiDefButS(block, MENU, B_REDR, cp, 10,180,150,19, &hook->active, 0, 0, 0, 0, "Set active hook");
MEM_freeN(cp);
for(nr=1, hook= ob->hooks.first; hook; hook= hook->next, nr++) {
@@ -1071,14 +1072,18 @@ void object_panel_hooks(Object *ob)
}
if(hook==NULL) printf("error in object_panel_hooks\n");
uiBlockBeginAlign(block);
uiDefButC(block, TEX, B_REDR, "Name: ", 160,180,150,19, hook->name, 0, 32, 0, 0, "Set name of hook");
uiDefIDPoinBut(block, test_obpoin_but, B_CLR_HOOK, "Parent:", 160, 160, 150, 19, &hook->parent, "Parent Object for hook, also recalculates and clears offset");
uiDefButF(block, NUMSLI, B_MAKEDISP, "Force: ", 160,140,150,19, &hook->force, 0.0, 1.0, 100, 0, "Set force of hook");
uiDefBut(block, TEX, B_REDR, "Name: ", 160,180,150,19, hook->name, 0, 31, 0, 0, "Set name of hook");
uiBlockBeginAlign(block);
uiDefBut(block, BUT, B_DEL_HOOK, "Delete", 10,100,150,19, NULL, 0.0, 0.0, 0, 0, "Delete hook");
uiDefBut(block, BUT, B_CLR_HOOK, "Clear offset", 160,100,150,19, NULL, 0.0, 0.0, 0, 0, "Recalculate and clear offset (transform) of hook");
uiDefButF(block, NUM, B_MAKEDISP, "Falloff: ", 160,140,150,19, &hook->falloff, 0.0, 100.0, 100, 0, "If not zero, the distance from hook where influence ends");
uiDefButF(block, NUMSLI, B_MAKEDISP, "Force: ", 160,120,150,19, &hook->force, 0.0, 1.0, 100, 0, "Set relative force of hook");
uiBlockEndAlign(block);
uiDefIDPoinBut(block, test_obpoin_but, B_CLR_HOOK, "Parent:", 10, 120, 150, 19, &hook->parent, "Parent Object for hook, also recalculates and clears offset");
uiBlockBeginAlign(block);
uiDefBut(block, BUT, B_DEL_HOOK, "Delete", 10,80,150,19, NULL, 0.0, 0.0, 0, 0, "Delete hook");
uiDefBut(block, BUT, B_CLR_HOOK, "Clear offset", 160,80,150,19, NULL, 0.0, 0.0, 0, 0, "Recalculate and clear offset (transform) of hook");
}

View File

@@ -2179,11 +2179,12 @@ static void drawDispList(Object *ob, int dt)
if(dt==OB_SOLID ) {
lb= &me->disp;
if(lb->first==0) addnormalsDispList(ob, lb);
if(lb->first==NULL) addnormalsDispList(ob, lb);
dl= lb->first;
if(dl==0) return;
if(dl==NULL) return;
if(dl->nors==NULL) addnormalsDispList(ob, lb);
if(mesh_uses_displist(me)) {
int vertexpaint= (G.f & (G_VERTEXPAINT+G_FACESELECT+G_TEXTUREPAINT+G_WEIGHTPAINT)) && (ob==((G.scene->basact) ? (G.scene->basact->object) : 0));