fixed issue of idle objects not moved by force application
This commit is contained in:
parent
ed2822a8f2
commit
eb5f199b60
|
@ -89,8 +89,14 @@ class irrDynamics
|
||||||
* \param node The scene node the force should be applied to.
|
* \param node The scene node the force should be applied to.
|
||||||
* \param force The force to apply, the vector represents its direction, the vector length its power.*/
|
* \param force The force to apply, the vector represents its direction, the vector length its power.*/
|
||||||
static void applyCentralForce(irr::scene::ISceneNode* node, const irr::core::vector3df& force);
|
static void applyCentralForce(irr::scene::ISceneNode* node, const irr::core::vector3df& force);
|
||||||
|
static void applyCentralImpulse(irr::scene::ISceneNode* node, const irr::core::vector3df& force);
|
||||||
static void setDamping(irr::scene::ISceneNode* node, irr::f32 linearDamping, irr::f32 angularDamping);
|
static void setDamping(irr::scene::ISceneNode* node, irr::f32 linearDamping, irr::f32 angularDamping);
|
||||||
static void setPosition(irr::scene::ISceneNode* node, const irr::core::vector3df& newPos);
|
static void setPosition(irr::scene::ISceneNode* node, const irr::core::vector3df& newPos);
|
||||||
|
//! Change default gravity
|
||||||
|
/** Per default, irrDynamics is set to an earth-like gravitational force. Modify that for other planets
|
||||||
|
* or your space sim game.
|
||||||
|
* \param newGravity New gravitational force in m/s^2.*/
|
||||||
|
static void setGravity(irr::f32 newGravity);
|
||||||
// static IRigidBody* createRigidBodyByBB(scene::ISceneNode* node, f32 mass);
|
// static IRigidBody* createRigidBodyByBB(scene::ISceneNode* node, f32 mass);
|
||||||
static void debugDraw();
|
static void debugDraw();
|
||||||
|
|
||||||
|
@ -112,7 +118,6 @@ class irrDynamics
|
||||||
class btSequentialImpulseConstraintSolver *solver;
|
class btSequentialImpulseConstraintSolver *solver;
|
||||||
class btDiscreteDynamicsWorld* world;
|
class btDiscreteDynamicsWorld* world;
|
||||||
|
|
||||||
// irrBulletWorld* bWorld;
|
|
||||||
irr::u32 lastStep;
|
irr::u32 lastStep;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -118,6 +118,11 @@ void irrDynamics::debugDraw()
|
||||||
// getInstance()->bWorld->debugDrawWorld(true);
|
// getInstance()->bWorld->debugDrawWorld(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void irrDynamics::setGravity(f32 newGravity)
|
||||||
|
{
|
||||||
|
getInstance()->world->setGravity(btVector3(0.f, newGravity, 0.f));
|
||||||
|
}
|
||||||
|
|
||||||
void irrDynamics::updateObjects()
|
void irrDynamics::updateObjects()
|
||||||
{
|
{
|
||||||
for (std::map<scene::ISceneNode*, btRigidBody*>::iterator iter = objects.begin(); iter != objects.end(); iter++)
|
for (std::map<scene::ISceneNode*, btRigidBody*>::iterator iter = objects.begin(); iter != objects.end(); iter++)
|
||||||
|
@ -354,6 +359,23 @@ void irrDynamics::applyCentralForce(scene::ISceneNode* node, const core::vector3
|
||||||
}
|
}
|
||||||
|
|
||||||
iter->second->applyCentralForce(btVector3(force.X, force.Y, force.Z));
|
iter->second->applyCentralForce(btVector3(force.X, force.Y, force.Z));
|
||||||
|
iter->second->activate();
|
||||||
|
}
|
||||||
|
|
||||||
|
void irrDynamics::applyCentralImpulse(scene::ISceneNode* node, const core::vector3df& force)
|
||||||
|
{
|
||||||
|
irrDynamics* inst = getInstance();
|
||||||
|
//find the corresponding rigid body:
|
||||||
|
std::map<scene::ISceneNode*, btRigidBody*>::iterator iter;
|
||||||
|
iter = inst->objects.find(node);
|
||||||
|
if (iter == inst->objects.end())
|
||||||
|
{
|
||||||
|
printf("irrdynamics: Unable to find node in list. Impulse application aborted.\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
iter->second->applyCentralImpulse(btVector3(force.X, force.Y, force.Z));
|
||||||
|
iter->second->activate();
|
||||||
}
|
}
|
||||||
|
|
||||||
btRigidBody* irrDynamics::addFloor(const core::vector3df& normal, const core::vector3df& offset)
|
btRigidBody* irrDynamics::addFloor(const core::vector3df& normal, const core::vector3df& offset)
|
||||||
|
|
Loading…
Reference in New Issue