|
@@ -32,14 +32,14 @@ JPH_IMPLEMENT_SERIALIZABLE_NON_VIRTUAL(SoftBodySharedSettings::Edge)
|
|
{
|
|
{
|
|
JPH_ADD_ATTRIBUTE(SoftBodySharedSettings::Edge, mVertex)
|
|
JPH_ADD_ATTRIBUTE(SoftBodySharedSettings::Edge, mVertex)
|
|
JPH_ADD_ATTRIBUTE(SoftBodySharedSettings::Edge, mRestLength)
|
|
JPH_ADD_ATTRIBUTE(SoftBodySharedSettings::Edge, mRestLength)
|
|
- JPH_ADD_ATTRIBUTE(SoftBodySharedSettings::Edge, mStiffness)
|
|
|
|
|
|
+ JPH_ADD_ATTRIBUTE(SoftBodySharedSettings::Edge, mCompliance)
|
|
}
|
|
}
|
|
|
|
|
|
JPH_IMPLEMENT_SERIALIZABLE_NON_VIRTUAL(SoftBodySharedSettings::Volume)
|
|
JPH_IMPLEMENT_SERIALIZABLE_NON_VIRTUAL(SoftBodySharedSettings::Volume)
|
|
{
|
|
{
|
|
JPH_ADD_ATTRIBUTE(SoftBodySharedSettings::Volume, mVertex)
|
|
JPH_ADD_ATTRIBUTE(SoftBodySharedSettings::Volume, mVertex)
|
|
JPH_ADD_ATTRIBUTE(SoftBodySharedSettings::Volume, mSixRestVolume)
|
|
JPH_ADD_ATTRIBUTE(SoftBodySharedSettings::Volume, mSixRestVolume)
|
|
- JPH_ADD_ATTRIBUTE(SoftBodySharedSettings::Volume, mStiffness)
|
|
|
|
|
|
+ JPH_ADD_ATTRIBUTE(SoftBodySharedSettings::Volume, mCompliance)
|
|
}
|
|
}
|
|
|
|
|
|
JPH_IMPLEMENT_SERIALIZABLE_NON_VIRTUAL(SoftBodySharedSettings::InvBind)
|
|
JPH_IMPLEMENT_SERIALIZABLE_NON_VIRTUAL(SoftBodySharedSettings::InvBind)
|
|
@@ -83,7 +83,7 @@ JPH_IMPLEMENT_SERIALIZABLE_NON_VIRTUAL(SoftBodySharedSettings)
|
|
JPH_ADD_ATTRIBUTE(SoftBodySharedSettings, mVertexRadius)
|
|
JPH_ADD_ATTRIBUTE(SoftBodySharedSettings, mVertexRadius)
|
|
}
|
|
}
|
|
|
|
|
|
-void SoftBodySharedSettings::CreateEdges(float inStiffness, float inAngleTolerance)
|
|
|
|
|
|
+void SoftBodySharedSettings::CreateEdges(float inCompliance, float inAngleTolerance)
|
|
{
|
|
{
|
|
struct EdgeHelper
|
|
struct EdgeHelper
|
|
{
|
|
{
|
|
@@ -111,13 +111,13 @@ void SoftBodySharedSettings::CreateEdges(float inStiffness, float inAngleToleran
|
|
QuickSort(edges.begin(), edges.end(), [](const EdgeHelper &inLHS, const EdgeHelper &inRHS) { return inLHS.mVertex[0] < inRHS.mVertex[0] || (inLHS.mVertex[0] == inRHS.mVertex[0] && inLHS.mVertex[1] < inRHS.mVertex[1]); });
|
|
QuickSort(edges.begin(), edges.end(), [](const EdgeHelper &inLHS, const EdgeHelper &inRHS) { return inLHS.mVertex[0] < inRHS.mVertex[0] || (inLHS.mVertex[0] == inRHS.mVertex[0] && inLHS.mVertex[1] < inRHS.mVertex[1]); });
|
|
|
|
|
|
// Only add edges if one of the vertices is movable
|
|
// Only add edges if one of the vertices is movable
|
|
- auto add_edge = [this](uint32 inVtx1, uint32 inVtx2, float inStiffnessParam) {
|
|
|
|
|
|
+ auto add_edge = [this, inCompliance](uint32 inVtx1, uint32 inVtx2) {
|
|
if (mVertices[inVtx1].mInvMass > 0.0f || mVertices[inVtx2].mInvMass > 0.0f)
|
|
if (mVertices[inVtx1].mInvMass > 0.0f || mVertices[inVtx2].mInvMass > 0.0f)
|
|
{
|
|
{
|
|
Edge temp_edge;
|
|
Edge temp_edge;
|
|
temp_edge.mVertex[0] = inVtx1;
|
|
temp_edge.mVertex[0] = inVtx1;
|
|
temp_edge.mVertex[1] = inVtx2;
|
|
temp_edge.mVertex[1] = inVtx2;
|
|
- temp_edge.mStiffness = inStiffnessParam;
|
|
|
|
|
|
+ temp_edge.mCompliance = inCompliance;
|
|
temp_edge.mRestLength = (Vec3(mVertices[inVtx2].mPosition) - Vec3(mVertices[inVtx1].mPosition)).Length();
|
|
temp_edge.mRestLength = (Vec3(mVertices[inVtx2].mPosition) - Vec3(mVertices[inVtx1].mPosition)).Length();
|
|
JPH_ASSERT(temp_edge.mRestLength > 0.0f);
|
|
JPH_ASSERT(temp_edge.mRestLength > 0.0f);
|
|
mEdgeConstraints.push_back(temp_edge);
|
|
mEdgeConstraints.push_back(temp_edge);
|
|
@@ -134,7 +134,7 @@ void SoftBodySharedSettings::CreateEdges(float inStiffness, float inAngleToleran
|
|
const EdgeHelper &e0 = edges[i];
|
|
const EdgeHelper &e0 = edges[i];
|
|
|
|
|
|
// Create a regular edge constraint
|
|
// Create a regular edge constraint
|
|
- add_edge(e0.mVertex[0], e0.mVertex[1], inStiffness);
|
|
|
|
|
|
+ add_edge(e0.mVertex[0], e0.mVertex[1]);
|
|
|
|
|
|
// Test if there are any shared edges
|
|
// Test if there are any shared edges
|
|
for (Array<EdgeHelper>::size_type j = i + 1; j < edges.size(); ++j)
|
|
for (Array<EdgeHelper>::size_type j = i + 1; j < edges.size(); ++j)
|
|
@@ -159,7 +159,7 @@ void SoftBodySharedSettings::CreateEdges(float inStiffness, float inAngleToleran
|
|
if (Square(e0_dir.Dot(e1_dir)) < sq_sin_tolerance * e0_dir.LengthSq() * e1_dir.LengthSq())
|
|
if (Square(e0_dir.Dot(e1_dir)) < sq_sin_tolerance * e0_dir.LengthSq() * e1_dir.LengthSq())
|
|
{
|
|
{
|
|
// Shear constraint
|
|
// Shear constraint
|
|
- add_edge(min(v0, v1), max(v0, v1), inStiffness);
|
|
|
|
|
|
+ add_edge(min(v0, v1), max(v0, v1));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|