From 0dbedd18fc62f700e92a4cf581e505d849bc47ad Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Wed, 5 Nov 2014 21:20:42 -0300 Subject: SceneMainLoop -> SceneTree -=-=-=-=-=-=-=-=-=-=-=-=-=- *YOUR SOURCE MIGHT NOT WORK* For mor information on fix: https://github.com/okamstudio/godot/wiki/devel_scene_tree Other stuff: -Shower of bullets demo -Fixes all around --- scene/3d/area.cpp | 42 +-- scene/3d/area.h | 6 +- scene/3d/body_shape.cpp | 4 +- scene/3d/bone_attachment.cpp | 8 +- scene/3d/camera.cpp | 30 +- scene/3d/collision_object.cpp | 4 +- scene/3d/collision_polygon.cpp | 2 +- scene/3d/interpolated_camera.cpp | 6 +- scene/3d/light.cpp | 8 +- scene/3d/mesh_instance.cpp | 4 +- scene/3d/navigation_mesh.cpp | 6 +- scene/3d/path.cpp | 720 ++++++++++++++++++------------------- scene/3d/physics_body.cpp | 42 +-- scene/3d/physics_body.h | 6 +- scene/3d/physics_joint.cpp | 4 +- scene/3d/proximity_group.cpp | 4 +- scene/3d/quad.cpp | 6 +- scene/3d/ray_cast.cpp | 10 +- scene/3d/room_instance.cpp | 2 +- scene/3d/skeleton.cpp | 8 +- scene/3d/spatial.cpp | 24 +- scene/3d/spatial.h | 2 +- scene/3d/spatial_stream_player.cpp | 4 +- scene/3d/sprite_3d.cpp | 4 +- scene/3d/vehicle_body.cpp | 4 +- scene/3d/visibility_notifier.cpp | 14 +- scene/3d/visual_instance.cpp | 2 +- 27 files changed, 488 insertions(+), 488 deletions(-) (limited to 'scene/3d') diff --git a/scene/3d/area.cpp b/scene/3d/area.cpp index 7370c36eb7..407747fc0d 100644 --- a/scene/3d/area.cpp +++ b/scene/3d/area.cpp @@ -94,7 +94,7 @@ real_t Area::get_priority() const{ } -void Area::_body_enter_scene(ObjectID p_id) { +void Area::_body_enter_tree(ObjectID p_id) { Object *obj = ObjectDB::get_instance(p_id); Node *node = obj ? obj->cast_to() : NULL; @@ -102,9 +102,9 @@ void Area::_body_enter_scene(ObjectID p_id) { Map::Element *E=body_map.find(p_id); ERR_FAIL_COND(!E); - ERR_FAIL_COND(E->get().in_scene); + ERR_FAIL_COND(E->get().in_tree); - E->get().in_scene=true; + E->get().in_tree=true; emit_signal(SceneStringNames::get_singleton()->body_enter,node); for(int i=0;iget().shapes.size();i++) { @@ -113,15 +113,15 @@ void Area::_body_enter_scene(ObjectID p_id) { } -void Area::_body_exit_scene(ObjectID p_id) { +void Area::_body_exit_tree(ObjectID p_id) { Object *obj = ObjectDB::get_instance(p_id); Node *node = obj ? obj->cast_to() : NULL; ERR_FAIL_COND(!node); Map::Element *E=body_map.find(p_id); ERR_FAIL_COND(!E); - ERR_FAIL_COND(!E->get().in_scene); - E->get().in_scene=false; + ERR_FAIL_COND(!E->get().in_tree); + E->get().in_tree=false; emit_signal(SceneStringNames::get_singleton()->body_exit,node); for(int i=0;iget().shapes.size();i++) { @@ -147,11 +147,11 @@ void Area::_body_inout(int p_status,const RID& p_body, int p_instance, int p_bod E = body_map.insert(objid,BodyState()); E->get().rc=0; - E->get().in_scene=node && node->is_inside_scene(); + E->get().in_tree=node && node->is_inside_tree(); if (node) { - node->connect(SceneStringNames::get_singleton()->enter_scene,this,SceneStringNames::get_singleton()->_body_enter_scene,make_binds(objid)); - node->connect(SceneStringNames::get_singleton()->exit_scene,this,SceneStringNames::get_singleton()->_body_exit_scene,make_binds(objid)); - if (E->get().in_scene) { + node->connect(SceneStringNames::get_singleton()->enter_tree,this,SceneStringNames::get_singleton()->_body_enter_tree,make_binds(objid)); + node->connect(SceneStringNames::get_singleton()->exit_tree,this,SceneStringNames::get_singleton()->_body_exit_tree,make_binds(objid)); + if (E->get().in_tree) { emit_signal(SceneStringNames::get_singleton()->body_enter,node); } } @@ -162,7 +162,7 @@ void Area::_body_inout(int p_status,const RID& p_body, int p_instance, int p_bod E->get().shapes.insert(ShapePair(p_body_shape,p_area_shape)); - if (E->get().in_scene) { + if (E->get().in_tree) { emit_signal(SceneStringNames::get_singleton()->body_enter_shape,objid,node,p_body_shape,p_area_shape); } @@ -178,9 +178,9 @@ void Area::_body_inout(int p_status,const RID& p_body, int p_instance, int p_bod if (E->get().rc==0) { if (node) { - node->disconnect(SceneStringNames::get_singleton()->enter_scene,this,SceneStringNames::get_singleton()->_body_enter_scene); - node->disconnect(SceneStringNames::get_singleton()->exit_scene,this,SceneStringNames::get_singleton()->_body_exit_scene); - if (E->get().in_scene) + node->disconnect(SceneStringNames::get_singleton()->enter_tree,this,SceneStringNames::get_singleton()->_body_enter_tree); + node->disconnect(SceneStringNames::get_singleton()->exit_tree,this,SceneStringNames::get_singleton()->_body_exit_tree); + if (E->get().in_tree) emit_signal(SceneStringNames::get_singleton()->body_exit,obj); } @@ -188,7 +188,7 @@ void Area::_body_inout(int p_status,const RID& p_body, int p_instance, int p_bod eraseit=true; } - if (node && E->get().in_scene) { + if (node && E->get().in_tree) { emit_signal(SceneStringNames::get_singleton()->body_exit_shape,objid,obj,p_body_shape,p_area_shape); } @@ -211,7 +211,7 @@ void Area::_clear_monitoring() { Object *obj = ObjectDB::get_instance(E->key()); Node *node = obj ? obj->cast_to() : NULL; ERR_CONTINUE(!node); - if (!E->get().in_scene) + if (!E->get().in_tree) continue; for(int i=0;iget().shapes.size();i++) { @@ -221,14 +221,14 @@ void Area::_clear_monitoring() { emit_signal(SceneStringNames::get_singleton()->body_exit,obj); - node->disconnect(SceneStringNames::get_singleton()->enter_scene,this,SceneStringNames::get_singleton()->_body_enter_scene); - node->disconnect(SceneStringNames::get_singleton()->exit_scene,this,SceneStringNames::get_singleton()->_body_exit_scene); + node->disconnect(SceneStringNames::get_singleton()->enter_tree,this,SceneStringNames::get_singleton()->_body_enter_tree); + node->disconnect(SceneStringNames::get_singleton()->exit_tree,this,SceneStringNames::get_singleton()->_body_exit_tree); } } void Area::_notification(int p_what) { - if (p_what==NOTIFICATION_EXIT_SCENE) { + if (p_what==NOTIFICATION_EXIT_TREE) { _clear_monitoring(); } } @@ -258,8 +258,8 @@ bool Area::is_monitoring_enabled() const { void Area::_bind_methods() { - ObjectTypeDB::bind_method(_MD("_body_enter_scene","id"),&Area::_body_enter_scene); - ObjectTypeDB::bind_method(_MD("_body_exit_scene","id"),&Area::_body_exit_scene); + ObjectTypeDB::bind_method(_MD("_body_enter_tree","id"),&Area::_body_enter_tree); + ObjectTypeDB::bind_method(_MD("_body_exit_tree","id"),&Area::_body_exit_tree); ObjectTypeDB::bind_method(_MD("set_space_override_mode","enable"),&Area::set_space_override_mode); ObjectTypeDB::bind_method(_MD("get_space_override_mode"),&Area::get_space_override_mode); diff --git a/scene/3d/area.h b/scene/3d/area.h index 5558e2c719..96b8585338 100644 --- a/scene/3d/area.h +++ b/scene/3d/area.h @@ -56,8 +56,8 @@ private: void _body_inout(int p_status,const RID& p_body, int p_instance, int p_body_shape,int p_area_shape); - void _body_enter_scene(ObjectID p_id); - void _body_exit_scene(ObjectID p_id); + void _body_enter_tree(ObjectID p_id); + void _body_exit_tree(ObjectID p_id); struct ShapePair { @@ -77,7 +77,7 @@ private: struct BodyState { int rc; - bool in_scene; + bool in_tree; VSet shapes; }; diff --git a/scene/3d/body_shape.cpp b/scene/3d/body_shape.cpp index 947acc6549..287515dce7 100644 --- a/scene/3d/body_shape.cpp +++ b/scene/3d/body_shape.cpp @@ -320,7 +320,7 @@ void CollisionShape::_notification(int p_what) { switch(p_what) { - case NOTIFICATION_ENTER_SCENE: { + case NOTIFICATION_ENTER_TREE: { unparenting=false; //indicator_instance = VisualServer::get_singleton()->instance_create2(indicator,get_world()->get_scenario()); @@ -331,7 +331,7 @@ void CollisionShape::_notification(int p_what) { _update_body(); } } break; - case NOTIFICATION_EXIT_SCENE: { + case NOTIFICATION_EXIT_TREE: { /* if (indicator_instance.is_valid()) { VisualServer::get_singleton()->free(indicator_instance); indicator_instance=RID(); diff --git a/scene/3d/bone_attachment.cpp b/scene/3d/bone_attachment.cpp index cbc4abb7a9..6bbb957d25 100644 --- a/scene/3d/bone_attachment.cpp +++ b/scene/3d/bone_attachment.cpp @@ -102,12 +102,12 @@ void BoneAttachment::_check_unbind() { void BoneAttachment::set_bone_name(const String& p_name) { - if (is_inside_scene()) + if (is_inside_tree()) _check_unbind(); bone_name=p_name; - if (is_inside_scene()) + if (is_inside_tree()) _check_bind(); } @@ -120,11 +120,11 @@ void BoneAttachment::_notification(int p_what) { switch(p_what) { - case NOTIFICATION_ENTER_SCENE: { + case NOTIFICATION_ENTER_TREE: { _check_bind(); } break; - case NOTIFICATION_EXIT_SCENE: { + case NOTIFICATION_EXIT_TREE: { _check_unbind(); } break; diff --git a/scene/3d/camera.cpp b/scene/3d/camera.cpp index ab28c0c8d4..933f270475 100644 --- a/scene/3d/camera.cpp +++ b/scene/3d/camera.cpp @@ -121,7 +121,7 @@ bool Camera::_get(const StringName& p_name,Variant &r_ret) const { r_ret= int(keep_aspect); else if (p_name=="current") { - if (is_inside_scene() && get_scene()->is_editor_hint()) { + if (is_inside_tree() && get_tree()->is_editor_hint()) { r_ret=current; } else { r_ret=is_current(); @@ -182,7 +182,7 @@ void Camera::_update_camera() { // if (viewport_ptr && is_inside_scene() && is_current()) // viewport_ptr->_camera_transform_changed_notify(); - if (is_inside_scene() && is_current()) { + if (is_inside_tree() && is_current()) { if (viewport_ptr) { viewport_ptr->_camera_transform_changed_notify(); } @@ -309,7 +309,7 @@ void Camera::make_current() { current=true; - if (!is_inside_scene()) + if (!is_inside_tree()) return; if (viewport_ptr) { @@ -324,7 +324,7 @@ void Camera::_camera_make_next_current(Node *p_exclude) { if (this==p_exclude) return; - if (!is_inside_scene()) + if (!is_inside_tree()) return; if (get_viewport()->get_camera()!=NULL) return; @@ -336,14 +336,14 @@ void Camera::_camera_make_next_current(Node *p_exclude) { void Camera::clear_current() { current=false; - if (!is_inside_scene()) + if (!is_inside_tree()) return; if (viewport_ptr) { if (viewport_ptr->get_camera()==this) { viewport_ptr->_set_camera(NULL); //a group is used beause this needs to be in order to be deterministic - get_scene()->call_group(SceneMainLoop::GROUP_CALL_REALTIME,camera_group,"_camera_make_next_current",this); + get_tree()->call_group(SceneTree::GROUP_CALL_REALTIME,camera_group,"_camera_make_next_current",this); } } @@ -352,7 +352,7 @@ void Camera::clear_current() { bool Camera::is_current() const { - if (is_inside_scene()) { + if (is_inside_tree()) { if (viewport_ptr) return viewport_ptr->get_camera()==this; } else @@ -462,9 +462,9 @@ Vector3 Camera::project_ray_normal(const Point2& p_pos) const { Vector3 Camera::project_local_ray_normal(const Point2& p_pos) const { - if (!is_inside_scene()) { + if (!is_inside_tree()) { ERR_EXPLAIN("Camera is not inside scene."); - ERR_FAIL_COND_V(!is_inside_scene(),Vector3()); + ERR_FAIL_COND_V(!is_inside_tree(),Vector3()); } @@ -496,9 +496,9 @@ Vector3 Camera::project_local_ray_normal(const Point2& p_pos) const { Vector3 Camera::project_ray_origin(const Point2& p_pos) const { - if (!is_inside_scene()) { + if (!is_inside_tree()) { ERR_EXPLAIN("Camera is not inside scene."); - ERR_FAIL_COND_V(!is_inside_scene(),Vector3()); + ERR_FAIL_COND_V(!is_inside_tree(),Vector3()); } #if 0 @@ -540,9 +540,9 @@ Vector3 Camera::project_ray_origin(const Point2& p_pos) const { Point2 Camera::unproject_position(const Vector3& p_pos) const { - if (!is_inside_scene()) { + if (!is_inside_tree()) { ERR_EXPLAIN("Camera is not inside scene."); - ERR_FAIL_COND_V(!is_inside_scene(),Vector2()); + ERR_FAIL_COND_V(!is_inside_tree(),Vector2()); } Size2 viewport_size = viewport_ptr->get_visible_rect().size; @@ -571,9 +571,9 @@ Point2 Camera::unproject_position(const Vector3& p_pos) const { Vector3 Camera::project_position(const Point2& p_point) const { - if (!is_inside_scene()) { + if (!is_inside_tree()) { ERR_EXPLAIN("Camera is not inside scene."); - ERR_FAIL_COND_V(!is_inside_scene(),Vector3()); + ERR_FAIL_COND_V(!is_inside_tree(),Vector3()); } Size2 viewport_size = viewport_ptr->get_visible_rect().size; diff --git a/scene/3d/collision_object.cpp b/scene/3d/collision_object.cpp index 47d29cec1c..82158405ea 100644 --- a/scene/3d/collision_object.cpp +++ b/scene/3d/collision_object.cpp @@ -199,9 +199,9 @@ void CollisionObject::_mouse_exit() { } void CollisionObject::_update_pickable() { - if (!is_inside_scene()) + if (!is_inside_tree()) return; - bool pickable = ray_pickable && is_inside_scene() && is_visible(); + bool pickable = ray_pickable && is_inside_tree() && is_visible(); if (area) PhysicsServer::get_singleton()->area_set_ray_pickable(rid,pickable); else diff --git a/scene/3d/collision_polygon.cpp b/scene/3d/collision_polygon.cpp index 5a613f360a..4ab1a1a1ab 100644 --- a/scene/3d/collision_polygon.cpp +++ b/scene/3d/collision_polygon.cpp @@ -86,7 +86,7 @@ void CollisionPolygon::_notification(int p_what) { switch(p_what) { case NOTIFICATION_TRANSFORM_CHANGED: { - if (!is_inside_scene()) + if (!is_inside_tree()) break; _update_parent(); diff --git a/scene/3d/interpolated_camera.cpp b/scene/3d/interpolated_camera.cpp index f795f935ae..2f35164f49 100644 --- a/scene/3d/interpolated_camera.cpp +++ b/scene/3d/interpolated_camera.cpp @@ -32,9 +32,9 @@ void InterpolatedCamera::_notification(int p_what) { switch(p_what) { - case NOTIFICATION_ENTER_SCENE: { + case NOTIFICATION_ENTER_TREE: { - if (get_scene()->is_editor_hint() && enabled) + if (get_tree()->is_editor_hint() && enabled) set_fixed_process(false); } break; @@ -109,7 +109,7 @@ void InterpolatedCamera::set_interpolation_enabled(bool p_enable) { return; enabled=p_enable; if (p_enable) { - if (is_inside_scene() && get_scene()->is_editor_hint()) + if (is_inside_tree() && get_tree()->is_editor_hint()) return; set_process(true); } else diff --git a/scene/3d/light.cpp b/scene/3d/light.cpp index e51a9764f6..9d959cb0d6 100644 --- a/scene/3d/light.cpp +++ b/scene/3d/light.cpp @@ -432,7 +432,7 @@ void Light::approximate_opengl_attenuation(float p_constant, float p_linear, flo void Light::_update_visibility() { - if (!is_inside_scene()) + if (!is_inside_tree()) return; @@ -440,10 +440,10 @@ bool editor_ok=true; #ifdef TOOLS_ENABLED if (editor_only) { - if (!get_scene()->is_editor_hint()) { + if (!get_tree()->is_editor_hint()) { editor_ok=false; } else { - editor_ok = (get_scene()->get_edited_scene_root() && (this==get_scene()->get_edited_scene_root() || get_owner()==get_scene()->get_edited_scene_root())); + editor_ok = (get_tree()->get_edited_scene_root() && (this==get_tree()->get_edited_scene_root() || get_owner()==get_tree()->get_edited_scene_root())); } } #endif @@ -456,7 +456,7 @@ bool editor_ok=true; void Light::_notification(int p_what) { - if (p_what==NOTIFICATION_ENTER_SCENE || p_what==NOTIFICATION_VISIBILITY_CHANGED) { + if (p_what==NOTIFICATION_ENTER_TREE || p_what==NOTIFICATION_VISIBILITY_CHANGED) { _update_visibility(); } } diff --git a/scene/3d/mesh_instance.cpp b/scene/3d/mesh_instance.cpp index 72d63fa006..d7266e5df7 100644 --- a/scene/3d/mesh_instance.cpp +++ b/scene/3d/mesh_instance.cpp @@ -126,7 +126,7 @@ void MeshInstance::_resolve_skeleton_path(){ void MeshInstance::set_skeleton_path(const NodePath &p_skeleton) { skeleton_path = p_skeleton; - if (!is_inside_scene()) + if (!is_inside_tree()) return; _resolve_skeleton_path(); } @@ -226,7 +226,7 @@ void MeshInstance::create_convex_collision() { void MeshInstance::_notification(int p_what) { - if (p_what==NOTIFICATION_ENTER_SCENE) { + if (p_what==NOTIFICATION_ENTER_TREE) { _resolve_skeleton_path(); } } diff --git a/scene/3d/navigation_mesh.cpp b/scene/3d/navigation_mesh.cpp index db416f24dd..8c52d4c35c 100644 --- a/scene/3d/navigation_mesh.cpp +++ b/scene/3d/navigation_mesh.cpp @@ -114,7 +114,7 @@ void NavigationMeshInstance::set_enabled(bool p_enabled) { return; enabled=p_enabled; - if (!is_inside_scene()) + if (!is_inside_tree()) return; if (!enabled) { @@ -152,7 +152,7 @@ void NavigationMeshInstance::_notification(int p_what) { switch(p_what) { - case NOTIFICATION_ENTER_SCENE: { + case NOTIFICATION_ENTER_TREE: { Spatial *c=this; while(c) { @@ -178,7 +178,7 @@ void NavigationMeshInstance::_notification(int p_what) { } } break; - case NOTIFICATION_EXIT_SCENE: { + case NOTIFICATION_EXIT_TREE: { if (navigation) { diff --git a/scene/3d/path.cpp b/scene/3d/path.cpp index bc5cb1c4a2..8be918fc22 100644 --- a/scene/3d/path.cpp +++ b/scene/3d/path.cpp @@ -26,363 +26,363 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "path.h" -#include "scene/scene_string_names.h" - -void Path::_notification(int p_what) { -#if 0 - if (p_what==NOTIFICATION_DRAW && curve.is_valid() && is_inside_scene() && get_scene()->is_editor_hint()) { - //draw the curve!! - - for(int i=0;iget_point_count();i++) { - - Vector2 prev_p=curve->get_point_pos(i); - - for(int j=1;j<=8;j++) { - - real_t frac = j/8.0; - Vector2 p = curve->interpolate(i,frac); - draw_line(prev_p,p,Color(0.5,0.6,1.0,0.7),2); - prev_p=p; - } - } - } -#endif -} - -void Path::_curve_changed() { - - - if (is_inside_scene() && get_scene()->is_editor_hint()) - update_gizmo(); -} - - -void Path::set_curve(const Ref& p_curve) { - - if (curve.is_valid()) { - curve->disconnect("changed",this,"_curve_changed"); - } - - curve=p_curve; - - if (curve.is_valid()) { - curve->connect("changed",this,"_curve_changed"); - } - _curve_changed(); - -} - -Ref Path::get_curve() const{ - - return curve; -} - -void Path::_bind_methods() { - - ObjectTypeDB::bind_method(_MD("set_curve","curve:Curve3D"),&Path::set_curve); - ObjectTypeDB::bind_method(_MD("get_curve:Curve3D","curve"),&Path::get_curve); - ObjectTypeDB::bind_method(_MD("_curve_changed"),&Path::_curve_changed); - - ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "curve", PROPERTY_HINT_RESOURCE_TYPE, "Curve3D"), _SCS("set_curve"),_SCS("get_curve")); -} - -Path::Path() { - - set_curve(Ref( memnew( Curve3D ))); //create one by default -} - - -////////////// - - -void PathFollow::_update_transform() { - - - if (!path) - return; - - Ref c =path->get_curve(); - if (!c.is_valid()) - return; - - - float o = offset; - if (loop) - o=Math::fposmod(o,c->get_baked_length()); - - Vector3 pos = c->interpolate_baked(o,cubic); - Transform t=get_transform(); - - - if (rotation_mode!=ROTATION_NONE) { - - Vector3 n = (c->interpolate_baked(o+lookahead,cubic)-pos).normalized(); - - if (rotation_mode==ROTATION_Y) { - - n.y=0; - n.normalize(); - } - - if (n.length()interpolate_baked_tilt(o); - if (tilt!=0) { - - Matrix3 rot(-n,tilt); //remember.. lookat will be znegative.. znegative!! we abide by opengl clan. - up=rot.xform(up); - } - } - - t.set_look_at(pos,pos+n,up); - - } else { - - t.origin=pos; - } - - t.origin+=t.basis.get_axis(0)*h_offset + t.basis.get_axis(1)*v_offset; - set_transform(t); - -} - -void PathFollow::_notification(int p_what) { - - - switch(p_what) { - - case NOTIFICATION_ENTER_SCENE: { - - Node *parent=get_parent(); - if (parent) { - - path=parent->cast_to(); - if (path) { - _update_transform(); - } - } - - } break; - case NOTIFICATION_EXIT_SCENE: { - - - path=NULL; - } break; - } - -} - -void PathFollow::set_cubic_interpolation(bool p_enable) { - - cubic=p_enable; -} - -bool PathFollow::get_cubic_interpolation() const { - - return cubic; -} - - -bool PathFollow::_set(const StringName& p_name, const Variant& p_value) { - - if (p_name==SceneStringNames::get_singleton()->offset) { - set_offset(p_value); - } else if (p_name==SceneStringNames::get_singleton()->unit_offset) { - set_unit_offset(p_value); - } else if (p_name==SceneStringNames::get_singleton()->rotation_mode) { - set_rotation_mode(RotationMode(p_value.operator int())); - } else if (p_name==SceneStringNames::get_singleton()->v_offset) { - set_v_offset(p_value); - } else if (p_name==SceneStringNames::get_singleton()->h_offset) { - set_h_offset(p_value); - } else if (String(p_name)=="cubic_interp") { - set_cubic_interpolation(p_value); - } else if (String(p_name)=="loop") { - set_loop(p_value); - } else if (String(p_name)=="lookahead") { - set_lookahead(p_value); - } else - return false; - - return true; -} - -bool PathFollow::_get(const StringName& p_name,Variant &r_ret) const{ - - if (p_name==SceneStringNames::get_singleton()->offset) { - r_ret=get_offset(); - } else if (p_name==SceneStringNames::get_singleton()->unit_offset) { - r_ret=get_unit_offset(); - } else if (p_name==SceneStringNames::get_singleton()->rotation_mode) { - r_ret=get_rotation_mode(); - } else if (p_name==SceneStringNames::get_singleton()->v_offset) { - r_ret=get_v_offset(); - } else if (p_name==SceneStringNames::get_singleton()->h_offset) { - r_ret=get_h_offset(); - } else if (String(p_name)=="cubic_interp") { - r_ret=cubic; - } else if (String(p_name)=="loop") { - r_ret=loop; - } else if (String(p_name)=="lookahead") { - r_ret=lookahead; - } else - return false; - - return true; - -} -void PathFollow::_get_property_list( List *p_list) const{ - - float max=10000; - if (path && path->get_curve().is_valid()) - max=path->get_curve()->get_baked_length(); - p_list->push_back( PropertyInfo( Variant::REAL, "offset", PROPERTY_HINT_RANGE,"0,"+rtos(max)+",0.01")); - p_list->push_back( PropertyInfo( Variant::REAL, "unit_offset", PROPERTY_HINT_RANGE,"0,1,0.0001",PROPERTY_USAGE_EDITOR)); - p_list->push_back( PropertyInfo( Variant::REAL, "h_offset") ); - p_list->push_back( PropertyInfo( Variant::REAL, "v_offset") ); - p_list->push_back( PropertyInfo( Variant::INT, "rotation_mode", PROPERTY_HINT_ENUM,"None,Y,XY,XYZ")); - p_list->push_back( PropertyInfo( Variant::BOOL, "cubic_interp")); - p_list->push_back( PropertyInfo( Variant::BOOL, "loop")); - p_list->push_back( PropertyInfo( Variant::REAL, "lookahead",PROPERTY_HINT_RANGE,"0.001,1024.0,0.001")); -} - - -void PathFollow::_bind_methods() { - - ObjectTypeDB::bind_method(_MD("set_offset","offset"),&PathFollow::set_offset); - ObjectTypeDB::bind_method(_MD("get_offset"),&PathFollow::get_offset); - - ObjectTypeDB::bind_method(_MD("set_h_offset","h_offset"),&PathFollow::set_h_offset); - ObjectTypeDB::bind_method(_MD("get_h_offset"),&PathFollow::get_h_offset); - - ObjectTypeDB::bind_method(_MD("set_v_offset","v_offset"),&PathFollow::set_v_offset); - ObjectTypeDB::bind_method(_MD("get_v_offset"),&PathFollow::get_v_offset); - - ObjectTypeDB::bind_method(_MD("set_unit_offset","unit_offset"),&PathFollow::set_unit_offset); - ObjectTypeDB::bind_method(_MD("get_unit_offset"),&PathFollow::get_unit_offset); - - ObjectTypeDB::bind_method(_MD("set_rotation_mode","rotation_mode"),&PathFollow::set_rotation_mode); - ObjectTypeDB::bind_method(_MD("get_rotation_mode"),&PathFollow::get_rotation_mode); - - ObjectTypeDB::bind_method(_MD("set_cubic_interpolation","enable"),&PathFollow::set_cubic_interpolation); - ObjectTypeDB::bind_method(_MD("get_cubic_interpolation"),&PathFollow::get_cubic_interpolation); - - ObjectTypeDB::bind_method(_MD("set_loop","loop"),&PathFollow::set_loop); - ObjectTypeDB::bind_method(_MD("has_loop"),&PathFollow::has_loop); - - BIND_CONSTANT( ROTATION_NONE ); - BIND_CONSTANT( ROTATION_Y ); - BIND_CONSTANT( ROTATION_XY ); - BIND_CONSTANT( ROTATION_XYZ ); - -} - -void PathFollow::set_offset(float p_offset) { - - offset=p_offset; - if (path) - _update_transform(); - _change_notify("offset"); - _change_notify("unit_offset"); - -} - -void PathFollow::set_h_offset(float p_h_offset) { - - h_offset=p_h_offset; - if (path) - _update_transform(); - -} - -float PathFollow::get_h_offset() const { - - return h_offset; -} - -void PathFollow::set_v_offset(float p_v_offset) { - - v_offset=p_v_offset; - if (path) - _update_transform(); - -} - -float PathFollow::get_v_offset() const { - - return v_offset; -} - - -float PathFollow::get_offset() const{ - - return offset; -} - -void PathFollow::set_unit_offset(float p_unit_offset) { - - if (path && path->get_curve().is_valid() && path->get_curve()->get_baked_length()) - set_offset(p_unit_offset*path->get_curve()->get_baked_length()); - -} - -float PathFollow::get_unit_offset() const{ - - if (path && path->get_curve().is_valid() && path->get_curve()->get_baked_length()) - return get_offset()/path->get_curve()->get_baked_length(); - else - return 0; -} - -void PathFollow::set_lookahead(float p_lookahead) { - - lookahead=p_lookahead; - -} - -float PathFollow::get_lookahead() const{ - - return lookahead; -} - -void PathFollow::set_rotation_mode(RotationMode p_rotation_mode) { - - rotation_mode=p_rotation_mode; - _update_transform(); -} - -PathFollow::RotationMode PathFollow::get_rotation_mode() const { - - return rotation_mode; -} - -void PathFollow::set_loop(bool p_loop) { - - loop=p_loop; -} - -bool PathFollow::has_loop() const{ - - return loop; -} - - -PathFollow::PathFollow() { - - offset=0; - h_offset=0; - v_offset=0; - path=NULL; - rotation_mode=ROTATION_XYZ; - cubic=true; - loop=true; - lookahead=0.1; -} +#include "path.h" +#include "scene/scene_string_names.h" + +void Path::_notification(int p_what) { +#if 0 + if (p_what==NOTIFICATION_DRAW && curve.is_valid() && is_inside_scene() && get_scene()->is_editor_hint()) { + //draw the curve!! + + for(int i=0;iget_point_count();i++) { + + Vector2 prev_p=curve->get_point_pos(i); + + for(int j=1;j<=8;j++) { + + real_t frac = j/8.0; + Vector2 p = curve->interpolate(i,frac); + draw_line(prev_p,p,Color(0.5,0.6,1.0,0.7),2); + prev_p=p; + } + } + } +#endif +} + +void Path::_curve_changed() { + + + if (is_inside_tree() && get_tree()->is_editor_hint()) + update_gizmo(); +} + + +void Path::set_curve(const Ref& p_curve) { + + if (curve.is_valid()) { + curve->disconnect("changed",this,"_curve_changed"); + } + + curve=p_curve; + + if (curve.is_valid()) { + curve->connect("changed",this,"_curve_changed"); + } + _curve_changed(); + +} + +Ref Path::get_curve() const{ + + return curve; +} + +void Path::_bind_methods() { + + ObjectTypeDB::bind_method(_MD("set_curve","curve:Curve3D"),&Path::set_curve); + ObjectTypeDB::bind_method(_MD("get_curve:Curve3D","curve"),&Path::get_curve); + ObjectTypeDB::bind_method(_MD("_curve_changed"),&Path::_curve_changed); + + ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "curve", PROPERTY_HINT_RESOURCE_TYPE, "Curve3D"), _SCS("set_curve"),_SCS("get_curve")); +} + +Path::Path() { + + set_curve(Ref( memnew( Curve3D ))); //create one by default +} + + +////////////// + + +void PathFollow::_update_transform() { + + + if (!path) + return; + + Ref c =path->get_curve(); + if (!c.is_valid()) + return; + + + float o = offset; + if (loop) + o=Math::fposmod(o,c->get_baked_length()); + + Vector3 pos = c->interpolate_baked(o,cubic); + Transform t=get_transform(); + + + if (rotation_mode!=ROTATION_NONE) { + + Vector3 n = (c->interpolate_baked(o+lookahead,cubic)-pos).normalized(); + + if (rotation_mode==ROTATION_Y) { + + n.y=0; + n.normalize(); + } + + if (n.length()interpolate_baked_tilt(o); + if (tilt!=0) { + + Matrix3 rot(-n,tilt); //remember.. lookat will be znegative.. znegative!! we abide by opengl clan. + up=rot.xform(up); + } + } + + t.set_look_at(pos,pos+n,up); + + } else { + + t.origin=pos; + } + + t.origin+=t.basis.get_axis(0)*h_offset + t.basis.get_axis(1)*v_offset; + set_transform(t); + +} + +void PathFollow::_notification(int p_what) { + + + switch(p_what) { + + case NOTIFICATION_ENTER_TREE: { + + Node *parent=get_parent(); + if (parent) { + + path=parent->cast_to(); + if (path) { + _update_transform(); + } + } + + } break; + case NOTIFICATION_EXIT_TREE: { + + + path=NULL; + } break; + } + +} + +void PathFollow::set_cubic_interpolation(bool p_enable) { + + cubic=p_enable; +} + +bool PathFollow::get_cubic_interpolation() const { + + return cubic; +} + + +bool PathFollow::_set(const StringName& p_name, const Variant& p_value) { + + if (p_name==SceneStringNames::get_singleton()->offset) { + set_offset(p_value); + } else if (p_name==SceneStringNames::get_singleton()->unit_offset) { + set_unit_offset(p_value); + } else if (p_name==SceneStringNames::get_singleton()->rotation_mode) { + set_rotation_mode(RotationMode(p_value.operator int())); + } else if (p_name==SceneStringNames::get_singleton()->v_offset) { + set_v_offset(p_value); + } else if (p_name==SceneStringNames::get_singleton()->h_offset) { + set_h_offset(p_value); + } else if (String(p_name)=="cubic_interp") { + set_cubic_interpolation(p_value); + } else if (String(p_name)=="loop") { + set_loop(p_value); + } else if (String(p_name)=="lookahead") { + set_lookahead(p_value); + } else + return false; + + return true; +} + +bool PathFollow::_get(const StringName& p_name,Variant &r_ret) const{ + + if (p_name==SceneStringNames::get_singleton()->offset) { + r_ret=get_offset(); + } else if (p_name==SceneStringNames::get_singleton()->unit_offset) { + r_ret=get_unit_offset(); + } else if (p_name==SceneStringNames::get_singleton()->rotation_mode) { + r_ret=get_rotation_mode(); + } else if (p_name==SceneStringNames::get_singleton()->v_offset) { + r_ret=get_v_offset(); + } else if (p_name==SceneStringNames::get_singleton()->h_offset) { + r_ret=get_h_offset(); + } else if (String(p_name)=="cubic_interp") { + r_ret=cubic; + } else if (String(p_name)=="loop") { + r_ret=loop; + } else if (String(p_name)=="lookahead") { + r_ret=lookahead; + } else + return false; + + return true; + +} +void PathFollow::_get_property_list( List *p_list) const{ + + float max=10000; + if (path && path->get_curve().is_valid()) + max=path->get_curve()->get_baked_length(); + p_list->push_back( PropertyInfo( Variant::REAL, "offset", PROPERTY_HINT_RANGE,"0,"+rtos(max)+",0.01")); + p_list->push_back( PropertyInfo( Variant::REAL, "unit_offset", PROPERTY_HINT_RANGE,"0,1,0.0001",PROPERTY_USAGE_EDITOR)); + p_list->push_back( PropertyInfo( Variant::REAL, "h_offset") ); + p_list->push_back( PropertyInfo( Variant::REAL, "v_offset") ); + p_list->push_back( PropertyInfo( Variant::INT, "rotation_mode", PROPERTY_HINT_ENUM,"None,Y,XY,XYZ")); + p_list->push_back( PropertyInfo( Variant::BOOL, "cubic_interp")); + p_list->push_back( PropertyInfo( Variant::BOOL, "loop")); + p_list->push_back( PropertyInfo( Variant::REAL, "lookahead",PROPERTY_HINT_RANGE,"0.001,1024.0,0.001")); +} + + +void PathFollow::_bind_methods() { + + ObjectTypeDB::bind_method(_MD("set_offset","offset"),&PathFollow::set_offset); + ObjectTypeDB::bind_method(_MD("get_offset"),&PathFollow::get_offset); + + ObjectTypeDB::bind_method(_MD("set_h_offset","h_offset"),&PathFollow::set_h_offset); + ObjectTypeDB::bind_method(_MD("get_h_offset"),&PathFollow::get_h_offset); + + ObjectTypeDB::bind_method(_MD("set_v_offset","v_offset"),&PathFollow::set_v_offset); + ObjectTypeDB::bind_method(_MD("get_v_offset"),&PathFollow::get_v_offset); + + ObjectTypeDB::bind_method(_MD("set_unit_offset","unit_offset"),&PathFollow::set_unit_offset); + ObjectTypeDB::bind_method(_MD("get_unit_offset"),&PathFollow::get_unit_offset); + + ObjectTypeDB::bind_method(_MD("set_rotation_mode","rotation_mode"),&PathFollow::set_rotation_mode); + ObjectTypeDB::bind_method(_MD("get_rotation_mode"),&PathFollow::get_rotation_mode); + + ObjectTypeDB::bind_method(_MD("set_cubic_interpolation","enable"),&PathFollow::set_cubic_interpolation); + ObjectTypeDB::bind_method(_MD("get_cubic_interpolation"),&PathFollow::get_cubic_interpolation); + + ObjectTypeDB::bind_method(_MD("set_loop","loop"),&PathFollow::set_loop); + ObjectTypeDB::bind_method(_MD("has_loop"),&PathFollow::has_loop); + + BIND_CONSTANT( ROTATION_NONE ); + BIND_CONSTANT( ROTATION_Y ); + BIND_CONSTANT( ROTATION_XY ); + BIND_CONSTANT( ROTATION_XYZ ); + +} + +void PathFollow::set_offset(float p_offset) { + + offset=p_offset; + if (path) + _update_transform(); + _change_notify("offset"); + _change_notify("unit_offset"); + +} + +void PathFollow::set_h_offset(float p_h_offset) { + + h_offset=p_h_offset; + if (path) + _update_transform(); + +} + +float PathFollow::get_h_offset() const { + + return h_offset; +} + +void PathFollow::set_v_offset(float p_v_offset) { + + v_offset=p_v_offset; + if (path) + _update_transform(); + +} + +float PathFollow::get_v_offset() const { + + return v_offset; +} + + +float PathFollow::get_offset() const{ + + return offset; +} + +void PathFollow::set_unit_offset(float p_unit_offset) { + + if (path && path->get_curve().is_valid() && path->get_curve()->get_baked_length()) + set_offset(p_unit_offset*path->get_curve()->get_baked_length()); + +} + +float PathFollow::get_unit_offset() const{ + + if (path && path->get_curve().is_valid() && path->get_curve()->get_baked_length()) + return get_offset()/path->get_curve()->get_baked_length(); + else + return 0; +} + +void PathFollow::set_lookahead(float p_lookahead) { + + lookahead=p_lookahead; + +} + +float PathFollow::get_lookahead() const{ + + return lookahead; +} + +void PathFollow::set_rotation_mode(RotationMode p_rotation_mode) { + + rotation_mode=p_rotation_mode; + _update_transform(); +} + +PathFollow::RotationMode PathFollow::get_rotation_mode() const { + + return rotation_mode; +} + +void PathFollow::set_loop(bool p_loop) { + + loop=p_loop; +} + +bool PathFollow::has_loop() const{ + + return loop; +} + + +PathFollow::PathFollow() { + + offset=0; + h_offset=0; + v_offset=0; + path=NULL; + rotation_mode=ROTATION_XYZ; + cubic=true; + loop=true; + lookahead=0.1; +} diff --git a/scene/3d/physics_body.cpp b/scene/3d/physics_body.cpp index 15ec60514a..a80fdce64c 100644 --- a/scene/3d/physics_body.cpp +++ b/scene/3d/physics_body.cpp @@ -193,7 +193,7 @@ StaticBody::~StaticBody() { -void RigidBody::_body_enter_scene(ObjectID p_id) { +void RigidBody::_body_enter_tree(ObjectID p_id) { Object *obj = ObjectDB::get_instance(p_id); Node *node = obj ? obj->cast_to() : NULL; @@ -201,9 +201,9 @@ void RigidBody::_body_enter_scene(ObjectID p_id) { Map::Element *E=contact_monitor->body_map.find(p_id); ERR_FAIL_COND(!E); - ERR_FAIL_COND(E->get().in_scene); + ERR_FAIL_COND(E->get().in_tree); - E->get().in_scene=true; + E->get().in_tree=true; emit_signal(SceneStringNames::get_singleton()->body_enter,node); for(int i=0;iget().shapes.size();i++) { @@ -213,15 +213,15 @@ void RigidBody::_body_enter_scene(ObjectID p_id) { } -void RigidBody::_body_exit_scene(ObjectID p_id) { +void RigidBody::_body_exit_tree(ObjectID p_id) { Object *obj = ObjectDB::get_instance(p_id); Node *node = obj ? obj->cast_to() : NULL; ERR_FAIL_COND(!node); Map::Element *E=contact_monitor->body_map.find(p_id); ERR_FAIL_COND(!E); - ERR_FAIL_COND(!E->get().in_scene); - E->get().in_scene=false; + ERR_FAIL_COND(!E->get().in_tree); + E->get().in_tree=false; emit_signal(SceneStringNames::get_singleton()->body_exit,node); for(int i=0;iget().shapes.size();i++) { @@ -246,11 +246,11 @@ void RigidBody::_body_inout(int p_status, ObjectID p_instance, int p_body_shape, E = contact_monitor->body_map.insert(objid,BodyState()); //E->get().rc=0; - E->get().in_scene=node && node->is_inside_scene(); + E->get().in_tree=node && node->is_inside_tree(); if (node) { - node->connect(SceneStringNames::get_singleton()->enter_scene,this,SceneStringNames::get_singleton()->_body_enter_scene,make_binds(objid)); - node->connect(SceneStringNames::get_singleton()->exit_scene,this,SceneStringNames::get_singleton()->_body_exit_scene,make_binds(objid)); - if (E->get().in_scene) { + node->connect(SceneStringNames::get_singleton()->enter_tree,this,SceneStringNames::get_singleton()->_body_enter_tree,make_binds(objid)); + node->connect(SceneStringNames::get_singleton()->exit_tree,this,SceneStringNames::get_singleton()->_body_exit_tree,make_binds(objid)); + if (E->get().in_tree) { emit_signal(SceneStringNames::get_singleton()->body_enter,node); } } @@ -261,7 +261,7 @@ void RigidBody::_body_inout(int p_status, ObjectID p_instance, int p_body_shape, E->get().shapes.insert(ShapePair(p_body_shape,p_local_shape)); - if (E->get().in_scene) { + if (E->get().in_tree) { emit_signal(SceneStringNames::get_singleton()->body_enter_shape,objid,node,p_body_shape,p_local_shape); } @@ -272,21 +272,21 @@ void RigidBody::_body_inout(int p_status, ObjectID p_instance, int p_body_shape, if (node) E->get().shapes.erase(ShapePair(p_body_shape,p_local_shape)); - bool in_scene = E->get().in_scene; + bool in_tree = E->get().in_tree; if (E->get().shapes.empty()) { if (node) { - node->disconnect(SceneStringNames::get_singleton()->enter_scene,this,SceneStringNames::get_singleton()->_body_enter_scene); - node->disconnect(SceneStringNames::get_singleton()->exit_scene,this,SceneStringNames::get_singleton()->_body_exit_scene); - if (in_scene) + node->disconnect(SceneStringNames::get_singleton()->enter_tree,this,SceneStringNames::get_singleton()->_body_enter_tree); + node->disconnect(SceneStringNames::get_singleton()->exit_tree,this,SceneStringNames::get_singleton()->_body_exit_tree); + if (in_tree) emit_signal(SceneStringNames::get_singleton()->body_exit,obj); } contact_monitor->body_map.erase(E); } - if (node && in_scene) { + if (node && in_tree) { emit_signal(SceneStringNames::get_singleton()->body_exit_shape,objid,obj,p_body_shape,p_local_shape); } @@ -682,8 +682,8 @@ void RigidBody::_bind_methods() { ObjectTypeDB::bind_method(_MD("is_able_to_sleep"),&RigidBody::is_able_to_sleep); ObjectTypeDB::bind_method(_MD("_direct_state_changed"),&RigidBody::_direct_state_changed); - ObjectTypeDB::bind_method(_MD("_body_enter_scene"),&RigidBody::_body_enter_scene); - ObjectTypeDB::bind_method(_MD("_body_exit_scene"),&RigidBody::_body_exit_scene); + ObjectTypeDB::bind_method(_MD("_body_enter_tree"),&RigidBody::_body_enter_tree); + ObjectTypeDB::bind_method(_MD("_body_exit_tree"),&RigidBody::_body_exit_tree); ObjectTypeDB::bind_method(_MD("set_axis_lock","axis_lock"),&RigidBody::set_axis_lock); ObjectTypeDB::bind_method(_MD("get_axis_lock"),&RigidBody::get_axis_lock); @@ -792,7 +792,7 @@ Vector3 KinematicBody::move(const Vector3& p_motion) { colliding=false; - ERR_FAIL_COND_V(!is_inside_scene(),Vector3()); + ERR_FAIL_COND_V(!is_inside_tree(),Vector3()); PhysicsDirectSpaceState *dss = PhysicsServer::get_singleton()->space_get_direct_state(get_world()->get_space()); ERR_FAIL_COND_V(!dss,Vector3()); const int max_shapes=32; @@ -989,7 +989,7 @@ Vector3 KinematicBody::move_to(const Vector3& p_position) { bool KinematicBody::can_move_to(const Vector3& p_position, bool p_discrete) { - ERR_FAIL_COND_V(!is_inside_scene(),false); + ERR_FAIL_COND_V(!is_inside_tree(),false); PhysicsDirectSpaceState *dss = PhysicsServer::get_singleton()->space_get_direct_state(get_world()->get_space()); ERR_FAIL_COND_V(!dss,false); @@ -1029,7 +1029,7 @@ bool KinematicBody::can_move_to(const Vector3& p_position, bool p_discrete) { bool KinematicBody::is_colliding() const { - ERR_FAIL_COND_V(!is_inside_scene(),false); + ERR_FAIL_COND_V(!is_inside_tree(),false); return colliding; } diff --git a/scene/3d/physics_body.h b/scene/3d/physics_body.h index a19ad48c87..f9f028e20d 100644 --- a/scene/3d/physics_body.h +++ b/scene/3d/physics_body.h @@ -163,7 +163,7 @@ private: struct BodyState { //int rc; - bool in_scene; + bool in_tree; VSet shapes; }; @@ -176,8 +176,8 @@ private: ContactMonitor *contact_monitor; - void _body_enter_scene(ObjectID p_id); - void _body_exit_scene(ObjectID p_id); + void _body_enter_tree(ObjectID p_id); + void _body_exit_tree(ObjectID p_id); void _body_inout(int p_status, ObjectID p_instance, int p_body_shape,int p_local_shape); diff --git a/scene/3d/physics_joint.cpp b/scene/3d/physics_joint.cpp index 8a79e17d87..8d9257a273 100644 --- a/scene/3d/physics_joint.cpp +++ b/scene/3d/physics_joint.cpp @@ -42,7 +42,7 @@ void Joint::_update_joint(bool p_only_free) { bb=RID(); } - if (p_only_free || !is_inside_scene()) + if (p_only_free || !is_inside_tree()) return; Node *node_a = has_node( get_node_a() ) ? get_node( get_node_a() ) : (Node*)NULL; @@ -131,7 +131,7 @@ void Joint::_notification(int p_what) { case NOTIFICATION_READY: { _update_joint(); } break; - case NOTIFICATION_EXIT_SCENE: { + case NOTIFICATION_EXIT_TREE: { if (joint.is_valid()) { _update_joint(true); PhysicsServer::get_singleton()->free(joint); diff --git a/scene/3d/proximity_group.cpp b/scene/3d/proximity_group.cpp index b3378c7698..a30a23aa53 100644 --- a/scene/3d/proximity_group.cpp +++ b/scene/3d/proximity_group.cpp @@ -119,7 +119,7 @@ void ProximityGroup::_notification(int what) { switch (what) { - case NOTIFICATION_EXIT_SCENE: + case NOTIFICATION_EXIT_TREE: ++group_version; clear_groups(); break; @@ -135,7 +135,7 @@ void ProximityGroup::broadcast(String p_name, Variant p_params) { E = groups.front(); while (E) { - get_scene()->call_group(SceneMainLoop::GROUP_CALL_DEFAULT, E->key(), "_proximity_group_broadcast", p_name, p_params); + get_tree()->call_group(SceneTree::GROUP_CALL_DEFAULT, E->key(), "_proximity_group_broadcast", p_name, p_params); E = E->next(); }; diff --git a/scene/3d/quad.cpp b/scene/3d/quad.cpp index 78dd56141c..8ee232fef4 100644 --- a/scene/3d/quad.cpp +++ b/scene/3d/quad.cpp @@ -31,7 +31,7 @@ void Quad::_update() { - if (!is_inside_scene()) + if (!is_inside_tree()) return; Vector3 normal; @@ -171,14 +171,14 @@ void Quad::_notification(int p_what) { switch(p_what) { - case NOTIFICATION_ENTER_SCENE: { + case NOTIFICATION_ENTER_TREE: { if (pending_update) _update(); } break; - case NOTIFICATION_EXIT_SCENE: { + case NOTIFICATION_EXIT_TREE: { pending_update=true; diff --git a/scene/3d/ray_cast.cpp b/scene/3d/ray_cast.cpp index e36e2da14f..6bc0c677c0 100644 --- a/scene/3d/ray_cast.cpp +++ b/scene/3d/ray_cast.cpp @@ -33,7 +33,7 @@ void RayCast::set_cast_to(const Vector3& p_point) { cast_to=p_point; - if (is_inside_scene() && get_scene()->is_editor_hint()) + if (is_inside_tree() && get_tree()->is_editor_hint()) update_gizmo(); } @@ -72,7 +72,7 @@ Vector3 RayCast::get_collision_normal() const{ void RayCast::set_enabled(bool p_enabled) { enabled=p_enabled; - if (is_inside_scene() && !get_scene()->is_editor_hint()) + if (is_inside_tree() && !get_tree()->is_editor_hint()) set_fixed_process(p_enabled); if (!p_enabled) collided=false; @@ -91,9 +91,9 @@ void RayCast::_notification(int p_what) { switch(p_what) { - case NOTIFICATION_ENTER_SCENE: { + case NOTIFICATION_ENTER_TREE: { - if (enabled && !get_scene()->is_editor_hint()) { + if (enabled && !get_tree()->is_editor_hint()) { set_fixed_process(true); Node *p = get_parent(); while( p && p->cast_to() ) { @@ -113,7 +113,7 @@ void RayCast::_notification(int p_what) { } break; - case NOTIFICATION_EXIT_SCENE: { + case NOTIFICATION_EXIT_TREE: { if (enabled) { set_fixed_process(false); diff --git a/scene/3d/room_instance.cpp b/scene/3d/room_instance.cpp index fa1d3ecf6b..3f9e6c7f13 100644 --- a/scene/3d/room_instance.cpp +++ b/scene/3d/room_instance.cpp @@ -147,7 +147,7 @@ void Room::set_room( const Ref& p_room ) { set_base(RID()); } - if (!is_inside_scene()) + if (!is_inside_tree()) return; diff --git a/scene/3d/skeleton.cpp b/scene/3d/skeleton.cpp index 737f7d2dce..f53ee7d6bf 100644 --- a/scene/3d/skeleton.cpp +++ b/scene/3d/skeleton.cpp @@ -243,10 +243,10 @@ void Skeleton::set_bone_global_pose(int p_bone,const Transform& p_pose) { ERR_FAIL_INDEX(p_bone,bones.size()); if (bones[p_bone].parent==-1) { - set_bone_pose(p_bone,bones[p_bone].rest.inverse() * p_pose); + set_bone_pose(p_bone,bones[p_bone].rest_global_inverse * p_pose); //fast } else { - set_bone_pose(p_bone, bones[p_bone].rest.inverse() * (get_bone_global_pose(bones[p_bone].parent).affine_inverse() * p_pose)); + set_bone_pose(p_bone, bones[p_bone].rest.affine_inverse() * (get_bone_global_pose(bones[p_bone].parent).affine_inverse() * p_pose)); //slow } @@ -404,7 +404,7 @@ void Skeleton::clear_bones() { void Skeleton::set_bone_pose(int p_bone, const Transform& p_pose) { ERR_FAIL_INDEX( p_bone, bones.size() ); - ERR_FAIL_COND( !is_inside_scene() ); + ERR_FAIL_COND( !is_inside_tree() ); bones[p_bone].pose=p_pose; @@ -442,7 +442,7 @@ void Skeleton::_make_dirty() { if (dirty) return; - if (!is_inside_scene()) { + if (!is_inside_tree()) { dirty=true; return; } diff --git a/scene/3d/spatial.cpp b/scene/3d/spatial.cpp index d304095d33..a5b009823c 100644 --- a/scene/3d/spatial.cpp +++ b/scene/3d/spatial.cpp @@ -76,7 +76,7 @@ void Spatial::_notify_dirty() { if (!data.ignore_notification && !xform_change.in_list()) { - get_scene()->xform_change_list.add(&xform_change); + get_tree()->xform_change_list.add(&xform_change); } } @@ -91,7 +91,7 @@ void Spatial::_update_local_transform() const { } void Spatial::_propagate_transform_changed(Spatial *p_origin) { - if (!is_inside_scene()) { + if (!is_inside_tree()) { return; } @@ -110,7 +110,7 @@ void Spatial::_propagate_transform_changed(Spatial *p_origin) { if (!data.ignore_notification && !xform_change.in_list()) { - get_scene()->xform_change_list.add(&xform_change); + get_tree()->xform_change_list.add(&xform_change); } data.dirty|=DIRTY_GLOBAL; @@ -121,7 +121,7 @@ void Spatial::_propagate_transform_changed(Spatial *p_origin) { void Spatial::_notification(int p_what) { switch(p_what) { - case NOTIFICATION_ENTER_SCENE: { + case NOTIFICATION_ENTER_TREE: { Node *p = get_parent(); if (p) @@ -132,7 +132,7 @@ void Spatial::_notification(int p_what) { else data.C=NULL; - if (data.toplevel && !get_scene()->is_editor_hint()) { + if (data.toplevel && !get_tree()->is_editor_hint()) { if (data.parent) { data.local_transform = data.parent->get_global_transform() * get_transform(); @@ -147,11 +147,11 @@ void Spatial::_notification(int p_what) { notification(NOTIFICATION_ENTER_WORLD); } break; - case NOTIFICATION_EXIT_SCENE: { + case NOTIFICATION_EXIT_TREE: { notification(NOTIFICATION_EXIT_WORLD,true); if (xform_change.in_list()) - get_scene()->xform_change_list.remove(&xform_change); + get_tree()->xform_change_list.remove(&xform_change); if (data.C) data.parent->data.children.erase(data.C); data.parent=NULL; @@ -177,10 +177,10 @@ void Spatial::_notification(int p_what) { get_script_instance()->call_multilevel(SceneStringNames::get_singleton()->_enter_world,NULL,0); } #ifdef TOOLS_ENABLED - if (get_scene()->is_editor_hint()) { + if (get_tree()->is_editor_hint()) { // get_scene()->call_group(SceneMainLoop::GROUP_CALL_REALTIME,SceneStringNames::get_singleton()->_spatial_editor_group,SceneStringNames::get_singleton()->_request_gizmo,this); - get_scene()->call_group(0,SceneStringNames::get_singleton()->_spatial_editor_group,SceneStringNames::get_singleton()->_request_gizmo,this); + get_tree()->call_group(0,SceneStringNames::get_singleton()->_spatial_editor_group,SceneStringNames::get_singleton()->_request_gizmo,this); if (!data.gizmo_disabled) { if (data.gizmo.is_valid()) @@ -257,7 +257,7 @@ Transform Spatial::get_transform() const { } Transform Spatial::get_global_transform() const { - ERR_FAIL_COND_V(!is_inside_scene(), Transform()); + ERR_FAIL_COND_V(!is_inside_tree(), Transform()); if (data.dirty & DIRTY_GLOBAL) { @@ -460,7 +460,7 @@ void Spatial::set_as_toplevel(bool p_enabled) { if (data.toplevel==p_enabled) return; - if (is_inside_scene() && !get_scene()->is_editor_hint()) { + if (is_inside_tree() && !get_tree()->is_editor_hint()) { if (p_enabled) set_transform(get_global_transform()); @@ -537,7 +537,7 @@ void Spatial::show() { data.visible=true; - if (!is_inside_scene()) + if (!is_inside_tree()) return; if (!data.parent || is_visible()) { diff --git a/scene/3d/spatial.h b/scene/3d/spatial.h index 7036ef63ca..49ecf5779b 100644 --- a/scene/3d/spatial.h +++ b/scene/3d/spatial.h @@ -130,7 +130,7 @@ public: enum { - NOTIFICATION_TRANSFORM_CHANGED=SceneMainLoop::NOTIFICATION_TRANSFORM_CHANGED, + NOTIFICATION_TRANSFORM_CHANGED=SceneTree::NOTIFICATION_TRANSFORM_CHANGED, NOTIFICATION_ENTER_WORLD=41, NOTIFICATION_EXIT_WORLD=42, NOTIFICATION_VISIBILITY_CHANGED=43, diff --git a/scene/3d/spatial_stream_player.cpp b/scene/3d/spatial_stream_player.cpp index 25448498cb..51009662d6 100644 --- a/scene/3d/spatial_stream_player.cpp +++ b/scene/3d/spatial_stream_player.cpp @@ -74,7 +74,7 @@ Ref SpatialStreamPlayer::get_stream() const { void SpatialStreamPlayer::play() { - if (!is_inside_scene()) + if (!is_inside_tree()) return; if (stream.is_null()) return; @@ -89,7 +89,7 @@ void SpatialStreamPlayer::play() { void SpatialStreamPlayer::stop() { - if (!is_inside_scene()) + if (!is_inside_tree()) return; if (stream.is_null()) return; diff --git a/scene/3d/sprite_3d.cpp b/scene/3d/sprite_3d.cpp index 334a15e724..a6a8919d13 100644 --- a/scene/3d/sprite_3d.cpp +++ b/scene/3d/sprite_3d.cpp @@ -37,7 +37,7 @@ void SpriteBase3D::_propagate_color_changed() { void SpriteBase3D::_notification(int p_what) { - if (p_what==NOTIFICATION_ENTER_SCENE) { + if (p_what==NOTIFICATION_ENTER_TREE) { if (!pending_update) _im_update(); @@ -52,7 +52,7 @@ void SpriteBase3D::_notification(int p_what) { } } - if (p_what==NOTIFICATION_EXIT_SCENE) { + if (p_what==NOTIFICATION_EXIT_TREE) { if (parent_sprite) { diff --git a/scene/3d/vehicle_body.cpp b/scene/3d/vehicle_body.cpp index 4cf905e4ee..ba30c118f0 100644 --- a/scene/3d/vehicle_body.cpp +++ b/scene/3d/vehicle_body.cpp @@ -57,7 +57,7 @@ public: void VehicleWheel::_notification(int p_what) { - if (p_what==NOTIFICATION_ENTER_SCENE) { + if (p_what==NOTIFICATION_ENTER_TREE) { if (!get_parent()) return; @@ -73,7 +73,7 @@ void VehicleWheel::_notification(int p_what) { m_wheelAxleCS = get_transform().basis.get_axis(Vector3::AXIS_X).normalized(); } - if (p_what==NOTIFICATION_EXIT_SCENE) { + if (p_what==NOTIFICATION_EXIT_TREE) { if (!get_parent()) return; diff --git a/scene/3d/visibility_notifier.cpp b/scene/3d/visibility_notifier.cpp index 60e311cefe..d4ef2931e9 100644 --- a/scene/3d/visibility_notifier.cpp +++ b/scene/3d/visibility_notifier.cpp @@ -183,7 +183,7 @@ void VisibilityEnabler::_find_nodes(Node* p_node) { if (add) { - p_node->connect(SceneStringNames::get_singleton()->exit_scene,this,"_node_removed",varray(p_node),CONNECT_ONESHOT); + p_node->connect(SceneStringNames::get_singleton()->exit_tree,this,"_node_removed",varray(p_node),CONNECT_ONESHOT); nodes[p_node]=meta; _change_node_state(p_node,false); } @@ -200,9 +200,9 @@ void VisibilityEnabler::_find_nodes(Node* p_node) { void VisibilityEnabler::_notification(int p_what){ - if (p_what==NOTIFICATION_ENTER_SCENE) { + if (p_what==NOTIFICATION_ENTER_TREE) { - if (get_scene()->is_editor_hint()) + if (get_tree()->is_editor_hint()) return; @@ -215,9 +215,9 @@ void VisibilityEnabler::_notification(int p_what){ } - if (p_what==NOTIFICATION_EXIT_SCENE) { + if (p_what==NOTIFICATION_EXIT_TREE) { - if (get_scene()->is_editor_hint()) + if (get_tree()->is_editor_hint()) return; @@ -228,7 +228,7 @@ void VisibilityEnabler::_notification(int p_what){ if (!visible) _change_node_state(E->key(),true); - E->key()->disconnect(SceneStringNames::get_singleton()->exit_scene,this,"_node_removed"); + E->key()->disconnect(SceneStringNames::get_singleton()->exit_tree,this,"_node_removed"); } nodes.clear(); @@ -271,7 +271,7 @@ void VisibilityEnabler::_node_removed(Node* p_node) { if (!visible) _change_node_state(p_node,true); - p_node->disconnect(SceneStringNames::get_singleton()->exit_scene,this,"_node_removed"); + p_node->disconnect(SceneStringNames::get_singleton()->exit_tree,this,"_node_removed"); nodes.erase(p_node); } diff --git a/scene/3d/visual_instance.cpp b/scene/3d/visual_instance.cpp index 398fbdea82..5b40a4d7e5 100644 --- a/scene/3d/visual_instance.cpp +++ b/scene/3d/visual_instance.cpp @@ -257,7 +257,7 @@ void GeometryInstance::_find_baked_light() { void GeometryInstance::_update_visibility() { - if (!is_inside_scene()) + if (!is_inside_tree()) return; _change_notify("geometry/visible"); -- cgit v1.2.3