This commit is contained in:
Erwin Coumans
2019-05-07 19:43:33 -07:00
15 changed files with 125 additions and 18 deletions

View File

@@ -1942,7 +1942,7 @@ static PyObject* pybullet_loadSoftBody(PyObject* self, PyObject* args, PyObject*
int physicsClientId = 0;
int flags = 0;
static char* kwlist[] = {"fileName", "scale", "mass", "collisionMargin", "physicsClientId", NULL};
static char* kwlist[] = {"fileName", "basePosition", "baseOrientation", "scale", "mass", "collisionMargin", "physicsClientId", NULL};
int bodyUniqueId = -1;
const char* fileName = "";
@@ -1952,10 +1952,36 @@ static PyObject* pybullet_loadSoftBody(PyObject* self, PyObject* args, PyObject*
b3PhysicsClientHandle sm = 0;
if (!PyArg_ParseTupleAndKeywords(args, keywds, "s|dddi", kwlist, &fileName, &scale, &mass, &collisionMargin, &physicsClientId))
double startPos[3] = {0.0, 0.0, 0.0};
double startOrn[4] = {0.0, 0.0, 0.0, 1.0};
PyObject* basePosObj = 0;
PyObject* baseOrnObj = 0;
if (!PyArg_ParseTupleAndKeywords(args, keywds, "s|OOdddi", kwlist, &fileName, &basePosObj, &baseOrnObj, &scale, &mass, &collisionMargin, &physicsClientId))
{
return NULL;
}
else
{
if (basePosObj)
{
if (!pybullet_internalSetVectord(basePosObj, startPos))
{
PyErr_SetString(SpamError, "Cannot convert basePosition.");
return NULL;
}
}
if (baseOrnObj)
{
if (!pybullet_internalSetVector4d(baseOrnObj, startOrn))
{
PyErr_SetString(SpamError, "Cannot convert baseOrientation.");
return NULL;
}
}
}
sm = getPhysicsClient(physicsClientId);
if (sm == 0)
@@ -1971,6 +1997,9 @@ static PyObject* pybullet_loadSoftBody(PyObject* self, PyObject* args, PyObject*
b3SharedMemoryCommandHandle command =
b3LoadSoftBodyCommandInit(sm, fileName);
b3LoadSoftBodySetStartPosition(command, startPos[0], startPos[1], startPos[2]);
b3LoadSoftBodySetStartOrientation(command, startOrn[0], startOrn[1], startOrn[2], startOrn[3]);
if (scale > 0)
{
b3LoadSoftBodySetScale(command, scale);