2014-02-10 01:10:30 +00:00
|
|
|
/*************************************************************************/
|
2021-10-01 19:00:32 +00:00
|
|
|
/* joint_3d.cpp */
|
2014-02-10 01:10:30 +00:00
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
2017-08-27 12:16:55 +00:00
|
|
|
/* https://godotengine.org */
|
2014-02-10 01:10:30 +00:00
|
|
|
/*************************************************************************/
|
2022-01-03 20:27:34 +00:00
|
|
|
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
2014-02-10 01:10:30 +00:00
|
|
|
/* */
|
|
|
|
/* 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. */
|
|
|
|
/*************************************************************************/
|
2018-01-04 23:50:27 +00:00
|
|
|
|
2021-10-01 19:00:32 +00:00
|
|
|
#include "joint_3d.h"
|
2014-09-15 14:33:30 +00:00
|
|
|
|
2020-12-26 14:23:30 +00:00
|
|
|
#include "scene/scene_string_names.h"
|
|
|
|
|
|
|
|
void Joint3D::_disconnect_signals() {
|
|
|
|
Node *node_a = get_node_or_null(a);
|
|
|
|
PhysicsBody3D *body_a = Object::cast_to<PhysicsBody3D>(node_a);
|
|
|
|
if (body_a) {
|
|
|
|
body_a->disconnect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &Joint3D::_body_exit_tree));
|
|
|
|
}
|
|
|
|
|
|
|
|
Node *node_b = get_node_or_null(b);
|
|
|
|
PhysicsBody3D *body_b = Object::cast_to<PhysicsBody3D>(node_b);
|
|
|
|
if (body_b) {
|
|
|
|
body_b->disconnect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &Joint3D::_body_exit_tree));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-02 00:48:44 +00:00
|
|
|
void Joint3D::_body_exit_tree() {
|
2020-12-26 14:23:30 +00:00
|
|
|
_disconnect_signals();
|
2021-03-02 00:48:44 +00:00
|
|
|
_update_joint(true);
|
2020-12-26 14:23:30 +00:00
|
|
|
}
|
|
|
|
|
2020-03-26 21:49:16 +00:00
|
|
|
void Joint3D::_update_joint(bool p_only_free) {
|
2021-02-09 16:19:03 +00:00
|
|
|
if (ba.is_valid() && bb.is_valid()) {
|
|
|
|
PhysicsServer3D::get_singleton()->body_remove_collision_exception(ba, bb);
|
2021-02-27 15:38:58 +00:00
|
|
|
PhysicsServer3D::get_singleton()->body_remove_collision_exception(bb, ba);
|
2014-09-15 14:33:30 +00:00
|
|
|
}
|
|
|
|
|
2021-02-09 16:19:03 +00:00
|
|
|
ba = RID();
|
|
|
|
bb = RID();
|
|
|
|
|
|
|
|
configured = false;
|
|
|
|
|
2020-05-14 14:41:43 +00:00
|
|
|
if (p_only_free || !is_inside_tree()) {
|
2021-02-09 16:19:03 +00:00
|
|
|
PhysicsServer3D::get_singleton()->joint_clear(joint);
|
2020-11-25 18:21:33 +00:00
|
|
|
warning = String();
|
2020-10-29 10:01:28 +00:00
|
|
|
update_configuration_warnings();
|
2014-09-15 14:33:30 +00:00
|
|
|
return;
|
2020-05-14 14:41:43 +00:00
|
|
|
}
|
2014-09-15 14:33:30 +00:00
|
|
|
|
2020-12-26 14:23:30 +00:00
|
|
|
Node *node_a = get_node_or_null(a);
|
|
|
|
Node *node_b = get_node_or_null(b);
|
2014-09-15 14:33:30 +00:00
|
|
|
|
2020-03-26 21:49:16 +00:00
|
|
|
PhysicsBody3D *body_a = Object::cast_to<PhysicsBody3D>(node_a);
|
|
|
|
PhysicsBody3D *body_b = Object::cast_to<PhysicsBody3D>(node_b);
|
2014-09-15 14:33:30 +00:00
|
|
|
|
2020-11-25 18:21:33 +00:00
|
|
|
if (node_a && !body_a && node_b && !body_b) {
|
|
|
|
warning = TTR("Node A and Node B must be PhysicsBody3Ds");
|
2020-10-29 10:01:28 +00:00
|
|
|
} else if (node_a && !body_a) {
|
2020-11-25 18:21:33 +00:00
|
|
|
warning = TTR("Node A must be a PhysicsBody3D");
|
2020-10-29 10:01:28 +00:00
|
|
|
} else if (node_b && !body_b) {
|
2020-11-25 18:21:33 +00:00
|
|
|
warning = TTR("Node B must be a PhysicsBody3D");
|
2020-10-29 10:01:28 +00:00
|
|
|
} else if (!body_a && !body_b) {
|
2020-11-25 18:21:33 +00:00
|
|
|
warning = TTR("Joint is not connected to any PhysicsBody3Ds");
|
2020-10-29 10:01:28 +00:00
|
|
|
} else if (body_a == body_b) {
|
|
|
|
warning = TTR("Node A and Node B must be different PhysicsBody3Ds");
|
|
|
|
} else {
|
|
|
|
warning = String();
|
2020-05-14 14:41:43 +00:00
|
|
|
}
|
2017-08-29 21:15:12 +00:00
|
|
|
|
2020-10-29 10:01:28 +00:00
|
|
|
update_configuration_warnings();
|
|
|
|
|
|
|
|
if (!warning.is_empty()) {
|
2021-02-09 16:19:03 +00:00
|
|
|
PhysicsServer3D::get_singleton()->joint_clear(joint);
|
2020-11-25 18:21:33 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-02-09 16:19:03 +00:00
|
|
|
configured = true;
|
|
|
|
|
2021-01-13 18:58:05 +00:00
|
|
|
if (body_a) {
|
2021-02-09 16:19:03 +00:00
|
|
|
_configure_joint(joint, body_a, body_b);
|
2021-01-13 18:58:05 +00:00
|
|
|
} else if (body_b) {
|
2021-02-09 16:19:03 +00:00
|
|
|
_configure_joint(joint, body_b, nullptr);
|
2021-01-13 18:58:05 +00:00
|
|
|
}
|
2020-11-25 18:21:33 +00:00
|
|
|
|
2020-03-27 18:21:27 +00:00
|
|
|
PhysicsServer3D::get_singleton()->joint_set_solver_priority(joint, solver_priority);
|
2014-10-03 03:10:51 +00:00
|
|
|
|
2021-01-13 18:58:05 +00:00
|
|
|
if (body_a) {
|
|
|
|
ba = body_a->get_rid();
|
2021-03-02 00:48:44 +00:00
|
|
|
body_a->connect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &Joint3D::_body_exit_tree));
|
2021-01-13 18:58:05 +00:00
|
|
|
}
|
2020-12-26 14:23:30 +00:00
|
|
|
|
2020-05-14 14:41:43 +00:00
|
|
|
if (body_b) {
|
2018-08-16 06:23:08 +00:00
|
|
|
bb = body_b->get_rid();
|
2021-03-02 00:48:44 +00:00
|
|
|
body_b->connect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &Joint3D::_body_exit_tree));
|
2020-05-14 14:41:43 +00:00
|
|
|
}
|
2014-09-15 14:33:30 +00:00
|
|
|
|
2020-03-27 18:21:27 +00:00
|
|
|
PhysicsServer3D::get_singleton()->joint_disable_collisions_between_bodies(joint, exclude_from_collision);
|
2014-09-15 14:33:30 +00:00
|
|
|
}
|
|
|
|
|
2020-03-26 21:49:16 +00:00
|
|
|
void Joint3D::set_node_a(const NodePath &p_node_a) {
|
2020-05-14 14:41:43 +00:00
|
|
|
if (a == p_node_a) {
|
2014-09-15 14:33:30 +00:00
|
|
|
return;
|
2020-05-14 14:41:43 +00:00
|
|
|
}
|
2014-09-15 14:33:30 +00:00
|
|
|
|
2022-02-27 15:55:57 +00:00
|
|
|
if (is_configured()) {
|
2020-12-26 14:23:30 +00:00
|
|
|
_disconnect_signals();
|
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
a = p_node_a;
|
2014-09-15 14:33:30 +00:00
|
|
|
_update_joint();
|
|
|
|
}
|
|
|
|
|
2020-03-26 21:49:16 +00:00
|
|
|
NodePath Joint3D::get_node_a() const {
|
2014-09-15 14:33:30 +00:00
|
|
|
return a;
|
|
|
|
}
|
|
|
|
|
2020-03-26 21:49:16 +00:00
|
|
|
void Joint3D::set_node_b(const NodePath &p_node_b) {
|
2020-05-14 14:41:43 +00:00
|
|
|
if (b == p_node_b) {
|
2014-09-15 14:33:30 +00:00
|
|
|
return;
|
2020-05-14 14:41:43 +00:00
|
|
|
}
|
2020-12-26 14:23:30 +00:00
|
|
|
|
2022-02-27 15:55:57 +00:00
|
|
|
if (is_configured()) {
|
2020-12-26 14:23:30 +00:00
|
|
|
_disconnect_signals();
|
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
b = p_node_b;
|
2014-09-15 14:33:30 +00:00
|
|
|
_update_joint();
|
|
|
|
}
|
2020-05-14 12:29:06 +00:00
|
|
|
|
2020-03-26 21:49:16 +00:00
|
|
|
NodePath Joint3D::get_node_b() const {
|
2014-09-15 14:33:30 +00:00
|
|
|
return b;
|
|
|
|
}
|
|
|
|
|
2020-03-26 21:49:16 +00:00
|
|
|
void Joint3D::set_solver_priority(int p_priority) {
|
2017-03-05 15:44:50 +00:00
|
|
|
solver_priority = p_priority;
|
2020-05-14 14:41:43 +00:00
|
|
|
if (joint.is_valid()) {
|
2020-03-27 18:21:27 +00:00
|
|
|
PhysicsServer3D::get_singleton()->joint_set_solver_priority(joint, solver_priority);
|
2020-05-14 14:41:43 +00:00
|
|
|
}
|
2014-10-03 03:10:51 +00:00
|
|
|
}
|
|
|
|
|
2020-03-26 21:49:16 +00:00
|
|
|
int Joint3D::get_solver_priority() const {
|
2014-10-03 03:10:51 +00:00
|
|
|
return solver_priority;
|
|
|
|
}
|
|
|
|
|
2020-03-26 21:49:16 +00:00
|
|
|
void Joint3D::_notification(int p_what) {
|
2017-03-05 15:44:50 +00:00
|
|
|
switch (p_what) {
|
2022-02-28 21:21:32 +00:00
|
|
|
case NOTIFICATION_POST_ENTER_TREE: {
|
|
|
|
if (is_configured()) {
|
|
|
|
_disconnect_signals();
|
|
|
|
}
|
2014-09-15 14:33:30 +00:00
|
|
|
_update_joint();
|
|
|
|
} break;
|
2022-02-15 17:06:48 +00:00
|
|
|
|
2014-11-06 00:20:42 +00:00
|
|
|
case NOTIFICATION_EXIT_TREE: {
|
2022-02-27 15:55:57 +00:00
|
|
|
if (is_configured()) {
|
2020-12-26 14:23:30 +00:00
|
|
|
_disconnect_signals();
|
2014-09-15 14:33:30 +00:00
|
|
|
}
|
2022-02-28 21:21:32 +00:00
|
|
|
_update_joint(true);
|
2014-09-15 14:33:30 +00:00
|
|
|
} break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-26 21:49:16 +00:00
|
|
|
void Joint3D::set_exclude_nodes_from_collision(bool p_enable) {
|
2020-05-14 14:41:43 +00:00
|
|
|
if (exclude_from_collision == p_enable) {
|
2015-12-08 20:47:12 +00:00
|
|
|
return;
|
2020-05-14 14:41:43 +00:00
|
|
|
}
|
2022-02-28 21:25:45 +00:00
|
|
|
if (is_configured()) {
|
|
|
|
_disconnect_signals();
|
|
|
|
}
|
|
|
|
_update_joint(true);
|
2017-03-05 15:44:50 +00:00
|
|
|
exclude_from_collision = p_enable;
|
2015-12-08 20:47:12 +00:00
|
|
|
_update_joint();
|
|
|
|
}
|
|
|
|
|
2020-03-26 21:49:16 +00:00
|
|
|
bool Joint3D::get_exclude_nodes_from_collision() const {
|
2015-12-08 20:47:12 +00:00
|
|
|
return exclude_from_collision;
|
|
|
|
}
|
|
|
|
|
2020-10-29 10:01:28 +00:00
|
|
|
TypedArray<String> Joint3D::get_configuration_warnings() const {
|
|
|
|
TypedArray<String> warnings = Node3D::get_configuration_warnings();
|
2020-11-25 18:21:33 +00:00
|
|
|
|
2020-12-15 12:04:21 +00:00
|
|
|
if (!warning.is_empty()) {
|
2020-10-29 10:01:28 +00:00
|
|
|
warnings.push_back(warning);
|
2020-11-25 18:21:33 +00:00
|
|
|
}
|
|
|
|
|
2020-10-29 10:01:28 +00:00
|
|
|
return warnings;
|
2020-11-25 18:21:33 +00:00
|
|
|
}
|
|
|
|
|
2020-03-26 21:49:16 +00:00
|
|
|
void Joint3D::_bind_methods() {
|
|
|
|
ClassDB::bind_method(D_METHOD("set_node_a", "node"), &Joint3D::set_node_a);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_node_a"), &Joint3D::get_node_a);
|
2014-09-15 14:33:30 +00:00
|
|
|
|
2020-03-26 21:49:16 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("set_node_b", "node"), &Joint3D::set_node_b);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_node_b"), &Joint3D::get_node_b);
|
2015-12-08 20:47:12 +00:00
|
|
|
|
2020-03-26 21:49:16 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("set_solver_priority", "priority"), &Joint3D::set_solver_priority);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_solver_priority"), &Joint3D::get_solver_priority);
|
2015-12-08 20:47:12 +00:00
|
|
|
|
2020-03-26 21:49:16 +00:00
|
|
|
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);
|
2015-12-08 20:47:12 +00:00
|
|
|
|
2020-11-25 18:21:33 +00:00
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "nodes/node_a", PROPERTY_HINT_NODE_PATH_VALID_TYPES, "PhysicsBody3D"), "set_node_a", "get_node_a");
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "nodes/node_b", PROPERTY_HINT_NODE_PATH_VALID_TYPES, "PhysicsBody3D"), "set_node_b", "get_node_b");
|
2017-03-05 15:44:50 +00:00
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "solver/priority", PROPERTY_HINT_RANGE, "1,8,1"), "set_solver_priority", "get_solver_priority");
|
2014-09-15 14:33:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collision/exclude_nodes"), "set_exclude_nodes_from_collision", "get_exclude_nodes_from_collision");
|
2014-09-15 14:33:30 +00:00
|
|
|
}
|
|
|
|
|
2020-03-26 21:49:16 +00:00
|
|
|
Joint3D::Joint3D() {
|
2017-01-12 23:35:46 +00:00
|
|
|
set_notify_transform(true);
|
2021-02-09 16:19:03 +00:00
|
|
|
joint = PhysicsServer3D::get_singleton()->joint_create();
|
|
|
|
}
|
|
|
|
|
|
|
|
Joint3D::~Joint3D() {
|
|
|
|
PhysicsServer3D::get_singleton()->free(joint);
|
2014-09-15 14:33:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////////
|
|
|
|
|
2020-03-26 21:49:16 +00:00
|
|
|
void PinJoint3D::_bind_methods() {
|
|
|
|
ClassDB::bind_method(D_METHOD("set_param", "param", "value"), &PinJoint3D::set_param);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_param", "param"), &PinJoint3D::get_param);
|
2014-09-15 14:33:30 +00:00
|
|
|
|
Variant: Added 64-bit packed arrays, renamed Variant::REAL to FLOAT.
- Renames PackedIntArray to PackedInt32Array.
- Renames PackedFloatArray to PackedFloat32Array.
- Adds PackedInt64Array and PackedFloat64Array.
- Renames Variant::REAL to Variant::FLOAT for consistency.
Packed arrays are for storing large amount of data and creating stuff like
meshes, buffers. textures, etc. Forcing them to be 64 is a huge waste of
memory. That said, many users requested the ability to have 64 bits packed
arrays for their games, so this is just an optional added type.
For Variant, the float datatype is always 64 bits, and exposed as `float`.
We still have `real_t` which is the datatype that can change from 32 to 64
bits depending on a compile flag (not entirely working right now, but that's
the idea). It affects math related datatypes and code only.
Neither Variant nor PackedArray make use of real_t, which is only intended
for math precision, so the term is removed from there to keep only float.
2020-02-24 18:20:53 +00:00
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "params/bias", PROPERTY_HINT_RANGE, "0.01,0.99,0.01"), "set_param", "get_param", PARAM_BIAS);
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "params/damping", PROPERTY_HINT_RANGE, "0.01,8.0,0.01"), "set_param", "get_param", PARAM_DAMPING);
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "params/impulse_clamp", PROPERTY_HINT_RANGE, "0.0,64.0,0.01"), "set_param", "get_param", PARAM_IMPULSE_CLAMP);
|
2014-09-15 14:33:30 +00:00
|
|
|
|
2017-08-20 15:45:01 +00:00
|
|
|
BIND_ENUM_CONSTANT(PARAM_BIAS);
|
|
|
|
BIND_ENUM_CONSTANT(PARAM_DAMPING);
|
|
|
|
BIND_ENUM_CONSTANT(PARAM_IMPULSE_CLAMP);
|
2014-09-15 14:33:30 +00:00
|
|
|
}
|
|
|
|
|
2021-01-29 23:22:12 +00:00
|
|
|
void PinJoint3D::set_param(Param p_param, real_t p_value) {
|
2017-03-05 15:44:50 +00:00
|
|
|
ERR_FAIL_INDEX(p_param, 3);
|
|
|
|
params[p_param] = p_value;
|
2021-02-09 16:19:03 +00:00
|
|
|
if (is_configured()) {
|
2020-03-27 18:21:27 +00:00
|
|
|
PhysicsServer3D::get_singleton()->pin_joint_set_param(get_joint(), PhysicsServer3D::PinJointParam(p_param), p_value);
|
2020-05-14 14:41:43 +00:00
|
|
|
}
|
2014-09-15 14:33:30 +00:00
|
|
|
}
|
2020-05-14 12:29:06 +00:00
|
|
|
|
2021-01-29 23:22:12 +00:00
|
|
|
real_t PinJoint3D::get_param(Param p_param) const {
|
2017-03-05 15:44:50 +00:00
|
|
|
ERR_FAIL_INDEX_V(p_param, 3, 0);
|
2014-09-15 14:33:30 +00:00
|
|
|
return params[p_param];
|
|
|
|
}
|
|
|
|
|
2021-02-09 16:19:03 +00:00
|
|
|
void PinJoint3D::_configure_joint(RID p_joint, PhysicsBody3D *body_a, PhysicsBody3D *body_b) {
|
2014-09-15 14:33:30 +00:00
|
|
|
Vector3 pinpos = get_global_transform().origin;
|
2021-08-14 08:16:57 +00:00
|
|
|
Vector3 local_a = body_a->to_local(pinpos);
|
2014-09-15 14:33:30 +00:00
|
|
|
Vector3 local_b;
|
|
|
|
|
2020-05-14 14:41:43 +00:00
|
|
|
if (body_b) {
|
2021-08-14 08:16:57 +00:00
|
|
|
local_b = body_b->to_local(pinpos);
|
2020-05-14 14:41:43 +00:00
|
|
|
} else {
|
2017-03-05 15:44:50 +00:00
|
|
|
local_b = pinpos;
|
2020-05-14 14:41:43 +00:00
|
|
|
}
|
2014-09-15 14:33:30 +00:00
|
|
|
|
2021-02-09 16:19:03 +00:00
|
|
|
PhysicsServer3D::get_singleton()->joint_make_pin(p_joint, body_a->get_rid(), local_a, body_b ? body_b->get_rid() : RID(), local_b);
|
2017-03-05 15:44:50 +00:00
|
|
|
for (int i = 0; i < 3; i++) {
|
2021-02-09 16:19:03 +00:00
|
|
|
PhysicsServer3D::get_singleton()->pin_joint_set_param(p_joint, PhysicsServer3D::PinJointParam(i), params[i]);
|
2014-09-15 14:33:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-26 21:49:16 +00:00
|
|
|
PinJoint3D::PinJoint3D() {
|
2017-03-05 15:44:50 +00:00
|
|
|
params[PARAM_BIAS] = 0.3;
|
|
|
|
params[PARAM_DAMPING] = 1;
|
|
|
|
params[PARAM_IMPULSE_CLAMP] = 0;
|
2014-09-15 14:33:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////
|
|
|
|
|
|
|
|
///////////////////////////////////
|
|
|
|
|
2021-01-29 23:22:12 +00:00
|
|
|
void HingeJoint3D::_set_upper_limit(real_t p_limit) {
|
2017-03-05 15:44:50 +00:00
|
|
|
set_param(PARAM_LIMIT_UPPER, Math::deg2rad(p_limit));
|
2014-09-15 14:33:30 +00:00
|
|
|
}
|
|
|
|
|
2021-01-29 23:22:12 +00:00
|
|
|
real_t HingeJoint3D::_get_upper_limit() const {
|
2014-09-15 14:33:30 +00:00
|
|
|
return Math::rad2deg(get_param(PARAM_LIMIT_UPPER));
|
|
|
|
}
|
|
|
|
|
2021-01-29 23:22:12 +00:00
|
|
|
void HingeJoint3D::_set_lower_limit(real_t p_limit) {
|
2017-03-05 15:44:50 +00:00
|
|
|
set_param(PARAM_LIMIT_LOWER, Math::deg2rad(p_limit));
|
2014-09-15 14:33:30 +00:00
|
|
|
}
|
|
|
|
|
2021-01-29 23:22:12 +00:00
|
|
|
real_t HingeJoint3D::_get_lower_limit() const {
|
2014-09-15 14:33:30 +00:00
|
|
|
return Math::rad2deg(get_param(PARAM_LIMIT_LOWER));
|
|
|
|
}
|
|
|
|
|
2020-03-26 21:49:16 +00:00
|
|
|
void HingeJoint3D::_bind_methods() {
|
|
|
|
ClassDB::bind_method(D_METHOD("set_param", "param", "value"), &HingeJoint3D::set_param);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_param", "param"), &HingeJoint3D::get_param);
|
2014-09-15 14:33:30 +00:00
|
|
|
|
2020-03-26 21:49:16 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("set_flag", "flag", "enabled"), &HingeJoint3D::set_flag);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_flag", "flag"), &HingeJoint3D::get_flag);
|
2014-09-15 14:33:30 +00:00
|
|
|
|
2020-03-26 21:49:16 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("_set_upper_limit", "upper_limit"), &HingeJoint3D::_set_upper_limit);
|
|
|
|
ClassDB::bind_method(D_METHOD("_get_upper_limit"), &HingeJoint3D::_get_upper_limit);
|
2014-09-15 14:33:30 +00:00
|
|
|
|
2020-03-26 21:49:16 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("_set_lower_limit", "lower_limit"), &HingeJoint3D::_set_lower_limit);
|
|
|
|
ClassDB::bind_method(D_METHOD("_get_lower_limit"), &HingeJoint3D::_get_lower_limit);
|
2014-09-15 14:33:30 +00:00
|
|
|
|
Variant: Added 64-bit packed arrays, renamed Variant::REAL to FLOAT.
- Renames PackedIntArray to PackedInt32Array.
- Renames PackedFloatArray to PackedFloat32Array.
- Adds PackedInt64Array and PackedFloat64Array.
- Renames Variant::REAL to Variant::FLOAT for consistency.
Packed arrays are for storing large amount of data and creating stuff like
meshes, buffers. textures, etc. Forcing them to be 64 is a huge waste of
memory. That said, many users requested the ability to have 64 bits packed
arrays for their games, so this is just an optional added type.
For Variant, the float datatype is always 64 bits, and exposed as `float`.
We still have `real_t` which is the datatype that can change from 32 to 64
bits depending on a compile flag (not entirely working right now, but that's
the idea). It affects math related datatypes and code only.
Neither Variant nor PackedArray make use of real_t, which is only intended
for math precision, so the term is removed from there to keep only float.
2020-02-24 18:20:53 +00:00
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "params/bias", PROPERTY_HINT_RANGE, "0.00,0.99,0.01"), "set_param", "get_param", PARAM_BIAS);
|
2014-09-15 14:33:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "angular_limit/enable"), "set_flag", "get_flag", FLAG_USE_LIMIT);
|
Variant: Added 64-bit packed arrays, renamed Variant::REAL to FLOAT.
- Renames PackedIntArray to PackedInt32Array.
- Renames PackedFloatArray to PackedFloat32Array.
- Adds PackedInt64Array and PackedFloat64Array.
- Renames Variant::REAL to Variant::FLOAT for consistency.
Packed arrays are for storing large amount of data and creating stuff like
meshes, buffers. textures, etc. Forcing them to be 64 is a huge waste of
memory. That said, many users requested the ability to have 64 bits packed
arrays for their games, so this is just an optional added type.
For Variant, the float datatype is always 64 bits, and exposed as `float`.
We still have `real_t` which is the datatype that can change from 32 to 64
bits depending on a compile flag (not entirely working right now, but that's
the idea). It affects math related datatypes and code only.
Neither Variant nor PackedArray make use of real_t, which is only intended
for math precision, so the term is removed from there to keep only float.
2020-02-24 18:20:53 +00:00
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "angular_limit/upper", PROPERTY_HINT_RANGE, "-180,180,0.1"), "_set_upper_limit", "_get_upper_limit");
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "angular_limit/lower", PROPERTY_HINT_RANGE, "-180,180,0.1"), "_set_lower_limit", "_get_lower_limit");
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_limit/bias", PROPERTY_HINT_RANGE, "0.01,0.99,0.01"), "set_param", "get_param", PARAM_LIMIT_BIAS);
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_limit/softness", PROPERTY_HINT_RANGE, "0.01,16,0.01"), "set_param", "get_param", PARAM_LIMIT_SOFTNESS);
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_limit/relaxation", PROPERTY_HINT_RANGE, "0.01,16,0.01"), "set_param", "get_param", PARAM_LIMIT_RELAXATION);
|
2014-09-15 14:33:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "motor/enable"), "set_flag", "get_flag", FLAG_ENABLE_MOTOR);
|
Variant: Added 64-bit packed arrays, renamed Variant::REAL to FLOAT.
- Renames PackedIntArray to PackedInt32Array.
- Renames PackedFloatArray to PackedFloat32Array.
- Adds PackedInt64Array and PackedFloat64Array.
- Renames Variant::REAL to Variant::FLOAT for consistency.
Packed arrays are for storing large amount of data and creating stuff like
meshes, buffers. textures, etc. Forcing them to be 64 is a huge waste of
memory. That said, many users requested the ability to have 64 bits packed
arrays for their games, so this is just an optional added type.
For Variant, the float datatype is always 64 bits, and exposed as `float`.
We still have `real_t` which is the datatype that can change from 32 to 64
bits depending on a compile flag (not entirely working right now, but that's
the idea). It affects math related datatypes and code only.
Neither Variant nor PackedArray make use of real_t, which is only intended
for math precision, so the term is removed from there to keep only float.
2020-02-24 18:20:53 +00:00
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "motor/target_velocity", PROPERTY_HINT_RANGE, "-200,200,0.01,or_greater,or_lesser"), "set_param", "get_param", PARAM_MOTOR_TARGET_VELOCITY);
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "motor/max_impulse", PROPERTY_HINT_RANGE, "0.01,1024,0.01"), "set_param", "get_param", PARAM_MOTOR_MAX_IMPULSE);
|
2014-09-15 14:33:30 +00:00
|
|
|
|
2017-08-20 15:45:01 +00:00
|
|
|
BIND_ENUM_CONSTANT(PARAM_BIAS);
|
|
|
|
BIND_ENUM_CONSTANT(PARAM_LIMIT_UPPER);
|
|
|
|
BIND_ENUM_CONSTANT(PARAM_LIMIT_LOWER);
|
|
|
|
BIND_ENUM_CONSTANT(PARAM_LIMIT_BIAS);
|
|
|
|
BIND_ENUM_CONSTANT(PARAM_LIMIT_SOFTNESS);
|
|
|
|
BIND_ENUM_CONSTANT(PARAM_LIMIT_RELAXATION);
|
|
|
|
BIND_ENUM_CONSTANT(PARAM_MOTOR_TARGET_VELOCITY);
|
|
|
|
BIND_ENUM_CONSTANT(PARAM_MOTOR_MAX_IMPULSE);
|
|
|
|
BIND_ENUM_CONSTANT(PARAM_MAX);
|
2014-09-15 14:33:30 +00:00
|
|
|
|
2017-08-20 15:45:01 +00:00
|
|
|
BIND_ENUM_CONSTANT(FLAG_USE_LIMIT);
|
|
|
|
BIND_ENUM_CONSTANT(FLAG_ENABLE_MOTOR);
|
|
|
|
BIND_ENUM_CONSTANT(FLAG_MAX);
|
2014-09-15 14:33:30 +00:00
|
|
|
}
|
|
|
|
|
2021-01-29 23:22:12 +00:00
|
|
|
void HingeJoint3D::set_param(Param p_param, real_t p_value) {
|
2017-03-05 15:44:50 +00:00
|
|
|
ERR_FAIL_INDEX(p_param, PARAM_MAX);
|
|
|
|
params[p_param] = p_value;
|
2021-02-09 16:19:03 +00:00
|
|
|
if (is_configured()) {
|
2020-03-27 18:21:27 +00:00
|
|
|
PhysicsServer3D::get_singleton()->hinge_joint_set_param(get_joint(), PhysicsServer3D::HingeJointParam(p_param), p_value);
|
2020-05-14 14:41:43 +00:00
|
|
|
}
|
2014-09-15 14:33:30 +00:00
|
|
|
|
2021-06-23 14:49:50 +00:00
|
|
|
update_gizmos();
|
2014-09-15 14:33:30 +00:00
|
|
|
}
|
2020-05-14 12:29:06 +00:00
|
|
|
|
2021-01-29 23:22:12 +00:00
|
|
|
real_t HingeJoint3D::get_param(Param p_param) const {
|
2017-03-05 15:44:50 +00:00
|
|
|
ERR_FAIL_INDEX_V(p_param, PARAM_MAX, 0);
|
2014-09-15 14:33:30 +00:00
|
|
|
return params[p_param];
|
|
|
|
}
|
|
|
|
|
2020-03-26 21:49:16 +00:00
|
|
|
void HingeJoint3D::set_flag(Flag p_flag, bool p_value) {
|
2017-03-05 15:44:50 +00:00
|
|
|
ERR_FAIL_INDEX(p_flag, FLAG_MAX);
|
|
|
|
flags[p_flag] = p_value;
|
2021-02-09 16:19:03 +00:00
|
|
|
if (is_configured()) {
|
2020-03-27 18:21:27 +00:00
|
|
|
PhysicsServer3D::get_singleton()->hinge_joint_set_flag(get_joint(), PhysicsServer3D::HingeJointFlag(p_flag), p_value);
|
2020-05-14 14:41:43 +00:00
|
|
|
}
|
2014-09-15 14:33:30 +00:00
|
|
|
|
2021-06-23 14:49:50 +00:00
|
|
|
update_gizmos();
|
2014-09-15 14:33:30 +00:00
|
|
|
}
|
2020-05-14 12:29:06 +00:00
|
|
|
|
2020-03-26 21:49:16 +00:00
|
|
|
bool HingeJoint3D::get_flag(Flag p_flag) const {
|
2017-03-05 15:44:50 +00:00
|
|
|
ERR_FAIL_INDEX_V(p_flag, FLAG_MAX, false);
|
2014-09-15 14:33:30 +00:00
|
|
|
return flags[p_flag];
|
|
|
|
}
|
|
|
|
|
2021-02-09 16:19:03 +00:00
|
|
|
void HingeJoint3D::_configure_joint(RID p_joint, PhysicsBody3D *body_a, PhysicsBody3D *body_b) {
|
2020-10-17 05:08:21 +00:00
|
|
|
Transform3D gt = get_global_transform();
|
|
|
|
Transform3D ainv = body_a->get_global_transform().affine_inverse();
|
2014-09-15 14:33:30 +00:00
|
|
|
|
2020-10-17 05:08:21 +00:00
|
|
|
Transform3D local_a = ainv * gt;
|
2014-09-15 14:33:30 +00:00
|
|
|
local_a.orthonormalize();
|
2020-10-17 05:08:21 +00:00
|
|
|
Transform3D local_b = gt;
|
2014-09-15 14:33:30 +00:00
|
|
|
|
|
|
|
if (body_b) {
|
2020-10-17 05:08:21 +00:00
|
|
|
Transform3D binv = body_b->get_global_transform().affine_inverse();
|
2014-09-15 14:33:30 +00:00
|
|
|
local_b = binv * gt;
|
|
|
|
}
|
|
|
|
|
|
|
|
local_b.orthonormalize();
|
|
|
|
|
2021-02-09 16:19:03 +00:00
|
|
|
PhysicsServer3D::get_singleton()->joint_make_hinge(p_joint, body_a->get_rid(), local_a, body_b ? body_b->get_rid() : RID(), local_b);
|
2017-03-05 15:44:50 +00:00
|
|
|
for (int i = 0; i < PARAM_MAX; i++) {
|
2021-02-09 16:19:03 +00:00
|
|
|
PhysicsServer3D::get_singleton()->hinge_joint_set_param(p_joint, PhysicsServer3D::HingeJointParam(i), params[i]);
|
2014-09-15 14:33:30 +00:00
|
|
|
}
|
2017-03-05 15:44:50 +00:00
|
|
|
for (int i = 0; i < FLAG_MAX; i++) {
|
|
|
|
set_flag(Flag(i), flags[i]);
|
2021-02-09 16:19:03 +00:00
|
|
|
PhysicsServer3D::get_singleton()->hinge_joint_set_flag(p_joint, PhysicsServer3D::HingeJointFlag(i), flags[i]);
|
2014-09-15 14:33:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-26 21:49:16 +00:00
|
|
|
HingeJoint3D::HingeJoint3D() {
|
2017-03-05 15:44:50 +00:00
|
|
|
params[PARAM_BIAS] = 0.3;
|
|
|
|
params[PARAM_LIMIT_UPPER] = Math_PI * 0.5;
|
|
|
|
params[PARAM_LIMIT_LOWER] = -Math_PI * 0.5;
|
|
|
|
params[PARAM_LIMIT_BIAS] = 0.3;
|
|
|
|
params[PARAM_LIMIT_SOFTNESS] = 0.9;
|
|
|
|
params[PARAM_LIMIT_RELAXATION] = 1.0;
|
|
|
|
params[PARAM_MOTOR_TARGET_VELOCITY] = 1;
|
|
|
|
params[PARAM_MOTOR_MAX_IMPULSE] = 1;
|
2014-09-15 14:33:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
flags[FLAG_USE_LIMIT] = false;
|
|
|
|
flags[FLAG_ENABLE_MOTOR] = false;
|
2014-09-15 14:33:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////
|
|
|
|
|
|
|
|
//////////////////////////////////
|
|
|
|
|
2021-01-29 23:22:12 +00:00
|
|
|
void SliderJoint3D::_set_upper_limit_angular(real_t p_limit_angular) {
|
2017-03-05 15:44:50 +00:00
|
|
|
set_param(PARAM_ANGULAR_LIMIT_UPPER, Math::deg2rad(p_limit_angular));
|
2014-09-15 14:33:30 +00:00
|
|
|
}
|
|
|
|
|
2021-01-29 23:22:12 +00:00
|
|
|
real_t SliderJoint3D::_get_upper_limit_angular() const {
|
2014-09-15 14:33:30 +00:00
|
|
|
return Math::rad2deg(get_param(PARAM_ANGULAR_LIMIT_UPPER));
|
|
|
|
}
|
|
|
|
|
2021-01-29 23:22:12 +00:00
|
|
|
void SliderJoint3D::_set_lower_limit_angular(real_t p_limit_angular) {
|
2017-03-05 15:44:50 +00:00
|
|
|
set_param(PARAM_ANGULAR_LIMIT_LOWER, Math::deg2rad(p_limit_angular));
|
2014-09-15 14:33:30 +00:00
|
|
|
}
|
|
|
|
|
2021-01-29 23:22:12 +00:00
|
|
|
real_t SliderJoint3D::_get_lower_limit_angular() const {
|
2014-09-15 14:33:30 +00:00
|
|
|
return Math::rad2deg(get_param(PARAM_ANGULAR_LIMIT_LOWER));
|
|
|
|
}
|
|
|
|
|
2020-03-26 21:49:16 +00:00
|
|
|
void SliderJoint3D::_bind_methods() {
|
|
|
|
ClassDB::bind_method(D_METHOD("set_param", "param", "value"), &SliderJoint3D::set_param);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_param", "param"), &SliderJoint3D::get_param);
|
2017-03-05 15:44:50 +00:00
|
|
|
|
2020-03-26 21:49:16 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("_set_upper_limit_angular", "upper_limit_angular"), &SliderJoint3D::_set_upper_limit_angular);
|
|
|
|
ClassDB::bind_method(D_METHOD("_get_upper_limit_angular"), &SliderJoint3D::_get_upper_limit_angular);
|
2017-03-05 15:44:50 +00:00
|
|
|
|
2020-03-26 21:49:16 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("_set_lower_limit_angular", "lower_limit_angular"), &SliderJoint3D::_set_lower_limit_angular);
|
|
|
|
ClassDB::bind_method(D_METHOD("_get_lower_limit_angular"), &SliderJoint3D::_get_lower_limit_angular);
|
2017-03-05 15:44:50 +00:00
|
|
|
|
Variant: Added 64-bit packed arrays, renamed Variant::REAL to FLOAT.
- Renames PackedIntArray to PackedInt32Array.
- Renames PackedFloatArray to PackedFloat32Array.
- Adds PackedInt64Array and PackedFloat64Array.
- Renames Variant::REAL to Variant::FLOAT for consistency.
Packed arrays are for storing large amount of data and creating stuff like
meshes, buffers. textures, etc. Forcing them to be 64 is a huge waste of
memory. That said, many users requested the ability to have 64 bits packed
arrays for their games, so this is just an optional added type.
For Variant, the float datatype is always 64 bits, and exposed as `float`.
We still have `real_t` which is the datatype that can change from 32 to 64
bits depending on a compile flag (not entirely working right now, but that's
the idea). It affects math related datatypes and code only.
Neither Variant nor PackedArray make use of real_t, which is only intended
for math precision, so the term is removed from there to keep only float.
2020-02-24 18:20:53 +00:00
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "linear_limit/upper_distance", PROPERTY_HINT_RANGE, "-1024,1024,0.01"), "set_param", "get_param", PARAM_LINEAR_LIMIT_UPPER);
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "linear_limit/lower_distance", PROPERTY_HINT_RANGE, "-1024,1024,0.01"), "set_param", "get_param", PARAM_LINEAR_LIMIT_LOWER);
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "linear_limit/softness", PROPERTY_HINT_RANGE, "0.01,16.0,0.01"), "set_param", "get_param", PARAM_LINEAR_LIMIT_SOFTNESS);
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "linear_limit/restitution", PROPERTY_HINT_RANGE, "0.01,16.0,0.01"), "set_param", "get_param", PARAM_LINEAR_LIMIT_RESTITUTION);
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "linear_limit/damping", PROPERTY_HINT_RANGE, "0,16.0,0.01"), "set_param", "get_param", PARAM_LINEAR_LIMIT_DAMPING);
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "linear_motion/softness", PROPERTY_HINT_RANGE, "0.01,16.0,0.01"), "set_param", "get_param", PARAM_LINEAR_MOTION_SOFTNESS);
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "linear_motion/restitution", PROPERTY_HINT_RANGE, "0.01,16.0,0.01"), "set_param", "get_param", PARAM_LINEAR_MOTION_RESTITUTION);
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "linear_motion/damping", PROPERTY_HINT_RANGE, "0,16.0,0.01"), "set_param", "get_param", PARAM_LINEAR_MOTION_DAMPING);
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "linear_ortho/softness", PROPERTY_HINT_RANGE, "0.01,16.0,0.01"), "set_param", "get_param", PARAM_LINEAR_ORTHOGONAL_SOFTNESS);
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "linear_ortho/restitution", PROPERTY_HINT_RANGE, "0.01,16.0,0.01"), "set_param", "get_param", PARAM_LINEAR_ORTHOGONAL_RESTITUTION);
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "linear_ortho/damping", PROPERTY_HINT_RANGE, "0,16.0,0.01"), "set_param", "get_param", PARAM_LINEAR_ORTHOGONAL_DAMPING);
|
|
|
|
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "angular_limit/upper_angle", PROPERTY_HINT_RANGE, "-180,180,0.1"), "_set_upper_limit_angular", "_get_upper_limit_angular");
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "angular_limit/lower_angle", PROPERTY_HINT_RANGE, "-180,180,0.1"), "_set_lower_limit_angular", "_get_lower_limit_angular");
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_limit/softness", PROPERTY_HINT_RANGE, "0.01,16.0,0.01"), "set_param", "get_param", PARAM_ANGULAR_LIMIT_SOFTNESS);
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_limit/restitution", PROPERTY_HINT_RANGE, "0.01,16.0,0.01"), "set_param", "get_param", PARAM_ANGULAR_LIMIT_RESTITUTION);
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_limit/damping", PROPERTY_HINT_RANGE, "0,16.0,0.01"), "set_param", "get_param", PARAM_ANGULAR_LIMIT_DAMPING);
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_motion/softness", PROPERTY_HINT_RANGE, "0.01,16.0,0.01"), "set_param", "get_param", PARAM_ANGULAR_MOTION_SOFTNESS);
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_motion/restitution", PROPERTY_HINT_RANGE, "0.01,16.0,0.01"), "set_param", "get_param", PARAM_ANGULAR_MOTION_RESTITUTION);
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_motion/damping", PROPERTY_HINT_RANGE, "0,16.0,0.01"), "set_param", "get_param", PARAM_ANGULAR_MOTION_DAMPING);
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_ortho/softness", PROPERTY_HINT_RANGE, "0.01,16.0,0.01"), "set_param", "get_param", PARAM_ANGULAR_ORTHOGONAL_SOFTNESS);
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_ortho/restitution", PROPERTY_HINT_RANGE, "0.01,16.0,0.01"), "set_param", "get_param", PARAM_ANGULAR_ORTHOGONAL_RESTITUTION);
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_ortho/damping", PROPERTY_HINT_RANGE, "0,16.0,0.01"), "set_param", "get_param", PARAM_ANGULAR_ORTHOGONAL_DAMPING);
|
2017-03-05 15:44:50 +00:00
|
|
|
|
2017-08-20 15:45:01 +00:00
|
|
|
BIND_ENUM_CONSTANT(PARAM_LINEAR_LIMIT_UPPER);
|
|
|
|
BIND_ENUM_CONSTANT(PARAM_LINEAR_LIMIT_LOWER);
|
|
|
|
BIND_ENUM_CONSTANT(PARAM_LINEAR_LIMIT_SOFTNESS);
|
|
|
|
BIND_ENUM_CONSTANT(PARAM_LINEAR_LIMIT_RESTITUTION);
|
|
|
|
BIND_ENUM_CONSTANT(PARAM_LINEAR_LIMIT_DAMPING);
|
|
|
|
BIND_ENUM_CONSTANT(PARAM_LINEAR_MOTION_SOFTNESS);
|
|
|
|
BIND_ENUM_CONSTANT(PARAM_LINEAR_MOTION_RESTITUTION);
|
|
|
|
BIND_ENUM_CONSTANT(PARAM_LINEAR_MOTION_DAMPING);
|
|
|
|
BIND_ENUM_CONSTANT(PARAM_LINEAR_ORTHOGONAL_SOFTNESS);
|
|
|
|
BIND_ENUM_CONSTANT(PARAM_LINEAR_ORTHOGONAL_RESTITUTION);
|
|
|
|
BIND_ENUM_CONSTANT(PARAM_LINEAR_ORTHOGONAL_DAMPING);
|
|
|
|
|
|
|
|
BIND_ENUM_CONSTANT(PARAM_ANGULAR_LIMIT_UPPER);
|
|
|
|
BIND_ENUM_CONSTANT(PARAM_ANGULAR_LIMIT_LOWER);
|
|
|
|
BIND_ENUM_CONSTANT(PARAM_ANGULAR_LIMIT_SOFTNESS);
|
|
|
|
BIND_ENUM_CONSTANT(PARAM_ANGULAR_LIMIT_RESTITUTION);
|
|
|
|
BIND_ENUM_CONSTANT(PARAM_ANGULAR_LIMIT_DAMPING);
|
|
|
|
BIND_ENUM_CONSTANT(PARAM_ANGULAR_MOTION_SOFTNESS);
|
|
|
|
BIND_ENUM_CONSTANT(PARAM_ANGULAR_MOTION_RESTITUTION);
|
|
|
|
BIND_ENUM_CONSTANT(PARAM_ANGULAR_MOTION_DAMPING);
|
|
|
|
BIND_ENUM_CONSTANT(PARAM_ANGULAR_ORTHOGONAL_SOFTNESS);
|
|
|
|
BIND_ENUM_CONSTANT(PARAM_ANGULAR_ORTHOGONAL_RESTITUTION);
|
|
|
|
BIND_ENUM_CONSTANT(PARAM_ANGULAR_ORTHOGONAL_DAMPING);
|
|
|
|
|
|
|
|
BIND_ENUM_CONSTANT(PARAM_MAX);
|
2017-03-05 15:44:50 +00:00
|
|
|
}
|
|
|
|
|
2021-01-29 23:22:12 +00:00
|
|
|
void SliderJoint3D::set_param(Param p_param, real_t p_value) {
|
2017-03-05 15:44:50 +00:00
|
|
|
ERR_FAIL_INDEX(p_param, PARAM_MAX);
|
|
|
|
params[p_param] = p_value;
|
2021-02-09 16:19:03 +00:00
|
|
|
if (is_configured()) {
|
2020-03-27 18:21:27 +00:00
|
|
|
PhysicsServer3D::get_singleton()->slider_joint_set_param(get_joint(), PhysicsServer3D::SliderJointParam(p_param), p_value);
|
2020-05-14 14:41:43 +00:00
|
|
|
}
|
2021-06-23 14:49:50 +00:00
|
|
|
update_gizmos();
|
2014-09-15 14:33:30 +00:00
|
|
|
}
|
2020-05-14 12:29:06 +00:00
|
|
|
|
2021-01-29 23:22:12 +00:00
|
|
|
real_t SliderJoint3D::get_param(Param p_param) const {
|
2017-03-05 15:44:50 +00:00
|
|
|
ERR_FAIL_INDEX_V(p_param, PARAM_MAX, 0);
|
2014-09-15 14:33:30 +00:00
|
|
|
return params[p_param];
|
|
|
|
}
|
|
|
|
|
2021-02-09 16:19:03 +00:00
|
|
|
void SliderJoint3D::_configure_joint(RID p_joint, PhysicsBody3D *body_a, PhysicsBody3D *body_b) {
|
2020-10-17 05:08:21 +00:00
|
|
|
Transform3D gt = get_global_transform();
|
|
|
|
Transform3D ainv = body_a->get_global_transform().affine_inverse();
|
2014-09-15 14:33:30 +00:00
|
|
|
|
2020-10-17 05:08:21 +00:00
|
|
|
Transform3D local_a = ainv * gt;
|
2014-09-15 14:33:30 +00:00
|
|
|
local_a.orthonormalize();
|
2020-10-17 05:08:21 +00:00
|
|
|
Transform3D local_b = gt;
|
2014-09-15 14:33:30 +00:00
|
|
|
|
|
|
|
if (body_b) {
|
2020-10-17 05:08:21 +00:00
|
|
|
Transform3D binv = body_b->get_global_transform().affine_inverse();
|
2014-09-15 14:33:30 +00:00
|
|
|
local_b = binv * gt;
|
|
|
|
}
|
|
|
|
|
|
|
|
local_b.orthonormalize();
|
|
|
|
|
2021-02-09 16:19:03 +00:00
|
|
|
PhysicsServer3D::get_singleton()->joint_make_slider(p_joint, body_a->get_rid(), local_a, body_b ? body_b->get_rid() : RID(), local_b);
|
2017-03-05 15:44:50 +00:00
|
|
|
for (int i = 0; i < PARAM_MAX; i++) {
|
2021-02-09 16:19:03 +00:00
|
|
|
PhysicsServer3D::get_singleton()->slider_joint_set_param(p_joint, PhysicsServer3D::SliderJointParam(i), params[i]);
|
2014-09-15 14:33:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-26 21:49:16 +00:00
|
|
|
SliderJoint3D::SliderJoint3D() {
|
2017-03-05 15:44:50 +00:00
|
|
|
params[PARAM_LINEAR_LIMIT_UPPER] = 1.0;
|
|
|
|
params[PARAM_LINEAR_LIMIT_LOWER] = -1.0;
|
|
|
|
params[PARAM_LINEAR_LIMIT_SOFTNESS] = 1.0;
|
|
|
|
params[PARAM_LINEAR_LIMIT_RESTITUTION] = 0.7;
|
|
|
|
params[PARAM_LINEAR_LIMIT_DAMPING] = 1.0;
|
|
|
|
params[PARAM_LINEAR_MOTION_SOFTNESS] = 1.0;
|
|
|
|
params[PARAM_LINEAR_MOTION_RESTITUTION] = 0.7;
|
|
|
|
params[PARAM_LINEAR_MOTION_DAMPING] = 0; //1.0;
|
|
|
|
params[PARAM_LINEAR_ORTHOGONAL_SOFTNESS] = 1.0;
|
|
|
|
params[PARAM_LINEAR_ORTHOGONAL_RESTITUTION] = 0.7;
|
|
|
|
params[PARAM_LINEAR_ORTHOGONAL_DAMPING] = 1.0;
|
|
|
|
|
|
|
|
params[PARAM_ANGULAR_LIMIT_UPPER] = 0;
|
|
|
|
params[PARAM_ANGULAR_LIMIT_LOWER] = 0;
|
|
|
|
params[PARAM_ANGULAR_LIMIT_SOFTNESS] = 1.0;
|
|
|
|
params[PARAM_ANGULAR_LIMIT_RESTITUTION] = 0.7;
|
|
|
|
params[PARAM_ANGULAR_LIMIT_DAMPING] = 0; //1.0;
|
|
|
|
params[PARAM_ANGULAR_MOTION_SOFTNESS] = 1.0;
|
|
|
|
params[PARAM_ANGULAR_MOTION_RESTITUTION] = 0.7;
|
|
|
|
params[PARAM_ANGULAR_MOTION_DAMPING] = 1.0;
|
|
|
|
params[PARAM_ANGULAR_ORTHOGONAL_SOFTNESS] = 1.0;
|
|
|
|
params[PARAM_ANGULAR_ORTHOGONAL_RESTITUTION] = 0.7;
|
|
|
|
params[PARAM_ANGULAR_ORTHOGONAL_DAMPING] = 1.0;
|
2014-09-15 14:33:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////////////////
|
|
|
|
|
2021-01-29 23:22:12 +00:00
|
|
|
void ConeTwistJoint3D::_set_swing_span(real_t p_limit_angular) {
|
2017-03-05 15:44:50 +00:00
|
|
|
set_param(PARAM_SWING_SPAN, Math::deg2rad(p_limit_angular));
|
2014-09-15 14:33:30 +00:00
|
|
|
}
|
|
|
|
|
2021-01-29 23:22:12 +00:00
|
|
|
real_t ConeTwistJoint3D::_get_swing_span() const {
|
2014-09-15 14:33:30 +00:00
|
|
|
return Math::rad2deg(get_param(PARAM_SWING_SPAN));
|
|
|
|
}
|
|
|
|
|
2021-01-29 23:22:12 +00:00
|
|
|
void ConeTwistJoint3D::_set_twist_span(real_t p_limit_angular) {
|
2017-03-05 15:44:50 +00:00
|
|
|
set_param(PARAM_TWIST_SPAN, Math::deg2rad(p_limit_angular));
|
2014-09-15 14:33:30 +00:00
|
|
|
}
|
|
|
|
|
2021-01-29 23:22:12 +00:00
|
|
|
real_t ConeTwistJoint3D::_get_twist_span() const {
|
2014-09-15 14:33:30 +00:00
|
|
|
return Math::rad2deg(get_param(PARAM_TWIST_SPAN));
|
|
|
|
}
|
|
|
|
|
2020-03-26 21:49:16 +00:00
|
|
|
void ConeTwistJoint3D::_bind_methods() {
|
|
|
|
ClassDB::bind_method(D_METHOD("set_param", "param", "value"), &ConeTwistJoint3D::set_param);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_param", "param"), &ConeTwistJoint3D::get_param);
|
2014-09-15 14:33:30 +00:00
|
|
|
|
2020-03-26 21:49:16 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("_set_swing_span", "swing_span"), &ConeTwistJoint3D::_set_swing_span);
|
|
|
|
ClassDB::bind_method(D_METHOD("_get_swing_span"), &ConeTwistJoint3D::_get_swing_span);
|
2014-09-15 14:33:30 +00:00
|
|
|
|
2020-03-26 21:49:16 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("_set_twist_span", "twist_span"), &ConeTwistJoint3D::_set_twist_span);
|
|
|
|
ClassDB::bind_method(D_METHOD("_get_twist_span"), &ConeTwistJoint3D::_get_twist_span);
|
2014-09-15 14:33:30 +00:00
|
|
|
|
Variant: Added 64-bit packed arrays, renamed Variant::REAL to FLOAT.
- Renames PackedIntArray to PackedInt32Array.
- Renames PackedFloatArray to PackedFloat32Array.
- Adds PackedInt64Array and PackedFloat64Array.
- Renames Variant::REAL to Variant::FLOAT for consistency.
Packed arrays are for storing large amount of data and creating stuff like
meshes, buffers. textures, etc. Forcing them to be 64 is a huge waste of
memory. That said, many users requested the ability to have 64 bits packed
arrays for their games, so this is just an optional added type.
For Variant, the float datatype is always 64 bits, and exposed as `float`.
We still have `real_t` which is the datatype that can change from 32 to 64
bits depending on a compile flag (not entirely working right now, but that's
the idea). It affects math related datatypes and code only.
Neither Variant nor PackedArray make use of real_t, which is only intended
for math precision, so the term is removed from there to keep only float.
2020-02-24 18:20:53 +00:00
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "swing_span", PROPERTY_HINT_RANGE, "-180,180,0.1"), "_set_swing_span", "_get_swing_span");
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "twist_span", PROPERTY_HINT_RANGE, "-40000,40000,0.1"), "_set_twist_span", "_get_twist_span");
|
2014-09-15 14:33:30 +00:00
|
|
|
|
Variant: Added 64-bit packed arrays, renamed Variant::REAL to FLOAT.
- Renames PackedIntArray to PackedInt32Array.
- Renames PackedFloatArray to PackedFloat32Array.
- Adds PackedInt64Array and PackedFloat64Array.
- Renames Variant::REAL to Variant::FLOAT for consistency.
Packed arrays are for storing large amount of data and creating stuff like
meshes, buffers. textures, etc. Forcing them to be 64 is a huge waste of
memory. That said, many users requested the ability to have 64 bits packed
arrays for their games, so this is just an optional added type.
For Variant, the float datatype is always 64 bits, and exposed as `float`.
We still have `real_t` which is the datatype that can change from 32 to 64
bits depending on a compile flag (not entirely working right now, but that's
the idea). It affects math related datatypes and code only.
Neither Variant nor PackedArray make use of real_t, which is only intended
for math precision, so the term is removed from there to keep only float.
2020-02-24 18:20:53 +00:00
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "bias", PROPERTY_HINT_RANGE, "0.01,16.0,0.01"), "set_param", "get_param", PARAM_BIAS);
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "softness", PROPERTY_HINT_RANGE, "0.01,16.0,0.01"), "set_param", "get_param", PARAM_SOFTNESS);
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "relaxation", PROPERTY_HINT_RANGE, "0.01,16.0,0.01"), "set_param", "get_param", PARAM_RELAXATION);
|
2014-09-15 14:33:30 +00:00
|
|
|
|
2017-08-20 15:45:01 +00:00
|
|
|
BIND_ENUM_CONSTANT(PARAM_SWING_SPAN);
|
|
|
|
BIND_ENUM_CONSTANT(PARAM_TWIST_SPAN);
|
|
|
|
BIND_ENUM_CONSTANT(PARAM_BIAS);
|
|
|
|
BIND_ENUM_CONSTANT(PARAM_SOFTNESS);
|
|
|
|
BIND_ENUM_CONSTANT(PARAM_RELAXATION);
|
|
|
|
BIND_ENUM_CONSTANT(PARAM_MAX);
|
2014-09-15 14:33:30 +00:00
|
|
|
}
|
|
|
|
|
2021-01-29 23:22:12 +00:00
|
|
|
void ConeTwistJoint3D::set_param(Param p_param, real_t p_value) {
|
2017-03-05 15:44:50 +00:00
|
|
|
ERR_FAIL_INDEX(p_param, PARAM_MAX);
|
|
|
|
params[p_param] = p_value;
|
2021-02-09 16:19:03 +00:00
|
|
|
if (is_configured()) {
|
2020-03-27 18:21:27 +00:00
|
|
|
PhysicsServer3D::get_singleton()->cone_twist_joint_set_param(get_joint(), PhysicsServer3D::ConeTwistJointParam(p_param), p_value);
|
2020-05-14 14:41:43 +00:00
|
|
|
}
|
2014-09-15 14:33:30 +00:00
|
|
|
|
2021-06-23 14:49:50 +00:00
|
|
|
update_gizmos();
|
2014-09-15 14:33:30 +00:00
|
|
|
}
|
2020-05-14 12:29:06 +00:00
|
|
|
|
2021-01-29 23:22:12 +00:00
|
|
|
real_t ConeTwistJoint3D::get_param(Param p_param) const {
|
2017-03-05 15:44:50 +00:00
|
|
|
ERR_FAIL_INDEX_V(p_param, PARAM_MAX, 0);
|
2014-09-15 14:33:30 +00:00
|
|
|
return params[p_param];
|
|
|
|
}
|
|
|
|
|
2021-02-09 16:19:03 +00:00
|
|
|
void ConeTwistJoint3D::_configure_joint(RID p_joint, PhysicsBody3D *body_a, PhysicsBody3D *body_b) {
|
2020-10-17 05:08:21 +00:00
|
|
|
Transform3D gt = get_global_transform();
|
2014-09-15 14:33:30 +00:00
|
|
|
//Vector3 cone_twistpos = gt.origin;
|
|
|
|
//Vector3 cone_twistdir = gt.basis.get_axis(2);
|
|
|
|
|
2020-10-17 05:08:21 +00:00
|
|
|
Transform3D ainv = body_a->get_global_transform().affine_inverse();
|
2014-09-15 14:33:30 +00:00
|
|
|
|
2020-10-17 05:08:21 +00:00
|
|
|
Transform3D local_a = ainv * gt;
|
2014-09-15 14:33:30 +00:00
|
|
|
local_a.orthonormalize();
|
2020-10-17 05:08:21 +00:00
|
|
|
Transform3D local_b = gt;
|
2014-09-15 14:33:30 +00:00
|
|
|
|
|
|
|
if (body_b) {
|
2020-10-17 05:08:21 +00:00
|
|
|
Transform3D binv = body_b->get_global_transform().affine_inverse();
|
2014-09-15 14:33:30 +00:00
|
|
|
local_b = binv * gt;
|
|
|
|
}
|
|
|
|
|
|
|
|
local_b.orthonormalize();
|
|
|
|
|
2021-02-09 16:19:03 +00:00
|
|
|
PhysicsServer3D::get_singleton()->joint_make_cone_twist(p_joint, body_a->get_rid(), local_a, body_b ? body_b->get_rid() : RID(), local_b);
|
2017-03-05 15:44:50 +00:00
|
|
|
for (int i = 0; i < PARAM_MAX; i++) {
|
2021-02-09 16:19:03 +00:00
|
|
|
PhysicsServer3D::get_singleton()->cone_twist_joint_set_param(p_joint, PhysicsServer3D::ConeTwistJointParam(i), params[i]);
|
2014-09-15 14:33:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-26 21:49:16 +00:00
|
|
|
ConeTwistJoint3D::ConeTwistJoint3D() {
|
2017-03-05 15:44:50 +00:00
|
|
|
params[PARAM_SWING_SPAN] = Math_PI * 0.25;
|
|
|
|
params[PARAM_TWIST_SPAN] = Math_PI;
|
|
|
|
params[PARAM_BIAS] = 0.3;
|
|
|
|
params[PARAM_SOFTNESS] = 0.8;
|
|
|
|
params[PARAM_RELAXATION] = 1.0;
|
2014-09-15 14:33:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
2021-01-29 23:22:12 +00:00
|
|
|
void Generic6DOFJoint3D::_set_angular_hi_limit_x(real_t p_limit_angular) {
|
2017-03-05 15:44:50 +00:00
|
|
|
set_param_x(PARAM_ANGULAR_UPPER_LIMIT, Math::deg2rad(p_limit_angular));
|
2014-09-15 14:33:30 +00:00
|
|
|
}
|
|
|
|
|
2021-01-29 23:22:12 +00:00
|
|
|
real_t Generic6DOFJoint3D::_get_angular_hi_limit_x() const {
|
2014-09-15 14:33:30 +00:00
|
|
|
return Math::rad2deg(get_param_x(PARAM_ANGULAR_UPPER_LIMIT));
|
|
|
|
}
|
|
|
|
|
2021-01-29 23:22:12 +00:00
|
|
|
void Generic6DOFJoint3D::_set_angular_lo_limit_x(real_t p_limit_angular) {
|
2017-03-05 15:44:50 +00:00
|
|
|
set_param_x(PARAM_ANGULAR_LOWER_LIMIT, Math::deg2rad(p_limit_angular));
|
2014-09-15 14:33:30 +00:00
|
|
|
}
|
|
|
|
|
2021-01-29 23:22:12 +00:00
|
|
|
real_t Generic6DOFJoint3D::_get_angular_lo_limit_x() const {
|
2014-09-15 14:33:30 +00:00
|
|
|
return Math::rad2deg(get_param_x(PARAM_ANGULAR_LOWER_LIMIT));
|
|
|
|
}
|
|
|
|
|
2021-01-29 23:22:12 +00:00
|
|
|
void Generic6DOFJoint3D::_set_angular_hi_limit_y(real_t p_limit_angular) {
|
2017-03-05 15:44:50 +00:00
|
|
|
set_param_y(PARAM_ANGULAR_UPPER_LIMIT, Math::deg2rad(p_limit_angular));
|
2014-09-15 14:33:30 +00:00
|
|
|
}
|
|
|
|
|
2021-01-29 23:22:12 +00:00
|
|
|
real_t Generic6DOFJoint3D::_get_angular_hi_limit_y() const {
|
2014-09-15 14:33:30 +00:00
|
|
|
return Math::rad2deg(get_param_y(PARAM_ANGULAR_UPPER_LIMIT));
|
|
|
|
}
|
|
|
|
|
2021-01-29 23:22:12 +00:00
|
|
|
void Generic6DOFJoint3D::_set_angular_lo_limit_y(real_t p_limit_angular) {
|
2017-03-05 15:44:50 +00:00
|
|
|
set_param_y(PARAM_ANGULAR_LOWER_LIMIT, Math::deg2rad(p_limit_angular));
|
2014-09-15 14:33:30 +00:00
|
|
|
}
|
|
|
|
|
2021-01-29 23:22:12 +00:00
|
|
|
real_t Generic6DOFJoint3D::_get_angular_lo_limit_y() const {
|
2014-09-15 14:33:30 +00:00
|
|
|
return Math::rad2deg(get_param_y(PARAM_ANGULAR_LOWER_LIMIT));
|
|
|
|
}
|
|
|
|
|
2021-01-29 23:22:12 +00:00
|
|
|
void Generic6DOFJoint3D::_set_angular_hi_limit_z(real_t p_limit_angular) {
|
2017-03-05 15:44:50 +00:00
|
|
|
set_param_z(PARAM_ANGULAR_UPPER_LIMIT, Math::deg2rad(p_limit_angular));
|
2014-09-15 14:33:30 +00:00
|
|
|
}
|
|
|
|
|
2021-01-29 23:22:12 +00:00
|
|
|
real_t Generic6DOFJoint3D::_get_angular_hi_limit_z() const {
|
2014-09-15 14:33:30 +00:00
|
|
|
return Math::rad2deg(get_param_z(PARAM_ANGULAR_UPPER_LIMIT));
|
|
|
|
}
|
|
|
|
|
2021-01-29 23:22:12 +00:00
|
|
|
void Generic6DOFJoint3D::_set_angular_lo_limit_z(real_t p_limit_angular) {
|
2017-03-05 15:44:50 +00:00
|
|
|
set_param_z(PARAM_ANGULAR_LOWER_LIMIT, Math::deg2rad(p_limit_angular));
|
2014-09-15 14:33:30 +00:00
|
|
|
}
|
|
|
|
|
2021-01-29 23:22:12 +00:00
|
|
|
real_t Generic6DOFJoint3D::_get_angular_lo_limit_z() const {
|
2014-09-15 14:33:30 +00:00
|
|
|
return Math::rad2deg(get_param_z(PARAM_ANGULAR_LOWER_LIMIT));
|
|
|
|
}
|
|
|
|
|
2020-03-26 21:49:16 +00:00
|
|
|
void Generic6DOFJoint3D::_bind_methods() {
|
|
|
|
ClassDB::bind_method(D_METHOD("_set_angular_hi_limit_x", "angle"), &Generic6DOFJoint3D::_set_angular_hi_limit_x);
|
|
|
|
ClassDB::bind_method(D_METHOD("_get_angular_hi_limit_x"), &Generic6DOFJoint3D::_get_angular_hi_limit_x);
|
2017-03-05 15:44:50 +00:00
|
|
|
|
2020-03-26 21:49:16 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("_set_angular_lo_limit_x", "angle"), &Generic6DOFJoint3D::_set_angular_lo_limit_x);
|
|
|
|
ClassDB::bind_method(D_METHOD("_get_angular_lo_limit_x"), &Generic6DOFJoint3D::_get_angular_lo_limit_x);
|
2017-03-05 15:44:50 +00:00
|
|
|
|
2020-03-26 21:49:16 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("_set_angular_hi_limit_y", "angle"), &Generic6DOFJoint3D::_set_angular_hi_limit_y);
|
|
|
|
ClassDB::bind_method(D_METHOD("_get_angular_hi_limit_y"), &Generic6DOFJoint3D::_get_angular_hi_limit_y);
|
2017-03-05 15:44:50 +00:00
|
|
|
|
2020-03-26 21:49:16 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("_set_angular_lo_limit_y", "angle"), &Generic6DOFJoint3D::_set_angular_lo_limit_y);
|
|
|
|
ClassDB::bind_method(D_METHOD("_get_angular_lo_limit_y"), &Generic6DOFJoint3D::_get_angular_lo_limit_y);
|
2017-03-05 15:44:50 +00:00
|
|
|
|
2020-03-26 21:49:16 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("_set_angular_hi_limit_z", "angle"), &Generic6DOFJoint3D::_set_angular_hi_limit_z);
|
|
|
|
ClassDB::bind_method(D_METHOD("_get_angular_hi_limit_z"), &Generic6DOFJoint3D::_get_angular_hi_limit_z);
|
2017-03-05 15:44:50 +00:00
|
|
|
|
2020-03-26 21:49:16 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("_set_angular_lo_limit_z", "angle"), &Generic6DOFJoint3D::_set_angular_lo_limit_z);
|
|
|
|
ClassDB::bind_method(D_METHOD("_get_angular_lo_limit_z"), &Generic6DOFJoint3D::_get_angular_lo_limit_z);
|
2017-03-05 15:44:50 +00:00
|
|
|
|
2020-03-26 21:49:16 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("set_param_x", "param", "value"), &Generic6DOFJoint3D::set_param_x);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_param_x", "param"), &Generic6DOFJoint3D::get_param_x);
|
2017-03-05 15:44:50 +00:00
|
|
|
|
2020-03-26 21:49:16 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("set_param_y", "param", "value"), &Generic6DOFJoint3D::set_param_y);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_param_y", "param"), &Generic6DOFJoint3D::get_param_y);
|
2017-03-05 15:44:50 +00:00
|
|
|
|
2020-03-26 21:49:16 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("set_param_z", "param", "value"), &Generic6DOFJoint3D::set_param_z);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_param_z", "param"), &Generic6DOFJoint3D::get_param_z);
|
2017-03-05 15:44:50 +00:00
|
|
|
|
2020-03-26 21:49:16 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("set_flag_x", "flag", "value"), &Generic6DOFJoint3D::set_flag_x);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_flag_x", "flag"), &Generic6DOFJoint3D::get_flag_x);
|
2017-03-05 15:44:50 +00:00
|
|
|
|
2020-03-26 21:49:16 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("set_flag_y", "flag", "value"), &Generic6DOFJoint3D::set_flag_y);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_flag_y", "flag"), &Generic6DOFJoint3D::get_flag_y);
|
2017-03-05 15:44:50 +00:00
|
|
|
|
2020-03-26 21:49:16 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("set_flag_z", "flag", "value"), &Generic6DOFJoint3D::set_flag_z);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_flag_z", "flag"), &Generic6DOFJoint3D::get_flag_z);
|
2017-03-05 15:44:50 +00:00
|
|
|
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "linear_limit_x/enabled"), "set_flag_x", "get_flag_x", FLAG_ENABLE_LINEAR_LIMIT);
|
Variant: Added 64-bit packed arrays, renamed Variant::REAL to FLOAT.
- Renames PackedIntArray to PackedInt32Array.
- Renames PackedFloatArray to PackedFloat32Array.
- Adds PackedInt64Array and PackedFloat64Array.
- Renames Variant::REAL to Variant::FLOAT for consistency.
Packed arrays are for storing large amount of data and creating stuff like
meshes, buffers. textures, etc. Forcing them to be 64 is a huge waste of
memory. That said, many users requested the ability to have 64 bits packed
arrays for their games, so this is just an optional added type.
For Variant, the float datatype is always 64 bits, and exposed as `float`.
We still have `real_t` which is the datatype that can change from 32 to 64
bits depending on a compile flag (not entirely working right now, but that's
the idea). It affects math related datatypes and code only.
Neither Variant nor PackedArray make use of real_t, which is only intended
for math precision, so the term is removed from there to keep only float.
2020-02-24 18:20:53 +00:00
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "linear_limit_x/upper_distance"), "set_param_x", "get_param_x", PARAM_LINEAR_UPPER_LIMIT);
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "linear_limit_x/lower_distance"), "set_param_x", "get_param_x", PARAM_LINEAR_LOWER_LIMIT);
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "linear_limit_x/softness", PROPERTY_HINT_RANGE, "0.01,16,0.01"), "set_param_x", "get_param_x", PARAM_LINEAR_LIMIT_SOFTNESS);
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "linear_limit_x/restitution", PROPERTY_HINT_RANGE, "0.01,16,0.01"), "set_param_x", "get_param_x", PARAM_LINEAR_RESTITUTION);
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "linear_limit_x/damping", PROPERTY_HINT_RANGE, "0.01,16,0.01"), "set_param_x", "get_param_x", PARAM_LINEAR_DAMPING);
|
2018-03-16 12:07:52 +00:00
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "linear_motor_x/enabled"), "set_flag_x", "get_flag_x", FLAG_ENABLE_LINEAR_MOTOR);
|
Variant: Added 64-bit packed arrays, renamed Variant::REAL to FLOAT.
- Renames PackedIntArray to PackedInt32Array.
- Renames PackedFloatArray to PackedFloat32Array.
- Adds PackedInt64Array and PackedFloat64Array.
- Renames Variant::REAL to Variant::FLOAT for consistency.
Packed arrays are for storing large amount of data and creating stuff like
meshes, buffers. textures, etc. Forcing them to be 64 is a huge waste of
memory. That said, many users requested the ability to have 64 bits packed
arrays for their games, so this is just an optional added type.
For Variant, the float datatype is always 64 bits, and exposed as `float`.
We still have `real_t` which is the datatype that can change from 32 to 64
bits depending on a compile flag (not entirely working right now, but that's
the idea). It affects math related datatypes and code only.
Neither Variant nor PackedArray make use of real_t, which is only intended
for math precision, so the term is removed from there to keep only float.
2020-02-24 18:20:53 +00:00
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "linear_motor_x/target_velocity"), "set_param_x", "get_param_x", PARAM_LINEAR_MOTOR_TARGET_VELOCITY);
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "linear_motor_x/force_limit"), "set_param_x", "get_param_x", PARAM_LINEAR_MOTOR_FORCE_LIMIT);
|
2018-11-09 11:58:57 +00:00
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "linear_spring_x/enabled"), "set_flag_x", "get_flag_x", FLAG_ENABLE_LINEAR_SPRING);
|
Variant: Added 64-bit packed arrays, renamed Variant::REAL to FLOAT.
- Renames PackedIntArray to PackedInt32Array.
- Renames PackedFloatArray to PackedFloat32Array.
- Adds PackedInt64Array and PackedFloat64Array.
- Renames Variant::REAL to Variant::FLOAT for consistency.
Packed arrays are for storing large amount of data and creating stuff like
meshes, buffers. textures, etc. Forcing them to be 64 is a huge waste of
memory. That said, many users requested the ability to have 64 bits packed
arrays for their games, so this is just an optional added type.
For Variant, the float datatype is always 64 bits, and exposed as `float`.
We still have `real_t` which is the datatype that can change from 32 to 64
bits depending on a compile flag (not entirely working right now, but that's
the idea). It affects math related datatypes and code only.
Neither Variant nor PackedArray make use of real_t, which is only intended
for math precision, so the term is removed from there to keep only float.
2020-02-24 18:20:53 +00:00
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "linear_spring_x/stiffness"), "set_param_x", "get_param_x", PARAM_LINEAR_SPRING_STIFFNESS);
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "linear_spring_x/damping"), "set_param_x", "get_param_x", PARAM_LINEAR_SPRING_DAMPING);
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "linear_spring_x/equilibrium_point"), "set_param_x", "get_param_x", PARAM_LINEAR_SPRING_EQUILIBRIUM_POINT);
|
2018-11-09 11:58:57 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "angular_limit_x/enabled"), "set_flag_x", "get_flag_x", FLAG_ENABLE_ANGULAR_LIMIT);
|
Variant: Added 64-bit packed arrays, renamed Variant::REAL to FLOAT.
- Renames PackedIntArray to PackedInt32Array.
- Renames PackedFloatArray to PackedFloat32Array.
- Adds PackedInt64Array and PackedFloat64Array.
- Renames Variant::REAL to Variant::FLOAT for consistency.
Packed arrays are for storing large amount of data and creating stuff like
meshes, buffers. textures, etc. Forcing them to be 64 is a huge waste of
memory. That said, many users requested the ability to have 64 bits packed
arrays for their games, so this is just an optional added type.
For Variant, the float datatype is always 64 bits, and exposed as `float`.
We still have `real_t` which is the datatype that can change from 32 to 64
bits depending on a compile flag (not entirely working right now, but that's
the idea). It affects math related datatypes and code only.
Neither Variant nor PackedArray make use of real_t, which is only intended
for math precision, so the term is removed from there to keep only float.
2020-02-24 18:20:53 +00:00
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "angular_limit_x/upper_angle", PROPERTY_HINT_RANGE, "-180,180,0.01"), "_set_angular_hi_limit_x", "_get_angular_hi_limit_x");
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "angular_limit_x/lower_angle", PROPERTY_HINT_RANGE, "-180,180,0.01"), "_set_angular_lo_limit_x", "_get_angular_lo_limit_x");
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_limit_x/softness", PROPERTY_HINT_RANGE, "0.01,16,0.01"), "set_param_x", "get_param_x", PARAM_ANGULAR_LIMIT_SOFTNESS);
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_limit_x/restitution", PROPERTY_HINT_RANGE, "0.01,16,0.01"), "set_param_x", "get_param_x", PARAM_ANGULAR_RESTITUTION);
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_limit_x/damping", PROPERTY_HINT_RANGE, "0.01,16,0.01"), "set_param_x", "get_param_x", PARAM_ANGULAR_DAMPING);
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_limit_x/force_limit"), "set_param_x", "get_param_x", PARAM_ANGULAR_FORCE_LIMIT);
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_limit_x/erp"), "set_param_x", "get_param_x", PARAM_ANGULAR_ERP);
|
2017-03-05 15:44:50 +00:00
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "angular_motor_x/enabled"), "set_flag_x", "get_flag_x", FLAG_ENABLE_MOTOR);
|
Variant: Added 64-bit packed arrays, renamed Variant::REAL to FLOAT.
- Renames PackedIntArray to PackedInt32Array.
- Renames PackedFloatArray to PackedFloat32Array.
- Adds PackedInt64Array and PackedFloat64Array.
- Renames Variant::REAL to Variant::FLOAT for consistency.
Packed arrays are for storing large amount of data and creating stuff like
meshes, buffers. textures, etc. Forcing them to be 64 is a huge waste of
memory. That said, many users requested the ability to have 64 bits packed
arrays for their games, so this is just an optional added type.
For Variant, the float datatype is always 64 bits, and exposed as `float`.
We still have `real_t` which is the datatype that can change from 32 to 64
bits depending on a compile flag (not entirely working right now, but that's
the idea). It affects math related datatypes and code only.
Neither Variant nor PackedArray make use of real_t, which is only intended
for math precision, so the term is removed from there to keep only float.
2020-02-24 18:20:53 +00:00
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_motor_x/target_velocity"), "set_param_x", "get_param_x", PARAM_ANGULAR_MOTOR_TARGET_VELOCITY);
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_motor_x/force_limit"), "set_param_x", "get_param_x", PARAM_ANGULAR_MOTOR_FORCE_LIMIT);
|
2018-11-09 11:58:57 +00:00
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "angular_spring_x/enabled"), "set_flag_x", "get_flag_x", FLAG_ENABLE_ANGULAR_SPRING);
|
Variant: Added 64-bit packed arrays, renamed Variant::REAL to FLOAT.
- Renames PackedIntArray to PackedInt32Array.
- Renames PackedFloatArray to PackedFloat32Array.
- Adds PackedInt64Array and PackedFloat64Array.
- Renames Variant::REAL to Variant::FLOAT for consistency.
Packed arrays are for storing large amount of data and creating stuff like
meshes, buffers. textures, etc. Forcing them to be 64 is a huge waste of
memory. That said, many users requested the ability to have 64 bits packed
arrays for their games, so this is just an optional added type.
For Variant, the float datatype is always 64 bits, and exposed as `float`.
We still have `real_t` which is the datatype that can change from 32 to 64
bits depending on a compile flag (not entirely working right now, but that's
the idea). It affects math related datatypes and code only.
Neither Variant nor PackedArray make use of real_t, which is only intended
for math precision, so the term is removed from there to keep only float.
2020-02-24 18:20:53 +00:00
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_spring_x/stiffness"), "set_param_x", "get_param_x", PARAM_ANGULAR_SPRING_STIFFNESS);
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_spring_x/damping"), "set_param_x", "get_param_x", PARAM_ANGULAR_SPRING_DAMPING);
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_spring_x/equilibrium_point"), "set_param_x", "get_param_x", PARAM_ANGULAR_SPRING_EQUILIBRIUM_POINT);
|
2017-03-05 15:44:50 +00:00
|
|
|
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "linear_limit_y/enabled"), "set_flag_y", "get_flag_y", FLAG_ENABLE_LINEAR_LIMIT);
|
Variant: Added 64-bit packed arrays, renamed Variant::REAL to FLOAT.
- Renames PackedIntArray to PackedInt32Array.
- Renames PackedFloatArray to PackedFloat32Array.
- Adds PackedInt64Array and PackedFloat64Array.
- Renames Variant::REAL to Variant::FLOAT for consistency.
Packed arrays are for storing large amount of data and creating stuff like
meshes, buffers. textures, etc. Forcing them to be 64 is a huge waste of
memory. That said, many users requested the ability to have 64 bits packed
arrays for their games, so this is just an optional added type.
For Variant, the float datatype is always 64 bits, and exposed as `float`.
We still have `real_t` which is the datatype that can change from 32 to 64
bits depending on a compile flag (not entirely working right now, but that's
the idea). It affects math related datatypes and code only.
Neither Variant nor PackedArray make use of real_t, which is only intended
for math precision, so the term is removed from there to keep only float.
2020-02-24 18:20:53 +00:00
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "linear_limit_y/upper_distance"), "set_param_y", "get_param_y", PARAM_LINEAR_UPPER_LIMIT);
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "linear_limit_y/lower_distance"), "set_param_y", "get_param_y", PARAM_LINEAR_LOWER_LIMIT);
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "linear_limit_y/softness", PROPERTY_HINT_RANGE, "0.01,16,0.01"), "set_param_y", "get_param_y", PARAM_LINEAR_LIMIT_SOFTNESS);
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "linear_limit_y/restitution", PROPERTY_HINT_RANGE, "0.01,16,0.01"), "set_param_y", "get_param_y", PARAM_LINEAR_RESTITUTION);
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "linear_limit_y/damping", PROPERTY_HINT_RANGE, "0.01,16,0.01"), "set_param_y", "get_param_y", PARAM_LINEAR_DAMPING);
|
2018-03-16 12:07:52 +00:00
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "linear_motor_y/enabled"), "set_flag_y", "get_flag_y", FLAG_ENABLE_LINEAR_MOTOR);
|
Variant: Added 64-bit packed arrays, renamed Variant::REAL to FLOAT.
- Renames PackedIntArray to PackedInt32Array.
- Renames PackedFloatArray to PackedFloat32Array.
- Adds PackedInt64Array and PackedFloat64Array.
- Renames Variant::REAL to Variant::FLOAT for consistency.
Packed arrays are for storing large amount of data and creating stuff like
meshes, buffers. textures, etc. Forcing them to be 64 is a huge waste of
memory. That said, many users requested the ability to have 64 bits packed
arrays for their games, so this is just an optional added type.
For Variant, the float datatype is always 64 bits, and exposed as `float`.
We still have `real_t` which is the datatype that can change from 32 to 64
bits depending on a compile flag (not entirely working right now, but that's
the idea). It affects math related datatypes and code only.
Neither Variant nor PackedArray make use of real_t, which is only intended
for math precision, so the term is removed from there to keep only float.
2020-02-24 18:20:53 +00:00
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "linear_motor_y/target_velocity"), "set_param_y", "get_param_y", PARAM_LINEAR_MOTOR_TARGET_VELOCITY);
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "linear_motor_y/force_limit"), "set_param_y", "get_param_y", PARAM_LINEAR_MOTOR_FORCE_LIMIT);
|
2018-11-09 11:58:57 +00:00
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "linear_spring_y/enabled"), "set_flag_y", "get_flag_y", FLAG_ENABLE_LINEAR_SPRING);
|
Variant: Added 64-bit packed arrays, renamed Variant::REAL to FLOAT.
- Renames PackedIntArray to PackedInt32Array.
- Renames PackedFloatArray to PackedFloat32Array.
- Adds PackedInt64Array and PackedFloat64Array.
- Renames Variant::REAL to Variant::FLOAT for consistency.
Packed arrays are for storing large amount of data and creating stuff like
meshes, buffers. textures, etc. Forcing them to be 64 is a huge waste of
memory. That said, many users requested the ability to have 64 bits packed
arrays for their games, so this is just an optional added type.
For Variant, the float datatype is always 64 bits, and exposed as `float`.
We still have `real_t` which is the datatype that can change from 32 to 64
bits depending on a compile flag (not entirely working right now, but that's
the idea). It affects math related datatypes and code only.
Neither Variant nor PackedArray make use of real_t, which is only intended
for math precision, so the term is removed from there to keep only float.
2020-02-24 18:20:53 +00:00
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "linear_spring_y/stiffness"), "set_param_y", "get_param_y", PARAM_LINEAR_SPRING_STIFFNESS);
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "linear_spring_y/damping"), "set_param_y", "get_param_y", PARAM_LINEAR_SPRING_DAMPING);
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "linear_spring_y/equilibrium_point"), "set_param_y", "get_param_y", PARAM_LINEAR_SPRING_EQUILIBRIUM_POINT);
|
2017-03-05 15:44:50 +00:00
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "angular_limit_y/enabled"), "set_flag_y", "get_flag_y", FLAG_ENABLE_ANGULAR_LIMIT);
|
Variant: Added 64-bit packed arrays, renamed Variant::REAL to FLOAT.
- Renames PackedIntArray to PackedInt32Array.
- Renames PackedFloatArray to PackedFloat32Array.
- Adds PackedInt64Array and PackedFloat64Array.
- Renames Variant::REAL to Variant::FLOAT for consistency.
Packed arrays are for storing large amount of data and creating stuff like
meshes, buffers. textures, etc. Forcing them to be 64 is a huge waste of
memory. That said, many users requested the ability to have 64 bits packed
arrays for their games, so this is just an optional added type.
For Variant, the float datatype is always 64 bits, and exposed as `float`.
We still have `real_t` which is the datatype that can change from 32 to 64
bits depending on a compile flag (not entirely working right now, but that's
the idea). It affects math related datatypes and code only.
Neither Variant nor PackedArray make use of real_t, which is only intended
for math precision, so the term is removed from there to keep only float.
2020-02-24 18:20:53 +00:00
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "angular_limit_y/upper_angle", PROPERTY_HINT_RANGE, "-180,180,0.01"), "_set_angular_hi_limit_y", "_get_angular_hi_limit_y");
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "angular_limit_y/lower_angle", PROPERTY_HINT_RANGE, "-180,180,0.01"), "_set_angular_lo_limit_y", "_get_angular_lo_limit_y");
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_limit_y/softness", PROPERTY_HINT_RANGE, "0.01,16,0.01"), "set_param_y", "get_param_y", PARAM_ANGULAR_LIMIT_SOFTNESS);
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_limit_y/restitution", PROPERTY_HINT_RANGE, "0.01,16,0.01"), "set_param_y", "get_param_y", PARAM_ANGULAR_RESTITUTION);
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_limit_y/damping", PROPERTY_HINT_RANGE, "0.01,16,0.01"), "set_param_y", "get_param_y", PARAM_ANGULAR_DAMPING);
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_limit_y/force_limit"), "set_param_y", "get_param_y", PARAM_ANGULAR_FORCE_LIMIT);
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_limit_y/erp"), "set_param_y", "get_param_y", PARAM_ANGULAR_ERP);
|
2017-03-05 15:44:50 +00:00
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "angular_motor_y/enabled"), "set_flag_y", "get_flag_y", FLAG_ENABLE_MOTOR);
|
Variant: Added 64-bit packed arrays, renamed Variant::REAL to FLOAT.
- Renames PackedIntArray to PackedInt32Array.
- Renames PackedFloatArray to PackedFloat32Array.
- Adds PackedInt64Array and PackedFloat64Array.
- Renames Variant::REAL to Variant::FLOAT for consistency.
Packed arrays are for storing large amount of data and creating stuff like
meshes, buffers. textures, etc. Forcing them to be 64 is a huge waste of
memory. That said, many users requested the ability to have 64 bits packed
arrays for their games, so this is just an optional added type.
For Variant, the float datatype is always 64 bits, and exposed as `float`.
We still have `real_t` which is the datatype that can change from 32 to 64
bits depending on a compile flag (not entirely working right now, but that's
the idea). It affects math related datatypes and code only.
Neither Variant nor PackedArray make use of real_t, which is only intended
for math precision, so the term is removed from there to keep only float.
2020-02-24 18:20:53 +00:00
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_motor_y/target_velocity"), "set_param_y", "get_param_y", PARAM_ANGULAR_MOTOR_TARGET_VELOCITY);
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_motor_y/force_limit"), "set_param_y", "get_param_y", PARAM_ANGULAR_MOTOR_FORCE_LIMIT);
|
2018-11-09 11:58:57 +00:00
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "angular_spring_y/enabled"), "set_flag_y", "get_flag_y", FLAG_ENABLE_ANGULAR_SPRING);
|
Variant: Added 64-bit packed arrays, renamed Variant::REAL to FLOAT.
- Renames PackedIntArray to PackedInt32Array.
- Renames PackedFloatArray to PackedFloat32Array.
- Adds PackedInt64Array and PackedFloat64Array.
- Renames Variant::REAL to Variant::FLOAT for consistency.
Packed arrays are for storing large amount of data and creating stuff like
meshes, buffers. textures, etc. Forcing them to be 64 is a huge waste of
memory. That said, many users requested the ability to have 64 bits packed
arrays for their games, so this is just an optional added type.
For Variant, the float datatype is always 64 bits, and exposed as `float`.
We still have `real_t` which is the datatype that can change from 32 to 64
bits depending on a compile flag (not entirely working right now, but that's
the idea). It affects math related datatypes and code only.
Neither Variant nor PackedArray make use of real_t, which is only intended
for math precision, so the term is removed from there to keep only float.
2020-02-24 18:20:53 +00:00
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_spring_y/stiffness"), "set_param_y", "get_param_y", PARAM_ANGULAR_SPRING_STIFFNESS);
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_spring_y/damping"), "set_param_y", "get_param_y", PARAM_ANGULAR_SPRING_DAMPING);
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_spring_y/equilibrium_point"), "set_param_y", "get_param_y", PARAM_ANGULAR_SPRING_EQUILIBRIUM_POINT);
|
2017-03-05 15:44:50 +00:00
|
|
|
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "linear_limit_z/enabled"), "set_flag_z", "get_flag_z", FLAG_ENABLE_LINEAR_LIMIT);
|
Variant: Added 64-bit packed arrays, renamed Variant::REAL to FLOAT.
- Renames PackedIntArray to PackedInt32Array.
- Renames PackedFloatArray to PackedFloat32Array.
- Adds PackedInt64Array and PackedFloat64Array.
- Renames Variant::REAL to Variant::FLOAT for consistency.
Packed arrays are for storing large amount of data and creating stuff like
meshes, buffers. textures, etc. Forcing them to be 64 is a huge waste of
memory. That said, many users requested the ability to have 64 bits packed
arrays for their games, so this is just an optional added type.
For Variant, the float datatype is always 64 bits, and exposed as `float`.
We still have `real_t` which is the datatype that can change from 32 to 64
bits depending on a compile flag (not entirely working right now, but that's
the idea). It affects math related datatypes and code only.
Neither Variant nor PackedArray make use of real_t, which is only intended
for math precision, so the term is removed from there to keep only float.
2020-02-24 18:20:53 +00:00
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "linear_limit_z/upper_distance"), "set_param_z", "get_param_z", PARAM_LINEAR_UPPER_LIMIT);
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "linear_limit_z/lower_distance"), "set_param_z", "get_param_z", PARAM_LINEAR_LOWER_LIMIT);
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "linear_limit_z/softness", PROPERTY_HINT_RANGE, "0.01,16,0.01"), "set_param_z", "get_param_z", PARAM_LINEAR_LIMIT_SOFTNESS);
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "linear_limit_z/restitution", PROPERTY_HINT_RANGE, "0.01,16,0.01"), "set_param_z", "get_param_z", PARAM_LINEAR_RESTITUTION);
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "linear_limit_z/damping", PROPERTY_HINT_RANGE, "0.01,16,0.01"), "set_param_z", "get_param_z", PARAM_LINEAR_DAMPING);
|
2018-03-16 12:07:52 +00:00
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "linear_motor_z/enabled"), "set_flag_z", "get_flag_z", FLAG_ENABLE_LINEAR_MOTOR);
|
Variant: Added 64-bit packed arrays, renamed Variant::REAL to FLOAT.
- Renames PackedIntArray to PackedInt32Array.
- Renames PackedFloatArray to PackedFloat32Array.
- Adds PackedInt64Array and PackedFloat64Array.
- Renames Variant::REAL to Variant::FLOAT for consistency.
Packed arrays are for storing large amount of data and creating stuff like
meshes, buffers. textures, etc. Forcing them to be 64 is a huge waste of
memory. That said, many users requested the ability to have 64 bits packed
arrays for their games, so this is just an optional added type.
For Variant, the float datatype is always 64 bits, and exposed as `float`.
We still have `real_t` which is the datatype that can change from 32 to 64
bits depending on a compile flag (not entirely working right now, but that's
the idea). It affects math related datatypes and code only.
Neither Variant nor PackedArray make use of real_t, which is only intended
for math precision, so the term is removed from there to keep only float.
2020-02-24 18:20:53 +00:00
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "linear_motor_z/target_velocity"), "set_param_z", "get_param_z", PARAM_LINEAR_MOTOR_TARGET_VELOCITY);
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "linear_motor_z/force_limit"), "set_param_z", "get_param_z", PARAM_LINEAR_MOTOR_FORCE_LIMIT);
|
2018-11-09 11:58:57 +00:00
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "linear_spring_z/enabled"), "set_flag_z", "get_flag_z", FLAG_ENABLE_LINEAR_SPRING);
|
Variant: Added 64-bit packed arrays, renamed Variant::REAL to FLOAT.
- Renames PackedIntArray to PackedInt32Array.
- Renames PackedFloatArray to PackedFloat32Array.
- Adds PackedInt64Array and PackedFloat64Array.
- Renames Variant::REAL to Variant::FLOAT for consistency.
Packed arrays are for storing large amount of data and creating stuff like
meshes, buffers. textures, etc. Forcing them to be 64 is a huge waste of
memory. That said, many users requested the ability to have 64 bits packed
arrays for their games, so this is just an optional added type.
For Variant, the float datatype is always 64 bits, and exposed as `float`.
We still have `real_t` which is the datatype that can change from 32 to 64
bits depending on a compile flag (not entirely working right now, but that's
the idea). It affects math related datatypes and code only.
Neither Variant nor PackedArray make use of real_t, which is only intended
for math precision, so the term is removed from there to keep only float.
2020-02-24 18:20:53 +00:00
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "linear_spring_z/stiffness"), "set_param_z", "get_param_z", PARAM_LINEAR_SPRING_STIFFNESS);
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "linear_spring_z/damping"), "set_param_z", "get_param_z", PARAM_LINEAR_SPRING_DAMPING);
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "linear_spring_z/equilibrium_point"), "set_param_z", "get_param_z", PARAM_LINEAR_SPRING_EQUILIBRIUM_POINT);
|
2017-03-05 15:44:50 +00:00
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "angular_limit_z/enabled"), "set_flag_z", "get_flag_z", FLAG_ENABLE_ANGULAR_LIMIT);
|
Variant: Added 64-bit packed arrays, renamed Variant::REAL to FLOAT.
- Renames PackedIntArray to PackedInt32Array.
- Renames PackedFloatArray to PackedFloat32Array.
- Adds PackedInt64Array and PackedFloat64Array.
- Renames Variant::REAL to Variant::FLOAT for consistency.
Packed arrays are for storing large amount of data and creating stuff like
meshes, buffers. textures, etc. Forcing them to be 64 is a huge waste of
memory. That said, many users requested the ability to have 64 bits packed
arrays for their games, so this is just an optional added type.
For Variant, the float datatype is always 64 bits, and exposed as `float`.
We still have `real_t` which is the datatype that can change from 32 to 64
bits depending on a compile flag (not entirely working right now, but that's
the idea). It affects math related datatypes and code only.
Neither Variant nor PackedArray make use of real_t, which is only intended
for math precision, so the term is removed from there to keep only float.
2020-02-24 18:20:53 +00:00
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "angular_limit_z/upper_angle", PROPERTY_HINT_RANGE, "-180,180,0.01"), "_set_angular_hi_limit_z", "_get_angular_hi_limit_z");
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "angular_limit_z/lower_angle", PROPERTY_HINT_RANGE, "-180,180,0.01"), "_set_angular_lo_limit_z", "_get_angular_lo_limit_z");
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_limit_z/softness", PROPERTY_HINT_RANGE, "0.01,16,0.01"), "set_param_z", "get_param_z", PARAM_ANGULAR_LIMIT_SOFTNESS);
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_limit_z/restitution", PROPERTY_HINT_RANGE, "0.01,16,0.01"), "set_param_z", "get_param_z", PARAM_ANGULAR_RESTITUTION);
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_limit_z/damping", PROPERTY_HINT_RANGE, "0.01,16,0.01"), "set_param_z", "get_param_z", PARAM_ANGULAR_DAMPING);
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_limit_z/force_limit"), "set_param_z", "get_param_z", PARAM_ANGULAR_FORCE_LIMIT);
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_limit_z/erp"), "set_param_z", "get_param_z", PARAM_ANGULAR_ERP);
|
2017-03-05 15:44:50 +00:00
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "angular_motor_z/enabled"), "set_flag_z", "get_flag_z", FLAG_ENABLE_MOTOR);
|
Variant: Added 64-bit packed arrays, renamed Variant::REAL to FLOAT.
- Renames PackedIntArray to PackedInt32Array.
- Renames PackedFloatArray to PackedFloat32Array.
- Adds PackedInt64Array and PackedFloat64Array.
- Renames Variant::REAL to Variant::FLOAT for consistency.
Packed arrays are for storing large amount of data and creating stuff like
meshes, buffers. textures, etc. Forcing them to be 64 is a huge waste of
memory. That said, many users requested the ability to have 64 bits packed
arrays for their games, so this is just an optional added type.
For Variant, the float datatype is always 64 bits, and exposed as `float`.
We still have `real_t` which is the datatype that can change from 32 to 64
bits depending on a compile flag (not entirely working right now, but that's
the idea). It affects math related datatypes and code only.
Neither Variant nor PackedArray make use of real_t, which is only intended
for math precision, so the term is removed from there to keep only float.
2020-02-24 18:20:53 +00:00
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_motor_z/target_velocity"), "set_param_z", "get_param_z", PARAM_ANGULAR_MOTOR_TARGET_VELOCITY);
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_motor_z/force_limit"), "set_param_z", "get_param_z", PARAM_ANGULAR_MOTOR_FORCE_LIMIT);
|
2018-11-09 11:58:57 +00:00
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "angular_spring_z/enabled"), "set_flag_z", "get_flag_z", FLAG_ENABLE_ANGULAR_SPRING);
|
Variant: Added 64-bit packed arrays, renamed Variant::REAL to FLOAT.
- Renames PackedIntArray to PackedInt32Array.
- Renames PackedFloatArray to PackedFloat32Array.
- Adds PackedInt64Array and PackedFloat64Array.
- Renames Variant::REAL to Variant::FLOAT for consistency.
Packed arrays are for storing large amount of data and creating stuff like
meshes, buffers. textures, etc. Forcing them to be 64 is a huge waste of
memory. That said, many users requested the ability to have 64 bits packed
arrays for their games, so this is just an optional added type.
For Variant, the float datatype is always 64 bits, and exposed as `float`.
We still have `real_t` which is the datatype that can change from 32 to 64
bits depending on a compile flag (not entirely working right now, but that's
the idea). It affects math related datatypes and code only.
Neither Variant nor PackedArray make use of real_t, which is only intended
for math precision, so the term is removed from there to keep only float.
2020-02-24 18:20:53 +00:00
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_spring_z/stiffness"), "set_param_z", "get_param_z", PARAM_ANGULAR_SPRING_STIFFNESS);
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_spring_z/damping"), "set_param_z", "get_param_z", PARAM_ANGULAR_SPRING_DAMPING);
|
|
|
|
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "angular_spring_z/equilibrium_point"), "set_param_z", "get_param_z", PARAM_ANGULAR_SPRING_EQUILIBRIUM_POINT);
|
2017-03-05 15:44:50 +00:00
|
|
|
|
2017-08-20 15:45:01 +00:00
|
|
|
BIND_ENUM_CONSTANT(PARAM_LINEAR_LOWER_LIMIT);
|
|
|
|
BIND_ENUM_CONSTANT(PARAM_LINEAR_UPPER_LIMIT);
|
|
|
|
BIND_ENUM_CONSTANT(PARAM_LINEAR_LIMIT_SOFTNESS);
|
|
|
|
BIND_ENUM_CONSTANT(PARAM_LINEAR_RESTITUTION);
|
|
|
|
BIND_ENUM_CONSTANT(PARAM_LINEAR_DAMPING);
|
2018-03-16 12:07:52 +00:00
|
|
|
BIND_ENUM_CONSTANT(PARAM_LINEAR_MOTOR_TARGET_VELOCITY);
|
|
|
|
BIND_ENUM_CONSTANT(PARAM_LINEAR_MOTOR_FORCE_LIMIT);
|
2020-05-02 11:48:00 +00:00
|
|
|
BIND_ENUM_CONSTANT(PARAM_LINEAR_SPRING_STIFFNESS);
|
|
|
|
BIND_ENUM_CONSTANT(PARAM_LINEAR_SPRING_DAMPING);
|
|
|
|
BIND_ENUM_CONSTANT(PARAM_LINEAR_SPRING_EQUILIBRIUM_POINT);
|
2017-08-20 15:45:01 +00:00
|
|
|
BIND_ENUM_CONSTANT(PARAM_ANGULAR_LOWER_LIMIT);
|
|
|
|
BIND_ENUM_CONSTANT(PARAM_ANGULAR_UPPER_LIMIT);
|
|
|
|
BIND_ENUM_CONSTANT(PARAM_ANGULAR_LIMIT_SOFTNESS);
|
|
|
|
BIND_ENUM_CONSTANT(PARAM_ANGULAR_DAMPING);
|
|
|
|
BIND_ENUM_CONSTANT(PARAM_ANGULAR_RESTITUTION);
|
|
|
|
BIND_ENUM_CONSTANT(PARAM_ANGULAR_FORCE_LIMIT);
|
|
|
|
BIND_ENUM_CONSTANT(PARAM_ANGULAR_ERP);
|
|
|
|
BIND_ENUM_CONSTANT(PARAM_ANGULAR_MOTOR_TARGET_VELOCITY);
|
|
|
|
BIND_ENUM_CONSTANT(PARAM_ANGULAR_MOTOR_FORCE_LIMIT);
|
2020-05-02 11:48:00 +00:00
|
|
|
BIND_ENUM_CONSTANT(PARAM_ANGULAR_SPRING_STIFFNESS);
|
|
|
|
BIND_ENUM_CONSTANT(PARAM_ANGULAR_SPRING_DAMPING);
|
|
|
|
BIND_ENUM_CONSTANT(PARAM_ANGULAR_SPRING_EQUILIBRIUM_POINT);
|
2017-08-20 15:45:01 +00:00
|
|
|
BIND_ENUM_CONSTANT(PARAM_MAX);
|
|
|
|
|
|
|
|
BIND_ENUM_CONSTANT(FLAG_ENABLE_LINEAR_LIMIT);
|
|
|
|
BIND_ENUM_CONSTANT(FLAG_ENABLE_ANGULAR_LIMIT);
|
2018-11-09 11:58:57 +00:00
|
|
|
BIND_ENUM_CONSTANT(FLAG_ENABLE_LINEAR_SPRING);
|
|
|
|
BIND_ENUM_CONSTANT(FLAG_ENABLE_ANGULAR_SPRING);
|
2017-08-20 15:45:01 +00:00
|
|
|
BIND_ENUM_CONSTANT(FLAG_ENABLE_MOTOR);
|
2018-03-16 12:07:52 +00:00
|
|
|
BIND_ENUM_CONSTANT(FLAG_ENABLE_LINEAR_MOTOR);
|
2017-08-20 15:45:01 +00:00
|
|
|
BIND_ENUM_CONSTANT(FLAG_MAX);
|
2017-03-05 15:44:50 +00:00
|
|
|
}
|
|
|
|
|
2021-01-29 23:22:12 +00:00
|
|
|
void Generic6DOFJoint3D::set_param_x(Param p_param, real_t p_value) {
|
2017-03-05 15:44:50 +00:00
|
|
|
ERR_FAIL_INDEX(p_param, PARAM_MAX);
|
|
|
|
params_x[p_param] = p_value;
|
2021-02-09 16:19:03 +00:00
|
|
|
if (is_configured()) {
|
2020-03-27 18:21:27 +00:00
|
|
|
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(get_joint(), Vector3::AXIS_X, PhysicsServer3D::G6DOFJointAxisParam(p_param), p_value);
|
2020-05-14 14:41:43 +00:00
|
|
|
}
|
2014-09-15 14:33:30 +00:00
|
|
|
|
2021-06-23 14:49:50 +00:00
|
|
|
update_gizmos();
|
2014-09-15 14:33:30 +00:00
|
|
|
}
|
2020-05-14 12:29:06 +00:00
|
|
|
|
2021-01-29 23:22:12 +00:00
|
|
|
real_t Generic6DOFJoint3D::get_param_x(Param p_param) const {
|
2017-03-05 15:44:50 +00:00
|
|
|
ERR_FAIL_INDEX_V(p_param, PARAM_MAX, 0);
|
2014-09-15 14:33:30 +00:00
|
|
|
return params_x[p_param];
|
|
|
|
}
|
|
|
|
|
2021-01-29 23:22:12 +00:00
|
|
|
void Generic6DOFJoint3D::set_param_y(Param p_param, real_t p_value) {
|
2017-03-05 15:44:50 +00:00
|
|
|
ERR_FAIL_INDEX(p_param, PARAM_MAX);
|
|
|
|
params_y[p_param] = p_value;
|
2021-02-09 16:19:03 +00:00
|
|
|
if (is_configured()) {
|
2020-03-27 18:21:27 +00:00
|
|
|
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(get_joint(), Vector3::AXIS_Y, PhysicsServer3D::G6DOFJointAxisParam(p_param), p_value);
|
2020-05-14 14:41:43 +00:00
|
|
|
}
|
2021-06-23 14:49:50 +00:00
|
|
|
update_gizmos();
|
2014-09-15 14:33:30 +00:00
|
|
|
}
|
2020-05-14 12:29:06 +00:00
|
|
|
|
2021-01-29 23:22:12 +00:00
|
|
|
real_t Generic6DOFJoint3D::get_param_y(Param p_param) const {
|
2017-03-05 15:44:50 +00:00
|
|
|
ERR_FAIL_INDEX_V(p_param, PARAM_MAX, 0);
|
2014-09-15 14:33:30 +00:00
|
|
|
return params_y[p_param];
|
|
|
|
}
|
|
|
|
|
2021-01-29 23:22:12 +00:00
|
|
|
void Generic6DOFJoint3D::set_param_z(Param p_param, real_t p_value) {
|
2017-03-05 15:44:50 +00:00
|
|
|
ERR_FAIL_INDEX(p_param, PARAM_MAX);
|
|
|
|
params_z[p_param] = p_value;
|
2021-02-09 16:19:03 +00:00
|
|
|
if (is_configured()) {
|
2020-03-27 18:21:27 +00:00
|
|
|
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(get_joint(), Vector3::AXIS_Z, PhysicsServer3D::G6DOFJointAxisParam(p_param), p_value);
|
2020-05-14 14:41:43 +00:00
|
|
|
}
|
2021-06-23 14:49:50 +00:00
|
|
|
update_gizmos();
|
2014-09-15 14:33:30 +00:00
|
|
|
}
|
2020-05-14 12:29:06 +00:00
|
|
|
|
2021-01-29 23:22:12 +00:00
|
|
|
real_t Generic6DOFJoint3D::get_param_z(Param p_param) const {
|
2017-03-05 15:44:50 +00:00
|
|
|
ERR_FAIL_INDEX_V(p_param, PARAM_MAX, 0);
|
2014-09-15 14:33:30 +00:00
|
|
|
return params_z[p_param];
|
|
|
|
}
|
|
|
|
|
2020-03-26 21:49:16 +00:00
|
|
|
void Generic6DOFJoint3D::set_flag_x(Flag p_flag, bool p_enabled) {
|
2017-03-05 15:44:50 +00:00
|
|
|
ERR_FAIL_INDEX(p_flag, FLAG_MAX);
|
|
|
|
flags_x[p_flag] = p_enabled;
|
2021-02-09 16:19:03 +00:00
|
|
|
if (is_configured()) {
|
2020-03-27 18:21:27 +00:00
|
|
|
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(get_joint(), Vector3::AXIS_X, PhysicsServer3D::G6DOFJointAxisFlag(p_flag), p_enabled);
|
2020-05-14 14:41:43 +00:00
|
|
|
}
|
2021-06-23 14:49:50 +00:00
|
|
|
update_gizmos();
|
2014-09-15 14:33:30 +00:00
|
|
|
}
|
2020-05-14 12:29:06 +00:00
|
|
|
|
2020-03-26 21:49:16 +00:00
|
|
|
bool Generic6DOFJoint3D::get_flag_x(Flag p_flag) const {
|
2017-03-05 15:44:50 +00:00
|
|
|
ERR_FAIL_INDEX_V(p_flag, FLAG_MAX, false);
|
2014-09-15 14:33:30 +00:00
|
|
|
return flags_x[p_flag];
|
|
|
|
}
|
|
|
|
|
2020-03-26 21:49:16 +00:00
|
|
|
void Generic6DOFJoint3D::set_flag_y(Flag p_flag, bool p_enabled) {
|
2017-03-05 15:44:50 +00:00
|
|
|
ERR_FAIL_INDEX(p_flag, FLAG_MAX);
|
|
|
|
flags_y[p_flag] = p_enabled;
|
2021-02-09 16:19:03 +00:00
|
|
|
if (is_configured()) {
|
2020-03-27 18:21:27 +00:00
|
|
|
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(get_joint(), Vector3::AXIS_Y, PhysicsServer3D::G6DOFJointAxisFlag(p_flag), p_enabled);
|
2020-05-14 14:41:43 +00:00
|
|
|
}
|
2021-06-23 14:49:50 +00:00
|
|
|
update_gizmos();
|
2014-09-15 14:33:30 +00:00
|
|
|
}
|
2020-05-14 12:29:06 +00:00
|
|
|
|
2020-03-26 21:49:16 +00:00
|
|
|
bool Generic6DOFJoint3D::get_flag_y(Flag p_flag) const {
|
2017-03-05 15:44:50 +00:00
|
|
|
ERR_FAIL_INDEX_V(p_flag, FLAG_MAX, false);
|
2014-09-15 14:33:30 +00:00
|
|
|
return flags_y[p_flag];
|
|
|
|
}
|
|
|
|
|
2020-03-26 21:49:16 +00:00
|
|
|
void Generic6DOFJoint3D::set_flag_z(Flag p_flag, bool p_enabled) {
|
2017-03-05 15:44:50 +00:00
|
|
|
ERR_FAIL_INDEX(p_flag, FLAG_MAX);
|
|
|
|
flags_z[p_flag] = p_enabled;
|
2021-02-09 16:19:03 +00:00
|
|
|
if (is_configured()) {
|
2020-03-27 18:21:27 +00:00
|
|
|
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(get_joint(), Vector3::AXIS_Z, PhysicsServer3D::G6DOFJointAxisFlag(p_flag), p_enabled);
|
2020-05-14 14:41:43 +00:00
|
|
|
}
|
2021-06-23 14:49:50 +00:00
|
|
|
update_gizmos();
|
2014-09-15 14:33:30 +00:00
|
|
|
}
|
2020-05-14 12:29:06 +00:00
|
|
|
|
2020-03-26 21:49:16 +00:00
|
|
|
bool Generic6DOFJoint3D::get_flag_z(Flag p_flag) const {
|
2017-03-05 15:44:50 +00:00
|
|
|
ERR_FAIL_INDEX_V(p_flag, FLAG_MAX, false);
|
2014-09-15 14:33:30 +00:00
|
|
|
return flags_z[p_flag];
|
|
|
|
}
|
|
|
|
|
2021-02-09 16:19:03 +00:00
|
|
|
void Generic6DOFJoint3D::_configure_joint(RID p_joint, PhysicsBody3D *body_a, PhysicsBody3D *body_b) {
|
2020-10-17 05:08:21 +00:00
|
|
|
Transform3D gt = get_global_transform();
|
2014-09-15 14:33:30 +00:00
|
|
|
//Vector3 cone_twistpos = gt.origin;
|
|
|
|
//Vector3 cone_twistdir = gt.basis.get_axis(2);
|
|
|
|
|
2020-10-17 05:08:21 +00:00
|
|
|
Transform3D ainv = body_a->get_global_transform().affine_inverse();
|
2014-09-15 14:33:30 +00:00
|
|
|
|
2020-10-17 05:08:21 +00:00
|
|
|
Transform3D local_a = ainv * gt;
|
2014-09-15 14:33:30 +00:00
|
|
|
local_a.orthonormalize();
|
2020-10-17 05:08:21 +00:00
|
|
|
Transform3D local_b = gt;
|
2014-09-15 14:33:30 +00:00
|
|
|
|
|
|
|
if (body_b) {
|
2020-10-17 05:08:21 +00:00
|
|
|
Transform3D binv = body_b->get_global_transform().affine_inverse();
|
2014-09-15 14:33:30 +00:00
|
|
|
local_b = binv * gt;
|
|
|
|
}
|
|
|
|
|
|
|
|
local_b.orthonormalize();
|
|
|
|
|
2021-02-09 16:19:03 +00:00
|
|
|
PhysicsServer3D::get_singleton()->joint_make_generic_6dof(p_joint, body_a->get_rid(), local_a, body_b ? body_b->get_rid() : RID(), local_b);
|
2017-03-05 15:44:50 +00:00
|
|
|
for (int i = 0; i < PARAM_MAX; i++) {
|
2021-02-09 16:19:03 +00:00
|
|
|
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(p_joint, Vector3::AXIS_X, PhysicsServer3D::G6DOFJointAxisParam(i), params_x[i]);
|
|
|
|
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(p_joint, Vector3::AXIS_Y, PhysicsServer3D::G6DOFJointAxisParam(i), params_y[i]);
|
|
|
|
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_param(p_joint, Vector3::AXIS_Z, PhysicsServer3D::G6DOFJointAxisParam(i), params_z[i]);
|
2014-09-15 14:33:30 +00:00
|
|
|
}
|
2017-03-05 15:44:50 +00:00
|
|
|
for (int i = 0; i < FLAG_MAX; i++) {
|
2021-02-09 16:19:03 +00:00
|
|
|
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(p_joint, Vector3::AXIS_X, PhysicsServer3D::G6DOFJointAxisFlag(i), flags_x[i]);
|
|
|
|
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(p_joint, Vector3::AXIS_Y, PhysicsServer3D::G6DOFJointAxisFlag(i), flags_y[i]);
|
|
|
|
PhysicsServer3D::get_singleton()->generic_6dof_joint_set_flag(p_joint, Vector3::AXIS_Z, PhysicsServer3D::G6DOFJointAxisFlag(i), flags_z[i]);
|
2014-09-15 14:33:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-12 15:01:17 +00:00
|
|
|
Generic6DOFJoint3D::Generic6DOFJoint3D() {
|
2017-03-05 15:44:50 +00:00
|
|
|
set_param_x(PARAM_LINEAR_LOWER_LIMIT, 0);
|
|
|
|
set_param_x(PARAM_LINEAR_UPPER_LIMIT, 0);
|
|
|
|
set_param_x(PARAM_LINEAR_LIMIT_SOFTNESS, 0.7);
|
|
|
|
set_param_x(PARAM_LINEAR_RESTITUTION, 0.5);
|
|
|
|
set_param_x(PARAM_LINEAR_DAMPING, 1.0);
|
2018-03-16 12:07:52 +00:00
|
|
|
set_param_x(PARAM_LINEAR_MOTOR_TARGET_VELOCITY, 0);
|
|
|
|
set_param_x(PARAM_LINEAR_MOTOR_FORCE_LIMIT, 0);
|
2018-11-09 11:58:57 +00:00
|
|
|
set_param_x(PARAM_LINEAR_SPRING_STIFFNESS, 0.01);
|
|
|
|
set_param_x(PARAM_LINEAR_SPRING_DAMPING, 0.01);
|
|
|
|
set_param_x(PARAM_LINEAR_SPRING_EQUILIBRIUM_POINT, 0.0);
|
2017-03-05 15:44:50 +00:00
|
|
|
set_param_x(PARAM_ANGULAR_LOWER_LIMIT, 0);
|
|
|
|
set_param_x(PARAM_ANGULAR_UPPER_LIMIT, 0);
|
|
|
|
set_param_x(PARAM_ANGULAR_LIMIT_SOFTNESS, 0.5f);
|
|
|
|
set_param_x(PARAM_ANGULAR_DAMPING, 1.0f);
|
|
|
|
set_param_x(PARAM_ANGULAR_RESTITUTION, 0);
|
|
|
|
set_param_x(PARAM_ANGULAR_FORCE_LIMIT, 0);
|
|
|
|
set_param_x(PARAM_ANGULAR_ERP, 0.5);
|
|
|
|
set_param_x(PARAM_ANGULAR_MOTOR_TARGET_VELOCITY, 0);
|
|
|
|
set_param_x(PARAM_ANGULAR_MOTOR_FORCE_LIMIT, 300);
|
2018-11-09 11:58:57 +00:00
|
|
|
set_param_x(PARAM_ANGULAR_SPRING_STIFFNESS, 0);
|
|
|
|
set_param_x(PARAM_ANGULAR_SPRING_DAMPING, 0);
|
|
|
|
set_param_x(PARAM_ANGULAR_SPRING_EQUILIBRIUM_POINT, 0);
|
2017-03-05 15:44:50 +00:00
|
|
|
|
|
|
|
set_flag_x(FLAG_ENABLE_ANGULAR_LIMIT, true);
|
|
|
|
set_flag_x(FLAG_ENABLE_LINEAR_LIMIT, true);
|
2018-11-09 11:58:57 +00:00
|
|
|
set_flag_x(FLAG_ENABLE_ANGULAR_SPRING, false);
|
|
|
|
set_flag_x(FLAG_ENABLE_LINEAR_SPRING, false);
|
2017-03-05 15:44:50 +00:00
|
|
|
set_flag_x(FLAG_ENABLE_MOTOR, false);
|
2018-03-16 12:07:52 +00:00
|
|
|
set_flag_x(FLAG_ENABLE_LINEAR_MOTOR, false);
|
2017-03-05 15:44:50 +00:00
|
|
|
|
|
|
|
set_param_y(PARAM_LINEAR_LOWER_LIMIT, 0);
|
|
|
|
set_param_y(PARAM_LINEAR_UPPER_LIMIT, 0);
|
|
|
|
set_param_y(PARAM_LINEAR_LIMIT_SOFTNESS, 0.7);
|
|
|
|
set_param_y(PARAM_LINEAR_RESTITUTION, 0.5);
|
|
|
|
set_param_y(PARAM_LINEAR_DAMPING, 1.0);
|
2018-03-16 12:07:52 +00:00
|
|
|
set_param_y(PARAM_LINEAR_MOTOR_TARGET_VELOCITY, 0);
|
|
|
|
set_param_y(PARAM_LINEAR_MOTOR_FORCE_LIMIT, 0);
|
2018-11-09 11:58:57 +00:00
|
|
|
set_param_y(PARAM_LINEAR_SPRING_STIFFNESS, 0.01);
|
|
|
|
set_param_y(PARAM_LINEAR_SPRING_DAMPING, 0.01);
|
|
|
|
set_param_y(PARAM_LINEAR_SPRING_EQUILIBRIUM_POINT, 0.0);
|
2017-03-05 15:44:50 +00:00
|
|
|
set_param_y(PARAM_ANGULAR_LOWER_LIMIT, 0);
|
|
|
|
set_param_y(PARAM_ANGULAR_UPPER_LIMIT, 0);
|
|
|
|
set_param_y(PARAM_ANGULAR_LIMIT_SOFTNESS, 0.5f);
|
|
|
|
set_param_y(PARAM_ANGULAR_DAMPING, 1.0f);
|
|
|
|
set_param_y(PARAM_ANGULAR_RESTITUTION, 0);
|
|
|
|
set_param_y(PARAM_ANGULAR_FORCE_LIMIT, 0);
|
|
|
|
set_param_y(PARAM_ANGULAR_ERP, 0.5);
|
|
|
|
set_param_y(PARAM_ANGULAR_MOTOR_TARGET_VELOCITY, 0);
|
|
|
|
set_param_y(PARAM_ANGULAR_MOTOR_FORCE_LIMIT, 300);
|
2018-11-09 11:58:57 +00:00
|
|
|
set_param_y(PARAM_ANGULAR_SPRING_STIFFNESS, 0);
|
|
|
|
set_param_y(PARAM_ANGULAR_SPRING_DAMPING, 0);
|
|
|
|
set_param_y(PARAM_ANGULAR_SPRING_EQUILIBRIUM_POINT, 0);
|
2017-03-05 15:44:50 +00:00
|
|
|
|
|
|
|
set_flag_y(FLAG_ENABLE_ANGULAR_LIMIT, true);
|
|
|
|
set_flag_y(FLAG_ENABLE_LINEAR_LIMIT, true);
|
2018-11-09 11:58:57 +00:00
|
|
|
set_flag_y(FLAG_ENABLE_ANGULAR_SPRING, false);
|
|
|
|
set_flag_y(FLAG_ENABLE_LINEAR_SPRING, false);
|
2017-03-05 15:44:50 +00:00
|
|
|
set_flag_y(FLAG_ENABLE_MOTOR, false);
|
2018-03-16 12:07:52 +00:00
|
|
|
set_flag_y(FLAG_ENABLE_LINEAR_MOTOR, false);
|
2017-03-05 15:44:50 +00:00
|
|
|
|
|
|
|
set_param_z(PARAM_LINEAR_LOWER_LIMIT, 0);
|
|
|
|
set_param_z(PARAM_LINEAR_UPPER_LIMIT, 0);
|
|
|
|
set_param_z(PARAM_LINEAR_LIMIT_SOFTNESS, 0.7);
|
|
|
|
set_param_z(PARAM_LINEAR_RESTITUTION, 0.5);
|
|
|
|
set_param_z(PARAM_LINEAR_DAMPING, 1.0);
|
2018-03-16 12:07:52 +00:00
|
|
|
set_param_z(PARAM_LINEAR_MOTOR_TARGET_VELOCITY, 0);
|
|
|
|
set_param_z(PARAM_LINEAR_MOTOR_FORCE_LIMIT, 0);
|
2018-11-09 11:58:57 +00:00
|
|
|
set_param_z(PARAM_LINEAR_SPRING_STIFFNESS, 0.01);
|
|
|
|
set_param_z(PARAM_LINEAR_SPRING_DAMPING, 0.01);
|
|
|
|
set_param_z(PARAM_LINEAR_SPRING_EQUILIBRIUM_POINT, 0.0);
|
2017-03-05 15:44:50 +00:00
|
|
|
set_param_z(PARAM_ANGULAR_LOWER_LIMIT, 0);
|
|
|
|
set_param_z(PARAM_ANGULAR_UPPER_LIMIT, 0);
|
|
|
|
set_param_z(PARAM_ANGULAR_LIMIT_SOFTNESS, 0.5f);
|
|
|
|
set_param_z(PARAM_ANGULAR_DAMPING, 1.0f);
|
|
|
|
set_param_z(PARAM_ANGULAR_RESTITUTION, 0);
|
|
|
|
set_param_z(PARAM_ANGULAR_FORCE_LIMIT, 0);
|
|
|
|
set_param_z(PARAM_ANGULAR_ERP, 0.5);
|
|
|
|
set_param_z(PARAM_ANGULAR_MOTOR_TARGET_VELOCITY, 0);
|
|
|
|
set_param_z(PARAM_ANGULAR_MOTOR_FORCE_LIMIT, 300);
|
2018-11-09 11:58:57 +00:00
|
|
|
set_param_z(PARAM_ANGULAR_SPRING_STIFFNESS, 0);
|
|
|
|
set_param_z(PARAM_ANGULAR_SPRING_DAMPING, 0);
|
|
|
|
set_param_z(PARAM_ANGULAR_SPRING_EQUILIBRIUM_POINT, 0);
|
2017-03-05 15:44:50 +00:00
|
|
|
|
|
|
|
set_flag_z(FLAG_ENABLE_ANGULAR_LIMIT, true);
|
|
|
|
set_flag_z(FLAG_ENABLE_LINEAR_LIMIT, true);
|
2018-11-09 11:58:57 +00:00
|
|
|
set_flag_z(FLAG_ENABLE_ANGULAR_SPRING, false);
|
|
|
|
set_flag_z(FLAG_ENABLE_LINEAR_SPRING, false);
|
2017-03-05 15:44:50 +00:00
|
|
|
set_flag_z(FLAG_ENABLE_MOTOR, false);
|
2018-03-16 12:07:52 +00:00
|
|
|
set_flag_z(FLAG_ENABLE_LINEAR_MOTOR, false);
|
2014-09-15 14:33:30 +00:00
|
|
|
}
|