summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
Diffstat (limited to 'scene')
-rw-r--r--scene/2d/audio_stream_player_2d.cpp8
-rw-r--r--scene/2d/canvas_item.cpp1
-rw-r--r--scene/3d/audio_stream_player_3d.cpp8
-rw-r--r--scene/3d/gi_probe.cpp31
-rw-r--r--scene/3d/light.cpp23
-rw-r--r--scene/3d/light.h10
-rw-r--r--scene/3d/physics_body.cpp228
-rw-r--r--scene/3d/physics_body.h52
-rw-r--r--scene/audio/audio_player.cpp2
-rw-r--r--scene/gui/base_button.cpp10
-rw-r--r--scene/gui/button_group.cpp168
-rw-r--r--scene/gui/button_group.h68
-rw-r--r--scene/gui/check_box.cpp1
-rw-r--r--scene/gui/control.cpp4
-rw-r--r--scene/gui/graph_node.cpp20
-rw-r--r--scene/gui/graph_node.h6
-rw-r--r--scene/gui/item_list.cpp16
-rw-r--r--scene/gui/item_list.h4
-rw-r--r--scene/gui/line_edit.cpp2
-rw-r--r--scene/gui/rich_text_label.cpp29
-rw-r--r--scene/gui/rich_text_label.h2
-rw-r--r--scene/gui/text_edit.cpp21
-rw-r--r--scene/gui/tree.cpp6
-rw-r--r--scene/main/viewport.cpp17
-rw-r--r--scene/main/viewport.h6
-rw-r--r--scene/register_scene_types.cpp2
-rw-r--r--scene/resources/default_theme/default_theme.cpp1
-rw-r--r--scene/resources/environment.cpp7
-rw-r--r--scene/resources/environment.h1
-rw-r--r--scene/resources/material.cpp55
-rw-r--r--scene/resources/material.h17
-rw-r--r--scene/resources/mesh_library.cpp4
-rw-r--r--scene/resources/mesh_library.h2
33 files changed, 417 insertions, 415 deletions
diff --git a/scene/2d/audio_stream_player_2d.cpp b/scene/2d/audio_stream_player_2d.cpp
index 39d3f2d6bf..ea2e77fc47 100644
--- a/scene/2d/audio_stream_player_2d.cpp
+++ b/scene/2d/audio_stream_player_2d.cpp
@@ -217,13 +217,15 @@ void AudioStreamPlayer2D::_notification(int p_what) {
setseek = setplay;
active = true;
setplay = -1;
- _change_notify("playing"); //update property in editor
+ //do not update, this makes it easier to animate (will shut off otherise)
+ //_change_notify("playing"); //update property in editor
}
//stop playing if no longer active
if (!active) {
set_fixed_process_internal(false);
- _change_notify("playing"); //update property in editor
+ //do not update, this makes it easier to animate (will shut off otherise)
+ //_change_notify("playing"); //update property in editor
emit_signal("finished");
}
}
@@ -439,7 +441,7 @@ void AudioStreamPlayer2D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "stream", PROPERTY_HINT_RESOURCE_TYPE, "AudioStream"), "set_stream", "get_stream");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "volume_db", PROPERTY_HINT_RANGE, "-80,24"), "set_volume_db", "get_volume_db");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "playing", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "_set_playing", "_is_active");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "play", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "_set_playing", "_is_active");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "autoplay"), "set_autoplay", "is_autoplay_enabled");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "max_distance", PROPERTY_HINT_RANGE, "1,65536,1"), "set_max_distance", "get_max_distance");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "attenuation", PROPERTY_HINT_EXP_EASING), "set_attenuation", "get_attenuation");
diff --git a/scene/2d/canvas_item.cpp b/scene/2d/canvas_item.cpp
index 4f00966e75..a7c5d1adbb 100644
--- a/scene/2d/canvas_item.cpp
+++ b/scene/2d/canvas_item.cpp
@@ -37,6 +37,7 @@
#include "scene/resources/style_box.h"
#include "scene/resources/texture.h"
#include "scene/scene_string_names.h"
+#include "servers/visual/visual_server_raster.h"
#include "servers/visual_server.h"
Mutex *CanvasItemMaterial::material_mutex = NULL;
diff --git a/scene/3d/audio_stream_player_3d.cpp b/scene/3d/audio_stream_player_3d.cpp
index a69bec2fc8..2073ebf94e 100644
--- a/scene/3d/audio_stream_player_3d.cpp
+++ b/scene/3d/audio_stream_player_3d.cpp
@@ -530,13 +530,15 @@ void AudioStreamPlayer3D::_notification(int p_what) {
setseek = setplay;
active = true;
setplay = -1;
- _change_notify("playing"); //update property in editor
+ //do not update, this makes it easier to animate (will shut off otherise)
+ ///_change_notify("playing"); //update property in editor
}
//stop playing if no longer active
if (!active) {
set_fixed_process_internal(false);
- _change_notify("playing"); //update property in editor
+ //do not update, this makes it easier to animate (will shut off otherise)
+ //_change_notify("playing"); //update property in editor
emit_signal("finished");
}
}
@@ -877,7 +879,7 @@ void AudioStreamPlayer3D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::REAL, "unit_db", PROPERTY_HINT_RANGE, "-80,80"), "set_unit_db", "get_unit_db");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "unit_size", PROPERTY_HINT_RANGE, "0.1,100,0.1"), "set_unit_size", "get_unit_size");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "max_db", PROPERTY_HINT_RANGE, "-24,6"), "set_max_db", "get_max_db");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "playing", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "_set_playing", "_is_active");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "play", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "_set_playing", "_is_active");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "autoplay"), "set_autoplay", "is_autoplay_enabled");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "max_distance", PROPERTY_HINT_RANGE, "0,65536,1"), "set_max_distance", "get_max_distance");
ADD_PROPERTY(PropertyInfo(Variant::INT, "out_of_range_mode", PROPERTY_HINT_ENUM, "Mix,Pause"), "set_out_of_range_mode", "get_out_of_range_mode");
diff --git a/scene/3d/gi_probe.cpp b/scene/3d/gi_probe.cpp
index bb54a43028..7792a86b4a 100644
--- a/scene/3d/gi_probe.cpp
+++ b/scene/3d/gi_probe.cpp
@@ -1092,7 +1092,7 @@ void GIProbe::_plot_mesh(const Transform &p_xform, Ref<Mesh> &p_mesh, Baker *p_b
void GIProbe::_find_meshes(Node *p_at_node, Baker *p_baker) {
MeshInstance *mi = Object::cast_to<MeshInstance>(p_at_node);
- if (mi && mi->get_flag(GeometryInstance::FLAG_USE_BAKED_LIGHT)) {
+ if (mi && mi->get_flag(GeometryInstance::FLAG_USE_BAKED_LIGHT) && mi->is_visible_in_tree()) {
Ref<Mesh> mesh = mi->get_mesh();
if (mesh.is_valid()) {
@@ -1115,23 +1115,26 @@ void GIProbe::_find_meshes(Node *p_at_node, Baker *p_baker) {
if (Spatial *s = Object::cast_to<Spatial>(p_at_node)) {
- Array meshes = p_at_node->call("get_meshes");
- for (int i = 0; i < meshes.size(); i += 2) {
+ if (s->is_visible_in_tree()) {
- Transform mxf = meshes[i];
- Ref<Mesh> mesh = meshes[i + 1];
- if (!mesh.is_valid())
- continue;
+ Array meshes = p_at_node->call("get_meshes");
+ for (int i = 0; i < meshes.size(); i += 2) {
- Rect3 aabb = mesh->get_aabb();
+ Transform mxf = meshes[i];
+ Ref<Mesh> mesh = meshes[i + 1];
+ if (!mesh.is_valid())
+ continue;
- Transform xf = get_global_transform().affine_inverse() * (s->get_global_transform() * mxf);
+ Rect3 aabb = mesh->get_aabb();
- if (Rect3(-extents, extents * 2).intersects(xf.xform(aabb))) {
- Baker::PlotMesh pm;
- pm.local_xform = xf;
- pm.mesh = mesh;
- p_baker->mesh_list.push_back(pm);
+ Transform xf = get_global_transform().affine_inverse() * (s->get_global_transform() * mxf);
+
+ if (Rect3(-extents, extents * 2).intersects(xf.xform(aabb))) {
+ Baker::PlotMesh pm;
+ pm.local_xform = xf;
+ pm.mesh = mesh;
+ p_baker->mesh_list.push_back(pm);
+ }
}
}
}
diff --git a/scene/3d/light.cpp b/scene/3d/light.cpp
index 09b253b309..d410ba1e2a 100644
--- a/scene/3d/light.cpp
+++ b/scene/3d/light.cpp
@@ -230,7 +230,6 @@ void Light::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "shadow_color", PROPERTY_HINT_COLOR_NO_ALPHA), "set_shadow_color", "get_shadow_color");
ADD_PROPERTYI(PropertyInfo(Variant::REAL, "shadow_bias", PROPERTY_HINT_RANGE, "-16,16,0.01"), "set_param", "get_param", PARAM_SHADOW_BIAS);
ADD_PROPERTYI(PropertyInfo(Variant::REAL, "shadow_contact", PROPERTY_HINT_RANGE, "0,16,0.01"), "set_param", "get_param", PARAM_CONTACT_SHADOW_SIZE);
- ADD_PROPERTYI(PropertyInfo(Variant::REAL, "shadow_max_distance", PROPERTY_HINT_RANGE, "0,65536,0.1"), "set_param", "get_param", PARAM_SHADOW_MAX_DISTANCE);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "shadow_reverse_cull_face"), "set_shadow_reverse_cull_face", "get_shadow_reverse_cull_face");
ADD_GROUP("Editor", "");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "editor_only"), "set_editor_only", "is_editor_only");
@@ -308,6 +307,18 @@ DirectionalLight::ShadowMode DirectionalLight::get_shadow_mode() const {
return shadow_mode;
}
+void DirectionalLight::set_shadow_depth_range(ShadowDepthRange p_range) {
+ shadow_depth_range=p_range;
+ VS::get_singleton()->light_directional_set_shadow_depth_range_mode(light, VS::LightDirectionalShadowDepthRangeMode(p_range));
+
+}
+
+DirectionalLight::ShadowDepthRange DirectionalLight::get_shadow_depth_range() const {
+
+ return shadow_depth_range;
+}
+
+
void DirectionalLight::set_blend_splits(bool p_enable) {
blend_splits = p_enable;
@@ -324,6 +335,9 @@ void DirectionalLight::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_shadow_mode", "mode"), &DirectionalLight::set_shadow_mode);
ClassDB::bind_method(D_METHOD("get_shadow_mode"), &DirectionalLight::get_shadow_mode);
+ ClassDB::bind_method(D_METHOD("set_shadow_depth_range", "mode"), &DirectionalLight::set_shadow_depth_range);
+ ClassDB::bind_method(D_METHOD("get_shadow_depth_range"), &DirectionalLight::get_shadow_depth_range);
+
ClassDB::bind_method(D_METHOD("set_blend_splits", "enabled"), &DirectionalLight::set_blend_splits);
ClassDB::bind_method(D_METHOD("is_blend_splits_enabled"), &DirectionalLight::is_blend_splits_enabled);
@@ -335,10 +349,15 @@ void DirectionalLight::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "directional_shadow_blend_splits"), "set_blend_splits", "is_blend_splits_enabled");
ADD_PROPERTYI(PropertyInfo(Variant::REAL, "directional_shadow_normal_bias", PROPERTY_HINT_RANGE, "0,16,0.01"), "set_param", "get_param", PARAM_SHADOW_NORMAL_BIAS);
ADD_PROPERTYI(PropertyInfo(Variant::REAL, "directional_shadow_bias_split_scale", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_param", "get_param", PARAM_SHADOW_BIAS_SPLIT_SCALE);
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "directional_shadow_depth_range", PROPERTY_HINT_ENUM, "Stable,Optimized"), "set_shadow_depth_range", "get_shadow_depth_range");
+ ADD_PROPERTYI(PropertyInfo(Variant::REAL, "directional_shadow_max_distance", PROPERTY_HINT_RANGE, "0,65536,0.1"), "set_param", "get_param", PARAM_SHADOW_MAX_DISTANCE);
BIND_ENUM_CONSTANT(SHADOW_ORTHOGONAL);
BIND_ENUM_CONSTANT(SHADOW_PARALLEL_2_SPLITS);
BIND_ENUM_CONSTANT(SHADOW_PARALLEL_4_SPLITS);
+
+ BIND_ENUM_CONSTANT( SHADOW_DEPTH_RANGE_STABLE );
+ BIND_ENUM_CONSTANT( SHADOW_DEPTH_RANGE_OPTIMIZED );
}
DirectionalLight::DirectionalLight()
@@ -349,6 +368,8 @@ DirectionalLight::DirectionalLight()
set_param(PARAM_SHADOW_MAX_DISTANCE, 200);
set_param(PARAM_SHADOW_BIAS_SPLIT_SCALE, 0.25);
set_shadow_mode(SHADOW_PARALLEL_4_SPLITS);
+ set_shadow_depth_range(SHADOW_DEPTH_RANGE_STABLE);
+
blend_splits = false;
}
diff --git a/scene/3d/light.h b/scene/3d/light.h
index 5d589d33e5..6aa0220265 100644
--- a/scene/3d/light.h
+++ b/scene/3d/light.h
@@ -133,9 +133,15 @@ public:
SHADOW_PARALLEL_4_SPLITS
};
+ enum ShadowDepthRange {
+ SHADOW_DEPTH_RANGE_STABLE = VS::LIGHT_DIRECTIONAL_SHADOW_DEPTH_RANGE_STABLE,
+ SHADOW_DEPTH_RANGE_OPTIMIZED = VS::LIGHT_DIRECTIONAL_SHADOW_DEPTH_RANGE_OPTIMIZED,
+ };
+
private:
bool blend_splits;
ShadowMode shadow_mode;
+ ShadowDepthRange shadow_depth_range;
protected:
static void _bind_methods();
@@ -144,6 +150,9 @@ public:
void set_shadow_mode(ShadowMode p_mode);
ShadowMode get_shadow_mode() const;
+ void set_shadow_depth_range(ShadowDepthRange p_mode);
+ ShadowDepthRange get_shadow_depth_range() const;
+
void set_blend_splits(bool p_enable);
bool is_blend_splits_enabled() const;
@@ -151,6 +160,7 @@ public:
};
VARIANT_ENUM_CAST(DirectionalLight::ShadowMode)
+VARIANT_ENUM_CAST(DirectionalLight::ShadowDepthRange)
class OmniLight : public Light {
diff --git a/scene/3d/physics_body.cpp b/scene/3d/physics_body.cpp
index 9590394211..6a8226c0e1 100644
--- a/scene/3d/physics_body.cpp
+++ b/scene/3d/physics_body.cpp
@@ -912,35 +912,24 @@ RigidBody::~RigidBody() {
//////////////////////////////////////////////////////
//////////////////////////
-Dictionary KinematicBody::_move(const Vector3 &p_motion) {
+Ref<KinematicCollision> KinematicBody::_move(const Vector3 &p_motion) {
Collision col;
- if (move(p_motion, col)) {
- Dictionary d;
- d["position"] = col.collision;
- d["normal"] = col.normal;
- d["local_shape"] = col.local_shape;
- d["travel"] = col.travel;
- d["remainder"] = col.remainder;
- d["collider_id"] = col.collider;
- if (col.collider) {
- d["collider"] = ObjectDB::get_instance(col.collider);
- } else {
- d["collider"] = Variant();
+ if (move_and_collide(p_motion, col)) {
+ if (motion_cache.is_null()) {
+ motion_cache.instance();
+ motion_cache->owner = this;
}
- d["collider_velocity"] = col.collider_vel;
- d["collider_shape_index"] = col.collider_shape;
- d["collider_metadata"] = col.collider_metadata;
-
- return d;
+ motion_cache->collision = col;
- } else {
- return Dictionary();
+ return motion_cache;
}
+
+ return Ref<KinematicCollision>();
}
-bool KinematicBody::move(const Vector3 &p_motion, Collision &r_collision) {
+bool KinematicBody::move_and_collide(const Vector3 &p_motion, Collision &r_collision) {
Transform gt = get_global_transform();
PhysicsServer::MotionResult result;
@@ -964,7 +953,7 @@ bool KinematicBody::move(const Vector3 &p_motion, Collision &r_collision) {
return colliding;
}
-Vector3 KinematicBody::move_and_slide(const Vector3 &p_linear_velocity, const Vector3 &p_floor_direction, float p_slope_stop_min_velocity, int p_max_bounces, float p_floor_max_angle) {
+Vector3 KinematicBody::move_and_slide(const Vector3 &p_linear_velocity, const Vector3 &p_floor_direction, float p_slope_stop_min_velocity, int p_max_slides, float p_floor_max_angle) {
Vector3 motion = (floor_velocity + p_linear_velocity) * get_fixed_process_delta_time();
Vector3 lv = p_linear_velocity;
@@ -975,11 +964,11 @@ Vector3 KinematicBody::move_and_slide(const Vector3 &p_linear_velocity, const Ve
colliders.clear();
floor_velocity = Vector3();
- while (p_max_bounces) {
+ while (p_max_slides) {
Collision collision;
- bool collided = move(motion, collision);
+ bool collided = move_and_collide(motion, collision);
if (collided) {
@@ -1017,7 +1006,7 @@ Vector3 KinematicBody::move_and_slide(const Vector3 &p_linear_velocity, const Ve
break;
}
- p_max_bounces--;
+ p_max_slides--;
if (motion == Vector3())
break;
}
@@ -1059,79 +1048,36 @@ float KinematicBody::get_safe_margin() const {
return margin;
}
-
-int KinematicBody::get_collision_count() const {
+int KinematicBody::get_slide_count() const {
return colliders.size();
}
-Vector3 KinematicBody::get_collision_position(int p_collision) const {
-
- ERR_FAIL_INDEX_V(p_collision, colliders.size(), Vector3());
- return colliders[p_collision].collision;
-}
-Vector3 KinematicBody::get_collision_normal(int p_collision) const {
- ERR_FAIL_INDEX_V(p_collision, colliders.size(), Vector3());
- return colliders[p_collision].normal;
+KinematicBody::Collision KinematicBody::get_slide_collision(int p_bounce) const {
+ ERR_FAIL_INDEX_V(p_bounce, colliders.size(), Collision());
+ return colliders[p_bounce];
}
-Vector3 KinematicBody::get_collision_travel(int p_collision) const {
- ERR_FAIL_INDEX_V(p_collision, colliders.size(), Vector3());
- return colliders[p_collision].travel;
-}
-Vector3 KinematicBody::get_collision_remainder(int p_collision) const {
- ERR_FAIL_INDEX_V(p_collision, colliders.size(), Vector3());
- return colliders[p_collision].remainder;
-}
-Object *KinematicBody::get_collision_local_shape(int p_collision) const {
- ERR_FAIL_INDEX_V(p_collision, colliders.size(), NULL);
- uint32_t owner = shape_find_owner(colliders[p_collision].local_shape);
- return shape_owner_get_owner(owner);
-}
-Object *KinematicBody::get_collision_collider(int p_collision) const {
- ERR_FAIL_INDEX_V(p_collision, colliders.size(), NULL);
+Ref<KinematicCollision> KinematicBody::_get_slide_collision(int p_bounce) {
- if (colliders[p_collision].collider) {
- return ObjectDB::get_instance(colliders[p_collision].collider);
+ ERR_FAIL_INDEX_V(p_bounce, colliders.size(), Ref<KinematicCollision>());
+ if (p_bounce > slide_colliders.size()) {
+ slide_colliders.resize(p_bounce + 1);
}
- return NULL;
-}
-ObjectID KinematicBody::get_collision_collider_id(int p_collision) const {
- ERR_FAIL_INDEX_V(p_collision, colliders.size(), 0);
-
- return colliders[p_collision].collider;
-}
-Object *KinematicBody::get_collision_collider_shape(int p_collision) const {
- ERR_FAIL_INDEX_V(p_collision, colliders.size(), NULL);
- Object *collider = get_collision_collider(p_collision);
- if (collider) {
- CollisionObject *obj2d = Object::cast_to<CollisionObject>(collider);
- if (obj2d) {
- uint32_t owner = shape_find_owner(colliders[p_collision].collider_shape);
- return obj2d->shape_owner_get_owner(owner);
- }
+ if (slide_colliders[p_bounce].is_null()) {
+ slide_colliders[p_bounce].instance();
+ slide_colliders[p_bounce]->owner = this;
}
- return NULL;
-}
-int KinematicBody::get_collision_collider_shape_index(int p_collision) const {
- ERR_FAIL_INDEX_V(p_collision, colliders.size(), -1);
- return colliders[p_collision].collider_shape;
-}
-Vector3 KinematicBody::get_collision_collider_velocity(int p_collision) const {
- ERR_FAIL_INDEX_V(p_collision, colliders.size(), Vector3());
- return colliders[p_collision].collider_vel;
-}
-Variant KinematicBody::get_collision_collider_metadata(int p_collision) const {
- ERR_FAIL_INDEX_V(p_collision, colliders.size(), Variant());
- return colliders[p_collision].collider_metadata;
+ slide_colliders[p_bounce]->collision = colliders[p_bounce];
+ return slide_colliders[p_bounce];
}
void KinematicBody::_bind_methods() {
- ClassDB::bind_method(D_METHOD("move", "rel_vec"), &KinematicBody::_move);
- ClassDB::bind_method(D_METHOD("move_and_slide", "linear_velocity", "floor_normal", "slope_stop_min_velocity", "max_bounces", "floor_max_angle"), &KinematicBody::move_and_slide, DEFVAL(Vector3(0, 0, 0)), DEFVAL(0.05), DEFVAL(4), DEFVAL(Math::deg2rad((float)45)));
+ ClassDB::bind_method(D_METHOD("move_and_collide", "rel_vec"), &KinematicBody::_move);
+ ClassDB::bind_method(D_METHOD("move_and_slide", "linear_velocity", "floor_normal", "slope_stop_min_velocity", "max_slides", "floor_max_angle"), &KinematicBody::move_and_slide, DEFVAL(Vector3(0, 0, 0)), DEFVAL(0.05), DEFVAL(4), DEFVAL(Math::deg2rad((float)45)));
ClassDB::bind_method(D_METHOD("test_move", "from", "rel_vec"), &KinematicBody::test_move);
@@ -1143,18 +1089,8 @@ void KinematicBody::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_safe_margin", "pixels"), &KinematicBody::set_safe_margin);
ClassDB::bind_method(D_METHOD("get_safe_margin"), &KinematicBody::get_safe_margin);
- ClassDB::bind_method(D_METHOD("get_collision_count"), &KinematicBody::get_collision_count);
- ClassDB::bind_method(D_METHOD("get_collision_position", "collision"), &KinematicBody::get_collision_position);
- ClassDB::bind_method(D_METHOD("get_collision_normal", "collision"), &KinematicBody::get_collision_normal);
- ClassDB::bind_method(D_METHOD("get_collision_travel", "collision"), &KinematicBody::get_collision_travel);
- ClassDB::bind_method(D_METHOD("get_collision_remainder", "collision"), &KinematicBody::get_collision_remainder);
- ClassDB::bind_method(D_METHOD("get_collision_local_shape", "collision"), &KinematicBody::get_collision_local_shape);
- ClassDB::bind_method(D_METHOD("get_collision_collider", "collision"), &KinematicBody::get_collision_collider);
- ClassDB::bind_method(D_METHOD("get_collision_collider_id", "collision"), &KinematicBody::get_collision_collider_id);
- ClassDB::bind_method(D_METHOD("get_collision_collider_shape", "collision"), &KinematicBody::get_collision_collider_shape);
- ClassDB::bind_method(D_METHOD("get_collision_collider_shape_index", "collision"), &KinematicBody::get_collision_collider_shape_index);
- ClassDB::bind_method(D_METHOD("get_collision_collider_velocity", "collision"), &KinematicBody::get_collision_collider_velocity);
- ClassDB::bind_method(D_METHOD("get_collision_collider_metadata", "collision"), &KinematicBody::get_collision_collider_metadata);
+ ClassDB::bind_method(D_METHOD("get_slide_count"), &KinematicBody::get_slide_count);
+ ClassDB::bind_method(D_METHOD("get_slide_collision", "slide_idx"), &KinematicBody::_get_slide_collision);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "collision/safe_margin", PROPERTY_HINT_RANGE, "0.001,256,0.001"), "set_safe_margin", "get_safe_margin");
}
@@ -1169,4 +1105,106 @@ KinematicBody::KinematicBody()
on_wall = false;
}
KinematicBody::~KinematicBody() {
+
+ if (motion_cache.is_valid()) {
+ motion_cache->owner = NULL;
+ }
+
+ for (int i = 0; i < slide_colliders.size(); i++) {
+ if (slide_colliders[i].is_valid()) {
+ slide_colliders[i]->owner = NULL;
+ }
+ }
+}
+///////////////////////////////////////
+
+Vector3 KinematicCollision::get_position() const {
+
+ return collision.collision;
+}
+Vector3 KinematicCollision::get_normal() const {
+ return collision.normal;
+}
+Vector3 KinematicCollision::get_travel() const {
+ return collision.travel;
+}
+Vector3 KinematicCollision::get_remainder() const {
+ return collision.remainder;
+}
+Object *KinematicCollision::get_local_shape() const {
+ ERR_FAIL_COND_V(!owner, NULL);
+ uint32_t ownerid = owner->shape_find_owner(collision.local_shape);
+ return owner->shape_owner_get_owner(ownerid);
+}
+
+Object *KinematicCollision::get_collider() const {
+
+ if (collision.collider) {
+ return ObjectDB::get_instance(collision.collider);
+ }
+
+ return NULL;
+}
+ObjectID KinematicCollision::get_collider_id() const {
+
+ return collision.collider;
+}
+Object *KinematicCollision::get_collider_shape() const {
+
+ Object *collider = get_collider();
+ if (collider) {
+ CollisionObject *obj2d = Object::cast_to<CollisionObject>(collider);
+ if (obj2d) {
+ uint32_t ownerid = obj2d->shape_find_owner(collision.collider_shape);
+ return obj2d->shape_owner_get_owner(ownerid);
+ }
+ }
+
+ return NULL;
+}
+int KinematicCollision::get_collider_shape_index() const {
+
+ return collision.collider_shape;
+}
+Vector3 KinematicCollision::get_collider_velocity() const {
+
+ return collision.collider_vel;
+}
+Variant KinematicCollision::get_collider_metadata() const {
+
+ return Variant();
+}
+
+void KinematicCollision::_bind_methods() {
+
+ ClassDB::bind_method(D_METHOD("get_position"), &KinematicCollision::get_position);
+ ClassDB::bind_method(D_METHOD("get_normal"), &KinematicCollision::get_normal);
+ ClassDB::bind_method(D_METHOD("get_travel"), &KinematicCollision::get_travel);
+ ClassDB::bind_method(D_METHOD("get_remainder"), &KinematicCollision::get_remainder);
+ ClassDB::bind_method(D_METHOD("get_local_shape"), &KinematicCollision::get_local_shape);
+ ClassDB::bind_method(D_METHOD("get_collider"), &KinematicCollision::get_collider);
+ ClassDB::bind_method(D_METHOD("get_collider_id"), &KinematicCollision::get_collider_id);
+ ClassDB::bind_method(D_METHOD("get_collider_shape"), &KinematicCollision::get_collider_shape);
+ ClassDB::bind_method(D_METHOD("get_collider_shape_index"), &KinematicCollision::get_collider_shape_index);
+ ClassDB::bind_method(D_METHOD("get_collider_velocity"), &KinematicCollision::get_collider_velocity);
+ ClassDB::bind_method(D_METHOD("get_collider_metadata"), &KinematicCollision::get_collider_metadata);
+
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "position"), "", "get_position");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "normal"), "", "get_normal");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "travel"), "", "get_travel");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "remainder"), "", "get_remainder");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "local_shape"), "", "get_local_shape");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "collider"), "", "get_collider");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "collider_id"), "", "get_collider_id");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "collider_shape"), "", "get_collider_shape");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "collider_shape_index"), "", "get_collider_shape_index");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "collider_velocity"), "", "get_collider_velocity");
+ ADD_PROPERTY(PropertyInfo(Variant::NIL, "collider_metadata", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NIL_IS_VARIANT), "", "get_collider_metadata");
+}
+
+KinematicCollision::KinematicCollision() {
+ collision.collider = 0;
+ collision.collider_shape = 0;
+ collision.local_shape = 0;
+ owner = NULL;
}
diff --git a/scene/3d/physics_body.h b/scene/3d/physics_body.h
index 23d752ad76..f88b3860dc 100644
--- a/scene/3d/physics_body.h
+++ b/scene/3d/physics_body.h
@@ -261,6 +261,8 @@ public:
VARIANT_ENUM_CAST(RigidBody::Mode);
VARIANT_ENUM_CAST(RigidBody::AxisLock);
+class KinematicCollision;
+
class KinematicBody : public PhysicsBody {
GDCLASS(KinematicBody, PhysicsBody);
@@ -286,42 +288,62 @@ private:
bool on_ceiling;
bool on_wall;
Vector<Collision> colliders;
+ Vector<Ref<KinematicCollision> > slide_colliders;
+ Ref<KinematicCollision> motion_cache;
_FORCE_INLINE_ bool _ignores_mode(PhysicsServer::BodyMode) const;
- Dictionary _move(const Vector3 &p_motion);
+ Ref<KinematicCollision> _move(const Vector3 &p_motion);
+ Ref<KinematicCollision> _get_slide_collision(int p_bounce);
protected:
static void _bind_methods();
public:
- bool move(const Vector3 &p_motion, Collision &r_collision);
+ bool move_and_collide(const Vector3 &p_motion, Collision &r_collision);
bool test_move(const Transform &p_from, const Vector3 &p_motion);
void set_safe_margin(float p_margin);
float get_safe_margin() const;
- Vector3 move_and_slide(const Vector3 &p_linear_velocity, const Vector3 &p_floor_direction = Vector3(0, 0, 0), float p_slope_stop_min_velocity = 0.05, int p_max_bounces = 4, float p_floor_max_angle = Math::deg2rad((float)45));
+ Vector3 move_and_slide(const Vector3 &p_linear_velocity, const Vector3 &p_floor_direction = Vector3(0, 0, 0), float p_slope_stop_min_velocity = 0.05, int p_max_slides = 4, float p_floor_max_angle = Math::deg2rad((float)45));
bool is_on_floor() const;
bool is_on_wall() const;
bool is_on_ceiling() const;
Vector3 get_floor_velocity() const;
- int get_collision_count() const;
- Vector3 get_collision_position(int p_collision) const;
- Vector3 get_collision_normal(int p_collision) const;
- Vector3 get_collision_travel(int p_collision) const;
- Vector3 get_collision_remainder(int p_collision) const;
- Object *get_collision_local_shape(int p_collision) const;
- Object *get_collision_collider(int p_collision) const;
- ObjectID get_collision_collider_id(int p_collision) const;
- Object *get_collision_collider_shape(int p_collision) const;
- int get_collision_collider_shape_index(int p_collision) const;
- Vector3 get_collision_collider_velocity(int p_collision) const;
- Variant get_collision_collider_metadata(int p_collision) const;
+ int get_slide_count() const;
+ Collision get_slide_collision(int p_bounce) const;
KinematicBody();
~KinematicBody();
};
+class KinematicCollision : public Reference {
+
+ GDCLASS(KinematicCollision, Reference);
+
+ KinematicBody *owner;
+ friend class KinematicBody;
+ KinematicBody::Collision collision;
+
+protected:
+ static void _bind_methods();
+
+public:
+ Vector3 get_position() const;
+ Vector3 get_normal() const;
+ Vector3 get_travel() const;
+ Vector3 get_remainder() const;
+ Object *get_local_shape() const;
+ Object *get_collider() const;
+ ObjectID get_collider_id() const;
+ Object *get_collider_shape() const;
+ int get_collider_shape_index() const;
+ Vector3 get_collider_velocity() const;
+ Variant get_collider_metadata() const;
+
+ KinematicCollision();
+};
+
#endif // PHYSICS_BODY__H
diff --git a/scene/audio/audio_player.cpp b/scene/audio/audio_player.cpp
index 8bd924e7ce..341ae45ce8 100644
--- a/scene/audio/audio_player.cpp
+++ b/scene/audio/audio_player.cpp
@@ -304,7 +304,7 @@ void AudioStreamPlayer::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "stream", PROPERTY_HINT_RESOURCE_TYPE, "AudioStream"), "set_stream", "get_stream");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "volume_db", PROPERTY_HINT_RANGE, "-80,24"), "set_volume_db", "get_volume_db");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "playing", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "_set_playing", "_is_active");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "play", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "_set_playing", "_is_active");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "autoplay"), "set_autoplay", "is_autoplay_enabled");
ADD_PROPERTY(PropertyInfo(Variant::INT, "mix_target", PROPERTY_HINT_ENUM, "Stereo,Surround,Center"), "set_mix_target", "get_mix_target");
ADD_PROPERTY(PropertyInfo(Variant::STRING, "bus", PROPERTY_HINT_ENUM, ""), "set_bus", "get_bus");
diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp
index 8fd19e8655..5713a35b7a 100644
--- a/scene/gui/base_button.cpp
+++ b/scene/gui/base_button.cpp
@@ -87,14 +87,14 @@ void BaseButton::_gui_input(Ref<InputEvent> p_event) {
status.pressed = !status.pressed;
pressed();
- if (get_script_instance()) {
- Variant::CallError ce;
- get_script_instance()->call(SceneStringNames::get_singleton()->_pressed, NULL, 0, ce);
- }
+
emit_signal("pressed");
_unpress_group();
toggled(status.pressed);
+ if (get_script_instance()) {
+ get_script_instance()->call(SceneStringNames::get_singleton()->_toggled, status.pressed);
+ }
emit_signal("toggled", status.pressed);
}
@@ -143,10 +143,10 @@ void BaseButton::_gui_input(Ref<InputEvent> p_event) {
emit_signal("pressed");
toggled(status.pressed);
- emit_signal("toggled", status.pressed);
if (get_script_instance()) {
get_script_instance()->call(SceneStringNames::get_singleton()->_toggled, status.pressed);
}
+ emit_signal("toggled", status.pressed);
}
_unpress_group();
diff --git a/scene/gui/button_group.cpp b/scene/gui/button_group.cpp
deleted file mode 100644
index 336c88fe9d..0000000000
--- a/scene/gui/button_group.cpp
+++ /dev/null
@@ -1,168 +0,0 @@
-/*************************************************************************/
-/* button_group.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-#include "button_group.h"
-
-#if 0
-#include "base_button.h"
-
-void ButtonGroup::_add_button(BaseButton *p_button) {
-
- buttons.insert(p_button);
- p_button->set_toggle_mode(true);
- p_button->set_click_on_press(true);
- p_button->connect("pressed",this,"_pressed",make_binds(p_button));
-
-}
-
-void ButtonGroup::_remove_button(BaseButton *p_button){
-
- buttons.erase(p_button);
- p_button->disconnect("pressed",this,"_pressed");
-
-}
-
-void ButtonGroup::set_pressed_button(BaseButton *p_button) {
-
- _pressed(p_button);
-}
-
-void ButtonGroup::_pressed(Object *p_button) {
-
- ERR_FAIL_NULL(p_button);
- BaseButton *b=Object::cast_to<BaseButton>(p_button);
- ERR_FAIL_COND(!b);
-
- for(Set<BaseButton*>::Element *E=buttons.front();E;E=E->next()) {
-
- BaseButton *bb=E->get();
- bb->set_pressed( b==bb );
- if (b==bb){
- emit_signal("button_selected", b);
- }
- }
-}
-
-Array ButtonGroup::_get_button_list() const {
-
- List<BaseButton*> b;
- get_button_list(&b);
-
- b.sort_custom<Node::Comparator>();
-
- Array arr;
- arr.resize(b.size());
-
- int idx=0;
-
- for(List<BaseButton*>::Element *E=b.front();E;E=E->next(),idx++) {
-
- arr[idx]=E->get();
- }
-
- return arr;
-}
-
-void ButtonGroup::get_button_list(List<BaseButton*> *p_buttons) const {
-
- for(Set<BaseButton*>::Element *E=buttons.front();E;E=E->next()) {
-
- p_buttons->push_back(E->get());
- }
-}
-
-BaseButton *ButtonGroup::get_pressed_button() const {
-
- for(Set<BaseButton*>::Element *E=buttons.front();E;E=E->next()) {
-
- if (E->get()->is_pressed())
- return E->get();
- }
-
- return NULL;
-}
-
-BaseButton *ButtonGroup::get_focused_button() const{
-
- for(Set<BaseButton*>::Element *E=buttons.front();E;E=E->next()) {
-
- if (E->get()->has_focus())
- return E->get();
- }
-
- return NULL;
-
-}
-
-int ButtonGroup::get_pressed_button_index() const {
- //in tree order, this is bizarre
-
- ERR_FAIL_COND_V(!is_inside_tree(),0);
-
- BaseButton *pressed = get_pressed_button();
- if (!pressed)
- return -1;
-
- List<BaseButton*> blist;
- for(Set<BaseButton*>::Element *E=buttons.front();E;E=E->next()) {
-
- blist.push_back(E->get());
-
- }
-
- blist.sort_custom<Node::Comparator>();
-
- int idx=0;
- for(List<BaseButton*>::Element *E=blist.front();E;E=E->next()) {
-
- if (E->get()==pressed)
- return idx;
-
- idx++;
- }
-
- return -1;
-}
-
-void ButtonGroup::_bind_methods() {
-
- ClassDB::bind_method(D_METHOD("get_pressed_button"),&ButtonGroup::get_pressed_button);
- ClassDB::bind_method(D_METHOD("get_pressed_button_index"),&ButtonGroup::get_pressed_button_index);
- ClassDB::bind_method(D_METHOD("get_focused_button"),&ButtonGroup::get_focused_button);
- ClassDB::bind_method(D_METHOD("get_button_list"),&ButtonGroup::_get_button_list);
- ClassDB::bind_method(D_METHOD("_pressed"),&ButtonGroup::_pressed);
- ClassDB::bind_method(D_METHOD("set_pressed_button","button"),&ButtonGroup::_pressed);
-
- ADD_SIGNAL( MethodInfo("button_selected",PropertyInfo(Variant::OBJECT,"button",PROPERTY_HINT_RESOURCE_TYPE,"BaseButton")));
-}
-
-ButtonGroup::ButtonGroup() : BoxContainer(true)
-{
-}
-#endif
diff --git a/scene/gui/button_group.h b/scene/gui/button_group.h
deleted file mode 100644
index 6ebc0575d2..0000000000
--- a/scene/gui/button_group.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/*************************************************************************/
-/* button_group.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-#ifndef BUTTON_GROUP_H
-#define BUTTON_GROUP_H
-
-#include "scene/gui/box_container.h"
-
-#if 0
-class BaseButton;
-
-class ButtonGroup : public BoxContainer {
-
- GDCLASS(ButtonGroup,BoxContainer);
-
-
- Set<BaseButton*> buttons;
-
-
- Array _get_button_list() const;
- void _pressed(Object *p_button);
-
-protected:
-friend class BaseButton;
-
- void _add_button(BaseButton *p_button);
- void _remove_button(BaseButton *p_button);
-
- static void _bind_methods();
-public:
-
- void get_button_list(List<BaseButton*> *p_buttons) const;
- BaseButton *get_pressed_button() const;
- BaseButton *get_focused_button() const;
- void set_pressed_button(BaseButton *p_button);
- int get_pressed_button_index() const;
-
- ButtonGroup();
-};
-
-#endif
-#endif // BUTTON_GROUP_H
diff --git a/scene/gui/check_box.cpp b/scene/gui/check_box.cpp
index 21e2269141..e2b10a948f 100644
--- a/scene/gui/check_box.cpp
+++ b/scene/gui/check_box.cpp
@@ -29,7 +29,6 @@
/*************************************************************************/
#include "check_box.h"
-#include "button_group.h"
#include "servers/visual_server.h"
void CheckBox::_notification(int p_what) {
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index 961fccc804..7bf11e6712 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -1249,6 +1249,10 @@ void Control::_size_changed() {
new_size_cache.height = MAX(minimum_size.height, new_size_cache.height);
}
+ if (get_viewport()->is_snap_controls_to_pixels_enabled()) {
+ new_size_cache =new_size_cache.floor();
+ new_pos_cache = new_pos_cache.floor();
+ }
bool pos_changed = new_pos_cache != data.pos_cache;
bool size_changed = new_size_cache != data.size_cache;
diff --git a/scene/gui/graph_node.cpp b/scene/gui/graph_node.cpp
index 8730be0c06..bef0808fd0 100644
--- a/scene/gui/graph_node.cpp
+++ b/scene/gui/graph_node.cpp
@@ -270,7 +270,7 @@ void GraphNode::_notification(int p_what) {
}
}
- if (resizeable) {
+ if (resizable) {
draw_texture(resizer, get_size() - resizer->get_size());
}
}
@@ -594,7 +594,7 @@ void GraphNode::_gui_input(const Ref<InputEvent> &p_ev) {
Ref<Texture> resizer = get_icon("resizer");
- if (resizeable && mpos.x > get_size().x - resizer->get_width() && mpos.y > get_size().y - resizer->get_height()) {
+ if (resizable && mpos.x > get_size().x - resizer->get_width() && mpos.y > get_size().y - resizer->get_height()) {
resizing = true;
resizing_from = mpos;
@@ -645,15 +645,15 @@ bool GraphNode::is_comment() const {
return comment;
}
-void GraphNode::set_resizeable(bool p_enable) {
+void GraphNode::set_resizable(bool p_enable) {
- resizeable = p_enable;
+ resizable = p_enable;
update();
}
-bool GraphNode::is_resizeable() const {
+bool GraphNode::is_resizable() const {
- return resizeable;
+ return resizable;
}
void GraphNode::_bind_methods() {
@@ -678,8 +678,8 @@ void GraphNode::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_comment", "comment"), &GraphNode::set_comment);
ClassDB::bind_method(D_METHOD("is_comment"), &GraphNode::is_comment);
- ClassDB::bind_method(D_METHOD("set_resizeable", "resizeable"), &GraphNode::set_resizeable);
- ClassDB::bind_method(D_METHOD("is_resizeable"), &GraphNode::is_resizeable);
+ ClassDB::bind_method(D_METHOD("set_resizable", "resizable"), &GraphNode::set_resizable);
+ ClassDB::bind_method(D_METHOD("is_resizable"), &GraphNode::is_resizable);
ClassDB::bind_method(D_METHOD("set_selected", "selected"), &GraphNode::set_selected);
ClassDB::bind_method(D_METHOD("is_selected"), &GraphNode::is_selected);
@@ -702,7 +702,7 @@ void GraphNode::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::STRING, "title"), "set_title", "get_title");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "show_close"), "set_show_close_button", "is_close_button_visible");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "resizeable"), "set_resizeable", "is_resizeable");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "resizable"), "set_resizable", "is_resizable");
ADD_SIGNAL(MethodInfo("offset_changed"));
ADD_SIGNAL(MethodInfo("dragged", PropertyInfo(Variant::VECTOR2, "from"), PropertyInfo(Variant::VECTOR2, "to")));
@@ -722,7 +722,7 @@ GraphNode::GraphNode() {
connpos_dirty = true;
set_mouse_filter(MOUSE_FILTER_STOP);
comment = false;
- resizeable = false;
+ resizable = false;
resizing = false;
selected = false;
}
diff --git a/scene/gui/graph_node.h b/scene/gui/graph_node.h
index 416d711aab..a606e47acd 100644
--- a/scene/gui/graph_node.h
+++ b/scene/gui/graph_node.h
@@ -68,7 +68,7 @@ private:
bool show_close;
Vector2 offset;
bool comment;
- bool resizeable;
+ bool resizable;
bool resizing;
Vector2 resizing_from;
@@ -151,8 +151,8 @@ public:
void set_comment(bool p_enable);
bool is_comment() const;
- void set_resizeable(bool p_enable);
- bool is_resizeable() const;
+ void set_resizable(bool p_enable);
+ bool is_resizable() const;
virtual Size2 get_minimum_size() const;
diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp
index f8d82a339c..9a605c98f3 100644
--- a/scene/gui/item_list.cpp
+++ b/scene/gui/item_list.cpp
@@ -151,6 +151,20 @@ Color ItemList::get_item_custom_bg_color(int p_idx) const {
return items[p_idx].custom_bg;
}
+void ItemList::set_item_custom_fg_color(int p_idx, const Color &p_custom_fg_color) {
+
+ ERR_FAIL_INDEX(p_idx, items.size());
+
+ items[p_idx].custom_fg = p_custom_fg_color;
+}
+
+Color ItemList::get_item_custom_fg_color(int p_idx) const {
+
+ ERR_FAIL_INDEX_V(p_idx, items.size(), Color());
+
+ return items[p_idx].custom_fg;
+}
+
void ItemList::set_item_tag_icon(int p_idx, const Ref<Texture> &p_tag_icon) {
ERR_FAIL_INDEX(p_idx, items.size());
@@ -1021,7 +1035,7 @@ void ItemList::_notification(int p_what) {
else
max_len = size.x;
- Color modulate = items[i].selected ? font_color_selected : font_color;
+ Color modulate = items[i].selected ? font_color_selected : (items[i].custom_fg != Color() ? items[i].custom_fg : font_color);
if (items[i].disabled)
modulate.a *= 0.5;
diff --git a/scene/gui/item_list.h b/scene/gui/item_list.h
index 8166975408..673b7d8956 100644
--- a/scene/gui/item_list.h
+++ b/scene/gui/item_list.h
@@ -61,6 +61,7 @@ private:
bool tooltip_enabled;
Variant metadata;
String tooltip;
+ Color custom_fg;
Color custom_bg;
Rect2 rect_cache;
@@ -150,6 +151,9 @@ public:
void set_item_custom_bg_color(int p_idx, const Color &p_custom_bg_color);
Color get_item_custom_bg_color(int p_idx) const;
+ void set_item_custom_fg_color(int p_idx, const Color &p_custom_fg_color);
+ Color get_item_custom_fg_color(int p_idx) const;
+
void select(int p_idx, bool p_single = true);
void unselect(int p_idx);
bool is_selected(int p_idx) const;
diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp
index 66b4e6cec1..6a5f56c78c 100644
--- a/scene/gui/line_edit.cpp
+++ b/scene/gui/line_edit.cpp
@@ -631,7 +631,7 @@ void LineEdit::_notification(int p_what) {
if (has_icon("right_icon")) {
Ref<Texture> r_icon = Control::get_icon("right_icon");
ofs_max -= r_icon->get_width();
- r_icon->draw(ci, Point2(width - r_icon->get_width() - x_ofs, y_ofs), Color(1, 1, 1, disabled_alpha * .9));
+ r_icon->draw(ci, Point2(width - r_icon->get_width() - x_ofs, height / 2 - r_icon->get_height() / 2), Color(1, 1, 1, disabled_alpha * .9));
}
int caret_height = font->get_height() > y_area ? y_area : font->get_height();
diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp
index a3f116c883..ab2c2f445f 100644
--- a/scene/gui/rich_text_label.cpp
+++ b/scene/gui/rich_text_label.cpp
@@ -80,6 +80,10 @@ RichTextLabel::Item *RichTextLabel::_get_next_item(Item *p_item, bool p_free) {
return NULL;
}
+Rect2 RichTextLabel::_get_text_rect() {
+ Ref<StyleBox> style = get_stylebox("normal");
+ return Rect2(style->get_offset(), get_size() - style->get_minimum_size());
+}
void RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &y, int p_width, int p_line, ProcessMode p_mode, const Ref<Font> &p_base_font, const Color &p_base_color, const Point2i &p_click_pos, Item **r_click_item, int *r_click_char, bool *r_outside, int p_char_count) {
RID ci;
@@ -583,7 +587,7 @@ void RichTextLabel::_update_scroll() {
int total_height = 0;
if (main->lines.size())
- total_height = main->lines[main->lines.size() - 1].height_accum_cache;
+ total_height = main->lines[main->lines.size() - 1].height_accum_cache + get_stylebox("normal")->get_minimum_size().height;
bool exceeds = total_height > get_size().height && scroll_active;
@@ -641,7 +645,11 @@ void RichTextLabel::_notification(int p_what) {
_update_scroll();
RID ci = get_canvas_item();
+
Size2 size = get_size();
+ Rect2 text_rect = _get_text_rect();
+
+ draw_style_box(get_stylebox("normal"), Rect2(Point2(), size));
if (has_focus()) {
VisualServer::get_singleton()->canvas_item_add_clip_ignore(ci, true);
@@ -657,10 +665,10 @@ void RichTextLabel::_notification(int p_what) {
int total_chars = 0;
while (from_line < main->lines.size()) {
- if (main->lines[from_line].height_accum_cache >= ofs)
+ if (main->lines[from_line].height_accum_cache + _get_text_rect().get_position().y >= ofs)
break;
- from_line++;
total_chars += main->lines[from_line].char_count;
+ from_line++;
}
if (from_line >= main->lines.size())
@@ -672,7 +680,7 @@ void RichTextLabel::_notification(int p_what) {
while (y < size.height && from_line < main->lines.size()) {
- _process_line(main, Point2(), y, size.width - scroll_w, from_line, PROCESS_DRAW, base_font, base_color, Point2i(), NULL, NULL, NULL, total_chars);
+ _process_line(main, text_rect.get_position(), y, text_rect.get_size().width - scroll_w, from_line, PROCESS_DRAW, base_font, base_color, Point2i(), NULL, NULL, NULL, total_chars);
total_chars += main->lines[from_line].char_count;
from_line++;
}
@@ -686,7 +694,7 @@ void RichTextLabel::_find_click(ItemFrame *p_frame, const Point2i &p_click, Item
*r_click_item = NULL;
Size2 size = get_size();
-
+ Rect2 text_rect = _get_text_rect();
int ofs = vscroll->get_value();
//todo, change to binary search
@@ -706,9 +714,9 @@ void RichTextLabel::_find_click(ItemFrame *p_frame, const Point2i &p_click, Item
Ref<Font> base_font = get_font("normal_font");
Color base_color = get_color("default_color");
- while (y < size.height && from_line < p_frame->lines.size()) {
+ while (y < text_rect.get_size().height && from_line < p_frame->lines.size()) {
- _process_line(p_frame, Point2(), y, size.width - scroll_w, from_line, PROCESS_POINTER, base_font, base_color, p_click, r_click_item, r_click_char, r_outside);
+ _process_line(p_frame, text_rect.get_position(), y, text_rect.get_size().width - scroll_w, from_line, PROCESS_POINTER, base_font, base_color, p_click, r_click_item, r_click_char, r_outside);
if (r_click_item && *r_click_item)
return;
from_line++;
@@ -791,7 +799,7 @@ void RichTextLabel::_gui_input(Ref<InputEvent> p_event) {
Ref<InputEventKey> k = p_event;
if (k.is_valid()) {
- if (k->is_pressed() && !k->get_alt() && !k->get_shift() && !k->get_metakey()) {
+ if (k->is_pressed() && !k->get_alt() && !k->get_shift()) {
bool handled = true;
switch (k->get_scancode()) {
case KEY_PAGEUP: {
@@ -1015,13 +1023,14 @@ void RichTextLabel::_validate_line_caches(ItemFrame *p_frame) {
//validate invalid lines!s
Size2 size = get_size();
+ Rect2 text_rect = _get_text_rect();
Ref<Font> base_font = get_font("normal_font");
for (int i = p_frame->first_invalid_line; i < p_frame->lines.size(); i++) {
int y = 0;
- _process_line(p_frame, Point2(), y, size.width - scroll_w, i, PROCESS_CACHE, base_font, Color());
+ _process_line(p_frame, text_rect.get_position(), y, text_rect.get_size().width - scroll_w, i, PROCESS_CACHE, base_font, Color());
p_frame->lines[i].height_cache = y;
p_frame->lines[i].height_accum_cache = y;
@@ -1031,7 +1040,7 @@ void RichTextLabel::_validate_line_caches(ItemFrame *p_frame) {
int total_height = 0;
if (p_frame->lines.size())
- total_height = p_frame->lines[p_frame->lines.size() - 1].height_accum_cache;
+ total_height = p_frame->lines[p_frame->lines.size() - 1].height_accum_cache + get_stylebox("normal")->get_minimum_size().height;
main->first_invalid_line = p_frame->lines.size();
diff --git a/scene/gui/rich_text_label.h b/scene/gui/rich_text_label.h
index 74bf180b5d..4db2c3a8e9 100644
--- a/scene/gui/rich_text_label.h
+++ b/scene/gui/rich_text_label.h
@@ -276,6 +276,8 @@ private:
void _gui_input(Ref<InputEvent> p_event);
Item *_get_next_item(Item *p_item, bool p_free = false);
+ Rect2 _get_text_rect();
+
bool use_bbcode;
String bbcode;
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index ade665b418..1738e303aa 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -2136,15 +2136,25 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
break;
}
}
- if (auto_indent) {
- // indent once again if previous line will end with ':'
- // (i.e. colon precedes current cursor position)
- if (cursor.column > 0 && text[cursor.line][cursor.column - 1] == ':') {
+
+ bool brace_indent = false;
+
+ // no need to indent if we are going upwards.
+ if (auto_indent && !(k->get_command() && k->get_shift())) {
+ // indent once again if previous line will end with ':' or '{'
+ // (i.e. colon/brace precedes current cursor position)
+ if (cursor.column > 0 && (text[cursor.line][cursor.column - 1] == ':' || text[cursor.line][cursor.column - 1] == '{')) {
if (indent_using_spaces) {
ins += space_indent;
} else {
ins += "\t";
}
+
+ // no need to move the brace below if we are not taking the text with us.
+ if (text[cursor.line][cursor.column] == '}' && !k->get_command()) {
+ brace_indent = true;
+ ins += "\n" + ins.substr(1, ins.length() - 2);
+ }
}
}
@@ -2168,6 +2178,9 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
if (first_line) {
cursor_set_line(0);
+ } else if (brace_indent) {
+ cursor_set_line(cursor.line - 1);
+ cursor_set_column(text[cursor.line].length());
}
} break;
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index 5e15bceb7d..de17416d8e 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -1116,7 +1116,8 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
cache.selected->draw(ci, r);
}
if (text_editor->is_visible_in_tree()) {
- text_editor->set_position(get_global_position() + r.position);
+ Vector2 ofs(0, (text_editor->get_size().height - r.size.height) / 2);
+ text_editor->set_position(get_global_position() + r.position - ofs);
}
}
@@ -2572,7 +2573,8 @@ bool Tree::edit_selected() {
} else if (c.mode == TreeItem::CELL_MODE_STRING || c.mode == TreeItem::CELL_MODE_RANGE || c.mode == TreeItem::CELL_MODE_RANGE_EXPRESSION) {
- Point2i textedpos = get_global_position() + rect.position;
+ Vector2 ofs(0, (text_editor->get_size().height - rect.size.height) / 2);
+ Point2i textedpos = get_global_position() + rect.position - ofs;
text_editor->set_position(textedpos);
text_editor->set_size(rect.size);
text_editor->clear();
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index c71a280755..434d594bbb 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -2578,6 +2578,17 @@ int Viewport::get_render_info(RenderInfo p_info) {
return VS::get_singleton()->viewport_get_render_info(viewport, VS::ViewportRenderInfo(p_info));
}
+void Viewport::set_snap_controls_to_pixels(bool p_enable) {
+
+ snap_controls_to_pixels=p_enable;
+}
+
+bool Viewport::is_snap_controls_to_pixels_enabled() const {
+
+ return snap_controls_to_pixels;
+}
+
+
void Viewport::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_use_arvr", "use"), &Viewport::set_use_arvr);
@@ -2680,6 +2691,9 @@ void Viewport::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_shadow_atlas_size", "size"), &Viewport::set_shadow_atlas_size);
ClassDB::bind_method(D_METHOD("get_shadow_atlas_size"), &Viewport::get_shadow_atlas_size);
+ ClassDB::bind_method(D_METHOD("set_snap_controls_to_pixels", "enabled"), &Viewport::set_snap_controls_to_pixels);
+ ClassDB::bind_method(D_METHOD("is_snap_controls_to_pixels_enabled"), &Viewport::is_snap_controls_to_pixels_enabled);
+
ClassDB::bind_method(D_METHOD("set_shadow_atlas_quadrant_subdiv", "quadrant", "subdiv"), &Viewport::set_shadow_atlas_quadrant_subdiv);
ClassDB::bind_method(D_METHOD("get_shadow_atlas_quadrant_subdiv", "quadrant"), &Viewport::get_shadow_atlas_quadrant_subdiv);
@@ -2707,6 +2721,7 @@ void Viewport::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "physics_object_picking"), "set_physics_object_picking", "get_physics_object_picking");
ADD_GROUP("GUI", "gui_");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "gui_disable_input"), "set_disable_input", "is_input_disabled");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "gui_snap_controls_to_pixels"), "set_snap_controls_to_pixels", "is_snap_controls_to_pixels_enabled");
ADD_GROUP("Shadow Atlas", "shadow_atlas_");
ADD_PROPERTY(PropertyInfo(Variant::INT, "shadow_atlas_size"), "set_shadow_atlas_size", "get_shadow_atlas_size");
ADD_PROPERTYI(PropertyInfo(Variant::INT, "shadow_atlas_quad_0", PROPERTY_HINT_ENUM, "Disabled,1 Shadow,4 Shadows,16 Shadows,64 Shadows,256 Shadows,1024 Shadows"), "set_shadow_atlas_quadrant_subdiv", "get_shadow_atlas_quadrant_subdiv", 0);
@@ -2822,6 +2837,8 @@ Viewport::Viewport() {
usage = USAGE_3D;
debug_draw = DEBUG_DRAW_DISABLED;
clear_mode = CLEAR_MODE_ALWAYS;
+
+ snap_controls_to_pixels = true;
}
Viewport::~Viewport() {
diff --git a/scene/main/viewport.h b/scene/main/viewport.h
index ce2bc991f5..6bbd4b26b5 100644
--- a/scene/main/viewport.h
+++ b/scene/main/viewport.h
@@ -1,3 +1,4 @@
+
/*************************************************************************/
/* viewport.h */
/*************************************************************************/
@@ -193,6 +194,8 @@ private:
bool filter;
bool gen_mipmaps;
+ bool snap_controls_to_pixels;
+
bool physics_object_picking;
List<Ref<InputEvent> > physics_picking_events;
ObjectID physics_object_capture;
@@ -463,6 +466,9 @@ public:
int get_render_info(RenderInfo p_info);
+ void set_snap_controls_to_pixels(bool p_enable);
+ bool is_snap_controls_to_pixels_enabled() const;
+
Viewport();
~Viewport();
};
diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp
index e01f5e3cdf..9ed3734a36 100644
--- a/scene/register_scene_types.cpp
+++ b/scene/register_scene_types.cpp
@@ -66,7 +66,6 @@
#include "scene/audio/audio_player.h"
#include "scene/gui/box_container.h"
#include "scene/gui/button.h"
-#include "scene/gui/button_group.h"
#include "scene/gui/center_container.h"
#include "scene/gui/check_box.h"
#include "scene/gui/check_button.h"
@@ -378,6 +377,7 @@ void register_scene_types() {
ClassDB::register_virtual_class<CollisionObject>();
ClassDB::register_class<StaticBody>();
ClassDB::register_class<RigidBody>();
+ ClassDB::register_class<KinematicCollision>();
ClassDB::register_class<KinematicBody>();
ClassDB::register_class<VehicleBody>();
diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp
index 4ff635edeb..fdea5960e5 100644
--- a/scene/resources/default_theme/default_theme.cpp
+++ b/scene/resources/default_theme/default_theme.cpp
@@ -794,6 +794,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
// RichTextLabel
theme->set_stylebox("focus", "RichTextLabel", focus);
+ theme->set_stylebox("normal", "RichTextLabel", make_stylebox(tree_bg_png, 3, 3, 3, 3));
theme->set_font("normal_font", "RichTextLabel", default_font);
theme->set_font("bold_font", "RichTextLabel", default_font);
diff --git a/scene/resources/environment.cpp b/scene/resources/environment.cpp
index 14225d945d..da3bc6a95b 100644
--- a/scene/resources/environment.cpp
+++ b/scene/resources/environment.cpp
@@ -269,13 +269,13 @@ Ref<Texture> Environment::get_adjustment_color_correction() const {
void Environment::_validate_property(PropertyInfo &property) const {
if (property.name == "background_sky" || property.name == "background_sky_scale" || property.name == "ambient_light/sky_contribution") {
- if (bg_mode != BG_SKY) {
+ if (bg_mode != BG_SKY && bg_mode != BG_COLOR_SKY) {
property.usage = PROPERTY_USAGE_NOEDITOR;
}
}
if (property.name == "background_color") {
- if (bg_mode != BG_COLOR) {
+ if (bg_mode != BG_COLOR && bg_mode != BG_COLOR_SKY) {
property.usage = PROPERTY_USAGE_NOEDITOR;
}
}
@@ -839,7 +839,7 @@ void Environment::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_ambient_light_sky_contribution"), &Environment::get_ambient_light_sky_contribution);
ADD_GROUP("Background", "background_");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "background_mode", PROPERTY_HINT_ENUM, "Clear Color,Custom Color,Sky,Canvas,Keep"), "set_background", "get_background");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "background_mode", PROPERTY_HINT_ENUM, "Clear Color,Custom Color,Sky,Color+Sky,Canvas,Keep"), "set_background", "get_background");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "background_sky", PROPERTY_HINT_RESOURCE_TYPE, "Sky"), "set_sky", "get_sky");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "background_sky_scale", PROPERTY_HINT_RANGE, "0,32,0.01"), "set_sky_scale", "get_sky_scale");
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "background_color"), "set_bg_color", "get_bg_color");
@@ -1118,6 +1118,7 @@ void Environment::_bind_methods() {
BIND_ENUM_CONSTANT(BG_CLEAR_COLOR);
BIND_ENUM_CONSTANT(BG_COLOR);
BIND_ENUM_CONSTANT(BG_SKY);
+ BIND_ENUM_CONSTANT(BG_COLOR_SKY);
BIND_ENUM_CONSTANT(BG_CANVAS);
BIND_ENUM_CONSTANT(BG_MAX);
diff --git a/scene/resources/environment.h b/scene/resources/environment.h
index 6337981b95..9046ec1e49 100644
--- a/scene/resources/environment.h
+++ b/scene/resources/environment.h
@@ -45,6 +45,7 @@ public:
BG_CLEAR_COLOR,
BG_COLOR,
BG_SKY,
+ BG_COLOR_SKY,
BG_CANVAS,
BG_KEEP,
BG_MAX
diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp
index f3d790eef5..a187692bcb 100644
--- a/scene/resources/material.cpp
+++ b/scene/resources/material.cpp
@@ -65,6 +65,12 @@ RID Material::get_rid() const {
return material;
}
+void Material::_validate_property(PropertyInfo &property) const {
+
+ if (!_can_do_next_pass() && property.name=="next_pass") {
+ property.usage=0;
+ }
+}
void Material::_bind_methods() {
@@ -204,6 +210,11 @@ void ShaderMaterial::get_argument_options(const StringName &p_function, int p_id
Resource::get_argument_options(p_function, p_idx, r_options);
}
+bool ShaderMaterial::_can_do_next_pass() const {
+
+ return shader.is_valid() && shader->get_mode()==Shader::MODE_SPATIAL;
+}
+
ShaderMaterial::ShaderMaterial() {
}
@@ -239,6 +250,7 @@ void SpatialMaterial::init_shaders() {
shader_names->anisotropy = "anisotropy_ratio";
shader_names->depth_scale = "depth_scale";
shader_names->subsurface_scattering_strength = "subsurface_scattering_strength";
+ shader_names->transmission = "transmission";
shader_names->refraction = "refraction";
shader_names->point_size = "point_size";
shader_names->uv1_scale = "uv1_scale";
@@ -276,6 +288,7 @@ void SpatialMaterial::init_shaders() {
shader_names->texture_names[TEXTURE_AMBIENT_OCCLUSION] = "texture_ambient_occlusion";
shader_names->texture_names[TEXTURE_DEPTH] = "texture_depth";
shader_names->texture_names[TEXTURE_SUBSURFACE_SCATTERING] = "texture_subsurface_scattering";
+ shader_names->texture_names[TEXTURE_TRANSMISSION] = "texture_transmission";
shader_names->texture_names[TEXTURE_REFRACTION] = "texture_refraction";
shader_names->texture_names[TEXTURE_DETAIL_MASK] = "texture_detail_mask";
shader_names->texture_names[TEXTURE_DETAIL_ALBEDO] = "texture_detail_albedo";
@@ -352,7 +365,7 @@ void SpatialMaterial::_update_shader() {
}
switch (diffuse_mode) {
case DIFFUSE_LAMBERT: code += ",diffuse_lambert"; break;
- case DIFFUSE_HALF_LAMBERT: code += ",diffuse_half_lambert"; break;
+ case DIFFUSE_LAMBERT_WRAP: code += ",diffuse_lambert_wrap"; break;
case DIFFUSE_OREN_NAYAR: code += ",diffuse_oren_nayar"; break;
case DIFFUSE_BURLEY: code += ",diffuse_burley"; break;
case DIFFUSE_TOON: code += ",diffuse_toon"; break;
@@ -451,6 +464,12 @@ void SpatialMaterial::_update_shader() {
code += "uniform sampler2D texture_subsurface_scattering : hint_white;\n";
}
+ if (features[FEATURE_TRANSMISSION]) {
+
+ code += "uniform vec4 transmission : hint_color;\n";
+ code += "uniform sampler2D texture_transmission : hint_black;\n";
+ }
+
if (features[FEATURE_DEPTH_MAPPING]) {
code += "uniform sampler2D texture_depth : hint_black;\n";
code += "uniform float depth_scale;\n";
@@ -766,6 +785,15 @@ void SpatialMaterial::_update_shader() {
code += "\tSSS_STRENGTH=subsurface_scattering_strength*sss_tex;\n";
}
+ if (features[FEATURE_TRANSMISSION]) {
+ if (flags[FLAG_UV1_USE_TRIPLANAR]) {
+ code += "\tvec3 transmission_tex = triplanar_texture(texture_transmission,uv1_power_normal,uv1_triplanar_pos).rgb;\n";
+ } else {
+ code += "\tvec3 transmission_tex = texture(texture_transmission,base_uv).rgb;\n";
+ }
+ code += "\tTRANSMISSION = (transmission.rgb+transmission_tex);\n";
+ }
+
if (features[FEATURE_DETAIL]) {
bool triplanar = (flags[FLAG_UV1_USE_TRIPLANAR] && detail_uv == DETAIL_UV_1) || (flags[FLAG_UV2_USE_TRIPLANAR] && detail_uv == DETAIL_UV_2);
@@ -1015,6 +1043,17 @@ float SpatialMaterial::get_subsurface_scattering_strength() const {
return subsurface_scattering_strength;
}
+void SpatialMaterial::set_transmission(const Color &p_transmission) {
+
+ transmission = p_transmission;
+ VS::get_singleton()->material_set_param(_get_material(), shader_names->transmission, transmission);
+}
+
+Color SpatialMaterial::get_transmission() const {
+
+ return transmission;
+}
+
void SpatialMaterial::set_refraction(float p_refraction) {
refraction = p_refraction;
@@ -1180,6 +1219,7 @@ void SpatialMaterial::_validate_property(PropertyInfo &property) const {
_validate_feature("ao", FEATURE_AMBIENT_OCCLUSION, property);
_validate_feature("depth", FEATURE_DEPTH_MAPPING, property);
_validate_feature("subsurf_scatter", FEATURE_SUBSURACE_SCATTERING, property);
+ _validate_feature("transmission", FEATURE_TRANSMISSION, property);
_validate_feature("refraction", FEATURE_REFRACTION, property);
_validate_feature("detail", FEATURE_DETAIL, property);
@@ -1530,6 +1570,9 @@ void SpatialMaterial::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_subsurface_scattering_strength", "strength"), &SpatialMaterial::set_subsurface_scattering_strength);
ClassDB::bind_method(D_METHOD("get_subsurface_scattering_strength"), &SpatialMaterial::get_subsurface_scattering_strength);
+ ClassDB::bind_method(D_METHOD("set_transmission", "transmission"), &SpatialMaterial::set_transmission);
+ ClassDB::bind_method(D_METHOD("get_transmission"), &SpatialMaterial::get_transmission);
+
ClassDB::bind_method(D_METHOD("set_refraction", "refraction"), &SpatialMaterial::set_refraction);
ClassDB::bind_method(D_METHOD("get_refraction"), &SpatialMaterial::get_refraction);
@@ -1721,6 +1764,11 @@ void SpatialMaterial::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::REAL, "subsurf_scatter_strength", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_subsurface_scattering_strength", "get_subsurface_scattering_strength");
ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "subsurf_scatter_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture", TEXTURE_SUBSURFACE_SCATTERING);
+ ADD_GROUP("Transmission", "transmission_");
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "transmission_enabled"), "set_feature", "get_feature", FEATURE_TRANSMISSION);
+ ADD_PROPERTY(PropertyInfo(Variant::COLOR, "transmission", PROPERTY_HINT_COLOR_NO_ALPHA), "set_transmission", "get_transmission");
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "transmission_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture", TEXTURE_TRANSMISSION);
+
ADD_GROUP("Refraction", "refraction_");
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "refraction_enabled"), "set_feature", "get_feature", FEATURE_REFRACTION);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "refraction_scale", PROPERTY_HINT_RANGE, "-1,1,0.01"), "set_refraction", "get_refraction");
@@ -1758,6 +1806,7 @@ void SpatialMaterial::_bind_methods() {
BIND_ENUM_CONSTANT(TEXTURE_AMBIENT_OCCLUSION);
BIND_ENUM_CONSTANT(TEXTURE_DEPTH);
BIND_ENUM_CONSTANT(TEXTURE_SUBSURFACE_SCATTERING);
+ BIND_ENUM_CONSTANT(TEXTURE_TRANSMISSION);
BIND_ENUM_CONSTANT(TEXTURE_REFRACTION);
BIND_ENUM_CONSTANT(TEXTURE_DETAIL_MASK);
BIND_ENUM_CONSTANT(TEXTURE_DETAIL_ALBEDO);
@@ -1776,6 +1825,7 @@ void SpatialMaterial::_bind_methods() {
BIND_ENUM_CONSTANT(FEATURE_AMBIENT_OCCLUSION);
BIND_ENUM_CONSTANT(FEATURE_DEPTH_MAPPING);
BIND_ENUM_CONSTANT(FEATURE_SUBSURACE_SCATTERING);
+ BIND_ENUM_CONSTANT(FEATURE_TRANSMISSION);
BIND_ENUM_CONSTANT(FEATURE_REFRACTION);
BIND_ENUM_CONSTANT(FEATURE_DETAIL);
BIND_ENUM_CONSTANT(FEATURE_MAX);
@@ -1809,7 +1859,7 @@ void SpatialMaterial::_bind_methods() {
BIND_ENUM_CONSTANT(FLAG_MAX);
BIND_ENUM_CONSTANT(DIFFUSE_LAMBERT);
- BIND_ENUM_CONSTANT(DIFFUSE_HALF_LAMBERT);
+ BIND_ENUM_CONSTANT(DIFFUSE_LAMBERT_WRAP);
BIND_ENUM_CONSTANT(DIFFUSE_OREN_NAYAR);
BIND_ENUM_CONSTANT(DIFFUSE_BURLEY);
BIND_ENUM_CONSTANT(DIFFUSE_TOON);
@@ -1850,6 +1900,7 @@ SpatialMaterial::SpatialMaterial()
set_anisotropy(0);
set_depth_scale(0.05);
set_subsurface_scattering_strength(0);
+ set_transmission(Color(0, 0, 0));
set_refraction(0.05);
set_line_width(1);
set_point_size(1);
diff --git a/scene/resources/material.h b/scene/resources/material.h
index d560d7af55..fdb11982a8 100644
--- a/scene/resources/material.h
+++ b/scene/resources/material.h
@@ -53,6 +53,9 @@ class Material : public Resource {
protected:
_FORCE_INLINE_ RID _get_material() const { return material; }
static void _bind_methods();
+ virtual bool _can_do_next_pass() const { return false; }
+
+ void _validate_property(PropertyInfo &property) const;
public:
enum {
@@ -84,6 +87,8 @@ protected:
void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const;
+ virtual bool _can_do_next_pass() const;
+
public:
void set_shader(const Ref<Shader> &p_shader);
Ref<Shader> get_shader() const;
@@ -112,6 +117,7 @@ public:
TEXTURE_AMBIENT_OCCLUSION,
TEXTURE_DEPTH,
TEXTURE_SUBSURFACE_SCATTERING,
+ TEXTURE_TRANSMISSION,
TEXTURE_REFRACTION,
TEXTURE_DETAIL_MASK,
TEXTURE_DETAIL_ALBEDO,
@@ -135,6 +141,7 @@ public:
FEATURE_AMBIENT_OCCLUSION,
FEATURE_DEPTH_MAPPING,
FEATURE_SUBSURACE_SCATTERING,
+ FEATURE_TRANSMISSION,
FEATURE_REFRACTION,
FEATURE_DETAIL,
FEATURE_MAX
@@ -179,7 +186,7 @@ public:
enum DiffuseMode {
DIFFUSE_LAMBERT,
- DIFFUSE_HALF_LAMBERT,
+ DIFFUSE_LAMBERT_WRAP,
DIFFUSE_OREN_NAYAR,
DIFFUSE_BURLEY,
DIFFUSE_TOON,
@@ -212,7 +219,7 @@ private:
union MaterialKey {
struct {
- uint64_t feature_mask : 11;
+ uint64_t feature_mask : 12;
uint64_t detail_uv : 1;
uint64_t blend_mode : 2;
uint64_t depth_draw_mode : 2;
@@ -286,6 +293,7 @@ private:
StringName anisotropy;
StringName depth_scale;
StringName subsurface_scattering_strength;
+ StringName transmission;
StringName refraction;
StringName point_size;
StringName uv1_scale;
@@ -337,6 +345,7 @@ private:
float anisotropy;
float depth_scale;
float subsurface_scattering_strength;
+ Color transmission;
float refraction;
float line_width;
float point_size;
@@ -390,6 +399,7 @@ private:
protected:
static void _bind_methods();
void _validate_property(PropertyInfo &property) const;
+ virtual bool _can_do_next_pass() const { return true; }
public:
void set_albedo(const Color &p_albedo);
@@ -443,6 +453,9 @@ public:
void set_subsurface_scattering_strength(float p_subsurface_scattering_strength);
float get_subsurface_scattering_strength() const;
+ void set_transmission(const Color &p_transmission);
+ Color get_transmission() const;
+
void set_refraction(float p_refraction);
float get_refraction() const;
diff --git a/scene/resources/mesh_library.cpp b/scene/resources/mesh_library.cpp
index 4e1ffd2ab3..833a4c3d22 100644
--- a/scene/resources/mesh_library.cpp
+++ b/scene/resources/mesh_library.cpp
@@ -214,7 +214,7 @@ Vector<int> MeshLibrary::get_item_list() const {
return ret;
}
-int MeshLibrary::find_item_name(const String &p_name) const {
+int MeshLibrary::find_item_by_name(const String &p_name) const {
for (Map<int, Item>::Element *E = item_map.front(); E; E = E->next()) {
@@ -275,6 +275,8 @@ void MeshLibrary::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_item_shapes", "id"), &MeshLibrary::_get_item_shapes);
ClassDB::bind_method(D_METHOD("get_item_preview", "id"), &MeshLibrary::get_item_preview);
ClassDB::bind_method(D_METHOD("remove_item", "id"), &MeshLibrary::remove_item);
+ ClassDB::bind_method(D_METHOD("find_item_by_name", "name"), &MeshLibrary::find_item_by_name);
+
ClassDB::bind_method(D_METHOD("clear"), &MeshLibrary::clear);
ClassDB::bind_method(D_METHOD("get_item_list"), &MeshLibrary::get_item_list);
ClassDB::bind_method(D_METHOD("get_last_unused_item_id"), &MeshLibrary::get_last_unused_item_id);
diff --git a/scene/resources/mesh_library.h b/scene/resources/mesh_library.h
index 99b6b48d61..c5d23ce50f 100644
--- a/scene/resources/mesh_library.h
+++ b/scene/resources/mesh_library.h
@@ -84,7 +84,7 @@ public:
void clear();
- int find_item_name(const String &p_name) const;
+ int find_item_by_name(const String &p_name) const;
Vector<int> get_item_list() const;
int get_last_unused_item_id() const;