-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'collision' - I should have done this ages ago.
Conflicts: src/bindings.cpp src/includes.h src/main.cpp src/ph-utils src/player.h
- Loading branch information
Showing
25 changed files
with
596 additions
and
106 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
env = Environment() | ||
env = Environment(CPPPATH=['/usr/include/bullet']) | ||
|
||
debug = ARGUMENTS.get('debug', 0) | ||
if int(debug): | ||
env.Append(CCFLAGS = '-g') | ||
env.Append(CPPDEFINES = 'DEBUG') | ||
|
||
env.Program("#gel-on-earth", Glob('*.cpp'), | ||
LIBS=['GL', 'GLU', 'sfml-system', 'sfml-window', 'sfml-graphics']) | ||
LIBS=['GL', 'GLU', 'sfml-system', 'sfml-window', 'sfml-graphics', | ||
'BulletDynamics']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#include "bullet.h" | ||
|
||
Bullet::Bullet(ph::vec3f pos, ph::vec3f vel) { | ||
shape = new btSphereShape(0.2); | ||
|
||
btScalar mass = 1; | ||
btVector3 inertia = vel; | ||
btMotionState *state = new btDefaultMotionState(btTransform(btQuaternion(0,0,0,1), pos)); | ||
|
||
initialize(mass, inertia, state); | ||
|
||
body->setGravity(btVector3(0,0,0)); | ||
body->setCcdMotionThreshold(0.2); | ||
body->setCcdSweptSphereRadius(0.2); | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#ifndef GOE_BULLET_H | ||
#define GOE_BULLET_H | ||
|
||
#include "entity.h" | ||
|
||
class Bullet : public Entity { | ||
public: | ||
typedef Entity super; | ||
|
||
Bullet(ph::vec3f pos, ph::vec3f vel); | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#include "debug-draw.h" | ||
#include "vertex.h" | ||
|
||
void DebugDraw::drawLine(const btVector3 &from, const btVector3 &to, | ||
const btVector3 &color) | ||
{ | ||
Vertex line[] = { | ||
Vertex(from, color.x(), color.y(), color.z()), | ||
Vertex(to, color.x(), color.y(), color.z()) | ||
}; | ||
|
||
line->draw(GL_LINES, 2); | ||
} | ||
|
||
void DebugDraw::setDebugMode(int m) { | ||
mode = m; | ||
} | ||
int DebugDraw::getDebugMode() const { | ||
return mode; | ||
} | ||
|
||
void DebugDraw::drawContactPoint(const btVector3&, const btVector3&, btScalar, | ||
int, const btVector3&) | ||
{ | ||
printf("drawContactPoint()"); | ||
} | ||
void DebugDraw::reportErrorWarning(const char*) { | ||
printf("reportErrorWarning()"); | ||
} | ||
void DebugDraw::draw3dText(const btVector3&, const char*) { | ||
printf("draw3dText()"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#ifndef GOE_DEBUG_DRAW_H | ||
#define GOE_DEBUG_DRAW_H | ||
|
||
#include "includes.h" | ||
|
||
class DebugDraw : public btIDebugDraw { | ||
public: | ||
int mode; | ||
|
||
void drawLine(const btVector3 &from, const btVector3 &to, | ||
const btVector3 &color); | ||
|
||
void setDebugMode(int); | ||
int getDebugMode() const; | ||
|
||
/* These are pure virtual, but I haven't really implemented them. */ | ||
void drawContactPoint(const btVector3&, const btVector3&, btScalar, | ||
int, const btVector3&); | ||
void reportErrorWarning(const char*); | ||
void draw3dText(const btVector3&, const char*); | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#include "entity.h" | ||
#include "globals.h" | ||
|
||
Entity::Entity () | ||
: shape(NULL), body(NULL) | ||
{} | ||
|
||
Entity::~Entity() { | ||
if (shape) | ||
delete shape; | ||
|
||
if (body) { | ||
G::physics->removeRigidBody(body); | ||
|
||
if (body->getMotionState()) | ||
delete body->getMotionState(); | ||
|
||
delete body; | ||
} | ||
} | ||
|
||
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); | ||
} | ||
} | ||
|
||
void Entity::update () {} | ||
void Entity::draw () {} | ||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#ifndef GOE_ENTITY_H | ||
#define GOE_ENTITY_H | ||
|
||
#include "includes.h" | ||
|
||
class Entity { | ||
public: | ||
Entity(); | ||
~Entity(); | ||
|
||
virtual void initialize(btScalar mass, btVector3 vel, | ||
btMotionState *state); | ||
|
||
virtual void update(); | ||
virtual void draw(); | ||
|
||
btCollisionShape* shape; | ||
btRigidBody *body; | ||
}; | ||
|
||
#endif | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.