Skip to content

Commit

Permalink
Re-enabled gravity and changes player's collision capsule size
Browse files Browse the repository at this point in the history
Removed VoxelVolume code from test_data.cpp.

Trivial cleanup in test_data.cpp.
  • Loading branch information
adam4813 committed Jun 1, 2016
1 parent 8a41e5e commit 160301c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 37 deletions.
34 changes: 2 additions & 32 deletions client/test_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,35 +163,6 @@ namespace tec {
};
auto deferred_shadow_shader = Shader::CreateFromFile("deferred_shadow", deferred_shadow_shader_files);

auto voxvol = VoxelVolume::Create(100, "bob");
auto voxvol_shared = voxvol.lock();
FilePath metal_wall_filename = FilePath::GetAssetPath("metal_wall.png");
auto pixbuf = PixelBuffer::Create("metal_wall", metal_wall_filename);
auto tex = std::make_shared<TextureObject>(pixbuf);
TextureMap::Set("metal_wall", tex);

VoxelCommand add_voxel(
[ ] (VoxelVolume* vox_vol) {
for (int i = -5; i <= 5; ++i) {
for (int j = -25; j <= 25; ++j) {
vox_vol->AddVoxel(-1, i, j);
}
}
});
VoxelVolume::QueueCommand(std::move(add_voxel));
voxvol_shared->Update(0.0);

VoxelCommand rem_voxel(
[ ] (VoxelVolume* vox_vol) {
vox_vol->RemoveVoxel(-1, 5, 5);
});
VoxelVolume::QueueCommand(std::move(rem_voxel));
voxvol_shared->Update(0.0);
{
Entity voxel1(100);
voxel1.Add(voxvol_shared);
}

{
Entity bob(99);
std::shared_ptr<MD5Mesh> mesh1 = MD5Mesh::Create(FilePath::GetAssetPath("bob/bob.md5mesh"));
Expand Down Expand Up @@ -224,14 +195,13 @@ namespace tec {
std::fstream input(fname.GetNativePath(), std::ios::in | std::ios::binary);
std::shared_ptr<EntityCreated> data = std::make_shared<EntityCreated>();
data->entity.ParseFromIstream(&input);
eid entity_id = data->entity.id();
data->entity_id = entity_id;
data->entity_id = data->entity.id();;
EventSystem<EntityCreated>::Get()->Emit(data);
for (int i = 0; i < data->entity.components_size(); ++i) {
const proto::Component& comp = data->entity.components(i);
if (in_functors.find(comp.component_case()) != in_functors.end()) {
in_functors[comp.component_case()](data->entity, comp);
entity_out_functors[entity_id].insert(&out_functors.at(comp.component_case()));
entity_out_functors[data->entity_id].insert(&out_functors.at(comp.component_case()));
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions server/client_connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,16 @@ namespace tec {
void ClientConnection::DoJoin() {
// Build an entity
Entity self(this->id);
self.Add<Position, Orientation, Velocity, View>(glm::vec3(10,10,10), Orientation(), Velocity(), true);
self.Add<Position, Orientation, Velocity, View>(glm::vec3(0,1.0,0), Orientation(), Velocity(), true);
CollisionBody* body = new CollisionBody();
proto::Component* component = this->entity.add_components();
proto::CollisionBody* body_component = component->mutable_collision_body();
body_component->set_mass(1.0f);
body_component->set_disable_deactivation(true);
body_component->set_disable_rotation(true);
proto::CollisionBody_Capsule* capsule_component = body_component->mutable_capsule();
capsule_component->set_height(1.0f);
capsule_component->set_radius(0.6f);
capsule_component->set_height(1.6f);
capsule_component->set_radius(0.5f);
body->entity_id = this->id;
body->In(*component);
Multiton<eid, CollisionBody*>::Set(this->id, body);
Expand Down
4 changes: 2 additions & 2 deletions src/physics-system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace tec {
this->broadphase = new btDbvtBroadphase();
this->solver = new btSequentialImpulseConstraintSolver();
this->dynamicsWorld = new btDiscreteDynamicsWorld(this->dispatcher, this->broadphase, this->solver, this->collisionConfiguration);
this->dynamicsWorld->setGravity(btVector3(0, 0.0, 0));
this->dynamicsWorld->setGravity(btVector3(0, -3.5, 0));

btGImpactCollisionAlgorithm::registerAlgorithm(this->dispatcher);

Expand Down Expand Up @@ -114,7 +114,7 @@ namespace tec {
if (state.velocties.find(entity_id) != state.velocties.end()) {
const Velocity& vel = state.velocties.at(entity_id);
if (std::isfinite(vel.linear.x) && std::isfinite(vel.linear.x) && std::isfinite(vel.linear.x)) {
body->setLinearVelocity(vel.GetLinear() + body->getGravity());
body->setLinearVelocity(vel.GetLinear() + btVector3(0.0, 1.0, 0.0) + body->getGravity());
}
if (std::isfinite(vel.angular.x) && std::isfinite(vel.angular.x) && std::isfinite(vel.angular.x)) {
body->setAngularVelocity(vel.GetAngular());
Expand Down

0 comments on commit 160301c

Please sign in to comment.