aboutsummaryrefslogtreecommitdiff
path: root/scene/2d/joints_2d.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/2d/joints_2d.cpp')
-rw-r--r--scene/2d/joints_2d.cpp265
1 files changed, 111 insertions, 154 deletions
diff --git a/scene/2d/joints_2d.cpp b/scene/2d/joints_2d.cpp
index 6754eb398..96ef714f1 100644
--- a/scene/2d/joints_2d.cpp
+++ b/scene/2d/joints_2d.cpp
@@ -27,8 +27,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "joints_2d.h"
-#include "servers/physics_2d_server.h"
#include "physics_body_2d.h"
+#include "servers/physics_2d_server.h"
void Joint2D::_update_joint() {
@@ -39,49 +39,41 @@ void Joint2D::_update_joint() {
Physics2DServer::get_singleton()->free(joint);
}
- joint=RID();
-
+ joint = RID();
joint = _configure_joint();
- Physics2DServer::get_singleton()->get_singleton()->joint_set_param(joint,Physics2DServer::JOINT_PARAM_BIAS,bias);
-
-
+ Physics2DServer::get_singleton()->get_singleton()->joint_set_param(joint, Physics2DServer::JOINT_PARAM_BIAS, bias);
}
+void Joint2D::set_node_a(const NodePath &p_node_a) {
-void Joint2D::set_node_a(const NodePath& p_node_a) {
-
-
- if (a==p_node_a)
+ if (a == p_node_a)
return;
- a=p_node_a;
+ a = p_node_a;
_update_joint();
}
-NodePath Joint2D::get_node_a() const{
+NodePath Joint2D::get_node_a() const {
return a;
}
-void Joint2D::set_node_b(const NodePath& p_node_b){
+void Joint2D::set_node_b(const NodePath &p_node_b) {
- if (b==p_node_b)
+ if (b == p_node_b)
return;
- b=p_node_b;
+ b = p_node_b;
_update_joint();
-
}
-NodePath Joint2D::get_node_b() const{
-
+NodePath Joint2D::get_node_b() const {
return b;
}
-
void Joint2D::_notification(int p_what) {
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_READY: {
_update_joint();
@@ -90,70 +82,61 @@ void Joint2D::_notification(int p_what) {
if (joint.is_valid()) {
Physics2DServer::get_singleton()->free(joint);
- joint=RID();
+ joint = RID();
}
} break;
-
}
-
}
void Joint2D::set_bias(real_t p_bias) {
- bias=p_bias;
+ bias = p_bias;
if (joint.is_valid())
- Physics2DServer::get_singleton()->get_singleton()->joint_set_param(joint,Physics2DServer::JOINT_PARAM_BIAS,bias);
+ Physics2DServer::get_singleton()->get_singleton()->joint_set_param(joint, Physics2DServer::JOINT_PARAM_BIAS, bias);
}
-real_t Joint2D::get_bias() const{
-
+real_t Joint2D::get_bias() const {
return bias;
}
void Joint2D::set_exclude_nodes_from_collision(bool p_enable) {
- if (exclude_from_collision==p_enable)
+ if (exclude_from_collision == p_enable)
return;
- exclude_from_collision=p_enable;
+ exclude_from_collision = p_enable;
_update_joint();
}
-bool Joint2D::get_exclude_nodes_from_collision() const{
+bool Joint2D::get_exclude_nodes_from_collision() const {
return exclude_from_collision;
}
-
void Joint2D::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("set_node_a", "node"), &Joint2D::set_node_a);
+ ClassDB::bind_method(D_METHOD("get_node_a"), &Joint2D::get_node_a);
- ClassDB::bind_method( D_METHOD("set_node_a","node"), &Joint2D::set_node_a );
- ClassDB::bind_method( D_METHOD("get_node_a"), &Joint2D::get_node_a );
-
- ClassDB::bind_method( D_METHOD("set_node_b","node"), &Joint2D::set_node_b );
- ClassDB::bind_method( D_METHOD("get_node_b"), &Joint2D::get_node_b );
+ ClassDB::bind_method(D_METHOD("set_node_b", "node"), &Joint2D::set_node_b);
+ ClassDB::bind_method(D_METHOD("get_node_b"), &Joint2D::get_node_b);
- ClassDB::bind_method( D_METHOD("set_bias","bias"), &Joint2D::set_bias );
- ClassDB::bind_method( D_METHOD("get_bias"), &Joint2D::get_bias );
-
- ClassDB::bind_method( D_METHOD("set_exclude_nodes_from_collision","enable"), &Joint2D::set_exclude_nodes_from_collision );
- ClassDB::bind_method( D_METHOD("get_exclude_nodes_from_collision"), &Joint2D::get_exclude_nodes_from_collision );
-
- ADD_PROPERTY( PropertyInfo( Variant::NODE_PATH, "node_a"), "set_node_a","get_node_a") ;
- ADD_PROPERTY( PropertyInfo( Variant::NODE_PATH, "node_b"), "set_node_b","get_node_b") ;
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "bias",PROPERTY_HINT_RANGE,"0,0.9,0.001"), "set_bias","get_bias") ;
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "disable_collision"), "set_exclude_nodes_from_collision","get_exclude_nodes_from_collision") ;
+ ClassDB::bind_method(D_METHOD("set_bias", "bias"), &Joint2D::set_bias);
+ ClassDB::bind_method(D_METHOD("get_bias"), &Joint2D::get_bias);
+ ClassDB::bind_method(D_METHOD("set_exclude_nodes_from_collision", "enable"), &Joint2D::set_exclude_nodes_from_collision);
+ ClassDB::bind_method(D_METHOD("get_exclude_nodes_from_collision"), &Joint2D::get_exclude_nodes_from_collision);
+ ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "node_a"), "set_node_a", "get_node_a");
+ ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "node_b"), "set_node_b", "get_node_b");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "bias", PROPERTY_HINT_RANGE, "0,0.9,0.001"), "set_bias", "get_bias");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "disable_collision"), "set_exclude_nodes_from_collision", "get_exclude_nodes_from_collision");
}
-
-
Joint2D::Joint2D() {
- bias=0;
- exclude_from_collision=true;
+ bias = 0;
+ exclude_from_collision = true;
}
///////////////////////////////////////////////////////////////////////////////
@@ -162,7 +145,7 @@ Joint2D::Joint2D() {
void PinJoint2D::_notification(int p_what) {
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_DRAW: {
if (!is_inside_tree())
@@ -172,50 +155,46 @@ void PinJoint2D::_notification(int p_what) {
break;
}
-
- draw_line(Point2(-10,0),Point2(+10,0),Color(0.7,0.6,0.0,0.5),3);
- draw_line(Point2(0,-10),Point2(0,+10),Color(0.7,0.6,0.0,0.5),3);
+ draw_line(Point2(-10, 0), Point2(+10, 0), Color(0.7, 0.6, 0.0, 0.5), 3);
+ draw_line(Point2(0, -10), Point2(0, +10), Color(0.7, 0.6, 0.0, 0.5), 3);
} break;
}
-
}
RID PinJoint2D::_configure_joint() {
- Node *node_a = has_node( get_node_a() ) ? get_node( get_node_a() ) : (Node*)NULL;
- Node *node_b = has_node( get_node_b() ) ? get_node( get_node_b() ) : (Node*)NULL;
+ Node *node_a = has_node(get_node_a()) ? get_node(get_node_a()) : (Node *)NULL;
+ Node *node_b = has_node(get_node_b()) ? get_node(get_node_b()) : (Node *)NULL;
if (!node_a && !node_b)
return RID();
- PhysicsBody2D *body_a=node_a ? node_a->cast_to<PhysicsBody2D>() : (PhysicsBody2D*)NULL;
- PhysicsBody2D *body_b=node_b ? node_b->cast_to<PhysicsBody2D>() : (PhysicsBody2D*)NULL;
+ PhysicsBody2D *body_a = node_a ? node_a->cast_to<PhysicsBody2D>() : (PhysicsBody2D *)NULL;
+ PhysicsBody2D *body_b = node_b ? node_b->cast_to<PhysicsBody2D>() : (PhysicsBody2D *)NULL;
if (!body_a && !body_b)
return RID();
if (!body_a) {
- SWAP(body_a,body_b);
+ SWAP(body_a, body_b);
} else if (body_b) {
//add a collision exception between both
if (get_exclude_nodes_from_collision())
- Physics2DServer::get_singleton()->body_add_collision_exception(body_a->get_rid(),body_b->get_rid());
+ Physics2DServer::get_singleton()->body_add_collision_exception(body_a->get_rid(), body_b->get_rid());
else
- Physics2DServer::get_singleton()->body_remove_collision_exception(body_a->get_rid(),body_b->get_rid());
+ Physics2DServer::get_singleton()->body_remove_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());
+ 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;
-
}
void PinJoint2D::set_softness(real_t p_softness) {
- softness=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 {
@@ -225,10 +204,10 @@ real_t PinJoint2D::get_softness() const {
void PinJoint2D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_softness","softness"), &PinJoint2D::set_softness);
+ ClassDB::bind_method(D_METHOD("set_softness", "softness"), &PinJoint2D::set_softness);
ClassDB::bind_method(D_METHOD("get_softness"), &PinJoint2D::get_softness);
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "softness", PROPERTY_HINT_EXP_RANGE,"0.00,16,0.01"), "set_softness", "get_softness");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "softness", PROPERTY_HINT_EXP_RANGE, "0.00,16,0.01"), "set_softness", "get_softness");
}
PinJoint2D::PinJoint2D() {
@@ -236,16 +215,13 @@ PinJoint2D::PinJoint2D() {
softness = 0;
}
-
-
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
-
void GrooveJoint2D::_notification(int p_what) {
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_DRAW: {
if (!is_inside_tree())
break;
@@ -254,48 +230,44 @@ void GrooveJoint2D::_notification(int p_what) {
break;
}
- draw_line(Point2(-10,0),Point2(+10,0),Color(0.7,0.6,0.0,0.5),3);
- draw_line(Point2(-10,length),Point2(+10,length),Color(0.7,0.6,0.0,0.5),3);
- draw_line(Point2(0,0),Point2(0,length),Color(0.7,0.6,0.0,0.5),3);
- draw_line(Point2(-10,initial_offset),Point2(+10,initial_offset),Color(0.8,0.8,0.9,0.5),5);
+ draw_line(Point2(-10, 0), Point2(+10, 0), Color(0.7, 0.6, 0.0, 0.5), 3);
+ draw_line(Point2(-10, length), Point2(+10, length), Color(0.7, 0.6, 0.0, 0.5), 3);
+ draw_line(Point2(0, 0), Point2(0, length), Color(0.7, 0.6, 0.0, 0.5), 3);
+ draw_line(Point2(-10, initial_offset), Point2(+10, initial_offset), Color(0.8, 0.8, 0.9, 0.5), 5);
} break;
}
}
-RID GrooveJoint2D::_configure_joint(){
+RID GrooveJoint2D::_configure_joint() {
-
- Node *node_a = has_node( get_node_a() ) ? get_node( get_node_a() ) : (Node*)NULL;
- Node *node_b = has_node( get_node_b() ) ? get_node( get_node_b() ) : (Node*)NULL;
+ Node *node_a = has_node(get_node_a()) ? get_node(get_node_a()) : (Node *)NULL;
+ Node *node_b = has_node(get_node_b()) ? get_node(get_node_b()) : (Node *)NULL;
if (!node_a || !node_b)
return RID();
- PhysicsBody2D *body_a=node_a->cast_to<PhysicsBody2D>();
- PhysicsBody2D *body_b=node_b->cast_to<PhysicsBody2D>();
+ PhysicsBody2D *body_a = node_a->cast_to<PhysicsBody2D>();
+ PhysicsBody2D *body_b = node_b->cast_to<PhysicsBody2D>();
if (!body_a || !body_b)
return RID();
-
if (get_exclude_nodes_from_collision())
- Physics2DServer::get_singleton()->body_add_collision_exception(body_a->get_rid(),body_b->get_rid());
+ Physics2DServer::get_singleton()->body_add_collision_exception(body_a->get_rid(), body_b->get_rid());
else
- Physics2DServer::get_singleton()->body_remove_collision_exception(body_a->get_rid(),body_b->get_rid());
+ Physics2DServer::get_singleton()->body_remove_collision_exception(body_a->get_rid(), body_b->get_rid());
Transform2D gt = get_global_transform();
Vector2 groove_A1 = gt.get_origin();
- Vector2 groove_A2 = gt.xform( Vector2(0,length) );
- Vector2 anchor_B = gt.xform( Vector2(0,initial_offset) );
-
+ Vector2 groove_A2 = gt.xform(Vector2(0, length));
+ Vector2 anchor_B = gt.xform(Vector2(0, initial_offset));
- return Physics2DServer::get_singleton()->groove_joint_create(groove_A1,groove_A2,anchor_B,body_a->get_rid(),body_b->get_rid());
+ return Physics2DServer::get_singleton()->groove_joint_create(groove_A1, groove_A2, anchor_B, body_a->get_rid(), body_b->get_rid());
}
-
void GrooveJoint2D::set_length(real_t p_length) {
- length=p_length;
+ length = p_length;
update();
}
@@ -304,10 +276,9 @@ real_t GrooveJoint2D::get_length() const {
return length;
}
-
void GrooveJoint2D::set_initial_offset(real_t p_initial_offset) {
- initial_offset=p_initial_offset;
+ initial_offset = p_initial_offset;
update();
}
@@ -316,38 +287,30 @@ real_t GrooveJoint2D::get_initial_offset() const {
return initial_offset;
}
-
-
void GrooveJoint2D::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("set_length", "length"), &GrooveJoint2D::set_length);
+ ClassDB::bind_method(D_METHOD("get_length"), &GrooveJoint2D::get_length);
+ ClassDB::bind_method(D_METHOD("set_initial_offset", "offset"), &GrooveJoint2D::set_initial_offset);
+ ClassDB::bind_method(D_METHOD("get_initial_offset"), &GrooveJoint2D::get_initial_offset);
- ClassDB::bind_method(D_METHOD("set_length","length"),&GrooveJoint2D::set_length);
- ClassDB::bind_method(D_METHOD("get_length"),&GrooveJoint2D::get_length);
- ClassDB::bind_method(D_METHOD("set_initial_offset","offset"),&GrooveJoint2D::set_initial_offset);
- ClassDB::bind_method(D_METHOD("get_initial_offset"),&GrooveJoint2D::get_initial_offset);
-
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "length", PROPERTY_HINT_EXP_RANGE,"1,65535,1"), "set_length","get_length");
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "initial_offset", PROPERTY_HINT_EXP_RANGE,"1,65535,1"), "set_initial_offset","get_initial_offset");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "length", PROPERTY_HINT_EXP_RANGE, "1,65535,1"), "set_length", "get_length");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "initial_offset", PROPERTY_HINT_EXP_RANGE, "1,65535,1"), "set_initial_offset", "get_initial_offset");
}
GrooveJoint2D::GrooveJoint2D() {
- length=50;
- initial_offset=25;
+ length = 50;
+ initial_offset = 25;
}
-
-
-
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
-
-
void DampedSpringJoint2D::_notification(int p_what) {
- switch(p_what) {
+ switch (p_what) {
case NOTIFICATION_DRAW: {
if (!is_inside_tree())
@@ -357,50 +320,48 @@ void DampedSpringJoint2D::_notification(int p_what) {
break;
}
- draw_line(Point2(-10,0),Point2(+10,0),Color(0.7,0.6,0.0,0.5),3);
- draw_line(Point2(-10,length),Point2(+10,length),Color(0.7,0.6,0.0,0.5),3);
- draw_line(Point2(0,0),Point2(0,length),Color(0.7,0.6,0.0,0.5),3);
+ draw_line(Point2(-10, 0), Point2(+10, 0), Color(0.7, 0.6, 0.0, 0.5), 3);
+ draw_line(Point2(-10, length), Point2(+10, length), Color(0.7, 0.6, 0.0, 0.5), 3);
+ draw_line(Point2(0, 0), Point2(0, length), Color(0.7, 0.6, 0.0, 0.5), 3);
} break;
}
}
-RID DampedSpringJoint2D::_configure_joint(){
-
+RID DampedSpringJoint2D::_configure_joint() {
- Node *node_a = has_node( get_node_a() ) ? get_node( get_node_a() ) : (Node*)NULL;
- Node *node_b = has_node( get_node_b() ) ? get_node( get_node_b() ) : (Node*)NULL;
+ Node *node_a = has_node(get_node_a()) ? get_node(get_node_a()) : (Node *)NULL;
+ Node *node_b = has_node(get_node_b()) ? get_node(get_node_b()) : (Node *)NULL;
if (!node_a || !node_b)
return RID();
- PhysicsBody2D *body_a=node_a->cast_to<PhysicsBody2D>();
- PhysicsBody2D *body_b=node_b->cast_to<PhysicsBody2D>();
+ PhysicsBody2D *body_a = node_a->cast_to<PhysicsBody2D>();
+ PhysicsBody2D *body_b = node_b->cast_to<PhysicsBody2D>();
if (!body_a || !body_b)
return RID();
if (get_exclude_nodes_from_collision())
- Physics2DServer::get_singleton()->body_add_collision_exception(body_a->get_rid(),body_b->get_rid());
+ Physics2DServer::get_singleton()->body_add_collision_exception(body_a->get_rid(), body_b->get_rid());
else
- Physics2DServer::get_singleton()->body_remove_collision_exception(body_a->get_rid(),body_b->get_rid());
+ Physics2DServer::get_singleton()->body_remove_collision_exception(body_a->get_rid(), body_b->get_rid());
Transform2D gt = get_global_transform();
Vector2 anchor_A = gt.get_origin();
- Vector2 anchor_B = gt.xform( Vector2(0,length) );
+ Vector2 anchor_B = gt.xform(Vector2(0, length));
- RID dsj = Physics2DServer::get_singleton()->damped_spring_joint_create(anchor_A,anchor_B,body_a->get_rid(),body_b->get_rid());
+ RID dsj = Physics2DServer::get_singleton()->damped_spring_joint_create(anchor_A, anchor_B, body_a->get_rid(), body_b->get_rid());
if (rest_length)
- Physics2DServer::get_singleton()->damped_string_joint_set_param(dsj,Physics2DServer::DAMPED_STRING_REST_LENGTH,rest_length);
- Physics2DServer::get_singleton()->damped_string_joint_set_param(dsj,Physics2DServer::DAMPED_STRING_STIFFNESS,stiffness);
- Physics2DServer::get_singleton()->damped_string_joint_set_param(dsj,Physics2DServer::DAMPED_STRING_DAMPING,damping);
+ Physics2DServer::get_singleton()->damped_string_joint_set_param(dsj, Physics2DServer::DAMPED_STRING_REST_LENGTH, rest_length);
+ Physics2DServer::get_singleton()->damped_string_joint_set_param(dsj, Physics2DServer::DAMPED_STRING_STIFFNESS, stiffness);
+ Physics2DServer::get_singleton()->damped_string_joint_set_param(dsj, Physics2DServer::DAMPED_STRING_DAMPING, damping);
return dsj;
}
-
void DampedSpringJoint2D::set_length(real_t p_length) {
- length=p_length;
+ length = p_length;
update();
}
@@ -411,11 +372,10 @@ real_t DampedSpringJoint2D::get_length() const {
void DampedSpringJoint2D::set_rest_length(real_t p_rest_length) {
- rest_length=p_rest_length;
+ rest_length = p_rest_length;
update();
if (get_joint().is_valid())
- Physics2DServer::get_singleton()->damped_string_joint_set_param(get_joint(),Physics2DServer::DAMPED_STRING_REST_LENGTH,p_rest_length?p_rest_length:length);
-
+ Physics2DServer::get_singleton()->damped_string_joint_set_param(get_joint(), Physics2DServer::DAMPED_STRING_REST_LENGTH, p_rest_length ? p_rest_length : length);
}
real_t DampedSpringJoint2D::get_rest_length() const {
@@ -425,10 +385,10 @@ real_t DampedSpringJoint2D::get_rest_length() const {
void DampedSpringJoint2D::set_stiffness(real_t p_stiffness) {
- stiffness=p_stiffness;
+ stiffness = p_stiffness;
update();
if (get_joint().is_valid())
- Physics2DServer::get_singleton()->damped_string_joint_set_param(get_joint(),Physics2DServer::DAMPED_STRING_STIFFNESS,p_stiffness);
+ Physics2DServer::get_singleton()->damped_string_joint_set_param(get_joint(), Physics2DServer::DAMPED_STRING_STIFFNESS, p_stiffness);
}
real_t DampedSpringJoint2D::get_stiffness() const {
@@ -438,10 +398,10 @@ real_t DampedSpringJoint2D::get_stiffness() const {
void DampedSpringJoint2D::set_damping(real_t p_damping) {
- damping=p_damping;
+ damping = p_damping;
update();
if (get_joint().is_valid())
- Physics2DServer::get_singleton()->damped_string_joint_set_param(get_joint(),Physics2DServer::DAMPED_STRING_DAMPING,p_damping);
+ Physics2DServer::get_singleton()->damped_string_joint_set_param(get_joint(), Physics2DServer::DAMPED_STRING_DAMPING, p_damping);
}
real_t DampedSpringJoint2D::get_damping() const {
@@ -449,30 +409,27 @@ real_t DampedSpringJoint2D::get_damping() const {
return damping;
}
-
void DampedSpringJoint2D::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("set_length", "length"), &DampedSpringJoint2D::set_length);
+ ClassDB::bind_method(D_METHOD("get_length"), &DampedSpringJoint2D::get_length);
+ ClassDB::bind_method(D_METHOD("set_rest_length", "rest_length"), &DampedSpringJoint2D::set_rest_length);
+ ClassDB::bind_method(D_METHOD("get_rest_length"), &DampedSpringJoint2D::get_rest_length);
+ ClassDB::bind_method(D_METHOD("set_stiffness", "stiffness"), &DampedSpringJoint2D::set_stiffness);
+ ClassDB::bind_method(D_METHOD("get_stiffness"), &DampedSpringJoint2D::get_stiffness);
+ ClassDB::bind_method(D_METHOD("set_damping", "damping"), &DampedSpringJoint2D::set_damping);
+ ClassDB::bind_method(D_METHOD("get_damping"), &DampedSpringJoint2D::get_damping);
- ClassDB::bind_method(D_METHOD("set_length","length"),&DampedSpringJoint2D::set_length);
- ClassDB::bind_method(D_METHOD("get_length"),&DampedSpringJoint2D::get_length);
- ClassDB::bind_method(D_METHOD("set_rest_length","rest_length"),&DampedSpringJoint2D::set_rest_length);
- ClassDB::bind_method(D_METHOD("get_rest_length"),&DampedSpringJoint2D::get_rest_length);
- ClassDB::bind_method(D_METHOD("set_stiffness","stiffness"),&DampedSpringJoint2D::set_stiffness);
- ClassDB::bind_method(D_METHOD("get_stiffness"),&DampedSpringJoint2D::get_stiffness);
- ClassDB::bind_method(D_METHOD("set_damping","damping"),&DampedSpringJoint2D::set_damping);
- ClassDB::bind_method(D_METHOD("get_damping"),&DampedSpringJoint2D::get_damping);
-
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "length", PROPERTY_HINT_EXP_RANGE,"1,65535,1"), "set_length","get_length");
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "rest_length", PROPERTY_HINT_EXP_RANGE,"0,65535,1"), "set_rest_length","get_rest_length");
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "stiffness", PROPERTY_HINT_EXP_RANGE,"0.1,64,0.1"), "set_stiffness","get_stiffness");
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "damping", PROPERTY_HINT_EXP_RANGE,"0.01,16,0.01"), "set_damping","get_damping");
-
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "length", PROPERTY_HINT_EXP_RANGE, "1,65535,1"), "set_length", "get_length");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "rest_length", PROPERTY_HINT_EXP_RANGE, "0,65535,1"), "set_rest_length", "get_rest_length");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "stiffness", PROPERTY_HINT_EXP_RANGE, "0.1,64,0.1"), "set_stiffness", "get_stiffness");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "damping", PROPERTY_HINT_EXP_RANGE, "0.01,16,0.01"), "set_damping", "get_damping");
}
DampedSpringJoint2D::DampedSpringJoint2D() {
- length=50;
- rest_length=0;
- stiffness=20;
- damping=1;
+ length = 50;
+ rest_length = 0;
+ stiffness = 20;
+ damping = 1;
}