Added IceBrick and started to remove the scale dependency for physics bodies

This commit is contained in:
viktorljung
2015-10-05 16:25:00 +02:00
parent dca06a46a5
commit 005fd40167
7 changed files with 1264 additions and 11 deletions
+2 -1
View File
@@ -186,10 +186,11 @@ void dd::Systems::LevelSystem::CreateBrick(int row, int line, glm::vec2 spacesBe
model->ModelFile = "Models/Test/Brick/Brick.obj";
if ((line == 1 && row == 4) || (line == 3 && row == 2) || (line == 6 && row == 6)) {
std::shared_ptr<Components::PowerUpBrick> cPow = m_World->AddComponent<Components::PowerUpBrick>(brick);
model->ModelFile = "Models/Brick/IceBrick.obj";
}
float x = line * spacesBetweenBricks.x;
float y = row * spacesBetweenBricks.y;
transform->Scale = glm::vec3(0.8, 0.2, 0.2);
//transform->Scale = glm::vec3(0.8, 0.2, 0.2);
transform->Position = glm::vec3(x - 3, 5 - spaceToEdge - y , -10.f);
cBrick->Score = 10 * num;
+4 -8
View File
@@ -252,20 +252,16 @@ void dd::Systems::PhysicsSystem::CreateBody(EntityID entity)
b2Shape* pShape;
auto boxComponent = m_World->GetComponent<Components::RectangleShape>(entity);
if (boxComponent) {
auto rectangleComponent = m_World->GetComponent<Components::RectangleShape>(entity);
if (rectangleComponent) {
b2PolygonShape* bShape = new b2PolygonShape();
bShape->SetAsBox(absoluteTransform.Scale.x/2, absoluteTransform.Scale.y/2);
bShape->SetAsBox(rectangleComponent->Dimensions.x/2.f, rectangleComponent->Dimensions.y/2.f);
pShape = bShape;
} else {
auto circleComponent = m_World->GetComponent<Components::CircleShape>(entity);
if (circleComponent) {
pShape = new b2CircleShape();
pShape->m_radius = absoluteTransform.Scale.x/2;
if (absoluteTransform.Scale.x != absoluteTransform.Scale.y && absoluteTransform.Scale.y != absoluteTransform.Scale.z) {
LOG_WARNING("Circles has to be of uniform scale. xScale has been used for radius");
}
pShape->m_radius = circleComponent->Radius;
}
}