History

indents

Philip Rosedale committed 13 years ago

Commit dd09d681 parent d8dcb6a1 file · +13 −20Browse files

Showing the changes to interface/src/Field.cpp (1 of 1 file). Show all

Unified · Split

interface/src/Field.cpp+13−20
@@ -11,17 +11,15 @@ · 10 unmodified lines
1111
1212 int Field::value(float *value, float *pos) {
1313 int index = (int)(pos[0] / _worldSize * 10.0) +
14− (int)(pos[1] / _worldSize * 10.0) * 10 +
15− (int)(pos[2] / _worldSize * 10.0) * 100;
14+ (int)(pos[1] / _worldSize * 10.0) * 10 +
15+ (int)(pos[2] / _worldSize * 10.0) * 100;
1616
17− if ((index >= 0) && (index < FIELD_ELEMENTS))
18− {
17+ if ((index >= 0) && (index < FIELD_ELEMENTS)) {
1918 value[0] = _field[index].val.x;
2019 value[1] = _field[index].val.y;
2120 value[2] = _field[index].val.z;
2221 return 1;
23− }
24− else {
22+ } else {
2523 return 0;
2624 }
2725 }
@@ -30,8 +28,7 @@ Field::Field(float worldSize, float coupling) { · 2 unmodified lines
3028 _worldSize = worldSize;
3129 _coupling = coupling;
3230 //float fx, fy, fz;
33− for (int i = 0; i < FIELD_ELEMENTS; i++)
34− {
31+ for (int i = 0; i < FIELD_ELEMENTS; i++) {
3532 const float FIELD_INITIAL_MAG = 0.0f;
3633 _field[i].val = randVector() * FIELD_INITIAL_MAG * _worldSize;
3734 _field[i].center.x = ((float)(i % 10) + 0.5f);
@@ -44,11 +41,10 @@ Field::Field(float worldSize, float coupling) { · 6 unmodified lines
4441
4542 void Field::add(float* add, float *pos) {
4643 int index = (int)(pos[0] / _worldSize * 10.0) +
47− (int)(pos[1] / _worldSize * 10.0) * 10 +
48− (int)(pos[2] / _worldSize * 10.0) * 100;
44+ (int)(pos[1] / _worldSize * 10.0) * 10 +
45+ (int)(pos[2] / _worldSize * 10.0) * 100;
4946
50− if ((index >= 0) && (index < FIELD_ELEMENTS))
51− {
47+ if ((index >= 0) && (index < FIELD_ELEMENTS)) {
5248 _field[index].val.x += add[0];
5349 _field[index].val.y += add[1];
5450 _field[index].val.z += add[2];
@@ -58,8 +54,8 @@ void Field::add(float* add, float *pos) { · 3 unmodified lines
5854 void Field::interact(float deltaTime, const glm::vec3& pos, glm::vec3& vel) {
5955
6056 int index = (int)(pos.x / _worldSize * 10.0) +
61− (int)(pos.y / _worldSize*10.0) * 10 +
62− (int)(pos.z / _worldSize*10.0) * 100;
57+ (int)(pos.y / _worldSize*10.0) * 10 +
58+ (int)(pos.z / _worldSize*10.0) * 100;
6359 if ((index >= 0) && (index < FIELD_ELEMENTS)) {
6460 vel += _field[index].val * deltaTime; // Particle influenced by field
6561 _field[index].val += vel * deltaTime * _coupling; // Field influenced by particle
@@ -69,8 +65,7 @@ void Field::interact(float deltaTime, const glm::vec3& pos, glm::vec3& vel) { · 3 unmodified lines
6965 void Field::simulate(float deltaTime) {
7066 glm::vec3 neighbors, add, diff;
7167
72− for (int i = 0; i < FIELD_ELEMENTS; i++)
73− {
68+ for (int i = 0; i < FIELD_ELEMENTS; i++) {
7469 const float CONSTANT_DAMPING = 0.5f;
7570 _field[i].val *= (1.f - CONSTANT_DAMPING * deltaTime);
7671 }
@@ -82,8 +77,7 @@ void Field::render() { · 5 unmodified lines
8277
8378 glDisable(GL_LIGHTING);
8479 glBegin(GL_LINES);
85− for (i = 0; i < FIELD_ELEMENTS; i++)
86− {
80+ for (i = 0; i < FIELD_ELEMENTS; i++) {
8781 glColor3f(0, 1, 0);
8882 glVertex3fv(&_field[i].center.x);
8983 glVertex3f(_field[i].center.x + _field[i].val.x * scale_view,
@@ -96,8 +90,7 @@ void Field::render() { · 6 unmodified lines
9690 glPointSize(4.0);
9791 glEnable(GL_POINT_SMOOTH);
9892 glBegin(GL_POINTS);
99− for (i = 0; i < FIELD_ELEMENTS; i++)
100− {
93+ for (i = 0; i < FIELD_ELEMENTS; i++) {
10194 glVertex3fv(&_field[i].center.x);
10295 }
10396 glEnd();