Permalink
Browse files

Bullets now move when fired.

My mistake was in thinking that calculateLocalInertia would set the
inertia of the body from the argument. Actually it changes the argument
to reflect the inertia.

Bullets seem to go through walls alarmingly often, even if I increase
the number of steps.
  • Loading branch information...
ChickenProp committed Dec 18, 2010
1 parent fd25c14 commit 0300529f0d9e7f2c6f7c1cf9835954a93f2ba34b
Showing with 5 additions and 3 deletions.
  1. +3 −1 src/entity.cpp
  2. +1 −1 src/entity.h
  3. +1 −1 src/player.cpp
View
@@ -19,14 +19,16 @@ Entity::~Entity() {
}
}
-void Entity::initialize (btScalar mass, btVector3 inertia, btMotionState *state)
+void Entity::initialize (btScalar mass, btVector3 vel, btMotionState *state)
{
if (shape) {
+ btVector3 inertia;
shape->calculateLocalInertia(mass, inertia);
btRigidBody::btRigidBodyConstructionInfo
construct(mass, state, shape, inertia);
body = new btRigidBody(construct);
+ body->setLinearVelocity(vel);
body->setActivationState(DISABLE_DEACTIVATION);
G::physics->addRigidBody(body);
View
@@ -8,7 +8,7 @@ class Entity {
Entity();
~Entity();
- virtual void initialize(btScalar mass, btVector3 inertia,
+ virtual void initialize(btScalar mass, btVector3 vel,
btMotionState *state);
virtual void update();
View
@@ -40,7 +40,7 @@ void Player::shoot() {
// don't need to worry about where I create it. (When I make the player
// be not-a-sphere, it may not be obvious how far away I should create
// the bullet not to be intersecting the player.)
- new Bullet(pos + orientation*2, orientation);
+ Bullet *b = new Bullet(pos + orientation*2, orientation*50);
}
void Player::strafe(float fwd, float side) {

0 comments on commit 0300529

Please sign in to comment.