summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/engine.cpp2
-rw-r--r--core/engine.h4
-rw-r--r--core/io/resource_format_binary.cpp73
-rw-r--r--core/math/audio_frame.h10
-rw-r--r--core/math/vector3.h6
5 files changed, 92 insertions, 3 deletions
diff --git a/core/engine.cpp b/core/engine.cpp
index 42850325b4..c16a2903d3 100644
--- a/core/engine.cpp
+++ b/core/engine.cpp
@@ -119,4 +119,6 @@ Engine::Engine() {
_fixed_frames = 0;
_idle_frames = 0;
_in_fixed = false;
+ _frame_ticks = 0;
+ _frame_step = 0;
}
diff --git a/core/engine.h b/core/engine.h
index 80b11c095d..16dfb77593 100644
--- a/core/engine.h
+++ b/core/engine.h
@@ -42,6 +42,8 @@ class Engine {
String _custom_level;
uint64_t frames_drawn;
uint32_t _frame_delay;
+ uint64_t _frame_ticks;
+ float _frame_step;
int ips;
float _fps;
@@ -72,6 +74,8 @@ public:
uint64_t get_fixed_frames() const { return _fixed_frames; }
uint64_t get_idle_frames() const { return _idle_frames; }
bool is_in_fixed_frame() const { return _in_fixed; }
+ uint64_t get_idle_frame_ticks() const { return _frame_ticks; }
+ float get_idle_frame_step() const { return _frame_step; }
void set_time_scale(float p_scale);
float get_time_scale() const;
diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp
index b474c2e078..728cd5d4ff 100644
--- a/core/io/resource_format_binary.cpp
+++ b/core/io/resource_format_binary.cpp
@@ -29,6 +29,7 @@
/*************************************************************************/
#include "resource_format_binary.h"
#include "global_config.h"
+#include "image.h"
#include "io/file_access_compressed.h"
#include "io/marshalls.h"
#include "os/dir_access.h"
@@ -54,7 +55,6 @@ enum {
VARIANT_TRANSFORM = 17,
VARIANT_MATRIX32 = 18,
VARIANT_COLOR = 20,
- //VARIANT_IMAGE = 21, - no longer variant type
VARIANT_NODE_PATH = 22,
VARIANT_RID = 23,
VARIANT_OBJECT = 24,
@@ -70,7 +70,13 @@ enum {
VARIANT_VECTOR2_ARRAY = 37,
VARIANT_INT64 = 40,
VARIANT_DOUBLE = 41,
-
+#ifndef DISABLE_DEPRECATED
+ VARIANT_IMAGE = 21, // - no longer variant type
+ IMAGE_ENCODING_EMPTY = 0,
+ IMAGE_ENCODING_RAW = 1,
+ IMAGE_ENCODING_LOSSLESS = 2,
+ IMAGE_ENCODING_LOSSY = 3,
+#endif
OBJECT_EMPTY = 0,
OBJECT_EXTERNAL_RESOURCE = 1,
OBJECT_INTERNAL_RESOURCE = 2,
@@ -541,7 +547,69 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) {
w = PoolVector<Color>::Write();
r_v = array;
} break;
+#ifndef DISABLE_DEPRECATED
+ case VARIANT_IMAGE: {
+ uint32_t encoding = f->get_32();
+ if (encoding == IMAGE_ENCODING_EMPTY) {
+ r_v = Ref<Image>();
+ break;
+ } else if (encoding == IMAGE_ENCODING_RAW) {
+ uint32_t width = f->get_32();
+ uint32_t height = f->get_32();
+ uint32_t mipmaps = f->get_32();
+ uint32_t format = f->get_32();
+ const uint32_t format_version_shift = 24;
+ const uint32_t format_version_mask = format_version_shift - 1;
+
+ uint32_t format_version = format >> format_version_shift;
+
+ const uint32_t current_version = 0;
+ if (format_version > current_version) {
+
+ ERR_PRINT("Format version for encoded binary image is too new");
+ return ERR_PARSE_ERROR;
+ }
+
+ Image::Format fmt = Image::Format(format & format_version_mask); //if format changes, we can add a compatibility bit on top
+
+ uint32_t datalen = f->get_32();
+
+ PoolVector<uint8_t> imgdata;
+ imgdata.resize(datalen);
+ PoolVector<uint8_t>::Write w = imgdata.write();
+ f->get_buffer(w.ptr(), datalen);
+ _advance_padding(datalen);
+ w = PoolVector<uint8_t>::Write();
+
+ Ref<Image> image;
+ image.instance();
+ image->create(width, height, mipmaps, fmt, imgdata);
+ r_v = image;
+
+ } else {
+ //compressed
+ PoolVector<uint8_t> data;
+ data.resize(f->get_32());
+ PoolVector<uint8_t>::Write w = data.write();
+ f->get_buffer(w.ptr(), data.size());
+ w = PoolVector<uint8_t>::Write();
+
+ Ref<Image> image;
+ if (encoding == IMAGE_ENCODING_LOSSY && Image::lossy_unpacker) {
+
+ image = Image::lossy_unpacker(data);
+ } else if (encoding == IMAGE_ENCODING_LOSSLESS && Image::lossless_unpacker) {
+
+ image = Image::lossless_unpacker(data);
+ }
+ _advance_padding(data.size());
+
+ r_v = image;
+ }
+
+ } break;
+#endif
default: {
ERR_FAIL_V(ERR_FILE_CORRUPT);
} break;
@@ -1644,7 +1712,6 @@ void ResourceFormatSaverBinaryInstance::_find_resources(const Variant &p_variant
get_string_index(np.get_property());
} break;
-
default: {}
}
}
diff --git a/core/math/audio_frame.h b/core/math/audio_frame.h
index 5ccc9d9e5e..d54f622197 100644
--- a/core/math/audio_frame.h
+++ b/core/math/audio_frame.h
@@ -102,6 +102,16 @@ struct AudioFrame {
r = ::undenormalise(r);
}
+ _FORCE_INLINE_ AudioFrame linear_interpolate(const AudioFrame &p_b, float p_t) const {
+
+ AudioFrame res = *this;
+
+ res.l += (p_t * (p_b.l - l));
+ res.r += (p_t * (p_b.r - r));
+
+ return res;
+ }
+
_ALWAYS_INLINE_ AudioFrame(float p_l, float p_r) {
l = p_l;
r = p_r;
diff --git a/core/math/vector3.h b/core/math/vector3.h
index 7dfcedd0da..6a7974681e 100644
--- a/core/math/vector3.h
+++ b/core/math/vector3.h
@@ -100,6 +100,7 @@ struct Vector3 {
_FORCE_INLINE_ Vector3 abs() const;
_FORCE_INLINE_ Vector3 floor() const;
+ _FORCE_INLINE_ Vector3 sign() const;
_FORCE_INLINE_ Vector3 ceil() const;
_FORCE_INLINE_ real_t distance_to(const Vector3 &p_b) const;
@@ -187,6 +188,11 @@ Vector3 Vector3::abs() const {
return Vector3(Math::abs(x), Math::abs(y), Math::abs(z));
}
+Vector3 Vector3::sign() const {
+
+ return Vector3(SGN(x), SGN(y), SGN(z));
+}
+
Vector3 Vector3::floor() const {
return Vector3(Math::floor(x), Math::floor(y), Math::floor(z));