cool fixes and stuff

This commit is contained in:
viktorljung
2015-09-25 05:33:10 +02:00
parent a730a1ce16
commit cb48b881b7
3 changed files with 8 additions and 7 deletions
+1 -1
View File
@@ -208,7 +208,7 @@ public:
{ {
auto t_waterBody = m_World->CreateEntity(); auto t_waterBody = m_World->CreateEntity();
auto transform = m_World->AddComponent<Components::Transform>(t_waterBody); auto transform = m_World->AddComponent<Components::Transform>(t_waterBody);
transform->Position = glm::vec3(0.f, -4.5f, -10.f); transform->Position = glm::vec3(0.f, -5.5f, -10.f);
transform->Scale = glm::vec3(7.f, 1.5f, 1.f); transform->Scale = glm::vec3(7.f, 1.5f, 1.f);
auto water = m_World->AddComponent<Components::WaterVolume>(t_waterBody); auto water = m_World->AddComponent<Components::WaterVolume>(t_waterBody);
auto body = m_World->AddComponent<Components::RectangleShape>(t_waterBody); auto body = m_World->AddComponent<Components::RectangleShape>(t_waterBody);
+3 -2
View File
@@ -281,9 +281,10 @@ bool dd::Systems::LevelSystem::OnContact(const dd::Events::Contact &event)
Events::SetImpulse e; Events::SetImpulse e;
e.Entity = entityBrick; e.Entity = entityBrick;
glm::vec2 point = glm::vec2(transformComponentBrick->Position.x + ((transformComponentBrick->Position.x - transformComponentBall->Position.x)/4), transformComponentBrick->Position.y + ((transformComponentBrick->Position.y - transformComponentBall->Position.y )/4)); glm::vec2 point = glm::vec2(transformComponentBrick->Position.x + ((transformComponentBall->Position.x - transformComponentBrick->Position.x )/4),
transformComponentBrick->Position.y + ((transformComponentBall->Position.y - transformComponentBrick->Position.y)/4));
e.Impulse = glm::normalize(point)/2.f; e.Impulse = glm::normalize(point)*5.f;///2.f;
e.Point = point; e.Point = point;
EventBroker->Publish(e); EventBroker->Publish(e);
//TODO: Bricks dont collide with walls D= //TODO: Bricks dont collide with walls D=
+4 -4
View File
@@ -90,7 +90,7 @@ void dd::Systems::PhysicsSystem::Update(double dt)
b2Vec2 position; b2Vec2 position;
position.x = transformComponent->Position.x; position.x = transformComponent->Position.x;
position.y = transformComponent->Position.y; position.y = transformComponent->Position.y;
float angle = -glm::eulerAngles(transformComponent->Orientation).z; float angle = glm::eulerAngles(transformComponent->Orientation).z;
body->SetTransform(position, angle); body->SetTransform(position, angle);
body->SetLinearVelocity(b2Vec2(transformComponent->Velocity.x, transformComponent->Velocity.y)); body->SetLinearVelocity(b2Vec2(transformComponent->Velocity.x, transformComponent->Velocity.y));
body->SetGravityScale(physicsComponent->GravityScale); body->SetGravityScale(physicsComponent->GravityScale);
@@ -128,7 +128,7 @@ void dd::Systems::PhysicsSystem::Update(double dt)
if (parent == 0) { if (parent == 0) {
auto physicsComponent = m_World->GetComponent<Components::Physics>(entity); auto physicsComponent = m_World->GetComponent<Components::Physics>(entity);
if (physicsComponent->Calculate) { if (physicsComponent->Calculate) { //TODO: REPLACE THIS WITH PARTICLE COLLISION FILTERS
transformComponent->Position.x = transformComponent->Position.x + (transformComponent->Velocity.x * m_TimeStep); transformComponent->Position.x = transformComponent->Position.x + (transformComponent->Velocity.x * m_TimeStep);
transformComponent->Position.y = transformComponent->Position.y + (transformComponent->Velocity.y * m_TimeStep); transformComponent->Position.y = transformComponent->Position.y + (transformComponent->Velocity.y * m_TimeStep);
} }
@@ -138,7 +138,7 @@ void dd::Systems::PhysicsSystem::Update(double dt)
transformComponent->Position.y = position.y; transformComponent->Position.y = position.y;
float angle = body->GetAngle(); float angle = body->GetAngle();
transformComponent->Orientation = glm::quat(glm::vec3(0, 0, -angle)); transformComponent->Orientation = glm::quat(glm::vec3(0, 0, angle));
b2Vec2 velocity = body->GetLinearVelocity(); b2Vec2 velocity = body->GetLinearVelocity();
transformComponent->Velocity.x = velocity.x; transformComponent->Velocity.x = velocity.x;
@@ -272,7 +272,7 @@ void dd::Systems::PhysicsSystem::CreateBody(EntityID entity)
} }
else { else {
fixtureDef.shape = pShape; fixtureDef.shape = pShape;
fixtureDef.density = 1.f; fixtureDef.density = 10.f;
fixtureDef.restitution = 1.0f; fixtureDef.restitution = 1.0f;
fixtureDef.friction = 0.0f; fixtureDef.friction = 0.0f;
body->CreateFixture(&fixtureDef); body->CreateFixture(&fixtureDef);