Add support for picking deformable with mouse

This commit is contained in:
Xuchen Han
2020-03-09 11:19:08 -07:00
parent 41ca8b9e59
commit 7dfef92267
21 changed files with 494 additions and 273 deletions

View File

@@ -21,16 +21,15 @@
#include "BulletDynamics/Featherstone/btMultiBodyConstraintSolver.h"
#include <stdio.h> //printf debugging
#include "../CommonInterfaces/CommonRigidBodyBase.h"
#include "../CommonInterfaces/CommonDeformableBodyBase.h"
#include "../Utils/b3ResourcePath.h"
///The DeformableSelfCollision shows deformable self collisions
class DeformableSelfCollision : public CommonRigidBodyBase
class DeformableSelfCollision : public CommonDeformableBodyBase
{
btAlignedObjectArray<btDeformableLagrangianForce*> m_forces;
public:
DeformableSelfCollision(struct GUIHelperInterface* helper)
: CommonRigidBodyBase(helper)
: CommonDeformableBodyBase(helper)
{
}
virtual ~DeformableSelfCollision()
@@ -57,23 +56,9 @@ public:
void addCloth(btVector3 origin);
virtual const btDeformableMultiBodyDynamicsWorld* getDeformableDynamicsWorld() const
{
///just make it a btSoftRigidDynamicsWorld please
///or we will add type checking
return (btDeformableMultiBodyDynamicsWorld*)m_dynamicsWorld;
}
virtual btDeformableMultiBodyDynamicsWorld* getDeformableDynamicsWorld()
{
///just make it a btSoftRigidDynamicsWorld please
///or we will add type checking
return (btDeformableMultiBodyDynamicsWorld*)m_dynamicsWorld;
}
virtual void renderScene()
{
CommonRigidBodyBase::renderScene();
CommonDeformableBodyBase::renderScene();
}
};
@@ -183,7 +168,7 @@ void DeformableSelfCollision::addCloth(btVector3 origin)
void DeformableSelfCollision::exitPhysics()
{
//cleanup in the reverse order of creation/initialization
removePickingConstraint();
//remove the rigidbodies from the dynamics world and delete them
int i;
for (i = m_dynamicsWorld->getNumCollisionObjects() - 1; i >= 0; i--)