Various code improvements
This commit is contained in:
@@ -1336,6 +1336,8 @@ FileReadStream* FlaxStorage::OpenFile()
|
|||||||
|
|
||||||
bool FlaxStorage::CloseFileHandles()
|
bool FlaxStorage::CloseFileHandles()
|
||||||
{
|
{
|
||||||
|
if (Platform::AtomicRead(&_chunksLock) == 0)
|
||||||
|
return false; // Early out
|
||||||
PROFILE_CPU();
|
PROFILE_CPU();
|
||||||
|
|
||||||
// Note: this is usually called by the content manager when this file is not used or on exit
|
// Note: this is usually called by the content manager when this file is not used or on exit
|
||||||
|
|||||||
@@ -4,9 +4,9 @@
|
|||||||
|
|
||||||
#include "Engine/Core/Math/Vector3.h"
|
#include "Engine/Core/Math/Vector3.h"
|
||||||
#include "Engine/Core/Math/Vector4.h"
|
#include "Engine/Core/Math/Vector4.h"
|
||||||
|
#include "Engine/Core/ISerializable.h"
|
||||||
#include "Engine/Content/AssetReference.h"
|
#include "Engine/Content/AssetReference.h"
|
||||||
#include "Engine/Content/SoftAssetReference.h"
|
#include "Engine/Content/SoftAssetReference.h"
|
||||||
#include "Engine/Core/ISerializable.h"
|
|
||||||
#include "Engine/Content/Assets/Texture.h"
|
#include "Engine/Content/Assets/Texture.h"
|
||||||
#include "Engine/Content/Assets/MaterialBase.h"
|
#include "Engine/Content/Assets/MaterialBase.h"
|
||||||
|
|
||||||
@@ -2015,7 +2015,7 @@ API_STRUCT() struct FLAXENGINE_API PostProcessSettings : ISerializable
|
|||||||
ScreenSpaceReflectionsSettings ScreenSpaceReflections;
|
ScreenSpaceReflectionsSettings ScreenSpaceReflections;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The anti-aliasing effect settings.
|
/// The antialiasing effect settings.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
API_FIELD(Attributes="EditorDisplay(\"Anti Aliasing\"), EditorOrder(1100), JsonProperty(\"AA\")")
|
API_FIELD(Attributes="EditorDisplay(\"Anti Aliasing\"), EditorOrder(1100), JsonProperty(\"AA\")")
|
||||||
AntiAliasingSettings AntiAliasing;
|
AntiAliasingSettings AntiAliasing;
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ class FLAXENGINE_API SceneQuery
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Try to find actor hit by the given ray
|
/// Try to find actor hit by the given ray.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="ray">Ray to test</param>
|
/// <param name="ray">Ray to test</param>
|
||||||
/// <returns>Hit actor or nothing</returns>
|
/// <returns>Hit actor or nothing</returns>
|
||||||
@@ -55,19 +55,16 @@ public:
|
|||||||
public:
|
public:
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Execute custom action on actors tree.
|
/// Execute custom action on actors tree.
|
||||||
/// Action should returns false to stop calling deeper.
|
|
||||||
/// First action argument is current actor object.
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="action">Actor to call on every actor in the tree. Returns true if keep calling deeper.</param>
|
/// <param name="action">Actor to call on every actor in the tree. Returns true if keep calling deeper.</param>
|
||||||
/// <param name="args">Custom arguments for the function</param>
|
/// <param name="args">Custom arguments for the function</param>
|
||||||
template<typename... Params>
|
template<typename... Params>
|
||||||
static void TreeExecute(Function<bool(Actor*, Params ...)>& action, Params ... args)
|
static void TreeExecute(Function<bool(Actor*, Params...)>& action, Params... args)
|
||||||
{
|
{
|
||||||
#if SCENE_QUERIES_WITH_LOCK
|
#if SCENE_QUERIES_WITH_LOCK
|
||||||
ScopeLock lock(Level::ScenesLock);
|
ScopeLock lock(Level::ScenesLock);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (int32 i = 0; i < Level::Scenes.Count(); i++)
|
for (int32 i = 0; i < Level::Scenes.Count(); i++)
|
||||||
Level::Scenes[i]->TreeExecute<Params...>(action, args...);
|
Level::Scenes.Get()[i]->TreeExecute<Params...>(action, args...);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#include "Engine/Physics/PhysicsScene.h"
|
#include "Engine/Physics/PhysicsScene.h"
|
||||||
#include "Engine/Physics/PhysicsBackend.h"
|
#include "Engine/Physics/PhysicsBackend.h"
|
||||||
#include "Engine/Physics/CollisionCooking.h"
|
#include "Engine/Physics/CollisionCooking.h"
|
||||||
|
#include "Engine/Profiler/ProfilerCPU.h"
|
||||||
#include "Engine/Threading/Threading.h"
|
#include "Engine/Threading/Threading.h"
|
||||||
|
|
||||||
REGISTER_BINARY_ASSET(CollisionData, "FlaxEngine.CollisionData", true);
|
REGISTER_BINARY_ASSET(CollisionData, "FlaxEngine.CollisionData", true);
|
||||||
@@ -33,6 +34,7 @@ bool CollisionData::CookCollision(CollisionDataType type, ModelBase* modelObj, i
|
|||||||
LOG(Error, "Cannot cook collision data for virtual models on a main thread (virtual models data is stored on GPU only). Use thread pool or async task.");
|
LOG(Error, "Cannot cook collision data for virtual models on a main thread (virtual models data is stored on GPU only). Use thread pool or async task.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
PROFILE_CPU();
|
||||||
|
|
||||||
// Prepare
|
// Prepare
|
||||||
CollisionCooking::Argument arg;
|
CollisionCooking::Argument arg;
|
||||||
@@ -61,6 +63,7 @@ bool CollisionData::CookCollision(CollisionDataType type, ModelBase* modelObj, i
|
|||||||
|
|
||||||
bool CollisionData::CookCollision(CollisionDataType type, const Span<Float3>& vertices, const Span<uint32>& triangles, ConvexMeshGenerationFlags convexFlags, int32 convexVertexLimit)
|
bool CollisionData::CookCollision(CollisionDataType type, const Span<Float3>& vertices, const Span<uint32>& triangles, ConvexMeshGenerationFlags convexFlags, int32 convexVertexLimit)
|
||||||
{
|
{
|
||||||
|
PROFILE_CPU();
|
||||||
CHECK_RETURN(vertices.Length() != 0, true);
|
CHECK_RETURN(vertices.Length() != 0, true);
|
||||||
CHECK_RETURN(triangles.Length() != 0 && triangles.Length() % 3 == 0, true);
|
CHECK_RETURN(triangles.Length() != 0 && triangles.Length() % 3 == 0, true);
|
||||||
ModelData modelData;
|
ModelData modelData;
|
||||||
@@ -74,6 +77,7 @@ bool CollisionData::CookCollision(CollisionDataType type, const Span<Float3>& ve
|
|||||||
|
|
||||||
bool CollisionData::CookCollision(CollisionDataType type, const Span<Float3>& vertices, const Span<int32>& triangles, ConvexMeshGenerationFlags convexFlags, int32 convexVertexLimit)
|
bool CollisionData::CookCollision(CollisionDataType type, const Span<Float3>& vertices, const Span<int32>& triangles, ConvexMeshGenerationFlags convexFlags, int32 convexVertexLimit)
|
||||||
{
|
{
|
||||||
|
PROFILE_CPU();
|
||||||
CHECK_RETURN(vertices.Length() != 0, true);
|
CHECK_RETURN(vertices.Length() != 0, true);
|
||||||
CHECK_RETURN(triangles.Length() != 0 && triangles.Length() % 3 == 0, true);
|
CHECK_RETURN(triangles.Length() != 0 && triangles.Length() % 3 == 0, true);
|
||||||
ModelData modelData;
|
ModelData modelData;
|
||||||
@@ -89,12 +93,12 @@ bool CollisionData::CookCollision(CollisionDataType type, const Span<Float3>& ve
|
|||||||
|
|
||||||
bool CollisionData::CookCollision(CollisionDataType type, ModelData* modelData, ConvexMeshGenerationFlags convexFlags, int32 convexVertexLimit)
|
bool CollisionData::CookCollision(CollisionDataType type, ModelData* modelData, ConvexMeshGenerationFlags convexFlags, int32 convexVertexLimit)
|
||||||
{
|
{
|
||||||
// Validate state
|
|
||||||
if (!IsVirtual())
|
if (!IsVirtual())
|
||||||
{
|
{
|
||||||
LOG(Warning, "Only virtual assets can be modified at runtime.");
|
LOG(Warning, "Only virtual assets can be modified at runtime.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
PROFILE_CPU();
|
||||||
|
|
||||||
// Prepare
|
// Prepare
|
||||||
CollisionCooking::Argument arg;
|
CollisionCooking::Argument arg;
|
||||||
@@ -107,18 +111,14 @@ bool CollisionData::CookCollision(CollisionDataType type, ModelData* modelData,
|
|||||||
SerializedOptions options;
|
SerializedOptions options;
|
||||||
BytesContainer outputData;
|
BytesContainer outputData;
|
||||||
if (CollisionCooking::CookCollision(arg, options, outputData))
|
if (CollisionCooking::CookCollision(arg, options, outputData))
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
|
|
||||||
// Clear state
|
// Clear state
|
||||||
unload(true);
|
unload(true);
|
||||||
|
|
||||||
// Load data
|
// Load data
|
||||||
if (load(&options, outputData.Get(), outputData.Length()) != LoadResult::Ok)
|
if (load(&options, outputData.Get(), outputData.Length()) != LoadResult::Ok)
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
|
|
||||||
// Mark as loaded (eg. Mesh Colliders using this asset will update shape for physics simulation)
|
// Mark as loaded (eg. Mesh Colliders using this asset will update shape for physics simulation)
|
||||||
onLoaded();
|
onLoaded();
|
||||||
@@ -133,6 +133,7 @@ bool CollisionData::GetModelTriangle(uint32 faceIndex, MeshBase*& mesh, uint32&
|
|||||||
meshTriangleIndex = MAX_uint32;
|
meshTriangleIndex = MAX_uint32;
|
||||||
if (!IsLoaded())
|
if (!IsLoaded())
|
||||||
return false;
|
return false;
|
||||||
|
PROFILE_CPU();
|
||||||
ScopeLock lock(Locker);
|
ScopeLock lock(Locker);
|
||||||
if (_triangleMesh)
|
if (_triangleMesh)
|
||||||
{
|
{
|
||||||
@@ -178,6 +179,7 @@ bool CollisionData::GetModelTriangle(uint32 faceIndex, MeshBase*& mesh, uint32&
|
|||||||
|
|
||||||
void CollisionData::ExtractGeometry(Array<Float3>& vertexBuffer, Array<int32>& indexBuffer) const
|
void CollisionData::ExtractGeometry(Array<Float3>& vertexBuffer, Array<int32>& indexBuffer) const
|
||||||
{
|
{
|
||||||
|
PROFILE_CPU();
|
||||||
vertexBuffer.Clear();
|
vertexBuffer.Clear();
|
||||||
indexBuffer.Clear();
|
indexBuffer.Clear();
|
||||||
|
|
||||||
@@ -194,6 +196,7 @@ const Array<Float3>& CollisionData::GetDebugLines()
|
|||||||
{
|
{
|
||||||
if (_hasMissingDebugLines && IsLoaded())
|
if (_hasMissingDebugLines && IsLoaded())
|
||||||
{
|
{
|
||||||
|
PROFILE_CPU();
|
||||||
ScopeLock lock(Locker);
|
ScopeLock lock(Locker);
|
||||||
_hasMissingDebugLines = false;
|
_hasMissingDebugLines = false;
|
||||||
|
|
||||||
|
|||||||
@@ -4265,6 +4265,7 @@ void* PhysicsBackend::CreateHeightField(byte* data, int32 dataSize)
|
|||||||
|
|
||||||
void PhysicsBackend::GetConvexMeshTriangles(void* contextMesh, Array<Float3, HeapAllocation>& vertexBuffer, Array<int, HeapAllocation>& indexBuffer)
|
void PhysicsBackend::GetConvexMeshTriangles(void* contextMesh, Array<Float3, HeapAllocation>& vertexBuffer, Array<int, HeapAllocation>& indexBuffer)
|
||||||
{
|
{
|
||||||
|
PROFILE_CPU();
|
||||||
auto contextMeshPhysX = (PxConvexMesh*)contextMesh;
|
auto contextMeshPhysX = (PxConvexMesh*)contextMesh;
|
||||||
uint32 numIndices = 0;
|
uint32 numIndices = 0;
|
||||||
uint32 numVertices = contextMeshPhysX->getNbVertices();
|
uint32 numVertices = contextMeshPhysX->getNbVertices();
|
||||||
@@ -4304,6 +4305,7 @@ void PhysicsBackend::GetConvexMeshTriangles(void* contextMesh, Array<Float3, Hea
|
|||||||
|
|
||||||
void PhysicsBackend::GetTriangleMeshTriangles(void* triangleMesh, Array<Float3>& vertexBuffer, Array<int32, HeapAllocation>& indexBuffer)
|
void PhysicsBackend::GetTriangleMeshTriangles(void* triangleMesh, Array<Float3>& vertexBuffer, Array<int32, HeapAllocation>& indexBuffer)
|
||||||
{
|
{
|
||||||
|
PROFILE_CPU();
|
||||||
auto triangleMeshPhysX = (PxTriangleMesh*)triangleMesh;
|
auto triangleMeshPhysX = (PxTriangleMesh*)triangleMesh;
|
||||||
uint32 numVertices = triangleMeshPhysX->getNbVertices();
|
uint32 numVertices = triangleMeshPhysX->getNbVertices();
|
||||||
uint32 numIndices = triangleMeshPhysX->getNbTriangles() * 3;
|
uint32 numIndices = triangleMeshPhysX->getNbTriangles() * 3;
|
||||||
|
|||||||
@@ -2474,7 +2474,7 @@ void TerrainPatch::ExtractCollisionGeometry(Array<Float3>& vertexBuffer, Array<i
|
|||||||
if (_collisionVertices.IsEmpty())
|
if (_collisionVertices.IsEmpty())
|
||||||
{
|
{
|
||||||
// Prevent race conditions
|
// Prevent race conditions
|
||||||
ScopeLock lock(Level::ScenesLock);
|
ScopeLock sceneLock(Level::ScenesLock);
|
||||||
if (_collisionVertices.IsEmpty())
|
if (_collisionVertices.IsEmpty())
|
||||||
{
|
{
|
||||||
const float size = _terrain->_chunkSize * TERRAIN_UNITS_PER_VERTEX * Terrain::Terrain::ChunksCountEdge;
|
const float size = _terrain->_chunkSize * TERRAIN_UNITS_PER_VERTEX * Terrain::Terrain::ChunksCountEdge;
|
||||||
|
|||||||
5
Source/ThirdParty/recastnavigation/Recast.h
vendored
5
Source/ThirdParty/recastnavigation/Recast.h
vendored
@@ -196,6 +196,10 @@ protected:
|
|||||||
class rcScopedTimer
|
class rcScopedTimer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
#if 1
|
||||||
|
// Disable timer functionality
|
||||||
|
inline rcScopedTimer(rcContext* ctx, const rcTimerLabel label) { }
|
||||||
|
#else
|
||||||
/// Constructs an instance and starts the timer.
|
/// Constructs an instance and starts the timer.
|
||||||
/// @param[in] ctx The context to use.
|
/// @param[in] ctx The context to use.
|
||||||
/// @param[in] label The category of the timer.
|
/// @param[in] label The category of the timer.
|
||||||
@@ -209,6 +213,7 @@ private:
|
|||||||
|
|
||||||
rcContext* const m_ctx;
|
rcContext* const m_ctx;
|
||||||
const rcTimerLabel m_label;
|
const rcTimerLabel m_label;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Specifies a configuration to use when performing Recast builds.
|
/// Specifies a configuration to use when performing Recast builds.
|
||||||
|
|||||||
Reference in New Issue
Block a user