summaryrefslogtreecommitdiff
path: root/scene/resources
diff options
context:
space:
mode:
Diffstat (limited to 'scene/resources')
-rw-r--r--scene/resources/animation.cpp11
-rw-r--r--scene/resources/color_ramp.h7
-rw-r--r--scene/resources/default_theme/default_theme.h2
-rw-r--r--scene/resources/font.cpp5
-rw-r--r--scene/resources/material.cpp35
-rw-r--r--scene/resources/material.h12
-rw-r--r--scene/resources/texture.cpp4
7 files changed, 63 insertions, 13 deletions
diff --git a/scene/resources/animation.cpp b/scene/resources/animation.cpp
index 1a2c8333ef..eae95d9247 100644
--- a/scene/resources/animation.cpp
+++ b/scene/resources/animation.cpp
@@ -970,7 +970,12 @@ int Animation::_find(const Vector<K> &p_keys, float p_time) const {
int low = 0;
int high = len - 1;
- int middle;
+ int middle = 0;
+
+#if DEBUG_ENABLED
+ if (low > high)
+ ERR_PRINT("low > high, this may be a bug");
+#endif
const K *keys = &p_keys[0];
@@ -1289,7 +1294,7 @@ Error Animation::transform_track_interpolate(int p_track, float p_time, Vector3
TransformTrack *tt = static_cast<TransformTrack *>(t);
- bool ok;
+ bool ok = false;
TransformKey tk = _interpolate(tt->transforms, p_time, tt->interpolation, tt->loop_wrap, &ok);
@@ -1315,7 +1320,7 @@ Variant Animation::value_track_interpolate(int p_track, float p_time) const {
ERR_FAIL_COND_V(t->type != TYPE_VALUE, Variant());
ValueTrack *vt = static_cast<ValueTrack *>(t);
- bool ok;
+ bool ok = false;
Variant res = _interpolate(vt->values, p_time, vt->update_mode == UPDATE_CONTINUOUS ? vt->interpolation : INTERPOLATION_NEAREST, vt->loop_wrap, &ok);
diff --git a/scene/resources/color_ramp.h b/scene/resources/color_ramp.h
index 816152d51f..316c188d59 100644
--- a/scene/resources/color_ramp.h
+++ b/scene/resources/color_ramp.h
@@ -88,7 +88,12 @@ public:
//binary search
int low = 0;
int high = points.size() - 1;
- int middle;
+ int middle = 0;
+
+#if DEBUG_ENABLED
+ if (low > high)
+ ERR_PRINT("low > high, this may be a bug");
+#endif
while (low <= high) {
middle = (low + high) / 2;
diff --git a/scene/resources/default_theme/default_theme.h b/scene/resources/default_theme/default_theme.h
index 9032b71775..f2a4b2616d 100644
--- a/scene/resources/default_theme/default_theme.h
+++ b/scene/resources/default_theme/default_theme.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* default_theme.cpp */
+/* default_theme.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
diff --git a/scene/resources/font.cpp b/scene/resources/font.cpp
index d9ccd31f88..ea75748b3d 100644
--- a/scene/resources/font.cpp
+++ b/scene/resources/font.cpp
@@ -40,7 +40,7 @@ void Font::draw_halign(RID p_canvas_item, const Point2 &p_pos, HAlign p_align, f
return;
}
- float ofs;
+ float ofs = 0.f;
switch (p_align) {
case HALIGN_LEFT: {
ofs = 0;
@@ -51,6 +51,9 @@ void Font::draw_halign(RID p_canvas_item, const Point2 &p_pos, HAlign p_align, f
case HALIGN_RIGHT: {
ofs = p_width - length;
} break;
+ default: {
+ ERR_PRINT("Unknown halignment type");
+ } break;
}
draw(p_canvas_item, p_pos + Point2(ofs, 0), p_text, p_modulate, p_width);
}
diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp
index 315351d039..63b7fe4a86 100644
--- a/scene/resources/material.cpp
+++ b/scene/resources/material.cpp
@@ -48,6 +48,19 @@ Ref<Material> Material::get_next_pass() const {
return next_pass;
}
+void Material::set_render_priority(int p_priority) {
+
+ ERR_FAIL_COND(p_priority < RENDER_PRIORITY_MIN);
+ ERR_FAIL_COND(p_priority > RENDER_PRIORITY_MAX);
+ render_priority = p_priority;
+ VS::get_singleton()->material_set_render_priority(material, p_priority);
+}
+
+int Material::get_render_priority() const {
+
+ return render_priority;
+}
+
RID Material::get_rid() const {
return material;
@@ -58,12 +71,20 @@ void Material::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_next_pass", "next_pass"), &Material::set_next_pass);
ClassDB::bind_method(D_METHOD("get_next_pass"), &Material::get_next_pass);
+ ClassDB::bind_method(D_METHOD("set_render_priority", "priority"), &Material::set_render_priority);
+ ClassDB::bind_method(D_METHOD("get_render_priority"), &Material::get_render_priority);
+
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "render_priority", PROPERTY_HINT_RANGE, itos(RENDER_PRIORITY_MIN) + "," + itos(RENDER_PRIORITY_MAX) + ",1"), "set_render_priority", "get_render_priority");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "next_pass", PROPERTY_HINT_RESOURCE_TYPE, "Material"), "set_next_pass", "get_next_pass");
+
+ BIND_CONSTANT(RENDER_PRIORITY_MAX);
+ BIND_CONSTANT(RENDER_PRIORITY_MIN);
}
Material::Material() {
material = VisualServer::get_singleton()->material_create();
+ render_priority = 0;
}
Material::~Material() {
@@ -347,8 +368,8 @@ void SpatialMaterial::_update_shader() {
if (flags[FLAG_UNSHADED]) {
code += ",unshaded";
}
- if (flags[FLAG_ONTOP]) {
- code += ",ontop";
+ if (flags[FLAG_DISABLE_DEPTH_TEST]) {
+ code += ",depth_test_disable";
}
if (flags[FLAG_USE_VERTEX_LIGHTING]) {
code += ",vertex_lighting";
@@ -1459,6 +1480,12 @@ RID SpatialMaterial::get_material_rid_for_2d(bool p_shaded, bool p_transparent,
return materials_for_2d[version]->get_rid();
}
+void SpatialMaterial::set_on_top_of_alpha() {
+ set_feature(FEATURE_TRANSPARENT, true);
+ set_render_priority(RENDER_PRIORITY_MAX);
+ set_flag(FLAG_DISABLE_DEPTH_TEST, true);
+}
+
void SpatialMaterial::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_albedo", "albedo"), &SpatialMaterial::set_albedo);
@@ -1606,7 +1633,7 @@ void SpatialMaterial::_bind_methods() {
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "flags_transparent"), "set_feature", "get_feature", FEATURE_TRANSPARENT);
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "flags_unshaded"), "set_flag", "get_flag", FLAG_UNSHADED);
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "flags_vertex_lighting"), "set_flag", "get_flag", FLAG_USE_VERTEX_LIGHTING);
- ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "flags_on_top"), "set_flag", "get_flag", FLAG_ONTOP);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "flags_no_depth_test"), "set_flag", "get_flag", FLAG_DISABLE_DEPTH_TEST);
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "flags_use_point_size"), "set_flag", "get_flag", FLAG_USE_POINT_SIZE);
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "flags_fixed_size"), "set_flag", "get_flag", FLAG_FIXED_SIZE);
ADD_GROUP("Vertex Color", "vertex_color");
@@ -1768,7 +1795,7 @@ void SpatialMaterial::_bind_methods() {
BIND_ENUM_CONSTANT(FLAG_UNSHADED);
BIND_ENUM_CONSTANT(FLAG_USE_VERTEX_LIGHTING);
- BIND_ENUM_CONSTANT(FLAG_ONTOP);
+ BIND_ENUM_CONSTANT(FLAG_DISABLE_DEPTH_TEST);
BIND_ENUM_CONSTANT(FLAG_ALBEDO_FROM_VERTEX_COLOR);
BIND_ENUM_CONSTANT(FLAG_SRGB_VERTEX_COLOR);
BIND_ENUM_CONSTANT(FLAG_USE_POINT_SIZE);
diff --git a/scene/resources/material.h b/scene/resources/material.h
index 6a0eead708..4977e5dd70 100644
--- a/scene/resources/material.h
+++ b/scene/resources/material.h
@@ -48,15 +48,23 @@ class Material : public Resource {
RID material;
Ref<Material> next_pass;
+ int render_priority;
protected:
_FORCE_INLINE_ RID _get_material() const { return material; }
static void _bind_methods();
public:
+ enum {
+ RENDER_PRIORITY_MAX = VS::MATERIAL_RENDER_PRIORITY_MAX,
+ RENDER_PRIORITY_MIN = VS::MATERIAL_RENDER_PRIORITY_MIN,
+ };
void set_next_pass(const Ref<Material> &p_pass);
Ref<Material> get_next_pass() const;
+ void set_render_priority(int p_priority);
+ int get_render_priority() const;
+
virtual RID get_rid() const;
Material();
virtual ~Material();
@@ -156,7 +164,7 @@ public:
enum Flags {
FLAG_UNSHADED,
FLAG_USE_VERTEX_LIGHTING,
- FLAG_ONTOP,
+ FLAG_DISABLE_DEPTH_TEST,
FLAG_ALBEDO_FROM_VERTEX_COLOR,
FLAG_SRGB_VERTEX_COLOR,
FLAG_USE_POINT_SIZE,
@@ -511,6 +519,8 @@ public:
void set_alpha_scissor_threshold(float p_treshold);
float get_alpha_scissor_threshold() const;
+ void set_on_top_of_alpha();
+
void set_metallic_texture_channel(TextureChannel p_channel);
TextureChannel get_metallic_texture_channel() const;
void set_roughness_texture_channel(TextureChannel p_channel);
diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp
index 9751d6e711..6a9ded9ea3 100644
--- a/scene/resources/texture.cpp
+++ b/scene/resources/texture.cpp
@@ -501,9 +501,9 @@ Error StreamTexture::_load_data(const String &p_path, int &tw, int &th, int &fla
Vector<Ref<Image> > mipmap_images;
int total_size = 0;
- for (int i = 0; i < mipmaps; i++) {
+ for (uint32_t i = 0; i < mipmaps; i++) {
- if (i > 0) {
+ if (i) {
size = f->get_32();
}