add new additional noggit data/definitions folder containing extra data not contained in the client
This commit is contained in:
27
src/math/trig.cpp
Normal file
27
src/math/trig.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
// This file is part of Noggit3, licensed under GNU General Public License (version 3).
|
||||
|
||||
#include <math/trig.hpp>
|
||||
#include <glm/vec2.hpp>
|
||||
#include <vector>
|
||||
|
||||
bool math::is_inside_of_polygon(const glm::vec2& pos, const std::vector<glm::vec2>& polygon) {
|
||||
int n = polygon.size();
|
||||
bool inside = false;
|
||||
|
||||
for (int i = 0; i < n; ++i)
|
||||
{
|
||||
glm::vec2 v1 = polygon[i];
|
||||
glm::vec2 v2 = polygon[(i + 1) % n];
|
||||
|
||||
if ((v1.y > pos.y) != (v2.y > pos.y))
|
||||
{
|
||||
float intersectX = (pos.y - v1.y) * (v2.x - v1.x) / (v2.y - v1.y) + v1.x;
|
||||
if (pos.x < intersectX)
|
||||
{
|
||||
inside = !inside;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return inside;
|
||||
}
|
||||
@@ -15,10 +15,10 @@ namespace Noggit::Application {
|
||||
|
||||
struct NoggitApplicationGraphicsConfiguration
|
||||
{
|
||||
QSurfaceFormat::SwapBehavior SwapChainDepth;
|
||||
char SwapChainInternal;
|
||||
char DepthBufferSize;
|
||||
char SamplesCount;
|
||||
QSurfaceFormat::SwapBehavior SwapChainDepth = QSurfaceFormat::TripleBuffer; // DefaultSwapBehavior = 0, SingleBuffer = 1, DoubleBuffer = 2, TripleBuffer = 3
|
||||
char SwapChainInternal = 0; // 0 = no vsync, 1 = vsync, waits for one refresh cycle before swapping buffers. 2+ wait for more cycles.
|
||||
char DepthBufferSize = 24;
|
||||
char SamplesCount = 0; // No MultiSamplingAA(MSAA) = 0, Low = 2, Medium = 4, High = 8, VeryHigh = 16
|
||||
};
|
||||
|
||||
struct NoggitApplicationConfiguration
|
||||
@@ -27,6 +27,7 @@ namespace Noggit::Application {
|
||||
std::string ApplicationThemePath;
|
||||
std::string ApplicationListFilePath;
|
||||
std::string ApplicationDatabaseDefinitionsPath;
|
||||
std::string ApplicationNoggitDefinitionsPath = "noggit-definitions"; // default for compatibility with older config files
|
||||
NoggitApplicationGraphicsConfiguration GraphicsConfiguration;
|
||||
NoggitApplicationLoggingConfiguration LoggingConfiguration;
|
||||
};
|
||||
|
||||
@@ -21,6 +21,12 @@ namespace Noggit::Application {
|
||||
noggitApplicationConfiguration.ApplicationThemePath = noggitConfiguration["ApplicationThemePath"].toString().toStdString();
|
||||
if (noggitConfiguration.contains("ApplicationDatabaseDefinitionsPath"))
|
||||
noggitApplicationConfiguration.ApplicationDatabaseDefinitionsPath = noggitConfiguration["ApplicationDatabaseDefinitionsPath"].toString().toStdString();
|
||||
if (noggitConfiguration.contains("ApplicationNoggitDefinitionsPath"))
|
||||
{
|
||||
noggitApplicationConfiguration.ApplicationNoggitDefinitionsPath = noggitConfiguration["ApplicationNoggitDefinitionsPath"].toString().toStdString();
|
||||
}
|
||||
else
|
||||
|
||||
if (noggitConfiguration.contains("ApplicationListFilePath"))
|
||||
noggitApplicationConfiguration.ApplicationListFilePath = noggitConfiguration["ApplicationListFilePath"].toString().toStdString();
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ namespace Noggit::Application {
|
||||
noggitApplicationConfiguration.ApplicationProjectPath = std::string("projects");
|
||||
noggitApplicationConfiguration.ApplicationThemePath = std::string("themes");
|
||||
noggitApplicationConfiguration.ApplicationDatabaseDefinitionsPath = std::string("definitions");
|
||||
noggitApplicationConfiguration.ApplicationNoggitDefinitionsPath = std::string("noggit-definitions");
|
||||
noggitApplicationConfiguration.ApplicationListFilePath = std::string("listfile.csv");
|
||||
|
||||
noggitApplicationConfiguration.GraphicsConfiguration = NoggitApplicationGraphicsConfiguration();
|
||||
@@ -56,6 +57,7 @@ namespace Noggit::Application {
|
||||
rootConfiguration.insert("ApplicationProjectPath", configuration.ApplicationProjectPath.c_str());
|
||||
rootConfiguration.insert("ApplicationThemePath", configuration.ApplicationThemePath.c_str());
|
||||
rootConfiguration.insert("ApplicationDatabaseDefinitionsPath", configuration.ApplicationDatabaseDefinitionsPath.c_str());
|
||||
rootConfiguration.insert("ApplicationNoggitDefinitionsPath", configuration.ApplicationNoggitDefinitionsPath.c_str());
|
||||
rootConfiguration.insert("ApplicationListFilePath", configuration.ApplicationListFilePath.c_str());
|
||||
rootConfiguration.insert("GraphicsConfiguration", graphicsConfiguration);
|
||||
rootConfiguration.insert("LoggingConfiguration", loggingConfiguration);
|
||||
|
||||
@@ -90,11 +90,11 @@ namespace Noggit::Application
|
||||
auto noggitProjectPath = applicationConfiguration.ApplicationProjectPath;
|
||||
if (!std::filesystem::exists(noggitProjectPath))
|
||||
{
|
||||
std::filesystem::create_directory(noggitProjectPath);
|
||||
// std::filesystem::create_directory(noggitProjectPath);
|
||||
// Log << "Noggit Project Folder Not Loaded! Creating..." << std::endl;
|
||||
}
|
||||
|
||||
auto listFilePath = applicationConfiguration.ApplicationListFilePath;
|
||||
auto& listFilePath = applicationConfiguration.ApplicationListFilePath;
|
||||
if (!std::filesystem::exists(listFilePath))
|
||||
{
|
||||
// LogError << "Unable to find listfile! please reinstall Noggit Red, or download from wow.tools" << std::endl;
|
||||
@@ -102,13 +102,21 @@ namespace Noggit::Application
|
||||
|
||||
Log << "Listfile found! : " << listFilePath << std::endl;
|
||||
|
||||
auto databaseDefinitionPath = applicationConfiguration.ApplicationDatabaseDefinitionsPath;
|
||||
auto& databaseDefinitionPath = applicationConfiguration.ApplicationDatabaseDefinitionsPath;
|
||||
if (!std::filesystem::exists(databaseDefinitionPath))
|
||||
{
|
||||
LogError << "Unable to find database definitions! please reinstall Noggit Red, or download from wow.tools" << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log << "Database Definitions found! : " << databaseDefinitionPath << std::endl;
|
||||
}
|
||||
|
||||
Log << "Database Definitions found! : " << databaseDefinitionPath << std::endl;
|
||||
auto& noggitDefinitionPath = applicationConfiguration.ApplicationNoggitDefinitionsPath;
|
||||
if (!std::filesystem::exists(noggitDefinitionPath))
|
||||
{
|
||||
LogError << "Unable to find noggit definitions! " << noggitDefinitionPath << std::endl;
|
||||
}
|
||||
|
||||
// Check MSVC redistribuable version
|
||||
const QString registryPath = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\";
|
||||
@@ -125,7 +133,7 @@ namespace Noggit::Application
|
||||
};
|
||||
|
||||
// confirmed crashes with v14.30.30704.00 and v14.36.32532.00
|
||||
const int required_version = 37;
|
||||
const int required_version = 38;
|
||||
|
||||
bool redist_found = false;
|
||||
foreach (const QString & version, versions) {
|
||||
@@ -182,11 +190,13 @@ namespace Noggit::Application
|
||||
QSettings app_settings;
|
||||
bool vsync = app_settings.value("vsync", false).toBool();
|
||||
format.setSwapInterval(vsync ? 1 : applicationConfiguration.GraphicsConfiguration.SwapChainInternal);
|
||||
if (applicationConfiguration.GraphicsConfiguration.SwapChainInternal > 1)
|
||||
LogDebug << "WARNING : SwapChainInternal setting is set to more than 1, this will significantly slow down rendering." << std::endl;
|
||||
// TODO. old config files used 16 so just ignore them, could implement a version check of the config file to update it
|
||||
format.setDepthBufferSize(24); // applicationConfiguration.GraphicsConfiguration.DepthBufferSize
|
||||
auto deflt = format.depthBufferSize();
|
||||
bool doAntiAliasing = app_settings.value("anti_aliasing", false).toBool();
|
||||
format.setSamples(doAntiAliasing ? 4 : applicationConfiguration.GraphicsConfiguration.SamplesCount); // default is 0, no AA
|
||||
// Multisample anti-aliasing (MSAA). 0x, 2x, 4x, 8x or 16x. Default is 0, no AA
|
||||
format.setSamples(doAntiAliasing ? 4 : applicationConfiguration.GraphicsConfiguration.SamplesCount);
|
||||
|
||||
// context creation seems to get stuck sometimes, this ensure the app is killed
|
||||
// otherwise it's wasting cpu resources and is annoying when developping
|
||||
|
||||
Reference in New Issue
Block a user