Merge pull request #27792 from Giacom/fix_quat

Fixes being unable to use the Quat(Vector3) constructor
This commit is contained in:
Rémi Verschelde 2019-12-11 22:04:09 +01:00 committed by GitHub
commit 9abc0ad8a5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1187,31 +1187,6 @@ Variant Variant::construct(const Variant::Type p_type, const Variant **p_args, i
default: return Variant(); default: return Variant();
} }
} else if (p_argcount > 1) {
_VariantCall::ConstructFunc &c = _VariantCall::construct_funcs[p_type];
for (List<_VariantCall::ConstructData>::Element *E = c.constructors.front(); E; E = E->next()) {
const _VariantCall::ConstructData &cd = E->get();
if (cd.arg_count != p_argcount)
continue;
//validate parameters
for (int i = 0; i < cd.arg_count; i++) {
if (!Variant::can_convert(p_args[i]->type, cd.arg_types[i])) {
r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT; //no such constructor
r_error.argument = i;
r_error.expected = cd.arg_types[i];
return Variant();
}
}
Variant v;
cd.func(v, p_args);
return v;
}
} else if (p_argcount == 1 && p_args[0]->type == p_type) { } else if (p_argcount == 1 && p_args[0]->type == p_type) {
return *p_args[0]; //copy construct return *p_args[0]; //copy construct
} else if (p_argcount == 1 && (!p_strict || Variant::can_convert(p_args[0]->type, p_type))) { } else if (p_argcount == 1 && (!p_strict || Variant::can_convert(p_args[0]->type, p_type))) {
@ -1268,6 +1243,30 @@ Variant Variant::construct(const Variant::Type p_type, const Variant **p_args, i
case POOL_COLOR_ARRAY: return (PoolColorArray(*p_args[0])); case POOL_COLOR_ARRAY: return (PoolColorArray(*p_args[0]));
default: return Variant(); default: return Variant();
} }
} else if (p_argcount >= 1) {
_VariantCall::ConstructFunc &c = _VariantCall::construct_funcs[p_type];
for (List<_VariantCall::ConstructData>::Element *E = c.constructors.front(); E; E = E->next()) {
const _VariantCall::ConstructData &cd = E->get();
if (cd.arg_count != p_argcount)
continue;
//validate parameters
for (int i = 0; i < cd.arg_count; i++) {
if (!Variant::can_convert(p_args[i]->type, cd.arg_types[i])) {
r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT; //no such constructor
r_error.argument = i;
r_error.expected = cd.arg_types[i];
return Variant();
}
}
Variant v;
cd.func(v, p_args);
return v;
}
} }
r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD; //no such constructor r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD; //no such constructor
return Variant(); return Variant();