Various fixes to allow compiling negine with custom build configurations

This commit is contained in:
Wojtek Figat
2022-07-26 23:06:03 +02:00
parent 8beb732cb9
commit ff1fba403d
18 changed files with 41 additions and 39 deletions

View File

@@ -610,6 +610,7 @@ API_CLASS(Static) class FLAXENGINE_API DebugDraw
#define DEBUG_DRAW_TRIANGLE(v0, v1, v2, color, duration, depthTest) DebugDraw::DrawTriangle(v0, v1, v2, color, duration, depthTest)
#define DEBUG_DRAW_TRIANGLES(vertices, color, duration, depthTest) DebugDraw::DrawTriangles(vertices, color, duration, depthTest)
#define DEBUG_DRAW_TRIANGLES_EX(vertices, indices, color, duration, depthTest) DebugDraw::DrawTriangles(vertices, indices, color, duration, depthTest)
#define DEBUG_DRAW_TRIANGLES_EX2(vertices, indices, transform, color, duration, depthTest) DebugDraw::DrawTriangles(vertices, indices, transform, color, duration, depthTest)
#define DEBUG_DRAW_SPHERE(sphere, color, duration, depthTest) DebugDraw::DrawSphere(sphere, color, duration, depthTest)
#define DEBUG_DRAW_TUBE(position, orientation, radius, length, color, duration, depthTest) DebugDraw::DrawTube(position, orientation, radius, length, color, duration, depthTest)
#define DEBUG_DRAW_BOX(box, color, duration, depthTest) DebugDraw::DrawBox(box, color, duration, depthTest)
@@ -638,6 +639,7 @@ API_CLASS(Static) class FLAXENGINE_API DebugDraw
#define DEBUG_DRAW_TRIANGLE(v0, v1, v2, color, duration, depthTest)
#define DEBUG_DRAW_TRIANGLES(vertices, color, duration, depthTest)
#define DEBUG_DRAW_TRIANGLES_EX(vertices, indices, color, duration, depthTest)
#define DEBUG_DRAW_TRIANGLES_EX2(vertices, indices, transform, color, duration, depthTest)
#define DEBUG_DRAW_SPHERE(sphere, color, duration, depthTest)
#define DEBUG_DRAW_TUBE(position, orientation, radius, length, color, duration, depthTest)
#define DEBUG_DRAW_BOX(box, color, duration, depthTest)

View File

@@ -27,6 +27,7 @@ void BoxVolume::SetSize(const Vector3& value)
#if USE_EDITOR
#include "Engine/Debug/DebugDraw.h"
#include "Engine/Core/Math/Color.h"
Color BoxVolume::GetWiresColor()
{

View File

@@ -15,14 +15,12 @@ class SceneObject;
/// <seealso cref="JsonAssetBase" />
API_CLASS(NoSpawn) class FLAXENGINE_API Prefab : public JsonAssetBase
{
DECLARE_ASSET_HEADER(Prefab);
DECLARE_ASSET_HEADER(Prefab);
private:
bool _isCreatingDefaultInstance;
Actor* _defaultInstance;
public:
/// <summary>
/// The serialized scene objects amount (actors and scripts).
/// </summary>
@@ -49,11 +47,9 @@ public:
Dictionary<Guid, const void*> ObjectsCache;
public:
/// <summary>
/// Gets the root object identifier (prefab object ID). Asset must be loaded.
/// </summary>
/// <returns>The ID.</returns>
Guid GetRootObjectId() const
{
ASSERT(IsLoaded());
@@ -74,7 +70,6 @@ public:
API_FUNCTION() SceneObject* GetDefaultInstance(API_PARAM(Ref) const Guid& objectId);
#if USE_EDITOR
/// <summary>
/// Applies the difference from the prefab object instance, saves the changes and synchronizes them with the active instances of the prefab asset.
/// </summary>
@@ -83,11 +78,9 @@ public:
/// </remarks>
/// <param name="targetActor">The root actor of spawned prefab instance to use as modified changes sources.</param>
bool ApplyAll(Actor* targetActor);
#endif
private:
#if USE_EDITOR
typedef Array<AssetReference<Prefab>> NestedPrefabsList;
bool ApplyAllInternal(Actor* targetActor, bool linkTargetActorObjectToPrefab);
@@ -99,7 +92,6 @@ private:
void DeleteDefaultInstance();
protected:
// [JsonAssetBase]
LoadResult loadAsset() override;
void unload(bool isReloading) override;

View File

@@ -105,7 +105,6 @@ public:
/// <summary>
/// Returns true if object has a parent assigned.
/// </summary>
/// <returns>True if has parent, otherwise false.</returns>
API_PROPERTY() FORCE_INLINE bool HasParent() const
{
return _parent != nullptr;
@@ -114,7 +113,6 @@ public:
/// <summary>
/// Gets the parent actor (or null if object has no parent).
/// </summary>
/// <returns>The parent actor.</returns>
API_PROPERTY(Attributes="HideInEditor")
FORCE_INLINE Actor* GetParent() const
{
@@ -160,7 +158,6 @@ public:
/// <summary>
/// Gets a value indicating whether this object has a valid linkage to the prefab asset.
/// </summary>
/// <returns>True if actor has valid prefab link, otherwise false.</returns>
API_PROPERTY() FORCE_INLINE bool HasPrefabLink() const
{
return _prefabID.IsValid();
@@ -169,7 +166,6 @@ public:
/// <summary>
/// Gets the prefab asset ID. Empty if no prefab link exists.
/// </summary>
/// <returns>The prefab asset ID.</returns>
API_PROPERTY() FORCE_INLINE Guid GetPrefabID() const
{
return _prefabID;
@@ -178,7 +174,6 @@ public:
/// <summary>
/// Gets the ID of the object within a prefab that is used for synchronization with this object. Empty if no prefab link exists.
/// </summary>
/// <returns>The prefab object ID.</returns>
API_PROPERTY() FORCE_INLINE Guid GetPrefabObjectID() const
{
return _prefabObjectID;

View File

@@ -110,8 +110,10 @@ bool LocalizedStringTable::Save(const StringView& path)
writer.EndObject();
// Save asset
#if COMPILE_WITH_ASSETS_IMPORTER
const bool saveResult = CreateJson::Create(path.HasChars() ? path : StringView(GetPath()), outputData, TypeName);
if (saveResult)
#endif
{
LOG(Error, "Cannot save \'{0}\'", ToString());
return true;

View File

@@ -215,7 +215,7 @@ void NavigationSettings::Apply()
if (area.Id < DT_MAX_AREAS)
{
NavMeshRuntime::NavAreasCosts[area.Id] = area.Cost;
#if USE_EDITOR
#if COMPILE_WITH_DEBUG_DRAW
NavMeshRuntime::NavAreasColors[area.Id] = area.Color;
#endif
}

View File

@@ -16,6 +16,7 @@
#if USE_EDITOR
#include "ParticleEmitterFunction.h"
#include "Engine/ShadersCompilation/Config.h"
#include "Engine/Particles/Graph/GPU/ParticleEmitterGraph.GPU.h"
#if BUILD_DEBUG
#include "Engine/Engine/Globals.h"
#endif
@@ -26,7 +27,6 @@
#include "Engine/Graphics/Shaders/Cache/ShaderStorage.h"
#endif
#if COMPILE_WITH_PARTICLE_GPU_GRAPH && COMPILE_WITH_SHADER_COMPILER
#include "Engine/Particles/Graph/GPU/ParticleEmitterGraph.GPU.h"
#include "Engine/Utilities/Encryption.h"
#endif

View File

@@ -23,6 +23,7 @@ void BoxCollider::SetSize(const Float3& value)
#if USE_EDITOR
#include "Engine/Debug/DebugDraw.h"
#include "Engine/Core/Math/Color.h"
#include "Engine/Graphics/RenderView.h"
void BoxCollider::DrawPhysicsDebug(RenderView& view)
@@ -31,9 +32,9 @@ void BoxCollider::DrawPhysicsDebug(RenderView& view)
if (!view.CullingFrustum.Intersects(sphere))
return;
if (view.Mode == ViewMode::PhysicsColliders && !GetIsTrigger())
DebugDraw::DrawBox(_bounds, _staticActor ? Color::CornflowerBlue : Color::Orchid, 0, true);
DEBUG_DRAW_BOX(_bounds, _staticActor ? Color::CornflowerBlue : Color::Orchid, 0, true);
else
DebugDraw::DrawWireBox(_bounds, Color::GreenYellow * 0.8f, 0, true);
DEBUG_DRAW_WIRE_BOX(_bounds, Color::GreenYellow * 0.8f, 0, true);
}
void BoxCollider::OnDebugDraw()

View File

@@ -49,9 +49,9 @@ void CapsuleCollider::DrawPhysicsDebug(RenderView& view)
const float radius = Math::Max(Math::Abs(_radius) * scaling, minSize);
const float height = Math::Max(Math::Abs(_height) * scaling, minSize);
if (view.Mode == ViewMode::PhysicsColliders && !GetIsTrigger())
DebugDraw::DrawTube(_transform.LocalToWorld(_center), rot, radius, height, _staticActor ? Color::CornflowerBlue : Color::Orchid, 0, true);
DEBUG_DRAW_TUBE(_transform.LocalToWorld(_center), rot, radius, height, _staticActor ? Color::CornflowerBlue : Color::Orchid, 0, true);
else
DebugDraw::DrawWireTube(_transform.LocalToWorld(_center), rot, radius, height, Color::GreenYellow * 0.8f, 0, true);
DEBUG_DRAW_WIRE_TUBE(_transform.LocalToWorld(_center), rot, radius, height, Color::GreenYellow * 0.8f, 0, true);
}
void CapsuleCollider::OnDebugDrawSelected()

View File

@@ -179,9 +179,9 @@ void CharacterController::DrawPhysicsDebug(RenderView& view)
const float radius = Math::Max(Math::Abs(_radius) * scaling, minSize);
const float height = Math::Max(Math::Abs(_height) * scaling, minSize);
if (view.Mode == ViewMode::PhysicsColliders)
DebugDraw::DrawTube(_transform.LocalToWorld(_center), Quaternion::Euler(90, 0, 0), radius, height, Color::LightYellow, 0, true);
DEBUG_DRAW_TUBE(_transform.LocalToWorld(_center), Quaternion::Euler(90, 0, 0), radius, height, Color::LightYellow, 0, true);
else
DebugDraw::DrawWireTube(_transform.LocalToWorld(_center), Quaternion::Euler(90, 0, 0), radius, height, Color::GreenYellow * 0.8f, 0, true);
DEBUG_DRAW_WIRE_TUBE(_transform.LocalToWorld(_center), Quaternion::Euler(90, 0, 0), radius, height, Color::GreenYellow * 0.8f, 0, true);
}
void CharacterController::OnDebugDrawSelected()

View File

@@ -77,11 +77,11 @@ void MeshCollider::DrawPhysicsDebug(RenderView& view)
Array<Float3>* vertexBuffer;
Array<int32>* indexBuffer;
CollisionData->GetDebugTriangles(vertexBuffer, indexBuffer);
DebugDraw::DrawTriangles(*vertexBuffer, *indexBuffer, _transform.GetWorld(), _staticActor ? Color::CornflowerBlue : Color::Orchid, 0, true);
DEBUG_DRAW_TRIANGLES_EX2(*vertexBuffer, *indexBuffer, _transform.GetWorld(), _staticActor ? Color::CornflowerBlue : Color::Orchid, 0, true);
}
else
{
DebugDraw::DrawLines(CollisionData->GetDebugLines(), _transform.GetWorld(), Color::GreenYellow * 0.8f, 0, true);
DEBUG_DRAW_LINES(CollisionData->GetDebugLines(), _transform.GetWorld(), Color::GreenYellow * 0.8f, 0, true);
}
}
}

View File

@@ -31,9 +31,9 @@ void SphereCollider::DrawPhysicsDebug(RenderView& view)
if (!view.CullingFrustum.Intersects(sphere))
return;
if (view.Mode == ViewMode::PhysicsColliders && !GetIsTrigger())
DebugDraw::DrawSphere(_sphere, _staticActor ? Color::CornflowerBlue : Color::Orchid, 0, true);
DEBUG_DRAW_SPHERE(_sphere, _staticActor ? Color::CornflowerBlue : Color::Orchid, 0, true);
else
DebugDraw::DrawWireSphere(_sphere, Color::GreenYellow * 0.8f, 0, true);
DEBUG_DRAW_WIRE_SPHERE(_sphere, Color::GreenYellow * 0.8f, 0, true);
}
void SphereCollider::OnDebugDrawSelected()

View File

@@ -92,9 +92,9 @@ void SplineCollider::DrawPhysicsDebug(RenderView& view)
if (!view.CullingFrustum.Intersects(sphere))
return;
if (view.Mode == ViewMode::PhysicsColliders && !GetIsTrigger())
DebugDraw::DrawTriangles(_vertexBuffer, _indexBuffer, Color::CornflowerBlue, 0, true);
DEBUG_DRAW_WIRE_TRIANGLES_EX(_vertexBuffer, _indexBuffer, Color::CornflowerBlue, 0, true);
else
DebugDraw::DrawWireTriangles(_vertexBuffer, _indexBuffer, Color::GreenYellow * 0.8f, 0, true);
DEBUG_DRAW_WIRE_TRIANGLES_EX(_vertexBuffer, _indexBuffer, Color::GreenYellow * 0.8f, 0, true);
}
void SplineCollider::OnDebugDrawSelected()

View File

@@ -159,7 +159,7 @@ void D6Joint::OnDebugDrawSelected()
const float twistSize = 9.0f;
const Color swingColor = Color::Green.AlphaMultiplied(0.6f);
const Color twistColor = Color::Yellow.AlphaMultiplied(0.5f);
DebugDraw::DrawWireArrow(target, targetRotation, swingSize / 100.0f * 0.5f, Color::Red, 0, false);
DEBUG_DRAW_WIRE_ARROW(target, targetRotation, swingSize / 100.0f * 0.5f, Color::Red, 0, false);
if (_motion[(int32)D6JointAxis::SwingY] == D6JointMotion::Locked && _motion[(int32)D6JointAxis::SwingZ] == D6JointMotion::Locked)
{
// Swing is locked

View File

@@ -52,6 +52,7 @@ float HingeJoint::GetCurrentVelocity() const
#if USE_EDITOR
#include "Engine/Debug/DebugDraw.h"
#include "Engine/Core/Math/Color.h"
void HingeJoint::OnDebugDrawSelected()
{
@@ -62,8 +63,8 @@ void HingeJoint::OnDebugDrawSelected()
const Quaternion targetRotation = GetTargetOrientation() * xRotation;
const float size = 15.0f;
const Color color = Color::Green.AlphaMultiplied(0.6f);
DebugDraw::DrawWireArrow(source, sourceRotation, size / 100.0f * 0.5f, Color::Red, 0, false);
DebugDraw::DrawWireArrow(target, targetRotation, size / 100.0f * 0.5f, Color::Blue, 0, false);
DEBUG_DRAW_WIRE_ARROW(source, sourceRotation, size / 100.0f * 0.5f, Color::Red, 0, false);
DEBUG_DRAW_WIRE_ARROW(target, targetRotation, size / 100.0f * 0.5f, Color::Blue, 0, false);
if (_flags & HingeJointFlag::Limit)
{
const float upper = Math::Max(_limit.Upper, _limit.Lower);

View File

@@ -31,6 +31,7 @@ void SphericalJoint::SetLimit(const LimitConeRange& value)
#if USE_EDITOR
#include "Engine/Debug/DebugDraw.h"
#include "Engine/Core/Math/Color.h"
void SphericalJoint::OnDebugDrawSelected()
{
@@ -38,7 +39,7 @@ void SphericalJoint::OnDebugDrawSelected()
const Vector3 target = GetTargetPosition();
const float size = 15.0f;
const Color color = Color::Green.AlphaMultiplied(0.6f);
DebugDraw::DrawWireArrow(source, GetOrientation(), size / 100.0f * 0.5f, Color::Red, 0, false);
DEBUG_DRAW_WIRE_ARROW(source, GetOrientation(), size / 100.0f * 0.5f, Color::Red, 0, false);
if (_flags & SphericalJointFlag::Limit)
{
DEBUG_DRAW_CONE(source, GetOrientation(), size, _limit.YLimitAngle * DegreesToRadians, _limit.ZLimitAngle * DegreesToRadians, color, 0, false);

View File

@@ -838,7 +838,7 @@ bool TerrainPatch::SetupHeightMap(int32 heightMapLength, const float* heightMap,
return true;
}
}
#if USE_EDITOR
#if COMPILE_WITH_ASSETS_IMPORTER
else
{
// Import data to the asset file
@@ -897,7 +897,7 @@ bool TerrainPatch::SetupHeightMap(int32 heightMapLength, const float* heightMap,
return true;
}
#if USE_EDITOR
#if COMPILE_WITH_ASSETS_IMPORTER
if (!useVirtualStorage)
{
// Import data to the asset file
@@ -1072,7 +1072,7 @@ bool TerrainPatch::SetupSplatMap(int32 index, int32 splatMapLength, const Color3
return true;
}
}
#if USE_EDITOR
#if COMPILE_WITH_ASSETS_IMPORTER
else
{
// Import data to the asset file
@@ -1659,7 +1659,7 @@ bool TerrainPatch::ModifySplatMap(int32 index, const Color32* samples, const Int
return true;
}
}
#if USE_EDITOR
#if COMPILE_WITH_ASSETS_IMPORTER
else
{
// Prepare asset path for the non-virtual asset
@@ -2254,7 +2254,7 @@ void TerrainPatch::DrawPhysicsDebug(RenderView& view)
if (view.Mode == ViewMode::PhysicsColliders)
{
DebugDraw::DrawTriangles(GetCollisionTriangles(), Color::DarkOliveGreen, 0, true);
DEBUG_DRAW_TRIANGLES(GetCollisionTriangles(), Color::DarkOliveGreen, 0, true);
}
else
{
@@ -2264,7 +2264,7 @@ void TerrainPatch::DrawPhysicsDebug(RenderView& view)
{
if (_debugLines.IsEmpty())
CacheDebugLines();
DebugDraw::DrawLines(_debugLines, world, Color::GreenYellow * 0.8f, 0, true);
DEBUG_DRAW_LINES(_debugLines, world, Color::GreenYellow * 0.8f, 0, true);
}
}
}

View File

@@ -390,7 +390,8 @@ bool ModelTool::ImportData(const String& path, ImportedModelData& data, Options&
if (ImportDataOpenFBX(importPath.Get(), data, options, errorMsg))
return true;
#else
#error Cannot use Model Tool without any importing backend!
LOG(Error, "Compiled without model importing backend.");
return true;
#endif
// Remove temporary file
@@ -809,6 +810,7 @@ bool ModelTool::ImportModel(const String& path, ModelData& meshData, Options& op
} while (importedFileNames.Contains(filename));
}
importedFileNames.Add(filename);
#if COMPILE_WITH_ASSETS_IMPORTER
auto assetPath = autoImportOutput / filename + ASSET_FILES_EXTENSION_WITH_DOT;
TextureTool::Options textureOptions;
switch (texture.Type)
@@ -825,6 +827,7 @@ bool ModelTool::ImportModel(const String& path, ModelData& meshData, Options& op
default: ;
}
AssetsImportingManager::ImportIfEdited(texture.FilePath, assetPath, texture.AssetID, &textureOptions);
#endif
}
// Prepare material
@@ -854,6 +857,7 @@ bool ModelTool::ImportModel(const String& path, ModelData& meshData, Options& op
} while (importedFileNames.Contains(filename));
}
importedFileNames.Add(filename);
#if COMPILE_WITH_ASSETS_IMPORTER
auto assetPath = autoImportOutput / filename + ASSET_FILES_EXTENSION_WITH_DOT;
CreateMaterial::Options materialOptions;
materialOptions.Diffuse.Color = material.Diffuse.Color;
@@ -873,6 +877,7 @@ bool ModelTool::ImportModel(const String& path, ModelData& meshData, Options& op
if (!Math::IsOne(material.Opacity.Value) || material.Opacity.TextureIndex != -1)
materialOptions.Info.BlendMode = MaterialBlendMode::Transparent;
AssetsImportingManager::Create(AssetsImportingManager::CreateMaterialTag, assetPath, material.AssetID, &materialOptions);
#endif
}
// Prepare import transformation
@@ -953,6 +958,7 @@ bool ModelTool::ImportModel(const String& path, ModelData& meshData, Options& op
}
if (collisionModel.LODs.HasItems())
{
#if COMPILE_WITH_PHYSICS_COOKING
// Create collision
CollisionCooking::Argument arg;
arg.Type = CollisionDataType::TriangleMesh;
@@ -962,6 +968,7 @@ bool ModelTool::ImportModel(const String& path, ModelData& meshData, Options& op
{
LOG(Error, "Failed to create collision mesh.");
}
#endif
}
}