Index: sdl-game.hpp
===================================================================
--- sdl-game.hpp	(revision 996dd3efcf576a5eaf4f04878167c007d853dbac)
+++ sdl-game.hpp	(revision a3cefaa6294c97206ade08805f4ff1b8c13d2d4e)
@@ -21,4 +21,5 @@
 #include "consts.hpp"
 #include "vulkan-utils.hpp"
+#include "vulkan-buffer.hpp"
 #include "graphics-pipeline_vulkan.hpp"
 #include "game-gui-sdl.hpp"
@@ -77,4 +78,5 @@
 // Also, probably better to make this a vector of structs where each struct
 // has a VkBuffer, VkDeviceMemory, and VkDescriptorBufferInfo
+// TODO: Maybe change the structure here since VkDescriptorBufferInfo already stores a reference to the VkBuffer
 struct StorageBufferSet {
    vector<VkBuffer> buffers;
@@ -219,4 +221,5 @@
 
       StorageBufferSet storageBuffers_modelPipeline;
+      VulkanBuffer<SSBO_ModelObject> objects_modelPipeline;
 
       // TODO: Maybe make the ubo objects part of the pipeline class since there's only one ubo
@@ -296,6 +299,7 @@
       // TODO: Remove the need for templating, which is only there so a GraphicsPupeline_Vulkan can be passed in
       template<class VertexType, class SSBOType>
-      void resizeStorageBufferSet(StorageBufferSet& set, VkCommandPool commandPool, VkQueue graphicsQueue,
-                                  GraphicsPipeline_Vulkan<VertexType>& pipeline);
+      void resizeStorageBufferSet(StorageBufferSet& set, VulkanBuffer<SSBOType>& buffer,
+                                  GraphicsPipeline_Vulkan<VertexType>& pipeline,
+                                  VkCommandPool commandPool, VkQueue graphicsQueue);
 
       template<class SSBOType>
@@ -308,6 +312,5 @@
                                                    GraphicsPipeline_Vulkan<VertexType>& pipeline,
                                                    const vector<VertexType>& vertices, vector<uint16_t> indices,
-                                                   SSBOType ssbo, StorageBufferSet& storageBuffers,
-                                                   bool pipelinesCreated);
+                                                   SSBOType ssbo, StorageBufferSet& storageBuffers);
 
       template<class VertexType>
@@ -344,8 +347,14 @@
 
 template<class VertexType, class SSBOType>
-void VulkanGame::resizeStorageBufferSet(StorageBufferSet& set, VkCommandPool commandPool, VkQueue graphicsQueue,
-                                        GraphicsPipeline_Vulkan<VertexType>& pipeline) {
-   pipeline.objectCapacity *= 2;
-   VkDeviceSize bufferSize = pipeline.objectCapacity * sizeof(SSBOType);
+void VulkanGame::resizeStorageBufferSet(StorageBufferSet& set, VulkanBuffer<SSBOType>& buffer,
+                                        GraphicsPipeline_Vulkan<VertexType>& pipeline,
+                                        VkCommandPool commandPool, VkQueue graphicsQueue) {
+   size_t numObjects = buffer.numObjects < buffer.capacity ? buffer.numObjects : buffer.capacity;
+
+   do {
+      buffer.capacity *= 2;
+   } while (buffer.capacity < buffer.numObjects);
+
+   VkDeviceSize bufferSize = buffer.capacity * sizeof(SSBOType);
 
    for (size_t i = 0; i < set.buffers.size(); i++) {
@@ -359,5 +368,5 @@
 
       VulkanUtils::copyBuffer(device, commandPool, set.buffers[i], newStorageBuffer,
-         0, 0, pipeline.numObjects * sizeof(SSBOType), graphicsQueue);
+         0, 0, numObjects * sizeof(SSBOType), graphicsQueue);
 
       vkDestroyBuffer(device, set.buffers[i], nullptr);
@@ -371,4 +380,8 @@
       set.infoSet[i].range = bufferSize; // Size of the update starting from offset, or VK_WHOLE_SIZE
    }
+
+   // Assume the SSBO is always the 2nd binding
+   // TODO: Figure out a way to make this more flexible
+   pipeline.updateDescriptorInfo(1, &set.infoSet, swapChainImages);
 }
 
@@ -384,15 +397,9 @@
 // and to change the model matrix later by setting model_transform and then calling updateObject()
 // Figure out a better way to allow the model matrix to be set during object creation
-
-// TODO: Maybe return a reference to the object from this method if I decide that updating it
-// immediately after creation is a good idea (such as setting model_base)
-// Currently, model_base is set like this in a few places and the radius is set for asteroids
-// to account for scaling
 template<class VertexType, class SSBOType>
 SceneObject<VertexType, SSBOType>& VulkanGame::addObject(vector<SceneObject<VertexType, SSBOType>>& objects,
                                                          GraphicsPipeline_Vulkan<VertexType>& pipeline,
                                                          const vector<VertexType>& vertices, vector<uint16_t> indices,
-                                                         SSBOType ssbo, StorageBufferSet& storageBuffers,
-                                                         bool pipelinesCreated) {
+                                                         SSBOType ssbo, StorageBufferSet& storageBuffers) {
    // TODO: Use the model field of ssbo to set the object's model_base
    // currently, the passed in model is useless since it gets overridden in updateObject() anyway
@@ -415,46 +422,4 @@
 
    pipeline.addObject(obj.vertices, obj.indices, resourceCommandPool, graphicsQueue);
-
-   // TODO: Probably move the resizing to the VulkanBuffer class
-   // First, try moving this out of addObject
-   bool resizeStorageBuffer = pipeline.numObjects == pipeline.objectCapacity;
-
-   if (resizeStorageBuffer) {
-      resizeStorageBufferSet<VertexType, SSBOType>(storageBuffers, resourceCommandPool, graphicsQueue, pipeline);
-      pipeline.cleanup();
-
-      // Assume the SSBO is always the 2nd binding
-      // TODO: Figure out a way to make this more flexible
-      pipeline.updateDescriptorInfo(1, &storageBuffers.infoSet);
-   }
-
-   pipeline.numObjects++;
-
-   // TODO: Figure out why I am destroying and recreating the ubos when the swap chain is recreated,
-   // but am reusing the same ssbos. Maybe I don't need to recreate the ubos.
-
-   if (pipelinesCreated) {
-      // TODO: See if I can avoid doing this when recreating the pipeline
-      vkDeviceWaitIdle(device);
-
-      for (uint32_t i = 0; i < swapChainImageCount; i++) {
-         vkFreeCommandBuffers(device, commandPools[i], 1, &commandBuffers[i]);
-      }
-
-      // TODO: The pipeline recreation only has to be done once per frame where at least
-      // one SSBO is resized.
-      // Refactor the logic to check for any resized SSBOs after all objects for the frame
-      // are created and then recreate each of the corresponding pipelines only once per frame
-
-      // TODO: Also, verify if I actually need to recreate all of these, or maybe just the descriptor sets, for instance
-
-      if (resizeStorageBuffer) {
-         pipeline.createPipeline(pipeline.vertShaderFile, pipeline.fragShaderFile);
-         pipeline.createDescriptorPool(swapChainImages);
-         pipeline.createDescriptorSets(swapChainImages);
-      }
-
-      createCommandBuffers();
-   }
 
    return obj;
