providing a minimalistic UI for SB vertex to face collision detection
in the particle interaction panel "D"= "Amount of damping during softbody collision/intrusion" "I"= "Inner face thickness" good value for unit cube == 0.2 "O"= "Outer face thickness" good value for unit cube == 0.02 still we can easily hide that before releasing
This commit is contained in:
@@ -1535,7 +1535,7 @@ int SoftBodyDetectCollision(float opco[3], float npco[3], float colco[3],
|
||||
short cur_frame;
|
||||
int d_object=0, d_face=0, ds_object=0, ds_face=0;
|
||||
|
||||
// i'm going to rearrange it to declatation rules when WIP is finoshed (BM)
|
||||
// i'm going to rearrange it to declaration rules when WIP is finished (BM)
|
||||
float u,v,len_u,len_v;
|
||||
float innerfacethickness = -0.5f;
|
||||
float outerfacethickness = 0.2f;
|
||||
@@ -1543,10 +1543,6 @@ int SoftBodyDetectCollision(float opco[3], float npco[3], float colco[3],
|
||||
float ff = 0.1f;
|
||||
float fa;
|
||||
|
||||
fa = (ff*outerfacethickness-outerfacethickness);
|
||||
fa *= fa;
|
||||
fa = 1.0f/fa;
|
||||
|
||||
min_t = 200000;
|
||||
|
||||
/* The first part of the code, finding the first intersected face*/
|
||||
@@ -1564,7 +1560,13 @@ int SoftBodyDetectCollision(float opco[3], float npco[3], float colco[3],
|
||||
d_face = d_face + 1;
|
||||
mface= def_mesh->mface;
|
||||
a = def_mesh->totface;
|
||||
/* need to have user control for that since it depends on model scale */
|
||||
|
||||
innerfacethickness =-ob->pd->pdef_sbift;
|
||||
outerfacethickness =ob->pd->pdef_sboft;
|
||||
fa = (ff*outerfacethickness-outerfacethickness);
|
||||
fa *= fa;
|
||||
fa = 1.0f/fa;
|
||||
|
||||
if(ob->parent==NULL && ob->ipo==NULL) { // static
|
||||
if(ob->sumohandle==NULL) cache_object_vertices(ob);
|
||||
@@ -1651,7 +1653,7 @@ int SoftBodyDetectCollision(float opco[3], float npco[3], float colco[3],
|
||||
force[0] += force_mag_norm*d_nvect[0] ;
|
||||
force[1] += force_mag_norm*d_nvect[1] ;
|
||||
force[2] += force_mag_norm*d_nvect[2] ;
|
||||
*damp=ob->pd->pdef_damp;
|
||||
*damp=ob->pd->pdef_sbdamp;
|
||||
deflected = 2;
|
||||
|
||||
colco[0] = nv2[0] + len_u*u*edge1[0] + len_v*v*edge2[0];
|
||||
@@ -1685,7 +1687,7 @@ int SoftBodyDetectCollision(float opco[3], float npco[3], float colco[3],
|
||||
force[0] += force_mag_norm*d_nvect[0] ;
|
||||
force[1] += force_mag_norm*d_nvect[1] ;
|
||||
force[2] += force_mag_norm*d_nvect[2] ;
|
||||
*damp=ob->pd->pdef_damp;
|
||||
*damp=ob->pd->pdef_sbdamp;
|
||||
deflected = 2;
|
||||
colco[0] = nv4[0] + len_u*u*edge1[0] + len_v*v*edge2[0];
|
||||
colco[1] = nv4[1] + len_u*u*edge1[1] + len_v*v*edge2[1];
|
||||
|
||||
@@ -92,6 +92,10 @@ typedef struct PartDeflect {
|
||||
float f_strength; /* The strength of the force (+ or - ) */
|
||||
float f_power; /* The power law - real gravitation is 2 (square) */
|
||||
float maxdist; /* if indicated, use this maximum */
|
||||
|
||||
float pdef_sbdamp; /* Damping factor for softbody deflection */
|
||||
float pdef_sbift; /* inner face thickness for softbody deflection */
|
||||
float pdef_sboft; /* outer face thickness for softbody deflection */
|
||||
} PartDeflect;
|
||||
|
||||
/* pd->forcefield: Effector Fields types */
|
||||
|
||||
@@ -1463,6 +1463,17 @@ static void object_panel_deflectors(Object *ob)
|
||||
uiDefButF(block, NUM, B_DIFF, "Permeability: ", 10,-10,200,20, &pd->pdef_perm, 0.0, 1.0, 10, 0, "Chance that the particle will pass through the mesh");
|
||||
}
|
||||
uiBlockEndAlign(block);
|
||||
|
||||
if(ob->type==OB_MESH) {
|
||||
uiBlockBeginAlign(block);
|
||||
uiDefBut(block, LABEL, 0, "Softbody", 210, 50,110,20, NULL, 0.0, 0.0, 0, 0, "");
|
||||
uiDefButF(block, NUM, B_DIFF, "D", 210,30,110,20, &pd->pdef_sbdamp, 0.0, 1.0, 10, 0, "Amount of damping during softbody collision");
|
||||
uiDefButF(block, NUM, B_DIFF, "I", 210,10,110,20, &pd->pdef_sbift, 0.001, 1.0, 10, 0, "Inner face thickness");
|
||||
uiDefButF(block, NUM, B_DIFF, "O", 210,-10,110,20, &pd->pdef_sboft, 0.001, 1.0, 10, 0, "Outer face thickness");
|
||||
}
|
||||
uiBlockEndAlign(block);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user