Update dew, fix no lighting mode

This commit is contained in:
Jack Andersen 2019-11-24 16:46:57 -10:00
parent 875c0fb9fd
commit 30c1646f02
11 changed files with 80 additions and 32 deletions

View File

@ -5,10 +5,11 @@ set(MACOSX_DEPLOYMENT_TARGET 10.10)
if(NOT CMAKE_BUILD_TYPE) if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release) set(CMAKE_BUILD_TYPE Release)
endif() endif()
set(CMAKE_CONFIGURATION_TYPES ${CMAKE_BUILD_TYPE})
project(PrimeWorldEditor CXX) 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) if (PWE_PUBLIC_RELEASE)
add_compile_definitions(PUBLIC_RELEASE=1) add_compile_definitions(PUBLIC_RELEASE=1)
message(STATUS "Enabled public release mode") message(STATUS "Enabled public release mode")

View File

@ -17,6 +17,13 @@ function(integrate_dew)
return() return()
endif() 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 # Acquaint CMake with dew prefix
# #

View File

@ -28,7 +28,7 @@
"url": "https://github.com/AxioDL/nod", "url": "https://github.com/AxioDL/nod",
"type": "git", "type": "git",
"head": "master", "head": "master",
"ref": "a1284ae06586b958f36b8ecaba29390835ed2820" "ref": "f147e1235646b849f78a8574a6d554214b70792d"
}, },
{ {
"name": "lzokay", "name": "lzokay",

View File

@ -3,8 +3,8 @@ cmake_minimum_required(VERSION 3.12)
project(pwe_core CXX C) project(pwe_core CXX C)
find_package(tinyxml2 CONFIG REQUIRED) find_package(tinyxml2 CONFIG REQUIRED)
find_package(nod CONFIG REQUIRED)
find_package(logvisor CONFIG REQUIRED) find_package(logvisor CONFIG REQUIRED)
find_package(nod CONFIG REQUIRED)
find_package(lzokay CONFIG REQUIRED) find_package(lzokay CONFIG REQUIRED)
find_package(OpenGL REQUIRED) find_package(OpenGL REQUIRED)
find_package(assimp CONFIG REQUIRED) find_package(assimp CONFIG REQUIRED)

View File

@ -12,6 +12,7 @@
#include <Common/Serialization/CXMLWriter.h> #include <Common/Serialization/CXMLWriter.h>
#include <nod/nod.hpp> #include <nod/nod.hpp>
#include <nod/DiscBase.hpp>
#include <tinyxml2.h> #include <tinyxml2.h>
#define LOAD_PAKS 1 #define LOAD_PAKS 1

View File

@ -9,7 +9,7 @@
#include <Common/Flags.h> #include <Common/Flags.h>
#include <Common/TString.h> #include <Common/TString.h>
#include <map> #include <map>
#include <nod/nod.hpp> #include <nod/DiscBase.hpp>
enum class EDiscType enum class EDiscType
{ {

View File

@ -3,7 +3,8 @@
#include "IUIRelay.h" #include "IUIRelay.h"
#include "Core/Resource/Script/CGameTemplate.h" #include "Core/Resource/Script/CGameTemplate.h"
#include <Common/Serialization/XML.h> #include <Common/Serialization/XML.h>
#include <nod/nod.hpp> #include <nod/DiscGCN.hpp>
#include <nod/DiscWii.hpp>
#if NOD_UCS2 #if NOD_UCS2
#define TStringToNodString(string) ToWChar(string) #define TStringToNodString(string) ToWChar(string)

View File

@ -109,19 +109,34 @@ void CStaticModel::Draw(FRenderOptions Options)
{ {
if (!mBuffered) BufferGL(); if (!mBuffered) BufferGL();
if ((Options & ERenderOption::NoMaterialSetup) == 0) mpMaterial->SetCurrent(Options);
// Draw IBOs
mVBO.Bind(); mVBO.Bind();
glLineWidth(1.f); glLineWidth(1.f);
for (uint32 iIBO = 0; iIBO < mIBOs.size(); iIBO++) auto DoDraw = [this]()
{ {
CIndexBuffer *pIBO = &mIBOs[iIBO]; // Draw IBOs
pIBO->Bind(); for (uint32 iIBO = 0; iIBO < mIBOs.size(); iIBO++)
glDrawElements(pIBO->GetPrimitiveType(), pIBO->GetSize(), GL_UNSIGNED_SHORT, (void*) 0); {
pIBO->Unbind(); CIndexBuffer *pIBO = &mIBOs[iIBO];
gDrawCount++; 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(); mVBO.Unbind();
@ -133,20 +148,36 @@ void CStaticModel::DrawSurface(FRenderOptions Options, uint32 Surface)
mVBO.Bind(); mVBO.Bind();
glLineWidth(1.f); 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 for (uint32 iIBO = 0; iIBO < mIBOs.size(); iIBO++)
uint32 Offset = 0; {
if (Surface > 0) Offset = mSurfaceEndOffsets[iIBO][Surface - 1]; // Since there is a shared IBO for every mesh, we need two things to draw a single one: an offset and a size
uint32 Size = mSurfaceEndOffsets[iIBO][Surface] - Offset; 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 // Now we have both, so we can draw
mIBOs[iIBO].DrawElements(Offset, Size); mIBOs[iIBO].DrawElements(Offset, Size);
gDrawCount++; gDrawCount++;
}
};
// Bind material
if ((Options & ERenderOption::NoMaterialSetup) == 0)
{
for (CMaterial* passMat = mpMaterial; passMat; passMat = passMat->GetNextDrawPass())
{
passMat->SetCurrent(Options);
DoDraw();
}
}
else
{
DoDraw();
} }
mVBO.Unbind(); mVBO.Unbind();

View File

@ -63,6 +63,7 @@ void CStaticNode::Draw(FRenderOptions Options, int ComponentIndex, ERenderComman
{ {
CGraphics::sNumLights = 0; CGraphics::sNumLights = 0;
CGraphics::sVertexBlock.COLOR0_Amb = UseWhiteAmbient ? CColor::skTransparentWhite : CColor::skTransparentBlack; CGraphics::sVertexBlock.COLOR0_Amb = UseWhiteAmbient ? CColor::skTransparentWhite : CColor::skTransparentBlack;
CGraphics::sVertexBlock.COLOR0_Mat = CColor::skBlack;
CGraphics::sPixelBlock.LightmapMultiplier = 1.0f; CGraphics::sPixelBlock.LightmapMultiplier = 1.0f;
CGraphics::UpdateLightBlock(); CGraphics::UpdateLightBlock();
} }
@ -72,10 +73,9 @@ void CStaticNode::Draw(FRenderOptions Options, int ComponentIndex, ERenderComman
LoadLights(rkViewInfo); LoadLights(rkViewInfo);
if (CGraphics::sLightMode == CGraphics::ELightingMode::None || UseWhiteAmbient) if (CGraphics::sLightMode == CGraphics::ELightingMode::None || UseWhiteAmbient)
CGraphics::sVertexBlock.COLOR0_Amb = CColor::skTransparentWhite; CGraphics::sVertexBlock.COLOR0_Amb = CColor::skTransparentWhite;
CGraphics::sVertexBlock.COLOR0_Mat = CColor::skWhite;
} }
CGraphics::sVertexBlock.COLOR0_Mat = CColor::skBlack;
float Mul = CGraphics::sWorldLightMultiplier; float Mul = CGraphics::sWorldLightMultiplier;
CGraphics::sPixelBlock.SetAllTevColors(CColor(Mul,Mul,Mul)); CGraphics::sPixelBlock.SetAllTevColors(CColor(Mul,Mul,Mul));
CGraphics::sPixelBlock.TintColor = TintColor(rkViewInfo); CGraphics::sPixelBlock.TintColor = TintColor(rkViewInfo);

View File

@ -37,5 +37,6 @@ void CCollisionEditorViewport::Paint()
void CCollisionEditorViewport::OnResize() void CCollisionEditorViewport::OnResize()
{ {
mpRenderer->SetViewportSize(width(), height()); qreal pixelRatio = devicePixelRatioF();
mpRenderer->SetViewportSize(width() * pixelRatio, height() * pixelRatio);
} }

View File

@ -81,9 +81,12 @@ void CModelEditorViewport::Paint()
CGraphics::UpdateMVPBlock(); CGraphics::UpdateMVPBlock();
CGraphics::SetDefaultLighting(); CGraphics::SetDefaultLighting();
CGraphics::UpdateLightBlock(); // Note: vertex block is updated by the material 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) else if (mMode == EDrawMode::DrawSquare)
@ -100,9 +103,12 @@ void CModelEditorViewport::Paint()
CGraphics::sMVPBlock.ProjectionMatrix = CMatrix4f::skIdentity; CGraphics::sMVPBlock.ProjectionMatrix = CMatrix4f::skIdentity;
CGraphics::UpdateMVPBlock(); CGraphics::UpdateMVPBlock();
mpActiveMaterial->SetCurrent(ERenderOption::EnableUVScroll | ERenderOption::EnableOccluders); for (CMaterial* passMat = mpActiveMaterial; passMat; passMat = passMat->GetNextDrawPass())
float Aspect = (float) width() / (float) height(); {
CDrawUtil::DrawSquare(CVector2f(0,1), CVector2f(1 * Aspect, 1), CVector2f(1 * Aspect, 0), CVector2f(0,0)); 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(); mpRenderer->EndFrame();