From 160301c1abdcc19908e0c21f31dd568058ef60ba Mon Sep 17 00:00:00 2001 From: Adam Martin Date: Wed, 1 Jun 2016 17:18:16 -0500 Subject: [PATCH] Re-enabled gravity and changes player's collision capsule size Removed VoxelVolume code from test_data.cpp. Trivial cleanup in test_data.cpp. --- client/test_data.cpp | 34 ++-------------------------------- server/client_connection.cpp | 6 +++--- src/physics-system.cpp | 4 ++-- 3 files changed, 7 insertions(+), 37 deletions(-) diff --git a/client/test_data.cpp b/client/test_data.cpp index 41a48e40..18a026ba 100644 --- a/client/test_data.cpp +++ b/client/test_data.cpp @@ -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(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 mesh1 = MD5Mesh::Create(FilePath::GetAssetPath("bob/bob.md5mesh")); @@ -224,14 +195,13 @@ namespace tec { std::fstream input(fname.GetNativePath(), std::ios::in | std::ios::binary); std::shared_ptr data = std::make_shared(); data->entity.ParseFromIstream(&input); - eid entity_id = data->entity.id(); - data->entity_id = entity_id; + data->entity_id = data->entity.id();; EventSystem::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())); } } } diff --git a/server/client_connection.cpp b/server/client_connection.cpp index 403d8b13..649b0b13 100644 --- a/server/client_connection.cpp +++ b/server/client_connection.cpp @@ -47,7 +47,7 @@ namespace tec { void ClientConnection::DoJoin() { // Build an entity Entity self(this->id); - self.Add(glm::vec3(10,10,10), Orientation(), Velocity(), true); + self.Add(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(); @@ -55,8 +55,8 @@ namespace tec { 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::Set(this->id, body); diff --git a/src/physics-system.cpp b/src/physics-system.cpp index cdfbaa50..88d9e276 100644 --- a/src/physics-system.cpp +++ b/src/physics-system.cpp @@ -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); @@ -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());