Changeset 5ba732a in opengl-game
- Timestamp:
- Apr 19, 2020, 1:55:16 AM (5 years ago)
- Branches:
- feature/imgui-sdl, master, points-test
- Children:
- 6104594
- Parents:
- 4994692
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
vulkan-game.cpp
r4994692 r5ba732a 248 248 texturedSquare->model_base = 249 249 translate(mat4(1.0f), vec3(0.0f, 0.0f, -2.0f)); 250 updateObject(modelObjects, modelPipeline, modelObjects.size() - 1);250 texturedSquare->modified = true; 251 251 252 252 texturedSquare = &addObject(modelObjects, modelPipeline, … … 264 264 texturedSquare->model_base = 265 265 translate(mat4(1.0f), vec3(0.0f, 0.0f, -1.5f)); 266 updateObject(modelObjects, modelPipeline, modelObjects.size() - 1);266 texturedSquare->modified = true; 267 267 268 268 modelPipeline.createDescriptorSetLayout(); … … 549 549 translate(mat4(1.0f), vec3(0.0f, -1.2f, 1.65f)) * 550 550 scale(mat4(1.0f), vec3(0.1f, 0.1f, 0.1f)); 551 updateObject(shipObjects, shipPipeline, 0);551 ship.modified = true; 552 552 } 553 553 … … 650 650 texturedSquare.model_base = 651 651 translate(mat4(1.0f), vec3(0.0f, 0.0f, zOffset)); 652 updateObject(modelObjects, modelPipeline, modelObjects.size() - 1);652 texturedSquare.modified = true; 653 653 } else { 654 654 cout << "Key event detected" << endl; … … 682 682 ship.model_transform = translate(mat4(1.0f), vec3(distance, 0.0f, 0.0f)) 683 683 * shipObjects[0].model_transform; 684 685 updateObject(shipObjects, shipPipeline, 0); 684 ship.modified = true; 686 685 } else if (gui->keyPressed(SDL_SCANCODE_RIGHT)) { 687 686 float distance = this->shipSpeed * this->elapsedTime; … … 689 688 ship.model_transform = translate(mat4(1.0f), vec3(distance, 0.0f, 0.0f)) 690 689 * shipObjects[0].model_transform; 691 692 updateObject(shipObjects, shipPipeline, 0); 690 ship.modified = true; 693 691 } 694 692 … … 704 702 // where it will run just once per frame 705 703 void VulkanGame::updateScene(uint32_t currentImage) { 706 for ( int i = 0; i < modelObjects.size(); i++) {707 model Objects[i].model_transform =704 for (SceneObject<ModelVertex, SSBO_ModelObject>& model : this->modelObjects) { 705 model.model_transform = 708 706 translate(mat4(1.0f), vec3(0.0f, -2.0f, -0.0f)) * 709 707 rotate(mat4(1.0f), this->curTime * radians(90.0f), vec3(0.0f, 0.0f, 1.0f)); 710 711 updateObject(modelObjects, modelPipeline, i); 712 } 713 714 for (int i = 0; i < this->asteroidObjects.size(); i++) { 715 if (!this->asteroidObjects[i].ssbo.deleted) { 716 vec3 objCenter = vec3(viewMat * vec4(this->asteroidObjects[i].center, 1.0f)); 717 718 if ((objCenter.z - this->asteroidObjects[i].radius) > -NEAR_CLIP) { 719 this->asteroidObjects[i].ssbo.deleted = true; 708 model.modified = true; 709 } 710 711 for (SceneObject<AsteroidVertex, SSBO_Asteroid>& asteroid : this->asteroidObjects) { 712 if (!asteroid.ssbo.deleted) { 713 vec3 objCenter = vec3(viewMat * vec4(asteroid.center, 1.0f)); 714 715 if ((objCenter.z - asteroid.radius) > -NEAR_CLIP) { 716 asteroid.ssbo.deleted = true; 717 718 // TODO: Create explosion here 720 719 } else { 721 this->asteroidObjects[i].model_transform =720 asteroid.model_transform = 722 721 translate(mat4(1.0f), vec3(0.0f, 0.0f, this->asteroidSpeed * this->elapsedTime)) * 723 this->asteroidObjects[i].model_transform;722 asteroid.model_transform; 724 723 } 725 724 726 updateObject(asteroidObjects, asteroidPipeline, i);725 asteroid.modified = true; 727 726 } 728 727 } … … 807 806 rotate(mat4(1.0f), radians(60.0f), vec3(1.0f, 1.0f, -1.0f)) * 808 807 scale(mat4(1.0f), vec3(0.1f, 0.1f, 0.1f)); 809 810 updateObject(asteroidObjects, asteroidPipeline, asteroidObjects.size() - 1); 808 asteroid.modified = true; 809 } 810 811 for (size_t i = 0; i < shipObjects.size(); i++) { 812 if (shipObjects[i].modified) { 813 updateObject(shipObjects, shipPipeline, i); 814 } 815 } 816 817 for (size_t i = 0; i < modelObjects.size(); i++) { 818 if (modelObjects[i].modified) { 819 updateObject(modelObjects, modelPipeline, i); 820 } 821 } 822 823 for (size_t i = 0; i < asteroidObjects.size(); i++) { 824 if (asteroidObjects[i].modified) { 825 updateObject(asteroidObjects, asteroidPipeline, i); 826 } 811 827 } 812 828 -
vulkan-game.hpp
r4994692 r5ba732a 77 77 mat4 model_base; 78 78 mat4 model_transform; 79 80 bool modified; 79 81 80 82 // TODO: Figure out if I should make child classes that have these fields instead of putting them in the … … 295 297 } 296 298 297 objects.push_back({ vertices, indices, ssbo, mat4(1.0f), mat4(1.0f) });299 objects.push_back({ vertices, indices, ssbo, mat4(1.0f), mat4(1.0f), false }); 298 300 299 301 SceneObject<VertexType, SSBOType>& obj = objects.back(); … … 333 335 334 336 pipeline.updateObject(index, obj.ssbo); 337 338 obj.modified = false; 335 339 } 336 340
Note:
See TracChangeset
for help on using the changeset viewer.