pybullet.createSoftBodyAnchor
This commit is contained in:
@@ -2496,7 +2496,8 @@ void btSoftBody::updateNormals()
|
||||
btSoftBody::Face& f = m_faces[i];
|
||||
const btVector3 n = btCross(f.m_n[1]->m_x - f.m_n[0]->m_x,
|
||||
f.m_n[2]->m_x - f.m_n[0]->m_x);
|
||||
f.m_normal = n.normalized();
|
||||
f.m_normal = n;
|
||||
f.m_normal.safeNormalize();
|
||||
f.m_n[0]->m_n += n;
|
||||
f.m_n[1]->m_n += n;
|
||||
f.m_n[2]->m_n += n;
|
||||
@@ -3306,7 +3307,10 @@ void btSoftBody::interpolateRenderMesh()
|
||||
n.m_x.setZero();
|
||||
for (int j = 0; j < 4; ++j)
|
||||
{
|
||||
n.m_x += m_renderNodesParents[i][j]->m_x * m_renderNodesInterpolationWeights[i][j];
|
||||
if (m_renderNodesParents[i].size())
|
||||
{
|
||||
n.m_x += m_renderNodesParents[i][j]->m_x * m_renderNodesInterpolationWeights[i][j];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1500,43 +1500,6 @@ void btSoftBodyHelpers::getBarycentricWeights(const btVector3& a, const btVector
|
||||
bary = btVector4(va6*v6, vb6*v6, vc6*v6, vd6*v6);
|
||||
}
|
||||
|
||||
void btSoftBodyHelpers::readRenderMeshFromObj(const char* file, btSoftBody* psb)
|
||||
{
|
||||
std::ifstream fs;
|
||||
fs.open(file);
|
||||
std::string line;
|
||||
btVector3 pos;
|
||||
while (std::getline(fs, line))
|
||||
{
|
||||
std::stringstream ss(line);
|
||||
if (line.length()>1)
|
||||
{
|
||||
if (line[0] == 'v' && line[1] != 't' && line[1] != 'n')
|
||||
{
|
||||
ss.ignore();
|
||||
for (size_t i = 0; i < 3; i++)
|
||||
ss >> pos[i];
|
||||
btSoftBody::Node n;
|
||||
n.m_x = pos;
|
||||
psb->m_renderNodes.push_back(n);
|
||||
}
|
||||
else if (line[0] == 'f')
|
||||
{
|
||||
ss.ignore();
|
||||
int id0, id1, id2;
|
||||
ss >> id0;
|
||||
ss >> id1;
|
||||
ss >> id2;
|
||||
btSoftBody::Face f;
|
||||
f.m_n[0] = &psb->m_renderNodes[id0-1];
|
||||
f.m_n[1] = &psb->m_renderNodes[id1-1];
|
||||
f.m_n[2] = &psb->m_renderNodes[id2-1];
|
||||
psb->m_renderFaces.push_back(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
fs.close();
|
||||
}
|
||||
|
||||
// Iterate through all render nodes to find the simulation tetrahedron that contains the render node and record the barycentric weights
|
||||
// If the node is not inside any tetrahedron, assign it to the tetrahedron in which the node has the least negative barycentric weight
|
||||
|
||||
@@ -148,8 +148,6 @@ struct btSoftBodyHelpers
|
||||
|
||||
static void getBarycentricWeights(const btVector3& a, const btVector3& b, const btVector3& c, const btVector3& d, const btVector3& p, btVector4& bary);
|
||||
|
||||
static void readRenderMeshFromObj(const char* file, btSoftBody* psb);
|
||||
|
||||
static void interpolateBarycentricWeights(btSoftBody* psb);
|
||||
|
||||
static void generateBoundaryFaces(btSoftBody* psb);
|
||||
|
||||
@@ -274,7 +274,7 @@ struct btSparseSdf
|
||||
Lerp(gy[2], gy[3], ix.f), iz.f));
|
||||
normal.setZ(Lerp(Lerp(gz[0], gz[1], ix.f),
|
||||
Lerp(gz[2], gz[3], ix.f), iy.f));
|
||||
normal = normal.normalized();
|
||||
normal.safeNormalize();
|
||||
#else
|
||||
normal = btVector3(d[1] - d[0], d[3] - d[0], d[4] - d[0]).normalized();
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user