Skip to content

Commit

Permalink
feat: implement cone twist constraint limits
Browse files Browse the repository at this point in the history
  • Loading branch information
Silverlan committed Jan 22, 2023
1 parent c2997d2 commit 4f1aea9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/collision_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ void pragma::physics::BtSoftBody::AppendAnchor(uint32_t nodeId,pragma::physics::
assert(nodeId < GetInternalObject().m_nodes.size());
if(nodeId >= GetInternalObject().m_nodes.size())
{
Con::cwar<<"WARNING: Attempted to add soft-body anchor for invalid node "<<nodeId<<"! Skipping..."<<Con::endl;
Con::cwar<<"Attempted to add soft-body anchor for invalid node "<<nodeId<<"! Skipping..."<<Con::endl;
return;
}
GetInternalObject().appendAnchor(nodeId,&dynamic_cast<BtRigidBody&>(body).GetInternalObject(),uvec::create_bt(localPivot) *BtEnvironment::WORLD_SCALE,bDisableCollision,influence);
Expand All @@ -749,7 +749,7 @@ void pragma::physics::BtSoftBody::AppendAnchor(uint32_t nodeId,pragma::physics::
assert(nodeId < GetInternalObject().m_nodes.size());
if(nodeId >= GetInternalObject().m_nodes.size())
{
Con::cwar<<"WARNING: Attempted to add soft-body anchor for invalid node "<<nodeId<<"! Skipping..."<<Con::endl;
Con::cwar<<"Attempted to add soft-body anchor for invalid node "<<nodeId<<"! Skipping..."<<Con::endl;
return;
}
GetInternalObject().appendAnchor(nodeId,&dynamic_cast<BtRigidBody&>(body).GetInternalObject(),bDisableCollision,influence);
Expand Down Expand Up @@ -1007,7 +1007,7 @@ void pragma::physics::BtSoftBody::SetSubMesh(const ModelSubMesh &subMesh,const s
continue;
if(localIdx >= m_localVertexIndicesToMeshVertexIndices.size())
{
Con::cwar<<"WARNING: Invalid soft-body node index "<<localIdx<<"! Skipping..."<<Con::endl;
Con::cwar<<"Invalid soft-body node index "<<localIdx<<"! Skipping..."<<Con::endl;
continue;
}
m_localVertexIndicesToMeshVertexIndices.at(localIdx) = i;
Expand Down
9 changes: 7 additions & 2 deletions src/constraint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,16 @@ void pragma::physics::BtConeTwistConstraint::SetLimit(const Vector3 &lowerLimits
}
void pragma::physics::BtConeTwistConstraint::SetLimit(float swingSpan1,float swingSpan2,float twistSpan)
{
// TODO
GetInternalObject().setLimit(
swingSpan1,swingSpan2,twistSpan
// ,softness,biasFactor,relaxationFactor
);
}
void pragma::physics::BtConeTwistConstraint::GetLimit(float &outSwingSpan1,float &outSwingSpan2,float &outTwistSpan)
{
// TODO
outSwingSpan1 = GetInternalObject().getSwingSpan1();
outSwingSpan2 = GetInternalObject().getSwingSpan2();
outTwistSpan = GetInternalObject().getTwistSpan();
}
/*void pragma::physics::BtConeTwistConstraint::SetLimit(AxisType type,pragma::Axis axis,double lo,double hi)
{
Expand Down
2 changes: 1 addition & 1 deletion src/environment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ struct Vector3d
static std::unique_ptr<btSoftBody> createSoftBody(const PhysSoftBodyInfo &sbInfo,btSoftRigidDynamicsWorld *world,btSoftBodyWorldInfo *info,float mass,std::vector<Vector3d> &verts,std::vector<int32_t> indices) {
if(mass == 0.f)
{
Con::cwar<<"WARNING: Attempted to create soft-body object with mass of 0! Using mass of 1 instead..."<<Con::endl;
Con::cwar<<"Attempted to create soft-body object with mass of 0! Using mass of 1 instead..."<<Con::endl;
mass = 1.f;
}
auto cloth = std::unique_ptr<btSoftBody>{btSoftBodyHelpers::CreateFromTriMesh(*info,reinterpret_cast<btScalar*>(verts.data()),indices.data(),indices.size() /3,true)};
Expand Down

0 comments on commit 4f1aea9

Please sign in to comment.