Merge remote-tracking branch 'origin/master' into navigation-features

# Conflicts:
#	Source/Editor/Content/Settings/NavigationSettings.cs
#	Source/Engine/Engine/PhysicalMaterial.cs
#	Source/Tools/Flax.Build/Bindings/BindingsGenerator.Api.cs
This commit is contained in:
Wojtek Figat
2021-01-04 14:31:56 +01:00
2425 changed files with 4606 additions and 30937 deletions

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#if PLATFORM_ANDROID
@@ -746,15 +746,15 @@ uint64 AndroidPlatform::GetTimeCycles()
void AndroidPlatform::GetSystemTime(int32& year, int32& month, int32& dayOfWeek, int32& day, int32& hour, int32& minute, int32& second, int32& millisecond)
{
// Query for calendar time
// Get the calendar time
struct timeval time;
gettimeofday(&time, nullptr);
// Convert to local time
// Convert calendar time to local time
struct tm localTime;
localtime_r(&time.tv_sec, &localTime);
// Extract time
// Extract time from Unix date
year = localTime.tm_year + 1900;
month = localTime.tm_mon + 1;
dayOfWeek = localTime.tm_wday;
@@ -767,7 +767,7 @@ void AndroidPlatform::GetSystemTime(int32& year, int32& month, int32& dayOfWeek,
void AndroidPlatform::GetUTCTime(int32& year, int32& month, int32& dayOfWeek, int32& day, int32& hour, int32& minute, int32& second, int32& millisecond)
{
// Query for calendar time
// Get the calendar time
struct timeval time;
gettimeofday(&time, nullptr);
@@ -803,11 +803,11 @@ bool AndroidPlatform::Init()
}
// Set info about the CPU
cpu_set_t availableCpusMask;
CPU_ZERO(&availableCpusMask);
if (sched_getaffinity(0, sizeof(availableCpusMask), &availableCpusMask) == 0)
cpu_set_t cpus;
CPU_ZERO(&cpus);
if (sched_getaffinity(0, sizeof(cpus), &cpus) == 0)
{
AndroidCpu.ProcessorCoreCount = AndroidCpu.LogicalProcessorCount = CPU_COUNT(&availableCpusMask);
AndroidCpu.ProcessorCoreCount = AndroidCpu.LogicalProcessorCount = CPU_COUNT(&cpus);
}
else
{

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#if PLATFORM_ANDROID

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#include "Engine/Platform/File.h"
#include "Engine/Core/Math/Math.h"

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#include "Engine/Platform/FileSystem.h"
#include "Engine/Platform/File.h"

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#include "Engine/Platform/Platform.h"
#include "Engine/Platform/CPUInfo.h"

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
namespace FlaxEngine
{

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#include "Engine/Platform/StringUtils.h"
#include "Engine/Platform/FileSystem.h"
@@ -18,77 +18,49 @@ const char VolumeSeparatorChar = ':';
const Char* StringUtils::FindIgnoreCase(const Char* str, const Char* toFind)
{
// Validate input
if (toFind == nullptr || str == nullptr)
{
return nullptr;
}
// Get upper-case first letter of the find string (to reduce the number of full strnicmps)
Char findInitial = ToUpper(*toFind);
// Get length of find string, and increment past first letter
int32 length = Length(toFind++) - 1;
// Get the first letter of the search string, and increment past it
Char strChar = *str++;
// While we aren't at end of string
while (strChar)
const Char findInitial = ToUpper(*toFind);
const int32 length = Length(toFind++) - 1;
Char c = *str++;
while (c)
{
// Make sure it's upper-case
strChar = ToUpper(strChar);
// If it matches the first letter of the find string, do a case-insensitive string compare for the length of the find string
if (strChar == findInitial && !CompareIgnoreCase(str, toFind, length))
c = ToUpper(c);
if (c == findInitial && !CompareIgnoreCase(str, toFind, length))
{
// If we found the string, then return a pointer to the beginning of it in the search string
return str - 1;
}
// Go to next letter
strChar = *str++;
c = *str++;
}
// Nothing found
return nullptr;
}
const char* StringUtils::FindIgnoreCase(const char* str, const char* toFind)
{
// Validate input
if (toFind == nullptr || str == nullptr)
{
return nullptr;
}
// Get upper-case first letter of the find string (to reduce the number of full strnicmps)
char findInitial = (char)ToUpper(*toFind);
// Get length of find string, and increment past first letter
int32 length = Length(toFind++) - 1;
// Get the first letter of the search string, and increment past it
char strChar = *str++;
// While we aren't at end of string
while (strChar)
const char findInitial = (char)ToUpper(*toFind);
const int32 length = Length(toFind++) - 1;
char c = *str++;
while (c)
{
// Make sure it's upper-case
strChar = (char)ToUpper(strChar);
// If it matches the first letter of the find string, do a case-insensitive string compare for the length of the find string
if (strChar == findInitial && !CompareIgnoreCase(str, toFind, length))
c = (char)ToUpper(c);
if (c == findInitial && !CompareIgnoreCase(str, toFind, length))
{
// If we found the string, then return a pointer to the beginning of it in the search string
return str - 1;
}
// Go to next letter
strChar = *str++;
c = *str++;
}
// Nothing found
return nullptr;
}

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#include "Engine/Platform/Thread.h"
#include "Engine/Threading/IRunnable.h"

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#include "Engine/Platform/Window.h"
#include "Engine/Engine/Engine.h"

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#include "../WindowsManager.h"
#include "Engine/Engine/Time.h"

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
namespace FlaxEngine
{

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once

View File

@@ -229,7 +229,7 @@ uint64 LinuxFileSystem::GetFileSize(const StringView& path)
const StringAsANSI<> pathANSI(*path, path.Length());
if (stat(pathANSI.Get(), &fileInfo) != -1)
{
// make sure to return -1 for directories
// Check for directories
if (S_ISDIR(fileInfo.st_mode))
{
fileInfo.st_size = -1;

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#if PLATFORM_LINUX

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#if PLATFORM_LINUX
@@ -1277,7 +1277,7 @@ void LinuxPlatform::GetSystemTime(int32& year, int32& month, int32& dayOfWeek, i
void LinuxPlatform::GetUTCTime(int32& year, int32& month, int32& dayOfWeek, int32& day, int32& hour, int32& minute, int32& second, int32& millisecond)
{
// Query for calendar time
// Get the calendar time
struct timeval time;
gettimeofday(&time, nullptr);
@@ -1315,34 +1315,33 @@ bool LinuxPlatform::Init()
}
// Set info about the CPU
cpu_set_t availableCpusMask;
CPU_ZERO(&availableCpusMask);
if (sched_getaffinity(0, sizeof(availableCpusMask), &availableCpusMask) == 0)
cpu_set_t cpus;
CPU_ZERO(&cpus);
if (sched_getaffinity(0, sizeof(cpus), &cpus) == 0)
{
int32 numberOfCores = 0;
struct CpuInfo
{
int Core;
int Package;
} cpuInfos[CPU_SETSIZE];
Platform::MemoryClear(cpuInfos, sizeof(cpuInfos));
int maxCoreId = 0;
int maxPackageId = 0;
int numCpusAvailable = 0;
int32 Core;
int32 Package;
} cpusInfo[CPU_SETSIZE];
Platform::MemoryClear(cpusInfo, sizeof(cpusInfo));
int32 maxCoreId = 0;
int32 maxPackageId = 0;
int32 cpuCountAvailable = 0;
for (int32 cpuIdx = 0; cpuIdx < CPU_SETSIZE; cpuIdx++)
{
if (CPU_ISSET(cpuIdx, &availableCpusMask))
if (CPU_ISSET(cpuIdx, &cpus))
{
numCpusAvailable++;
cpuCountAvailable++;
sprintf(fileNameBuffer, "/sys/devices/system/cpu/cpu%d/topology/core_id", cpuIdx);
if (FILE* coreIdFile = fopen(fileNameBuffer, "r"))
{
if (fscanf(coreIdFile, "%d", &cpuInfos[cpuIdx].Core) != 1)
if (fscanf(coreIdFile, "%d", &cpusInfo[cpuIdx].Core) != 1)
{
cpuInfos[cpuIdx].Core = 0;
cpusInfo[cpuIdx].Core = 0;
}
fclose(coreIdFile);
}
@@ -1350,44 +1349,40 @@ bool LinuxPlatform::Init()
sprintf(fileNameBuffer, "/sys/devices/system/cpu/cpu%d/topology/physical_package_id", cpuIdx);
if (FILE* packageIdFile = fopen(fileNameBuffer, "r"))
{
// physical_package_id can be -1 on embedded devices - treat all CPUs as separate in that case.
if (fscanf(packageIdFile, "%d", &cpuInfos[cpuIdx].Package) != 1 || cpuInfos[cpuIdx].Package < 0)
if (fscanf(packageIdFile, "%d", &cpusInfo[cpuIdx].Package) != 1 || cpusInfo[cpuIdx].Package < 0)
{
cpuInfos[cpuIdx].Package = cpuInfos[cpuIdx].Core;
cpusInfo[cpuIdx].Package = cpusInfo[cpuIdx].Core;
}
fclose(packageIdFile);
}
maxCoreId = Math::Max(maxCoreId, cpuInfos[cpuIdx].Core);
maxPackageId = Math::Max(maxPackageId, cpuInfos[cpuIdx].Package);
maxCoreId = Math::Max(maxCoreId, cpusInfo[cpuIdx].Core);
maxPackageId = Math::Max(maxPackageId, cpusInfo[cpuIdx].Package);
}
}
int numCores = maxCoreId + 1;
int numPackages = maxPackageId + 1;
int numPairs = numPackages * numCores;
int32 coresCount = maxCoreId + 1;
int32 packagesCount = maxPackageId + 1;
int32 pairsCount = packagesCount * coresCount;
// AArch64 topology seems to be incompatible with the above assumptions, particularly, core_id can be all 0 while the cores themselves are obviously independent.
// Check if num CPUs available to us is more than 2 per core (i.e. more than reasonable when hyperthreading is involved), and if so, don't trust the topology.
if (numCores * 2 < numCpusAvailable)
if (coresCount * 2 < cpuCountAvailable)
{
// Consider all CPUs to be separate
numberOfCores = numCpusAvailable;
numberOfCores = cpuCountAvailable;
}
else
{
byte* pairs = (byte*)Allocator::Allocate(numPairs);
Platform::MemoryClear(pairs, numPairs * sizeof(unsigned char));
byte* pairs = (byte*)Allocator::Allocate(pairsCount);
Platform::MemoryClear(pairs, pairsCount * sizeof(unsigned char));
for (int32 cpuIdx = 0; cpuIdx < CPU_SETSIZE; cpuIdx++)
{
if (CPU_ISSET(cpuIdx, &availableCpusMask))
if (CPU_ISSET(cpuIdx, &cpus))
{
pairs[cpuInfos[cpuIdx].Package * numCores + cpuInfos[cpuIdx].Core] = 1;
pairs[cpusInfo[cpuIdx].Package * coresCount + cpusInfo[cpuIdx].Core] = 1;
}
}
for (int32 i = 0; i < numPairs; i++)
for (int32 i = 0; i < pairsCount; i++)
{
numberOfCores += pairs[i];
}
@@ -1395,9 +1390,9 @@ bool LinuxPlatform::Init()
Allocator::Free(pairs);
}
UnixCpu.ProcessorPackageCount = numPackages;
UnixCpu.ProcessorPackageCount = packagesCount;
UnixCpu.ProcessorCoreCount = Math::Max(numberOfCores, 1);
UnixCpu.LogicalProcessorCount = CPU_COUNT(&availableCpusMask);
UnixCpu.LogicalProcessorCount = CPU_COUNT(&cpus);
}
else
{

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#if PLATFORM_LINUX

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
using System.IO;
using Flax.Build;

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
namespace FlaxEditor.Content.Settings
{

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#if PLATFORM_UWP

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#if PLATFORM_UWP

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#if PLATFORM_UWP

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#if PLATFORM_UNIX

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#if PLATFORM_UNIX

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#if PLATFORM_UNIX

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#if PLATFORM_UNIX

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#if PLATFORM_WIN32

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#if PLATFORM_WIN32
@@ -41,11 +41,8 @@ bool Win32FileSystem::CreateDirectory(const StringView& path)
}
else
{
// Specified directory name already exists as a file or directory
const bool isDirectoryOrJunction =
((fileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0) ||
((fileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) != 0);
if (!isDirectoryOrJunction)
// Special case if directory name already exists as a file or directory
if (!((fileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0 || (fileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) != 0))
{
return true;
}
@@ -74,7 +71,7 @@ bool Win32FileSystem::DeleteDirectory(const String& path, bool deleteContents)
do
{
// Check if it isn't a special case
if (((StringUtils::Compare(info.cFileName, TEXT(".")) == 0) || (StringUtils::Compare(info.cFileName, TEXT("..")) == 0)))
if (StringUtils::Compare(info.cFileName, TEXT(".")) == 0 || StringUtils::Compare(info.cFileName, TEXT("..")) == 0)
continue;
// Check if its a directory of a file
@@ -110,19 +107,17 @@ bool Win32FileSystem::DeleteDirectory(const String& path, bool deleteContents)
// Check if still exists
const int32 result = GetFileAttributesW(*path);
return (result != 0xFFFFFFFF && (result & FILE_ATTRIBUTE_DIRECTORY));
return result != 0xFFFFFFFF && result & FILE_ATTRIBUTE_DIRECTORY;
}
bool Win32FileSystem::DirectoryExists(const StringView& path)
{
// Check if exists
const int32 result = GetFileAttributesW(*path);
return (result != 0xFFFFFFFF && (result & FILE_ATTRIBUTE_DIRECTORY));
return result != 0xFFFFFFFF && result & FILE_ATTRIBUTE_DIRECTORY;
}
bool Win32FileSystem::DirectoryGetFiles(Array<String>& results, const String& path, const Char* searchPattern, DirectorySearchOption option)
{
// Check if use only top directory
if (option == DirectorySearchOption::TopDirectoryOnly)
return getFilesFromDirectoryTop(results, path, searchPattern);
return getFilesFromDirectoryAll(results, path, searchPattern);
@@ -143,7 +138,7 @@ bool Win32FileSystem::GetChildDirectories(Array<String>& results, const String&
do
{
// Check if it isn't a special case
if (((StringUtils::Compare(info.cFileName, TEXT(".")) == 0) || (StringUtils::Compare(info.cFileName, TEXT("..")) == 0)))
if (StringUtils::Compare(info.cFileName, TEXT(".")) == 0 || StringUtils::Compare(info.cFileName, TEXT("..")) == 0)
continue;
// Check if its a directory of a file
@@ -161,7 +156,7 @@ bool Win32FileSystem::GetChildDirectories(Array<String>& results, const String&
bool Win32FileSystem::FileExists(const StringView& path)
{
const uint32 result = GetFileAttributesW(*path);
return (result != 0xFFFFFFFF && !(result & FILE_ATTRIBUTE_DIRECTORY));
return result != 0xFFFFFFFF && !(result & FILE_ATTRIBUTE_DIRECTORY);
}
bool Win32FileSystem::DeleteFile(const StringView& path)
@@ -182,13 +177,12 @@ uint64 Win32FileSystem::GetFileSize(const StringView& path)
return li.QuadPart;
}
}
return 0;
}
bool Win32FileSystem::IsReadOnly(const StringView& path)
{
uint32 result = GetFileAttributesW(*path);
const uint32 result = GetFileAttributesW(*path);
if (result != 0xFFFFFFFF)
{
return !!(result & FILE_ATTRIBUTE_READONLY);
@@ -203,24 +197,16 @@ bool Win32FileSystem::SetReadOnly(const StringView& path, bool isReadOnly)
bool Win32FileSystem::MoveFile(const StringView& dst, const StringView& src, bool overwrite)
{
DWORD flags = overwrite ? MOVEFILE_REPLACE_EXISTING : 0;
const DWORD flags = MOVEFILE_COPY_ALLOWED | (overwrite ? MOVEFILE_REPLACE_EXISTING : 0);
// Allow to copy files, needed in cases when Temp folder is
// located on different volume (eg.: Temp is on C:\ and Project in on D:\)
flags |= MOVEFILE_COPY_ALLOWED;
// If paths are almost the same but some characters have different case we need to use proxy file
// If paths are almost the same but some characters have different case we need to use a proxy file
if (StringUtils::CompareIgnoreCase(*dst, *src) == 0)
{
// Get temporary file path
String tmp;
GetTempFilePath(tmp);
// Move file
return MoveFileExW(*src, *tmp, MOVEFILE_REPLACE_EXISTING) == 0 || MoveFileExW(*tmp, *dst, flags) == 0;
return MoveFileExW(*src, *tmp, MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING) == 0 || MoveFileExW(*tmp, *dst, flags) == 0;
}
// Move file
return MoveFileExW(*src, *dst, flags) == 0;
}
@@ -278,7 +264,7 @@ bool Win32FileSystem::getFilesFromDirectoryTop(Array<String>& results, const Str
do
{
// Check if it isn't a special case
if (((StringUtils::Compare(info.cFileName, TEXT(".")) == 0) || (StringUtils::Compare(info.cFileName, TEXT("..")) == 0)))
if (StringUtils::Compare(info.cFileName, TEXT(".")) == 0 || StringUtils::Compare(info.cFileName, TEXT("..")) == 0)
continue;
// Check if its a directory or a file
@@ -315,7 +301,7 @@ bool Win32FileSystem::getFilesFromDirectoryAll(Array<String>& results, const Str
do
{
// Check if it isn't a special case
if ((StringUtils::Compare(info.cFileName, TEXT(".")) == 0) || (StringUtils::Compare(info.cFileName, TEXT("..")) == 0))
if (StringUtils::Compare(info.cFileName, TEXT(".")) == 0 || StringUtils::Compare(info.cFileName, TEXT("..")) == 0)
continue;
// Check if its a directory or a file

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#if PLATFORM_WIN32

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#if PLATFORM_WIN32

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#if PLATFORM_WIN32

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
using System;
using FlaxEngine.GUI;

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#if PLATFORM_WINDOWS

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#if PLATFORM_WINDOWS

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#if PLATFORM_WINDOWS

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#if PLATFORM_WINDOWS
@@ -295,7 +295,7 @@ bool WindowsMouse::WndProc(Window* window, const UINT msg, WPARAM wParam, LPARAM
float NormalizeXInputAxis(const int16 axisVal)
{
// Normalize [-32768..32767] -> [-1..1]
const float norm = axisVal <= 0 ? 32768.f : 32767.f;
const float norm = axisVal <= 0 ? 32768.0f : 32767.0f;
return float(axisVal) / norm;
}

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#pragma once

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved.
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
#if PLATFORM_WINDOWS
@@ -872,19 +872,31 @@ bool IsProcRunning(HANDLE handle)
return WaitForSingleObject(handle, 0) == WAIT_TIMEOUT;
}
void ReadPipe(HANDLE pipe, Array<char>& data)
void ReadPipe(HANDLE pipe, Array<char>& rawData, Array<Char>& logData, LogType logType)
{
// Check if any data is ready to read
DWORD bytesAvailable = 0;
if (PeekNamedPipe(pipe, nullptr, 0, nullptr, &bytesAvailable, nullptr) && bytesAvailable > 0)
{
const int32 idx = data.Count();
data.EnsureCapacity(idx + bytesAvailable);
char* ptr = data.Get() + idx;
// Read data
rawData.Clear();
rawData.Resize(bytesAvailable);
DWORD bytesRead = 0;
if (ReadFile(pipe, ptr, bytesAvailable, &bytesRead, nullptr))
if (ReadFile(pipe, rawData.Get(), bytesAvailable, &bytesRead, nullptr) && bytesRead > 0)
{
data.Resize(idx + bytesRead);
// Skip Windows-style lines
rawData.RemoveAllKeepOrder('\r');
// Remove last new line character
if (rawData.Last() == '\n')
rawData.RemoveLast();
// Log contents
logData.Clear();
logData.Resize(rawData.Count() + 1);
StringUtils::ConvertANSI2UTF16(rawData.Get(), logData.Get(), rawData.Count());
logData.Last() = '\0';
Log::Logger::Write(logType, StringView(logData.Get(), rawData.Count()));
}
}
}
@@ -996,39 +1008,17 @@ int32 WindowsPlatform::RunProcess(const StringView& cmdLine, const StringView& w
if (stdOutRead != nullptr)
{
Array<char> outData;
Array<char> errData;
// Keep reading std output and std error streams until process is running
Array<char> rawData;
Array<Char> logData;
do
{
ReadPipe(stdOutRead, outData);
ReadPipe(stdErrRead, errData);
Sleep(0);
ReadPipe(stdOutRead, rawData, logData, LogType::Info);
ReadPipe(stdErrRead, rawData, logData, LogType::Error);
Sleep(1);
} while (IsProcRunning(procInfo.hProcess));
ReadPipe(stdOutRead, outData);
ReadPipe(stdErrRead, errData);
if (outData.HasItems())
{
outData.RemoveAllKeepOrder('\r');
Array<Char> buffer;
buffer.Resize(outData.Count() + 1);
uint32 length = 0;
StringUtils::ConvertUTF82UTF16(outData.Get(), buffer.Get(), outData.Count(), &length);
buffer[length] = '\0';
Log::Logger::Write(LogType::Info, StringView(buffer.Get(), length));
}
if (errData.HasItems())
{
errData.RemoveAllKeepOrder('\r');
Array<Char> buffer;
buffer.Resize(errData.Count() + 1);
uint32 length = 0;
StringUtils::ConvertUTF82UTF16(errData.Get(), buffer.Get(), errData.Count(), &length);
buffer[length] = '\0';
Log::Logger::Write(LogType::Error, StringView(buffer.Get(), length));
}
ReadPipe(stdOutRead, rawData, logData, LogType::Info);
ReadPipe(stdErrRead, rawData, logData, LogType::Error);
}
else
{

Some files were not shown because too many files have changed in this diff Show More