Камера как часть сцены

This commit is contained in:
Ковалев Роман Евгеньевич 2023-10-17 02:14:37 +03:00 committed by re.kovalev
parent 5578a43c15
commit 7e6f1c8678
2 changed files with 8 additions and 2 deletions

View File

@ -2,6 +2,7 @@
#define SCENE_H #define SCENE_H
#include "Model.h" #include "Model.h"
#include "Camera.h"
// Класс сцены // Класс сцены
class Scene class Scene
@ -18,6 +19,7 @@ class Scene
// Списки объектов, выступающих узлами // Списки объектов, выступающих узлами
std::vector<Node> nodes; // Список пустых узлов std::vector<Node> nodes; // Список пустых узлов
std::vector<Model> models; // Список моделей для рендера std::vector<Model> models; // Список моделей для рендера
std::vector<Camera> cameras; // Список камер
protected: protected:
void rebuld_tree(const Scene& from); // Перестройка дерева после копирования или присваивания void rebuld_tree(const Scene& from); // Перестройка дерева после копирования или присваивания

View File

@ -3,12 +3,12 @@
// Конструктор пустой сцены // Конструктор пустой сцены
Scene::Scene() Scene::Scene()
{ {
} }
// Конструктор копирования // Конструктор копирования
Scene::Scene(const Scene &copy): root(copy.root), Scene::Scene(const Scene &copy): root(copy.root),
nodes(copy.nodes), models(copy.models) nodes(copy.nodes), models(copy.models), cameras(copy.cameras)
{ {
rebuld_tree(copy); rebuld_tree(copy);
} }
@ -19,6 +19,7 @@ Scene& Scene::operator=(const Scene& other)
root = other.root; root = other.root;
nodes = other.nodes; nodes = other.nodes;
models = other.models; models = other.models;
cameras = other.cameras;
rebuld_tree(other); rebuld_tree(other);
@ -53,6 +54,8 @@ void Scene::rebuild_Nodes_vector(T& nodes, const Scene& from)
continue; continue;
if (move_pointer(nodes[i], from.models, models)) if (move_pointer(nodes[i], from.models, models))
continue; continue;
if (move_pointer(nodes[i], from.cameras, cameras))
continue;
// Не нашли родителя - значит он не часть этой сцены // Не нашли родителя - значит он не часть этой сцены
// и изменений по нему не требуется // и изменений по нему не требуется
@ -80,4 +83,5 @@ void Scene::rebuld_tree(const Scene& from)
// Восстановим родителей в пустых узлах для копии // Восстановим родителей в пустых узлах для копии
rebuild_Nodes_vector(nodes, from); rebuild_Nodes_vector(nodes, from);
rebuild_Nodes_vector(models, from); rebuild_Nodes_vector(models, from);
rebuild_Nodes_vector(cameras, from);
} }