-
Notifications
You must be signed in to change notification settings - Fork 24
Camera manager #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: Lesson08
Are you sure you want to change the base?
Camera manager #16
Conversation
| world.system<Position, CameraPtr, const Speed>() | ||
| .each([&](flecs::entity e, Position& position, CameraPtr& camera, const Speed& speed) | ||
| world.system<CameraManagerPtr>() | ||
| .each([&](flecs::entity e, CameraManagerPtr& cameraManager) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Как-то глупо, что у вас сущности есть с камера менеджером в качестве компоненты, не находите?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ну и что будет, если я создам 2 сущности с такой компонентой? А если 3?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
В игре должна быть сущность - менеджер камер. А значит, у сущности есть указатель на менеджер камер в качестве компоненты. В игре предполагается создание одного менеджера камер. Если в игре будет несколько таких сущностей, то действия (переключиться на след. камеру, создать камеру и т.д.) будут дублироваться, но при этом работать с одним и тем же менеджером камер.
Engine/Editor/private/GameEditor.cpp
Outdated
| Core::g_MainCamera = new Core::Camera(); | ||
| Core::g_MainCamera->SetPosition(Math::Vector3f(0.0f, 12.0f, -10.0f)); | ||
| Core::g_MainCamera->SetViewDir(Math::Vector3f(0.0f, -6.0f, 12.0f)); | ||
| Core::g_CameraManager = new Core::CameraManager(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Может, лучше через unique_ptr сделать? У нас всё же только один менеджер может быть, а так сейчас ещё и память течёт
| for (World::LevelObject::Component& component : levelObject.GetComponents()) | ||
| { | ||
| ImGui::InputText(component.first.c_str(), &component.second); | ||
| if (VECTOR3_COMPONENTS.contains(component.first)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Я немного пофорщу код стайл движка, так что готовьтесь =)
В случае условий, как вы могли заметить, у нас фигурные скобки живут на отдельных строчках
if ()
{
...
}There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
да, стараюсь соблюдать, машинально пишу своим стилем
| } | ||
|
|
||
| void LevelEditor::AddDefaultObject() { | ||
| if (!m_Level.has_value()) return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Даже такие простые условия должны выделяться фигурными скобками в нашем движке
|
|
||
| std::string baseName = "NewObject1"; | ||
| std::string objectName = baseName; | ||
| int counter = 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Предпочитайте более явный тип данных. Есть всякие uint16_t и прочие. Из вашего кода я ожидаю, что возможные значения тут могут быть и отрицательные.
| // Can be set to 0 since it doesn't matter now, will be updated by the system | ||
| entity.set(EntitySystem::EditorECS::Position{ 0.0f, 0.0f, 0.0f }); | ||
| entity.set(GeometryPtr{ | ||
| reinterpret_cast<RenderCore::Geometry*>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Не static_cast?
| namespace GameEngine::Core | ||
| { | ||
| Camera* g_MainCamera = nullptr; | ||
| //Camera* g_MainCamera = nullptr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Не оставляйте такие комментарии. Просто удалите, раз оно не надо
|
|
||
| Camera::Ptr CameraManager::CreateCamera() | ||
| { | ||
| auto newCamera = std::make_shared<Camera>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
auto...
| --m_CurrCameraIt; | ||
| } | ||
| } | ||
| } No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
А если я хочу не "следующую камеру", а вполне конкретную камеру активировать?
| GameEngine::Core::Controller* ptr; | ||
| }; | ||
|
|
||
| struct ButtonManager |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Из текущей логики я могу переключиться только раз. Я хочу переключаться бесконечное количество раз, но не создавать новые камеры из кода, только заранее заданные камеры привязанные к объектам
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
нет, переключаться можно сколько угодно раз. Компонент ButtonManager нужен для того, чтобы предотвращать залипание кнопки. При нажатии на клавишу (переменная wasPressed меняется на true) переключение произойдет только один раз и не будет возможным до тех пор, пока не будет отжата кнопка (wasPressed = false).
…y pressed or not after some action. This system prevents keys from sticking
…a common system in a flecs world.
Added a Camera manager, which contains a list of camera, ptr to a current active camera and also can
On a game scene (launch Game) you can create another camera with button "C" and switch to the next or previous one with the buttons "Q" and "E".