Changeset c1ec4f6 in opengl-game
- Timestamp:
- Jun 11, 2021, 2:35:32 PM (3 years ago)
- 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)
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
sdl-game.cpp
rb7fc3c2 rc1ec4f6 123 123 SceneObject<ModelVertex, SSBO_ModelObject>* texturedSquare = nullptr; 124 124 125 // TODO: Ideally, avoid having to make the squares as modified upon creation126 127 125 texturedSquare = &addObject(modelObjects, modelPipeline, 128 126 addObjectIndex<ModelVertex>(modelObjects.size(), … … 143 141 texturedSquare->model_base = 144 142 translate(mat4(1.0f), vec3(0.0f, 0.0f, -2.0f)); 145 texturedSquare->modified = true;146 143 147 144 texturedSquare = &addObject(modelObjects, modelPipeline, … … 162 159 texturedSquare->model_base = 163 160 translate(mat4(1.0f), vec3(0.0f, 0.0f, -1.5f)); 164 texturedSquare->modified = true;165 161 166 162 modelPipeline.createDescriptorSetLayout(); … … 385 381 texturedSquare.model_base = 386 382 translate(mat4(1.0f), vec3(0.0f, 0.0f, zOffset)); 387 texturedSquare.modified = true;388 383 // START UNREVIEWED SECTION 389 384 // END UNREVIEWED SECTION … … 467 462 translate(mat4(1.0f), vec3(0.0f, -2.0f, -0.0f)) * 468 463 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); 479 469 } 480 470 -
sdl-game.hpp
rb7fc3c2 rc1ec4f6 102 102 mat4 model_transform; 103 103 104 bool modified;105 106 104 // TODO: Figure out if I should make child classes that have these fields instead of putting them in the 107 105 // parent class … … 117 115 // Could probably use the same approach to make indices optional 118 116 // Figure out if there are sufficient use cases to make either of these optional or is it fine to make 119 // them ma mdatory117 // them mandatory 120 118 121 119 … … 366 364 } 367 365 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) }); 369 367 objectBuffer.add(ssbo); 370 368 -
vulkan-game.cpp
rb7fc3c2 rc1ec4f6 151 151 SceneObject<ModelVertex, SSBO_ModelObject>* texturedSquare = nullptr; 152 152 153 // TODO: Ideally, avoid having to make the squares as modified upon creation154 155 153 texturedSquare = &addObject(modelObjects, modelPipeline, 156 154 addObjectIndex<ModelVertex>(modelObjects.size(), … … 171 169 texturedSquare->model_base = 172 170 translate(mat4(1.0f), vec3(0.0f, 0.0f, -2.0f)); 173 texturedSquare->modified = true;174 171 175 172 texturedSquare = &addObject(modelObjects, modelPipeline, … … 191 188 texturedSquare->model_base = 192 189 translate(mat4(1.0f), vec3(0.0f, 0.0f, -1.5f)); 193 texturedSquare->modified = true;194 190 195 191 modelPipeline.createDescriptorSetLayout(); … … 453 449 translate(mat4(1.0f), vec3(0.0f, -1.2f, 1.65f)) * 454 450 scale(mat4(1.0f), vec3(0.1f, 0.1f, 0.1f)); 455 ship.modified = true;456 451 457 452 shipPipeline.createDescriptorSetLayout(); … … 791 786 texturedSquare.model_base = 792 787 translate(mat4(1.0f), vec3(0.0f, 0.0f, zOffset)); 793 texturedSquare.modified = true;794 788 // START UNREVIEWED SECTION 795 789 } else if (e.key.keycode == SDL_SCANCODE_Z && leftLaserIdx == -1) { … … 824 818 if (e.key.keycode == SDL_SCANCODE_Z && leftLaserIdx != -1) { 825 819 laserObjects[leftLaserIdx].ssbo.deleted = true; 826 laserObjects[leftLaserIdx].modified = true;827 820 leftLaserIdx = -1; 828 821 … … 833 826 } else if (e.key.keycode == SDL_SCANCODE_X && rightLaserIdx != -1) { 834 827 laserObjects[rightLaserIdx].ssbo.deleted = true; 835 laserObjects[rightLaserIdx].modified = true;836 828 rightLaserIdx = -1; 837 829 … … 872 864 ship.model_transform = translate(mat4(1.0f), vec3(distance, 0.0f, 0.0f)) 873 865 * shipObjects[0].model_transform; 874 ship.modified = true;875 866 876 867 if (leftLaserIdx != -1) { … … 885 876 ship.model_transform = translate(mat4(1.0f), vec3(distance, 0.0f, 0.0f)) 886 877 * shipObjects[0].model_transform; 887 ship.modified = true;888 878 889 879 if (leftLaserIdx != -1) { … … 1026 1016 rotate(mat4(1.0f), radians(60.0f), vec3(1.0f, 1.0f, -1.0f)) * 1027 1017 scale(mat4(1.0f), vec3(0.1f, 0.1f, 0.1f)); 1028 asteroid.modified = true;1029 1018 } 1030 1019 … … 1051 1040 translate(mat4(1.0f), vec3(0.0f, -2.0f, -0.0f)) * 1052 1041 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); 1063 1047 } 1064 1048 … … 1077 1061 SSBO_ModelObject& objData = obj.ssbo; 1078 1062 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); 1087 1067 } 1088 1068 … … 1123 1103 } 1124 1104 1125 obj.modified = true;1126 }1127 1128 if (obj.modified) {1129 1105 objData.model = obj.model_transform * obj.model_base; 1130 1106 obj.center = vec3(objData.model * vec4(0.0f, 0.0f, 0.0f, 1.0f)); 1131 1132 obj.modified = false;1133 1107 1134 1108 updateBufferSet(storageBuffers_asteroidPipeline, i, objData); … … 1156 1130 SSBO_Laser& objData = obj.ssbo; 1157 1131 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); 1166 1136 } 1167 1137 … … 1182 1152 if (curTime > (objData.explosionStartTime + objData.explosionDuration)) { 1183 1153 objData.deleted = true; 1184 obj.modified = true;1185 1154 } 1186 1155 } 1187 1156 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); 1196 1161 } 1197 1162 … … 2083 2048 rotate(mat4(1.0f), yAxisRotation, vec3(0.0f, 1.0f, 0.0f)) * 2084 2049 rotate(mat4(1.0f), xAxisRotation, vec3(1.0f, 0.0f, 0.0f)); 2085 2086 laser.modified = true;2087 2050 } 2088 2051 … … 2115 2078 laser.model_base = rotate(mat4(1.0f), zAxisRotation, vec3(0.0f, 0.0f, 1.0f)); 2116 2079 laser.model_transform = translate(mat4(1.0f), translation) * laser.model_transform; 2117 2118 laser.modified = true;2119 2080 } 2120 2081 … … 2270 2231 explosion.model_base = model_mat; 2271 2232 explosion.model_transform = mat4(1.0f); 2272 2273 explosion.modified = true;2274 2233 } 2275 2234 -
vulkan-game.hpp
rb7fc3c2 rc1ec4f6 118 118 mat4 model_transform; 119 119 120 bool modified;121 122 120 // TODO: Figure out if I should make child classes that have these fields instead of putting them in the 123 121 // parent class … … 133 131 // Could probably use the same approach to make indices optional 134 132 // Figure out if there are sufficient use cases to make either of these optional or is it fine to make 135 // them ma mdatory133 // them mandatory 136 134 137 135 … … 189 187 190 188 *reinterpret_cast<float*>(effectedFieldPtr) = startValue + (curTime - startTime) * changePerSecond; 191 192 objects[objectIndex].modified = true;193 189 } 194 190 }; … … 521 517 } 522 518 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) }); 524 520 objectBuffer.add(ssbo); 525 521
Note:
See TracChangeset
for help on using the changeset viewer.