Changeset c1ec4f6 in opengl-game


Ignore:
Timestamp:
Jun 11, 2021, 2:35:32 PM (3 years ago)
Author:
Dmitry Portnoy <dportnoy@…>
Branches:
feature/imgui-sdl
Children:
6486ba8
Parents:
b7fc3c2
git-author:
Dmitry Portnoy <dportnoy@…> (06/10/21 21:37:02)
git-committer:
Dmitry Portnoy <dportnoy@…> (06/11/21 14:35:32)
Message:

Remove the modified field from the SceneObject object

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • sdl-game.cpp

    rb7fc3c2 rc1ec4f6  
    123123   SceneObject<ModelVertex, SSBO_ModelObject>* texturedSquare = nullptr;
    124124
    125    // TODO: Ideally, avoid having to make the squares as modified upon creation
    126 
    127125   texturedSquare = &addObject(modelObjects, modelPipeline,
    128126      addObjectIndex<ModelVertex>(modelObjects.size(),
     
    143141   texturedSquare->model_base =
    144142      translate(mat4(1.0f), vec3(0.0f, 0.0f, -2.0f));
    145    texturedSquare->modified = true;
    146143
    147144   texturedSquare = &addObject(modelObjects, modelPipeline,
     
    162159   texturedSquare->model_base =
    163160      translate(mat4(1.0f), vec3(0.0f, 0.0f, -1.5f));
    164    texturedSquare->modified = true;
    165161
    166162   modelPipeline.createDescriptorSetLayout();
     
    385381                  texturedSquare.model_base =
    386382                     translate(mat4(1.0f), vec3(0.0f, 0.0f, zOffset));
    387                   texturedSquare.modified = true;
    388383               // START UNREVIEWED SECTION
    389384               // END UNREVIEWED SECTION
     
    467462         translate(mat4(1.0f), vec3(0.0f, -2.0f, -0.0f)) *
    468463         rotate(mat4(1.0f), curTime * radians(90.0f), vec3(0.0f, 0.0f, 1.0f));
    469       obj.modified = true;
    470 
    471       if (obj.modified) {
    472          objData.model = obj.model_transform * obj.model_base;
    473          obj.center = vec3(objData.model * vec4(0.0f, 0.0f, 0.0f, 1.0f));
    474 
    475          obj.modified = false;
    476 
    477          updateBufferSet(storageBuffers_modelPipeline, i, objData);
    478       }
     464
     465      objData.model = obj.model_transform * obj.model_base;
     466      obj.center = vec3(objData.model * vec4(0.0f, 0.0f, 0.0f, 1.0f));
     467
     468      updateBufferSet(storageBuffers_modelPipeline, i, objData);
    479469   }
    480470
  • sdl-game.hpp

    rb7fc3c2 rc1ec4f6  
    102102   mat4 model_transform;
    103103
    104    bool modified;
    105 
    106104   // TODO: Figure out if I should make child classes that have these fields instead of putting them in the
    107105   // parent class
     
    117115// Could probably use the same approach to make indices optional
    118116// Figure out if there are sufficient use cases to make either of these optional or is it fine to make
    119 // them mamdatory
     117// them mandatory
    120118
    121119
     
    366364   }
    367365
    368    objects.push_back({ vertices, indices, ssbo, mat4(1.0f), mat4(1.0f), false });
     366   objects.push_back({ vertices, indices, ssbo, mat4(1.0f), mat4(1.0f) });
    369367   objectBuffer.add(ssbo);
    370368
  • vulkan-game.cpp

    rb7fc3c2 rc1ec4f6  
    151151   SceneObject<ModelVertex, SSBO_ModelObject>* texturedSquare = nullptr;
    152152
    153    // TODO: Ideally, avoid having to make the squares as modified upon creation
    154 
    155153   texturedSquare = &addObject(modelObjects, modelPipeline,
    156154      addObjectIndex<ModelVertex>(modelObjects.size(),
     
    171169   texturedSquare->model_base =
    172170      translate(mat4(1.0f), vec3(0.0f, 0.0f, -2.0f));
    173    texturedSquare->modified = true;
    174171
    175172   texturedSquare = &addObject(modelObjects, modelPipeline,
     
    191188   texturedSquare->model_base =
    192189      translate(mat4(1.0f), vec3(0.0f, 0.0f, -1.5f));
    193    texturedSquare->modified = true;
    194190
    195191   modelPipeline.createDescriptorSetLayout();
     
    453449      translate(mat4(1.0f), vec3(0.0f, -1.2f, 1.65f)) *
    454450      scale(mat4(1.0f), vec3(0.1f, 0.1f, 0.1f));
    455    ship.modified = true;
    456451
    457452   shipPipeline.createDescriptorSetLayout();
     
    791786                  texturedSquare.model_base =
    792787                     translate(mat4(1.0f), vec3(0.0f, 0.0f, zOffset));
    793                   texturedSquare.modified = true;
    794788               // START UNREVIEWED SECTION
    795789               } else if (e.key.keycode == SDL_SCANCODE_Z && leftLaserIdx == -1) {
     
    824818               if (e.key.keycode == SDL_SCANCODE_Z && leftLaserIdx != -1) {
    825819                  laserObjects[leftLaserIdx].ssbo.deleted = true;
    826                   laserObjects[leftLaserIdx].modified = true;
    827820                  leftLaserIdx = -1;
    828821
     
    833826               } else if (e.key.keycode == SDL_SCANCODE_X && rightLaserIdx != -1) {
    834827                  laserObjects[rightLaserIdx].ssbo.deleted = true;
    835                   laserObjects[rightLaserIdx].modified = true;
    836828                  rightLaserIdx = -1;
    837829
     
    872864         ship.model_transform = translate(mat4(1.0f), vec3(distance, 0.0f, 0.0f))
    873865            * shipObjects[0].model_transform;
    874          ship.modified = true;
    875866
    876867         if (leftLaserIdx != -1) {
     
    885876         ship.model_transform = translate(mat4(1.0f), vec3(distance, 0.0f, 0.0f))
    886877            * shipObjects[0].model_transform;
    887          ship.modified = true;
    888878
    889879         if (leftLaserIdx != -1) {
     
    10261016         rotate(mat4(1.0f), radians(60.0f), vec3(1.0f, 1.0f, -1.0f)) *
    10271017         scale(mat4(1.0f), vec3(0.1f, 0.1f, 0.1f));
    1028       asteroid.modified = true;
    10291018   }
    10301019
     
    10511040         translate(mat4(1.0f), vec3(0.0f, -2.0f, -0.0f)) *
    10521041         rotate(mat4(1.0f), curTime * radians(90.0f), vec3(0.0f, 0.0f, 1.0f));
    1053       obj.modified = true;
    1054 
    1055       if (obj.modified) {
    1056          objData.model = obj.model_transform * obj.model_base;
    1057          obj.center = vec3(objData.model * vec4(0.0f, 0.0f, 0.0f, 1.0f));
    1058 
    1059          obj.modified = false;
    1060 
    1061          updateBufferSet(storageBuffers_modelPipeline, i, objData);
    1062       }
     1042
     1043      objData.model = obj.model_transform * obj.model_base;
     1044      obj.center = vec3(objData.model * vec4(0.0f, 0.0f, 0.0f, 1.0f));
     1045
     1046      updateBufferSet(storageBuffers_modelPipeline, i, objData);
    10631047   }
    10641048
     
    10771061      SSBO_ModelObject& objData = obj.ssbo;
    10781062
    1079       if (obj.modified) {
    1080          objData.model = obj.model_transform * obj.model_base;
    1081          obj.center = vec3(objData.model * vec4(0.0f, 0.0f, 0.0f, 1.0f));
    1082 
    1083          obj.modified = false;
    1084 
    1085          updateBufferSet(storageBuffers_shipPipeline, i, objData);
    1086       }
     1063      objData.model = obj.model_transform * obj.model_base;
     1064      obj.center = vec3(objData.model * vec4(0.0f, 0.0f, 0.0f, 1.0f));
     1065
     1066      updateBufferSet(storageBuffers_shipPipeline, i, objData);
    10871067   }
    10881068
     
    11231103         }
    11241104
    1125          obj.modified = true;
    1126       }
    1127 
    1128       if (obj.modified) {
    11291105         objData.model = obj.model_transform * obj.model_base;
    11301106         obj.center = vec3(objData.model * vec4(0.0f, 0.0f, 0.0f, 1.0f));
    1131 
    1132          obj.modified = false;
    11331107
    11341108         updateBufferSet(storageBuffers_asteroidPipeline, i, objData);
     
    11561130      SSBO_Laser& objData = obj.ssbo;
    11571131
    1158       if (obj.modified) {
    1159          objData.model = obj.model_transform * obj.model_base;
    1160          obj.center = vec3(objData.model * vec4(0.0f, 0.0f, 0.0f, 1.0f));
    1161 
    1162          obj.modified = false;
    1163 
    1164          updateBufferSet(storageBuffers_laserPipeline, i, objData);
    1165       }
     1132      objData.model = obj.model_transform * obj.model_base;
     1133      obj.center = vec3(objData.model * vec4(0.0f, 0.0f, 0.0f, 1.0f));
     1134
     1135      updateBufferSet(storageBuffers_laserPipeline, i, objData);
    11661136   }
    11671137
     
    11821152         if (curTime > (objData.explosionStartTime + objData.explosionDuration)) {
    11831153            objData.deleted = true;
    1184             obj.modified = true;
    11851154         }
    11861155      }
    11871156
    1188       if (obj.modified) {
    1189          objData.model = obj.model_transform * obj.model_base;
    1190          obj.center = vec3(objData.model * vec4(0.0f, 0.0f, 0.0f, 1.0f));
    1191 
    1192          obj.modified = false;
    1193 
    1194          updateBufferSet(storageBuffers_explosionPipeline, i, objData);
    1195       }
     1157      objData.model = obj.model_transform * obj.model_base;
     1158      obj.center = vec3(objData.model * vec4(0.0f, 0.0f, 0.0f, 1.0f));
     1159
     1160      updateBufferSet(storageBuffers_explosionPipeline, i, objData);
    11961161   }
    11971162
     
    20832048      rotate(mat4(1.0f), yAxisRotation, vec3(0.0f, 1.0f, 0.0f)) *
    20842049      rotate(mat4(1.0f), xAxisRotation, vec3(1.0f, 0.0f, 0.0f));
    2085 
    2086    laser.modified = true;
    20872050}
    20882051
     
    21152078   laser.model_base = rotate(mat4(1.0f), zAxisRotation, vec3(0.0f, 0.0f, 1.0f));
    21162079   laser.model_transform = translate(mat4(1.0f), translation) * laser.model_transform;
    2117 
    2118    laser.modified = true;
    21192080}
    21202081
     
    22702231   explosion.model_base = model_mat;
    22712232   explosion.model_transform = mat4(1.0f);
    2272 
    2273    explosion.modified = true;
    22742233}
    22752234
  • vulkan-game.hpp

    rb7fc3c2 rc1ec4f6  
    118118   mat4 model_transform;
    119119
    120    bool modified;
    121 
    122120   // TODO: Figure out if I should make child classes that have these fields instead of putting them in the
    123121   // parent class
     
    133131// Could probably use the same approach to make indices optional
    134132// Figure out if there are sufficient use cases to make either of these optional or is it fine to make
    135 // them mamdatory
     133// them mandatory
    136134
    137135
     
    189187
    190188      *reinterpret_cast<float*>(effectedFieldPtr) = startValue + (curTime - startTime) * changePerSecond;
    191 
    192       objects[objectIndex].modified = true;
    193189   }
    194190};
     
    521517   }
    522518
    523    objects.push_back({ vertices, indices, ssbo, mat4(1.0f), mat4(1.0f), false });
     519   objects.push_back({ vertices, indices, ssbo, mat4(1.0f), mat4(1.0f) });
    524520   objectBuffer.add(ssbo);
    525521
Note: See TracChangeset for help on using the changeset viewer.