New user here, first post, hope I put this on the correct board. Just want to start off by saying awesome engine! I tried searching the board before posting but couldn't find anything.
I am currently using Bullet and OgreBullet for physics and I came across a problem. I have kinematic character controller that I created based on the character demo and it works fine. It collides correctly with all shapes I have tested so far convex hulls, boxes, trimeshes, cylinders, capsules and compound shapes but it crashes every time it hits a plane with the error "access violation while reading location 0x00000030." Collision between the plane and other things such as boxes, convex shapes and compound shapes works fine. Any ideas what the problem might be?
Here are some code snippets:
Creating the character:
Code: Select all
btTransform startTransform;
startTransform.setIdentity ();
startTransform.setOrigin (btVector3(node->getPosition().x,node->getPosition().y,node->getPosition().z));
btPairCachingGhostObject* m_ghostObject = new btPairCachingGhostObject();
m_ghostObject->setWorldTransform(startTransform);
mWorld->getBulletDynamicsWorld()->getPairCache()->setInternalGhostPairCallback(new btGhostPairCallback());
Vector3 size = entity->getBoundingBox().getSize()*0.5f*0.96f;
btConvexShape* cylinder = new btCylinderShape(btVector3(size.x, size.y, size.z));
m_ghostObject->setCollisionShape (cylinder);
m_ghostObject->setCollisionFlags (btCollisionObject::CF_CHARACTER_OBJECT);
btScalar stepHeight = btScalar(0.35);
btKinematicCharacterController* m_character = new btKinematicCharacterController (m_ghostObject,cylinder,stepHeight);
mWorld->getBulletDynamicsWorld()->addCollisionObject(m_ghostObject,btBroadphaseProxy::CharacterFilter, btBroadphaseProxy::StaticFilter|btBroadphaseProxy::DefaultFilter);
mWorld->getBulletDynamicsWorld()->addAction(m_character);
mWorld->getBulletDynamicsWorld()->getBroadphase()->getOverlappingPairCache()->cleanProxyFromPairs(m_ghostObject->getBroadphaseHandle(),mWorld->getBulletDynamicsWorld()->getDispatcher());
m_character->reset ();
m_character->warp (btVector3(node->getPosition().x,node->getPosition().y,node->getPosition().z));
//setting some parameters
m_character->setJumpSpeed(160);
m_character->setGravity(75);
m_characters.push_back(m_character);
nodes.push_back(node);
collisionMap.insert(std::pair<btCollisionObject*, SceneNode*>(m_ghostObject, node));
return agent;
Code: Select all
void PhysicsHandler::addPlane(Plane p, std::string name, const float restitution, const float friction){
OgreBulletCollisions::CollisionShape *Shape;
Shape = new OgreBulletCollisions::StaticPlaneCollisionShape(p.normal, -p.d); // (normal vector, distance)
OgreBulletDynamics::RigidBody *defaultPlaneBody = new OgreBulletDynamics::RigidBody(name, mWorld);
defaultPlaneBody->setStaticShape(Shape, restitution, friction); // (shape, restitution, friction)
// push the created objects to the deques
mShapes.push_back(Shape);
mBodies.push_back(defaultPlaneBody);
}
Thanks in advance