Add more const correctness

#2467
This commit is contained in:
Wojtek Figat
2024-04-22 22:53:27 +02:00
parent 515ee96a31
commit b92fbcb3bc
17 changed files with 28 additions and 28 deletions

View File

@@ -35,7 +35,7 @@ public:
namespace
{
FORCE_INLINE bool CanUpdateModel(AnimatedModel* animatedModel)
FORCE_INLINE bool CanUpdateModel(const AnimatedModel* animatedModel)
{
auto skinnedModel = animatedModel->SkinnedModel.Get();
auto animGraph = animatedModel->AnimationGraph.Get();

View File

@@ -35,7 +35,7 @@ const BytesContainer& SceneAnimation::LoadTimeline()
#if USE_EDITOR
bool SceneAnimation::SaveTimeline(BytesContainer& data)
bool SceneAnimation::SaveTimeline(const BytesContainer& data)
{
// Wait for asset to be loaded or don't if last load failed (eg. by shader source compilation error)
if (LastLoadFailed())

View File

@@ -454,10 +454,10 @@ public:
/// <summary>
/// Saves the serialized timeline data to the asset.
/// </summary>
/// <remarks>The cannot be used by virtual assets.</remarks>
/// <remarks>It cannot be used by virtual assets.</remarks>
/// <param name="data">The timeline data container.</param>
/// <returns><c>true</c> failed to save data; otherwise, <c>false</c>.</returns>
API_FUNCTION() bool SaveTimeline(BytesContainer& data);
API_FUNCTION() bool SaveTimeline(const BytesContainer& data);
#endif

View File

@@ -550,7 +550,7 @@ BytesContainer Material::LoadSurface(bool createDefaultIfMissing)
#if USE_EDITOR
bool Material::SaveSurface(BytesContainer& data, const MaterialInfo& info)
bool Material::SaveSurface(const BytesContainer& data, const MaterialInfo& info)
{
// Wait for asset to be loaded or don't if last load failed (eg. by shader source compilation error)
if (LastLoadFailed())

View File

@@ -32,7 +32,7 @@ public:
/// <param name="data">The surface graph data.</param>
/// <param name="info">The material info structure.</param>
/// <returns>True if cannot save it, otherwise false.</returns>
API_FUNCTION() bool SaveSurface(BytesContainer& data, const MaterialInfo& info);
API_FUNCTION() bool SaveSurface(const BytesContainer& data, const MaterialInfo& info);
#endif

View File

@@ -403,7 +403,7 @@ ContentStats Content::GetStats()
return stats;
}
Asset* Content::LoadAsyncInternal(const StringView& internalPath, MClass* type)
Asset* Content::LoadAsyncInternal(const StringView& internalPath, const MClass* type)
{
CHECK_RETURN(type, nullptr);
const auto scriptingType = Scripting::FindScriptingType(type->GetFullName());
@@ -445,7 +445,7 @@ FLAXENGINE_API Asset* LoadAsset(const Guid& id, const ScriptingTypeHandle& type)
return Content::LoadAsync(id, type);
}
Asset* Content::LoadAsync(const StringView& path, MClass* type)
Asset* Content::LoadAsync(const StringView& path, const MClass* type)
{
CHECK_RETURN(type, nullptr);
const auto scriptingType = Scripting::FindScriptingType(type->GetFullName());
@@ -832,7 +832,7 @@ void Content::UnloadAsset(Asset* asset)
asset->DeleteObject();
}
Asset* Content::CreateVirtualAsset(MClass* type)
Asset* Content::CreateVirtualAsset(const MClass* type)
{
CHECK_RETURN(type, nullptr);
const auto scriptingType = Scripting::FindScriptingType(type->GetFullName());

View File

@@ -164,7 +164,7 @@ public:
/// <param name="path">The path of the asset (absolute or relative to the current workspace directory).</param>
/// <param name="type">The asset type. If loaded object has different type (excluding types derived from the given) the loading fails.</param>
/// <returns>Loaded asset or null if cannot</returns>
API_FUNCTION(Attributes="HideInEditor") static Asset* LoadAsync(const StringView& path, MClass* type);
API_FUNCTION(Attributes="HideInEditor") static Asset* LoadAsync(const StringView& path, const MClass* type);
/// <summary>
/// Loads asset and holds it until it won't be referenced by any object. Returns null if asset is missing. Actual asset data loading is performed on a other thread in async.
@@ -192,7 +192,7 @@ public:
/// <param name="internalPath">The path of the asset relative to the engine internal content (excluding the extension).</param>
/// <param name="type">The asset type. If loaded object has different type (excluding types derived from the given) the loading fails.</param>
/// <returns>The loaded asset or null if failed.</returns>
API_FUNCTION(Attributes="HideInEditor") static Asset* LoadAsyncInternal(const StringView& internalPath, MClass* type);
API_FUNCTION(Attributes="HideInEditor") static Asset* LoadAsyncInternal(const StringView& internalPath, const MClass* type);
/// <summary>
/// Loads internal engine asset and holds it until it won't be referenced by any object. Returns null if asset is missing. Actual asset data loading is performed on a other thread in async.
@@ -342,7 +342,7 @@ public:
/// </summary>
/// <param name="type">The asset type klass.</param>
/// <returns>Created asset or null if failed.</returns>
API_FUNCTION() static Asset* CreateVirtualAsset(API_PARAM(Attributes="TypeReference(typeof(Asset))") MClass* type);
API_FUNCTION() static Asset* CreateVirtualAsset(API_PARAM(Attributes="TypeReference(typeof(Asset))") const MClass* type);
/// <summary>
/// Creates temporary and virtual asset of the given type.

View File

@@ -440,7 +440,7 @@ public:
/// <param name="silentMode">In silent mode don't reload opened storage container that is using target file.</param>
/// <param name="customData">Custom options.</param>
/// <returns>True if cannot create package, otherwise false</returns>
FORCE_INLINE static bool Create(const StringView& path, AssetInitData& data, bool silentMode = false, const CustomData* customData = nullptr)
FORCE_INLINE static bool Create(const StringView& path, const AssetInitData& data, bool silentMode = false, const CustomData* customData = nullptr)
{
return Create(path, &data, 1, silentMode, customData);
}

View File

@@ -773,7 +773,7 @@ void Matrix::Transformation(const Float3& scalingCenter, const Quaternion& scali
result = Translation(-scalingCenter) * Transpose(sr) * Scaling(scaling) * sr * Translation(scalingCenter) * Translation(-rotationCenter) * RotationQuaternion(rotation) * Translation(rotationCenter) * Translation(translation);
}
void Matrix::Transformation2D(Float2& scalingCenter, float scalingRotation, const Float2& scaling, const Float2& rotationCenter, float rotation, const Float2& translation, Matrix& result)
void Matrix::Transformation2D(const Float2& scalingCenter, float scalingRotation, const Float2& scaling, const Float2& rotationCenter, float rotation, const Float2& translation, Matrix& result)
{
result = Translation((Float3)-scalingCenter) * RotationZ(-scalingRotation) * Scaling((Float3)scaling) * RotationZ(scalingRotation) * Translation((Float3)scalingCenter) * Translation((Float3)-rotationCenter) * RotationZ(rotation) * Translation((Float3)rotationCenter) * Translation((Float3)translation);
result.M33 = 1.0f;

View File

@@ -941,7 +941,7 @@ public:
// @param rotation The rotation of the transformation.
// @param translation The translation factor of the transformation.
// @param result When the method completes, contains the created transformation matrix.
static void Transformation2D(Float2& scalingCenter, float scalingRotation, const Float2& scaling, const Float2& rotationCenter, float rotation, const Float2& translation, Matrix& result);
static void Transformation2D(const Float2& scalingCenter, float scalingRotation, const Float2& scaling, const Float2& rotationCenter, float rotation, const Float2& translation, Matrix& result);
// Creates a world matrix with the specified parameters.
// @param position Position of the object. This value is used in translation operations.

View File

@@ -99,7 +99,7 @@ Rectangle Rectangle::FromPoints(const Float2& p1, const Float2& p2)
return Rectangle(upperLeft, Math::Max(rightBottom - upperLeft, Float2::Zero));
}
Rectangle Rectangle::FromPoints(Float2* points, int32 pointsCount)
Rectangle Rectangle::FromPoints(const Float2* points, int32 pointsCount)
{
ASSERT(pointsCount > 0);
Float2 upperLeft = points[0];

View File

@@ -287,7 +287,7 @@ public:
// @returns Rectangle that contains both p1 and p2
static Rectangle FromPoints(const Float2& p1, const Float2& p2);
static Rectangle FromPoints(Float2* points, int32 pointsCount);
static Rectangle FromPoints(const Float2* points, int32 pointsCount);
};
template<>

View File

@@ -320,7 +320,7 @@ public:
/// </summary>
/// <param name="data">The data.</param>
/// <param name="length">The length.</param>
void Append(T* data, int32 length)
void Append(const T* data, int32 length)
{
if (length <= 0)
return;

View File

@@ -112,7 +112,7 @@ VariantType::VariantType(Types type, const StringAnsiView& typeName)
}
}
VariantType::VariantType(Types type, MClass* klass)
VariantType::VariantType(Types type, const MClass* klass)
{
Type = type;
TypeName = nullptr;

View File

@@ -105,7 +105,7 @@ public:
explicit VariantType(Types type, const StringView& typeName);
explicit VariantType(Types type, const StringAnsiView& typeName);
explicit VariantType(Types type, MClass* klass);
explicit VariantType(Types type, const MClass* klass);
explicit VariantType(const StringAnsiView& typeName);
VariantType(const VariantType& other);
VariantType(VariantType&& other) noexcept;

View File

@@ -840,7 +840,7 @@ void ScriptingObjectReferenceBase::OnDeleted(ScriptingObject* obj)
}
}
ScriptingObject* Scripting::FindObject(Guid id, MClass* type)
ScriptingObject* Scripting::FindObject(Guid id, const MClass* type)
{
if (!id.IsValid())
return nullptr;
@@ -894,7 +894,7 @@ ScriptingObject* Scripting::FindObject(Guid id, MClass* type)
return nullptr;
}
ScriptingObject* Scripting::TryFindObject(Guid id, MClass* type)
ScriptingObject* Scripting::TryFindObject(Guid id, const MClass* type)
{
if (!id.IsValid())
return nullptr;
@@ -930,7 +930,7 @@ ScriptingObject* Scripting::TryFindObject(Guid id, MClass* type)
return result;
}
ScriptingObject* Scripting::TryFindObject(MClass* type)
ScriptingObject* Scripting::TryFindObject(const MClass* type)
{
if (type == nullptr)
return nullptr;
@@ -1000,7 +1000,7 @@ bool Scripting::IsEveryAssemblyLoaded()
return true;
}
bool Scripting::IsTypeFromGameScripts(MClass* type)
bool Scripting::IsTypeFromGameScripts(const MClass* type)
{
const auto binaryModule = ManagedBinaryModule::GetModule(type ? type->GetAssembly() : nullptr);
return binaryModule && binaryModule != GetBinaryModuleCorlib() && binaryModule != GetBinaryModuleFlaxEngine();

View File

@@ -133,14 +133,14 @@ public:
/// <param name="id">The object unique identifier.</param>
/// <param name="type">The type of the object to find (optional).</param>
/// <returns>The found object or null if missing.</returns>
static ScriptingObject* FindObject(Guid id, MClass* type = nullptr);
static ScriptingObject* FindObject(Guid id, const MClass* type = nullptr);
/// <summary>
/// Tries to find the object by the given class.
/// </summary>
/// <param name="type">The type of the object to find.</param>
/// <returns>The found object or null if missing.</returns>
static ScriptingObject* TryFindObject(MClass* type);
static ScriptingObject* TryFindObject(const MClass* type);
/// <summary>
/// Tries to find the object by the given identifier.
@@ -159,7 +159,7 @@ public:
/// <param name="id">The object unique identifier.</param>
/// <param name="type">The type of the object to find (optional).</param>
/// <returns>The found object or null if missing.</returns>
static ScriptingObject* TryFindObject(Guid id, MClass* type = nullptr);
static ScriptingObject* TryFindObject(Guid id, const MClass* type = nullptr);
/// <summary>
/// Finds the object by the given managed instance handle. Searches only registered scene objects.
@@ -189,7 +189,7 @@ public:
/// <summary>
/// Returns true if given type is from one of the game scripts assemblies.
/// </summary>
static bool IsTypeFromGameScripts(MClass* type);
static bool IsTypeFromGameScripts(const MClass* type);
static void ProcessBuildInfoPath(String& path, const String& projectFolderPath);