编辑:花了一点时间理解我编写的代码后,我仍然不知道它有什么问题。这是我派生类的基类:
///ContactResultCallback is used to report contact points
struct ContactResultCallback
{
short int m_collisionFilterGroup;
short int m_collisionFilterMask;
ContactResultCallback()
:m_collisionFilterGroup(btBroadphaseProxy::DefaultFilter),
m_collisionFilterMask(btBroadphaseProxy::AllFilter)
{
}
virtual ~ContactResultCallback()
{
}
virtual bool needsCollision(btBroadphaseProxy* proxy0) const
{
bool collides = (proxy0->m_collisionFilterGroup & m_collisionFilterMask) != 0;
collides = collides && (m_collisionFilterGroup & proxy0->m_collisionFilterMask);
return collides;
}
virtual btScalar addSingleResult(btManifoldPoint& cp, const btCollisionObjectWrapper* colObj0Wrap,int partId0,int index0,const btCollisionObjectWrapper* colObj1Wrap,int partId1,int index1) = 0;
};
现在这是我的派生类:
class DisablePairCollision : public btCollisionWorld::ContactResultCallback
{
public:
virtual btScalar addSingleResult(btManifoldPoint& cp, const btCollisionObject* colObj0, int32_t partId0, int32_t index0, const btCollisionObject* colObj1, int32_t partId1, int32_t index1);
btDiscreteDynamicsWorld* DynamicsWorld;
};
下面是我实现主要功能的地方。仍然不确定为什么我会收到此错误。
我在带有 vc2010 和代码块的 windows 上使用下面的代码没有问题:
btScalar DisablePairCollision::addSingleResult(btManifoldPoint& cp, const btCollisionObject* colObj0, int32_t partId0, int32_t index0, const btCollisionObject* colObj1, int32_t partId1, int32_t index1)
{
// Create an identity matrix.
btTransform frame;
frame.setIdentity();
// Create a constraint between the two bone shapes which are contacting each other.
btGeneric6DofConstraint* Constraint;
Constraint = new btGeneric6DofConstraint( *(btRigidBody*)colObj0, *(btRigidBody*)colObj1, frame, frame, true );
// Set limits to be limitless.
Constraint->setLinearLowerLimit( btVector3(1, 1, 1 ) );
Constraint->setLinearUpperLimit( btVector3(0, 0, 0 ) );
Constraint->setAngularLowerLimit( btVector3(1, 1, 1 ) );
Constraint->setAngularUpperLimit( btVector3(0, 0, 0 ) );
// Add constraint to scene.
DynamicsWorld->addConstraint(Constraint, true);
return 0;
}
现在我正在尝试在 Ubuntu 上编译我的项目,但是当我尝试使用该类时出现此错误:
/home/steven/Desktop/ovgl/src/OvglScene.cpp:211: error: cannot declare variable ‘Callback’ to be of abstract type ‘Ovgl::DisablePairCollision’