My problem is that I have a rigidbody, but raycasts don't seem to find it after reloading it.
First some loading code:
Code: Select all
//Calls world->removeCollisionObject() with rigidbody pointer.
//Then deletes the old rigidbody and removes it from dynamicsworld, then deletes motionstate.
cleanUp();
...
if (myMass > 0.0)
myShape.getShape()->calculateLocalInertia(myMass, inertiaTensor);
motionState = new btDefaultMotionState(myBTransform);
const btRigidBody::btRigidBodyConstructionInfo info(
myMass, motionState, myShape.getShape().get(), inertiaTensor);
{
std::lock_guard<std::mutex> lockBody(bodyGuard);
myBody = new btRigidBody(info);
myBody->setRestitution(coefficientRestitution);
myBody->setUserPointer((void *)this);
....
//Adds rigidbody to the world by calling world->addRigidbody() function, passing the actual btRigidbody
BulletWorld::instance().addRigidbody(this);
Overall this process works fine for 2 other identical objects, but for some reason the 3rd object doesn't take the raycast. I also checked to see that it wasn't a problem with the ray by checking all collisions from the raycast, and it ends up taking the ground behind the object I'm trying to cast against.
The strange thing that I can get collisions against this last object with a capsule collision object and it works just fine.
A few things I have already tried:
1. If I remove the reload function, the collisions work for this object, which tells me it may be in the load function. Again, this process works just fine for 2 other objects that are identical, but I checked it.
2. Raycasting to the mirrored side of the object (because this is a mouse raycast I wanted to be certain that it wasn't mirrored)
3. Draw the physics debugger to find where the actual collision object and ran into it with a collision object to make sure it was there.
4. Removing all aspect of threading to check for race conditions.
The attached picture has a yellow arrow at the top, indicating that the raycast hit the object. The blue arrow also works though it's not shown here. But that one on the right, the red arrow, is the one that's not responding to raycasting.
Any ideas why this may be happening?
Thanks,
Devmane144