add options to perturb the softbody patch's initial position
This commit is contained in:
@@ -724,7 +724,8 @@ btSoftBody* btSoftBodyHelpers::CreatePatch(btSoftBodyWorldInfo& worldInfo, const
|
|||||||
int resx,
|
int resx,
|
||||||
int resy,
|
int resy,
|
||||||
int fixeds,
|
int fixeds,
|
||||||
bool gendiags)
|
bool gendiags,
|
||||||
|
btScalar perturbation)
|
||||||
{
|
{
|
||||||
#define IDX(_x_, _y_) ((_y_)*rx + (_x_))
|
#define IDX(_x_, _y_) ((_y_)*rx + (_x_))
|
||||||
/* Create nodes */
|
/* Create nodes */
|
||||||
@@ -744,7 +745,13 @@ btSoftBody* btSoftBodyHelpers::CreatePatch(btSoftBodyWorldInfo& worldInfo, const
|
|||||||
for (int ix = 0; ix < rx; ++ix)
|
for (int ix = 0; ix < rx; ++ix)
|
||||||
{
|
{
|
||||||
const btScalar tx = ix / (btScalar)(rx - 1);
|
const btScalar tx = ix / (btScalar)(rx - 1);
|
||||||
x[IDX(ix, iy)] = lerp(py0, py1, tx);
|
btScalar pert = perturbation * btScalar(rand())/RAND_MAX;
|
||||||
|
btVector4 temp1 = py1;
|
||||||
|
temp1.setY(py1.getY() + pert);
|
||||||
|
btVector4 temp = py0;
|
||||||
|
pert = perturbation * btScalar(rand())/RAND_MAX;
|
||||||
|
temp.setY(py0.getY() + pert);
|
||||||
|
x[IDX(ix, iy)] = lerp(temp, temp1, tx);
|
||||||
m[IDX(ix, iy)] = 1;
|
m[IDX(ix, iy)] = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,7 +92,8 @@ struct btSoftBodyHelpers
|
|||||||
int resx,
|
int resx,
|
||||||
int resy,
|
int resy,
|
||||||
int fixeds,
|
int fixeds,
|
||||||
bool gendiags);
|
bool gendiags,
|
||||||
|
btScalar perturbation = 0.);
|
||||||
/* Create a patch with UV Texture Coordinates */
|
/* Create a patch with UV Texture Coordinates */
|
||||||
static btSoftBody* CreatePatchUV(btSoftBodyWorldInfo& worldInfo,
|
static btSoftBody* CreatePatchUV(btSoftBodyWorldInfo& worldInfo,
|
||||||
const btVector3& corner00,
|
const btVector3& corner00,
|
||||||
|
|||||||
Reference in New Issue
Block a user