Merge pull request #80736 from Ughuuu/add-get-rid-to-joints
Expose the `get_rid` method of Joint2D and Joint3D
This commit is contained in:
commit
f4d85d58f7
6 changed files with 37 additions and 17 deletions
|
@ -8,6 +8,14 @@
|
|||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
<method name="get_rid" qualifiers="const">
|
||||
<return type="RID" />
|
||||
<description>
|
||||
Returns the joint's [RID].
|
||||
</description>
|
||||
</method>
|
||||
</methods>
|
||||
<members>
|
||||
<member name="bias" type="float" setter="set_bias" getter="get_bias" default="0.0">
|
||||
When [member node_a] and [member node_b] move in different directions the [code]bias[/code] controls how fast the joint pulls them back to their original position. The lower the [code]bias[/code] the more the two bodies can pull on the joint.
|
||||
|
|
|
@ -9,6 +9,14 @@
|
|||
<tutorials>
|
||||
<link title="3D Truck Town Demo">https://godotengine.org/asset-library/asset/524</link>
|
||||
</tutorials>
|
||||
<methods>
|
||||
<method name="get_rid" qualifiers="const">
|
||||
<return type="RID" />
|
||||
<description>
|
||||
Returns the joint's [RID].
|
||||
</description>
|
||||
</method>
|
||||
</methods>
|
||||
<members>
|
||||
<member name="exclude_nodes_from_collision" type="bool" setter="set_exclude_nodes_from_collision" getter="get_exclude_nodes_from_collision" default="true">
|
||||
If [code]true[/code], the two bodies of the nodes are not able to collide with each other.
|
||||
|
|
|
@ -235,6 +235,8 @@ void Joint2D::_bind_methods() {
|
|||
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);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_rid"), &Joint2D::get_rid);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "node_a", PROPERTY_HINT_NODE_PATH_VALID_TYPES, "PhysicsBody2D"), "set_node_a", "get_node_a");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "node_b", PROPERTY_HINT_NODE_PATH_VALID_TYPES, "PhysicsBody2D"), "set_node_b", "get_node_b");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "bias", PROPERTY_HINT_RANGE, "0,0.9,0.001"), "set_bias", "get_bias");
|
||||
|
@ -281,7 +283,7 @@ void PinJoint2D::set_softness(real_t p_softness) {
|
|||
softness = p_softness;
|
||||
queue_redraw();
|
||||
if (is_configured()) {
|
||||
PhysicsServer2D::get_singleton()->pin_joint_set_param(get_joint(), PhysicsServer2D::PIN_JOINT_SOFTNESS, p_softness);
|
||||
PhysicsServer2D::get_singleton()->pin_joint_set_param(get_rid(), PhysicsServer2D::PIN_JOINT_SOFTNESS, p_softness);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -410,7 +412,7 @@ void DampedSpringJoint2D::set_rest_length(real_t p_rest_length) {
|
|||
rest_length = p_rest_length;
|
||||
queue_redraw();
|
||||
if (is_configured()) {
|
||||
PhysicsServer2D::get_singleton()->damped_spring_joint_set_param(get_joint(), PhysicsServer2D::DAMPED_SPRING_REST_LENGTH, p_rest_length ? p_rest_length : length);
|
||||
PhysicsServer2D::get_singleton()->damped_spring_joint_set_param(get_rid(), PhysicsServer2D::DAMPED_SPRING_REST_LENGTH, p_rest_length ? p_rest_length : length);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -422,7 +424,7 @@ void DampedSpringJoint2D::set_stiffness(real_t p_stiffness) {
|
|||
stiffness = p_stiffness;
|
||||
queue_redraw();
|
||||
if (is_configured()) {
|
||||
PhysicsServer2D::get_singleton()->damped_spring_joint_set_param(get_joint(), PhysicsServer2D::DAMPED_SPRING_STIFFNESS, p_stiffness);
|
||||
PhysicsServer2D::get_singleton()->damped_spring_joint_set_param(get_rid(), PhysicsServer2D::DAMPED_SPRING_STIFFNESS, p_stiffness);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -434,7 +436,7 @@ void DampedSpringJoint2D::set_damping(real_t p_damping) {
|
|||
damping = p_damping;
|
||||
queue_redraw();
|
||||
if (is_configured()) {
|
||||
PhysicsServer2D::get_singleton()->damped_spring_joint_set_param(get_joint(), PhysicsServer2D::DAMPED_SPRING_DAMPING, p_damping);
|
||||
PhysicsServer2D::get_singleton()->damped_spring_joint_set_param(get_rid(), PhysicsServer2D::DAMPED_SPRING_DAMPING, p_damping);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ public:
|
|||
void set_exclude_nodes_from_collision(bool p_enable);
|
||||
bool get_exclude_nodes_from_collision() const;
|
||||
|
||||
RID get_joint() const { return joint; }
|
||||
RID get_rid() const { return joint; }
|
||||
Joint2D();
|
||||
~Joint2D();
|
||||
};
|
||||
|
|
|
@ -221,6 +221,8 @@ void Joint3D::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("set_exclude_nodes_from_collision", "enable"), &Joint3D::set_exclude_nodes_from_collision);
|
||||
ClassDB::bind_method(D_METHOD("get_exclude_nodes_from_collision"), &Joint3D::get_exclude_nodes_from_collision);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_rid"), &Joint3D::get_rid);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "node_a", PROPERTY_HINT_NODE_PATH_VALID_TYPES, "PhysicsBody3D"), "set_node_a", "get_node_a");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "node_b", PROPERTY_HINT_NODE_PATH_VALID_TYPES, "PhysicsBody3D"), "set_node_b", "get_node_b");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "solver_priority", PROPERTY_HINT_RANGE, "1,8,1"), "set_solver_priority", "get_solver_priority");
|
||||
|
@ -257,7 +259,7 @@ void PinJoint3D::set_param(Param p_param, real_t p_value) {
|
|||
ERR_FAIL_INDEX(p_param, 3);
|
||||
params[p_param] = p_value;
|
||||
if (is_configured()) {
|
||||
PhysicsServer3D::get_singleton()->pin_joint_set_param(get_joint(), PhysicsServer3D::PinJointParam(p_param), p_value);
|
||||
PhysicsServer3D::get_singleton()->pin_joint_set_param(get_rid(), PhysicsServer3D::PinJointParam(p_param), p_value);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -332,7 +334,7 @@ void HingeJoint3D::set_param(Param p_param, real_t p_value) {
|
|||
ERR_FAIL_INDEX(p_param, PARAM_MAX);
|
||||
params[p_param] = p_value;
|
||||
if (is_configured()) {
|
||||
PhysicsServer3D::get_singleton()->hinge_joint_set_param(get_joint(), PhysicsServer3D::HingeJointParam(p_param), p_value);
|
||||
PhysicsServer3D::get_singleton()->hinge_joint_set_param(get_rid(), PhysicsServer3D::HingeJointParam(p_param), p_value);
|
||||
}
|
||||
|
||||
update_gizmos();
|
||||
|
@ -347,7 +349,7 @@ void HingeJoint3D::set_flag(Flag p_flag, bool p_value) {
|
|||
ERR_FAIL_INDEX(p_flag, FLAG_MAX);
|
||||
flags[p_flag] = p_value;
|
||||
if (is_configured()) {
|
||||
PhysicsServer3D::get_singleton()->hinge_joint_set_flag(get_joint(), PhysicsServer3D::HingeJointFlag(p_flag), p_value);
|
||||
PhysicsServer3D::get_singleton()->hinge_joint_set_flag(get_rid(), PhysicsServer3D::HingeJointFlag(p_flag), p_value);
|
||||
}
|
||||
|
||||
update_gizmos();
|
||||
|
@ -458,7 +460,7 @@ void SliderJoint3D::set_param(Param p_param, real_t p_value) {
|
|||
ERR_FAIL_INDEX(p_param, PARAM_MAX);
|
||||
params[p_param] = p_value;
|
||||
if (is_configured()) {
|
||||
PhysicsServer3D::get_singleton()->slider_joint_set_param(get_joint(), PhysicsServer3D::SliderJointParam(p_param), p_value);
|
||||
PhysicsServer3D::get_singleton()->slider_joint_set_param(get_rid(), PhysicsServer3D::SliderJointParam(p_param), p_value);
|
||||
}
|
||||
update_gizmos();
|
||||
}
|
||||
|
@ -540,7 +542,7 @@ void ConeTwistJoint3D::set_param(Param p_param, real_t p_value) {
|
|||
ERR_FAIL_INDEX(p_param, PARAM_MAX);
|
||||
params[p_param] = p_value;
|
||||
if (is_configured()) {
|
||||
PhysicsServer3D::get_singleton()->cone_twist_joint_set_param(get_joint(), PhysicsServer3D::ConeTwistJointParam(p_param), p_value);
|
||||
PhysicsServer3D::get_singleton()->cone_twist_joint_set_param(get_rid(), PhysicsServer3D::ConeTwistJointParam(p_param), p_value);
|
||||
}
|
||||
|
||||
update_gizmos();
|
||||
|
@ -753,7 +755,7 @@ void Generic6DOFJoint3D::set_param_x(Param p_param, real_t p_value) {
|
|||
ERR_FAIL_INDEX(p_param, PARAM_MAX);
|
||||
params_x[p_param] = p_value;
|
||||
if (is_configured()) {
|
||||
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(get_joint(), Vector3::AXIS_X, PhysicsServer3D::G6DOFJointAxisParam(p_param), p_value);
|
||||
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(get_rid(), Vector3::AXIS_X, PhysicsServer3D::G6DOFJointAxisParam(p_param), p_value);
|
||||
}
|
||||
|
||||
update_gizmos();
|
||||
|
@ -768,7 +770,7 @@ void Generic6DOFJoint3D::set_param_y(Param p_param, real_t p_value) {
|
|||
ERR_FAIL_INDEX(p_param, PARAM_MAX);
|
||||
params_y[p_param] = p_value;
|
||||
if (is_configured()) {
|
||||
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(get_joint(), Vector3::AXIS_Y, PhysicsServer3D::G6DOFJointAxisParam(p_param), p_value);
|
||||
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(get_rid(), Vector3::AXIS_Y, PhysicsServer3D::G6DOFJointAxisParam(p_param), p_value);
|
||||
}
|
||||
update_gizmos();
|
||||
}
|
||||
|
@ -782,7 +784,7 @@ void Generic6DOFJoint3D::set_param_z(Param p_param, real_t p_value) {
|
|||
ERR_FAIL_INDEX(p_param, PARAM_MAX);
|
||||
params_z[p_param] = p_value;
|
||||
if (is_configured()) {
|
||||
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(get_joint(), Vector3::AXIS_Z, PhysicsServer3D::G6DOFJointAxisParam(p_param), p_value);
|
||||
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(get_rid(), Vector3::AXIS_Z, PhysicsServer3D::G6DOFJointAxisParam(p_param), p_value);
|
||||
}
|
||||
update_gizmos();
|
||||
}
|
||||
|
@ -796,7 +798,7 @@ void Generic6DOFJoint3D::set_flag_x(Flag p_flag, bool p_enabled) {
|
|||
ERR_FAIL_INDEX(p_flag, FLAG_MAX);
|
||||
flags_x[p_flag] = p_enabled;
|
||||
if (is_configured()) {
|
||||
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(get_joint(), Vector3::AXIS_X, PhysicsServer3D::G6DOFJointAxisFlag(p_flag), p_enabled);
|
||||
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(get_rid(), Vector3::AXIS_X, PhysicsServer3D::G6DOFJointAxisFlag(p_flag), p_enabled);
|
||||
}
|
||||
update_gizmos();
|
||||
}
|
||||
|
@ -810,7 +812,7 @@ void Generic6DOFJoint3D::set_flag_y(Flag p_flag, bool p_enabled) {
|
|||
ERR_FAIL_INDEX(p_flag, FLAG_MAX);
|
||||
flags_y[p_flag] = p_enabled;
|
||||
if (is_configured()) {
|
||||
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(get_joint(), Vector3::AXIS_Y, PhysicsServer3D::G6DOFJointAxisFlag(p_flag), p_enabled);
|
||||
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(get_rid(), Vector3::AXIS_Y, PhysicsServer3D::G6DOFJointAxisFlag(p_flag), p_enabled);
|
||||
}
|
||||
update_gizmos();
|
||||
}
|
||||
|
@ -824,7 +826,7 @@ void Generic6DOFJoint3D::set_flag_z(Flag p_flag, bool p_enabled) {
|
|||
ERR_FAIL_INDEX(p_flag, FLAG_MAX);
|
||||
flags_z[p_flag] = p_enabled;
|
||||
if (is_configured()) {
|
||||
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(get_joint(), Vector3::AXIS_Z, PhysicsServer3D::G6DOFJointAxisFlag(p_flag), p_enabled);
|
||||
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(get_rid(), Vector3::AXIS_Z, PhysicsServer3D::G6DOFJointAxisFlag(p_flag), p_enabled);
|
||||
}
|
||||
update_gizmos();
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ public:
|
|||
void set_exclude_nodes_from_collision(bool p_enable);
|
||||
bool get_exclude_nodes_from_collision() const;
|
||||
|
||||
RID get_joint() const { return joint; }
|
||||
RID get_rid() const { return joint; }
|
||||
Joint3D();
|
||||
~Joint3D();
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue