Refactor engine to support double-precision vectors
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
#include "MException.h"
|
||||
#include "Scripting.h"
|
||||
#include "Events.h"
|
||||
#include "StdTypesContainer.h"
|
||||
|
||||
Dictionary<Pair<ScriptingTypeHandle, StringView>, void(*)(ScriptingObject*, void*, bool)> ScriptingEvents::EventsTable;
|
||||
Delegate<ScriptingObject*, Span<Variant>, ScriptingTypeHandle, StringView> ScriptingEvents::Event;
|
||||
@@ -775,6 +776,25 @@ namespace
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool VariantTypeEquals(const VariantType& type, MonoType* monoType)
|
||||
{
|
||||
MonoClass* monoClass = mono_class_from_mono_type(monoType);
|
||||
if (MUtils::GetClass(type) != monoClass)
|
||||
{
|
||||
// Hack for Vector2/3/4 which alias with Float2/3/4 or Double2/3/4 (depending on USE_LARGE_WORLDS)
|
||||
const auto& stdTypes = *StdTypesContainer::Instance();
|
||||
if (monoClass == stdTypes.Vector2Class->GetNative() && type.Type == VariantType::Float2 || type.Type == VariantType::Double2)
|
||||
return true;
|
||||
if (monoClass == stdTypes.Vector3Class->GetNative() && type.Type == VariantType::Float3 || type.Type == VariantType::Double3)
|
||||
return true;
|
||||
if (monoClass == stdTypes.Vector4Class->GetNative() && type.Type == VariantType::Float4 || type.Type == VariantType::Double4)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -799,13 +819,13 @@ MMethod* ManagedBinaryModule::FindMethod(MClass* mclass, const ScriptingTypeMeth
|
||||
{
|
||||
auto& param = signature.Params[paramIdx];
|
||||
if (param.IsOut != (mono_signature_param_is_out(sig, paramIdx) != 0) ||
|
||||
MUtils::GetClass(param.Type) != mono_class_from_mono_type(((MonoType**)sigParams)[paramIdx]))
|
||||
!VariantTypeEquals(param.Type, ((MonoType**)sigParams)[paramIdx]))
|
||||
{
|
||||
isValid = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (isValid && MUtils::GetClass(signature.ReturnType) == mono_class_from_mono_type(mono_signature_get_return_type(sig)))
|
||||
if (isValid && VariantTypeEquals(signature.ReturnType, mono_signature_get_return_type(sig)))
|
||||
return method;
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user