diff options
Diffstat (limited to 'scene')
54 files changed, 79 insertions, 4319 deletions
diff --git a/scene/2d/collision_polygon_2d.cpp b/scene/2d/collision_polygon_2d.cpp index b373d391b2..e2764a6e8d 100644 --- a/scene/2d/collision_polygon_2d.cpp +++ b/scene/2d/collision_polygon_2d.cpp @@ -79,11 +79,6 @@ void CollisionPolygon2D::_build_polygon() { Vector<Vector<Vector2> > CollisionPolygon2D::_decompose_in_convex() { Vector<Vector<Vector2> > decomp; -#if 0 - //fast but imprecise triangulator, gave us problems - decomp = Geometry::decompose_polygon(polygon); -#else - List<TriangulatorPoly> in_poly, out_poly; TriangulatorPoly inp; @@ -116,8 +111,6 @@ Vector<Vector<Vector2> > CollisionPolygon2D::_decompose_in_convex() { idx++; } -#endif - return decomp; } diff --git a/scene/2d/navigation2d.cpp b/scene/2d/navigation2d.cpp index 00afd3bf99..fa488b6b23 100644 --- a/scene/2d/navigation2d.cpp +++ b/scene/2d/navigation2d.cpp @@ -236,42 +236,6 @@ void Navigation2D::navpoly_remove(int p_id) { _navpoly_unlink(p_id); navpoly_map.erase(p_id); } -#if 0 -void Navigation2D::_clip_path(Vector<Vector2>& path, Polygon *from_poly, const Vector2& p_to_point, Polygon* p_to_poly) { - - Vector2 from = path[path.size()-1]; - - if (from.distance_to(p_to_point)<CMP_EPSILON) - return; - Plane cut_plane; - cut_plane.normal = (from-p_to_point).cross(up); - if (cut_plane.normal==Vector2()) - return; - cut_plane.normal.normalize(); - cut_plane.d = cut_plane.normal.dot(from); - - - while(from_poly!=p_to_poly) { - - int pe = from_poly->prev_edge; - Vector2 a = _get_vertex(from_poly->edges[pe].point); - Vector2 b = _get_vertex(from_poly->edges[(pe+1)%from_poly->edges.size()].point); - - from_poly=from_poly->edges[pe].C; - ERR_FAIL_COND(!from_poly); - - if (a.distance_to(b)>CMP_EPSILON) { - - Vector2 inters; - if (cut_plane.intersects_segment(a,b,&inters)) { - if (inters.distance_to(p_to_point)>CMP_EPSILON && inters.distance_to(path[path.size()-1])>CMP_EPSILON) { - path.push_back(inters); - } - } - } - } -} -#endif Vector<Vector2> Navigation2D::get_simple_path(const Vector2 &p_start, const Vector2 &p_end, bool p_optimize) { @@ -498,29 +462,7 @@ Vector<Vector2> Navigation2D::get_simple_path(const Vector2 &p_start, const Vect open_list.erase(least_cost_poly); } -#if 0 -debug path - { - Polygon *p=end_poly; - int idx=0; - - while(true) { - int prev = p->prev_edge; - int prev_n = (p->prev_edge+1)%p->edges.size(); - Vector2 point = (_get_vertex(p->edges[prev].point) + _get_vertex(p->edges[prev_n].point))*0.5; - String points; - for(int i=0;i<p->edges.size();i++) { - if (i>0) - points+=", "; - points+=_get_vertex(p->edges[i].point); - } - //print_line("poly "+itos(idx++)+" - "+points); - p = p->edges[prev].C; - if (p==begin_poly) - break; - } - } -#endif + if (found_route) { Vector<Vector2> path; diff --git a/scene/2d/navigation2d.h b/scene/2d/navigation2d.h index f65bfbce78..e87b01f7c5 100644 --- a/scene/2d/navigation2d.h +++ b/scene/2d/navigation2d.h @@ -153,9 +153,7 @@ class Navigation2D : public Node2D { float cell_size; Map<int, NavMesh> navpoly_map; int last_id; -#if 0 - void _clip_path(Vector<Vector2>& path,Polygon *from_poly, const Vector2& p_to_point, Polygon* p_to_poly); -#endif + protected: static void _bind_methods(); diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp index cffaa98b7b..6ac946ea37 100644 --- a/scene/2d/physics_body_2d.cpp +++ b/scene/2d/physics_body_2d.cpp @@ -182,29 +182,6 @@ real_t StaticBody2D::get_constant_angular_velocity() const { return constant_angular_velocity; } -#if 0 -void StaticBody2D::_update_xform() { - - if (!pre_xform || !pending) - return; - - setting=true; - - - Transform2D new_xform = get_global_transform(); //obtain the new one - - set_block_transform_notify(true); - Physics2DServer::get_singleton()->body_set_state(get_rid(),Physics2DServer::BODY_STATE_TRANSFORM,*pre_xform); //then simulate motion! - set_global_transform(*pre_xform); //but restore state to previous one in both visual and physics - set_block_transform_notify(false); - - Physics2DServer::get_singleton()->body_static_simulate_motion(get_rid(),new_xform); //then simulate motion! - - setting=false; - pending=false; - -} -#endif void StaticBody2D::set_friction(real_t p_friction) { diff --git a/scene/3d/camera.cpp b/scene/3d/camera.cpp index d229c6381f..02a7845e0b 100644 --- a/scene/3d/camera.cpp +++ b/scene/3d/camera.cpp @@ -339,15 +339,8 @@ Vector3 Camera::project_local_ray_normal(const Point2 &p_pos) const { ERR_FAIL_COND_V(!is_inside_tree(), Vector3()); } -#if 0 - Size2 viewport_size = get_viewport()->get_visible_rect().size; - Vector2 cpos = p_pos; -#else - Size2 viewport_size = get_viewport()->get_camera_rect_size(); Vector2 cpos = get_viewport()->get_camera_coords(p_pos); -#endif - Vector3 ray; if (mode == PROJECTION_ORTHOGONAL) { @@ -371,17 +364,9 @@ Vector3 Camera::project_ray_origin(const Point2 &p_pos) const { ERR_FAIL_COND_V(!is_inside_tree(), Vector3()); } -#if 0 - Size2 viewport_size = get_viewport()->get_visible_rect().size; - Vector2 cpos = p_pos; -#else - Size2 viewport_size = get_viewport()->get_camera_rect_size(); Vector2 cpos = get_viewport()->get_camera_coords(p_pos); -#endif - ERR_FAIL_COND_V(viewport_size.y == 0, Vector3()); - //float aspect = viewport_size.x / viewport_size.y; if (mode == PROJECTION_PERSPECTIVE) { diff --git a/scene/3d/character_camera.cpp b/scene/3d/character_camera.cpp deleted file mode 100644 index c9dfed5185..0000000000 --- a/scene/3d/character_camera.cpp +++ /dev/null @@ -1,718 +0,0 @@ -/*************************************************************************/ -/* character_camera.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 "character_camera.h" - -#include "physics_body.h" -#if 0 -void CharacterCamera::_set(const String& p_name, const Variant& p_value) { - - if (p_name=="type") - set_camera_type((CameraType)((int)(p_value))); - else if (p_name=="orbit") - set_orbit(p_value); - else if (p_name=="height") - set_height(p_value); - else if (p_name=="inclination") - set_inclination(p_value); - else if (p_name=="max_orbit_x") - set_max_orbit_x(p_value); - else if (p_name=="min_orbit_x") - set_min_orbit_x(p_value); - else if (p_name=="max_distance") - set_max_distance(p_value); - else if (p_name=="min_distance") - set_min_distance(p_value); - else if (p_name=="distance") - set_distance(p_value); - else if (p_name=="clip") - set_clip(p_value); - else if (p_name=="autoturn") - set_autoturn(p_value); - else if (p_name=="autoturn_tolerance") - set_autoturn_tolerance(p_value); - else if (p_name=="autoturn_speed") - set_autoturn_speed(p_value); - -} -Variant CharacterCamera::_get(const String& p_name) const { - - if (p_name=="type") - return get_camera_type(); - else if (p_name=="orbit") - return get_orbit(); - else if (p_name=="height") - return get_height(); - else if (p_name=="inclination") - return get_inclination(); - else if (p_name=="max_orbit_x") - return get_max_orbit_x(); - else if (p_name=="min_orbit_x") - return get_min_orbit_x(); - else if (p_name=="max_distance") - return get_max_distance(); - else if (p_name=="min_distance") - return get_min_distance(); - else if (p_name=="distance") - return get_distance(); - else if (p_name=="clip") - return has_clip(); - else if (p_name=="autoturn") - return has_autoturn(); - else if (p_name=="autoturn_tolerance") - return get_autoturn_tolerance(); - else if (p_name=="autoturn_speed") - return get_autoturn_speed(); - - return Variant(); -} - -void CharacterCamera::_get_property_list( List<PropertyInfo> *p_list) const { - - p_list->push_back( PropertyInfo( Variant::INT, "type", PROPERTY_HINT_ENUM, "Fixed,Follow") ); - p_list->push_back( PropertyInfo( Variant::VECTOR2, "orbit" ) ); - p_list->push_back( PropertyInfo( Variant::REAL, "height", PROPERTY_HINT_RANGE,"-1024,1024,0.01" ) ); - p_list->push_back( PropertyInfo( Variant::REAL, "inclination", PROPERTY_HINT_RANGE,"-90,90,0.01" ) ); - p_list->push_back( PropertyInfo( Variant::REAL, "max_orbit_x", PROPERTY_HINT_RANGE,"-90,90,0.01" ) ); - p_list->push_back( PropertyInfo( Variant::REAL, "min_orbit_x", PROPERTY_HINT_RANGE,"-90,90,0.01" ) ); - p_list->push_back( PropertyInfo( Variant::REAL, "min_distance", PROPERTY_HINT_RANGE,"0,100,0.01" ) ); - p_list->push_back( PropertyInfo( Variant::REAL, "max_distance", PROPERTY_HINT_RANGE,"0,100,0.01" ) ); - p_list->push_back( PropertyInfo( Variant::REAL, "distance", PROPERTY_HINT_RANGE,"0.01,1024,0,01") ); - p_list->push_back( PropertyInfo( Variant::BOOL, "clip") ); - p_list->push_back( PropertyInfo( Variant::BOOL, "autoturn") ); - p_list->push_back( PropertyInfo( Variant::REAL, "autoturn_tolerance", PROPERTY_HINT_RANGE,"1,90,0.01") ); - p_list->push_back( PropertyInfo( Variant::REAL, "autoturn_speed", PROPERTY_HINT_RANGE,"1,90,0.01") ); - - -} - -void CharacterCamera::_compute_camera() { - - - // update the transform with the next proposed transform (camera is 1 logic frame delayed) - - /* - float time = get_root_node()->get_frame_time(); - Vector3 oldp = accepted.get_origin(); - Vector3 newp = proposed.get_origin(); - - float frame_dist = time * - if (oldp.distance_to(newp) > - */ - - float time = get_root_node()->get_frame_time(); - - if (true) { - - if (clip_ray[0].clipped && clip_ray[1].clipped && clip_ray[2].clipped) { - //all have been clipped - proposed.origin=clip_ray[1].clip_pos; - - - } else { - - Vector3 rel=proposed.origin-target_pos; - - if (clip_ray[0].clipped && !clip_ray[2].clipped) { - - float distance = target_pos.distance_to(clip_ray[0].clip_pos); - real_t amount = 1.0-(distance/clip_len); - amount = CLAMP(amount,0,1); - - - rel=Matrix3(Vector3(0,1,0)), - rotate_orbit(Vector2(0,autoturn_speed*time*amount)); - } - if (clip_ray[2].clipped && !clip_ray[0].clipped) { - - float distance = target_pos.distance_to(clip_ray[2].clip_pos); - real_t amount = 1.0-(distance/clip_len); - amount = CLAMP(amount,0,1); - - rotate_orbit(Vector2(0,-autoturn_speed*time*amount)); - } - - } - } - - - Transform final; - - static float pos_ratio = 0.9; - static float rot_ratio = 10; - - Vector3 vec1 = accepted.origin; - Vector3 vec2 = proposed.origin; - final.origin = vec2.linear_interpolate(vec1, pos_ratio * time); - - Quat q1 = accepted.basis; - Quat q2 = proposed.basis; - final.basis = q1.slerp(q2, rot_ratio * time); - - accepted=final; - - _update_camera(); - - // calculate the next proposed transform - - - Vector3 new_pos; - Vector3 character_pos = get_global_transform().origin; - character_pos.y+=height; // height compensate - - if(type==CAMERA_FOLLOW) { - - - - /* calculate some variables */ - - Vector3 rel = follow_pos - character_pos; - - float l = rel.length(); - Vector3 rel_n = (l > 0) ? (rel/l) : Vector3(); -#if 1 - float ang = Math::acos(rel_n.dot( Vector3(0,1,0) )); - - Vector3 tangent = rel_n; - tangent.y=0; // get rid of y - if (tangent.length_squared() < CMP_EPSILON2) - tangent=Vector3(0,0,1); // use Z as tangent if rel is parallel to y - else - tangent.normalize(); - - /* now start applying the rules */ - - //clip distance - if (l > max_distance) - l=max_distance; - if (l < min_distance) - l=min_distance; - - //fix angle - - float ang_min = Math_PI * 0.5 + Math::deg2rad(min_orbit_x); - float ang_max = Math_PI * 0.5 + Math::deg2rad(max_orbit_x); - - if (ang<ang_min) - ang=ang_min; - if (ang>ang_max) - ang=ang_max; - - /* finally, rebuild the validated camera position */ - - new_pos=Vector3(0,Math::cos(ang),0); - new_pos+=tangent*Math::sin(ang); - new_pos*=l; - new_pos+=character_pos; -#else - if (l > max_distance) - l=max_distance; - if (l < min_distance) - l=min_distance; - - new_pos = character_pos + rel_n * l; - -#endif - follow_pos=new_pos; - - } else if (type==CAMERA_FIXED) { - - - if (distance<min_distance) - distance=min_distance; - if (distance>max_distance) - distance=max_distance; - - if (orbit.x<min_orbit_x) - orbit.x=min_orbit_x; - if (orbit.x>max_orbit_x) - orbit.x=max_orbit_x; - - Matrix3 m; - m.rotate(Vector3(0,1,0),-Math::deg2rad(orbit.y)); - m.rotate(Vector3(1,0,0),-Math::deg2rad(orbit.x)); - - new_pos = (m.get_axis(2) * distance) + character_pos; - - if (use_lookat_target) { - - Transform t = get_global_transform(); - Vector3 y = t.basis.get_axis(1).normalized(); - Vector3 z = lookat_target - character_pos; - z= (z - y * y.dot(z)).normalized(); - orbit.y = -Math::rad2deg(Math::atan2(z.x,z.z)) + 180; - - /* - Transform t = get_global_transform(); - Vector3 y = t.basis.get_axis(1).normalized(); - Vector3 z = lookat_target - t.origin; - z= (z - y * y.dot(z)).normalized(); - Vector3 x = z.cross(y).normalized(); - Transform t2; - t2.basis.set_axis(0,x); - t2.basis.set_axis(1,y); - t2.basis.set_axis(2,z); - t2.origin=t.origin; - - Vector3 local = t2.xform_inv(camera_pos); - - float ang = Math::atan2(local.x,local.y); - */ - - /* - - Vector3 vec1 = lookat_target - new_pos; - vec1.normalize(); - Vector3 vec2 = character_pos - new_pos; - vec2.normalize(); - - float dot = vec1.dot(vec2); - printf("dot %f\n", dot); - if ( dot < 0.5) { - - rotate_orbit(Vector2(0, 90)); - }; - */ - - - }; - } - - Vector3 target; - if (use_lookat_target) { - - target = lookat_target; - } else { - target = character_pos; - }; - - proposed.set_look_at(new_pos,target,Vector3(0,1,0)); - proposed = proposed * Transform(Matrix3(Vector3(1,0,0),Math::deg2rad(inclination)),Vector3()); //inclination - - - Vector<RID> exclude; - exclude.push_back(target_body); - - - - Vector3 rel = new_pos-target; - - for(int i=0;i<3;i++) { - - PhysicsServer::get_singleton()->query_intersection(clip_ray[i].query,get_world().get_space(),exclude); - PhysicsServer::get_singleton()->query_intersection_segment(clip_ray[i].query,target,target+Matrix3(Vector3(0,1,0),Math::deg2rad(autoturn_tolerance*(i-1.0))).xform(rel)); - clip_ray[i].clipped=false; - clip_ray[i].clip_pos=Vector3(); - } - target_pos=target; - clip_len=rel.length(); - - - -} - -void CharacterCamera::set_use_lookat_target(bool p_use, const Vector3 &p_lookat) { - - use_lookat_target = p_use; - lookat_target = p_lookat; -}; - - -void CharacterCamera::_notification(int p_what) { - - switch(p_what) { - - case NOTIFICATION_PROCESS: { - - - _compute_camera(); - } break; - - case NOTIFICATION_ENTER_SCENE: { - - if (type==CAMERA_FOLLOW) { - - set_orbit(orbit); - set_distance(distance); - } - - accepted=get_global_transform(); - proposed=accepted; - - target_body = RID(); - - Node* parent = get_parent(); - while (parent) { - PhysicsBody* p = Object::cast_to<PhysicsBody>(parent); - if (p) { - target_body = p->get_body(); - break; - }; - parent = parent->get_parent(); - }; - - } break; - - case NOTIFICATION_TRANSFORM_CHANGED: { - - } break; - case NOTIFICATION_EXIT_SCENE: { - - if (type==CAMERA_FOLLOW) { - distance=get_distance(); - orbit=get_orbit(); - - } - } break; - - case NOTIFICATION_BECAME_CURRENT: { - - set_process(true); - } break; - case NOTIFICATION_LOST_CURRENT: { - - set_process(false); - } break; - } - -} - - -void CharacterCamera::set_camera_type(CameraType p_camera_type) { - - - if (p_camera_type==type) - return; - - type=p_camera_type; - - // do conversions -} - -CharacterCamera::CameraType CharacterCamera::get_camera_type() const { - - return type; - -} - -void CharacterCamera::set_orbit(const Vector2& p_orbit) { - - orbit=p_orbit; - - if(type == CAMERA_FOLLOW && is_inside_scene()) { - - Vector3 char_pos = get_global_transform().origin; - char_pos.y+=height; - float d = char_pos.distance_to(follow_pos); - - Matrix3 m; - m.rotate(Vector3(0,1,0),-orbit.y); - m.rotate(Vector3(1,0,0),-orbit.x); - - follow_pos=char_pos + m.get_axis(2) * d; - - } - -} -void CharacterCamera::set_orbit_x(float p_x) { - - orbit.x=p_x; - if(type == CAMERA_FOLLOW && is_inside_scene()) - set_orbit(Vector2( p_x, get_orbit().y )); -} -void CharacterCamera::set_orbit_y(float p_y) { - - - orbit.y=p_y; - if(type == CAMERA_FOLLOW && is_inside_scene()) - set_orbit(Vector2( get_orbit().x, p_y )); - -} -Vector2 CharacterCamera::get_orbit() const { - - - if (type == CAMERA_FOLLOW && is_inside_scene()) { - - Vector3 char_pos = get_global_transform().origin; - char_pos.y+=height; - Vector3 rel = (follow_pos - char_pos).normalized(); - Vector2 ret_orbit; - ret_orbit.x = Math::acos( Vector3(0,1,0).dot( rel ) ) - Math_PI * 0.5; - ret_orbit.y = Math::atan2(rel.x,rel.z); - return ret_orbit; - } - return orbit; -} - -void CharacterCamera::rotate_orbit(const Vector2& p_relative) { - - if (type == CAMERA_FOLLOW && is_inside_scene()) { - - Matrix3 m; - m.rotate(Vector3(0,1,0),-Math::deg2rad(p_relative.y)); - m.rotate(Vector3(1,0,0),-Math::deg2rad(p_relative.x)); - - Vector3 char_pos = get_global_transform().origin; - char_pos.y+=height; - Vector3 rel = (follow_pos - char_pos); - rel = m.xform(rel); - follow_pos=char_pos+rel; - - } - - orbit+=p_relative; -} - -void CharacterCamera::set_height(float p_height) { - - - height=p_height; -} - -float CharacterCamera::get_height() const { - - return height; - -} - -void CharacterCamera::set_max_orbit_x(float p_max) { - - max_orbit_x=p_max; -} - -float CharacterCamera::get_max_orbit_x() const { - - return max_orbit_x; -} - -void CharacterCamera::set_min_orbit_x(float p_min) { - - min_orbit_x=p_min; -} - -float CharacterCamera::get_min_orbit_x() const { - - return min_orbit_x; -} - -float CharacterCamera::get_min_distance() const { - - return min_distance; -} -float CharacterCamera::get_max_distance() const { - - return max_distance; -} - -void CharacterCamera::set_min_distance(float p_min) { - - min_distance=p_min; -} - -void CharacterCamera::set_max_distance(float p_max) { - - max_distance = p_max; -} - - -void CharacterCamera::set_distance(float p_distance) { - - if (type == CAMERA_FOLLOW && is_inside_scene()) { - - Vector3 char_pos = get_global_transform().origin; - char_pos.y+=height; - Vector3 rel = (follow_pos - char_pos).normalized(); - rel*=p_distance; - follow_pos=char_pos+rel; - - } - - distance=p_distance; -} - -float CharacterCamera::get_distance() const { - - if (type == CAMERA_FOLLOW && is_inside_scene()) { - - Vector3 char_pos = get_global_transform().origin; - char_pos.y+=height; - return (follow_pos - char_pos).length(); - - } - - return distance; -} - -void CharacterCamera::set_clip(bool p_enabled) { - - - clip=p_enabled; -} - -bool CharacterCamera::has_clip() const { - - return clip; - -} - - -void CharacterCamera::set_autoturn(bool p_enabled) { - - - autoturn=p_enabled; -} - -bool CharacterCamera::has_autoturn() const { - - return autoturn; - -} - -void CharacterCamera::set_autoturn_tolerance(float p_degrees) { - - - autoturn_tolerance=p_degrees; -} -float CharacterCamera::get_autoturn_tolerance() const { - - - return autoturn_tolerance; -} - -void CharacterCamera::set_inclination(float p_degrees) { - - - inclination=p_degrees; -} -float CharacterCamera::get_inclination() const { - - - return inclination; -} - - -void CharacterCamera::set_autoturn_speed(float p_speed) { - - - autoturn_speed=p_speed; -} -float CharacterCamera::get_autoturn_speed() const { - - return autoturn_speed; - -} - - - - - -void CharacterCamera::_bind_methods() { - - ClassDB::bind_method(D_METHOD("set_camera_type","type"),&CharacterCamera::set_camera_type); - ClassDB::bind_method(D_METHOD("get_camera_type"),&CharacterCamera::get_camera_type); - ClassDB::bind_method(D_METHOD("set_orbit","orbit"),&CharacterCamera::set_orbit); - ClassDB::bind_method(D_METHOD("get_orbit"),&CharacterCamera::get_orbit); - ClassDB::bind_method(D_METHOD("set_orbit_x","x"),&CharacterCamera::set_orbit_x); - ClassDB::bind_method(D_METHOD("set_orbit_y","y"),&CharacterCamera::set_orbit_y); - ClassDB::bind_method(D_METHOD("set_min_orbit_x","x"),&CharacterCamera::set_min_orbit_x); - ClassDB::bind_method(D_METHOD("get_min_orbit_x"),&CharacterCamera::get_min_orbit_x); - ClassDB::bind_method(D_METHOD("set_max_orbit_x","x"),&CharacterCamera::set_max_orbit_x); - ClassDB::bind_method(D_METHOD("get_max_orbit_x"),&CharacterCamera::get_max_orbit_x); - ClassDB::bind_method(D_METHOD("rotate_orbit"),&CharacterCamera::rotate_orbit); - ClassDB::bind_method(D_METHOD("set_distance","distance"),&CharacterCamera::set_distance); - ClassDB::bind_method(D_METHOD("get_distance"),&CharacterCamera::get_distance); - ClassDB::bind_method(D_METHOD("set_clip","enable"),&CharacterCamera::set_clip); - ClassDB::bind_method(D_METHOD("has_clip"),&CharacterCamera::has_clip); - ClassDB::bind_method(D_METHOD("set_autoturn","enable"),&CharacterCamera::set_autoturn); - ClassDB::bind_method(D_METHOD("has_autoturn"),&CharacterCamera::has_autoturn); - ClassDB::bind_method(D_METHOD("set_autoturn_tolerance","degrees"),&CharacterCamera::set_autoturn_tolerance); - ClassDB::bind_method(D_METHOD("get_autoturn_tolerance"),&CharacterCamera::get_autoturn_tolerance); - ClassDB::bind_method(D_METHOD("set_autoturn_speed","speed"),&CharacterCamera::set_autoturn_speed); - ClassDB::bind_method(D_METHOD("get_autoturn_speed"),&CharacterCamera::get_autoturn_speed); - ClassDB::bind_method(D_METHOD("set_use_lookat_target","use","lookat"),&CharacterCamera::set_use_lookat_target, DEFVAL(Vector3())); - - ClassDB::bind_method(D_METHOD("_ray_collision"),&CharacterCamera::_ray_collision); - - BIND_ENUM_CONSTANT( CAMERA_FIXED ); - BIND_ENUM_CONSTANT( CAMERA_FOLLOW ); -} - -void CharacterCamera::_ray_collision(Vector3 p_point, Vector3 p_normal, int p_subindex, ObjectID p_against,int p_idx) { - - - clip_ray[p_idx].clip_pos=p_point; - clip_ray[p_idx].clipped=true; -}; - -Transform CharacterCamera::get_camera_transform() const { - - return accepted; -} - - -CharacterCamera::CharacterCamera() { - - - type=CAMERA_FOLLOW; - height=1; - - orbit=Vector2(0,0); - - distance=3; - min_distance=2; - max_distance=5; - - autoturn=false; - autoturn_tolerance=15; - autoturn_speed=20; - - min_orbit_x=-50; - max_orbit_x=70; - inclination=0; - - clip=false; - use_lookat_target = false; - - for(int i=0;i<3;i++) { - clip_ray[i].query=PhysicsServer::get_singleton()->query_create(this, "_ray_collision", i, true); - clip_ray[i].clipped=false; - } - - -} - -CharacterCamera::~CharacterCamera() { - - for(int i=0;i<3;i++) { - PhysicsServer::get_singleton()->free(clip_ray[i].query); - } - - -} -#endif diff --git a/scene/3d/character_camera.h b/scene/3d/character_camera.h deleted file mode 100644 index 739e4c783d..0000000000 --- a/scene/3d/character_camera.h +++ /dev/null @@ -1,167 +0,0 @@ -/*************************************************************************/ -/* character_camera.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 CHARACTER_CAMERA_H -#define CHARACTER_CAMERA_H - -#include "scene/3d/camera.h" -#if 0 -class CharacterCamera : public Camera { - - GDCLASS( CharacterCamera, Camera ); -public: - - enum CameraType { - CAMERA_FIXED, - CAMERA_FOLLOW - }; - -private: - - - CameraType type; - - //used for follow - Vector3 follow_pos; - //used for fixed - Vector2 orbit; - float distance; - - float height; - - float min_distance; - float max_distance; - - float max_orbit_x; - float min_orbit_x; - - float inclination; - - bool clip; - bool autoturn; - float autoturn_tolerance; - float autoturn_speed; - - - - struct ClipRay { - RID query; - bool clipped; - Vector3 clip_pos; - }; - - ClipRay clip_ray[3]; - Vector3 target_pos; - float clip_len; - - - Transform accepted; - Vector3 proposed_pos; - - bool use_lookat_target; - Vector3 lookat_target; - - void _compute_camera(); - - RID ray_query; - RID left_turn_query; - RID right_turn_query; - RID target_body; - -protected: - - virtual void _request_camera_update() {} //ignore - - bool _set(const StringName& p_name, const Variant& p_value); - bool _get(const StringName& p_name,Variant &r_ret) const; - void _get_property_list( List<PropertyInfo> *p_list) const; - void _notification(int p_what); - - static void _bind_methods(); - - void _ray_collision(Vector3 p_point, Vector3 p_normal, int p_subindex, ObjectID p_against,int p_idx); - -public: - - - void set_camera_type(CameraType p_camera_type); - CameraType get_camera_type() const; - - void set_orbit(const Vector2& p_orbit); - void set_orbit_x(float p_x); - void set_orbit_y(float p_y); - Vector2 get_orbit() const; - - void set_height(float p_height); - float get_height() const; - - void set_inclination(float p_degrees); - float get_inclination() const; - - void set_max_orbit_x(float p_max); - float get_max_orbit_x() const; - - void set_min_orbit_x(float p_min); - float get_min_orbit_x() const; - - void rotate_orbit(const Vector2& p_relative); - - void set_distance(float p_distance); - float get_distance() const; - - float get_min_distance() const; - float get_max_distance() const; - void set_min_distance(float p_min); - void set_max_distance(float p_max); - - - void set_clip(bool p_enabled); - bool has_clip() const; - - void set_autoturn(bool p_enabled); - bool has_autoturn() const; - - void set_autoturn_tolerance(float p_degrees); - float get_autoturn_tolerance() const; - - void set_autoturn_speed(float p_speed); - float get_autoturn_speed() const; - - void set_use_lookat_target(bool p_use, const Vector3 &p_lookat = Vector3()); - - virtual Transform get_camera_transform() const; - - CharacterCamera(); - ~CharacterCamera(); -}; - -VARIANT_ENUM_CAST( CharacterCamera::CameraType ); - -#endif -#endif // CHARACTER_CAMERA_H diff --git a/scene/3d/collision_object.cpp b/scene/3d/collision_object.cpp index 78439c245d..c121ef4566 100644 --- a/scene/3d/collision_object.cpp +++ b/scene/3d/collision_object.cpp @@ -28,6 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "collision_object.h" + #include "scene/scene_string_names.h" #include "servers/physics_server.h" diff --git a/scene/3d/light.h b/scene/3d/light.h index 48e50f09e8..93dd4828da 100644 --- a/scene/3d/light.h +++ b/scene/3d/light.h @@ -38,8 +38,6 @@ @author Juan Linietsky <reduzio@gmail.com> */ -class BakedLight; - class Light : public VisualInstance { GDCLASS(Light, VisualInstance); diff --git a/scene/3d/path.cpp b/scene/3d/path.cpp index 30fc2c9d12..ed4d88417c 100644 --- a/scene/3d/path.cpp +++ b/scene/3d/path.cpp @@ -33,24 +33,6 @@ #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() && Engine::get_singleton()->is_editor_hint()) { - //draw the curve!! - - for(int i=0;i<curve->get_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() { diff --git a/scene/3d/physics_joint.cpp b/scene/3d/physics_joint.cpp index fe1612fcbd..aa127ab79f 100644 --- a/scene/3d/physics_joint.cpp +++ b/scene/3d/physics_joint.cpp @@ -973,301 +973,3 @@ Generic6DOFJoint::Generic6DOFJoint() { set_flag_z(FLAG_ENABLE_LINEAR_LIMIT, true); set_flag_z(FLAG_ENABLE_MOTOR, false); } - -#if 0 - -void PhysicsJoint::_set(const String& p_name, const Variant& p_value) { - - if (p_name=="body_A") - set_body_a(p_value); - else if (p_name=="body_B") - set_body_b(p_value); - else if (p_name=="active") - set_active(p_value); - else if (p_name=="no_collision") - set_disable_collision(p_value); -} -Variant PhysicsJoint::_get(const String& p_name) const { - - if (p_name=="body_A") - return get_body_a(); - else if (p_name=="body_B") - return get_body_b(); - else if (p_name=="active") - return is_active(); - else if (p_name=="no_collision") - return has_disable_collision(); - - return Variant(); -} -void PhysicsJoint::_get_property_list( List<PropertyInfo> *p_list) const { - - - p_list->push_back( PropertyInfo( Variant::NODE_PATH, "body_A" ) ); - p_list->push_back( PropertyInfo( Variant::NODE_PATH, "body_B" ) ); - p_list->push_back( PropertyInfo( Variant::BOOL, "active" ) ); - p_list->push_back( PropertyInfo( Variant::BOOL, "no_collision" ) ); -} -void PhysicsJoint::_notification(int p_what) { - - - switch(p_what) { - - case NOTIFICATION_PARENT_CONFIGURED: { - - _connect(); - if (get_root_node()->get_editor() && !indicator.is_valid()) { - - indicator=VisualServer::get_singleton()->poly_create(); - RID mat=VisualServer::get_singleton()->fixed_material_create(); - VisualServer::get_singleton()->material_set_flag( mat, VisualServer::MATERIAL_FLAG_UNSHADED, true ); - VisualServer::get_singleton()->material_set_flag( mat, VisualServer::MATERIAL_FLAG_ONTOP, true ); - VisualServer::get_singleton()->material_set_flag( mat, VisualServer::MATERIAL_FLAG_WIREFRAME, true ); - VisualServer::get_singleton()->material_set_flag( mat, VisualServer::MATERIAL_FLAG_DOUBLE_SIDED, true ); - VisualServer::get_singleton()->material_set_line_width( mat, 3 ); - - VisualServer::get_singleton()->poly_set_material(indicator,mat,true); - _update_indicator(); - - } - - if (indicator.is_valid()) { - - indicator_instance=VisualServer::get_singleton()->instance_create(indicator,get_world()->get_scenario()); - VisualServer::get_singleton()->instance_attach_object_instance_id( indicator_instance,get_instance_id() ); - } - } break; - case NOTIFICATION_TRANSFORM_CHANGED: { - - if (indicator_instance.is_valid()) { - - VisualServer::get_singleton()->instance_set_transform(indicator_instance,get_global_transform()); - } - } break; - case NOTIFICATION_EXIT_SCENE: { - - if (indicator_instance.is_valid()) { - - VisualServer::get_singleton()->free(indicator_instance); - } - _disconnect(); - - } break; - - } -} - - -RID PhysicsJoint::_get_visual_instance_rid() const { - - return indicator_instance; - -} - -void PhysicsJoint::_bind_methods() { - - ClassDB::bind_method(D_METHOD("_get_visual_instance_rid"),&PhysicsJoint::_get_visual_instance_rid); - ClassDB::bind_method(D_METHOD("set_body_a","path"),&PhysicsJoint::set_body_a); - ClassDB::bind_method(D_METHOD("set_body_b"),&PhysicsJoint::set_body_b); - ClassDB::bind_method(D_METHOD("get_body_a","path"),&PhysicsJoint::get_body_a); - ClassDB::bind_method(D_METHOD("get_body_b"),&PhysicsJoint::get_body_b); - - ClassDB::bind_method(D_METHOD("set_active","active"),&PhysicsJoint::set_active); - ClassDB::bind_method(D_METHOD("is_active"),&PhysicsJoint::is_active); - - ClassDB::bind_method(D_METHOD("set_disable_collision","disable"),&PhysicsJoint::set_disable_collision); - ClassDB::bind_method(D_METHOD("has_disable_collision"),&PhysicsJoint::has_disable_collision); - - - ClassDB::bind_method("reconnect",&PhysicsJoint::reconnect); - - ClassDB::bind_method(D_METHOD("get_rid"),&PhysicsJoint::get_rid); - -} - -void PhysicsJoint::set_body_a(const NodePath& p_path) { - - _disconnect(); - body_A=p_path; - _connect(); - _change_notify("body_A"); -} -void PhysicsJoint::set_body_b(const NodePath& p_path) { - - _disconnect(); - body_B=p_path; - _connect(); - _change_notify("body_B"); - -} -NodePath PhysicsJoint::get_body_a() const { - - return body_A; -} -NodePath PhysicsJoint::get_body_b() const { - - return body_B; -} - -void PhysicsJoint::set_active(bool p_active) { - - active=p_active; - if (is_inside_scene()) { - PhysicsServer::get_singleton()->joint_set_active(joint,active); - } - _change_notify("active"); -} - -void PhysicsJoint::set_disable_collision(bool p_active) { - - if (no_collision==p_active) - return; - _disconnect(); - no_collision=p_active; - _connect(); - - _change_notify("no_collision"); -} -bool PhysicsJoint::has_disable_collision() const { - - return no_collision; -} - - - -bool PhysicsJoint::is_active() const { - - return active; -} - -void PhysicsJoint::_disconnect() { - - if (!is_inside_scene()) - return; - - if (joint.is_valid()) - PhysicsServer::get_singleton()->free(joint); - - joint=RID(); - - Node *nA = get_node(body_A); - Node *nB = get_node(body_B); - - PhysicsBody *A = Object::cast_to<PhysicsBody>(nA); - PhysicsBody *B = Object::cast_to<PhysicsBody>(nB); - - if (!A ||!B) - return; - - if (no_collision) - PhysicsServer::get_singleton()->body_remove_collision_exception(A->get_body(),B->get_body()); - -} -void PhysicsJoint::_connect() { - - if (!is_inside_scene()) - return; - - ERR_FAIL_COND(joint.is_valid()); - - Node *nA = get_node(body_A); - Node *nB = get_node(body_B); - - PhysicsBody *A = Object::cast_to<PhysicsBody>(nA); - PhysicsBody *B = Object::cast_to<PhysicsBody>(nB); - - if (!A && !B) - return; - - if (B && !A) - SWAP(B,A); - - joint = create(A,B); - - if (A<B) - SWAP(A,B); - - if (no_collision) - PhysicsServer::get_singleton()->body_add_collision_exception(A->get_body(),B->get_body()); - - - -} - -void PhysicsJoint::reconnect() { - - _disconnect(); - _connect(); - -} - - -RID PhysicsJoint::get_rid() { - - return joint; -} - - -PhysicsJoint::PhysicsJoint() { - - active=true; - no_collision=true; -} - - -PhysicsJoint::~PhysicsJoint() { - - if (indicator.is_valid()) { - - VisualServer::get_singleton()->free(indicator); - } - -} - -/* PIN */ - -void PhysicsJointPin::_update_indicator() { - - - VisualServer::get_singleton()->poly_clear(indicator); - - Vector<Color> colors; - colors.push_back( Color(0.3,0.9,0.2,0.7) ); - colors.push_back( Color(0.3,0.9,0.2,0.7) ); - - Vector<Vector3> points; - points.resize(2); - points[0]=Vector3(Vector3(-0.2,0,0)); - points[1]=Vector3(Vector3(0.2,0,0)); - VisualServer::get_singleton()->poly_add_primitive(indicator,points,Vector<Vector3>(),colors,Vector<Vector3>()); - - points[0]=Vector3(Vector3(0,-0.2,0)); - points[1]=Vector3(Vector3(0,0.2,0)); - VisualServer::get_singleton()->poly_add_primitive(indicator,points,Vector<Vector3>(),colors,Vector<Vector3>()); - - points[0]=Vector3(Vector3(0,0,-0.2)); - points[1]=Vector3(Vector3(0,0,0.2)); - VisualServer::get_singleton()->poly_add_primitive(indicator,points,Vector<Vector3>(),colors,Vector<Vector3>()); - -} - -RID PhysicsJointPin::create(PhysicsBody*A,PhysicsBody*B) { - - RID body_A = A->get_body(); - RID body_B = B?B->get_body():RID(); - - ERR_FAIL_COND_V( !body_A.is_valid(), RID() ); - - Vector3 pin_pos = get_global_transform().origin; - - if (body_B.is_valid()) - return PhysicsServer::get_singleton()->joint_create_double_pin_global(body_A,pin_pos,body_B,pin_pos); - else - return PhysicsServer::get_singleton()->joint_create_pin(body_A,A->get_global_transform().xform_inv(pin_pos),pin_pos); -} - -PhysicsJointPin::PhysicsJointPin() { - - -} -#endif diff --git a/scene/3d/physics_joint.h b/scene/3d/physics_joint.h index 5f66a7c35e..b94297da30 100644 --- a/scene/3d/physics_joint.h +++ b/scene/3d/physics_joint.h @@ -321,73 +321,4 @@ public: VARIANT_ENUM_CAST(Generic6DOFJoint::Param); VARIANT_ENUM_CAST(Generic6DOFJoint::Flag); -#if 0 -class PhysicsJoint : public Spatial { - - GDCLASS(PhysicsJoint,Spatial); - OBJ_CATEGORY("3D Physics Nodes"); - - NodePath body_A; - NodePath body_B; - bool active; - bool no_collision; - - - RID indicator_instance; - - RID _get_visual_instance_rid() const; -protected: - - RID joint; - RID indicator; - - bool _set(const StringName& p_name, const Variant& p_value); - bool _get(const StringName& p_name,Variant &r_ret) const; - void _get_property_list( List<PropertyInfo> *p_list) const; - void _notification(int p_what); - static void _bind_methods(); - - virtual RID create(PhysicsBody*A,PhysicsBody*B)=0; - virtual void _update_indicator()=0; - - void _disconnect(); - void _connect(); -public: - - void set_body_a(const NodePath& p_path); - void set_body_b(const NodePath& p_path); - NodePath get_body_a() const; - NodePath get_body_b() const; - - void set_active(bool p_active); - bool is_active() const; - - void set_disable_collision(bool p_active); - bool has_disable_collision() const; - - void reconnect(); - - RID get_rid(); - - PhysicsJoint(); - ~PhysicsJoint(); -}; - - - -class PhysicsJointPin : public PhysicsJoint { - - GDCLASS( PhysicsJointPin, PhysicsJoint ); - -protected: - - virtual void _update_indicator(); - virtual RID create(PhysicsBody*A,PhysicsBody*B); -public: - - - PhysicsJointPin(); -}; - #endif // PHYSICS_JOINT_H -#endif diff --git a/scene/3d/portal.cpp b/scene/3d/portal.cpp index b60f88b09d..6c14f7dbc9 100644 --- a/scene/3d/portal.cpp +++ b/scene/3d/portal.cpp @@ -32,6 +32,7 @@ #include "scene/resources/surface_tool.h" #include "servers/visual_server.h" +// FIXME: This will be removed, kept as reference for new implementation #if 0 bool Portal::_set(const StringName &p_name, const Variant &p_value) { diff --git a/scene/3d/room_instance.cpp b/scene/3d/room_instance.cpp index 9306902d7d..439b6bfdf8 100644 --- a/scene/3d/room_instance.cpp +++ b/scene/3d/room_instance.cpp @@ -31,6 +31,7 @@ #include "servers/visual_server.h" +// FIXME: Will be removed, kept as reference for new implementation #if 0 #include "geometry.h" #include "project_settings.h" diff --git a/scene/3d/spatial.cpp b/scene/3d/spatial.cpp index 484d12422a..7db3bb18bd 100644 --- a/scene/3d/spatial.cpp +++ b/scene/3d/spatial.cpp @@ -286,37 +286,6 @@ Transform Spatial::get_global_transform() const { return data.global_transform; } -#if 0 -void Spatial::add_child_notify(Node *p_child) { -/* - Spatial *s=Object::cast_to<Spatial>(p_child); - if (!s) - return; - - ERR_FAIL_COND(data.children_lock>0); - - s->data.dirty=DIRTY_GLOBAL; // don't allow global transform to be valid - s->data.parent=this; - data.children.push_back(s); - s->data.C=data.children.back(); -*/ -} - -void Spatial::remove_child_notify(Node *p_child) { -/* - Spatial *s=Object::cast_to<Spatial>(p_child); - if (!s) - return; - - ERR_FAIL_COND(data.children_lock>0); - - if (s->data.C) - data.children.erase(s->data.C); - s->data.parent=NULL; - s->data.C=NULL; -*/ -} -#endif Spatial *Spatial::get_parent_spatial() const { diff --git a/scene/3d/spatial_indexer.cpp b/scene/3d/spatial_indexer.cpp deleted file mode 100644 index 0a10e9c4b0..0000000000 --- a/scene/3d/spatial_indexer.cpp +++ /dev/null @@ -1,166 +0,0 @@ -/*************************************************************************/ -/* spatial_indexer.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 "spatial_indexer.h" - -#if 0 - -#include "camera.h" -#include "proximity_area.h" -#include "scene/scene_string_names.h" - -void SpatialIndexer::add_camera(Camera* p_camera) { - - cameras.insert(p_camera); -} - -void SpatialIndexer::remove_camera(Camera* p_camera){ - - for (Set<ProximityArea*>::Element *F=proximity_areas.front();F;F=F->next()) { - - ProximityArea *prox = F->get(); - TK<Camera> k; - k.against=p_camera; - k.area=prox; - if (camera_pairs.has(k)) { - camera_pairs.erase(k); - prox->area_exit(ProximityArea::TRACK_CAMERAS,p_camera); - } - } - cameras.erase(p_camera); - -} - -void SpatialIndexer::update_camera(Camera* p_camera) { - - - _request_update(); -} - -void SpatialIndexer::_update_pairs() { - - // brute force interseciton code, no broadphase - // will implement broadphase in the future - - for (Set<Camera*>::Element *E=cameras.front();E;E=E->next()) { - - Camera *cam = E->get(); - Vector<Plane> cplanes = cam->get_frustum(); - - for (Set<ProximityArea*>::Element *F=proximity_areas.front();F;F=F->next()) { - - ProximityArea *prox = F->get(); - - bool inters=false; - - if (prox->get_track_flag(ProximityArea::TRACK_CAMERAS)) { - - AABB aabb = prox->get_global_transform().xform(prox->get_aabb()); - if (aabb.intersects_convex_shape(cplanes.ptr(),cplanes.size())) - inters=true; - } - - TK<Camera> k; - k.against=cam; - k.area=prox; - - bool has = camera_pairs.has(k); - - if (inters==has) - continue; - - if (inters) { - camera_pairs.insert(k); - prox->area_enter(ProximityArea::TRACK_CAMERAS,cam); - } else { - - camera_pairs.erase(k); - prox->area_exit(ProximityArea::TRACK_CAMERAS,cam); - } - } - - } - - pending_update=false; -} - -void SpatialIndexer::_bind_methods() { - - - ClassDB::bind_method(D_METHOD("_update_pairs"),&SpatialIndexer::_update_pairs); -} - - -void SpatialIndexer::add_proximity_area(ProximityArea* p_area) { - - proximity_areas.insert(p_area); - -} - -void SpatialIndexer::remove_proximity_area(ProximityArea* p_area) { - - for (Set<Camera*>::Element *E=cameras.front();E;E=E->next()) { - - Camera *cam = E->get(); - TK<Camera> k; - k.against=cam; - k.area=p_area; - if (camera_pairs.has(k)) { - camera_pairs.erase(k); - p_area->area_exit(ProximityArea::TRACK_CAMERAS,cam); - } - } - proximity_areas.erase(p_area); - -} - -void SpatialIndexer::_request_update() { - - if (pending_update) - return; - pending_update=true; - call_deferred(SceneStringNames::get_singleton()->_update_pairs); - -} - -void SpatialIndexer::update_proximity_area_transform(ProximityArea* p_area) { - - _request_update(); -} - -void SpatialIndexer::update_proximity_area_flags(ProximityArea* p_area) { - - _request_update(); -} - -SpatialIndexer::SpatialIndexer() { - - pending_update=false; -} -#endif diff --git a/scene/3d/spatial_indexer.h b/scene/3d/spatial_indexer.h deleted file mode 100644 index 2b591f3ff3..0000000000 --- a/scene/3d/spatial_indexer.h +++ /dev/null @@ -1,84 +0,0 @@ -/*************************************************************************/ -/* spatial_indexer.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 SPATIAL_INDEXER_H -#define SPATIAL_INDEXER_H - -#include "scene/3d/spatial.h" -#if 0 - -class Camera; -class ProximityArea; - -class SpatialIndexer : public Object { - - GDCLASS( SpatialIndexer, Object ); - - template<class T> - struct TK { - - T *against; - ProximityArea *area; - bool operator<(const TK<T>& p_k) const { return against==p_k.against ? area < p_k.area : against < p_k.against; } - }; - - - Set<Camera*> cameras; //cameras - Set<ProximityArea*> proximity_areas; - - Set<TK<Camera> > camera_pairs; - - bool pending_update; - void _update_pairs(); - void _request_update(); - -protected: - - static void _bind_methods(); - -friend class ProximityArea; -friend class Camera; - - void add_proximity_area(ProximityArea* p_area); - void remove_proximity_area(ProximityArea* p_area); - void update_proximity_area_transform(ProximityArea* p_area); - void update_proximity_area_flags(ProximityArea* p_area); - - void add_camera(Camera* p_camera); - void remove_camera(Camera* p_camera); - void update_camera(Camera* p_camera); - -public: - - - SpatialIndexer(); - -}; -#endif -#endif // SPATIAL_INDEXER_H diff --git a/scene/3d/sprite_3d.cpp b/scene/3d/sprite_3d.cpp index 39c6971d66..49a3205f21 100644 --- a/scene/3d/sprite_3d.cpp +++ b/scene/3d/sprite_3d.cpp @@ -598,219 +598,6 @@ Sprite3D::Sprite3D() { //////////////////////////////////////// -#if 0 - -void AnimatedSprite3D::_draw() { - - RID immediate = get_immediate(); - VS::get_singleton()->immediate_clear(immediate); - - if (!frames.is_valid() || !frames->get_frame_count(animation) || frame<0 || frame>=frames->get_frame_count(animation)) { - return; - } - - Ref<Texture> texture = frames->get_frame(animation,frame); - if (!texture.is_valid()) - return; //no texuture no life - Vector2 tsize = texture->get_size(); - if (tsize.x==0 || tsize.y==0) - return; - - Size2i s=tsize; - Rect2i src_rect; - - src_rect.size=s; - - Point2i ofs=get_offset(); - if (is_centered()) - ofs-=s/2; - - Rect2i dst_rect(ofs,s); - - - Rect2 final_rect; - Rect2 final_src_rect; - if (!texture->get_rect_region(dst_rect,src_rect,final_rect,final_src_rect)) - return; - - - if (final_rect.size.x==0 || final_rect.size.y==0) - return; - - Color color=_get_color_accum(); - color.a*=get_opacity(); - - float pixel_size=get_pixel_size(); - - Vector2 vertices[4]={ - - (final_rect.pos+Vector2(0,final_rect.size.y)) * pixel_size, - (final_rect.pos+final_rect.size) * pixel_size, - (final_rect.pos+Vector2(final_rect.size.x,0)) * pixel_size, - final_rect.pos * pixel_size, - - - }; - Vector2 uvs[4]={ - final_src_rect.pos / tsize, - (final_src_rect.pos+Vector2(final_src_rect.size.x,0)) / tsize, - (final_src_rect.pos+final_src_rect.size) / tsize, - (final_src_rect.pos+Vector2(0,final_src_rect.size.y)) / tsize, - }; - - if (is_flipped_h()) { - SWAP(uvs[0],uvs[1]); - SWAP(uvs[2],uvs[3]); - } - if (is_flipped_v()) { - - SWAP(uvs[0],uvs[3]); - SWAP(uvs[1],uvs[2]); - } - - - Vector3 normal; - int axis = get_axis(); - normal[axis]=1.0; - - RID mat = VS::get_singleton()->material_2d_get(get_draw_flag(FLAG_SHADED),get_draw_flag(FLAG_TRANSPARENT),get_alpha_cut_mode()==ALPHA_CUT_DISCARD,get_alpha_cut_mode()==ALPHA_CUT_OPAQUE_PREPASS); - VS::get_singleton()->immediate_set_material(immediate,mat); - - VS::get_singleton()->immediate_begin(immediate,VS::PRIMITIVE_TRIANGLE_FAN,texture->get_rid()); - - int x_axis = ((axis + 1) % 3); - int y_axis = ((axis + 2) % 3); - - if (axis!=Vector3::AXIS_Z) { - SWAP(x_axis,y_axis); - - for(int i=0;i<4;i++) { - //uvs[i] = Vector2(1.0,1.0)-uvs[i]; - //SWAP(vertices[i].x,vertices[i].y); - if (axis==Vector3::AXIS_Y) { - vertices[i].y = - vertices[i].y; - } else if (axis==Vector3::AXIS_X) { - vertices[i].x = - vertices[i].x; - } - } - } - - AABB aabb; - - for(int i=0;i<4;i++) { - VS::get_singleton()->immediate_normal(immediate,normal); - VS::get_singleton()->immediate_color(immediate,color); - VS::get_singleton()->immediate_uv(immediate,uvs[i]); - - Vector3 vtx; - vtx[x_axis]=vertices[i][0]; - vtx[y_axis]=vertices[i][1]; - VS::get_singleton()->immediate_vertex(immediate,vtx); - if (i==0) { - aabb.pos=vtx; - aabb.size=Vector3(); - } else { - aabb.expand_to(vtx); - } - } - set_aabb(aabb); - VS::get_singleton()->immediate_end(immediate); - -} - -void AnimatedSprite3D::_bind_methods(){ - - ClassDB::bind_method(D_METHOD("set_sprite_frames","sprite_frames"),&AnimatedSprite3D::set_sprite_frames); - ClassDB::bind_method(D_METHOD("get_sprite_frames"),&AnimatedSprite3D::get_sprite_frames); - ClassDB::bind_method(D_METHOD("set_frame","frame"),&AnimatedSprite3D::set_frame); - ClassDB::bind_method(D_METHOD("get_frame"),&AnimatedSprite3D::get_frame); - - ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "frames", PROPERTY_HINT_RESOURCE_TYPE,"SpriteFrames"), "set_sprite_frames","get_sprite_frames"); - ADD_PROPERTY( PropertyInfo( Variant::INT, "frame",PROPERTY_HINT_SPRITE_FRAME), "set_frame","get_frame"); - - ADD_SIGNAL(MethodInfo("frame_changed")); - -} - - - - -void AnimatedSprite3D::set_sprite_frames(const Ref<SpriteFrames>& p_sprite_frames) { - - - if (frames==p_sprite_frames) - return; - - if (frames.is_valid()) - frames->disconnect("changed",this,"_queue_update"); - frames=p_sprite_frames; - if (frames.is_valid()) - frames->connect("changed",this,"_queue_update"); - - if (!frames.is_valid() || frame >=frames->get_frame_count(animation)) { - frame=0; - - } - _queue_update(); - -} - -Ref<SpriteFrames> AnimatedSprite3D::get_sprite_frames() const{ - - return frames; -} - -void AnimatedSprite3D::set_frame(int p_frame){ - - if (frames.is_null()) - return; - - ERR_FAIL_INDEX(p_frame,frames->get_frame_count(animation)); - - if (frame==p_frame) - return; - - frame=p_frame; - _queue_update(); - emit_signal(SceneStringNames::get_singleton()->frame_changed); - -} -int AnimatedSprite3D::get_frame() const{ - - return frame; -} - -Rect2 AnimatedSprite3D::get_item_rect() const { - - if (!frames.is_valid() || !frames->get_frame_count(animation) || frame<0 || frame>=frames->get_frame_count(animation)) { - return Rect2(0,0,1,1); - } - - Ref<Texture> t = frames->get_frame(animation,frame); - if (t.is_null()) - return Rect2(0,0,1,1); - Size2i s = t->get_size(); - - Point2i ofs=get_offset(); - if (is_centered()) - ofs-=s/2; - - if (s==Size2(0,0)) - s=Size2(1,1); - - return Rect2(ofs,s); -} - - - -AnimatedSprite3D::AnimatedSprite3D() { - - animation="current"; - frame=0; -} - -#endif - void AnimatedSprite3D::_draw() { RID immediate = get_immediate(); @@ -1022,63 +809,6 @@ void AnimatedSprite3D::_notification(int p_what) { timeout -= to_process; } } break; -#if 0 - case NOTIFICATION_DRAW: { - - if (frames.is_null()) { - print_line("no draw no faemos"); - return; - } - - if (frame<0) { - print_line("no draw frame <0"); - return; - } - - if (!frames->has_animation(animation)) { - print_line("no draw no anim: "+String(animation)); - return; - } - - - - Ref<Texture> texture = frames->get_frame(animation,frame); - if (texture.is_null()) { - print_line("no draw texture is null"); - return; - } - - //print_line("DECIDED TO DRAW"); - - RID ci = get_canvas_item(); - - /* - texture->draw(ci,Point2()); - break; - */ - - Size2i s; - s = texture->get_size(); - Point2 ofs=offset; - if (centered) - ofs-=s/2; - - if (OS::get_singleton()->get_use_pixel_snap()) { - ofs=ofs.floor(); - } - Rect2 dst_rect(ofs,s); - - if (hflip) - dst_rect.size.x=-dst_rect.size.x; - if (vflip) - dst_rect.size.y=-dst_rect.size.y; - - //texture->draw_rect(ci,dst_rect,false,modulate); - texture->draw_rect_region(ci,dst_rect,Rect2(Vector2(),texture->get_size()),modulate); - //VisualServer::get_singleton()->canvas_item_add_texture_rect_region(ci,dst_rect,texture->get_rid(),src_rect,modulate); - - } break; -#endif } } diff --git a/scene/3d/sprite_3d.h b/scene/3d/sprite_3d.h index e3a65e1e8c..1165392cb2 100644 --- a/scene/3d/sprite_3d.h +++ b/scene/3d/sprite_3d.h @@ -181,37 +181,6 @@ public: //~Sprite3D(); }; -#if 0 -class AnimatedSprite3D : public SpriteBase3D { - - GDCLASS(AnimatedSprite3D,SpriteBase3D); - Ref<SpriteFrames> frames; - - - StringName animation; - int frame; - -protected: - virtual void _draw(); - static void _bind_methods(); -public: - - - - void set_sprite_frames(const Ref<SpriteFrames>& p_sprite_frames); - Ref<SpriteFrames> get_sprite_frames() const; - - void set_frame(int p_frame); - int get_frame() const; - - - virtual Rect2 get_item_rect() const; - - AnimatedSprite3D(); - //~AnimatedSprite3D(); -}; -#endif - class AnimatedSprite3D : public SpriteBase3D { GDCLASS(AnimatedSprite3D, SpriteBase3D); diff --git a/scene/3d/visual_instance.h b/scene/3d/visual_instance.h index d15045d023..c405236d2c 100644 --- a/scene/3d/visual_instance.h +++ b/scene/3d/visual_instance.h @@ -76,8 +76,6 @@ public: ~VisualInstance(); }; -class BakedLight; - class GeometryInstance : public VisualInstance { GDCLASS(GeometryInstance, VisualInstance); diff --git a/scene/SCsub b/scene/SCsub index df52e9c6cb..513adeffda 100644 --- a/scene/SCsub +++ b/scene/SCsub @@ -27,7 +27,6 @@ SConscript('2d/SCsub') SConscript('animation/SCsub') SConscript('audio/SCsub') SConscript('resources/SCsub') -SConscript('io/SCsub') # Build it all as a library diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp index 2233aaf3c1..be0b652276 100644 --- a/scene/animation/animation_player.cpp +++ b/scene/animation/animation_player.cpp @@ -608,16 +608,6 @@ void AnimationPlayer::_animation_update_transforms() { ERR_CONTINUE(pa->accum_pass != accum_pass); -#if 1 - /* switch(pa->special) { - - - case SP_NONE: pa->object->set(pa->prop,pa->value_accum); break; //you are not speshul - case SP_NODE2D_POS: static_cast<Node2D*>(pa->object)->set_position(pa->value_accum); break; - case SP_NODE2D_ROT: static_cast<Node2D*>(pa->object)->set_rot(Math::deg2rad(pa->value_accum)); break; - case SP_NODE2D_SCALE: static_cast<Node2D*>(pa->object)->set_scale(pa->value_accum); break; - }*/ - switch (pa->special) { case SP_NONE: { @@ -657,10 +647,6 @@ void AnimationPlayer::_animation_update_transforms() { static_cast<Node2D *>(pa->object)->set_scale(pa->value_accum); } break; } -#else - - pa->object->set(pa->prop, pa->value_accum); -#endif } cache_update_prop_size = 0; @@ -668,8 +654,6 @@ void AnimationPlayer::_animation_update_transforms() { void AnimationPlayer::_animation_process(float p_delta) { - //bool any_active=false; - if (playback.current.from) { end_notify = false; diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp index eee23cba9f..8fd19e8655 100644 --- a/scene/gui/base_button.cpp +++ b/scene/gui/base_button.cpp @@ -28,6 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "base_button.h" + #include "os/keyboard.h" #include "print_string.h" #include "scene/main/viewport.h" diff --git a/scene/gui/control.h b/scene/gui/control.h index 9d6abecec4..da5c4d0908 100644 --- a/scene/gui/control.h +++ b/scene/gui/control.h @@ -33,7 +33,7 @@ #include "math_2d.h" #include "rid.h" #include "scene/2d/canvas_item.h" -#include "scene/gui/input_action.h" +#include "scene/gui/shortcut.h" #include "scene/main/node.h" #include "scene/main/timer.h" #include "scene/resources/theme.h" diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp index 532887feee..5b00aab2ef 100644 --- a/scene/gui/graph_edit.cpp +++ b/scene/gui/graph_edit.cpp @@ -28,6 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "graph_edit.h" + #include "os/input.h" #include "os/keyboard.h" #include "scene/gui/box_container.h" @@ -593,8 +594,6 @@ void GraphEdit::_bake_segment2d(Vector<Vector2> &points, Vector<Color> &colors, void GraphEdit::_draw_cos_line(CanvasItem *p_where, const Vector2 &p_from, const Vector2 &p_to, const Color &p_color, const Color &p_to_color) { -#if 1 - //cubic bezier code float diff = p_to.x - p_from.x; float cp_offset; @@ -621,84 +620,53 @@ void GraphEdit::_draw_cos_line(CanvasItem *p_where, const Vector2 &p_from, const colors.push_back(p_to_color); p_where->draw_polyline_colors(points, colors, 2, true); - -#else - - static const int steps = 20; - - //old cosine code - Rect2 r; - r.pos = p_from; - r.expand_to(p_to); - Vector2 sign = Vector2((p_from.x < p_to.x) ? 1 : -1, (p_from.y < p_to.y) ? 1 : -1); - bool flip = sign.x * sign.y < 0; - - Vector2 prev; - for (int i = 0; i <= steps; i++) { - - float d = i / float(steps); - float c = -Math::cos(d * Math_PI) * 0.5 + 0.5; - if (flip) - c = 1.0 - c; - Vector2 p = r.pos + Vector2(d * r.size.width, c * r.size.height); - - if (i > 0) { - - p_where->draw_line(prev, p, p_color.linear_interpolate(p_to_color, d), 2); - } - - prev = p; - } -#endif } void GraphEdit::_connections_layer_draw() { - { - //draw connections - List<List<Connection>::Element *> to_erase; - for (List<Connection>::Element *E = connections.front(); E; E = E->next()) { - - NodePath fromnp(E->get().from); + //draw connections + List<List<Connection>::Element *> to_erase; + for (List<Connection>::Element *E = connections.front(); E; E = E->next()) { - Node *from = get_node(fromnp); - if (!from) { - to_erase.push_back(E); - continue; - } + NodePath fromnp(E->get().from); - GraphNode *gfrom = Object::cast_to<GraphNode>(from); + Node *from = get_node(fromnp); + if (!from) { + to_erase.push_back(E); + continue; + } - if (!gfrom) { - to_erase.push_back(E); - continue; - } + GraphNode *gfrom = Object::cast_to<GraphNode>(from); - NodePath tonp(E->get().to); - Node *to = get_node(tonp); - if (!to) { - to_erase.push_back(E); - continue; - } + if (!gfrom) { + to_erase.push_back(E); + continue; + } - GraphNode *gto = Object::cast_to<GraphNode>(to); + NodePath tonp(E->get().to); + Node *to = get_node(tonp); + if (!to) { + to_erase.push_back(E); + continue; + } - if (!gto) { - to_erase.push_back(E); - continue; - } + GraphNode *gto = Object::cast_to<GraphNode>(to); - Vector2 frompos = gfrom->get_connection_output_pos(E->get().from_port) + gfrom->get_offset() * zoom; - Color color = gfrom->get_connection_output_color(E->get().from_port); - Vector2 topos = gto->get_connection_input_pos(E->get().to_port) + gto->get_offset() * zoom; - Color tocolor = gto->get_connection_input_color(E->get().to_port); - _draw_cos_line(connections_layer, frompos, topos, color, tocolor); + if (!gto) { + to_erase.push_back(E); + continue; } - while (to_erase.size()) { - connections.erase(to_erase.front()->get()); - to_erase.pop_front(); - } + Vector2 frompos = gfrom->get_connection_output_pos(E->get().from_port) + gfrom->get_offset() * zoom; + Color color = gfrom->get_connection_output_color(E->get().from_port); + Vector2 topos = gto->get_connection_input_pos(E->get().to_port) + gto->get_offset() * zoom; + Color tocolor = gto->get_connection_input_color(E->get().to_port); + _draw_cos_line(connections_layer, frompos, topos, color, tocolor); + } + + while (to_erase.size()) { + connections.erase(to_erase.front()->get()); + to_erase.pop_front(); } } diff --git a/scene/gui/popup.cpp b/scene/gui/popup.cpp index 10198f9410..5a2a552943 100644 --- a/scene/gui/popup.cpp +++ b/scene/gui/popup.cpp @@ -59,17 +59,10 @@ void Popup::_notification(int p_what) { void Popup::_fix_size() { -#if 0 - Point2 pos = get_position(); - Size2 size = get_size(); - Point2 window_size = window==this ? get_parent_area_size() :window->get_size(); -#else - Point2 pos = get_global_position(); Size2 size = get_size(); Point2 window_size = get_viewport_rect().size; -#endif if (pos.x + size.width > window_size.width) pos.x = window_size.width - size.width; if (pos.x < 0) @@ -79,14 +72,8 @@ void Popup::_fix_size() { pos.y = window_size.height - size.height; if (pos.y < 0) pos.y = 0; -#if 0 - if (pos!=get_pos()) - set_position(pos); -#else if (pos != get_position()) set_global_position(pos); - -#endif } void Popup::set_as_minsize() { diff --git a/scene/gui/scroll_bar.cpp b/scene/gui/scroll_bar.cpp index 2250dc44d1..16d1b320b7 100644 --- a/scene/gui/scroll_bar.cpp +++ b/scene/gui/scroll_bar.cpp @@ -28,9 +28,11 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "scroll_bar.h" + #include "os/keyboard.h" #include "os/os.h" #include "print_string.h" + bool ScrollBar::focus_by_default = false; void ScrollBar::set_can_focus_by_default(bool p_can_focus) { @@ -686,138 +688,6 @@ bool ScrollBar::is_smooth_scroll_enabled() const { return smooth_scroll_enabled; } -#if 0 - -void ScrollBar::mouse_button(const Point2& p_pos, int b->get_button_index(),bool b->is_pressed(),int p_modifier_mask) { - - // wheel! - - if (b->get_button_index()==BUTTON_WHEEL_UP && b->is_pressed()) { - - if (orientation==VERTICAL) - set_val( get_val() - get_page() / 4.0 ); - else - set_val( get_val() + get_page() / 4.0 ); - - } - if (b->get_button_index()==BUTTON_WHEEL_DOWN && b->is_pressed()) { - - if (orientation==HORIZONTAL) - set_val( get_val() - get_page() / 4.0 ); - else - set_val( get_val() + get_page() / 4.0 ); - } - - if (b->get_button_index()!=BUTTON_LEFT) - return; - - if (b->is_pressed()) { - - int ofs = orientation==VERTICAL ? p_pos.y : p_pos.x ; - int grabber_ofs = get_grabber_offset(); - int grabber_size = get_grabber_size(); - - if ( ofs < grabber_ofs ) { - - set_val( get_val() - get_page() ); - - } else if (ofs > grabber_ofs + grabber_size ) { - - set_val( get_val() + get_page() ); - - } else { - - - drag.active=true; - drag.pos_at_click=get_click_pos(p_pos); - drag.value_at_click=get_unit_value(); - } - - - } else { - - drag.active=false; - } - -} -void ScrollBar::mouse_motion(const Point2& p_pos, const Point2& p_rel, int b->get_button_index()_mask) { - - if (!drag.active) - return; - - double value_ofs=drag.value_at_click+(get_click_pos(p_pos)-drag.pos_at_click); - - - value_ofs=value_ofs*( get_max() - get_min() ); - if (value_ofs<get_min()) - value_ofs=get_min(); - if (value_ofs>(get_max()-get_page())) - value_ofs=get_max()-get_page(); - if (get_val()==value_ofs) - return; //don't bother if the value is the same - - set_val( value_ofs ); - -} - -bool ScrollBar::key(unsigned long p_unicode, unsigned long p_scan_code,bool b->is_pressed(),bool p_repeat,int p_modifier_mask) { - - if (!b->is_pressed()) - return false; - - switch (p_scan_code) { - - case KEY_LEFT: { - - if (orientation!=HORIZONTAL) - return false; - set_val( get_val() - get_step() ); - - } break; - case KEY_RIGHT: { - - if (orientation!=HORIZONTAL) - return false; - set_val( get_val() + get_step() ); - - } break; - case KEY_UP: { - - if (orientation!=VERTICAL) - return false; - - set_val( get_val() - get_step() ); - - - } break; - case KEY_DOWN: { - - if (orientation!=VERTICAL) - return false; - set_val( get_val() + get_step() ); - - } break; - case KEY_HOME: { - - set_val( get_min() ); - - } break; - case KEY_END: { - - set_val( get_max() ); - - } break; - - default: - return false; - - } - - return true; -} - -#endif - void ScrollBar::_bind_methods() { ClassDB::bind_method(D_METHOD("_gui_input"), &ScrollBar::_gui_input); diff --git a/scene/gui/input_action.cpp b/scene/gui/shortcut.cpp index fb2385dd50..f37410e77b 100644 --- a/scene/gui/input_action.cpp +++ b/scene/gui/shortcut.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* input_action.cpp */ +/* shortcut.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -27,7 +27,8 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "input_action.h" +#include "shortcut.h" + #include "os/keyboard.h" void ShortCut::set_shortcut(const Ref<InputEvent> &p_shortcut) { @@ -52,61 +53,6 @@ String ShortCut::get_as_text() const { return shortcut->as_text(); else return "None"; -#if 0 - switch (shortcut.type) { - - case Ref<InputEvent>::NONE: { - - return "None"; - } break; - case Ref<InputEvent>::KEY: { - - String str; - if (shortcut->get_shift()) - str += RTR("Shift+"); - if (shortcut->get_alt()) - str += RTR("Alt+"); - if (shortcut->get_control()) - str += RTR("Ctrl+"); - if (shortcut->get_metakey()) - str += RTR("Meta+"); - - str += keycode_get_string(shortcut->get_scancode()).capitalize(); - - return str; - } break; - case Ref<InputEvent>::JOYPAD_BUTTON: { - - String str = RTR("Device") + " " + itos(shortcut.device) + ", " + RTR("Button") + " " + itos(shortcut.joy_button->get_button_index()); - str += "."; - - return str; - } break; - case Ref<InputEvent>::MOUSE_BUTTON: { - - String str = RTR("Device") + " " + itos(shortcut.device) + ", "; - switch (shortcut->get_button_index()) { - case BUTTON_LEFT: str += RTR("Left Button."); break; - case BUTTON_RIGHT: str += RTR("Right Button."); break; - case BUTTON_MIDDLE: str += RTR("Middle Button."); break; - case BUTTON_WHEEL_UP: str += RTR("Wheel Up."); break; - case BUTTON_WHEEL_DOWN: str += RTR("Wheel Down."); break; - default: str += RTR("Button") + " " + itos(shortcut->get_button_index()) + "."; - } - - return str; - } break; - case Ref<InputEvent>::JOYPAD_MOTION: { - - int ax = shortcut.joy_motion.axis; - String str = RTR("Device") + " " + itos(shortcut.device) + ", " + RTR("Axis") + " " + itos(ax) + "."; - - return str; - } break; - } - - return ""; -#endif } bool ShortCut::is_valid() const { diff --git a/scene/gui/input_action.h b/scene/gui/shortcut.h index 0bff5a1762..8d85bb920f 100644 --- a/scene/gui/input_action.h +++ b/scene/gui/shortcut.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* input_action.h */ +/* shortcut.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -27,8 +27,8 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef INPUTACTION_H -#define INPUTACTION_H +#ifndef SHORTCUT_H +#define SHORTCUT_H #include "os/input_event.h" #include "resource.h" @@ -53,4 +53,4 @@ public: ShortCut(); }; -#endif // INPUTACTION_H +#endif // SHORTCUT_H diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 9add6eb607..e82044b133 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -27,13 +27,12 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ - #include "text_edit.h" + +#include "message_queue.h" #include "os/input.h" #include "os/keyboard.h" #include "os/os.h" - -#include "message_queue.h" #include "project_settings.h" #include "scene/main/viewport.h" @@ -4466,18 +4465,6 @@ void TextEdit::_update_completion_candidates() { // The top of the list is the best match completion_current = completion_options[0]; - -#if 0 // even there's only one option, user still get the chance to choose using it or not - if (completion_options.size()==1) { - //one option to complete, just complete it automagically - _confirm_completion(); - //insert_text_at_cursor(completion_options[0].substr(s.length(),completion_options[0].length()-s.length())); - _cancel_completion(); - return; - - } -#endif - completion_enabled = true; } @@ -4904,24 +4891,6 @@ TextEdit::TextEdit() { click_select_held->set_wait_time(0.05); click_select_held->connect("timeout", this, "_click_selection_held"); -#if 0 - syntax_coloring=true; - keywords["void"]=Color(0.3,0.0,0.1); - keywords["int"]=Color(0.3,0.0,0.1); - keywords["function"]=Color(0.3,0.0,0.1); - keywords["class"]=Color(0.3,0.0,0.1); - keywords["extends"]=Color(0.3,0.0,0.1); - keywords["constructor"]=Color(0.3,0.0,0.1); - symbol_color=Color(0.1,0.0,0.3,1.0); - - color_regions.push_back(ColorRegion("/*","*/",Color(0.4,0.6,0,4))); - color_regions.push_back(ColorRegion("//","",Color(0.6,0.6,0.4))); - color_regions.push_back(ColorRegion("\"","\"",Color(0.4,0.7,0.7))); - color_regions.push_back(ColorRegion("'","'",Color(0.4,0.8,0.8))); - color_regions.push_back(ColorRegion("#","",Color(0.2,1.0,0.2))); - -#endif - current_op.type = TextOperation::TYPE_NONE; undo_enabled = true; undo_stack_pos = NULL; diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index 1940cef34d..5e15bceb7d 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -28,6 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "tree.h" + #include "os/input.h" #include "os/keyboard.h" #include "os/os.h" @@ -990,41 +991,10 @@ void Tree::draw_item_rect(const TreeItem::Cell &p_cell, const Rect2i &p_rect, co rect.size.x -= bmsize.x + cache.hseparation; } - /* - if (p_tool) - rect.size.x-=Math::floor(rect.size.y/2); - */ - rect.position.y += Math::floor((rect.size.y - font->get_height()) / 2.0) + font->get_ascent(); font->draw(ci, rect.position, text, p_color, rect.size.x); } -#if 0 -void Tree::draw_item_text(String p_text,const Ref<Texture>& p_icon,int p_icon_max_w,bool p_tool,Rect2i p_rect,const Color& p_color) { - - RID ci = get_canvas_item(); - if (!p_icon.is_null()) { - Size2i bmsize = p_icon->get_size(); - if (p_icon_max_w>0 && bmsize.width > p_icon_max_w) { - bmsize.height = bmsize.height * p_icon_max_w / bmsize.width; - bmsize.width=p_icon_max_w; - } - - draw_texture_rect(p_icon,Rect2(p_rect.pos + Size2i(0,Math::floor((p_rect.size.y-bmsize.y)/2)),bmsize)); - p_rect.pos.x+=bmsize.x+cache.hseparation; - p_rect.size.x-=bmsize.x+cache.hseparation; - - } - - if (p_tool) - p_rect.size.x-=Math::floor(p_rect.size.y/2); - - Ref<Font> font = cache.font; - - p_rect.pos.y+=Math::floor((p_rect.size.y-font->get_height())/2.0) +font->get_ascent(); - font->draw(ci,p_rect.pos,p_text,p_color,p_rect.size.x); -} -#endif int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2 &p_draw_size, TreeItem *p_item) { if (p_pos.y - cache.offset.y > (p_draw_size.height)) diff --git a/scene/gui/video_player.cpp b/scene/gui/video_player.cpp index b39b392017..a92155cc4f 100644 --- a/scene/gui/video_player.cpp +++ b/scene/gui/video_player.cpp @@ -28,27 +28,9 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "video_player.h" + #include "os/os.h" #include "servers/audio_server.h" -/* - -int VideoPlayer::InternalStream::get_channel_count() const { - - return player->sp_get_channel_count(); -} -void VideoPlayer::InternalStream::set_mix_rate(int p_rate){ - - return player->sp_set_mix_rate(p_rate); -} -bool VideoPlayer::InternalStream::mix(int32_t *p_buffer,int p_frames){ - - return player->sp_mix(p_buffer,p_frames); -} -void VideoPlayer::InternalStream::update(){ - - player->sp_update(); -} -*/ int VideoPlayer::sp_get_channel_count() const { @@ -69,31 +51,6 @@ bool VideoPlayer::sp_mix(int32_t *p_buffer, int p_frames) { return false; } -void VideoPlayer::sp_update() { -#if 0 - _THREAD_SAFE_METHOD_ - //update is unused - if (!paused && playback.is_valid()) { - - if (!playback->is_playing()) { - //stream depleted data, but there's still audio in the ringbuffer - //check that all this audio has been flushed before stopping the stream - int to_mix = resampler.get_total() - resampler.get_todo(); - if (to_mix==0) { - stop(); - return; - } - - return; - } - - int todo =resampler.get_todo(); - int wrote = playback->mix(resampler.get_write_buffer(),todo); - resampler.write(wrote); - } -#endif -} - int VideoPlayer::_audio_mix_callback(void *p_udata, const int16_t *p_data, int p_frames) { VideoPlayer *vp = (VideoPlayer *)p_udata; diff --git a/scene/gui/video_player.h b/scene/gui/video_player.h index 731ba2abd7..b78f3aabe7 100644 --- a/scene/gui/video_player.h +++ b/scene/gui/video_player.h @@ -38,23 +38,12 @@ class VideoPlayer : public Control { GDCLASS(VideoPlayer, Control); - /* struct InternalStream : public AudioServer::AudioStream { - VideoPlayer *player; - virtual int get_channel_count() const; - virtual void set_mix_rate(int p_rate); //notify the stream of the mix rate - virtual bool mix(int32_t *p_buffer,int p_frames); - virtual void update(); - }; -*/ - - // InternalStream internal_stream; Ref<VideoStreamPlayback> playback; Ref<VideoStream> stream; int sp_get_channel_count() const; void sp_set_mix_rate(int p_rate); //notify the stream of the mix rate bool sp_mix(int32_t *p_buffer, int p_frames); - void sp_update(); RID stream_rid; @@ -118,4 +107,4 @@ public: ~VideoPlayer(); }; -#endif +#endif // VIDEO_PLAYER_H diff --git a/scene/io/SCsub b/scene/io/SCsub deleted file mode 100644 index bf9125be7f..0000000000 --- a/scene/io/SCsub +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env python - -Import('env') - -env.add_source_files(env.scene_sources, "*.cpp") - -Export('env') diff --git a/scene/io/resource_format_image.cpp b/scene/io/resource_format_image.cpp deleted file mode 100644 index 3fcc500e63..0000000000 --- a/scene/io/resource_format_image.cpp +++ /dev/null @@ -1,266 +0,0 @@ -/*************************************************************************/ -/* resource_format_image.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 "resource_format_image.h" - -#if 0 -#include "io/image_loader.h" -#include "os/os.h" -#include "project_settings.h" -#include "scene/resources/texture.h" -RES ResourceFormatLoaderImage::load(const String &p_path, const String& p_original_path, Error *r_error) { - - if (r_error) - *r_error=ERR_CANT_OPEN; - - if (p_path.get_extension()=="cube") { - // open as cubemap txture - - CubeMap* ptr = memnew(CubeMap); - Ref<CubeMap> cubemap( ptr ); - - Error err; - FileAccess *f = FileAccess::open(p_path,FileAccess::READ,&err); - if (err) { - - ERR_FAIL_COND_V( err, RES() ); - } - - String base_path=p_path.substr( 0, p_path.find_last("/")+1 ); - - for(int i=0;i<6;i++) { - - String file = f->get_line().strip_edges(); - Image image; - - Error err = ImageLoader::load_image(base_path+file,&image); - - - if (err) { - - memdelete(f); - ERR_FAIL_COND_V( err, RES() ); - } - - if (i==0) { - - //cubemap->create(image.get_width(),image.get_height(),image.get_format(),Texture::FLAGS_DEFAULT|Texture::FLAG_CUBEMAP); - } - - static const CubeMap::Side cube_side[6]= { - CubeMap::SIDE_LEFT, - CubeMap::SIDE_RIGHT, - CubeMap::SIDE_BOTTOM, - CubeMap::SIDE_TOP, - CubeMap::SIDE_FRONT, - CubeMap::SIDE_BACK - }; - - cubemap->set_side(cube_side[i],image); - } - - memdelete(f); - - cubemap->set_name(p_path.get_file()); - if (r_error) - *r_error=OK; - - return cubemap; - - } else { - // simple image - - ImageTexture* ptr = memnew(ImageTexture); - Ref<ImageTexture> texture( ptr ); - - uint64_t begtime; - double total; - - Image image; - - if (debug_load_times) - begtime=OS::get_singleton()->get_ticks_usec(); - - - Error err = ImageLoader::load_image(p_path,&image); - - if (!err && debug_load_times) { - double total=USEC_TO_SEC((OS::get_singleton()->get_ticks_usec()-begtime)); - print_line("IMAGE: "+itos(image.get_width())+"x"+itos(image.get_height())); - print_line(" -load: "+rtos(total)); - } - - - ERR_EXPLAIN("Failed loading image: "+p_path); - ERR_FAIL_COND_V(err, RES()); - if (r_error) - *r_error=ERR_FILE_CORRUPT; - -#ifdef DEBUG_ENABLED -#ifdef TOOLS_ENABLED - - if (max_texture_size && (image.get_width() > max_texture_size || image.get_height() > max_texture_size)) { - - - if (bool(ProjectSettings::get_singleton()->get("debug/image_loader/max_texture_size_alert"))) { - OS::get_singleton()->alert("Texture is too large: '"+p_path+"', at "+itos(image.get_width())+"x"+itos(image.get_height())+". Max allowed size is: "+itos(max_texture_size)+"x"+itos(max_texture_size)+".","BAD ARTIST, NO COOKIE!"); - } - - ERR_EXPLAIN("Texture is too large: '"+p_path+"', at "+itos(image.get_width())+"x"+itos(image.get_height())+". Max allowed size is: "+itos(max_texture_size)+"x"+itos(max_texture_size)+"."); - ERR_FAIL_V(RES()); - } -#endif -#endif - - - uint32_t flags=load_image_flags(p_path); - - if (debug_load_times) - begtime=OS::get_singleton()->get_ticks_usec(); - - //print_line("img: "+p_path+" flags: "+itos(flags)); - texture->create_from_image( image,flags ); - texture->set_name(p_path.get_file()); - - - if (debug_load_times) { - total=USEC_TO_SEC(OS::get_singleton()->get_ticks_usec()-begtime); - print_line(" -make texture: "+rtos(total)); - } - - if (r_error) - *r_error=OK; - - return RES( texture ); - } - - -} - -uint32_t ResourceFormatLoaderImage::load_image_flags(const String &p_path) { - - - FileAccess *f2 = FileAccess::open(p_path+".flags",FileAccess::READ); - Map<String,bool> flags_found; - if (f2) { - - while(!f2->eof_reached()) { - String l2 = f2->get_line(); - int eqpos = l2.find("="); - if (eqpos!=-1) { - String flag=l2.substr(0,eqpos).strip_edges(); - String val=l2.substr(eqpos+1,l2.length()).strip_edges().to_lower(); - flags_found[flag]=(val=="true" || val=="1")?true:false; - } - } - memdelete(f2); - } - - - uint32_t flags=0; - - if (flags_found.has("filter")) { - if (flags_found["filter"]) - flags|=Texture::FLAG_FILTER; - } else if (bool(GLOBAL_DEF("rendering/image_loader/filter",true))) { - flags|=Texture::FLAG_FILTER; - } - - - if (flags_found.has("gen_mipmaps")) { - if (flags_found["gen_mipmaps"]) - flags|=Texture::FLAG_MIPMAPS; - } else if (bool(GLOBAL_DEF("rendering/image_loader/gen_mipmaps",true))) { - flags|=Texture::FLAG_MIPMAPS; - } - - if (flags_found.has("repeat")) { - if (flags_found["repeat"]) - flags|=Texture::FLAG_REPEAT; - } else if (bool(GLOBAL_DEF("rendering/image_loader/repeat",true))) { - flags|=Texture::FLAG_REPEAT; - } - - if (flags_found.has("anisotropic")) { - if (flags_found["anisotropic"]) - flags|=Texture::FLAG_ANISOTROPIC_FILTER; - } - - if (flags_found.has("tolinear")) { - if (flags_found["tolinear"]) - flags|=Texture::FLAG_CONVERT_TO_LINEAR; - } - - if (flags_found.has("mirroredrepeat")) { - if (flags_found["mirroredrepeat"]) - flags|=Texture::FLAG_MIRRORED_REPEAT; - } - - return flags; -} - -bool ResourceFormatLoaderImage::handles_type(const String& p_type) const { - - return ClassDB::is_parent_class(p_type,"Texture") || ClassDB::is_parent_class(p_type,"CubeMap"); -} - -void ResourceFormatLoaderImage::get_recognized_extensions(List<String> *p_extensions) const { - - ImageLoader::get_recognized_extensions(p_extensions); - p_extensions->push_back("cube"); -} - -String ResourceFormatLoaderImage::get_resource_type(const String &p_path) const { - - String ext=p_path.get_extension().to_lower(); - if (ext=="cube") - return "CubeMap"; - - List<String> extensions; - ImageLoader::get_recognized_extensions(&extensions); - - for(List<String>::Element *E=extensions.front();E;E=E->next()) { - if (E->get()==ext) - return "ImageTexture"; - } - return ""; -} - - -ResourceFormatLoaderImage::ResourceFormatLoaderImage() { - - max_texture_size = GLOBAL_DEF("debug/image_loader/max_texture_size",0); - GLOBAL_DEF("debug/image_loader/max_texture_size_alert",false); - debug_load_times=GLOBAL_DEF("debug/image_loader/image_load_times",false); - GLOBAL_DEF("rendering/image_loader/filter",true); - GLOBAL_DEF("rendering/image_loader/gen_mipmaps",true); - GLOBAL_DEF("rendering/image_loader/repeat",false); - -} -#endif diff --git a/scene/io/resource_format_image.h b/scene/io/resource_format_image.h deleted file mode 100644 index 506dc66c19..0000000000 --- a/scene/io/resource_format_image.h +++ /dev/null @@ -1,55 +0,0 @@ -/*************************************************************************/ -/* resource_format_image.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 RESOURCE_FORMAT_IMAGE_H -#define RESOURCE_FORMAT_IMAGE_H - -#if 0 - -#include "io/resource_loader.h" -#include "io/resource_saver.h" -/** - @author Juan Linietsky <reduzio@gmail.com> -*/ -class ResourceFormatLoaderImage : public ResourceFormatLoader { - - bool debug_load_times; - int max_texture_size; -public: - virtual RES load(const String &p_path,const String& p_original_path="",Error *r_error=NULL); - static uint32_t load_image_flags(const String &p_path); - virtual void get_recognized_extensions(List<String> *p_extensions) const; - virtual bool handles_type(const String& p_type) const; - virtual String get_resource_type(const String &p_path) const; - - ResourceFormatLoaderImage(); -}; - -#endif -#endif diff --git a/scene/io/resource_format_wav.cpp b/scene/io/resource_format_wav.cpp deleted file mode 100644 index ec856a96fb..0000000000 --- a/scene/io/resource_format_wav.cpp +++ /dev/null @@ -1,277 +0,0 @@ -/*************************************************************************/ -/* resource_format_wav.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. */ -/*************************************************************************/ -#if 0 -#include "resource_format_wav.h" -#include "os/file_access.h" -#include "scene/resources/sample.h" - - -RES ResourceFormatLoaderWAV::load(const String &p_path, const String& p_original_path, Error *r_error) { - if (r_error) - *r_error=ERR_FILE_CANT_OPEN; - - Error err; - FileAccess *file=FileAccess::open(p_path, FileAccess::READ,&err); - - ERR_FAIL_COND_V( err!=OK, RES() ); - - if (r_error) - *r_error=ERR_FILE_CORRUPT; - - /* CHECK RIFF */ - char riff[5]; - riff[4]=0; - file->get_buffer((uint8_t*)&riff,4); //RIFF - - if (riff[0]!='R' || riff[1]!='I' || riff[2]!='F' || riff[3]!='F') { - - file->close(); - memdelete(file); - ERR_FAIL_V( RES() ); - } - - - /* GET FILESIZE */ - uint32_t filesize=file->get_32(); - - /* CHECK WAVE */ - - char wave[4]; - - file->get_buffer((uint8_t*)&wave,4); //RIFF - - if (wave[0]!='W' || wave[1]!='A' || wave[2]!='V' || wave[3]!='E') { - - - file->close(); - memdelete(file); - ERR_EXPLAIN("Not a WAV file (no WAVE RIFF Header)") - ERR_FAIL_V( RES() ); - } - - bool format_found=false; - bool data_found=false; - int format_bits=0; - int format_channels=0; - int format_freq=0; - Sample::LoopFormat loop=Sample::LOOP_NONE; - int loop_begin=0; - int loop_end=0; - - - Ref<Sample> sample( memnew( Sample ) ); - - - while (!file->eof_reached()) { - - - /* chunk */ - char chunkID[4]; - file->get_buffer((uint8_t*)&chunkID,4); //RIFF - - /* chunk size */ - uint32_t chunksize=file->get_32(); - uint32_t file_pos=file->get_position(); //save file pos, so we can skip to next chunk safely - - if (file->eof_reached()) { - - //ERR_PRINT("EOF REACH"); - break; - } - - if (chunkID[0]=='f' && chunkID[1]=='m' && chunkID[2]=='t' && chunkID[3]==' ' && !format_found) { - /* IS FORMAT CHUNK */ - - uint16_t compression_code=file->get_16(); - - - if (compression_code!=1) { - ERR_PRINT("Format not supported for WAVE file (not PCM). Save WAVE files as uncompressed PCM instead."); - break; - } - - format_channels=file->get_16(); - if (format_channels!=1 && format_channels !=2) { - - ERR_PRINT("Format not supported for WAVE file (not stereo or mono)"); - break; - - } - - format_freq=file->get_32(); //sampling rate - - file->get_32(); // average bits/second (unused) - file->get_16(); // block align (unused) - format_bits=file->get_16(); // bits per sample - - if (format_bits%8) { - - ERR_PRINT("Strange number of bits in sample (not 8,16,24,32)"); - break; - } - - /* Don't need anything else, continue */ - format_found=true; - } - - - if (chunkID[0]=='d' && chunkID[1]=='a' && chunkID[2]=='t' && chunkID[3]=='a' && !data_found) { - /* IS FORMAT CHUNK */ - data_found=true; - - if (!format_found) { - ERR_PRINT("'data' chunk before 'format' chunk found."); - break; - - } - - int frames=chunksize; - - frames/=format_channels; - frames/=(format_bits>>3); - - /*print_line("chunksize: "+itos(chunksize)); - print_line("channels: "+itos(format_channels)); - print_line("bits: "+itos(format_bits)); -*/ - sample->create( - (format_bits==8) ? Sample::FORMAT_PCM8 : Sample::FORMAT_PCM16, - (format_channels==2)?true:false, - frames ); - sample->set_mix_rate( format_freq ); - - int len=frames; - if (format_channels==2) - len*=2; - if (format_bits>8) - len*=2; - - PoolVector<uint8_t> data; - data.resize(len); - PoolVector<uint8_t>::Write dataw = data.write(); - void * data_ptr = dataw.ptr(); - - for (int i=0;i<frames;i++) { - - - for (int c=0;c<format_channels;c++) { - - - if (format_bits==8) { - // 8 bit samples are UNSIGNED - - uint8_t s = file->get_8(); - s-=128; - int8_t *sp=(int8_t*)&s; - - int8_t *data_ptr8=&((int8_t*)data_ptr)[i*format_channels+c]; - - *data_ptr8=*sp; - - } else { - //16+ bits samples are SIGNED - // if sample is > 16 bits, just read extra bytes - - uint32_t data=0; - for (int b=0;b<(format_bits>>3);b++) { - - data|=((uint32_t)file->get_8())<<(b*8); - } - data<<=(32-format_bits); - - - int32_t s=data; - - int16_t *data_ptr16=&((int16_t*)data_ptr)[i*format_channels+c]; - - *data_ptr16=s>>16; - } - } - - } - - dataw=PoolVector<uint8_t>::Write(); - - sample->set_data(data); - - - if (file->eof_reached()) { - file->close(); - memdelete(file); - ERR_EXPLAIN("Premature end of file."); - ERR_FAIL_V(RES()); - } - } - - if (chunkID[0]=='s' && chunkID[1]=='m' && chunkID[2]=='p' && chunkID[3]=='l') { - //loop point info! - - for(int i=0;i<10;i++) - file->get_32(); // i wish to know why should i do this... no doc! - - loop=file->get_32()?Sample::LOOP_PING_PONG:Sample::LOOP_FORWARD; - loop_begin=file->get_32(); - loop_end=file->get_32(); - - } - file->seek( file_pos+chunksize ); - } - - sample->set_loop_format(loop); - sample->set_loop_begin(loop_begin); - sample->set_loop_end(loop_end); - - file->close(); - memdelete(file); - - if (r_error) - *r_error=OK; - - - return sample; - -} -void ResourceFormatLoaderWAV::get_recognized_extensions(List<String> *p_extensions) const { - - p_extensions->push_back("wav"); -} -bool ResourceFormatLoaderWAV::handles_type(const String& p_type) const { - - return (p_type=="Sample"); -} - -String ResourceFormatLoaderWAV::get_resource_type(const String &p_path) const { - - if (p_path.get_extension().to_lower()=="wav") - return "Sample"; - return ""; -} - -#endif diff --git a/scene/io/resource_format_wav.h b/scene/io/resource_format_wav.h deleted file mode 100644 index 7e7a07ec7e..0000000000 --- a/scene/io/resource_format_wav.h +++ /dev/null @@ -1,46 +0,0 @@ -/*************************************************************************/ -/* resource_format_wav.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 RESOURCE_FORMAT_WAV_H -#define RESOURCE_FORMAT_WAV_H - -#if 0 -#include "io/resource_loader.h" - -class ResourceFormatLoaderWAV : public ResourceFormatLoader { -public: - virtual RES load(const String &p_path,const String& p_original_path="",Error *r_error=NULL); - virtual void get_recognized_extensions(List<String> *p_extensions) const; - virtual bool handles_type(const String& p_type) const; - virtual String get_resource_type(const String &p_path) const; - -}; - -#endif -#endif // RESOURCE_FORMAT_WAV_H diff --git a/scene/main/node.cpp b/scene/main/node.cpp index 75017eae54..c3d9d97c5a 100755 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -28,6 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "node.h" + #include "instance_placeholder.h" #include "io/resource_loader.h" #include "message_queue.h" @@ -360,18 +361,6 @@ void Node::add_child_notify(Node *p_child) { // to be used when not wanted } -/* -void Node::remove_and_delete_child(Node *p_child) { - - ERR_FAIL_NULL( p_child ); - ERR_FAIL_COND( p_child->get_parent()!=this ); - - remove_child(p_child); - memdelete(p_child); - -} -*/ - void Node::remove_child_notify(Node *p_child) { // to be used when not wanted @@ -675,31 +664,6 @@ Variant Node::_rpc_unreliable_id_bind(const Variant **p_args, int p_argcount, Va return Variant(); } -#if 0 -Variant Node::_rpc_bind(const Variant** p_args, int p_argcount, Variant::CallError& r_error) { - - if (p_argcount<1) { - r_error.error=Variant::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS; - r_error.argument=1; - return Variant(); - } - - if (p_args[0]->get_type()!=Variant::STRING) { - r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT; - r_error.argument=0; - r_error.expected=Variant::STRING; - return Variant(); - } - - StringName method = *p_args[0]; - - rpcp(method,&p_args[1],p_argcount-1); - - r_error.error=Variant::CallError::CALL_OK; - return Variant(); -} - -#endif void Node::rpcp(int p_peer_id, bool p_unreliable, const StringName &p_method, const Variant **p_arg, int p_argcount) { ERR_FAIL_COND(!is_inside_tree()); @@ -2070,59 +2034,6 @@ HashMap<NodePath, int> Node::get_editable_instances() const { return data.editable_instances; } -#if 0 - -void Node::generate_instance_state() { - - List<PropertyInfo> properties; - get_property_list(&properties); - - data.instance_state.clear(); - - for( List<PropertyInfo>::Element *E=properties.front();E;E=E->next() ) { - - PropertyInfo &pi=E->get(); - if ((pi.usage&PROPERTY_USAGE_NO_INSTANCE_STATE) || !(pi.usage&PROPERTY_USAGE_EDITOR) || !(pi.usage&PROPERTY_USAGE_STORAGE)) - continue; - - data.instance_state[pi.name]=get(pi.name); - } - - List<GroupInfo> groups; - get_groups(&groups); - for(List<GroupInfo>::Element *E=groups.front();E;E=E->next()) { - - if (!E->get().persistent) - continue; - data.instance_groups.push_back(E->get().name); - } - - List<MethodInfo> signal_list; - - get_signal_list(&signal_list); - - for(List<MethodInfo>::Element *E=signal_list.front();E;E=E->next()) { - - StringName name = E->get().name; - List<Connection> connections; - get_signal_connection_list(name,&connections); - - for(List<Connection>::Element *F=connections.front();F;F=F->next()) { - - if (F->get().flags&CONNECT_PERSIST) - data.instance_connections.push_back(F->get()); - } - - } -} - -Dictionary Node::get_instance_state() const { - - return data.instance_state; -} - -#endif - void Node::set_scene_instance_state(const Ref<SceneState> &p_state) { data.instance_state = p_state; @@ -2752,7 +2663,6 @@ void Node::_bind_methods() { ClassDB::bind_method(D_METHOD("get_name"), &Node::get_name); ClassDB::bind_method(D_METHOD("add_child", "node", "legible_unique_name"), &Node::add_child, DEFVAL(false)); ClassDB::bind_method(D_METHOD("remove_child", "node"), &Node::remove_child); - //ClassDB::bind_method(D_METHOD("remove_and_delete_child","node"),&Node::remove_and_delete_child); ClassDB::bind_method(D_METHOD("get_child_count"), &Node::get_child_count); ClassDB::bind_method(D_METHOD("get_children"), &Node::_get_children); ClassDB::bind_method(D_METHOD("get_child", "idx"), &Node::get_child); @@ -2864,7 +2774,6 @@ void Node::_bind_methods() { BIND_CONSTANT(NOTIFICATION_ENTER_TREE); BIND_CONSTANT(NOTIFICATION_EXIT_TREE); BIND_CONSTANT(NOTIFICATION_MOVED_IN_PARENT); - //BIND_CONSTANT( NOTIFICATION_PARENT_DECONFIGURED ); BIND_CONSTANT(NOTIFICATION_READY); BIND_CONSTANT(NOTIFICATION_FIXED_PROCESS); BIND_CONSTANT(NOTIFICATION_PROCESS); diff --git a/scene/main/node.h b/scene/main/node.h index c7fd6f50cd..12d6310062 100644 --- a/scene/main/node.h +++ b/scene/main/node.h @@ -192,7 +192,6 @@ protected: virtual void add_child_notify(Node *p_child); virtual void remove_child_notify(Node *p_child); virtual void move_child_notify(Node *p_child); - //void remove_and_delete_child(Node *p_child); void _propagate_replace_owner(Node *p_owner, Node *p_by_owner); @@ -212,7 +211,6 @@ public: NOTIFICATION_EXIT_TREE = 11, NOTIFICATION_MOVED_IN_PARENT = 12, NOTIFICATION_READY = 13, - //NOTIFICATION_PARENT_DECONFIGURED =15, - it's confusing, it's going away NOTIFICATION_PAUSED = 14, NOTIFICATION_UNPAUSED = 15, NOTIFICATION_FIXED_PROCESS = 16, diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp index eb7b572d59..65aeb23609 100644 --- a/scene/main/scene_tree.cpp +++ b/scene/main/scene_tree.cpp @@ -29,18 +29,15 @@ /*************************************************************************/ #include "scene_tree.h" +#include "editor/editor_node.h" +#include "io/marshalls.h" +#include "io/resource_loader.h" #include "message_queue.h" #include "node.h" #include "os/keyboard.h" #include "os/os.h" #include "print_string.h" #include "project_settings.h" -#include <stdio.h> -//#include "servers/spatial_sound_2d_server.h" - -#include "editor/editor_node.h" -#include "io/marshalls.h" -#include "io/resource_loader.h" #include "scene/resources/material.h" #include "scene/resources/mesh.h" #include "scene/resources/packed_scene.h" @@ -49,6 +46,8 @@ #include "servers/physics_server.h" #include "viewport.h" +#include <stdio.h> + void SceneTreeTimer::_bind_methods() { ClassDB::bind_method(D_METHOD("set_time_left", "time"), &SceneTreeTimer::set_time_left); @@ -413,19 +412,7 @@ void SceneTree::input_event(const Ref<InputEvent> &p_event) { root_lock++; if (!input_handled) { - -#if 0 - _call_input_pause("unhandled_input","_unhandled_input",ev); - //call_group(GROUP_CALL_REVERSE|GROUP_CALL_REALTIME|GROUP_CALL_MULIILEVEL,"unhandled_input","_unhandled_input",ev); - if (!input_handled && ev.type==InputEvent::KEY) { - _call_input_pause("unhandled_key_input","_unhandled_key_input",ev); - //call_group(GROUP_CALL_REVERSE|GROUP_CALL_REALTIME|GROUP_CALL_MULIILEVEL,"unhandled_key_input","_unhandled_key_input",ev); - } -#else - call_group_flags(GROUP_CALL_REALTIME, "_viewports", "_vp_unhandled_input", ev); //special one for GUI, as controls use their own process check - -#endif input_handled = true; _flush_ugc(); root_lock--; diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index 3659457789..02da926e50 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -28,28 +28,23 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "viewport.h" + #include "os/input.h" #include "os/os.h" -#include "scene/3d/spatial.h" -#include "servers/physics_2d_server.h" -//#include "scene/3d/camera.h" - +#include "project_settings.h" +#include "scene/2d/collision_object_2d.h" #include "scene/3d/camera.h" #include "scene/3d/collision_object.h" #include "scene/3d/listener.h" -#include "scene/3d/spatial_indexer.h" +#include "scene/3d/scenario_fx.h" +#include "scene/3d/spatial.h" #include "scene/gui/control.h" -#include "scene/resources/mesh.h" - -#include "scene/2d/collision_object_2d.h" - #include "scene/gui/label.h" #include "scene/gui/panel.h" #include "scene/main/timer.h" +#include "scene/resources/mesh.h" #include "scene/scene_string_names.h" - -#include "project_settings.h" -#include "scene/3d/scenario_fx.h" +#include "servers/physics_2d_server.h" void ViewportTexture::setup_local_to_scene() { @@ -1180,44 +1175,7 @@ bool Viewport::is_size_override_stretch_enabled() const { return size_override_stretch; } -#if 0 -void Viewport::set_as_render_target(bool p_enable){ - -/* if (render_target==p_enable) - return; - - render_target=p_enable; - VS::get_singleton()->viewport_set_as_render_target(viewport,p_enable); - if (is_inside_tree()) { - - if (p_enable) - _vp_exit_tree(); - else - _vp_enter_tree(); - } - - if (p_enable) { - - texture_rid = VS::get_singleton()->viewport_get_texture(viewport); - } else { - - texture_rid=RID(); - } - - texture->set_flags(texture->flags); - texture->emit_changed(); - - update_configuration_warning(); - */ -} - -bool Viewport::is_set_as_render_target() const{ - - return render_target; - -} -#endif void Viewport::set_update_mode(UpdateMode p_mode) { update_mode = p_mode; @@ -1227,7 +1185,6 @@ Viewport::UpdateMode Viewport::get_update_mode() const { return update_mode; } -//RID get_texture() const; Ref<ViewportTexture> Viewport::get_texture() const { diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp index 17bf165b33..e01f5e3cdf 100644 --- a/scene/register_scene_types.cpp +++ b/scene/register_scene_types.cpp @@ -108,8 +108,6 @@ #include "scene/gui/tree.h" #include "scene/gui/video_player.h" #include "scene/gui/viewport_container.h" -#include "scene/io/resource_format_image.h" -#include "scene/io/resource_format_wav.h" #include "scene/main/canvas_layer.h" #include "scene/main/http_request.h" #include "scene/main/instance_placeholder.h" diff --git a/scene/resources/animation.cpp b/scene/resources/animation.cpp index 0328c8c9cd..1a2c8333ef 100644 --- a/scene/resources/animation.cpp +++ b/scene/resources/animation.cpp @@ -28,6 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "animation.h" + #include "geometry.h" bool Animation::_set(const StringName &p_name, const Variant &p_value) { @@ -83,44 +84,6 @@ bool Animation::_set(const StringName &p_name, const Variant &p_value) { TransformTrack *tt = static_cast<TransformTrack *>(tracks[track]); PoolVector<float> values = p_value; int vcount = values.size(); - -#if 0 // old compatibility hack - if ((vcount%11) == 0) { - - - PoolVector<float>::Read r = values.read(); - - tt->transforms.resize(vcount/11); - - - for(int i=0;i<(vcount/11);i++) { - - - TKey<TransformKey> &tk=tt->transforms[i]; - const float *ofs=&r[i*11]; - tk.time=ofs[0]; - - tk.value.loc.x=ofs[1]; - tk.value.loc.y=ofs[2]; - tk.value.loc.z=ofs[3]; - - tk.value.rot.x=ofs[4]; - tk.value.rot.y=ofs[5]; - tk.value.rot.z=ofs[6]; - tk.value.rot.w=ofs[7]; - - tk.value.scale.x=ofs[8]; - tk.value.scale.y=ofs[9]; - tk.value.scale.z=ofs[10]; - - - } - return true; - - - - } -#endif ERR_FAIL_COND_V(vcount % 12, false); // shuld be multiple of 11 PoolVector<float>::Read r = values.read(); diff --git a/scene/resources/audio_stream_resampled.cpp b/scene/resources/audio_stream_resampled.cpp deleted file mode 100644 index 4d0f869f15..0000000000 --- a/scene/resources/audio_stream_resampled.cpp +++ /dev/null @@ -1,388 +0,0 @@ -/*************************************************************************/ -/* audio_stream_resampled.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 "audio_stream_resampled.h" -#include "project_settings.h" - -#if 0 -int AudioStreamResampled::get_channel_count() const { - - if (!rb) - return 0; - - return channels; -} - - -template<int C> -uint32_t AudioStreamResampled::_resample(int32_t *p_dest,int p_todo,int32_t p_increment) { - - uint32_t read=offset&MIX_FRAC_MASK; - - for (int i=0;i<p_todo;i++) { - - offset = (offset + p_increment)&(((1<<(rb_bits+MIX_FRAC_BITS))-1)); - read+=p_increment; - uint32_t pos = offset >> MIX_FRAC_BITS; - uint32_t frac = offset & MIX_FRAC_MASK; -#ifndef FAST_AUDIO - ERR_FAIL_COND_V(pos>=rb_len,0); -#endif - uint32_t pos_next = (pos+1)&rb_mask; - //printf("rb pos %i\n",pos); - - // since this is a template with a known compile time value (C), conditionals go away when compiling. - if (C==1) { - - int32_t v0 = rb[pos]; - int32_t v0n=rb[pos_next]; -#ifndef FAST_AUDIO - v0+=(v0n-v0)*(int32_t)frac >> MIX_FRAC_BITS; -#endif - v0<<=16; - p_dest[i]=v0; - - } - if (C==2) { - - int32_t v0 = rb[(pos<<1)+0]; - int32_t v1 = rb[(pos<<1)+1]; - int32_t v0n=rb[(pos_next<<1)+0]; - int32_t v1n=rb[(pos_next<<1)+1]; - -#ifndef FAST_AUDIO - v0+=(v0n-v0)*(int32_t)frac >> MIX_FRAC_BITS; - v1+=(v1n-v1)*(int32_t)frac >> MIX_FRAC_BITS; -#endif - v0<<=16; - v1<<=16; - p_dest[(i<<1)+0]=v0; - p_dest[(i<<1)+1]=v1; - - } - - if (C==4) { - - int32_t v0 = rb[(pos<<2)+0]; - int32_t v1 = rb[(pos<<2)+1]; - int32_t v2 = rb[(pos<<2)+2]; - int32_t v3 = rb[(pos<<2)+3]; - int32_t v0n = rb[(pos_next<<2)+0]; - int32_t v1n=rb[(pos_next<<2)+1]; - int32_t v2n=rb[(pos_next<<2)+2]; - int32_t v3n=rb[(pos_next<<2)+3]; - -#ifndef FAST_AUDIO - v0+=(v0n-v0)*(int32_t)frac >> MIX_FRAC_BITS; - v1+=(v1n-v1)*(int32_t)frac >> MIX_FRAC_BITS; - v2+=(v2n-v2)*(int32_t)frac >> MIX_FRAC_BITS; - v3+=(v3n-v3)*(int32_t)frac >> MIX_FRAC_BITS; -#endif - v0<<=16; - v1<<=16; - v2<<=16; - v3<<=16; - p_dest[(i<<2)+0]=v0; - p_dest[(i<<2)+1]=v1; - p_dest[(i<<2)+2]=v2; - p_dest[(i<<2)+3]=v3; - - } - - if (C==6) { - - int32_t v0 = rb[(pos*6)+0]; - int32_t v1 = rb[(pos*6)+1]; - int32_t v2 = rb[(pos*6)+2]; - int32_t v3 = rb[(pos*6)+3]; - int32_t v4 = rb[(pos*6)+4]; - int32_t v5 = rb[(pos*6)+5]; - int32_t v0n = rb[(pos_next*6)+0]; - int32_t v1n=rb[(pos_next*6)+1]; - int32_t v2n=rb[(pos_next*6)+2]; - int32_t v3n=rb[(pos_next*6)+3]; - int32_t v4n=rb[(pos_next*6)+4]; - int32_t v5n=rb[(pos_next*6)+5]; - -#ifndef FAST_AUDIO - v0+=(v0n-v0)*(int32_t)frac >> MIX_FRAC_BITS; - v1+=(v1n-v1)*(int32_t)frac >> MIX_FRAC_BITS; - v2+=(v2n-v2)*(int32_t)frac >> MIX_FRAC_BITS; - v3+=(v3n-v3)*(int32_t)frac >> MIX_FRAC_BITS; - v4+=(v4n-v4)*(int32_t)frac >> MIX_FRAC_BITS; - v5+=(v5n-v5)*(int32_t)frac >> MIX_FRAC_BITS; -#endif - v0<<=16; - v1<<=16; - v2<<=16; - v3<<=16; - v4<<=16; - v5<<=16; - p_dest[(i*6)+0]=v0; - p_dest[(i*6)+1]=v1; - p_dest[(i*6)+2]=v2; - p_dest[(i*6)+3]=v3; - p_dest[(i*6)+4]=v4; - p_dest[(i*6)+5]=v5; - - } - - - } - - - return read>>MIX_FRAC_BITS;//rb_read_pos=offset>>MIX_FRAC_BITS; - -} - - -bool AudioStreamResampled::mix(int32_t *p_dest, int p_frames) { - - - if (!rb || !_can_mix()) - return false; - - int write_pos_cache=rb_write_pos; - - int32_t increment=(mix_rate*MIX_FRAC_LEN)/get_mix_rate(); - - int rb_todo; - - if (write_pos_cache==rb_read_pos) { - return false; //out of buffer - - } else if (rb_read_pos<write_pos_cache) { - - rb_todo=write_pos_cache-rb_read_pos; //-1? - } else { - - rb_todo=(rb_len-rb_read_pos)+write_pos_cache; //-1? - } - - int todo = MIN( ((int64_t(rb_todo)<<MIX_FRAC_BITS)/increment)+1, p_frames ); -#if 0 - if (int(mix_rate)==get_mix_rate()) { - - - if (channels==6) { - - for(int i=0;i<p_frames;i++) { - - int from = ((rb_read_pos+i)&rb_mask)*6; - int to = i*6; - - p_dest[from+0]=int32_t(rb[to+0])<<16; - p_dest[from+1]=int32_t(rb[to+1])<<16; - p_dest[from+2]=int32_t(rb[to+2])<<16; - p_dest[from+3]=int32_t(rb[to+3])<<16; - p_dest[from+4]=int32_t(rb[to+4])<<16; - p_dest[from+5]=int32_t(rb[to+5])<<16; - } - - } else { - int len=p_frames*channels; - int from=rb_read_pos*channels; - int mask=0; - switch(channels) { - case 1: mask=rb_len-1; break; - case 2: mask=(rb_len*2)-1; break; - case 4: mask=(rb_len*4)-1; break; - } - - for(int i=0;i<len;i++) { - - p_dest[i]=int32_t(rb[(from+i)&mask])<<16; - } - } - - rb_read_pos = (rb_read_pos+p_frames)&rb_mask; - } else -#endif - { - - uint32_t read=0; - switch(channels) { - case 1: read=_resample<1>(p_dest,todo,increment); break; - case 2: read=_resample<2>(p_dest,todo,increment); break; - case 4: read=_resample<4>(p_dest,todo,increment); break; - case 6: read=_resample<6>(p_dest,todo,increment); break; - } -#if 1 - //end of stream, fadeout - int remaining = p_frames-todo; - if (remaining && todo>0) { - - //print_line("fadeout"); - for(int c=0;c<channels;c++) { - - for(int i=0;i<todo;i++) { - - int32_t samp = p_dest[i*channels+c]>>8; - uint32_t mul = (todo-i) * 256 /todo; - //print_line("mul: "+itos(i)+" "+itos(mul)); - p_dest[i*channels+c]=samp*mul; - } - - } - - } - -#else - int remaining = p_frames-todo; - if (remaining && todo>0) { - - - for(int c=0;c<channels;c++) { - - int32_t from = p_dest[(todo-1)*channels+c]>>8; - - for(int i=0;i<remaining;i++) { - - uint32_t mul = (remaining-i) * 256 /remaining; - p_dest[(todo+i)*channels+c]=from*mul; - } - - } - - } -#endif - - //zero out what remains there to avoid glitches - for(int i=todo*channels;i<int(p_frames)*channels;i++) { - - p_dest[i]=0; - } - - if (read>rb_todo) - read=rb_todo; - - rb_read_pos = (rb_read_pos+read)&rb_mask; - - - - - } - - return true; -} - - -Error AudioStreamResampled::_setup(int p_channels,int p_mix_rate,int p_minbuff_needed) { - - ERR_FAIL_COND_V(p_channels!=1 && p_channels!=2 && p_channels!=4 && p_channels!=6,ERR_INVALID_PARAMETER); - - - float buffering_sec = int(GLOBAL_DEF("audio/stream_buffering_ms",500))/1000.0; - int desired_rb_bits =nearest_shift(MAX(buffering_sec*p_mix_rate,p_minbuff_needed)); - - bool recreate=!rb; - - if (rb && (uint32_t(desired_rb_bits)!=rb_bits || channels!=uint32_t(p_channels))) { - //recreate - - memdelete_arr(rb); - memdelete_arr(read_buf); - recreate=true; - - } - - if (recreate) { - - channels=p_channels; - rb_bits=desired_rb_bits; - rb_len=(1<<rb_bits); - rb_mask=rb_len-1; - rb = memnew_arr( int16_t, rb_len * p_channels ); - read_buf = memnew_arr( int16_t, rb_len * p_channels ); - - } - - mix_rate=p_mix_rate; - offset=0; - rb_read_pos=0; - rb_write_pos=0; - - //avoid maybe strange noises upon load - for (int i=0;i<(rb_len*channels);i++) { - - rb[i]=0; - read_buf[i]=0; - } - - return OK; - -} - -void AudioStreamResampled::_clear() { - - if (!rb) - return; - - AudioServer::get_singleton()->lock(); - //should be stopped at this point but just in case - if (rb) { - memdelete_arr(rb); - memdelete_arr(read_buf); - } - rb=NULL; - offset=0; - rb_read_pos=0; - rb_write_pos=0; - read_buf=NULL; - AudioServer::get_singleton()->unlock(); - -} - -AudioStreamResampled::AudioStreamResampled() { - - rb=NULL; - offset=0; - read_buf=NULL; - rb_read_pos=0; - rb_write_pos=0; - - rb_bits=0; - rb_len=0; - rb_mask=0; - read_buff_len=0; - channels=0; - mix_rate=0; - -} - -AudioStreamResampled::~AudioStreamResampled() { - - if (rb) { - memdelete_arr(rb); - memdelete_arr(read_buf); - } - -} - -#endif diff --git a/scene/resources/audio_stream_resampled.h b/scene/resources/audio_stream_resampled.h deleted file mode 100644 index e6dd44ea51..0000000000 --- a/scene/resources/audio_stream_resampled.h +++ /dev/null @@ -1,166 +0,0 @@ -/*************************************************************************/ -/* audio_stream_resampled.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 AUDIO_STREAM_RESAMPLED_H -#define AUDIO_STREAM_RESAMPLED_H - -//#include "scene/resources/audio_stream.h" - -#if 0 - -class AudioStreamResampled : public AudioStream { - GDCLASS(AudioStreamResampled,AudioStream); - - uint32_t rb_bits; - uint32_t rb_len; - uint32_t rb_mask; - uint32_t read_buff_len; - uint32_t channels; - uint32_t mix_rate; - - volatile int rb_read_pos; - volatile int rb_write_pos; - - int32_t offset; //contains the fractional remainder of the resampler - enum { - MIX_FRAC_BITS=13, - MIX_FRAC_LEN=(1<<MIX_FRAC_BITS), - MIX_FRAC_MASK=MIX_FRAC_LEN-1, - }; - - int16_t *read_buf; - int16_t *rb; - - - template<int C> - uint32_t _resample(int32_t *p_dest,int p_todo,int32_t p_increment); - - -protected: - - _FORCE_INLINE_ int get_total() const { - - return rb_len; - } - - _FORCE_INLINE_ int get_todo() const { //return amount of frames to mix - - int todo; - int read_pos_cache=rb_read_pos; - - if (read_pos_cache==rb_write_pos) { - todo=rb_len-1; - } else if (read_pos_cache>rb_write_pos) { - - todo=read_pos_cache-rb_write_pos-1; - } else { - - todo=(rb_len-rb_write_pos)+read_pos_cache-1; - } - - return todo; - } - - //Stream virtual funcs - virtual int get_channel_count() const; - virtual bool mix(int32_t *p_dest, int p_frames); - - _FORCE_INLINE_ void _flush() { - rb_read_pos=0; - rb_write_pos=0; - } - - _FORCE_INLINE_ int16_t *get_write_buffer() { return read_buf; } - _FORCE_INLINE_ void write(uint32_t p_frames) { - - ERR_FAIL_COND(p_frames >= rb_len); - - switch(channels) { - case 1: { - - for(uint32_t i=0;i<p_frames;i++) { - - rb[ rb_write_pos ] = read_buf[i]; - rb_write_pos=(rb_write_pos+1)&rb_mask; - } - } break; - case 2: { - - for(uint32_t i=0;i<p_frames;i++) { - - rb[ (rb_write_pos<<1)+0 ] = read_buf[(i<<1)+0]; - rb[ (rb_write_pos<<1)+1 ] = read_buf[(i<<1)+1]; - rb_write_pos=(rb_write_pos+1)&rb_mask; - } - } break; - case 4: { - - for(uint32_t i=0;i<p_frames;i++) { - - rb[ (rb_write_pos<<2)+0 ] = read_buf[(i<<2)+0]; - rb[ (rb_write_pos<<2)+1 ] = read_buf[(i<<2)+1]; - rb[ (rb_write_pos<<2)+2 ] = read_buf[(i<<2)+2]; - rb[ (rb_write_pos<<2)+3 ] = read_buf[(i<<2)+3]; - rb_write_pos=(rb_write_pos+1)&rb_mask; - } - } break; - case 6: { - - for(uint32_t i=0;i<p_frames;i++) { - - rb[ (rb_write_pos*6)+0 ] = read_buf[(i*6)+0]; - rb[ (rb_write_pos*6)+1 ] = read_buf[(i*6)+1]; - rb[ (rb_write_pos*6)+2 ] = read_buf[(i*6)+2]; - rb[ (rb_write_pos*6)+3 ] = read_buf[(i*6)+3]; - rb[ (rb_write_pos*6)+4 ] = read_buf[(i*6)+4]; - rb[ (rb_write_pos*6)+5 ] = read_buf[(i*6)+5]; - rb_write_pos=(rb_write_pos+1)&rb_mask; - } - } break; - - - } - - } - - virtual bool _can_mix() const =0; - - _FORCE_INLINE_ bool _is_ready() const{ - return rb!=NULL; - } - - Error _setup(int p_channels,int p_mix_rate,int p_minbuff_needed=-1); - void _clear(); - -public: - AudioStreamResampled(); - ~AudioStreamResampled(); -}; -#endif -#endif // AUDIO_STREAM_RESAMPLED_H diff --git a/scene/resources/curve.cpp b/scene/resources/curve.cpp index 877760c1bd..7fbaa1f73c 100644 --- a/scene/resources/curve.cpp +++ b/scene/resources/curve.cpp @@ -28,6 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "curve.h" + #include "core_string_names.h" template <class T> @@ -42,344 +43,6 @@ static _FORCE_INLINE_ T _bezier_interp(real_t t, T start, T control_1, T control return start * omt3 + control_1 * omt2 * t * 3.0 + control_2 * omt * t2 * 3.0 + end * t3; } -#if 0 - -int Curve2D::get_point_count() const { - - return points.size(); -} -void Curve2D::add_point(const Vector2& p_pos, const Vector2& p_in, const Vector2& p_out) { - - Point n; - n.pos=p_pos; - n.in=p_in; - n.out=p_out; - points.push_back(n); - emit_signal(CoreStringNames::get_singleton()->changed); -} -void Curve2D::set_point_pos(int p_index, const Vector2& p_pos) { - - ERR_FAIL_INDEX(p_index,points.size()); - - points[p_index].pos=p_pos; - emit_signal(CoreStringNames::get_singleton()->changed); - -} -Vector2 Curve2D::get_point_pos(int p_index) const { - - ERR_FAIL_INDEX_V(p_index,points.size(),Vector2()); - return points[p_index].pos; - -} - - -void Curve2D::set_point_in(int p_index, const Vector2& p_in) { - - ERR_FAIL_INDEX(p_index,points.size()); - - points[p_index].in=p_in; - emit_signal(CoreStringNames::get_singleton()->changed); - -} -Vector2 Curve2D::get_point_in(int p_index) const { - - ERR_FAIL_INDEX_V(p_index,points.size(),Vector2()); - return points[p_index].in; - -} - -void Curve2D::set_point_out(int p_index, const Vector2& p_out) { - - ERR_FAIL_INDEX(p_index,points.size()); - - points[p_index].out=p_out; - emit_signal(CoreStringNames::get_singleton()->changed); -} - -Vector2 Curve2D::get_point_out(int p_index) const { - - ERR_FAIL_INDEX_V(p_index,points.size(),Vector2()); - return points[p_index].out; - -} - - -void Curve2D::remove_point(int p_index) { - - ERR_FAIL_INDEX(p_index,points.size()); - points.remove(p_index); - emit_signal(CoreStringNames::get_singleton()->changed); -} - -Vector2 Curve2D::interpolate(int p_index, float p_offset) const { - - int pc = points.size(); - ERR_FAIL_COND_V(pc==0,Vector2()); - - if (p_index >= pc-1) - return points[pc-1].pos; - else if (p_index<0) - return points[0].pos; - - Vector2 p0 = points[p_index].pos; - Vector2 p1 = p0+points[p_index].out; - Vector2 p3 = points[p_index+1].pos; - Vector2 p2 = p3+points[p_index+1].in; - - return _bezier_interp(p_offset,p0,p1,p2,p3); -} - -Vector2 Curve2D::interpolatef(real_t p_findex) const { - - - if (p_findex<0) - p_findex=0; - else if (p_findex>=points.size()) - p_findex=points.size(); - - return interpolate((int)p_findex,Math::fmod(p_findex,1.0)); - -} - -PoolVector<Point2> Curve2D::bake(int p_subdivs) const { - - int pc = points.size(); - - PoolVector<Point2> ret; - if (pc<2) - return ret; - - ret.resize((pc-1)*p_subdivs+1); - - PoolVector<Point2>::Write w = ret.write(); - const Point *r = points.ptr(); - - for(int i=0;i<pc;i++) { - - int ofs = pc*p_subdivs; - - int limit=(i==pc-1)?p_subdivs+1:p_subdivs; - - for(int j=0;j<limit;j++) { - - Vector2 p0 = r[i].pos; - Vector2 p1 = p0+r[i].out; - Vector2 p3 = r[i].pos; - Vector2 p2 = p3+r[i].in; - real_t t = j/(real_t)p_subdivs; - - w[ofs+j]=_bezier_interp(t,p0,p1,p2,p3); - - } - } - - w = PoolVector<Point2>::Write(); - - return ret; -} - -void Curve2D::advance(real_t p_distance,int &r_index, real_t &r_pos) const { - - int pc = points.size(); - ERR_FAIL_COND(pc<2); - if (r_index<0 || r_index>=(pc-1)) - return; - - Vector2 pos = interpolate(r_index,r_pos); - - float sign=p_distance<0 ? -1 : 1; - p_distance=Math::abs(p_distance); - - real_t base = r_index+r_pos; - real_t top = 0.1; //a tenth is in theory representative - int iterations=32; - - - - for(int i=0;i<iterations;i++) { - - - real_t o=base+top*sign; - if (sign>0 && o >=pc) { - top=pc-base; - break; - } else if (sign<0 && o <0) { - top=-base; - break; - } - - Vector2 new_d = interpolatef(o); - - if (new_d.distance_to(pos) > p_distance) - break; - top*=2.0; - } - - - real_t bottom = 0.0; - iterations=8; - real_t final_offset; - - - for(int i=0;i<iterations;i++) { - - real_t middle = (bottom+top)*0.5; - real_t o=base+middle*sign; - Vector2 new_d = interpolatef(o); - - if (new_d.distance_to(pos) > p_distance) { - bottom=middle; - } else { - top=middle; - } - final_offset=o; - } - - r_index=(int)final_offset; - r_pos=Math::fmod(final_offset,1.0); - -} - -void Curve2D::get_approx_position_from_offset(real_t p_offset,int &r_index, real_t &r_pos,int p_subdivs) const { - - ERR_FAIL_COND(points.size()<2); - - real_t accum=0; - - - - for(int i=0;i<points.size();i++) { - - Vector2 prev_p=interpolate(i,0); - - - for(int j=1;j<=p_subdivs;j++) { - - real_t frac = j/(real_t)p_subdivs; - Vector2 p = interpolate(i,frac); - real_t d = p.distance_to(prev_p); - - accum+=d; - if (accum>p_offset) { - - - r_index=j-1; - if (d>0) { - real_t mf = (p_offset-(accum-d)) / d; - r_pos=frac-(1.0-mf); - } else { - r_pos=frac; - } - - return; - } - - prev_p=p; - } - } - - r_index=points.size()-1; - r_pos=1.0; - - -} - -void Curve2D::set_points_in(const Vector2Array& p_points) { - - points.resize(p_points.size()); - for (int i=0; i<p_points.size(); i++) { - - Point p = points[i]; - p.in = p_points[i]; - points[i] = p; - }; -}; - -void Curve2D::set_points_out(const Vector2Array& p_points) { - - points.resize(p_points.size()); - for (int i=0; i<p_points.size(); i++) { - - Point p = points[i]; - p.out = p_points[i]; - points[i] = p; - }; -}; - -void Curve2D::set_points_pos(const Vector2Array& p_points) { - - points.resize(p_points.size()); - for (int i=0; i<p_points.size(); i++) { - - Point p = points[i]; - p.pos = p_points[i]; - points[i] = p; - }; -}; - -Vector2Array Curve2D::get_points_in() const { - Vector2Array ret; - ret.resize(points.size()); - for (int i=0; i<points.size(); i++) { - ret.set(i, points[i].in); - }; - return ret; -}; - -Vector2Array Curve2D::get_points_out() const { - Vector2Array ret; - ret.resize(points.size()); - for (int i=0; i<points.size(); i++) { - ret.set(i, points[i].out); - }; - return ret; -}; - -Vector2Array Curve2D::get_points_pos() const { - Vector2Array ret; - ret.resize(points.size()); - for (int i=0; i<points.size(); i++) { - ret.set(i, points[i].pos); - }; - return ret; -}; - - -void Curve2D::_bind_methods() { - - ClassDB::bind_method(D_METHOD("get_point_count"),&Curve2D::get_point_count); - ClassDB::bind_method(D_METHOD("add_point","pos","in","out"),&Curve2D::add_point,DEFVAL(Vector2()),DEFVAL(Vector2())); - ClassDB::bind_method(D_METHOD("set_point_pos","idx","pos"),&Curve2D::set_point_pos); - ClassDB::bind_method(D_METHOD("get_point_pos","idx"),&Curve2D::get_point_pos); - ClassDB::bind_method(D_METHOD("set_point_in","idx","pos"),&Curve2D::set_point_in); - ClassDB::bind_method(D_METHOD("get_point_in","idx"),&Curve2D::get_point_in); - ClassDB::bind_method(D_METHOD("set_point_out","idx","pos"),&Curve2D::set_point_out); - ClassDB::bind_method(D_METHOD("get_point_out","idx"),&Curve2D::get_point_out); - ClassDB::bind_method(D_METHOD("remove_point","idx"),&Curve2D::remove_point); - ClassDB::bind_method(D_METHOD("interpolate","idx","t"),&Curve2D::interpolate); - ClassDB::bind_method(D_METHOD("bake","subdivs"),&Curve2D::bake,DEFVAL(10)); - - - ClassDB::bind_method(D_METHOD("set_points_in"),&Curve2D::set_points_in); - ClassDB::bind_method(D_METHOD("set_points_out"),&Curve2D::set_points_out); - ClassDB::bind_method(D_METHOD("set_points_pos"),&Curve2D::set_points_pos); - - ClassDB::bind_method(D_METHOD("get_points_in"),&Curve2D::get_points_in); - ClassDB::bind_method(D_METHOD("get_points_out"),&Curve2D::get_points_out); - ClassDB::bind_method(D_METHOD("get_points_pos"),&Curve2D::get_points_pos); - - ADD_PROPERTY( PropertyInfo( Variant::VECTOR2_ARRAY, "points_in"), "set_points_in","get_points_in"); - ADD_PROPERTY( PropertyInfo( Variant::VECTOR2_ARRAY, "points_out"), "set_points_out","get_points_out"); - ADD_PROPERTY( PropertyInfo( Variant::VECTOR2_ARRAY, "points_pos"), "set_points_pos","get_points_pos"); -} - - -Curve2D::Curve2D() -{ -} - -#endif - const char *Curve::SIGNAL_RANGE_CHANGED = "range_changed"; Curve::Curve() { diff --git a/scene/resources/curve.h b/scene/resources/curve.h index 0cdcc72d61..3071aee5de 100644 --- a/scene/resources/curve.h +++ b/scene/resources/curve.h @@ -31,56 +31,6 @@ #define CURVE_H #include "resource.h" -#if 0 -class Curve2D : public Resource { - - GDCLASS(Curve2D,Resource); - - struct Point { - - Vector2 in; - Vector2 out; - Vector2 pos; - }; - - - Vector<Point> points; - -protected: - - static void _bind_methods(); - - void set_points_in(const Vector2Array& p_points_in); - void set_points_out(const Vector2Array& p_points_out); - void set_points_pos(const Vector2Array& p_points_pos); - - Vector2Array get_points_in() const; - Vector2Array get_points_out() const; - Vector2Array get_points_pos() const; - -public: - - - int get_point_count() const; - void add_point(const Vector2& p_pos, const Vector2& p_in=Vector2(), const Vector2& p_out=Vector2()); - void set_point_pos(int p_index, const Vector2& p_pos); - Vector2 get_point_pos(int p_index) const; - void set_point_in(int p_index, const Vector2& p_in); - Vector2 get_point_in(int p_index) const; - void set_point_out(int p_index, const Vector2& p_out); - Vector2 get_point_out(int p_index) const; - void remove_point(int p_index); - - Vector2 interpolate(int p_index, float p_offset) const; - Vector2 interpolatef(real_t p_findex) const; - PoolVector<Point2> bake(int p_subdivs=10) const; - void advance(real_t p_distance,int &r_index, real_t &r_pos) const; - void get_approx_position_from_offset(real_t p_offset,int &r_index, real_t &r_pos,int p_subdivs=16) const; - - Curve2D(); -}; - -#endif // y(x) curve class Curve : public Resource { diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp index d25ba11cf0..19fab5d587 100644 --- a/scene/resources/packed_scene.cpp +++ b/scene/resources/packed_scene.cpp @@ -28,6 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "packed_scene.h" + #include "core/core_string_names.h" #include "io/resource_loader.h" #include "project_settings.h" @@ -35,6 +36,7 @@ #include "scene/3d/spatial.h" #include "scene/gui/control.h" #include "scene/main/instance_placeholder.h" + #define PACK_VERSION 2 bool SceneState::can_instance() const { @@ -451,60 +453,6 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Map } } -#if 0 - - Ref<SceneState> base_scene = p_node->get_scene_inherited_state(); //for inheritance - Ref<SceneState> instance_state; - int instance_state_node=-1; - - if (base_scene.is_valid() && (p_node==p_owner || p_node->get_owner()==p_owner)) { - //scene inheritance in use, see if this node is actually inherited - NodePath path = p_owner->get_path_to(p_node); - instance_state_node = base_scene->find_node_by_path(path); - if (instance_state_node>=0) { - instance_state=base_scene; - } - } - - // check that this is a directly instanced scene from the scene being packed, if so - // this information must be saved. Of course, if using scene instancing and this node - // does belong to base scene, ignore. - - if (instance_state.is_null() && p_node!=p_owner && p_node->get_owner()==p_owner && p_node->get_filename()!="") { - - //instanced, only direct sub-scnes are supported of course - Ref<PackedScene> instance = ResourceLoader::load(p_node->get_filename()); - if (!instance.is_valid()) { - return ERR_CANT_OPEN; - } - - nd.instance=_vm_get_variant(instance,variant_map); - - } else { - - nd.instance=-1; - } - - // finally, if this does not belong to scene inheritance, check - // if it belongs to scene instancing - - if (instance_state.is_null() && p_node!=p_owner) { - //if not affected by scene inheritance, this may be - if (p_node->get_owner()==p_owner && p_node->get_filename()!=String()) { - instance_state=p_node->get_scene_instance_state(); - if (instance_state.is_valid()) { - instance_state_node=instance_state->find_node_by_path(p_node->get_path_to(p_node)); - } - - } else if (p_node->get_owner()!=p_owner && p_owner->is_editable_instance(p_node->get_owner())) { - instance_state=p_node->get_owner()->get_scene_instance_state(); - if (instance_state.is_valid()) { - instance_state_node=instance_state->find_node_by_path(p_node->get_owner()->get_path_to(p_node)); - } - } - } -#endif - // all setup, we then proceed to check all properties for the node // and save the ones that are worth saving @@ -641,27 +589,6 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Map } else { nd.owner = -1; -#if 0 - // this is pointless, if this was instanced by something else, - // the owner will already be set. - - if (node_map.has(p_node->get_owner())) { - //maybe an existing saved node - nd.owner=node_map[p_node->get_owner()]; - } else { - //not saved, use nodepath map - int sidx; - if (nodepath_map.has(p_node->get_owner())) { - sidx=nodepath_map[p_node->get_owner()]; - } else { - sidx=nodepath_map.size(); - nodepath_map[p_node->get_owner()]=sidx; - } - - nd.owner=FLAG_ID_IS_PATH|sidx; - - } -#endif } // Save the right type. If this node was created by an instance diff --git a/scene/resources/room.cpp b/scene/resources/room.cpp index 2f75118bdf..487975dd4e 100644 --- a/scene/resources/room.cpp +++ b/scene/resources/room.cpp @@ -30,6 +30,8 @@ #include "room.h" #include "servers/visual_server.h" + +// FIXME: Left for reference for reimplementation using Area #if 0 RID RoomBounds::get_rid() const { diff --git a/scene/resources/shader_graph.cpp b/scene/resources/shader_graph.cpp index 1b00f71f4f..2ca9a14562 100644 --- a/scene/resources/shader_graph.cpp +++ b/scene/resources/shader_graph.cpp @@ -28,8 +28,10 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "shader_graph.h" + #include "scene/scene_string_names.h" +// FIXME: Needs to be ported to the new 3.0 shader API #if 0 Array ShaderGraph::_get_node_list(ShaderType p_type) const { @@ -397,79 +399,6 @@ void ShaderGraph::_bind_methods() { BIND_ENUM_CONSTANT( VEC_MAX_FUNC ); ADD_SIGNAL(MethodInfo("updated")); - -#if 0 - ClassDB::bind_method(D_METHOD("node_add"),&ShaderGraph::node_add ); - ClassDB::bind_method(D_METHOD("node_remove"),&ShaderGraph::node_remove ); - ClassDB::bind_method(D_METHOD("node_set_param"),&ShaderGraph::node_set_param ); - ClassDB::bind_method(D_METHOD("node_set_pos"),&ShaderGraph::node_set_pos ); - - ClassDB::bind_method(D_METHOD("node_get_pos"),&ShaderGraph::node_get_pos ); - ClassDB::bind_method(D_METHOD("node_get_param"),&ShaderGraph::node_get_param); - ClassDB::bind_method(D_METHOD("node_get_type"),&ShaderGraph::node_get_type); - - ClassDB::bind_method(D_METHOD("connect"),&ShaderGraph::connect ); - ClassDB::bind_method(D_METHOD("disconnect"),&ShaderGraph::disconnect ); - - ClassDB::bind_method(D_METHOD("get_connections"),&ShaderGraph::_get_connections_helper ); - - ClassDB::bind_method(D_METHOD("clear"),&ShaderGraph::clear ); - - BIND_ENUM_CONSTANT( NODE_IN ); ///< param 0: name - BIND_ENUM_CONSTANT( NODE_OUT ); ///< param 0: name - BIND_ENUM_CONSTANT( NODE_CONSTANT ); ///< param 0: value - BIND_ENUM_CONSTANT( NODE_PARAMETER ); ///< param 0: name - BIND_ENUM_CONSTANT( NODE_ADD ); - BIND_ENUM_CONSTANT( NODE_SUB ); - BIND_ENUM_CONSTANT( NODE_MUL ); - BIND_ENUM_CONSTANT( NODE_DIV ); - BIND_ENUM_CONSTANT( NODE_MOD ); - BIND_ENUM_CONSTANT( NODE_SIN ); - BIND_ENUM_CONSTANT( NODE_COS ); - BIND_ENUM_CONSTANT( NODE_TAN ); - BIND_ENUM_CONSTANT( NODE_ARCSIN ); - BIND_ENUM_CONSTANT( NODE_ARCCOS ); - BIND_ENUM_CONSTANT( NODE_ARCTAN ); - BIND_ENUM_CONSTANT( NODE_POW ); - BIND_ENUM_CONSTANT( NODE_LOG ); - BIND_ENUM_CONSTANT( NODE_MAX ); - BIND_ENUM_CONSTANT( NODE_MIN ); - BIND_ENUM_CONSTANT( NODE_COMPARE ); - BIND_ENUM_CONSTANT( NODE_TEXTURE ); ///< param 0: texture - BIND_ENUM_CONSTANT( NODE_TIME ); ///< param 0: interval length - BIND_ENUM_CONSTANT( NODE_NOISE ); - BIND_ENUM_CONSTANT( NODE_PASS ); - BIND_ENUM_CONSTANT( NODE_VEC_IN ); ///< param 0: name - BIND_ENUM_CONSTANT( NODE_VEC_OUT ); ///< param 0: name - BIND_ENUM_CONSTANT( NODE_VEC_CONSTANT ); ///< param 0: value - BIND_ENUM_CONSTANT( NODE_VEC_PARAMETER ); ///< param 0: name - BIND_ENUM_CONSTANT( NODE_VEC_ADD ); - BIND_ENUM_CONSTANT( NODE_VEC_SUB ); - BIND_ENUM_CONSTANT( NODE_VEC_MUL ); - BIND_ENUM_CONSTANT( NODE_VEC_DIV ); - BIND_ENUM_CONSTANT( NODE_VEC_MOD ); - BIND_ENUM_CONSTANT( NODE_VEC_CROSS ); - BIND_ENUM_CONSTANT( NODE_VEC_DOT ); - BIND_ENUM_CONSTANT( NODE_VEC_POW ); - BIND_ENUM_CONSTANT( NODE_VEC_NORMALIZE ); - BIND_ENUM_CONSTANT( NODE_VEC_TRANSFORM3 ); - BIND_ENUM_CONSTANT( NODE_VEC_TRANSFORM4 ); - BIND_ENUM_CONSTANT( NODE_VEC_COMPARE ); - BIND_ENUM_CONSTANT( NODE_VEC_TEXTURE_2D ); - BIND_ENUM_CONSTANT( NODE_VEC_TEXTURE_CUBE ); - BIND_ENUM_CONSTANT( NODE_VEC_NOISE ); - BIND_ENUM_CONSTANT( NODE_VEC_0 ); - BIND_ENUM_CONSTANT( NODE_VEC_1 ); - BIND_ENUM_CONSTANT( NODE_VEC_2 ); - BIND_ENUM_CONSTANT( NODE_VEC_BUILD ); - BIND_ENUM_CONSTANT( NODE_VEC_PASS ); - BIND_ENUM_CONSTANT( NODE_COLOR_CONSTANT ); - BIND_ENUM_CONSTANT( NODE_COLOR_PARAMETER ); - BIND_ENUM_CONSTANT( NODE_TEXTURE_PARAMETER ); - BIND_ENUM_CONSTANT( NODE_TEXTURE_2D_PARAMETER ); - BIND_ENUM_CONSTANT( NODE_TEXTURE_CUBE_PARAMETER ); - BIND_ENUM_CONSTANT( NODE_TYPE_MAX ); -#endif } diff --git a/scene/resources/shader_graph.h b/scene/resources/shader_graph.h index bb82ff167f..9a74b6c53a 100644 --- a/scene/resources/shader_graph.h +++ b/scene/resources/shader_graph.h @@ -30,6 +30,7 @@ #ifndef SHADER_GRAPH_H #define SHADER_GRAPH_H +// FIXME: Needs to be ported to the new 3.0 shader API #if 0 #include "map.h" #include "scene/resources/shader.h" diff --git a/scene/resources/video_stream.h b/scene/resources/video_stream.h index f032685800..e08be02a07 100644 --- a/scene/resources/video_stream.h +++ b/scene/resources/video_stream.h @@ -30,7 +30,6 @@ #ifndef VIDEO_STREAM_H #define VIDEO_STREAM_H -#include "audio_stream_resampled.h" #include "scene/resources/texture.h" class VideoStreamPlayback : public Resource { diff --git a/scene/resources/world.cpp b/scene/resources/world.cpp index 06026d1198..af159975ca 100644 --- a/scene/resources/world.cpp +++ b/scene/resources/world.cpp @@ -28,10 +28,10 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "world.h" + #include "camera_matrix.h" #include "octree.h" #include "scene/3d/camera.h" -#include "scene/3d/spatial_indexer.h" #include "scene/3d/visibility_notifier.h" #include "scene/scene_string_names.h" |