From 30c1646f020dd5e536bd83ef7aa4375c4db62692 Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Sun, 24 Nov 2019 16:46:57 -1000 Subject: [PATCH] Update dew, fix no lighting mode --- CMakeLists.txt | 3 +- dew.cmake | 7 ++ dewfile.json | 2 +- src/Core/CMakeLists.txt | 2 +- src/Core/GameProject/CGameExporter.cpp | 1 + src/Core/GameProject/CGameExporter.h | 2 +- src/Core/GameProject/CGameProject.cpp | 3 +- src/Core/Resource/Model/CStaticModel.cpp | 69 ++++++++++++++----- src/Core/Scene/CStaticNode.cpp | 4 +- .../CCollisionEditorViewport.cpp | 3 +- .../ModelEditor/CModelEditorViewport.cpp | 16 +++-- 11 files changed, 80 insertions(+), 32 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 47246c17..b2f5dbc2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,10 +5,11 @@ set(MACOSX_DEPLOYMENT_TARGET 10.10) if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Release) endif() +set(CMAKE_CONFIGURATION_TYPES ${CMAKE_BUILD_TYPE}) project(PrimeWorldEditor CXX) -option(PWE_PUBLIC_RELEASE "Enable end-user deployment configuration for PWE" OFF) +option(PWE_PUBLIC_RELEASE "Enable end-user deployment configuration for PWE" ON) if (PWE_PUBLIC_RELEASE) add_compile_definitions(PUBLIC_RELEASE=1) message(STATUS "Enabled public release mode") diff --git a/dew.cmake b/dew.cmake index c57ae41d..e3e2d272 100644 --- a/dew.cmake +++ b/dew.cmake @@ -17,6 +17,13 @@ function(integrate_dew) return() endif() + # + # Advise the user that setting the build type is necessary for debug dependencies. + # + if (NOT CMAKE_BUILD_TYPE) + message(WARNING "CMAKE_BUILD_TYPE is not set. Dew will build release dependencies by default.") + endif() + # # Acquaint CMake with dew prefix # diff --git a/dewfile.json b/dewfile.json index 50a6f223..844ca29b 100644 --- a/dewfile.json +++ b/dewfile.json @@ -28,7 +28,7 @@ "url": "https://github.com/AxioDL/nod", "type": "git", "head": "master", - "ref": "a1284ae06586b958f36b8ecaba29390835ed2820" + "ref": "f147e1235646b849f78a8574a6d554214b70792d" }, { "name": "lzokay", diff --git a/src/Core/CMakeLists.txt b/src/Core/CMakeLists.txt index d2edac23..ff03500d 100644 --- a/src/Core/CMakeLists.txt +++ b/src/Core/CMakeLists.txt @@ -3,8 +3,8 @@ cmake_minimum_required(VERSION 3.12) project(pwe_core CXX C) find_package(tinyxml2 CONFIG REQUIRED) -find_package(nod CONFIG REQUIRED) find_package(logvisor CONFIG REQUIRED) +find_package(nod CONFIG REQUIRED) find_package(lzokay CONFIG REQUIRED) find_package(OpenGL REQUIRED) find_package(assimp CONFIG REQUIRED) diff --git a/src/Core/GameProject/CGameExporter.cpp b/src/Core/GameProject/CGameExporter.cpp index ddb86a84..ae88e31f 100644 --- a/src/Core/GameProject/CGameExporter.cpp +++ b/src/Core/GameProject/CGameExporter.cpp @@ -12,6 +12,7 @@ #include #include +#include #include #define LOAD_PAKS 1 diff --git a/src/Core/GameProject/CGameExporter.h b/src/Core/GameProject/CGameExporter.h index 442bf2bb..860ef6b9 100644 --- a/src/Core/GameProject/CGameExporter.h +++ b/src/Core/GameProject/CGameExporter.h @@ -9,7 +9,7 @@ #include #include #include -#include +#include enum class EDiscType { diff --git a/src/Core/GameProject/CGameProject.cpp b/src/Core/GameProject/CGameProject.cpp index 5aa4f013..fc395fb8 100644 --- a/src/Core/GameProject/CGameProject.cpp +++ b/src/Core/GameProject/CGameProject.cpp @@ -3,7 +3,8 @@ #include "IUIRelay.h" #include "Core/Resource/Script/CGameTemplate.h" #include -#include +#include +#include #if NOD_UCS2 #define TStringToNodString(string) ToWChar(string) diff --git a/src/Core/Resource/Model/CStaticModel.cpp b/src/Core/Resource/Model/CStaticModel.cpp index 15052174..e5c4ccc1 100644 --- a/src/Core/Resource/Model/CStaticModel.cpp +++ b/src/Core/Resource/Model/CStaticModel.cpp @@ -109,19 +109,34 @@ void CStaticModel::Draw(FRenderOptions Options) { if (!mBuffered) BufferGL(); - if ((Options & ERenderOption::NoMaterialSetup) == 0) mpMaterial->SetCurrent(Options); - - // Draw IBOs mVBO.Bind(); glLineWidth(1.f); - for (uint32 iIBO = 0; iIBO < mIBOs.size(); iIBO++) + auto DoDraw = [this]() { - CIndexBuffer *pIBO = &mIBOs[iIBO]; - pIBO->Bind(); - glDrawElements(pIBO->GetPrimitiveType(), pIBO->GetSize(), GL_UNSIGNED_SHORT, (void*) 0); - pIBO->Unbind(); - gDrawCount++; + // Draw IBOs + for (uint32 iIBO = 0; iIBO < mIBOs.size(); iIBO++) + { + CIndexBuffer *pIBO = &mIBOs[iIBO]; + pIBO->Bind(); + glDrawElements(pIBO->GetPrimitiveType(), pIBO->GetSize(), GL_UNSIGNED_SHORT, (void*) 0); + pIBO->Unbind(); + gDrawCount++; + } + }; + + // Bind material + if ((Options & ERenderOption::NoMaterialSetup) == 0) + { + for (CMaterial* passMat = mpMaterial; passMat; passMat = passMat->GetNextDrawPass()) + { + passMat->SetCurrent(Options); + DoDraw(); + } + } + else + { + DoDraw(); } mVBO.Unbind(); @@ -133,20 +148,36 @@ void CStaticModel::DrawSurface(FRenderOptions Options, uint32 Surface) mVBO.Bind(); glLineWidth(1.f); - if ((Options & ERenderOption::NoMaterialSetup) == 0) mpMaterial->SetCurrent(Options); - for (uint32 iIBO = 0; iIBO < mIBOs.size(); iIBO++) + auto DoDraw = [this, Surface]() { - // Since there is a shared IBO for every mesh, we need two things to draw a single one: an offset and a size - uint32 Offset = 0; - if (Surface > 0) Offset = mSurfaceEndOffsets[iIBO][Surface - 1]; - uint32 Size = mSurfaceEndOffsets[iIBO][Surface] - Offset; + for (uint32 iIBO = 0; iIBO < mIBOs.size(); iIBO++) + { + // Since there is a shared IBO for every mesh, we need two things to draw a single one: an offset and a size + uint32 Offset = 0; + if (Surface > 0) Offset = mSurfaceEndOffsets[iIBO][Surface - 1]; + uint32 Size = mSurfaceEndOffsets[iIBO][Surface] - Offset; - if (!Size) continue; // The chosen submesh doesn't use this IBO + if (!Size) continue; // The chosen submesh doesn't use this IBO - // Now we have both, so we can draw - mIBOs[iIBO].DrawElements(Offset, Size); - gDrawCount++; + // Now we have both, so we can draw + mIBOs[iIBO].DrawElements(Offset, Size); + gDrawCount++; + } + }; + + // Bind material + if ((Options & ERenderOption::NoMaterialSetup) == 0) + { + for (CMaterial* passMat = mpMaterial; passMat; passMat = passMat->GetNextDrawPass()) + { + passMat->SetCurrent(Options); + DoDraw(); + } + } + else + { + DoDraw(); } mVBO.Unbind(); diff --git a/src/Core/Scene/CStaticNode.cpp b/src/Core/Scene/CStaticNode.cpp index 26fe307a..f43922c5 100644 --- a/src/Core/Scene/CStaticNode.cpp +++ b/src/Core/Scene/CStaticNode.cpp @@ -63,6 +63,7 @@ void CStaticNode::Draw(FRenderOptions Options, int ComponentIndex, ERenderComman { CGraphics::sNumLights = 0; CGraphics::sVertexBlock.COLOR0_Amb = UseWhiteAmbient ? CColor::skTransparentWhite : CColor::skTransparentBlack; + CGraphics::sVertexBlock.COLOR0_Mat = CColor::skBlack; CGraphics::sPixelBlock.LightmapMultiplier = 1.0f; CGraphics::UpdateLightBlock(); } @@ -72,10 +73,9 @@ void CStaticNode::Draw(FRenderOptions Options, int ComponentIndex, ERenderComman LoadLights(rkViewInfo); if (CGraphics::sLightMode == CGraphics::ELightingMode::None || UseWhiteAmbient) CGraphics::sVertexBlock.COLOR0_Amb = CColor::skTransparentWhite; + CGraphics::sVertexBlock.COLOR0_Mat = CColor::skWhite; } - CGraphics::sVertexBlock.COLOR0_Mat = CColor::skBlack; - float Mul = CGraphics::sWorldLightMultiplier; CGraphics::sPixelBlock.SetAllTevColors(CColor(Mul,Mul,Mul)); CGraphics::sPixelBlock.TintColor = TintColor(rkViewInfo); diff --git a/src/Editor/CollisionEditor/CCollisionEditorViewport.cpp b/src/Editor/CollisionEditor/CCollisionEditorViewport.cpp index 1635a0fb..6920f6ad 100644 --- a/src/Editor/CollisionEditor/CCollisionEditorViewport.cpp +++ b/src/Editor/CollisionEditor/CCollisionEditorViewport.cpp @@ -37,5 +37,6 @@ void CCollisionEditorViewport::Paint() void CCollisionEditorViewport::OnResize() { - mpRenderer->SetViewportSize(width(), height()); + qreal pixelRatio = devicePixelRatioF(); + mpRenderer->SetViewportSize(width() * pixelRatio, height() * pixelRatio); } diff --git a/src/Editor/ModelEditor/CModelEditorViewport.cpp b/src/Editor/ModelEditor/CModelEditorViewport.cpp index f494ad62..d14abbb2 100644 --- a/src/Editor/ModelEditor/CModelEditorViewport.cpp +++ b/src/Editor/ModelEditor/CModelEditorViewport.cpp @@ -81,9 +81,12 @@ void CModelEditorViewport::Paint() CGraphics::UpdateMVPBlock(); CGraphics::SetDefaultLighting(); CGraphics::UpdateLightBlock(); // Note: vertex block is updated by the material - mpActiveMaterial->SetCurrent(ERenderOption::EnableUVScroll | ERenderOption::EnableBackfaceCull | ERenderOption::EnableOccluders); - CDrawUtil::DrawSphere(true); + for (CMaterial* passMat = mpActiveMaterial; passMat; passMat = passMat->GetNextDrawPass()) + { + passMat->SetCurrent(ERenderOption::EnableUVScroll | ERenderOption::EnableBackfaceCull | ERenderOption::EnableOccluders); + CDrawUtil::DrawSphere(true); + } } else if (mMode == EDrawMode::DrawSquare) @@ -100,9 +103,12 @@ void CModelEditorViewport::Paint() CGraphics::sMVPBlock.ProjectionMatrix = CMatrix4f::skIdentity; CGraphics::UpdateMVPBlock(); - mpActiveMaterial->SetCurrent(ERenderOption::EnableUVScroll | ERenderOption::EnableOccluders); - float Aspect = (float) width() / (float) height(); - CDrawUtil::DrawSquare(CVector2f(0,1), CVector2f(1 * Aspect, 1), CVector2f(1 * Aspect, 0), CVector2f(0,0)); + for (CMaterial* passMat = mpActiveMaterial; passMat; passMat = passMat->GetNextDrawPass()) + { + passMat->SetCurrent(ERenderOption::EnableUVScroll | ERenderOption::EnableOccluders); + float Aspect = (float) width() / (float) height(); + CDrawUtil::DrawSquare(CVector2f(0,1), CVector2f(1 * Aspect, 1), CVector2f(1 * Aspect, 0), CVector2f(0,0)); + } } mpRenderer->EndFrame();