Skip to content

Commit

Permalink
[FIX] : fix camera ratio issue on View3dPane resize
Browse files Browse the repository at this point in the history
  • Loading branch information
aiekick committed Nov 19, 2023
1 parent 32853a4 commit ed0d6ca
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 27 deletions.
4 changes: 2 additions & 2 deletions Plugins/PostProcessing/src/Headers/PostProcessingBuild.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#define PostProcessing_Prefix "PostProcessing"
#define PostProcessing_BuildNumber 533
#define PostProcessing_BuildNumber 534
#define PostProcessing_MinorNumber 1
#define PostProcessing_MajorNumber 0
#define PostProcessing_BuildId "0.1.533"
#define PostProcessing_BuildId "0.1.534"
18 changes: 11 additions & 7 deletions bin/projects/post_processing.lum
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,20 @@
<slot place="OUTPUT" index="5" name="Color" type="TEXTURE_2D" id="105182"/>
<slot place="OUTPUT" index="6" name="Depth" type="TEXTURE_2D" id="105186"/>
</node>
<node name="Texture 2D" type="TEXTURE_2D" pos="-401;-2" id="269834">
<slot place="OUTPUT" index="0" name="Output" type="TEXTURE_2D" id="269838"/>
<texture_2d_module>
<file_path_name>C:\Gamedev\gitlab\Lumo\bin\matcap\BazC_SkinMat.jpg</file_path_name>
<file_path>C:\Gamedev\gitlab\Lumo\bin\matcap</file_path>
</texture_2d_module>
</node>
<node name="Model" type="MESH" pos="-370;-82" id="156328">
<slot place="OUTPUT" index="0" name="Output" type="MESH" id="156332"/>
<mesh_module>
<file_path_name>C:\Gamedev\gitlab\Lumo\bin\meshs\beethoven.gltf</file_path_name>
<file_path>C:\Gamedev\gitlab\Lumo\bin\meshs</file_path>
</mesh_module>
</node>
<node name="Texture 2D" type="TEXTURE_2D" pos="-401;-2" id="269834">
<slot place="OUTPUT" index="0" name="Output" type="TEXTURE_2D" id="269838"/>
<texture_2d_module>
<file_path_name>C:\Gamedev\gitlab\Lumo\bin\matcap\BazC_SkinMat.jpg</file_path_name>
<file_path>C:\Gamedev\gitlab\Lumo\bin\matcap</file_path>
</texture_2d_module>
</node>
<node name="Post Processing" type="POST_PROCESSING" pos="0;-44" id="229189">
<slot place="INPUT" index="0" name="Color" type="TEXTURE_2D" id="229192"/>
<slot place="INPUT" index="1" name="Position" type="TEXTURE_2D" id="229195"/>
Expand Down Expand Up @@ -163,6 +163,8 @@
</links>
<outputs>
<output type="left" ids="229189:229201"/>
<output type="middle" ids="300593:300614"/>
<output type="right" ids="300593:300614"/>
</outputs>
</graph>
</scene>
Expand Down Expand Up @@ -219,6 +221,8 @@
</links>
<outputs>
<output type="left" ids="229189:229201"/>
<output type="middle" ids="300593:300614"/>
<output type="right" ids="300593:300614"/>
</outputs>
</graph>
</scene>
Expand Down
2 changes: 1 addition & 1 deletion src/Backend/MainBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ void MainBackend::m_UpdateCamera(const bool& vForce) {
if (vForce) {
CommonSystem::Instance()->NeedCamChange();
}
CommonSystem::Instance()->UpdateIfNeeded(m_DisplaySize);
View3DPane::Instance()->UpdateCameraIfNeeded();
}

void MainBackend::m_UpdateSound() {
Expand Down
4 changes: 2 additions & 2 deletions src/Headers/LumoBuild.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#define Lumo_Prefix "Lumo"
#define Lumo_BuildNumber 5355
#define Lumo_BuildNumber 5359
#define Lumo_MinorNumber 0
#define Lumo_MajorNumber 0
#define Lumo_BuildId "0.0.5355"
#define Lumo_BuildId "0.0.5359"
28 changes: 16 additions & 12 deletions src/Panes/View3DPane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,13 @@ bool View3DPane::DrawPanes(const uint32_t& vCurrentFrame, PaneFlags& vInOutPaneS
{
if (ImGui::IsMouseHoveringRect(org, org + siz))
{
if (m_CanWeTuneMouse && CanUpdateMouse(true, 0))
if (m_CanWeTuneMouse && m_CanUpdateMouse(true, 0))
{
ct::fvec2 norPos = (ImGui::GetMousePos() - org) / siz;
CommonSystem::Instance()->SetMousePos(norPos, m_PaneSize, ImGui::GetCurrentContext()->IO.MouseDown);
}

UpdateCamera(org, siz);
m_UpdateCamera(org, siz);
}
}

Expand Down Expand Up @@ -217,6 +217,10 @@ bool View3DPane::DrawOverlays(const uint32_t& vCurrentFrame, const ImRect& vRect
return false;
}

void View3DPane::Select(BaseNodeWeak vObjet) {
CTOOL_DEBUG_BREAK;
}

///////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -270,13 +274,16 @@ void View3DPane::SetVulkanImGuiRenderer(VulkanImGuiRendererWeak vVulkanImGuiRend
m_VulkanImGuiRenderer = vVulkanImGuiRenderer;
}

void View3DPane::SetDescriptor(GaiApi::VulkanFrameBufferAttachment* vVulkanFrameBufferAttachment)
bool View3DPane::UpdateCameraIfNeeded() {
return CommonSystem::Instance()->UpdateIfNeeded(ct::uvec2(m_PaneSize.x, m_PaneSize.y));
}

void View3DPane::m_SetDescriptor(GaiApi::VulkanFrameBufferAttachment* vVulkanFrameBufferAttachment)
{
m_ImGuiTexture.SetDescriptor(m_VulkanImGuiRenderer, vVulkanFrameBufferAttachment);
}

bool View3DPane::CanUpdateMouse(bool vWithMouseDown, int vMouseButton)
{
bool View3DPane::m_CanUpdateMouse(bool vWithMouseDown, int vMouseButton) {
ZoneScoped;

bool canUpdateMouse = true;
Expand All @@ -296,14 +303,13 @@ bool View3DPane::CanUpdateMouse(bool vWithMouseDown, int vMouseButton)
return canUpdateMouse;
}

void View3DPane::UpdateCamera(ImVec2 vOrg, ImVec2 vSize)
{
void View3DPane::m_UpdateCamera(ImVec2 vOrg, ImVec2 vSize) {
ZoneScoped;

bool canTuneCamera = !ImGuizmo::IsUsing() && (m_CanWeTuneCamera || ImGui::IsKeyPressed(ImGuiKey_LeftAlt));

// update mesher camera // camera of renderpack
if (CanUpdateMouse(true, 0)) // left mouse rotate
if (m_CanUpdateMouse(true, 0)) // left mouse rotate
{
if (canTuneCamera)// && !ImGuizmo::IsUsing())
{
Expand All @@ -321,8 +327,7 @@ void View3DPane::UpdateCamera(ImVec2 vOrg, ImVec2 vSize)
if (!diff.emptyAND()) m_UINeedRefresh |= true;
m_LastNormalizedMousePos = m_CurrNormalizedMousePos;
}
}
else if (CanUpdateMouse(true, 1)) // right mouse zoom
} else if (m_CanUpdateMouse(true, 1)) // right mouse zoom
{
if (canTuneCamera)// && !ImGuizmo::IsUsing())
{
Expand All @@ -341,8 +346,7 @@ void View3DPane::UpdateCamera(ImVec2 vOrg, ImVec2 vSize)
if (!diff.emptyAND()) m_UINeedRefresh |= true;
m_LastNormalizedMousePos = m_CurrNormalizedMousePos;
}
}
else if (CanUpdateMouse(true, 2)) // middle mouse, translate
} else if (m_CanUpdateMouse(true, 2)) // middle mouse, translate
{
if (canTuneCamera)// && !ImGuizmo::IsUsing())
{
Expand Down
8 changes: 5 additions & 3 deletions src/Panes/View3DPane.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,12 @@ class View3DPane : public AbstractPane
ct::fvec2 SetOrUpdateOutput(NodeSlotWeak vTextureOutputSlot);
void SetVulkanImGuiRenderer(VulkanImGuiRendererWeak vVulkanImGuiRenderer);

bool UpdateCameraIfNeeded();

private:
void SetDescriptor(GaiApi::VulkanFrameBufferAttachment* vVulkanFrameBufferAttachment);
bool CanUpdateMouse(bool vWithMouseDown, int vMouseButton);
void UpdateCamera(ImVec2 vOrg, ImVec2 vSize);
void m_SetDescriptor(GaiApi::VulkanFrameBufferAttachment* vVulkanFrameBufferAttachment);
bool m_CanUpdateMouse(bool vWithMouseDown, int vMouseButton);
void m_UpdateCamera(ImVec2 vOrg, ImVec2 vSize);

public: // singleton
static std::shared_ptr<View3DPane> Instance()
Expand Down

0 comments on commit ed0d6ca

Please sign in to comment.