summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/color.h18
-rw-r--r--core/io/resource_format_binary.cpp11
-rw-r--r--core/io/resource_format_binary.h1
-rw-r--r--core/node_path.cpp17
-rw-r--r--core/os/os.cpp2
-rw-r--r--core/translation.cpp2
-rw-r--r--core/variant.cpp15
-rw-r--r--core/variant_call.cpp12
8 files changed, 55 insertions, 23 deletions
diff --git a/core/color.h b/core/color.h
index 972b6a1b33..da2bfdcd98 100644
--- a/core/color.h
+++ b/core/color.h
@@ -101,6 +101,24 @@ struct Color {
return res;
}
+ _FORCE_INLINE_ Color darkened(float p_amount) const {
+
+ Color res = *this;
+ res.r = CLAMP(res.r * (1.0f - p_amount), 0.0, 1.0);
+ res.g = CLAMP(res.g * (1.0f - p_amount), 0.0, 1.0);
+ res.b = CLAMP(res.b * (1.0f - p_amount), 0.0, 1.0);
+ return res;
+ }
+
+ _FORCE_INLINE_ Color lightened(float p_amount) const {
+
+ Color res = *this;
+ res.r = CLAMP(res.r + (1.0f - res.r) * p_amount, 0.0, 1.0);
+ res.g = CLAMP(res.g + (1.0f - res.g) * p_amount, 0.0, 1.0);
+ res.b = CLAMP(res.b + (1.0f - res.b) * p_amount, 0.0, 1.0);
+ return res;
+ }
+
_FORCE_INLINE_ uint32_t to_rgbe9995() const {
const float pow2to9 = 512.0f;
diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp
index aa51b00028..df0d41ea9d 100644
--- a/core/io/resource_format_binary.cpp
+++ b/core/io/resource_format_binary.cpp
@@ -84,8 +84,10 @@ enum {
OBJECT_INTERNAL_RESOURCE = 2,
OBJECT_EXTERNAL_RESOURCE_INDEX = 3,
//version 2: added 64 bits support for float and int
- FORMAT_VERSION = 2,
- FORMAT_VERSION_CAN_RENAME_DEPS = 1
+ //version 3: changed nodepath encoding
+ FORMAT_VERSION = 3,
+ FORMAT_VERSION_CAN_RENAME_DEPS = 1,
+ FORMAT_VERSION_NO_NODEPATH_PROPERTY = 3,
};
@@ -273,6 +275,9 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) {
uint32_t subname_count = f->get_16();
absolute = subname_count & 0x8000;
subname_count &= 0x7FFF;
+ if (ver_format < FORMAT_VERSION_NO_NODEPATH_PROPERTY) {
+ subname_count += 1; // has a property field, so we should count it as well
+ }
for (int i = 0; i < name_count; i++)
names.push_back(_get_string());
@@ -854,7 +859,7 @@ void ResourceInteractiveLoaderBinary::open(FileAccess *p_f) {
uint32_t ver_major = f->get_32();
uint32_t ver_minor = f->get_32();
- uint32_t ver_format = f->get_32();
+ ver_format = f->get_32();
print_bl("big endian: " + itos(big_endian));
#ifdef BIG_ENDIAN_ENABLED
diff --git a/core/io/resource_format_binary.h b/core/io/resource_format_binary.h
index 2316f05b3c..687da0a9b4 100644
--- a/core/io/resource_format_binary.h
+++ b/core/io/resource_format_binary.h
@@ -41,6 +41,7 @@ class ResourceInteractiveLoaderBinary : public ResourceInteractiveLoader {
String res_path;
String type;
Ref<Resource> resource;
+ uint32_t ver_format;
FileAccess *f;
diff --git a/core/node_path.cpp b/core/node_path.cpp
index a01bb420a5..a12152aca6 100644
--- a/core/node_path.cpp
+++ b/core/node_path.cpp
@@ -207,7 +207,7 @@ StringName NodePath::get_concatenated_subnames() const {
String concatenated;
const StringName *ssn = data->subpath.ptr();
for (int i = 0; i < spc; i++) {
- concatenated += i == 0 ? ssn[i].operator String() : "." + ssn[i];
+ concatenated += i == 0 ? ssn[i].operator String() : ":" + ssn[i];
}
data->concatenated_subpath = concatenated;
}
@@ -257,13 +257,17 @@ NodePath NodePath::rel_path_to(const NodePath &p_np) const {
NodePath NodePath::get_as_property_path() const {
- if (data->has_slashes || !data->path.size()) {
- return NodePath(Vector<StringName>(), data->subpath, false);
+ if (!data->path.size()) {
+ return *this;
} else {
- ERR_FAIL_COND_V(data->path.size() != 1, NodePath());
-
Vector<StringName> new_path = data->subpath;
- new_path.insert(0, data->path[0]);
+
+ String initial_subname = data->path[0];
+ for (size_t i = 1; i < data->path.size(); i++) {
+ initial_subname += i == 0 ? data->path[i].operator String() : "/" + data->path[i];
+ }
+ new_path.insert(0, initial_subname);
+
return NodePath(Vector<StringName>(), new_path, false);
}
}
@@ -335,7 +339,6 @@ NodePath::NodePath(const String &p_path) {
return;
String path = p_path;
- StringName property;
Vector<StringName> subpath;
int absolute = (path[0] == '/') ? 1 : 0;
diff --git a/core/os/os.cpp b/core/os/os.cpp
index 0e7e26df73..84937c0e59 100644
--- a/core/os/os.cpp
+++ b/core/os/os.cpp
@@ -554,7 +554,7 @@ bool OS::has_feature(const String &p_feature) {
if (sizeof(void *) == 4 && p_feature == "32") {
return true;
}
-#if defined(__x86_64) || defined(__x86_64__)
+#if defined(__x86_64) || defined(__x86_64__) || defined(__amd64__)
if (p_feature == "x86_64") {
return true;
}
diff --git a/core/translation.cpp b/core/translation.cpp
index 7e4d4feb89..dcca58692a 100644
--- a/core/translation.cpp
+++ b/core/translation.cpp
@@ -333,6 +333,7 @@ static const char *locale_list[] = {
"sq_KV", // Albanian (Kosovo)
"sq_MK", // Albanian (Macedonia)
"sr", // Serbian
+ "sr_Cyrl", // Serbian (Cyrillic)
"sr_ME", // Serbian (Montenegro)
"sr_RS", // Serbian (Serbia)
"ss_ZA", // Swati (South Africa)
@@ -693,6 +694,7 @@ static const char *locale_names[] = {
"Albanian (Kosovo)",
"Albanian (Macedonia)",
"Serbian",
+ "Serbian (Cyrillic)",
"Serbian (Montenegro)",
"Serbian (Serbia)",
"Swati (South Africa)",
diff --git a/core/variant.cpp b/core/variant.cpp
index d4143b8d84..0f97b98a6f 100644
--- a/core/variant.cpp
+++ b/core/variant.cpp
@@ -66,7 +66,7 @@ String Variant::get_type_name(Variant::Type p_type) {
return "String";
} break;
- // math types
+ // math types
case VECTOR2: {
@@ -513,6 +513,7 @@ bool Variant::can_convert_strict(Variant::Type p_type_from, Variant::Type p_type
static const Type valid[] = {
QUAT,
+ VECTOR3,
NIL
};
@@ -723,7 +724,7 @@ bool Variant::is_zero() const {
} break;
- // math types
+ // math types
case VECTOR2: {
@@ -932,7 +933,7 @@ void Variant::reference(const Variant &p_variant) {
memnew_placement(_data._mem, String(*reinterpret_cast<const String *>(p_variant._data._mem)));
} break;
- // math types
+ // math types
case VECTOR2: {
@@ -1632,7 +1633,9 @@ Variant::operator Basis() const {
return *_data._basis;
else if (type == QUAT)
return *reinterpret_cast<const Quat *>(_data._mem);
- else if (type == TRANSFORM)
+ else if (type == VECTOR3) {
+ return Basis(*reinterpret_cast<const Vector3 *>(_data._mem));
+ } else if (type == TRANSFORM) // unexposed in Variant::can_convert?
return _data._transform->basis;
else
return Basis();
@@ -2502,7 +2505,7 @@ void Variant::operator=(const Variant &p_variant) {
*reinterpret_cast<String *>(_data._mem) = *reinterpret_cast<const String *>(p_variant._data._mem);
} break;
- // math types
+ // math types
case VECTOR2: {
@@ -2642,7 +2645,7 @@ uint32_t Variant::hash() const {
return reinterpret_cast<const String *>(_data._mem)->hash();
} break;
- // math types
+ // math types
case VECTOR2: {
diff --git a/core/variant_call.cpp b/core/variant_call.cpp
index 365ed07810..4a140bdb99 100644
--- a/core/variant_call.cpp
+++ b/core/variant_call.cpp
@@ -437,6 +437,8 @@ struct _VariantCall {
VCALL_LOCALMEM0R(Color, contrasted);
VCALL_LOCALMEM2R(Color, linear_interpolate);
VCALL_LOCALMEM1R(Color, blend);
+ VCALL_LOCALMEM1R(Color, lightened);
+ VCALL_LOCALMEM1R(Color, darkened);
VCALL_LOCALMEM1R(Color, to_html);
VCALL_LOCALMEM0R(RID, get_id);
@@ -447,6 +449,7 @@ struct _VariantCall {
VCALL_LOCALMEM0R(NodePath, get_subname_count);
VCALL_LOCALMEM1R(NodePath, get_subname);
VCALL_LOCALMEM0R(NodePath, get_concatenated_subnames);
+ VCALL_LOCALMEM0R(NodePath, get_as_property_path);
VCALL_LOCALMEM0R(NodePath, is_empty);
VCALL_LOCALMEM0R(Dictionary, size);
@@ -899,11 +902,6 @@ struct _VariantCall {
r_ret = Basis(p_args[0]->operator Vector3(), p_args[1]->operator real_t());
}
- static void Basis_init3(Variant &r_ret, const Variant **p_args) {
-
- r_ret = Basis(p_args[0]->operator Vector3());
- }
-
static void Transform_init1(Variant &r_ret, const Variant **p_args) {
Transform t;
@@ -1583,6 +1581,8 @@ void register_variant_methods() {
ADDFUNC0R(COLOR, COLOR, Color, contrasted, varray());
ADDFUNC2R(COLOR, COLOR, Color, linear_interpolate, COLOR, "b", REAL, "t", varray());
ADDFUNC1R(COLOR, COLOR, Color, blend, COLOR, "over", varray());
+ ADDFUNC1R(COLOR, COLOR, Color, lightened, REAL, "amount", varray());
+ ADDFUNC1R(COLOR, COLOR, Color, darkened, REAL, "amount", varray());
ADDFUNC1R(COLOR, STRING, Color, to_html, BOOL, "with_alpha", varray(true));
ADDFUNC0R(_RID, INT, RID, get_id, varray());
@@ -1593,6 +1593,7 @@ void register_variant_methods() {
ADDFUNC0R(NODE_PATH, INT, NodePath, get_subname_count, varray());
ADDFUNC1R(NODE_PATH, STRING, NodePath, get_subname, INT, "idx", varray());
ADDFUNC0R(NODE_PATH, STRING, NodePath, get_concatenated_subnames, varray());
+ ADDFUNC0R(NODE_PATH, NODE_PATH, NodePath, get_as_property_path, varray());
ADDFUNC0R(NODE_PATH, BOOL, NodePath, is_empty, varray());
ADDFUNC0R(DICTIONARY, INT, Dictionary, size, varray());
@@ -1799,7 +1800,6 @@ void register_variant_methods() {
_VariantCall::add_constructor(_VariantCall::Basis_init1, Variant::BASIS, "x_axis", Variant::VECTOR3, "y_axis", Variant::VECTOR3, "z_axis", Variant::VECTOR3);
_VariantCall::add_constructor(_VariantCall::Basis_init2, Variant::BASIS, "axis", Variant::VECTOR3, "phi", Variant::REAL);
- _VariantCall::add_constructor(_VariantCall::Basis_init3, Variant::BASIS, "euler", Variant::VECTOR3);
_VariantCall::add_constructor(_VariantCall::Transform_init1, Variant::TRANSFORM, "x_axis", Variant::VECTOR3, "y_axis", Variant::VECTOR3, "z_axis", Variant::VECTOR3, "origin", Variant::VECTOR3);
_VariantCall::add_constructor(_VariantCall::Transform_init2, Variant::TRANSFORM, "basis", Variant::BASIS, "origin", Variant::VECTOR3);