activate object after size changes...
Posted: Thu Jan 31, 2019 4:12 pm
Hey, hey, hey, I change objects sizes and update their collision shapes, then call the method activateAllObjects() but the objects
remain hung in thin air, see pic and code here below...
The same method activateAllObjects() works fine elsewhere in the project. If I click on and off on the resized object, it remains
hung. rigidBody->activate(true) did not work either. The object starts falling down only if I pick it up and move it with the mouse.
So, please, how to activate resized objects, so they fall down by gravity once resized? ))
remain hung in thin air, see pic and code here below...
The same method activateAllObjects() works fine elsewhere in the project. If I click on and off on the resized object, it remains
hung. rigidBody->activate(true) did not work either. The object starts falling down only if I pick it up and move it with the mouse.
So, please, how to activate resized objects, so they fall down by gravity once resized? ))
Code: Select all
switch (collisionShape->getShapeType()) {
case BOX_SHAPE_PROXYTYPE:
collisionShape->setLocalScaling(sizeObject);
break;
case SPHERE_SHAPE_PROXYTYPE:
collisionShape->setLocalScaling(sizeObject);
break;
case CYLINDER_SHAPE_PROXYTYPE:
collisionShape->setLocalScaling(sizeObject);
break;
case CONE_SHAPE_PROXYTYPE:
collisionShape->setLocalScaling(sizeObject);
break;
case CONVEX_HULL_SHAPE_PROXYTYPE: { // icosahedron, table, tree, flower, mushroom,...
btConvexHullShape* convexHullShape = static_cast<btConvexHullShape*>(collisionShape);
convexHullShape->setLocalScaling(sizeObject);
convexHullShape->initializePolyhedralFeatures();
break;
}
case GIMPACT_SHAPE_PROXYTYPE: { // truck, bunny,...
btGImpactMeshShape* impactMeshShape = static_cast<btGImpactMeshShape*>(collisionShape);
impactMeshShape->updateBound();
impactMeshShape->setLocalScaling(sizeObject);
impactMeshShape->setMargin(0.04f);
break;
}
default:
logStderr("ERROR: Unrecognized collision shape...\n");
break;
}
rigidBody->activate(true);
m_dynamicsWorld->updateSingleAabb(rigidBody);
Code: Select all
void InceptionPhysics::activateAllObjects() {
for (int i = m_dynamicsWorld->getNumCollisionObjects() - 1; i >= 0; i--) {
btCollisionObject* collisionObject = m_dynamicsWorld->getCollisionObjectArray()[i];
collisionObject->activate(true);
}
}