Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2009-08-18 09:24:15 +0000
committerStijn Buys <ingar@osirion.org>2009-08-18 09:24:15 +0000
commitf030154fe727e25a2afe1f78b3998c2d2dba95e4 (patch)
treecd92baf9e4fa8a136523b9eb570e9811846c9250 /src/game/base/physics.cc
parent5636fad174f0bcff857c357c394c4cc8d424b302 (diff)
astyle cleanup, corrects not loading of material textures
Diffstat (limited to 'src/game/base/physics.cc')
-rw-r--r--src/game/base/physics.cc45
1 files changed, 22 insertions, 23 deletions
diff --git a/src/game/base/physics.cc b/src/game/base/physics.cc
index b76e0c1..3cc7427 100644
--- a/src/game/base/physics.cc
+++ b/src/game/base/physics.cc
@@ -49,12 +49,12 @@ CollisionShape::CollisionShape(model::Model *model, const bool moving)
if (group->type() == model::FragmentGroup::None) {
// for each fragment
- for (model::FragmentGroup::iterator fit = group->begin(); fit != group->end(); fit++) {
+ for (model::FragmentGroup::iterator fit = group->begin(); fit != group->end(); fit++) {
model::Fragment *fragment = (*fit);
- const size_t index = fragment->index();
- const size_t triangle_count = (fragment->structural_size() + fragment->detail_size()) / 3;
-
+ const size_t index = fragment->index();
+ const size_t triangle_count = (fragment->structural_size() + fragment->detail_size()) / 3;
+
// load vertices from the global VertexArray into the bullet shape
for (size_t i = 0; i < triangle_count; i++) {
float *f = vertexarray->vertex() + index + (i * 9);
@@ -81,8 +81,8 @@ CollisionShape::CollisionShape(model::Model *model, const bool moving)
static_shape = new btBvhTriangleMeshShape(shape_mesh, true, false);
shape_bulletshape = static_shape;
}
-
-
+
+
con_debug << " collision data for " << model->name() << ": " << count << " tris " << std::endl;
#endif
}
@@ -136,10 +136,10 @@ void Physics::init()
{
con_print << "^BInitializing bullet physics..." << std::endl;
- configuration = new btDefaultCollisionConfiguration();
+ configuration = new btDefaultCollisionConfiguration();
dispatcher = new btCollisionDispatcher(configuration);
solver = new btSequentialImpulseConstraintSolver;
-
+
}
void Physics::frame(const float seconds)
@@ -183,12 +183,12 @@ void Physics::shutdown()
PhysicsZone::PhysicsZone(const std::string &label) : core::Zone(label)
{
#ifdef HAVE_BULLET
- btVector3 worldAabbMin(-10000,-10000,-10000);
- btVector3 worldAabbMax(10000,10000,10000);
+ btVector3 worldAabbMin(-10000, -10000, -10000);
+ btVector3 worldAabbMax(10000, 10000, 10000);
const int maxProxies = 1024;
-
- zone_cache = new btAxisSweep3(worldAabbMin,worldAabbMax,maxProxies);
- zone_dynamics_world = new btDiscreteDynamicsWorld(Physics::dispatcher, zone_cache, Physics::solver,Physics::configuration);
+
+ zone_cache = new btAxisSweep3(worldAabbMin, worldAabbMax, maxProxies);
+ zone_dynamics_world = new btDiscreteDynamicsWorld(Physics::dispatcher, zone_cache, Physics::solver, Physics::configuration);
// disable gravity
zone_dynamics_world->setGravity(btVector3(0.0f, 0.0f, 0.0f));
@@ -222,7 +222,7 @@ PhysicsBody::PhysicsBody(core::Entity *entity)
#endif
}
-PhysicsBody::~PhysicsBody()
+PhysicsBody::~PhysicsBody()
{
#ifdef HAVE_BULLET
if (collider_body) {
@@ -251,22 +251,22 @@ void PhysicsBody::init_physics(const float mass)
}
if (!collider_body) {
- btVector3 inertia(0,0,0);
+ btVector3 inertia(0, 0, 0);
btTransform t;
t.setIdentity();
t.setOrigin(to_btVector3(entity()->location()));
t.setBasis(to_btMatrix3x3(entity()->axis()));
-
-
+
+
if (moving) {
- collider_shape->bullet_shape()->calculateLocalInertia(mass,inertia);
+ collider_shape->bullet_shape()->calculateLocalInertia(mass, inertia);
btMotionState *motionstate = new btDefaultMotionState(t);
btRigidBody::btRigidBodyConstructionInfo body_info(mass, motionstate, collider_shape->bullet_shape(), inertia);
- collider_body = new btRigidBody(body_info);
+ collider_body = new btRigidBody(body_info);
collider_body->setUserPointer((void *)entity());
- collider_body->setLinearFactor(btVector3(1,1,1));
+ collider_body->setLinearFactor(btVector3(1, 1, 1));
collider_body->setCcdMotionThreshold(0.0001f);
} else {
collider_body = new btRigidBody(mass, 0, collider_shape->bullet_shape(), inertia);
@@ -276,7 +276,7 @@ void PhysicsBody::init_physics(const float mass)
if (entity()->zone()) {
PhysicsZone *zone = static_cast<PhysicsZone *>(entity()->zone());
- zone->dynamics_world()->addRigidBody(collider_body);
+ zone->dynamics_world()->addRigidBody(collider_body);
if (moving) {
//collider_body->setActivationState(ISLAND_SLEEPING);
//collider_body->setActivationState(ACTIVE_TAG);
@@ -292,8 +292,7 @@ void PhysicsBody::shutdown_physics()
if (collider_body && entity()->zone()) {
PhysicsZone *zone = static_cast<PhysicsZone *>(entity()->zone());
- if(collider_body->getMotionState())
- {
+ if (collider_body->getMotionState()) {
delete collider_body->getMotionState();
}
zone->dynamics_world()->removeCollisionObject(collider_body);