mirror of
https://github.com/bulletphysics/bullet3
synced 2025-01-19 05:20:06 +00:00
add options to perturb the softbody patch's initial position
This commit is contained in:
parent
cfbd6c512a
commit
9e6e571732
@ -724,7 +724,8 @@ btSoftBody* btSoftBodyHelpers::CreatePatch(btSoftBodyWorldInfo& worldInfo, const
|
||||
int resx,
|
||||
int resy,
|
||||
int fixeds,
|
||||
bool gendiags)
|
||||
bool gendiags,
|
||||
btScalar perturbation)
|
||||
{
|
||||
#define IDX(_x_, _y_) ((_y_)*rx + (_x_))
|
||||
/* Create nodes */
|
||||
@ -744,7 +745,13 @@ btSoftBody* btSoftBodyHelpers::CreatePatch(btSoftBodyWorldInfo& worldInfo, const
|
||||
for (int ix = 0; ix < rx; ++ix)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -92,7 +92,8 @@ struct btSoftBodyHelpers
|
||||
int resx,
|
||||
int resy,
|
||||
int fixeds,
|
||||
bool gendiags);
|
||||
bool gendiags,
|
||||
btScalar perturbation = 0.);
|
||||
/* Create a patch with UV Texture Coordinates */
|
||||
static btSoftBody* CreatePatchUV(btSoftBodyWorldInfo& worldInfo,
|
||||
const btVector3& corner00,
|
||||
|
Loading…
Reference in New Issue
Block a user