Changeset 2ba5617 in opengl-game for vulkan-game.hpp
- Timestamp:
- Mar 26, 2020, 3:41:42 AM (5 years ago)
- Branches:
- feature/imgui-sdl, master, points-test
- Children:
- bf4744d
- Parents:
- 2ff4d3e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vulkan-game.hpp
r2ff4d3e r2ba5617 61 61 mat4 model_base; 62 62 mat4 model_transform; 63 vec3 center; 64 float radius; 63 vec3 center; // currently only matters for asteroids 64 float radius; // currently only matters for asteroids 65 65 }; 66 66 … … 159 159 // Or maybe create a higher level wrapper around GraphicsPipeline_Vulkan to hold things like 160 160 // the objects vector, the ubo, and the ssbo 161 162 // TODO: Rename *_VP_mats to *_uniforms and possibly use different types for each one 163 // if there is a need to add other uniform variables to one or more of the shaders 161 164 162 165 GraphicsPipeline_Vulkan<ModelVertex, SSBO_ModelObject> modelPipeline; … … 263 266 // and to change the model matrix later by setting model_transform and then calling updateObject() 264 267 // Figure out a better way to allow the model matrix to be set during objecting creation 268 269 // TODO: Maybe return a reference to the object from this method if I decide that updating it 270 // immediately after creation is a good idea (such as setting model_base) 271 // Currently, model_base is set like this in a few places and the radius is set for asteroids 272 // to account for scaling 265 273 template<class VertexType, class SSBOType> 266 274 void VulkanGame::addObject(vector<SceneObject<VertexType, SSBOType>>& objects, … … 268 276 const vector<VertexType>& vertices, vector<uint16_t> indices, SSBOType ssbo, 269 277 bool pipelinesCreated) { 278 // TODO: Use the model field of ssbo to set the object's model_base 279 // currently, the passed in model is useless since it gets overridden in updateObject() anyway 270 280 size_t numVertices = pipeline.getNumVertices(); 271 281 … … 275 285 276 286 objects.push_back({ vertices, indices, ssbo, mat4(1.0f), mat4(1.0f) }); 277 centerObject(objects.back()); 278 279 bool storageBufferResized = pipeline.addObject(vertices, indices, ssbo, commandPool, graphicsQueue); 287 288 SceneObject<VertexType, SSBOType>& obj = objects.back(); 289 centerObject(obj); 290 291 bool storageBufferResized = pipeline.addObject(obj.vertices, obj.indices, obj.ssbo, commandPool, graphicsQueue); 280 292 281 293 if (pipelinesCreated) { … … 304 316 305 317 obj.ssbo.model = obj.model_transform * obj.model_base; 306 307 // could probably re-calculate the object center here based on model 308 // I think the center should be calculated by using model * vec3(0, 0, 0) 309 // model_base is currently only used to set the original location of the ship and asteroids 318 obj.center = vec3(obj.ssbo.model * vec4(0.0f, 0.0f, 0.0f, 1.0f)); 310 319 311 320 pipeline.updateObject(index, obj.ssbo); … … 379 388 } 380 389 381 object.radius = std::max(center.x, center.y); 382 object.radius = std::max(object.radius, center.z); 390 object.radius = std::max(max_x - center.x, max_y - center.y); 391 object.radius = std::max(object.radius, max_z - center.z); 392 383 393 object.center = vec3(0.0f, 0.0f, 0.0f); 384 394 }
Note:
See TracChangeset
for help on using the changeset viewer.