Conversation
# Conflicts: # PolyEngine/Engine/Src/Engine.cpp
…ce and Game Project. Spams a lot
…included in shared libs
MuniuDev
left a comment
There was a problem hiding this comment.
I only addressed architectonical issues for now, as it's yet unfinished (at least according to the description)
PolyEngine/Engine/Src/EnginePCH.hpp
Outdated
| #include <assimp/scene.h> | ||
| #include <assimp/Importer.hpp> | ||
|
|
||
| // SILENCE_GCC_WARNING(-Wimplicit-fallthrough=, "Surpressing clang warnings in imstb_truetype") |
There was a problem hiding this comment.
We either need that or not, if not needed then remove commented code.
|
|
||
| namespace ImguiSystem | ||
| { | ||
| void ImguiUpdatePhase(Scene* world); |
There was a problem hiding this comment.
Use class systems, function systems are deprecated.
| @@ -0,0 +1,37 @@ | |||
| // ImGui Renderer for: OpenGL3 / OpenGL ES2 / OpenGL ES3 (modern OpenGL with shaders / programmatic pipeline) | |||
There was a problem hiding this comment.
This header and it's corresponding cpp look like part of imgui, we should make this another library and link it, not copy the files. This can be called ImGuiGLBinding or sth similar. Later, this would need to be linked by our rendering backend, depending on the rendering framework used.
There was a problem hiding this comment.
I would keep it as example of custom rendering pass introduced by engine ImguiSystem
There was a problem hiding this comment.
But this is not custom pass. This is third party code injected into our code tree. I think it would be much better to separate this. I know it's easier that way, but I would still try. You can think of it as something similar to epoxy, it provides gl bindings to our engine.
There was a problem hiding this comment.
Need to compare OpenGL implementation with Vulkan.
|
|
||
| using namespace Poly; | ||
|
|
||
| ImguiResource::ImguiResource() |
There was a problem hiding this comment.
Why make it resource? I think this can safely be system field (use class systems) as it does not hold any state, at least relevant to game.
| { | ||
| class ImguiResource; | ||
|
|
||
| class ENGINE_DLLEXPORT ImguiWorldComponent : public ComponentBase |
There was a problem hiding this comment.
There really is no need for the component. This can be safely put into system, as it does not hold state relevant to the game.
…stem constructor, removed Resource and WorldComponent
… consumed by any system
PolyEngine/Engine/CMakeLists.txt
Outdated
| find_package(Imgui REQUIRED) | ||
| find_package(RapidJSON REQUIRED) | ||
| find_package(STB REQUIRED) | ||
| add_subdirectory("${ENGINE_ROOT_DIR}/ThirdParty/Imgui" "${CMAKE_CURRENT_BINARY_DIR}/Imgui") |
There was a problem hiding this comment.
Move this line to CMakeListsCommon.txt
PolyEngine/Engine/CMakeLists.txt
Outdated
| add_library(${ENGINE_TARGET} SHARED ${POLYENGINE_SRCS}) | ||
| target_compile_definitions(${ENGINE_TARGET} PRIVATE _ENGINE) | ||
| target_include_directories(${ENGINE_TARGET} PUBLIC ${POLYENGINE_INCLUDE} ${BULLET_INCLUDE_DIRS} ${STB_INCLUDE_DIRS} ${IMGUI_INCLUDE_DIRS}) | ||
| target_include_directories(${ENGINE_TARGET} PUBLIC ${POLYENGINE_INCLUDE} ${BULLET_INCLUDE_DIRS} ${STB_INCLUDE_DIRS} "${ENGINE_ROOT_DIR}/ThirdParty/Imgui") |
There was a problem hiding this comment.
Let's make the location of the imgui headers a variable, set in CMakeListsCommon.txt, just near the line with add_subdirectory.
PolyEngine/Engine/Src/Engine.hpp
Outdated
| /// <summary>Pushes input event to an input queue with specified UTF8 character. | ||
| /// One of eight functions handling incoming input events.</summary> | ||
| /// <param name="key">Unicode UTF8 character</param> | ||
| void AddCharacterUTF8(char* charUTF8) { InputEventsQueue.PushBack({eInputEventType::TEXTCHAR, charUTF8}); } |
|
|
||
| /// <summary>Returns refference to output queue needed by Main.</summary> | ||
| /// <returns>Reference to OutputQueue instance.</returns> | ||
| OutputQueue& GetOutputQueue() { return OutputEventsQueue; } |
There was a problem hiding this comment.
Just out of curiosity, what do we output in that queue?
There was a problem hiding this comment.
Commands to Window handling library (SDL2) in main.cpp such as switching between cursors on panel resizing.
| if (inputCmp->GetCharUTF8() != nullptr) | ||
| { | ||
| const char* charUTF8 = inputCmp->GetCharUTF8(); | ||
| size_t length = StrLen(charUTF8); |
There was a problem hiding this comment.
This is dangerous. The length should be handled by utf-8 aware method. We really need a UTF-8 String... But do we really need to check that length? I would just check if it's nullptr.
There was a problem hiding this comment.
nullptr check was added later and should be sufficient, done
| static bool show_demo_window = true; | ||
| static ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f); | ||
| if (io.WantCaptureMouse || io.WantCaptureKeyboard) | ||
| inputCmp->SetConsumed(); |
There was a problem hiding this comment.
Why do we need to consume the input?
There was a problem hiding this comment.
Bad thing:
- Checkout fet/imgui branch
- Uncomment lines 174. and 175.
3.1 See that ex. camera (FreeFloatMovement) is rotated when dragging mouse inside imgui panels. - 2 See that ex. camera (FreeFloatMovement) is moved when typing inside imgui text widgets.
Good thing:
Consuming input in ImguiSystem handles also Imgui panels created by other systems including game systems.
| break; | ||
| case eInputEventType::MOUSEPOS: | ||
| com->MouseDelta = ev.Pos - com->MousePos; | ||
| // com->MouseDelta = ev.Pos - com->MousePos; |
There was a problem hiding this comment.
Suddenly MOUSEPOS event i overwriting com->MouseDelta with (0,0) after MOUSEMOVE event and camera (FreeFloatMovement) does not rotate. Issue is also on dev. Tested in Standalone. Happens also on dev branch
Please checkout branches and confirm the issue.
Diffed with dev branch, seems that there are no changes in this branch for regression.

There was a problem hiding this comment.
Indeed there is a problem, this is a result the way event are being sent. MOUSEMOVE and MOUSEPOS are always received in a pair (with that order). Let's add a comment describing that behaviour, and remove the commended line of code.
| Dynarray<Optional<size_t>> PlayerIDToJoystickID; | ||
| std::unordered_map<size_t, size_t> JoystickIDToPlayerID; | ||
| bool IsConsumed; | ||
| char* CharUTF8; |
There was a problem hiding this comment.
default values for both of those fields are needed.
There was a problem hiding this comment.
Done, please check it
| float deltaTime = (float)(TimeSystem::GetTimerDeltaTime(world, Poly::eEngineTimer::GAMEPLAY)); | ||
| InputWorldComponent* inputCmp = world->GetWorldComponent<InputWorldComponent>(); | ||
|
|
||
| if (inputCmp->GetIsConsumed()) |
There was a problem hiding this comment.
I know. Please see reported issues with camera rotation and mouse dragging on Imgui panels.
| Engine->Update(); | ||
|
|
||
| Poly::OutputQueue& OutputEventsQueue = Engine->GetOutputQueue(); | ||
| while (!OutputEventsQueue.IsEmpty()) |
There was a problem hiding this comment.
We should add that logic for input handling to editor also.
There was a problem hiding this comment.
Need to know where it is handled in Editor.
There was a problem hiding this comment.
Engine::Update is called here - Editor/Src/Managers/Project/EngineManager.cpp
You can get SDL from - Editor/Src/Widgets/Inspectors/ViewportInspectorWidget.cpp
You can write getter for ViewportInsepctor InspectorManager at- Editor/Src/Managers/Project/InspectorManager.cpp
and then get ViewportInsepctor using gApp (gApp->InspectorMgr)
There was a problem hiding this comment.
Added cursor handling from OutputEvent queue from engine. Couldn't open project in editor so it is only untested conversation starter.
|
|
||
| InputWorldComponent() = default; | ||
| InputWorldComponent() | ||
| : IsConsumed(false), CharUTF8(nullptr) |
There was a problem hiding this comment.
This should have been done in class header, not in the constructor. Please revert this.
* imgui reacting to input and drawing on screen from render device * proper init, render deinit and windows created by game * comments * comments * commented #pragma failing travis ci * removed #pragma * removed pragma from resource * commented unused components * commented out wrong variable doh... * merged with dev * cmake attempt * moved imgui to third parties, cmake updated for Engine, RenderingDevice and Game Project. Spams a lot * removed sanity spam * resource cleanup * imguisystem cleanup * imgui world component cleanup * added non windows API attributes to imconfig.h * moved imgui to pch * silencing third party gcc -Wimplicit-fallthrough= * enabled -fPIC (Position Independent Code) for imgui static lib to be included in shared libs * fixing gcc includes * fixing cgg includes * made includes same as in GLTextureDeviceProxy * removed commented out code * ImguiUpdate is now in System, Imgui context creation moved to ImguiSystem constructor, removed Resource and WorldComponent * moved Imgui to Engine subdirectory * Added clipboard support, tweaked mouse handling and input that can be consumed by any system * added UTF8 char input from keyboard keys * fixing input consumption (works on all widowns: engine and game) * added output queue and events handled by SDL * CI fix * CI fix and cleanup * CI fix * CI fix * fix * move add_subdirectory of imgui to CMakeListsCommon * added const to charUTF8 * removed length check when passing charUTF to Imgui * variable reuse * InputWorldComponent member initialization * dummy change * added comment about MouseDelta overwrite to (0,0) in MOUSEPOS * property init moved to header * handling mouse cursor feedback from engine imgui
Added Dear ImGui by https://github.com/ocornut/imgui
Engine and Game systems can draw Imgui windows in Update Phase.