From 06f2f1ecbc9f6f2fee81135478b027f5d7bea2e4 Mon Sep 17 00:00:00 2001 From: Mikael Hermansson Date: Mon, 22 Jan 2024 13:55:57 +0100 Subject: [PATCH] Bind physics server methods related to `SoftBody3D` --- doc/classes/PhysicsServer3D.xml | 252 ++++++++++++++++++++++++++++++++ servers/physics_server_3d.cpp | 52 +++++++ 2 files changed, 304 insertions(+) diff --git a/doc/classes/PhysicsServer3D.xml b/doc/classes/PhysicsServer3D.xml index 32810b0daf35..4735091f2004 100644 --- a/doc/classes/PhysicsServer3D.xml +++ b/doc/classes/PhysicsServer3D.xml @@ -1014,10 +1014,262 @@ Gets a slider_joint parameter (see [enum SliderJointParam] constants). + + + + + + Adds the given body to the list of bodies exempt from collisions. + + + + + + Creates a new soft body and returns its internal [RID]. + + + Returns the bounds of the given soft body in global coordinates. + + + + + + + Returns the physics layer or layers that the given soft body belongs to. + + + + + + + Returns the physics layer or layers that the given soft body can collide with. + + + + + + + Returns the damping coefficient of the given soft body. + + + + + + + Returns the drag coefficient of the given soft body. + + + + + + + Returns the linear stiffness of the given soft body. + + + + + + + + Returns the current position of the given soft body point in global coordinates. + + + + + + + Returns the pressure coefficient of the given soft body. + + + + + + + Returns the simulation precision of the given soft body. + + + + + + + Returns the [RID] of the space assigned to the given soft body. + + + + + + + + Returns the given soft body state (see [enum BodyState] constants). + [b]Note:[/b] Godot's default physics implementation does not support [constant BODY_STATE_LINEAR_VELOCITY], [constant BODY_STATE_ANGULAR_VELOCITY], [constant BODY_STATE_SLEEPING], or [constant BODY_STATE_CAN_SLEEP]. + + + + + + + Returns the total mass assigned to the given soft body. + + + + + + + + Returns whether the given soft body point is pinned. + + + + + + + + + Moves the given soft body point to a position in global coordinates. + + + + + + + + + Pins or unpins the given soft body point based on the value of [param pin]. + [b]Note:[/b] Pinning a point effectively makes it kinematic, preventing it from being affected by forces, but you can still move it using [method soft_body_move_point]. + + + + + + + Unpins all points of the given soft body. + + + + + + + + Removes the given body from the list of bodies exempt from collisions. + + + + + + + + Sets the physics layer or layers the given soft body belongs to. + + + + + + + + Sets the physics layer or layers the given soft body can collide with. + + + + + + + + Sets the damping coefficient of the given soft body. Higher values will slow down the body more noticeably when forces are applied. + + + + + + + + Sets the drag coefficient of the given soft body. Higher values increase this body's air resistance. + [b]Note:[/b] This value is currently unused by Godot's default physics implementation. + + + + + + + + Sets the linear stiffness of the given soft body. Higher values will result in a stiffer body, while lower values will increase the body's ability to bend. The value can be between [code]0.0[/code] and [code]1.0[/code] (inclusive). + + + + + + + + Sets the mesh of the given soft body. + + + + + + + + Sets the pressure coefficient of the given soft body. Simulates pressure build-up from inside this body. Higher values increase the strength of this effect. + + + + + + + + Sets whether the given soft body will be pickable when using object picking. + + + + + + + + Sets the simulation precision of the given soft body. Increasing this value will improve the resulting simulation, but can affect performance. Use with care. + + + + + + + + Assigns a space to the given soft body (see [method space_create]). + + + + + + + + + Sets the given body state for the given body (see [enum BodyState] constants). + [b]Note:[/b] Godot's default physics implementation does not support [constant BODY_STATE_LINEAR_VELOCITY], [constant BODY_STATE_ANGULAR_VELOCITY], [constant BODY_STATE_SLEEPING], or [constant BODY_STATE_CAN_SLEEP]. + + + + + + + + Sets the total mass for the given soft body. + + + + + + + + Sets the global transform of the given soft body. + + + + + + + + Requests that the physics server updates the rendering server with the latest positions of the given soft body's points through the [param rendering_server_handler] interface. diff --git a/servers/physics_server_3d.cpp b/servers/physics_server_3d.cpp index addd1a56632a..686388f23733 100644 --- a/servers/physics_server_3d.cpp +++ b/servers/physics_server_3d.cpp @@ -835,8 +835,60 @@ void PhysicsServer3D::_bind_methods() { /* SOFT BODY API */ + ClassDB::bind_method(D_METHOD("soft_body_create"), &PhysicsServer3D::soft_body_create); + + ClassDB::bind_method(D_METHOD("soft_body_update_rendering_server", "body", "rendering_server_handler"), &PhysicsServer3D::soft_body_update_rendering_server); + + ClassDB::bind_method(D_METHOD("soft_body_set_space", "body", "space"), &PhysicsServer3D::soft_body_set_space); + ClassDB::bind_method(D_METHOD("soft_body_get_space", "body"), &PhysicsServer3D::soft_body_get_space); + + ClassDB::bind_method(D_METHOD("soft_body_set_mesh", "body", "mesh"), &PhysicsServer3D::soft_body_set_mesh); + ClassDB::bind_method(D_METHOD("soft_body_get_bounds", "body"), &PhysicsServer3D::soft_body_get_bounds); + ClassDB::bind_method(D_METHOD("soft_body_set_collision_layer", "body", "layer"), &PhysicsServer3D::soft_body_set_collision_layer); + ClassDB::bind_method(D_METHOD("soft_body_get_collision_layer", "body"), &PhysicsServer3D::soft_body_get_collision_layer); + + ClassDB::bind_method(D_METHOD("soft_body_set_collision_mask", "body", "mask"), &PhysicsServer3D::soft_body_set_collision_mask); + ClassDB::bind_method(D_METHOD("soft_body_get_collision_mask", "body"), &PhysicsServer3D::soft_body_get_collision_mask); + + ClassDB::bind_method(D_METHOD("soft_body_add_collision_exception", "body", "body_b"), &PhysicsServer3D::soft_body_add_collision_exception); + ClassDB::bind_method(D_METHOD("soft_body_remove_collision_exception", "body", "body_b"), &PhysicsServer3D::soft_body_remove_collision_exception); + + ClassDB::bind_method(D_METHOD("soft_body_set_state", "body", "state", "variant"), &PhysicsServer3D::soft_body_set_state); + ClassDB::bind_method(D_METHOD("soft_body_get_state", "body", "state"), &PhysicsServer3D::soft_body_get_state); + + ClassDB::bind_method(D_METHOD("soft_body_set_transform", "body", "transform"), &PhysicsServer3D::soft_body_set_transform); + + ClassDB::bind_method(D_METHOD("soft_body_set_ray_pickable", "body", "enable"), &PhysicsServer3D::soft_body_set_ray_pickable); + + ClassDB::bind_method(D_METHOD("soft_body_set_simulation_precision", "body", "simulation_precision"), &PhysicsServer3D::soft_body_set_simulation_precision); + ClassDB::bind_method(D_METHOD("soft_body_get_simulation_precision", "body"), &PhysicsServer3D::soft_body_get_simulation_precision); + + ClassDB::bind_method(D_METHOD("soft_body_set_total_mass", "body", "total_mass"), &PhysicsServer3D::soft_body_set_total_mass); + ClassDB::bind_method(D_METHOD("soft_body_get_total_mass", "body"), &PhysicsServer3D::soft_body_get_total_mass); + + ClassDB::bind_method(D_METHOD("soft_body_set_linear_stiffness", "body", "stiffness"), &PhysicsServer3D::soft_body_set_linear_stiffness); + ClassDB::bind_method(D_METHOD("soft_body_get_linear_stiffness", "body"), &PhysicsServer3D::soft_body_get_linear_stiffness); + + ClassDB::bind_method(D_METHOD("soft_body_set_pressure_coefficient", "body", "pressure_coefficient"), &PhysicsServer3D::soft_body_set_pressure_coefficient); + ClassDB::bind_method(D_METHOD("soft_body_get_pressure_coefficient", "body"), &PhysicsServer3D::soft_body_get_pressure_coefficient); + + ClassDB::bind_method(D_METHOD("soft_body_set_damping_coefficient", "body", "damping_coefficient"), &PhysicsServer3D::soft_body_set_damping_coefficient); + ClassDB::bind_method(D_METHOD("soft_body_get_damping_coefficient", "body"), &PhysicsServer3D::soft_body_get_damping_coefficient); + + ClassDB::bind_method(D_METHOD("soft_body_set_drag_coefficient", "body", "drag_coefficient"), &PhysicsServer3D::soft_body_set_drag_coefficient); + ClassDB::bind_method(D_METHOD("soft_body_get_drag_coefficient", "body"), &PhysicsServer3D::soft_body_get_drag_coefficient); + + ClassDB::bind_method(D_METHOD("soft_body_move_point", "body", "point_index", "global_position"), &PhysicsServer3D::soft_body_move_point); + ClassDB::bind_method(D_METHOD("soft_body_get_point_global_position", "body", "point_index"), &PhysicsServer3D::soft_body_get_point_global_position); + + ClassDB::bind_method(D_METHOD("soft_body_remove_all_pinned_points", "body"), &PhysicsServer3D::soft_body_remove_all_pinned_points); + + ClassDB::bind_method(D_METHOD("soft_body_pin_point", "body", "point_index", "pin"), &PhysicsServer3D::soft_body_pin_point); + + ClassDB::bind_method(D_METHOD("soft_body_is_point_pinned", "body", "point_index"), &PhysicsServer3D::soft_body_is_point_pinned); + /* JOINT API */ ClassDB::bind_method(D_METHOD("joint_create"), &PhysicsServer3D::joint_create);