summaryrefslogtreecommitdiff
path: root/scene/2d
diff options
context:
space:
mode:
authorMarianoGNU <marianognu.easyrpg@gmail.com>2015-10-17 23:38:33 -0300
committerMarianoGNU <marianognu.easyrpg@gmail.com>2015-10-17 23:38:33 -0300
commit4452e262539ad9d52a5980305584d897829986d1 (patch)
treecde7f3bdc36e727a21f55938a131083f84e043a6 /scene/2d
parent68fb30aaea0acf3ff279831d2d77b2e7129e4b69 (diff)
parent97f483af0a3e040f73c2df957bd092af2f6c085b (diff)
Merge branch 'master' of https://github.com/okamstudio/godot
Diffstat (limited to 'scene/2d')
-rw-r--r--scene/2d/joints_2d.cpp28
-rw-r--r--scene/2d/joints_2d.h6
-rw-r--r--scene/2d/parallax_background.cpp20
-rw-r--r--scene/2d/parallax_background.h4
-rw-r--r--scene/2d/ray_cast_2d.cpp17
-rw-r--r--scene/2d/ray_cast_2d.h4
6 files changed, 73 insertions, 6 deletions
diff --git a/scene/2d/joints_2d.cpp b/scene/2d/joints_2d.cpp
index c1e91c2ecd..1df936535f 100644
--- a/scene/2d/joints_2d.cpp
+++ b/scene/2d/joints_2d.cpp
@@ -126,7 +126,7 @@ void Joint2D::_bind_methods() {
ADD_PROPERTY( PropertyInfo( Variant::NODE_PATH, "node_a"), _SCS("set_node_a"),_SCS("get_node_a") );
ADD_PROPERTY( PropertyInfo( Variant::NODE_PATH, "node_b"), _SCS("set_node_b"),_SCS("get_node_b") );
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "bias/bias",PROPERTY_HINT_RANGE,"0,0.9,0.01"), _SCS("set_bias"),_SCS("get_bias") );
+ ADD_PROPERTY( PropertyInfo( Variant::REAL, "bias/bias",PROPERTY_HINT_RANGE,"0,0.9,0.001"), _SCS("set_bias"),_SCS("get_bias") );
}
@@ -175,15 +175,37 @@ RID PinJoint2D::_configure_joint() {
//add a collision exception between both
Physics2DServer::get_singleton()->body_add_collision_exception(body_a->get_rid(),body_b->get_rid());
}
+ RID pj = Physics2DServer::get_singleton()->pin_joint_create(get_global_transform().get_origin(),body_a->get_rid(),body_b?body_b->get_rid():RID());
+ Physics2DServer::get_singleton()->pin_joint_set_param(pj, Physics2DServer::PIN_JOINT_SOFTNESS, softness);
+ return pj;
- return Physics2DServer::get_singleton()->pin_joint_create(get_global_transform().get_origin(),body_a->get_rid(),body_b?body_b->get_rid():RID());
+}
+
+void PinJoint2D::set_softness(real_t p_softness) {
+
+ softness=p_softness;
+ update();
+ if (get_joint().is_valid())
+ Physics2DServer::get_singleton()->pin_joint_set_param(get_joint(), Physics2DServer::PIN_JOINT_SOFTNESS, p_softness);
}
+real_t PinJoint2D::get_softness() const {
-PinJoint2D::PinJoint2D() {
+ return softness;
+}
+
+void PinJoint2D::_bind_methods() {
+
+ ObjectTypeDB::bind_method(_MD("set_softness","softness"), &PinJoint2D::set_softness);
+ ObjectTypeDB::bind_method(_MD("get_softness"), &PinJoint2D::get_softness);
+ ADD_PROPERTY( PropertyInfo( Variant::REAL, "softness", PROPERTY_HINT_EXP_RANGE,"0.00,16,0.01"), _SCS("set_softness"), _SCS("get_softness"));
+}
+
+PinJoint2D::PinJoint2D() {
+ softness = 0;
}
diff --git a/scene/2d/joints_2d.h b/scene/2d/joints_2d.h
index ac72c6ce59..908e3a158e 100644
--- a/scene/2d/joints_2d.h
+++ b/scene/2d/joints_2d.h
@@ -72,13 +72,17 @@ class PinJoint2D : public Joint2D {
OBJ_TYPE(PinJoint2D,Joint2D);
+ real_t softness;
+
protected:
void _notification(int p_what);
virtual RID _configure_joint();
+ static void _bind_methods();
public:
-
+ void set_softness(real_t p_stiffness);
+ real_t get_softness() const;
PinJoint2D();
};
diff --git a/scene/2d/parallax_background.cpp b/scene/2d/parallax_background.cpp
index 109546bde3..8bb4eb55ba 100644
--- a/scene/2d/parallax_background.cpp
+++ b/scene/2d/parallax_background.cpp
@@ -110,7 +110,10 @@ void ParallaxBackground::_update_scroll() {
if (!l)
continue;
- l->set_base_offset_and_scale(ofs,scale);
+ if (ignore_camera_zoom)
+ l->set_base_offset_and_scale(ofs, 1.0);
+ else
+ l->set_base_offset_and_scale(ofs, scale);
}
}
@@ -165,6 +168,18 @@ Point2 ParallaxBackground::get_limit_end() const {
return limit_end;
}
+void ParallaxBackground::set_ignore_camera_zoom(bool ignore){
+
+ ignore_camera_zoom = ignore;
+
+}
+
+bool ParallaxBackground::is_ignore_camera_zoom(){
+
+ return ignore_camera_zoom;
+
+}
+
void ParallaxBackground::_bind_methods() {
ObjectTypeDB::bind_method(_MD("_camera_moved"),&ParallaxBackground::_camera_moved);
@@ -178,6 +193,8 @@ void ParallaxBackground::_bind_methods() {
ObjectTypeDB::bind_method(_MD("get_limit_begin"),&ParallaxBackground::get_limit_begin);
ObjectTypeDB::bind_method(_MD("set_limit_end","ofs"),&ParallaxBackground::set_limit_end);
ObjectTypeDB::bind_method(_MD("get_limit_end"),&ParallaxBackground::get_limit_end);
+ ObjectTypeDB::bind_method(_MD("set_ignore_camera_zoom"), &ParallaxBackground::set_ignore_camera_zoom);
+ ObjectTypeDB::bind_method(_MD("is_ignore_camera_zoom"), &ParallaxBackground::is_ignore_camera_zoom);
ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"scroll/offset"),_SCS("set_scroll_offset"),_SCS("get_scroll_offset"));
@@ -185,6 +202,7 @@ void ParallaxBackground::_bind_methods() {
ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"scroll/base_scale"),_SCS("set_scroll_base_scale"),_SCS("get_scroll_base_scale"));
ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"scroll/limit_begin"),_SCS("set_limit_begin"),_SCS("get_limit_begin"));
ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"scroll/limit_end"),_SCS("set_limit_end"),_SCS("get_limit_end"));
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL, "scroll/ignore_camera_zoom"), _SCS("set_ignore_camera_zoom"), _SCS("is_ignore_camera_zoom"));
}
diff --git a/scene/2d/parallax_background.h b/scene/2d/parallax_background.h
index 363236b2ad..8dede07a16 100644
--- a/scene/2d/parallax_background.h
+++ b/scene/2d/parallax_background.h
@@ -44,6 +44,7 @@ class ParallaxBackground : public CanvasLayer {
String group_name;
Point2 limit_begin;
Point2 limit_end;
+ bool ignore_camera_zoom;
void _update_scroll();
protected:
@@ -72,6 +73,9 @@ public:
void set_limit_end(const Point2& p_ofs);
Point2 get_limit_end() const;
+ void set_ignore_camera_zoom(bool ignore);
+ bool is_ignore_camera_zoom();
+
ParallaxBackground();
};
diff --git a/scene/2d/ray_cast_2d.cpp b/scene/2d/ray_cast_2d.cpp
index 05594fd79c..acc4c620e6 100644
--- a/scene/2d/ray_cast_2d.cpp
+++ b/scene/2d/ray_cast_2d.cpp
@@ -53,6 +53,16 @@ uint32_t RayCast2D::get_layer_mask() const {
return layer_mask;
}
+void RayCast2D::set_type_mask(uint32_t p_mask) {
+
+ type_mask=p_mask;
+}
+
+uint32_t RayCast2D::get_type_mask() const {
+
+ return type_mask;
+}
+
bool RayCast2D::is_colliding() const{
return collided;
@@ -162,7 +172,7 @@ void RayCast2D::_notification(int p_what) {
Physics2DDirectSpaceState::RayResult rr;
- if (dss->intersect_ray(gt.get_origin(),gt.xform(to),rr,exclude,layer_mask)) {
+ if (dss->intersect_ray(gt.get_origin(),gt.xform(to),rr,exclude,layer_mask,type_mask)) {
collided=true;
against=rr.collider_id;
@@ -241,9 +251,13 @@ void RayCast2D::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_layer_mask","mask"),&RayCast2D::set_layer_mask);
ObjectTypeDB::bind_method(_MD("get_layer_mask"),&RayCast2D::get_layer_mask);
+ ObjectTypeDB::bind_method(_MD("set_type_mask","mask"),&RayCast2D::set_type_mask);
+ ObjectTypeDB::bind_method(_MD("get_type_mask"),&RayCast2D::get_type_mask);
+
ADD_PROPERTY(PropertyInfo(Variant::BOOL,"enabled"),_SCS("set_enabled"),_SCS("is_enabled"));
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2,"cast_to"),_SCS("set_cast_to"),_SCS("get_cast_to"));
ADD_PROPERTY(PropertyInfo(Variant::INT,"layer_mask",PROPERTY_HINT_ALL_FLAGS),_SCS("set_layer_mask"),_SCS("get_layer_mask"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"type_mask",PROPERTY_HINT_FLAGS,"Static,Kinematic,Rigid,Character,Area"),_SCS("set_type_mask"),_SCS("get_type_mask"));
}
RayCast2D::RayCast2D() {
@@ -253,5 +267,6 @@ RayCast2D::RayCast2D() {
collided=false;
against_shape=0;
layer_mask=1;
+ type_mask=Physics2DDirectSpaceState::TYPE_MASK_COLLISION;
cast_to=Vector2(0,50);
}
diff --git a/scene/2d/ray_cast_2d.h b/scene/2d/ray_cast_2d.h
index c7616be523..8c3ce8b3b3 100644
--- a/scene/2d/ray_cast_2d.h
+++ b/scene/2d/ray_cast_2d.h
@@ -44,6 +44,7 @@ class RayCast2D : public Node2D {
Vector2 collision_normal;
Set<RID> exclude;
uint32_t layer_mask;
+ uint32_t type_mask;
Vector2 cast_to;
@@ -62,6 +63,9 @@ public:
void set_layer_mask(uint32_t p_mask);
uint32_t get_layer_mask() const;
+ void set_type_mask(uint32_t p_mask);
+ uint32_t get_type_mask() const;
+
bool is_colliding() const;
Object *get_collider() const;
int get_collider_shape() const;