Permalink
Browse files

Stop tunneling, but now bullets get stuck in walls.

gNumClampedCcdMotions continues to increase, which is interesting.

Also stop segfault on quit.
  • Loading branch information...
1 parent 775fa63 commit ba00a6ac8f19d37b81df9d69d157f0dc3c156593 @ChickenProp committed Dec 28, 2010
Showing with 23 additions and 1 deletion.
  1. +2 −0 src/bullet.cpp
  2. +2 −0 src/player.cpp
  3. +17 −1 src/world.cpp
  4. +2 −0 src/world.h
View
2 src/bullet.cpp
@@ -10,6 +10,8 @@ Bullet::Bullet(ph::vec3f pos, ph::vec3f vel) {
initialize(mass, inertia, state);
body->setGravity(btVector3(0,0,0));
+ body->setCcdMotionThreshold(0.2);
+ body->setCcdSweptSphereRadius(0.2);
}
View
2 src/player.cpp
@@ -1,6 +1,7 @@
#include "player.h"
#include "globals.h"
#include "bullet.h"
+#include "world.h"
Player::Player() {
pos = ph::vec3f(0,0,1);
@@ -41,6 +42,7 @@ void Player::shoot() {
// be not-a-sphere, it may not be obvious how far away I should create
// the bullet not to be intersecting the player.)
Bullet *b = new Bullet(pos + orientation*2, orientation*50);
+ G::gameScreen->addEntity(b);
}
void Player::strafe(float fwd, float side) {
View
18 src/world.cpp
@@ -4,6 +4,9 @@
#include "wall.h"
#include "bullet.h"
+// This is a debugging symbol from bullet.
+extern int gNumClampedCcdMotions;
+
World::World() {
rotate = 0.0f;
@@ -21,7 +24,7 @@ World::World() {
G::physics->addRigidBody(groundBody);
- new Bullet(ph::vec3f(0, 2, 2), ph::vec3f(0,0,0));
+ addEntity(new Bullet(ph::vec3f(0, 2, 2), ph::vec3f(0,0,0)));
}
World::~World () {
@@ -34,12 +37,25 @@ World::~World () {
delete *it;
*it = NULL;
}
+
+ for (std::vector<Entity*>::iterator it = entities.begin();
+ it != entities.end(); it++)
+ {
+ delete *it;
+ *it = NULL;
+ }
}
void World::update() {
int steps = G::physics->stepSimulation(1/G::framerate, 10);
player.update();
rotate += 1.0f;
+
+ printf("%d\n", gNumClampedCcdMotions);
+}
+
+void World::addEntity(Entity *ent) {
+ entities.push_back(ent);
}
void World::draw() {
View
2 src/world.h
@@ -17,6 +17,8 @@ class World : public Screen {
btRigidBody *groundBody;
std::vector<Wall*> walls;
+ std::vector<Entity*> entities;
+ void addEntity(Entity *ent);
//Just for the box, which I'll remove at some point.
float rotate;

0 comments on commit ba00a6a

Please sign in to comment.