Changeset b7fc3c2 in opengl-game
- Timestamp:
- Jun 10, 2021, 2:58:54 PM (3 years ago)
- Branches:
- feature/imgui-sdl
- Children:
- c1ec4f6
- Parents:
- bb76950
- git-author:
- Dmitry Portnoy <dportnoy@…> (06/10/21 14:53:52)
- git-committer:
- Dmitry Portnoy <dportnoy@…> (06/10/21 14:58:54)
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
sdl-game.cpp
rbb76950 rb7fc3c2 92 92 vkGetPhysicalDeviceProperties(physicalDevice, &deviceProperties); 93 93 94 objects_modelPipeline = VulkanBuffer<SSBO_ModelObject>(10, deviceProperties.limits.minUniformBufferOffsetAlignment); 94 objects_modelPipeline = VulkanBuffer<SSBO_ModelObject>(10, deviceProperties.limits.maxStorageBufferRange, 95 deviceProperties.limits.minStorageBufferOffsetAlignment); 95 96 96 97 initImGuiOverlay(); … … 448 449 449 450 void VulkanGame::updateScene() { 450 // Rotate the textured squares 451 for (SceneObject<ModelVertex, SSBO_ModelObject>& model : this->modelObjects) { 452 model.model_transform = 451 // TODO: Probably move the resizing to the VulkanBuffer class 452 if (objects_modelPipeline.resized) { 453 resizeBufferSet(storageBuffers_modelPipeline, objects_modelPipeline.memorySize(), resourceCommandPool, 454 graphicsQueue, true); 455 456 objects_modelPipeline.resize(); 457 458 modelPipeline.updateDescriptorInfo(1, &storageBuffers_modelPipeline.infoSet, swapChainImages.size()); 459 } 460 461 for (size_t i = 0; i < modelObjects.size(); i++) { 462 SceneObject<ModelVertex, SSBO_ModelObject>& obj = modelObjects[i]; 463 SSBO_ModelObject& objData = obj.ssbo; 464 465 // Rotate the textured squares 466 obj.model_transform = 453 467 translate(mat4(1.0f), vec3(0.0f, -2.0f, -0.0f)) * 454 468 rotate(mat4(1.0f), curTime * radians(90.0f), vec3(0.0f, 0.0f, 1.0f)); 455 model.modified = true; 456 } 457 458 // TODO: Probably move the resizing to the VulkanBuffer class 459 if (objects_modelPipeline.resized) { 460 // TODO: Also resize the dynamic ubo 461 resizeBufferSet(storageBuffers_modelPipeline, objects_modelPipeline.capacity * sizeof(SSBO_ModelObject), 462 resourceCommandPool, graphicsQueue, true); 463 464 objects_modelPipeline.resize(); 465 466 modelPipeline.updateDescriptorInfo(1, &storageBuffers_modelPipeline.infoSet, swapChainImages.size()); 467 } 468 469 for (size_t i = 0; i < modelObjects.size(); i++) { 470 if (modelObjects[i].modified) { 471 updateObject(modelObjects[i]); 472 updateBufferSet(storageBuffers_modelPipeline, i, modelObjects[i].ssbo); 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); 473 478 } 474 479 } -
sdl-game.hpp
rbb76950 rb7fc3c2 323 323 void centerObject(SceneObject<VertexType, SSBOType>& object); 324 324 325 template<class VertexType, class SSBOType>326 void updateObject(SceneObject<VertexType, SSBOType>& obj);327 328 325 void renderFrame(ImDrawData* draw_data); 329 326 void presentFrame(); … … 353 350 } 354 351 355 // TODO: Right now, it's basically necessary to pass the identity matrix in for ssbo.model 356 // and to change the model matrix later by setting model_transform and then calling updateObject()352 // TODO: Right now, it's basically necessary to pass the identity matrix in for ssbo.model and to change 353 // the model matrix later by setting model_transform and then calculating the new ssbo.model. 357 354 // Figure out a better way to allow the model matrix to be set during object creation 358 355 template<class VertexType, class SSBOType> … … 362 359 VulkanBuffer<SSBOType>& objectBuffer, SSBOType ssbo) { 363 360 // TODO: Use the model field of ssbo to set the object's model_base 364 // currently, the passed in model is useless since it gets overridden in updateObject() anyway361 // currently, the passed-in model is useless since it gets overridden when ssbo.model is recalculated 365 362 size_t numVertices = pipeline.getNumVertices(); 366 363 … … 464 461 } 465 462 466 // TODO: Just pass in the single object instead of a list of all of them467 template<class VertexType, class SSBOType>468 void VulkanGame::updateObject(SceneObject<VertexType, SSBOType>& obj) {469 obj.ssbo.model = obj.model_transform * obj.model_base;470 obj.center = vec3(obj.ssbo.model * vec4(0.0f, 0.0f, 0.0f, 1.0f));471 472 obj.modified = false;473 }474 475 463 #endif // _SDL_GAME_H -
vulkan-buffer.hpp
rbb76950 rb7fc3c2 21 21 22 22 VulkanBuffer(); 23 VulkanBuffer(size_t capacity, size_t minOffsetAlignment);23 VulkanBuffer(size_t capacity, size_t range, size_t minOffsetAlignment); 24 24 25 25 VulkanBuffer(const VulkanBuffer<T>&) = delete; … … 35 35 void add(T obj); 36 36 37 // TODO: Add a resize function37 size_t memorySize(); 38 38 39 39 private: 40 40 41 41 size_t alignment; 42 size_t range; 42 43 size_t numObjects; 43 44 … … 48 49 // Maybe rename it to mappedData or something to make that clearer 49 50 void* rawData; 51 52 size_t memRequirement(size_t capacity); 50 53 }; 51 54 … … 66 69 VulkanBuffer<T>::VulkanBuffer() 67 70 : alignment(0) 71 , range(0) 68 72 , capacity(0) 69 73 , numObjects(0) … … 75 79 76 80 template<class T> 77 VulkanBuffer<T>::VulkanBuffer(size_t capacity, size_t minOffsetAlignment) 78 : alignment(sizeof(T)) 81 VulkanBuffer<T>::VulkanBuffer(size_t capacity, size_t range, size_t minOffsetAlignment) 82 : alignment(range) 83 , range(range / sizeof(T)) 79 84 , capacity(capacity) 80 85 , numObjects(0) … … 87 92 } 88 93 89 srcData = (T*)malloc( capacity * alignment);94 srcData = (T*)malloc(memRequirement(capacity)); 90 95 } 91 96 … … 110 115 111 116 alignment = other.alignment; 117 range = other.range; 112 118 113 119 if (srcData != nullptr) { … … 119 125 other.capacity = 0; 120 126 other.numObjects = 0; 121 // TODO: Maybe set rnage to 0 as well127 other.range = 0; 122 128 123 129 other.srcData = nullptr; … … 144 150 } 145 151 152 template<class T> 153 size_t VulkanBuffer<T>::memorySize() { 154 return memRequirement(capacity); 155 } 156 157 template<class T> 158 size_t VulkanBuffer<T>::memRequirement(size_t capacity) { 159 return (capacity / range) * alignment + (capacity % range) * sizeof(T); 160 } 161 146 162 #endif // _VULKAN_BUFFER_H -
vulkan-game.cpp
rbb76950 rb7fc3c2 110 110 vkGetPhysicalDeviceProperties(physicalDevice, &deviceProperties); 111 111 112 objects_modelPipeline = VulkanBuffer<SSBO_ModelObject>(10, deviceProperties.limits.minUniformBufferOffsetAlignment); 113 objects_shipPipeline = VulkanBuffer<SSBO_ModelObject>(10, deviceProperties.limits.minUniformBufferOffsetAlignment); 114 objects_asteroidPipeline = VulkanBuffer<SSBO_Asteroid>(10, deviceProperties.limits.minUniformBufferOffsetAlignment); 115 objects_laserPipeline = VulkanBuffer<SSBO_Laser>(2, deviceProperties.limits.minUniformBufferOffsetAlignment); 116 objects_explosionPipeline = VulkanBuffer<SSBO_Explosion>(2, deviceProperties.limits.minUniformBufferOffsetAlignment); 112 objects_modelPipeline = VulkanBuffer<SSBO_ModelObject>(10, deviceProperties.limits.maxStorageBufferRange, 113 deviceProperties.limits.minStorageBufferOffsetAlignment); 114 objects_shipPipeline = VulkanBuffer<SSBO_ModelObject>(10, deviceProperties.limits.maxStorageBufferRange, 115 deviceProperties.limits.minStorageBufferOffsetAlignment); 116 objects_asteroidPipeline = VulkanBuffer<SSBO_Asteroid>(10, deviceProperties.limits.maxStorageBufferRange, 117 deviceProperties.limits.minStorageBufferOffsetAlignment); 118 objects_laserPipeline = VulkanBuffer<SSBO_Laser>(2, deviceProperties.limits.maxStorageBufferRange, 119 deviceProperties.limits.minStorageBufferOffsetAlignment); 120 objects_explosionPipeline = VulkanBuffer<SSBO_Explosion>(2, deviceProperties.limits.maxStorageBufferRange, 121 deviceProperties.limits.minStorageBufferOffsetAlignment); 117 122 118 123 initImGuiOverlay(); … … 941 946 // where it will run just once per frame 942 947 void VulkanGame::updateScene() { 943 // Rotate the textured squares944 for (SceneObject<ModelVertex, SSBO_ModelObject>& model : this->modelObjects) {945 model.model_transform =946 translate(mat4(1.0f), vec3(0.0f, -2.0f, -0.0f)) *947 rotate(mat4(1.0f), curTime * radians(90.0f), vec3(0.0f, 0.0f, 1.0f));948 model.modified = true;949 }950 951 if (leftLaserIdx != -1) {952 updateLaserTarget(leftLaserIdx);953 }954 if (rightLaserIdx != -1) {955 updateLaserTarget(rightLaserIdx);956 }957 958 for (vector<BaseEffectOverTime*>::iterator it = effects.begin(); it != effects.end(); ) {959 if ((*it)->deleted) {960 delete *it;961 it = effects.erase(it);962 } else {963 BaseEffectOverTime* eot = *it;964 965 eot->applyEffect(curTime);966 967 it++;968 }969 }970 971 for (SceneObject<ModelVertex, SSBO_Asteroid>& asteroid : this->asteroidObjects) {972 if (!asteroid.ssbo.deleted) {973 vec3 objCenter = vec3(viewMat * vec4(asteroid.center, 1.0f));974 975 if (asteroid.ssbo.hp <= 0.0f) {976 asteroid.ssbo.deleted = true;977 978 // TODO: Optimize this so I don't recalculate the camera rotation every time979 // TODO: Also, avoid re-declaring cam_pitch980 float cam_pitch = -50.0f;981 mat4 pitch_mat = rotate(mat4(1.0f), radians(cam_pitch), vec3(1.0f, 0.0f, 0.0f));982 mat4 model_mat = translate(mat4(1.0f), asteroid.center) * pitch_mat;983 984 addExplosion(model_mat, 0.5f, curTime);985 986 this->score++;987 } else if ((objCenter.z - asteroid.radius) > -NEAR_CLIP) {988 asteroid.ssbo.deleted = true;989 } else {990 asteroid.model_transform =991 translate(mat4(1.0f), vec3(0.0f, 0.0f, this->asteroidSpeed * this->elapsedTime)) *992 asteroid.model_transform;993 }994 995 asteroid.modified = true;996 }997 }998 999 948 if (curTime - this->lastSpawn_asteroid > this->spawnRate_asteroid) { 1000 949 this->lastSpawn_asteroid = curTime; … … 1080 1029 } 1081 1030 1082 for (SceneObject<ExplosionVertex, SSBO_Explosion>& explosion : this->explosionObjects) { 1083 if (!explosion.ssbo.deleted) { 1084 if (curTime > (explosion.ssbo.explosionStartTime + explosion.ssbo.explosionDuration)) { 1085 explosion.ssbo.deleted = true; 1086 explosion.modified = true; 1031 // TODO: Probably move the resizing to the VulkanBuffer class 1032 1033 // TODO: Replace updateBufferSet to one call to copyDataToMemory, using VulkanBuffer to provide the data source 1034 // TODO: Figure out a way to make updateDescriptorInfo easier to use, maybe store the binding index in the buffer set 1035 1036 if (objects_modelPipeline.resized) { 1037 resizeBufferSet(storageBuffers_modelPipeline, objects_modelPipeline.memorySize(), resourceCommandPool, 1038 graphicsQueue, true); 1039 1040 objects_modelPipeline.resize(); 1041 1042 modelPipeline.updateDescriptorInfo(1, &storageBuffers_modelPipeline.infoSet, swapChainImages.size()); 1043 } 1044 1045 for (size_t i = 0; i < modelObjects.size(); i++) { 1046 SceneObject<ModelVertex, SSBO_ModelObject>& obj = modelObjects[i]; 1047 SSBO_ModelObject& objData = obj.ssbo; 1048 1049 // Rotate the textured squares 1050 obj.model_transform = 1051 translate(mat4(1.0f), vec3(0.0f, -2.0f, -0.0f)) * 1052 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 } 1063 } 1064 1065 if (objects_shipPipeline.resized) { 1066 resizeBufferSet(storageBuffers_shipPipeline, objects_shipPipeline.memorySize(), resourceCommandPool, 1067 graphicsQueue, true); 1068 1069 objects_shipPipeline.resize(); 1070 1071 shipPipeline.updateDescriptorInfo(1, &storageBuffers_shipPipeline.infoSet, swapChainImages.size()); 1072 } 1073 1074 // TODO: Move ship position updates from the ui event handling code into this function 1075 for (size_t i = 0; i < shipObjects.size(); i++) { 1076 SceneObject<ModelVertex, SSBO_ModelObject>& obj = shipObjects[i]; 1077 SSBO_ModelObject& objData = obj.ssbo; 1078 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 } 1087 } 1088 1089 if (objects_asteroidPipeline.resized) { 1090 resizeBufferSet(storageBuffers_asteroidPipeline, objects_asteroidPipeline.memorySize(), resourceCommandPool, 1091 graphicsQueue, true); 1092 1093 objects_asteroidPipeline.resize(); 1094 1095 asteroidPipeline.updateDescriptorInfo(1, &storageBuffers_asteroidPipeline.infoSet, swapChainImages.size()); 1096 } 1097 1098 for (size_t i = 0; i < asteroidObjects.size(); i++) { 1099 SceneObject<ModelVertex, SSBO_Asteroid>& obj = asteroidObjects[i]; 1100 SSBO_Asteroid& objData = obj.ssbo; 1101 1102 if (!objData.deleted) { 1103 vec3 objCenter = vec3(viewMat * vec4(obj.center, 1.0f)); 1104 1105 if (objData.hp <= 0.0f) { 1106 objData.deleted = true; 1107 1108 // TODO: Optimize this so I don't recalculate the camera rotation every time 1109 // TODO: Also, avoid re-declaring cam_pitch 1110 float cam_pitch = -50.0f; 1111 mat4 pitch_mat = rotate(mat4(1.0f), radians(cam_pitch), vec3(1.0f, 0.0f, 0.0f)); 1112 mat4 model_mat = translate(mat4(1.0f), obj.center) * pitch_mat; 1113 1114 addExplosion(model_mat, 0.5f, curTime); 1115 1116 this->score++; 1117 } else if ((objCenter.z - obj.radius) > -NEAR_CLIP) { 1118 objData.deleted = true; 1119 } else { 1120 obj.model_transform = 1121 translate(mat4(1.0f), vec3(0.0f, 0.0f, this->asteroidSpeed * this->elapsedTime)) * 1122 obj.model_transform; 1123 } 1124 1125 obj.modified = true; 1126 } 1127 1128 if (obj.modified) { 1129 objData.model = obj.model_transform * obj.model_base; 1130 obj.center = vec3(objData.model * vec4(0.0f, 0.0f, 0.0f, 1.0f)); 1131 1132 obj.modified = false; 1133 1134 updateBufferSet(storageBuffers_asteroidPipeline, i, objData); 1135 } 1136 } 1137 1138 if (objects_laserPipeline.resized) { 1139 resizeBufferSet(storageBuffers_laserPipeline, objects_laserPipeline.memorySize(), resourceCommandPool, 1140 graphicsQueue, true); 1141 1142 objects_laserPipeline.resize(); 1143 1144 laserPipeline.updateDescriptorInfo(1, &storageBuffers_laserPipeline.infoSet, swapChainImages.size()); 1145 } 1146 1147 if (leftLaserIdx != -1) { 1148 updateLaserTarget(leftLaserIdx); 1149 } 1150 if (rightLaserIdx != -1) { 1151 updateLaserTarget(rightLaserIdx); 1152 } 1153 1154 for (size_t i = 0; i < laserObjects.size(); i++) { 1155 SceneObject<LaserVertex, SSBO_Laser>& obj = laserObjects[i]; 1156 SSBO_Laser& objData = obj.ssbo; 1157 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 } 1166 } 1167 1168 if (objects_explosionPipeline.resized) { 1169 resizeBufferSet(storageBuffers_explosionPipeline, objects_explosionPipeline.memorySize(), resourceCommandPool, 1170 graphicsQueue, true); 1171 1172 objects_explosionPipeline.resize(); 1173 1174 explosionPipeline.updateDescriptorInfo(1, &storageBuffers_explosionPipeline.infoSet, swapChainImages.size()); 1175 } 1176 1177 for (size_t i = 0; i < explosionObjects.size(); i++) { 1178 SceneObject<ExplosionVertex, SSBO_Explosion>& obj = explosionObjects[i]; 1179 SSBO_Explosion& objData = obj.ssbo; 1180 1181 if (!objData.deleted) { 1182 if (curTime > (objData.explosionStartTime + objData.explosionDuration)) { 1183 objData.deleted = true; 1184 obj.modified = true; 1087 1185 } 1088 1186 } 1089 } 1090 1091 // TODO: Replace updateBufferSet to one call to copyDataToMemory, using VulkanBuffer to provide the data source 1092 // TODO: Figure out a way to make updateDescriptorInfo easier to use, maybe store the binding index in the buffer set 1093 // TODO: Probably move the resizing to the VulkanBuffer class 1094 1095 if (objects_modelPipeline.resized) { 1096 resizeBufferSet(storageBuffers_modelPipeline, objects_modelPipeline.capacity * sizeof(SSBO_ModelObject), 1097 resourceCommandPool, graphicsQueue, true); 1098 1099 objects_modelPipeline.resize(); 1100 1101 modelPipeline.updateDescriptorInfo(1, &storageBuffers_modelPipeline.infoSet, swapChainImages.size()); 1102 } 1103 1104 for (size_t i = 0; i < modelObjects.size(); i++) { 1105 if (modelObjects[i].modified) { 1106 updateObject(modelObjects[i]); 1107 updateBufferSet(storageBuffers_modelPipeline, i, modelObjects[i].ssbo); 1187 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); 1108 1195 } 1109 1196 } 1110 1197 1111 // TODO: Probably move the resizing to the VulkanBuffer class 1112 if (objects_shipPipeline.resized) { 1113 resizeBufferSet(storageBuffers_shipPipeline, objects_shipPipeline.capacity * sizeof(SSBO_ModelObject), 1114 resourceCommandPool, graphicsQueue, true); 1115 1116 objects_shipPipeline.resize(); 1117 1118 shipPipeline.updateDescriptorInfo(1, &storageBuffers_shipPipeline.infoSet, swapChainImages.size()); 1119 } 1120 1121 for (size_t i = 0; i < shipObjects.size(); i++) { 1122 if (shipObjects[i].modified) { 1123 updateObject(shipObjects[i]); 1124 updateBufferSet(storageBuffers_shipPipeline, i, shipObjects[i].ssbo); 1198 explosion_UBO.cur_time = curTime; 1199 1200 for (vector<BaseEffectOverTime*>::iterator it = effects.begin(); it != effects.end(); ) { 1201 if ((*it)->deleted) { 1202 delete *it; 1203 it = effects.erase(it); 1204 } else { 1205 BaseEffectOverTime* eot = *it; 1206 1207 eot->applyEffect(curTime); 1208 1209 it++; 1125 1210 } 1126 1211 } 1127 1128 // TODO: Probably move the resizing to the VulkanBuffer class1129 if (objects_asteroidPipeline.resized) {1130 resizeBufferSet(storageBuffers_asteroidPipeline, objects_asteroidPipeline.capacity * sizeof(SSBO_Asteroid),1131 resourceCommandPool, graphicsQueue, true);1132 1133 objects_asteroidPipeline.resize();1134 1135 asteroidPipeline.updateDescriptorInfo(1, &storageBuffers_asteroidPipeline.infoSet, swapChainImages.size());1136 }1137 1138 for (size_t i = 0; i < asteroidObjects.size(); i++) {1139 if (asteroidObjects[i].modified) {1140 updateObject(asteroidObjects[i]);1141 updateBufferSet(storageBuffers_asteroidPipeline, i, asteroidObjects[i].ssbo);1142 }1143 }1144 1145 // TODO: Probably move the resizing to the VulkanBuffer class1146 if (objects_laserPipeline.resized) {1147 resizeBufferSet(storageBuffers_laserPipeline, objects_laserPipeline.capacity * sizeof(SSBO_Laser),1148 resourceCommandPool, graphicsQueue, true);1149 1150 objects_laserPipeline.resize();1151 1152 laserPipeline.updateDescriptorInfo(1, &storageBuffers_laserPipeline.infoSet, swapChainImages.size());1153 }1154 1155 for (size_t i = 0; i < laserObjects.size(); i++) {1156 if (laserObjects[i].modified) {1157 updateObject(laserObjects[i]);1158 updateBufferSet(storageBuffers_laserPipeline, i, laserObjects[i].ssbo);1159 }1160 }1161 1162 // TODO: Probably move the resizing to the VulkanBuffer class1163 if (objects_explosionPipeline.resized) {1164 resizeBufferSet(storageBuffers_explosionPipeline, objects_explosionPipeline.capacity * sizeof(SSBO_Explosion),1165 resourceCommandPool, graphicsQueue, true);1166 1167 objects_explosionPipeline.resize();1168 1169 explosionPipeline.updateDescriptorInfo(1, &storageBuffers_explosionPipeline.infoSet, swapChainImages.size());1170 }1171 1172 for (size_t i = 0; i < explosionObjects.size(); i++) {1173 if (explosionObjects[i].modified) {1174 updateObject(explosionObjects[i]);1175 updateBufferSet(storageBuffers_explosionPipeline, i, explosionObjects[i].ssbo);1176 }1177 }1178 1179 explosion_UBO.cur_time = curTime;1180 1212 1181 1213 VulkanUtils::copyDataToMemory(device, &object_VP_mats, uniformBuffers_modelPipeline.memory[imageIndex], 0, -
vulkan-game.hpp
rbb76950 rb7fc3c2 459 459 460 460 template<class VertexType, class SSBOType> 461 void updateObject(SceneObject<VertexType, SSBOType>& obj);462 463 template<class VertexType, class SSBOType>464 461 void updateObjectVertices(GraphicsPipeline_Vulkan<VertexType>& pipeline, 465 462 SceneObject<VertexType, SSBOType>& obj, size_t index); … … 508 505 } 509 506 510 // TODO: Right now, it's basically necessary to pass the identity matrix in for ssbo.model 511 // and to change the model matrix later by setting model_transform and then calling updateObject()507 // TODO: Right now, it's basically necessary to pass the identity matrix in for ssbo.model and to change 508 // the model matrix later by setting model_transform and then calculating the new ssbo.model. 512 509 // Figure out a better way to allow the model matrix to be set during object creation 513 510 template<class VertexType, class SSBOType> … … 517 514 VulkanBuffer<SSBOType>& objectBuffer, SSBOType ssbo) { 518 515 // TODO: Use the model field of ssbo to set the object's model_base 519 // currently, the passed in model is useless since it gets overridden in updateObject() anyway516 // currently, the passed-in model is useless since it gets overridden when ssbo.model is recalculated 520 517 size_t numVertices = pipeline.getNumVertices(); 521 518 … … 624 621 } 625 622 626 // TODO: Just pass in the single object instead of a list of all of them627 template<class VertexType, class SSBOType>628 void VulkanGame::updateObject(SceneObject<VertexType, SSBOType>& obj) {629 obj.ssbo.model = obj.model_transform * obj.model_base;630 obj.center = vec3(obj.ssbo.model * vec4(0.0f, 0.0f, 0.0f, 1.0f));631 632 obj.modified = false;633 }634 635 623 template<class VertexType, class SSBOType> 636 624 void VulkanGame::updateObjectVertices(GraphicsPipeline_Vulkan<VertexType>& pipeline,
Note:
See TracChangeset
for help on using the changeset viewer.