summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--drivers/gles2/rasterizer_storage_gles2.cpp2
-rw-r--r--editor/plugins/animation_blend_tree_editor_plugin.cpp27
-rw-r--r--platform/javascript/os_javascript.cpp115
-rw-r--r--platform/javascript/os_javascript.h5
-rw-r--r--scene/2d/canvas_item.h2
-rw-r--r--scene/2d/collision_object_2d.cpp4
-rw-r--r--scene/2d/physics_body_2d.cpp41
-rw-r--r--scene/2d/physics_body_2d.h1
-rw-r--r--scene/animation/animation_blend_tree.cpp11
-rw-r--r--scene/animation/animation_blend_tree.h1
-rw-r--r--scene/animation/animation_tree.cpp45
-rw-r--r--scene/animation/animation_tree.h11
-rw-r--r--scene/main/canvas_layer.cpp19
-rw-r--r--scene/main/canvas_layer.h1
14 files changed, 173 insertions, 112 deletions
diff --git a/drivers/gles2/rasterizer_storage_gles2.cpp b/drivers/gles2/rasterizer_storage_gles2.cpp
index b1df65493f..262add1cc3 100644
--- a/drivers/gles2/rasterizer_storage_gles2.cpp
+++ b/drivers/gles2/rasterizer_storage_gles2.cpp
@@ -640,6 +640,8 @@ void RasterizerStorageGLES2::texture_set_flags(RID p_texture, uint32_t p_flags)
bool had_mipmaps = texture->flags & VS::TEXTURE_FLAG_MIPMAPS;
+ texture->flags = p_flags;
+
glActiveTexture(GL_TEXTURE0);
glBindTexture(texture->target, texture->tex_id);
diff --git a/editor/plugins/animation_blend_tree_editor_plugin.cpp b/editor/plugins/animation_blend_tree_editor_plugin.cpp
index 42e32b9788..9530fae8e4 100644
--- a/editor/plugins/animation_blend_tree_editor_plugin.cpp
+++ b/editor/plugins/animation_blend_tree_editor_plugin.cpp
@@ -650,8 +650,9 @@ void AnimationNodeBlendTreeEditor::_notification(int p_what) {
blend_tree->get_node_connections(&conns);
for (List<AnimationNodeBlendTree::NodeConnection>::Element *E = conns.front(); E; E = E->next()) {
float activity = 0;
+ StringName path = AnimationTreeEditor::get_singleton()->get_base_path() + E->get().input_node;
if (AnimationTreeEditor::get_singleton()->get_tree() && !AnimationTreeEditor::get_singleton()->get_tree()->is_state_invalid()) {
- activity = blend_tree->get_connection_activity(E->get().input_node, E->get().input_index);
+ activity = AnimationTreeEditor::get_singleton()->get_tree()->get_connection_activity(path, E->get().input_index);
}
graph->set_connection_activity(E->get().output_node, 0, E->get().input_node, E->get().input_index, activity);
}
@@ -777,6 +778,30 @@ void AnimationNodeBlendTreeEditor::_node_renamed(const String &p_text, Ref<Anima
visible_properties[i]->set_object_and_property(visible_properties[i]->get_edited_object(), new_name);
}
}
+
+ //recreate connections
+ graph->clear_connections();
+
+ List<AnimationNodeBlendTree::NodeConnection> connections;
+ blend_tree->get_node_connections(&connections);
+
+ for (List<AnimationNodeBlendTree::NodeConnection>::Element *E = connections.front(); E; E = E->next()) {
+
+ StringName from = E->get().output_node;
+ StringName to = E->get().input_node;
+ int to_idx = E->get().input_index;
+
+ graph->connect_node(from, 0, to, to_idx);
+ }
+
+ //update animations
+ for (Map<StringName, ProgressBar *>::Element *E = animations.front(); E; E = E->next()) {
+ if (E->key() == prev_name) {
+ animations[new_name] = animations[prev_name];
+ animations.erase(prev_name);
+ break;
+ }
+ }
}
void AnimationNodeBlendTreeEditor::_node_renamed_focus_out(Node *le, Ref<AnimationNode> p_node) {
diff --git a/platform/javascript/os_javascript.cpp b/platform/javascript/os_javascript.cpp
index a2c6bdd629..5a8a05d4df 100644
--- a/platform/javascript/os_javascript.cpp
+++ b/platform/javascript/os_javascript.cpp
@@ -71,14 +71,6 @@ static bool is_canvas_focused() {
static bool cursor_inside_canvas = true;
-EM_BOOL OS_JavaScript::browser_resize_callback(int p_event_type, const EmscriptenUiEvent *p_event, void *p_user_data) {
-
- // The order of the fullscreen change event and the window size change
- // event varies, even within just one browser, so defer handling.
- get_singleton()->canvas_size_adjustment_requested = true;
- return false;
-}
-
EM_BOOL OS_JavaScript::fullscreen_change_callback(int p_event_type, const EmscriptenFullscreenChangeEvent *p_event, void *p_user_data) {
OS_JavaScript *os = get_singleton();
@@ -88,7 +80,13 @@ EM_BOOL OS_JavaScript::fullscreen_change_callback(int p_event_type, const Emscri
// This event property is the only reliable data on
// browser fullscreen state.
os->video_mode.fullscreen = p_event->isFullscreen;
- os->canvas_size_adjustment_requested = true;
+ if (os->video_mode.fullscreen) {
+ os->entering_fullscreen = false;
+ } else {
+ // Restoring maximized window now will cause issues,
+ // so delay until main_loop_iterate.
+ os->just_exited_fullscreen = true;
+ }
}
return false;
}
@@ -114,14 +112,14 @@ Size2 OS_JavaScript::get_screen_size(int p_screen) const {
void OS_JavaScript::set_window_size(const Size2 p_size) {
windowed_size = p_size;
- if (is_window_fullscreen()) {
+ if (video_mode.fullscreen) {
window_maximized = false;
set_window_fullscreen(false);
- } else if (is_window_maximized()) {
- set_window_maximized(false);
} else {
- video_mode.width = p_size.x;
- video_mode.height = p_size.y;
+ if (window_maximized) {
+ emscripten_exit_soft_fullscreen();
+ window_maximized = false;
+ }
emscripten_set_canvas_size(p_size.x, p_size.y);
}
}
@@ -135,31 +133,22 @@ Size2 OS_JavaScript::get_window_size() const {
void OS_JavaScript::set_window_maximized(bool p_enabled) {
- window_maximized = p_enabled;
- if (is_window_fullscreen()) {
+ if (video_mode.fullscreen) {
+ window_maximized = p_enabled;
set_window_fullscreen(false);
- return;
- }
- // Calling emscripten_enter_soft_fullscreen mutltiple times hides all
- // page elements except the canvas permanently, so track state.
- if (p_enabled && !soft_fullscreen_enabled) {
-
+ } else if (!p_enabled) {
+ emscripten_exit_soft_fullscreen();
+ window_maximized = false;
+ } else if (!window_maximized) {
+ // Prevent calling emscripten_enter_soft_fullscreen mutltiple times,
+ // this would hide page elements permanently.
EmscriptenFullscreenStrategy strategy;
strategy.scaleMode = EMSCRIPTEN_FULLSCREEN_SCALE_STRETCH;
strategy.canvasResolutionScaleMode = EMSCRIPTEN_FULLSCREEN_CANVAS_SCALE_STDDEF;
strategy.filteringMode = EMSCRIPTEN_FULLSCREEN_FILTERING_DEFAULT;
strategy.canvasResizedCallback = NULL;
emscripten_enter_soft_fullscreen(NULL, &strategy);
- soft_fullscreen_enabled = true;
- video_mode.width = get_window_size().width;
- video_mode.height = get_window_size().height;
- } else if (!p_enabled) {
-
- emscripten_exit_soft_fullscreen();
- soft_fullscreen_enabled = false;
- video_mode.width = windowed_size.width;
- video_mode.height = windowed_size.height;
- emscripten_set_canvas_size(video_mode.width, video_mode.height);
+ window_maximized = p_enabled;
}
}
@@ -170,30 +159,33 @@ bool OS_JavaScript::is_window_maximized() const {
void OS_JavaScript::set_window_fullscreen(bool p_enabled) {
- if (p_enabled == is_window_fullscreen()) {
+ if (p_enabled == video_mode.fullscreen) {
return;
}
- // Just request changes here, if successful, canvas is resized in
- // _browser_resize_callback or _fullscreen_change_callback.
- EMSCRIPTEN_RESULT result;
+ // Just request changes here, if successful, logic continues in
+ // fullscreen_change_callback.
if (p_enabled) {
if (window_maximized) {
- // Soft fullsreen during real fulllscreen can cause issues.
- set_window_maximized(false);
- window_maximized = true;
+ // Soft fullsreen during real fullscreen can cause issues, so exit.
+ // This must be called before requesting full screen.
+ emscripten_exit_soft_fullscreen();
}
EmscriptenFullscreenStrategy strategy;
strategy.scaleMode = EMSCRIPTEN_FULLSCREEN_SCALE_STRETCH;
strategy.canvasResolutionScaleMode = EMSCRIPTEN_FULLSCREEN_CANVAS_SCALE_STDDEF;
strategy.filteringMode = EMSCRIPTEN_FULLSCREEN_FILTERING_DEFAULT;
strategy.canvasResizedCallback = NULL;
- emscripten_request_fullscreen_strategy(NULL, false, &strategy);
+ EMSCRIPTEN_RESULT result = emscripten_request_fullscreen_strategy(NULL, false, &strategy);
+ ERR_EXPLAIN("Enabling fullscreen is only possible from an input callback for the HTML5 platform");
+ ERR_FAIL_COND(result == EMSCRIPTEN_RESULT_FAILED_NOT_DEFERRED);
+ ERR_FAIL_COND(result != EMSCRIPTEN_RESULT_SUCCESS);
+ // Not fullscreen yet, so prevent "windowed" canvas dimensions from
+ // being overwritten.
+ entering_fullscreen = true;
} else {
- result = emscripten_exit_fullscreen();
- if (result != EMSCRIPTEN_RESULT_SUCCESS) {
- ERR_PRINTS("Failed to exit fullscreen: Code " + itos(result));
- }
+ // No logic allowed here, since exiting w/ ESC key won't use this function.
+ ERR_FAIL_COND(emscripten_exit_fullscreen() != EMSCRIPTEN_RESULT_SUCCESS);
}
}
@@ -725,7 +717,6 @@ Error OS_JavaScript::initialize(const VideoMode &p_desired, int p_video_driver,
SET_EM_CALLBACK("#canvas", keydown, keydown_callback)
SET_EM_CALLBACK("#canvas", keypress, keypress_callback)
SET_EM_CALLBACK("#canvas", keyup, keyup_callback)
- SET_EM_CALLBACK(NULL, resize, browser_resize_callback)
SET_EM_CALLBACK(NULL, fullscreenchange, fullscreen_change_callback)
SET_EM_CALLBACK_NOTARGET(gamepadconnected, gamepad_change_callback)
SET_EM_CALLBACK_NOTARGET(gamepaddisconnected, gamepad_change_callback)
@@ -794,18 +785,32 @@ bool OS_JavaScript::main_loop_iterate() {
/* clang-format on */
}
}
+
process_joypads();
- if (canvas_size_adjustment_requested) {
- if (video_mode.fullscreen || window_maximized) {
- video_mode.width = get_window_size().width;
- video_mode.height = get_window_size().height;
- }
- if (!video_mode.fullscreen) {
- set_window_maximized(window_maximized);
+ if (just_exited_fullscreen) {
+ if (window_maximized) {
+ EmscriptenFullscreenStrategy strategy;
+ strategy.scaleMode = EMSCRIPTEN_FULLSCREEN_SCALE_STRETCH;
+ strategy.canvasResolutionScaleMode = EMSCRIPTEN_FULLSCREEN_CANVAS_SCALE_STDDEF;
+ strategy.filteringMode = EMSCRIPTEN_FULLSCREEN_FILTERING_DEFAULT;
+ strategy.canvasResizedCallback = NULL;
+ emscripten_enter_soft_fullscreen(NULL, &strategy);
+ } else {
+ emscripten_set_canvas_size(windowed_size.width, windowed_size.height);
}
- canvas_size_adjustment_requested = false;
+ just_exited_fullscreen = false;
}
+
+ int canvas[3];
+ emscripten_get_canvas_size(canvas, canvas + 1, canvas + 2);
+ video_mode.width = canvas[0];
+ video_mode.height = canvas[1];
+ if (!window_maximized && !video_mode.fullscreen && !just_exited_fullscreen && !entering_fullscreen) {
+ windowed_size.width = canvas[0];
+ windowed_size.height = canvas[1];
+ }
+
return Main::iteration();
}
@@ -958,8 +963,8 @@ OS_JavaScript::OS_JavaScript(int p_argc, char *p_argv[]) {
set_cmdline(p_argv[0], arguments);
window_maximized = false;
- soft_fullscreen_enabled = false;
- canvas_size_adjustment_requested = false;
+ entering_fullscreen = false;
+ just_exited_fullscreen = false;
main_loop = NULL;
diff --git a/platform/javascript/os_javascript.h b/platform/javascript/os_javascript.h
index 915320fe39..f40fb8fc7e 100644
--- a/platform/javascript/os_javascript.h
+++ b/platform/javascript/os_javascript.h
@@ -44,8 +44,8 @@ class OS_JavaScript : public OS_Unix {
VideoMode video_mode;
Vector2 windowed_size;
bool window_maximized;
- bool soft_fullscreen_enabled;
- bool canvas_size_adjustment_requested;
+ bool entering_fullscreen;
+ bool just_exited_fullscreen;
InputDefault *input;
Ref<InputEventKey> deferred_key_event;
@@ -59,7 +59,6 @@ class OS_JavaScript : public OS_Unix {
int64_t sync_wait_time;
int64_t last_sync_check_time;
- static EM_BOOL browser_resize_callback(int p_event_type, const EmscriptenUiEvent *p_event, void *p_user_data);
static EM_BOOL fullscreen_change_callback(int p_event_type, const EmscriptenFullscreenChangeEvent *p_event, void *p_user_data);
static EM_BOOL keydown_callback(int p_event_type, const EmscriptenKeyboardEvent *p_event, void *p_user_data);
diff --git a/scene/2d/canvas_item.h b/scene/2d/canvas_item.h
index 85f8564ac2..1e6a251c9c 100644
--- a/scene/2d/canvas_item.h
+++ b/scene/2d/canvas_item.h
@@ -139,8 +139,6 @@ class CanvasItem : public Node {
GDCLASS(CanvasItem, Node);
- friend class CanvasLayer;
-
public:
enum BlendMode {
diff --git a/scene/2d/collision_object_2d.cpp b/scene/2d/collision_object_2d.cpp
index 52d04ac10a..1e2184bd41 100644
--- a/scene/2d/collision_object_2d.cpp
+++ b/scene/2d/collision_object_2d.cpp
@@ -38,7 +38,7 @@ void CollisionObject2D::_notification(int p_what) {
case NOTIFICATION_ENTER_TREE: {
- Transform2D global_transform = get_global_transform_with_canvas();
+ Transform2D global_transform = get_global_transform();
if (area)
Physics2DServer::get_singleton()->area_set_transform(rid, global_transform);
@@ -64,7 +64,7 @@ void CollisionObject2D::_notification(int p_what) {
} break;
case NOTIFICATION_TRANSFORM_CHANGED: {
- Transform2D global_transform = get_global_transform_with_canvas();
+ Transform2D global_transform = get_global_transform();
if (only_update_transform_changes && global_transform == last_transform) {
return;
diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp
index 66686f10a8..02213e07d0 100644
--- a/scene/2d/physics_body_2d.cpp
+++ b/scene/2d/physics_body_2d.cpp
@@ -35,6 +35,19 @@
#include "engine.h"
#include "math_funcs.h"
#include "scene/scene_string_names.h"
+void PhysicsBody2D::_notification(int p_what) {
+
+ /*
+ switch(p_what) {
+
+ case NOTIFICATION_TRANSFORM_CHANGED: {
+
+ Physics2DServer::get_singleton()->body_set_state(get_rid(),Physics2DServer::BODY_STATE_TRANSFORM,get_global_transform());
+
+ } break;
+ }
+ */
+}
void PhysicsBody2D::_set_layers(uint32_t p_mask) {
@@ -423,7 +436,7 @@ bool RigidBody2D::_test_motion(const Vector2 &p_motion, bool p_infinite_inertia,
Physics2DServer::MotionResult *r = NULL;
if (p_result.is_valid())
r = p_result->get_result_ptr();
- return Physics2DServer::get_singleton()->body_test_motion(get_rid(), get_global_transform_with_canvas(), p_motion, p_infinite_inertia, p_margin, r);
+ return Physics2DServer::get_singleton()->body_test_motion(get_rid(), get_global_transform(), p_motion, p_infinite_inertia, p_margin, r);
}
void RigidBody2D::_direct_state_changed(Object *p_state) {
@@ -436,7 +449,7 @@ void RigidBody2D::_direct_state_changed(Object *p_state) {
set_block_transform_notify(true); // don't want notify (would feedback loop)
if (mode != MODE_KINEMATIC)
- set_global_transform(get_canvas_transform().affine_inverse() * state->get_transform());
+ set_global_transform(state->get_transform());
linear_velocity = state->get_linear_velocity();
angular_velocity = state->get_angular_velocity();
if (sleeping != state->is_sleeping()) {
@@ -1131,7 +1144,7 @@ bool KinematicBody2D::separate_raycast_shapes(bool p_infinite_inertia, Collision
Physics2DServer::SeparationResult sep_res[8]; //max 8 rays
- Transform2D gt = get_global_transform_with_canvas();
+ Transform2D gt = get_global_transform();
Vector2 recover;
int hits = Physics2DServer::get_singleton()->body_test_ray_separation(get_rid(), gt, p_infinite_inertia, recover, sep_res, 8, margin);
@@ -1145,7 +1158,7 @@ bool KinematicBody2D::separate_raycast_shapes(bool p_infinite_inertia, Collision
}
gt.elements[2] += recover;
- set_global_transform(get_canvas_transform().affine_inverse() * gt);
+ set_global_transform(gt);
if (deepest != -1) {
r_collision.collider = sep_res[deepest].collider_id;
@@ -1166,7 +1179,7 @@ bool KinematicBody2D::separate_raycast_shapes(bool p_infinite_inertia, Collision
bool KinematicBody2D::move_and_collide(const Vector2 &p_motion, bool p_infinite_inertia, Collision &r_collision, bool p_exclude_raycast_shapes, bool p_test_only) {
- Transform2D gt = get_global_transform_with_canvas();
+ Transform2D gt = get_global_transform();
Physics2DServer::MotionResult result;
bool colliding = Physics2DServer::get_singleton()->body_test_motion(get_rid(), gt, p_motion, p_infinite_inertia, margin, &result, p_exclude_raycast_shapes);
@@ -1185,7 +1198,7 @@ bool KinematicBody2D::move_and_collide(const Vector2 &p_motion, bool p_infinite_
if (!p_test_only) {
gt.elements[2] += result.motion;
- set_global_transform(get_canvas_transform().affine_inverse() * gt);
+ set_global_transform(gt);
}
return colliding;
@@ -1259,9 +1272,9 @@ Vector2 KinematicBody2D::move_and_slide(const Vector2 &p_linear_velocity, const
if (p_stop_on_slope) {
if (Vector2() == lv_n + p_floor_direction) {
- Transform2D gt = get_global_transform_with_canvas();
+ Transform2D gt = get_global_transform();
gt.elements[2] -= collision.travel;
- set_global_transform(get_canvas_transform().affine_inverse() * gt);
+ set_global_transform(gt);
return Vector2();
}
}
@@ -1310,7 +1323,7 @@ Vector2 KinematicBody2D::move_and_slide_with_snap(const Vector2 &p_linear_veloci
}
Collision col;
- Transform2D gt = get_global_transform_with_canvas();
+ Transform2D gt = get_global_transform();
if (move_and_collide(p_snap, p_infinite_inertia, col, false, true)) {
gt.elements[2] += col.travel;
@@ -1319,7 +1332,7 @@ Vector2 KinematicBody2D::move_and_slide_with_snap(const Vector2 &p_linear_veloci
on_floor_body = col.collider_rid;
floor_velocity = col.collider_vel;
}
- set_global_transform(get_canvas_transform().affine_inverse() * gt);
+ set_global_transform(gt);
}
return ret;
@@ -1416,22 +1429,22 @@ void KinematicBody2D::_direct_state_changed(Object *p_state) {
last_valid_transform = state->get_transform();
set_notify_local_transform(false);
- set_global_transform(get_canvas_transform().affine_inverse() * last_valid_transform);
+ set_global_transform(last_valid_transform);
set_notify_local_transform(true);
}
void KinematicBody2D::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE) {
- last_valid_transform = get_global_transform_with_canvas();
+ last_valid_transform = get_global_transform();
}
if (p_what == NOTIFICATION_LOCAL_TRANSFORM_CHANGED) {
//used by sync to physics, send the new transform to the physics
- Transform2D new_transform = get_global_transform_with_canvas();
+ Transform2D new_transform = get_global_transform();
Physics2DServer::get_singleton()->body_set_state(get_rid(), Physics2DServer::BODY_STATE_TRANSFORM, new_transform);
//but then revert changes
set_notify_local_transform(false);
- set_global_transform(get_canvas_transform().affine_inverse() * last_valid_transform);
+ set_global_transform(last_valid_transform);
set_notify_local_transform(true);
}
}
diff --git a/scene/2d/physics_body_2d.h b/scene/2d/physics_body_2d.h
index 0900438e3c..852963a721 100644
--- a/scene/2d/physics_body_2d.h
+++ b/scene/2d/physics_body_2d.h
@@ -49,6 +49,7 @@ class PhysicsBody2D : public CollisionObject2D {
uint32_t _get_layers() const;
protected:
+ void _notification(int p_what);
PhysicsBody2D(Physics2DServer::BodyMode p_mode);
static void _bind_methods();
diff --git a/scene/animation/animation_blend_tree.cpp b/scene/animation/animation_blend_tree.cpp
index 66a9c5babd..10bab3ce38 100644
--- a/scene/animation/animation_blend_tree.cpp
+++ b/scene/animation/animation_blend_tree.cpp
@@ -987,17 +987,6 @@ void AnimationNodeBlendTree::disconnect_node(const StringName &p_node, int p_inp
nodes[p_node].connections.write[p_input_index] = StringName();
}
-float AnimationNodeBlendTree::get_connection_activity(const StringName &p_input_node, int p_input_index) const {
-
- ERR_FAIL_COND_V(!nodes.has(p_input_node), 0);
-
- Ref<AnimationNode> input = nodes[p_input_node].node;
- ERR_FAIL_INDEX_V(p_input_index, nodes[p_input_node].connections.size(), 0);
-
- //return input->get_input_activity(p_input_index);
- return 0;
-}
-
AnimationNodeBlendTree::ConnectionError AnimationNodeBlendTree::can_connect_node(const StringName &p_input_node, int p_input_index, const StringName &p_output_node) const {
if (!nodes.has(p_output_node) || p_output_node == SceneStringNames::get_singleton()->output) {
diff --git a/scene/animation/animation_blend_tree.h b/scene/animation/animation_blend_tree.h
index 37bd45c74a..7bf2917c1e 100644
--- a/scene/animation/animation_blend_tree.h
+++ b/scene/animation/animation_blend_tree.h
@@ -349,7 +349,6 @@ public:
void connect_node(const StringName &p_input_node, int p_input_index, const StringName &p_output_node);
void disconnect_node(const StringName &p_node, int p_input_index);
- float get_connection_activity(const StringName &p_input_node, int p_input_index) const;
struct NodeConnection {
StringName input_node;
diff --git a/scene/animation/animation_tree.cpp b/scene/animation/animation_tree.cpp
index 1513010a8a..76f0ee9359 100644
--- a/scene/animation/animation_tree.cpp
+++ b/scene/animation/animation_tree.cpp
@@ -109,8 +109,16 @@ float AnimationNode::blend_input(int p_input, float p_time, bool p_seek, float p
Ref<AnimationNode> node = blend_tree->get_node(node_name);
//inputs.write[p_input].last_pass = state->last_pass;
- float activity;
- return _blend_node(node_name, blend_tree->get_node_connection_array(node_name), NULL, node, p_time, p_seek, p_blend, p_filter, p_optimize, &activity);
+ float activity=0;
+ float ret = _blend_node(node_name, blend_tree->get_node_connection_array(node_name), NULL, node, p_time, p_seek, p_blend, p_filter, p_optimize, &activity);
+
+ Vector<AnimationTree::Activity> *activity_ptr = state->tree->input_activity_map.getptr(base_path);
+
+ if (activity_ptr && p_input<activity_ptr->size()) {
+ activity_ptr->write[p_input].last_pass = state->last_pass;
+ activity_ptr->write[p_input].activity = activity;
+ }
+ return ret;
}
float AnimationNode::blend_node(const StringName &p_sub_path, Ref<AnimationNode> p_node, float p_time, bool p_seek, float p_blend, FilterAction p_filter, bool p_optimize) {
@@ -1285,6 +1293,18 @@ void AnimationTree::_update_properties_for_node(const String &p_base_path, Ref<A
property_parent_map[p_base_path] = HashMap<StringName, StringName>();
}
+ if (node->get_input_count() && !input_activity_map.has(p_base_path)) {
+
+ Vector<Activity> activity;
+ for(int i=0;i<node->get_input_count();i++) {
+ Activity a;
+ a.last_pass=0;
+ activity.push_back(a);
+ }
+ input_activity_map[p_base_path] = activity;
+ input_activity_map_get[String(p_base_path).substr(0,String(p_base_path).length()-1)]=&input_activity_map[p_base_path];
+ }
+
List<PropertyInfo> plist;
node->get_parameter_list(&plist);
for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) {
@@ -1317,6 +1337,8 @@ void AnimationTree::_update_properties() {
properties.clear();
property_parent_map.clear();
+ input_activity_map.clear();
+ input_activity_map_get.clear();
if (root.is_valid()) {
_update_properties_for_node(SceneStringNames::get_singleton()->parameters_base_path, root);
@@ -1380,6 +1402,25 @@ void AnimationTree::rename_parameter(const String &p_base, const String &p_new_b
_update_properties();
}
+float AnimationTree::get_connection_activity(const StringName& p_path,int p_connection) const {
+
+ if (!input_activity_map_get.has(p_path)) {
+ return 0;
+ }
+ const Vector<Activity> *activity = input_activity_map_get[p_path];
+
+ if (!activity || p_connection<0 || p_connection>=activity->size()) {
+ return 0;
+ }
+
+ if ((*activity)[p_connection].last_pass != process_pass) {
+ return 0;
+ }
+
+ return (*activity)[p_connection].activity;
+}
+
+
void AnimationTree::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_active", "active"), &AnimationTree::set_active);
ClassDB::bind_method(D_METHOD("is_active"), &AnimationTree::is_active);
diff --git a/scene/animation/animation_tree.h b/scene/animation/animation_tree.h
index 3c615b2f92..70f3932f21 100644
--- a/scene/animation/animation_tree.h
+++ b/scene/animation/animation_tree.h
@@ -55,7 +55,7 @@ public:
Vector<float> blends;
State *state;
- String path;
+
float _pre_process(const StringName &p_base_path, AnimationNode *p_parent, State *p_state, float p_time, bool p_seek, const Vector<StringName> &p_connections);
void _pre_update_animations(HashMap<NodePath, int> *track_map);
@@ -256,6 +256,14 @@ private:
HashMap<StringName, HashMap<StringName, StringName> > property_parent_map;
HashMap<StringName, Variant> property_map;
+ struct Activity {
+ uint64_t last_pass;
+ float activity;
+ };
+
+ HashMap<StringName, Vector<Activity> > input_activity_map;
+ HashMap<StringName, Vector<Activity> *> input_activity_map_get;
+
void _update_properties_for_node(const String &p_base_path, Ref<AnimationNode> node);
protected:
@@ -289,6 +297,7 @@ public:
Transform get_root_motion_transform() const;
+ float get_connection_activity(const StringName &p_path, int p_connection) const;
void advance(float p_time);
void rename_parameter(const String &p_base, const String &p_new_base);
diff --git a/scene/main/canvas_layer.cpp b/scene/main/canvas_layer.cpp
index c044443b51..a2e890e7a7 100644
--- a/scene/main/canvas_layer.cpp
+++ b/scene/main/canvas_layer.cpp
@@ -29,7 +29,6 @@
/*************************************************************************/
#include "canvas_layer.h"
-#include "scene/2d/canvas_item.h"
#include "viewport.h"
void CanvasLayer::set_layer(int p_xform) {
@@ -63,24 +62,6 @@ void CanvasLayer::_update_xform() {
transform.set_origin(ofs);
if (viewport.is_valid())
VisualServer::get_singleton()->viewport_set_canvas_transform(viewport, canvas, transform);
-
- if (!is_inside_tree())
- return;
-
- _notify_xform(this);
-}
-
-void CanvasLayer::_notify_xform(Node *p_node) {
-
- for (int i = 0; i < p_node->get_child_count(); i++) {
-
- CanvasItem *ci = Object::cast_to<CanvasItem>(p_node->get_child(i));
- if (ci) {
- ci->_notify_transform(ci);
- } else {
- _notify_xform(p_node->get_child(i));
- }
- }
}
void CanvasLayer::_update_locrotscale() {
diff --git a/scene/main/canvas_layer.h b/scene/main/canvas_layer.h
index fd347c4739..aae23fbb12 100644
--- a/scene/main/canvas_layer.h
+++ b/scene/main/canvas_layer.h
@@ -56,7 +56,6 @@ class CanvasLayer : public Node {
int sort_index;
void _update_xform();
- void _notify_xform(Node *p_node);
void _update_locrotscale();
protected: