summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorAnton Yabchinskiy <arn@bestmx.ru>2014-12-09 17:51:14 +0300
committerAnton Yabchinskiy <arn@bestmx.ru>2014-12-09 17:51:14 +0300
commitff755f93eb86e3f7f6801918457ca77a3001671b (patch)
tree58d6def002b427db665a504f08d25eae335bd9d9 /scene
parentd45be7d9f43046365fcfbf97420f9eca636c51e7 (diff)
parentbe4e40e90a5a322f6a7cec4893854ef5b15db600 (diff)
Merge branch 'master' of http://github.com/okamstudio/godot
Diffstat (limited to 'scene')
-rw-r--r--scene/2d/animated_sprite.cpp7
-rw-r--r--scene/2d/area_2d.cpp15
-rw-r--r--scene/2d/area_2d.h1
-rw-r--r--scene/2d/polygon_2d.cpp1
-rw-r--r--scene/2d/sprite.cpp6
-rw-r--r--scene/3d/area.cpp18
-rw-r--r--scene/3d/area.h1
-rw-r--r--scene/3d/camera.cpp2
-rw-r--r--scene/3d/light.cpp4
-rw-r--r--scene/3d/sprite_3d.cpp10
-rw-r--r--scene/3d/visual_instance.cpp8
-rw-r--r--scene/gui/text_edit.cpp19
-rw-r--r--scene/gui/tree.cpp7
-rw-r--r--scene/main/node.cpp6
-rw-r--r--scene/main/node.h1
-rw-r--r--scene/main/scene_main_loop.cpp3
-rw-r--r--scene/main/timer.cpp3
-rw-r--r--scene/scene_string_names.cpp2
-rw-r--r--scene/scene_string_names.h1
19 files changed, 98 insertions, 17 deletions
diff --git a/scene/2d/animated_sprite.cpp b/scene/2d/animated_sprite.cpp
index 316dffb3f9..2fcfc18429 100644
--- a/scene/2d/animated_sprite.cpp
+++ b/scene/2d/animated_sprite.cpp
@@ -27,7 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "animated_sprite.h"
-
+#include "scene/scene_string_names.h"
void AnimatedSprite::edit_set_pivot(const Point2& p_pivot) {
set_offset(p_pivot);
@@ -207,7 +207,7 @@ void AnimatedSprite::set_frame(int p_frame) {
frame=p_frame;
update();
_change_notify("frame");
-
+ emit_signal(SceneStringNames::get_singleton()->frame_changed);
}
int AnimatedSprite::get_frame() const {
@@ -233,6 +233,7 @@ void AnimatedSprite::set_offset(const Point2& p_offset) {
offset=p_offset;
update();
item_rect_changed();
+ _change_notify("offset");
}
Point2 AnimatedSprite::get_offset() const {
@@ -325,6 +326,8 @@ void AnimatedSprite::_bind_methods() {
ObjectTypeDB::bind_method(_MD("_res_changed"),&AnimatedSprite::_res_changed);
+ ADD_SIGNAL(MethodInfo("frame_changed"));
+
ADD_PROPERTYNZ( PropertyInfo( Variant::OBJECT, "frames",PROPERTY_HINT_RESOURCE_TYPE,"SpriteFrames"), _SCS("set_sprite_frames"),_SCS("get_sprite_frames"));
ADD_PROPERTYNZ( PropertyInfo( Variant::INT, "frame"), _SCS("set_frame"),_SCS("get_frame"));
ADD_PROPERTY( PropertyInfo( Variant::BOOL, "centered"), _SCS("set_centered"),_SCS("is_centered"));
diff --git a/scene/2d/area_2d.cpp b/scene/2d/area_2d.cpp
index 3114106235..ca2a42026d 100644
--- a/scene/2d/area_2d.cpp
+++ b/scene/2d/area_2d.cpp
@@ -142,6 +142,8 @@ void Area2D::_body_inout(int p_status,const RID& p_body, int p_instance, int p_b
ERR_FAIL_COND(!body_in && !E);
+ locked=true;
+
if (body_in) {
if (!E) {
@@ -197,11 +199,18 @@ void Area2D::_body_inout(int p_status,const RID& p_body, int p_instance, int p_b
}
+ locked=false;
+
+
}
void Area2D::_clear_monitoring() {
+ if (locked) {
+ ERR_EXPLAIN("This function can't be used during the in/out signal.");
+ }
+ ERR_FAIL_COND(locked);
Map<ObjectID,BodyState> bmcopy = body_map;
body_map.clear();
@@ -243,6 +252,11 @@ void Area2D::_notification(int p_what) {
void Area2D::set_enable_monitoring(bool p_enable) {
+ if (locked) {
+ ERR_EXPLAIN("This function can't be used during the in/out signal.");
+ }
+ ERR_FAIL_COND(locked);
+
if (p_enable==monitoring)
return;
@@ -336,6 +350,7 @@ Area2D::Area2D() : CollisionObject2D(Physics2DServer::get_singleton()->area_crea
set_gravity_vector(Vector2(0,1));
gravity_is_point=false;
density=0.1;
+ locked=false;
priority=0;
monitoring=false;
set_enable_monitoring(true);
diff --git a/scene/2d/area_2d.h b/scene/2d/area_2d.h
index c6210e7c9a..2044cc7db0 100644
--- a/scene/2d/area_2d.h
+++ b/scene/2d/area_2d.h
@@ -52,6 +52,7 @@ private:
real_t density;
int priority;
bool monitoring;
+ bool locked;
void _body_inout(int p_status,const RID& p_body, int p_instance, int p_body_shape,int p_area_shape);
diff --git a/scene/2d/polygon_2d.cpp b/scene/2d/polygon_2d.cpp
index 2b4be734af..217a98aaea 100644
--- a/scene/2d/polygon_2d.cpp
+++ b/scene/2d/polygon_2d.cpp
@@ -359,5 +359,6 @@ Polygon2D::Polygon2D() {
tex_rot=0;
tex_tile=true;
tex_scale=Vector2(1,1);
+ color=Color(1,1,1);
rect_cache_dirty=true;
}
diff --git a/scene/2d/sprite.cpp b/scene/2d/sprite.cpp
index 9f789a7a1f..82f5a6972a 100644
--- a/scene/2d/sprite.cpp
+++ b/scene/2d/sprite.cpp
@@ -34,6 +34,7 @@
void Sprite::edit_set_pivot(const Point2& p_pivot) {
set_offset(p_pivot);
+
}
Point2 Sprite::edit_get_pivot() const {
@@ -136,6 +137,7 @@ void Sprite::set_offset(const Point2& p_offset) {
offset=p_offset;
update();
item_rect_changed();
+ _change_notify("offset");
}
Point2 Sprite::get_offset() const {
@@ -199,6 +201,8 @@ void Sprite::set_frame(int p_frame) {
item_rect_changed();
frame=p_frame;
+
+ emit_signal(SceneStringNames::get_singleton()->frame_changed);
}
int Sprite::get_frame() const {
@@ -307,6 +311,8 @@ void Sprite::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_modulate","modulate"),&Sprite::set_modulate);
ObjectTypeDB::bind_method(_MD("get_modulate"),&Sprite::get_modulate);
+ ADD_SIGNAL(MethodInfo("frame_changed"));
+
ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_texture"),_SCS("get_texture"));
ADD_PROPERTY( PropertyInfo( Variant::BOOL, "centered"), _SCS("set_centered"),_SCS("is_centered"));
ADD_PROPERTY( PropertyInfo( Variant::VECTOR2, "offset"), _SCS("set_offset"),_SCS("get_offset"));
diff --git a/scene/3d/area.cpp b/scene/3d/area.cpp
index cb1df78fda..9cdd24d102 100644
--- a/scene/3d/area.cpp
+++ b/scene/3d/area.cpp
@@ -115,6 +115,7 @@ void Area::_body_enter_tree(ObjectID p_id) {
void Area::_body_exit_tree(ObjectID p_id) {
+
Object *obj = ObjectDB::get_instance(p_id);
Node *node = obj ? obj->cast_to<Node>() : NULL;
ERR_FAIL_COND(!node);
@@ -132,6 +133,7 @@ void Area::_body_exit_tree(ObjectID p_id) {
void Area::_body_inout(int p_status,const RID& p_body, int p_instance, int p_body_shape,int p_area_shape) {
+
bool body_in = p_status==PhysicsServer::AREA_BODY_ADDED;
ObjectID objid=p_instance;
@@ -142,6 +144,8 @@ void Area::_body_inout(int p_status,const RID& p_body, int p_instance, int p_bod
ERR_FAIL_COND(!body_in && !E);
+ locked=true;
+
if (body_in) {
if (!E) {
@@ -197,11 +201,19 @@ void Area::_body_inout(int p_status,const RID& p_body, int p_instance, int p_bod
}
+ locked=false;
+
+
}
void Area::_clear_monitoring() {
+ if (locked) {
+ ERR_EXPLAIN("This function can't be used during the in/out signal.");
+ }
+ ERR_FAIL_COND(locked);
+
Map<ObjectID,BodyState> bmcopy = body_map;
body_map.clear();
//disconnect all monitored stuff
@@ -235,6 +247,11 @@ void Area::_notification(int p_what) {
void Area::set_enable_monitoring(bool p_enable) {
+ if (locked) {
+ ERR_EXPLAIN("This function can't be used during the in/out signal.");
+ }
+ ERR_FAIL_COND(locked);
+
if (p_enable==monitoring)
return;
@@ -325,6 +342,7 @@ Area::Area() : CollisionObject(PhysicsServer::get_singleton()->area_create(),tru
space_override=SPACE_OVERRIDE_DISABLED;
set_gravity(9.8);;
+ locked=false;
set_gravity_vector(Vector3(0,-1,0));
gravity_is_point=false;
density=0.1;
diff --git a/scene/3d/area.h b/scene/3d/area.h
index 4707b73e1c..40c6d24b5c 100644
--- a/scene/3d/area.h
+++ b/scene/3d/area.h
@@ -52,6 +52,7 @@ private:
real_t density;
int priority;
bool monitoring;
+ bool locked;
void _body_inout(int p_status,const RID& p_body, int p_instance, int p_body_shape,int p_area_shape);
diff --git a/scene/3d/camera.cpp b/scene/3d/camera.cpp
index 933f270475..1db9886261 100644
--- a/scene/3d/camera.cpp
+++ b/scene/3d/camera.cpp
@@ -529,6 +529,8 @@ Vector3 Camera::project_ray_origin(const Point2& p_pos) const {
}
+
+
Vector3 ray;
ray.x = pos.x * (hsize) - hsize/2;
ray.y = (1.0 - pos.y) * (vsize) - vsize/2;
diff --git a/scene/3d/light.cpp b/scene/3d/light.cpp
index 9d959cb0d6..15e77e5378 100644
--- a/scene/3d/light.cpp
+++ b/scene/3d/light.cpp
@@ -415,11 +415,11 @@ void Light::approximate_opengl_attenuation(float p_constant, float p_linear, flo
float energy=1.0;
- if (p_constant>0)
+ /*if (p_constant>0)
energy=1.0/p_constant; //energy is this
else
energy=8.0; // some high number..
-
+*/
if (radius==10000)
radius=100; //bug?
diff --git a/scene/3d/sprite_3d.cpp b/scene/3d/sprite_3d.cpp
index a6a8919d13..77f2cf5cc1 100644
--- a/scene/3d/sprite_3d.cpp
+++ b/scene/3d/sprite_3d.cpp
@@ -275,6 +275,9 @@ void SpriteBase3D::_bind_methods() {
BIND_CONSTANT( ALPHA_CUT_DISABLED );
BIND_CONSTANT( ALPHA_CUT_DISCARD );
BIND_CONSTANT( ALPHA_CUT_OPAQUE_PREPASS );
+
+
+
}
@@ -494,6 +497,8 @@ void Sprite3D::set_frame(int p_frame) {
frame=p_frame;
_queue_update();
+ ADD_SIGNAL(MethodInfo("frame_changed"));
+
}
int Sprite3D::get_frame() const {
@@ -579,6 +584,8 @@ void Sprite3D::_bind_methods() {
ADD_PROPERTY( PropertyInfo( Variant::BOOL, "region"), _SCS("set_region"),_SCS("is_region"));
ADD_PROPERTY( PropertyInfo( Variant::RECT2, "region_rect"), _SCS("set_region_rect"),_SCS("get_region_rect"));
+ ADD_SIGNAL(MethodInfo("frame_changed"));
+
}
Sprite3D::Sprite3D() {
@@ -722,6 +729,8 @@ void AnimatedSprite3D::_bind_methods(){
ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "frames", PROPERTY_HINT_RESOURCE_TYPE,"SpriteFrames"), _SCS("set_sprite_frames"),_SCS("get_sprite_frames"));
ADD_PROPERTY( PropertyInfo( Variant::INT, "frame"), _SCS("set_frame"),_SCS("get_frame"));
+ ADD_SIGNAL(MethodInfo("frame_changed"));
+
}
@@ -764,6 +773,7 @@ void AnimatedSprite3D::set_frame(int p_frame){
frame=p_frame;
_queue_update();
+ emit_signal(SceneStringNames::get_singleton()->frame_changed);
}
int AnimatedSprite3D::get_frame() const{
diff --git a/scene/3d/visual_instance.cpp b/scene/3d/visual_instance.cpp
index 5b40a4d7e5..a82c69e67f 100644
--- a/scene/3d/visual_instance.cpp
+++ b/scene/3d/visual_instance.cpp
@@ -359,13 +359,13 @@ void GeometryInstance::_bind_methods() {
GeometryInstance::GeometryInstance() {
draw_begin=0;
draw_end=0;
+ for(int i=0;i<FLAG_MAX;i++) {
+ flags[i]=false;
+ }
+
flags[FLAG_VISIBLE]=true;
flags[FLAG_CAST_SHADOW]=true;
flags[FLAG_RECEIVE_SHADOWS]=true;
- flags[FLAG_BILLBOARD]=false;
- flags[FLAG_BILLBOARD_FIX_Y]=false;
- flags[FLAG_DEPH_SCALE]=false;
- flags[FLAG_VISIBLE_IN_ALL_ROOMS]=false;
baked_light_instance=NULL;
baked_light_texture_id=0;
VS::get_singleton()->instance_geometry_set_baked_light_texture_index(get_instance(),0);
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index b95d271394..ba68948e6b 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -1747,16 +1747,16 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
}
break;}
- default: {
+ default: {
- scancode_handled=false;
- } break;
+ scancode_handled=false;
+ } break;
}
if (scancode_handled)
accept_event();
-
+/*
if (!scancode_handled && !k.mod.command && !k.mod.alt) {
if (k.unicode>=32) {
@@ -1770,8 +1770,8 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
break;
}
}
-
- if (!scancode_handled && !k.mod.command && !k.mod.alt) {
+*/
+ if (!scancode_handled && !k.mod.command && !k.mod.alt) { //for german kbds
if (k.unicode>=32) {
@@ -3150,12 +3150,15 @@ void TextEdit::set_line(int line, String new_text)
{
if (line < 0 || line > text.size())
return;
- text.set(line, new_text);
+ _remove_text(line, 0, line, text[line].length());
+ _insert_text(line, 0, new_text);
}
void TextEdit::insert_at(const String &p_text, int at)
{
- text.insert(at, p_text);
+ cursor_set_column(0);
+ cursor_set_line(at);
+ _insert_text(at, 0, p_text+"\n");
}
void TextEdit::set_show_line_numbers(bool p_show) {
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index db9142cb99..b7b52a39dc 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -1693,6 +1693,13 @@ void Tree::text_editor_enter(String p_text) {
case TreeItem::CELL_MODE_RANGE: {
c.val=p_text.to_double();
+ if (c.step>0)
+ c.val=Math::stepify(c.val,c.step);
+ if (c.val<c.min)
+ c.val=c.min;
+ else if (c.val>c.max)
+ c.val=c.max;
+
//popup_edited_item->edited_signal.call( popup_edited_item_col );
} break;
default: { ERR_FAIL(); }
diff --git a/scene/main/node.cpp b/scene/main/node.cpp
index 292e4d1a7b..45a30d7bca 100644
--- a/scene/main/node.cpp
+++ b/scene/main/node.cpp
@@ -271,6 +271,7 @@ void Node::move_child(Node *p_child,int p_pos) {
data.children[i]->data.pos=i;
}
// notification second
+ move_child_notify(p_child);
for (int i=0;i<data.children.size();i++) {
data.children[i]->notification( NOTIFICATION_MOVED_IN_PARENT );
@@ -310,6 +311,11 @@ void Node::remove_child_notify(Node *p_child) {
// to be used when not wanted
}
+void Node::move_child_notify(Node *p_child) {
+
+ // to be used when not wanted
+}
+
void Node::set_fixed_process(bool p_process) {
if (data.fixed_process==p_process)
diff --git a/scene/main/node.h b/scene/main/node.h
index 9229e2f9bb..371a5325ca 100644
--- a/scene/main/node.h
+++ b/scene/main/node.h
@@ -142,6 +142,7 @@ 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);
diff --git a/scene/main/scene_main_loop.cpp b/scene/main/scene_main_loop.cpp
index 47089638bb..ed3e419359 100644
--- a/scene/main/scene_main_loop.cpp
+++ b/scene/main/scene_main_loop.cpp
@@ -333,6 +333,9 @@ void SceneTree::input_text( const String& p_text ) {
void SceneTree::input_event( const InputEvent& p_event ) {
+ if (is_editor_hint() && (p_event.type==InputEvent::JOYSTICK_MOTION || p_event.type==InputEvent::JOYSTICK_BUTTON))
+ return; //avoid joy input on editor
+
root_lock++;
//last_id=p_event.ID;
diff --git a/scene/main/timer.cpp b/scene/main/timer.cpp
index 2ae918f3f3..f718a09577 100644
--- a/scene/main/timer.cpp
+++ b/scene/main/timer.cpp
@@ -40,7 +40,8 @@ void Timer::_notification(int p_what) {
#ifdef TOOLS_ENABLED
if (get_tree()->is_editor_hint() && get_tree()->get_edited_scene_root() && (get_tree()->get_edited_scene_root()==this || get_tree()->get_edited_scene_root()->is_a_parent_of(this)))
break;
-#endif start();
+#endif
+ start();
}
} break;
case NOTIFICATION_PROCESS: {
diff --git a/scene/scene_string_names.cpp b/scene/scene_string_names.cpp
index 8ad7e06c0f..0d66257eda 100644
--- a/scene/scene_string_names.cpp
+++ b/scene/scene_string_names.cpp
@@ -150,4 +150,6 @@ SceneStringNames::SceneStringNames() {
_pressed=StaticCString::create("_pressed");
_toggled=StaticCString::create("_toggled");
+ frame_changed=StaticCString::create("frame_changed");
+
}
diff --git a/scene/scene_string_names.h b/scene/scene_string_names.h
index 512674f648..b0628c86b6 100644
--- a/scene/scene_string_names.h
+++ b/scene/scene_string_names.h
@@ -158,6 +158,7 @@ public:
StringName _mouse_enter;
StringName _mouse_exit;
+ StringName frame_changed;
};