### Initialize Fluid via PhysicsServer2D Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/api-reference/fluids.md Demonstrates the basic setup of a physics space and fluid context using the Godot PhysicsServer2D singleton. ```gdscript # In Godot GDScript - typical fluid setup var server = PhysicsServer2D.get_singleton() # Create a space var space = server.space_create() server.space_set_active(space, true) # Create a fluid (via Rapier server methods) # This would be wrapped in GDScript nodes in practice # Typically accessed through a Fluid2D/Fluid3D Godot node which handles: # - Creating the fluid RID # - Setting initial points and velocities # - Updating points each frame # - Retrieving particle positions for rendering ``` -------------------------------- ### PhysicsServer2D Integration Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/README.md Examples of how to initialize a physics world, create shapes, and configure rigid bodies using the PhysicsServer2D singleton. ```APIDOC ## PhysicsServer2D Usage ### Description Initializes a physics space, creates collision shapes, and configures rigid bodies. ### Code Example ```gdscript var server = PhysicsServer2D.get_singleton() # Create space var space = server.space_create() server.space_set_active(space, true) # Create shape var shape = server.circle_shape_create() server.shape_set_data(shape, 1.0) # Create body var body = server.body_create() server.body_set_space(body, space) server.body_set_mode(body, PhysicsServer2D.BODY_MODE_RIGID) server.body_add_shape(body, shape, Transform2D(), false) # Set physics properties server.body_set_param(body, PhysicsServer2D.BODY_PARAM_MASS, 2.0) server.body_set_param(body, PhysicsServer2D.BODY_PARAM_FRICTION, 0.8) ``` ``` -------------------------------- ### Setup Body Monitoring Callback Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/api-reference/serialization-and-advanced.md Registers a callable to monitor body contacts using the PhysicsServer2D singleton. ```gdscript func setup_body_monitoring(body_rid: RID) -> void: var server = PhysicsServer2D.get_singleton() # Set callback for body contact monitoring var callable = Callable(self, "_on_body_contact") server.body_set_monitor_callback(body_rid, callable) ``` -------------------------------- ### Get Rapier extra parameters in GDScript Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/api-reference/joints.md Usage example for retrieving the current dominance value of a body. ```gdscript var dominance = server.body_get_extra_param(body_rid, RapierPhysicsServer2D.BODY_PARAM_DOMINANCE) print("Dominance: ", dominance) ``` -------------------------------- ### Access Space State and Perform Query in GDScript Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/api-reference/space-queries.md Example of creating a space and retrieving its direct state to perform a raycast. ```gdscript var space = server.space_create() var state = server.space_get_direct_state(space) if state: # Perform queries on the state object var result = state.intersect_ray(query) ``` -------------------------------- ### Setup Area Monitoring Callbacks Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/api-reference/serialization-and-advanced.md Registers callbacks for monitoring body and area entries/exits within an area. ```gdscript func setup_area_monitoring(area_rid: RID) -> void: var server = PhysicsServer2D.get_singleton() # Monitor body entry/exit var body_callback = Callable(self, "_on_body_entered_area") server.area_set_monitor_callback(area_rid, body_callback) # Monitor area entry/exit var area_callback = Callable(self, "_on_area_entered") server.area_set_area_monitor_callback(area_rid, area_callback) ``` -------------------------------- ### space_get_direct_state() Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/api-reference/physics-server.md Gets the direct state accessor for a space for queries. ```APIDOC ## space_get_direct_state() ### Description Provides query capabilities for a space such as raycast, shapecast, and point queries. Returns None if the space is invalid. ### Signature `fn space_get_direct_state(&mut self, space: Rid) -> Option>` ### Parameters - **space** (Rid) - Required - The space resource identifier ### Returns - **Option>** - A direct space state object for performing queries, or None if invalid ``` -------------------------------- ### Configure Joint Data Dictionaries Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/api-reference/joints.md Examples of dictionary structures for Pin and Revolute joints used with joint_set_data. ```gdscript # Pin Joint (typical) var pin_data = { "bodies": [body1_rid, body2_rid], "anchor_a": Vector2(1.0, 0.0), # Local anchor on body A "anchor_b": Vector2(-1.0, 0.0) # Local anchor on body B } server.joint_set_data(joint_rid, pin_data) # Revolute Joint (2D) var revolute_data = { "bodies": [body1_rid, body2_rid], "anchor": Vector2(0, 0), # Pivot point in world space "axis": 0, # 0 for free rotation "param": { "min_angle": -PI, "max_angle": PI } } server.joint_set_data(joint_rid, revolute_data) ``` -------------------------------- ### Set Rapier extra parameters in GDScript Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/api-reference/joints.md Usage examples for configuring contact skin and dominance on a physics body. ```gdscript # Increase contact skin for better tunneling prevention server.body_set_extra_param(body_rid, RapierPhysicsServer2D.BODY_PARAM_CONTACT_SKIN, 0.1) # Set dominance for character controller server.body_set_extra_param(player_body_rid, RapierPhysicsServer2D.BODY_PARAM_DOMINANCE, 10) ``` -------------------------------- ### Retrieve body mode Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/api-reference/bodies-and-areas.md Get the current physics mode of a body. ```rust fn body_get_mode(&self, body: Rid) -> BodyMode ``` ```gdscript var mode = server.body_get_mode(body_rid) ``` -------------------------------- ### Deploy build output Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/CONTRIBUTING.md Copy the compiled library to the appropriate addon bin folder for macOS or Windows. ```bash cp target/release/libgodot_rapier.dylib bin2d/addons/godot-rapier2d/bin/libgodot_rapier.macos.framework/libgodot_rapier.macos.dylib ``` ```bash cp target/release/godot_rapier.dll bin2d/addons/godot-rapier2d/bin/godot_rapier.windows.x86_64-pc-windows-msvc.dll ``` -------------------------------- ### body_get_total_contact_impulse Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/api-reference/joints.md Gets the total contact impulse acting on a body. ```APIDOC ## body_get_total_contact_impulse(body: Rid) -> Vector ### Description Returns the combined impulse from all contacts on the body. Divide by physics delta time to get average force. ### Parameters - **body** (Rid) - Required - The body resource identifier ### Returns - **Vector** - The total contact impulse (Vector2 in 2D, Vector3 in 3D) ### Example ```gdscript var total_impulse = server.body_get_total_contact_impulse(body_rid) var average_force = total_impulse / physics_delta print("Average contact force: ", average_force.length()) ``` ``` -------------------------------- ### Get Body State in GDScript Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/api-reference/physics-server.md Retrieves current state properties such as transform or velocity from a physics body. ```gdscript var transform = server.body_get_state(body_rid, PhysicsServer2D.BODY_STATE_TRANSFORM) var velocity = server.body_get_state(body_rid, PhysicsServer2D.BODY_STATE_LINEAR_VELOCITY) ``` -------------------------------- ### body_get_contact_tangent_impulse Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/api-reference/joints.md Gets the friction impulse at a specific contact index. ```APIDOC ## body_get_contact_tangent_impulse(body: Rid, contact_idx: i32) -> real ### Description Returns the tangential (friction) component of the contact impulse for a specific contact index. ### Parameters - **body** (Rid) - Required - The body resource identifier - **contact_idx** (i32) - Required - Index of the contact (0-based) ### Returns - **real** - The friction impulse magnitude ### Example ```gdscript for i in range(server.body_get_contact_count(body_rid)): var tangent_impulse = server.body_get_contact_tangent_impulse(body_rid, i) if tangent_impulse > 0.1: print("Sliding contact: ", tangent_impulse) ``` ``` -------------------------------- ### Build the project Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/CONTRIBUTING.md Compile the project for 2D or 3D physics support using specific feature flags. ```bash # for 2d cargo build --release --features="single-dim2" # for 3d cargo build --release --features="single-dim3" ``` -------------------------------- ### Create 3D Physics Server Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/api-reference/physics-server.md Initializes a singleton instance of the Rapier 3D physics server. ```rust #[func] fn create_server() -> Gd ``` -------------------------------- ### area_get_shape_count Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/api-reference/bodies-and-areas.md Gets the number of collision shapes attached to an area. ```APIDOC ## area_get_shape_count(area: Rid) -> i32 ### Description Gets the number of collision shapes attached to an area. ### Parameters - **area** (Rid) - Required - The area resource identifier ### Returns - **i32** - The number of shapes attached ### Example ```gdscript var count = server.area_get_shape_count(area_rid) ``` ``` -------------------------------- ### RapierPhysicsServerFactory3D::create_server() Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/api-reference/physics-server.md Creates a singleton instance of the Rapier 3D physics server. ```APIDOC ## RapierPhysicsServerFactory3D::create_server() ### Description Creates a singleton instance of the Rapier 3D physics server. This method is typically called internally during engine initialization. ### Signature `fn create_server() -> Gd` ### Returns - **Gd** - A new physics server 3D instance. ``` -------------------------------- ### Get Collision Mask Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/api-reference/bodies-and-areas.md Retrieves the collision mask of a body. ```rust fn body_get_collision_mask(&self, body: Rid) -> u32 ``` ```gdscript var mask = server.body_get_collision_mask(body_rid) ``` -------------------------------- ### body_get_shape_count Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/api-reference/bodies-and-areas.md Gets the number of collision shapes attached to a body. ```APIDOC ## body_get_shape_count(body: Rid) -> i32 ### Description Gets the number of collision shapes attached to a body. ### Parameters - **body** (Rid) - Required - The body resource identifier ### Returns - **i32** - The number of shapes attached ### Example ```gdscript var count = server.body_get_shape_count(body_rid) ``` ``` -------------------------------- ### Create 2D Physics Server Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/api-reference/physics-server.md Initializes a singleton instance of the Rapier 2D physics server. ```rust #[func] fn create_server() -> Gd ``` -------------------------------- ### Enable Physics Profiling Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/api-reference/serialization-and-advanced.md Uses environment variables to output physics step timing to the console. ```bash GODOT_RAPIER_PROFILING=1 godot 2>&1 | grep "Physics step" ``` -------------------------------- ### Get Collision Layer Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/api-reference/bodies-and-areas.md Retrieves the collision layer mask of a body. ```rust fn body_get_collision_layer(&self, body: Rid) -> u32 ``` ```gdscript var layer = server.body_get_collision_layer(body_rid) ``` -------------------------------- ### RapierPhysicsServerFactory2D::create_server() Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/api-reference/physics-server.md Creates a singleton instance of the Rapier 2D physics server. ```APIDOC ## RapierPhysicsServerFactory2D::create_server() ### Description Creates a singleton instance of the Rapier 2D physics server. This method is typically called internally during engine initialization. ### Signature `fn create_server() -> Gd` ### Returns - **Gd** - A new physics server 2D instance. ``` -------------------------------- ### Retrieve area collision mask Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/api-reference/bodies-and-areas.md Gets the collision mask assigned to the area. ```rust fn area_get_collision_mask(&self, area: Rid) -> u32 ``` ```gdscript var mask = server.area_get_collision_mask(area_rid) ``` -------------------------------- ### Initialize a Physics Body Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/CONTRIBUTING.md Demonstrates the sequence of calls used by a RigidBody2D node to register a body with the Physics Server. ```c++ body_rid = body_create() body_set_space(body_rid, space_rid) body_set_state(body_rid, BODY_STATE_TRANSFORM, Transform2D()) ... ``` -------------------------------- ### Get Area Transform in GDScript Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/api-reference/bodies-and-areas.md Retrieves the current global transform of an area. ```gdscript var transform = server.area_get_transform(area_rid) print("Area position: ", transform.origin) ``` -------------------------------- ### Get User Flags Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/api-reference/bodies-and-areas.md Retrieves the custom user flags stored on a body. ```rust fn body_get_user_flags(&self, body: Rid) -> u32 ``` ```gdscript var flags = server.body_get_user_flags(body_rid) if (flags & FLAG_DAMAGEABLE) != 0: print("This body can take damage") ``` -------------------------------- ### Create a physics space in GDScript Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/api-reference/physics-server.md Initializes a new physics world and sets it to active. ```gdscript var space_rid = server.space_create() server.space_set_active(space_rid, true) ``` -------------------------------- ### Retrieve body space Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/api-reference/bodies-and-areas.md Get the physics space identifier associated with a body. ```rust fn body_get_space(&self, body: Rid) -> Rid ``` ```gdscript var space_rid = server.body_get_space(body_rid) ``` -------------------------------- ### Querying Physics Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/README.md Demonstrates how to perform raycast queries, retrieve active bodies, and access contact information from a physics space. ```gdscript # Raycast query var space_state = server.space_get_direct_state(space) var query = PhysicsRayQueryParameters2D.create(from, to) var result = space_state.intersect_ray(query) # Get active bodies var bodies = server.space_get_active_bodies(space) # Get contact information server.space_set_debug_contacts(space, 100) var contacts = server.space_get_contacts(space) ``` -------------------------------- ### Get Total Contact Impulse Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/api-reference/joints.md Calculates the combined impulse from all contacts acting on a body. ```rust pub fn body_get_total_contact_impulse(body: Rid) -> Vector ``` ```gdscript var total_impulse = server.body_get_total_contact_impulse(body_rid) var average_force = total_impulse / physics_delta print("Average contact force: ", average_force.length()) ``` -------------------------------- ### Retrieve area collision layer Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/api-reference/bodies-and-areas.md Gets the collision layer mask assigned to the area. ```rust fn area_get_collision_layer(&self, area: Rid) -> u32 ``` ```gdscript var layer = server.area_get_collision_layer(area_rid) ``` -------------------------------- ### Modify physics settings at runtime Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/configuration.md Use the ProjectSettings singleton to update physics parameters. Changes apply to new physics spaces immediately. ```gdscript var settings = ProjectSettings settings.set_setting("physics/rapier/solver/num_iterations", 8) var current_value = settings.get_setting("physics/rapier/solver/num_iterations") ``` -------------------------------- ### Retrieve Area Shape Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/api-reference/bodies-and-areas.md Gets the shape resource identifier for a shape at a specific index. ```rust fn area_get_shape(&self, area: Rid, shape_idx: i32) -> Rid ``` ```gdscript var shape_rid = server.area_get_shape(area_rid, 0) ``` -------------------------------- ### space_create() Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/api-reference/physics-server.md Creates a new physics space (world). ```APIDOC ## space_create() ### Description Creates an isolated physics world with its own objects, joints, and simulation. Multiple spaces can coexist without affecting each other. ### Signature `fn space_create(&mut self) -> Rid` ### Returns - **Rid** - A resource identifier for the newly created space ``` -------------------------------- ### Get Area Shape Transform Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/api-reference/bodies-and-areas.md Retrieves the local transform for a specific shape attached to an area. ```rust fn area_get_shape_transform(&self, area: Rid, shape_idx: i32) -> Transform ``` ```gdscript var transform = server.area_get_shape_transform(area_rid, 0) ``` -------------------------------- ### Define RapierPhysics3DExtensionLibrary class Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/api-reference/physics-server.md Registers the 3D physics plugin entry point for engine initialization. ```rust #[derive(GodotClass)] #[class(base=Object, init)] pub struct RapierPhysics3DExtensionLibrary {} ``` -------------------------------- ### Define RapierPhysics2DExtensionLibrary class Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/api-reference/physics-server.md Registers the 2D physics plugin entry point for engine initialization. ```rust #[derive(GodotClass)] #[class(base=Object, init)] pub struct RapierPhysics2DExtensionLibrary {} ``` -------------------------------- ### Get Continuous Collision Detection Mode Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/api-reference/bodies-and-areas.md Retrieves the current CCD mode for a specified body. ```rust fn body_get_continuous_collision_detection_mode(&self, body: Rid) -> CcdMode ``` ```gdscript var ccd_mode = server.body_get_continuous_collision_detection_mode(body_rid) ``` -------------------------------- ### Parallel Solver Configuration Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/api-reference/serialization-and-advanced.md Notes on the default behavior of the parallel constraint solver. ```gdscript # Parallel solver is enabled by default in non-web builds # The number of threads is automatically determined based on CPU cores ``` -------------------------------- ### Get body shape Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/api-reference/bodies-and-areas.md Retrieve a specific shape resource identifier attached to a body by index. ```rust fn body_get_shape(&self, body: Rid, shape_idx: i32) -> Rid ``` ```gdscript var shape_rid = server.body_get_shape(body_rid, 0) var shape_type = server.shape_get_type(shape_rid) ``` -------------------------------- ### Get body shape count Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/api-reference/bodies-and-areas.md Retrieve the total number of collision shapes attached to a body. ```rust fn body_get_shape_count(&self, body: Rid) -> i32 ``` ```gdscript var count = server.body_get_shape_count(body_rid) for i in range(count): var shape = server.body_get_shape(body_rid, i) ``` -------------------------------- ### Register Rapier as a GDExtension dependency Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/README.md Forward Godot Rapier's initialization stages within your own ExtensionLibrary implementation. ```rust use godot::prelude::*; use godot_rapier::RapierPhysics3DExtensionLibrary; struct MyExtension; #[gdextension] unsafe impl ExtensionLibrary for MyExtension { fn min_level() -> InitLevel { InitLevel::Servers } fn on_stage_init(level: InitStage) { RapierPhysics3DExtensionLibrary::on_stage_init(level); } fn on_stage_deinit(level: InitStage) { RapierPhysics3DExtensionLibrary::on_stage_deinit(level); } } ``` -------------------------------- ### Get Active Contact Count Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/api-reference/space-queries.md Returns the total number of active contacts currently tracked in the space. ```gdscript var contact_count = server.space_get_contact_count(space_rid) print("Active contacts: ", contact_count) ``` -------------------------------- ### Access Performance Monitors Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/api-reference/serialization-and-advanced.md Retrieve specific physics performance metrics using the Godot Performance singleton. ```gdscript var perf = Performance.get_monitor("physics_rapier/...") ``` -------------------------------- ### Get Contact Tangent Impulse Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/api-reference/joints.md Retrieves the tangential friction component of the impulse for a specific contact index. ```rust pub fn body_get_contact_tangent_impulse(body: Rid, contact_idx: i32) -> real ``` ```gdscript for i in range(server.body_get_contact_count(body_rid)): var tangent_impulse = server.body_get_contact_tangent_impulse(body_rid, i) if tangent_impulse > 0.1: print("Sliding contact: ", tangent_impulse) ``` -------------------------------- ### Enable Rapier Profiling via Environment Variable Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/configuration.md Set the GODOT_RAPIER_PROFILING environment variable to output physics step times and solver statistics to stdout. ```bash GODOT_RAPIER_PROFILING=1 godot ``` -------------------------------- ### body_create() Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/api-reference/physics-server.md Creates a new rigid body. This method initializes an empty body without shapes, mass, or mode, which must be configured subsequently. ```APIDOC ## body_create() ### Description Creates a new rigid body. Creates an empty rigid body without shapes, mass, or mode. ### Signature `fn body_create(&mut self) -> Rid` ### Returns - **Rid** - A resource identifier for the newly created body ``` -------------------------------- ### Get Contact Force Threshold Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/api-reference/joints.md Retrieves the currently configured contact force threshold for a specific body. ```rust pub fn body_get_contact_force_threshold(body: Rid) -> real ``` ```gdscript var threshold = server.body_get_contact_force_threshold(body_rid) ``` -------------------------------- ### Physics Server Method Call Flow Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/CONTRIBUTING.md Illustrates the relationship between standard Godot physics methods and their corresponding extension implementations. ```c++ body_create() | v _body_create() ``` -------------------------------- ### Create a New Joint Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/api-reference/joints.md Initializes an empty joint resource. The joint requires further configuration before it becomes active. ```rust fn joint_create(&mut self) -> Rid ``` ```gdscript var joint_rid = server.joint_create() server.joint_set_param(joint_rid, PhysicsServer2D.JOINT_PARAM_BIAS, 0.3) ``` -------------------------------- ### Creating a Physics World Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/README.md Initializes a physics space, creates a circular shape, and configures a rigid body with physical properties. ```gdscript var server = PhysicsServer2D.get_singleton() # Create space var space = server.space_create() server.space_set_active(space, true) # Create shape var shape = server.circle_shape_create() server.shape_set_data(shape, 1.0) # radius # Create body var body = server.body_create() server.body_set_space(body, space) server.body_set_mode(body, PhysicsServer2D.BODY_MODE_RIGID) server.body_add_shape(body, shape, Transform2D(), false) # Set physics properties server.body_set_param(body, PhysicsServer2D.BODY_PARAM_MASS, 2.0) server.body_set_param(body, PhysicsServer2D.BODY_PARAM_FRICTION, 0.8) ``` -------------------------------- ### Access Physics Server Directly Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/README.md Retrieve the PhysicsServer2D singleton to perform lower-level physics operations using the Rapier implementation. ```gdscript var server = PhysicsServer2D.get_singleton() # The server is the Rapier implementation when configured # All methods documented in this reference are available ``` -------------------------------- ### Get Area Shape Count Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/api-reference/bodies-and-areas.md Returns the total number of collision shapes currently attached to the specified area. ```rust fn area_get_shape_count(&self, area: Rid) -> i32 ``` ```gdscript var count = server.area_get_shape_count(area_rid) ``` -------------------------------- ### Configure Physics for Performance Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/configuration.md Optimizes physics settings for mobile or lower-end hardware. ```gdscript [physics] rapier/solver/preset = "Low" rapier/motion/recover_attempts = 2 rapier/motion/cast_iterations = 4 rapier/queries/max_shape_cast_results = 32 ``` -------------------------------- ### Raycast Queries Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/api-reference/space-queries.md Traces a straight line through space to detect the first collision. ```APIDOC ## Raycast Queries ### Description Ray queries trace a straight line through space detecting the first collision. ### Result Fields - **position** - Hit position in global coordinates - **normal** - Surface normal at hit point - **collider** - The Rid of the colliding object - **collider_id** - Instance ID of the colliding object's node - **shape** - Index of the colliding shape on the collider - **rid** - The resource ID of the collider ``` -------------------------------- ### Applying Forces Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/README.md Shows methods for applying impulses, torque, and setting linear velocity on a physics body. ```gdscript # Apply impulse at center server.body_apply_central_impulse(body, Vector2(10, 0)) # Apply torque impulse server.body_apply_torque_impulse(body, 5.0) # 2D: scalar # Set velocity directly server.body_set_state(body, PhysicsServer2D.BODY_STATE_LINEAR_VELOCITY, Vector2(5, 0)) ``` -------------------------------- ### Define RapierPhysicsServer3D class Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/api-reference/physics-server.md Implements the 3D physics server singleton by extending PhysicsServer3DExtension. ```rust #[derive(GodotClass)] #[class(base=PhysicsServer3DExtension, tool)] pub struct RapierPhysicsServer3D { pub implementation: RapierPhysicsServerImpl, base: Base, } ``` -------------------------------- ### Querying Physics Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/README.md Methods for performing raycasts and retrieving state information from the physics world. ```APIDOC ## Physics Querying ### Description Perform raycast queries and retrieve active body or contact information from a physics space. ### Code Example ```gdscript # Raycast query var space_state = server.space_get_direct_state(space) var query = PhysicsRayQueryParameters2D.create(from, to) var result = space_state.intersect_ray(query) # Get active bodies var bodies = server.space_get_active_bodies(space) # Get contact information server.space_set_debug_contacts(space, 100) var contacts = server.space_get_contacts(space) ``` ``` -------------------------------- ### Enable Physics Debug Visualization Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/api-reference/serialization-and-advanced.md Configures the physics server to track contact points for debugging purposes. ```gdscript func enable_physics_debug(space_rid: RID) -> void: var server = PhysicsServer2D.get_singleton() # Store up to 1000 contacts for visualization server.space_set_debug_contacts(space_rid, 1000) ``` -------------------------------- ### Import Physics World State Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/api-reference/serialization-and-advanced.md Restore a previously saved physics state into the specified space. ```gdscript func load_physics_state(space_rid: RID, data: Variant, format: String) -> bool: var server = PhysicsServer2D.get_singleton() return server.physics_state_import(space_rid, data, format) ``` -------------------------------- ### Configure Physics Engine in Project Settings Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/README.md Set the physics engine to Rapier2D or Rapier3D in the Godot Project Settings to enable the engine globally. ```gdscript # In Project Settings → Physics → 2D/3D Physics Engine: "Rapier2D" or "Rapier3D" ``` -------------------------------- ### Physics Server Thread Safety Patterns Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/api-reference/serialization-and-advanced.md Demonstrates the required main-thread execution for physics operations versus prohibited worker thread calls. ```gdscript func _physics_process(_delta: float) -> void: # Main thread physics operations var bodies = server.space_get_active_bodies(space_rid) for body in bodies: var velocity = server.body_get_state(body, PhysicsServer2D.BODY_STATE_LINEAR_VELOCITY) # Use the result... ``` ```gdscript # Do NOT call from worker threads! var thread = Thread.new(func(): server.body_add_shape(body_rid, shape_rid, Transform2D(), false) ) ``` -------------------------------- ### Create a new rigid body in GDScript Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/api-reference/physics-server.md Initializes an empty rigid body. Configuration methods must be called subsequently to define its properties. ```gdscript var body_rid = server.body_create() server.body_set_mode(body_rid, PhysicsServer2D.BODY_MODE_RIGID) server.body_set_space(body_rid, space_rid) ``` -------------------------------- ### Configure Advanced Body Parameters Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/api-reference/serialization-and-advanced.md Sets specific physics parameters for a body using RapierPhysicsServer2D constants. ```gdscript # Increase predicted collision distance server.body_set_extra_param(body_rid, RapierPhysicsServer2D.BODY_PARAM_CONTACT_SKIN, 0.1) ``` ```gdscript # Set constraint resolution priority server.body_set_extra_param(body_rid, RapierPhysicsServer2D.BODY_PARAM_DOMINANCE, 10) ``` ```gdscript # Enable soft CCD for passing through geometry when needed server.body_set_extra_param(body_rid, RapierPhysicsServer2D.BODY_PARAM_SOFT_CCD, true) ``` ```gdscript # Make body kinematic-like but joint-constrained server.body_set_extra_param(body_rid, RapierPhysicsServer2D.BODY_PARAM_MASSLESS, true) ``` -------------------------------- ### Configure Physics for Precision Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/configuration.md Configures high-precision settings suitable for physics-based animation. ```gdscript [physics] rapier/solver/preset = "Custom" rapier/solver/num_iterations = 16 rapier/solver/num_internal_stabilization_iterations = 2 rapier/solver/normalized_allowed_linear_error = 0.0001 rapier/solver/contact_natural_frequency = 120.0 ``` -------------------------------- ### Applying Forces Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/README.md Methods for applying impulses, torque, and setting state variables on physics bodies. ```APIDOC ## Applying Forces ### Description Apply physical forces and impulses to bodies, or set their state directly. ### Code Example ```gdscript # Apply impulse at center server.body_apply_central_impulse(body, Vector2(10, 0)) # Apply torque impulse server.body_apply_torque_impulse(body, 5.0) # Set velocity directly server.body_set_state(body, PhysicsServer2D.BODY_STATE_LINEAR_VELOCITY, Vector2(5, 0)) ``` ``` -------------------------------- ### Configure Physics for Determinism Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/configuration.md Sets parameters to ensure consistent physics behavior for replays or networked simulations. ```gdscript [physics] rapier/solver/preset = "Medium" rapier/solver/num_iterations = 4 rapier/solver/num_internal_pgs_iterations = 2 rapier/solver/normalized_prediction_distance = 0.002 ``` -------------------------------- ### Configure Cargo dependency for Godot Rapier Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/README.md Add the godot-rapier crate to your Cargo.toml dependencies with the appropriate features. ```toml [dependencies] godot-rapier = { git = "https://github.com/appsinacup/godot-rapier-physics.git", tag = "v0.35.0", features = ["single-dim2"] } ``` -------------------------------- ### Define RapierPhysicsServer2D class Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/api-reference/physics-server.md Implements the 2D physics server singleton by extending PhysicsServer2DExtension. ```rust #[derive(GodotClass)] #[class(base=PhysicsServer2DExtension, tool)] pub struct RapierPhysicsServer2D { pub implementation: RapierPhysicsServerImpl, base: Base, } ``` -------------------------------- ### Godot Rapier Data Layers and Singleton Structure Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/ARCHITECTURE.md A Mermaid diagram illustrating the two data layers (Godot Data Layer and Rapier Data Layer) and how they are managed within a Singleton, including the relationships between various components like RapierSpace, IRapierShape, IRapierJoint, IRapierCollisionObject, RapierFluid, and the PhysicsEngine. ```mermaid classDiagram natspace Godot Data Layer { class RapierSpace { stateless_data: Data state: RapierSpaceState } class RapierSpaceState { stateful_data: Data handle: Index } class IRapierShape { stateless_data: Data base: RapierShapeBase } class RapierShapeBase { stateless_data: Data state: RapierSpaceState } class RapierShapeBaseState { stateful_data: Data world_handle: Index handle: Index } class IRapierJoint { stateless_data: Data base: RapierJointBase } class RapierJointBase { stateless_data: Data base: RapierJointBase } class RapierJointBaseState { stateful_data: Data world_handle: Index handle: Index } class IRapierCollisionObject{ stateless_data: Data base: RapierCollisionObjectBase state: RapierCollisionObjectState } class RapierCollisionObjectBase { stateless_data: Data base: RapierCollisionObjectBaseState } class RapierCollisionObjectBaseState { stateful_data: Data world_handle: Index handle: Index } class RapierFluid { effects: Vec[IRapierFluidEffects] } class IRapierFluidEffects { } } namespace Rapier Data Layer { class PhysicsEngine { physics_worlds: Arena[Index, PhysicsWorld] shapes: Arena[Index, SharedShape] } class PhysicsWorld { physics_objects: PhysicsObjects fluids_pipeline: FluidsPipeline } class PhysicsObjects { impulse_joint_set: Arena[Index, ImpulseJoint] multi_body_joint_set: Arena[Index, MultiBodyJoint] rigid_body_set: Arena[Index, Rigidbody] collider_set: Arena[Index, Collider] handle: Index } } class Singleton { shapes: HashMap[Rid, RapierShape] spaces: HashMap[Rid, RapierSpace] collision_objects: HashMap[Rid, RapierCollisionObject] joints: HashMap[Rid, RapierJoint] fluids: HashMap[Rid, RapierFluid] physics_engine: PhysicsEngine --- rids: HashMap[Index, Rid] } Singleton *-- RapierSpace : rid Singleton *-- IRapierShape : rid Singleton *-- IRapierJoint : rid Singleton *-- IRapierCollisionObject : rid Singleton *-- RapierFluid : rid Singleton *-- PhysicsEngine PhysicsEngine *-- PhysicsWorld : space_handle PhysicsWorld *-- PhysicsObjects : space_handle RapierSpace *-- RapierSpaceState RapierSpaceState ..> PhysicsWorld : space_handle IRapierShape *-- RapierShapeBase RapierShapeBase *-- RapierShapeBaseState RapierShapeBaseState ..> PhysicsEngine : shape_handle IRapierJoint *-- RapierJointBase RapierJointBase *-- RapierJointBaseState RapierJointBaseState ..> PhysicsObjects : impulse_joint_handle IRapierCollisionObject *-- RapierCollisionObjectBase RapierCollisionObjectBase *-- RapierCollisionObjectBaseState RapierCollisionObjectBaseState ..> PhysicsObjects : rigidbody_handle RapierFluid *-- IRapierFluidEffects ``` -------------------------------- ### Configure body physical parameters in GDScript Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/api-reference/physics-server.md Sets physical properties like mass, friction, and bounce for a specific body. ```gdscript server.body_set_param(body_rid, PhysicsServer2D.BODY_PARAM_MASS, 1.5) server.body_set_param(body_rid, PhysicsServer2D.BODY_PARAM_FRICTION, 0.8) server.body_set_param(body_rid, PhysicsServer2D.BODY_PARAM_BOUNCE, 0.3) ``` -------------------------------- ### Implement Integration Callbacks Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/api-reference/serialization-and-advanced.md Modify physics state during the fixed timestep integration process using _integrate_forces. ```gdscript extends RigidBody2D func _integrate_forces(state: PhysicsDirectBodyState2D) -> void: # Called every physics step with the current state # Modify velocity and apply forces before constraint solving var gravity = state.total_gravity state.linear_velocity += gravity * state.step # Custom logic using instantaneous state if state.linear_velocity.length() > max_speed: state.linear_velocity = state.linear_velocity.normalized() * max_speed ``` -------------------------------- ### Configure VSCode debugger for Godot Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/CONTRIBUTING.md Add this configuration to launch.configurations in VSCode to enable debugging for the Godot project. ```json { "name": "Launch", "program": "path/to/godot/bin/godot.macos.editor.dev.arm64", "type": "cppdbg", "request": "launch", "cwd": "${workspaceFolder:godot-rapier-2d}", "osx": { "MIMode": "lldb" }, "args": [ "--path", "path/to/project/folder", "--debug-collisions", "scene-name.tscn" ] }, ``` -------------------------------- ### physics_state_import Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/api-reference/serialization-and-advanced.md Restores a previously saved physics world state. ```APIDOC ## physics_state_import ### Description Imports and restores a physics world state from provided data and format. ### Parameters - **space_rid** (RID) - Required - The RID of the physics space to restore. - **data** (Variant) - Required - The serialized state data to import. - **format** (String) - Required - The format of the provided data: "Json", "GodotBase64", or "RustBincode". ### Response - **bool** - Returns true if the import was successful, false otherwise. ``` -------------------------------- ### Configure space parameters in GDScript Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/api-reference/physics-server.md Updates simulation settings like contact properties for a specific space. ```gdscript # Set contact recycle radius server.space_set_param(space_rid, PhysicsServer2D.SPACE_PARAM_CONTACT_RECYCLE_RADIUS, 0.01) ``` -------------------------------- ### Rigid Body Management Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/INDEX.md Methods for creating, configuring, and controlling rigid bodies, including state management, collision settings, and impulse application. ```APIDOC ## Rigid Body Management - `body_create()` — Create body - `body_set_space()` — Assign to world - `body_get_space()` — Get assigned world - `body_set_mode()` — Set static/kinematic/rigid - `body_get_mode()` — Get body mode - `body_apply_central_impulse()` — Apply linear impulse - `body_apply_impulse()` — Apply impulse at offset - `body_apply_torque_impulse()` — Apply angular impulse - `body_apply_force()` — Apply continuous force - `body_set_collision_layer()` — Set what layer body is on - `body_set_collision_mask()` — Set what to collide with ``` -------------------------------- ### Create a circle shape in GDScript Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/api-reference/physics-server.md Initializes a circular shape and sets its radius using the physics server. ```gdscript var server = PhysicsServer2D.get_singleton() var shape_rid = server.circle_shape_create() server.shape_set_data(shape_rid, 1.5) # Set radius to 1.5 ``` -------------------------------- ### Space/World Management Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/INDEX.md Methods for managing physics worlds, including activation, parameter configuration, and contact debugging. ```APIDOC ## Space Management - `space_create()` — Create physics world - `space_set_active()` — Activate/pause physics - `space_is_active()` — Check if world is active - `space_set_param()` — Configure space parameters - `space_get_param()` — Retrieve space parameters - `space_get_direct_state()` — Get query interface - `space_set_debug_contacts()` — Enable contact debugging - `space_get_contacts()` — Retrieve debug contacts - `space_get_contact_count()` — Get contact count - `space_get_active_bodies()` — Get all active bodies - `space_get_bodies_transform()` — Batch-retrieve body transforms ``` -------------------------------- ### Configure Physics for Stability Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/configuration.md Adjusts solver settings to improve stability for complex stacking and interactions. ```gdscript [physics] rapier/solver/preset = "High" rapier/solver/num_iterations = 8 rapier/solver/contact_damping_ratio = 0.05 ``` -------------------------------- ### Format and lint Rust code Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/CONTRIBUTING.md Run these commands to format the codebase and perform linting for both 2D and 3D feature sets. ```sh # Format cargo fmt -- --config-path rustfmt.toml # Run clippy for 2d only cargo clippy --fix --allow-dirty --all-targets --features="single-dim2" # Run clippy for 3d only cargo clippy --fix --allow-dirty --all-targets --features="single-dim3" ``` -------------------------------- ### body_set_space() Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/api-reference/physics-server.md Assigns a body to a physics space to enable simulation. ```APIDOC ## body_set_space() ### Description Assigns a body to a physics space. Moves a body into a physics space where it will be simulated. ### Signature `fn body_set_space(&mut self, body: Rid, space: Rid)` ### Parameters - **body** (Rid) - Required - The body resource identifier - **space** (Rid) - Required - The space resource identifier to assign to ``` -------------------------------- ### area_create() Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/api-reference/physics-server.md Creates a new physics area used for trigger detection and non-moving collision testing. ```APIDOC ## area_create() ### Description Creates a new physics area. Areas do not have physics properties like mass and are used for trigger detection and non-moving collision testing. ### Signature `fn area_create(&mut self) -> Rid` ### Returns - **Rid** - A resource identifier for the newly created area. ### Example ```gdscript var area_rid = server.area_create() server.area_set_space(area_rid, space_rid) ``` ``` -------------------------------- ### Define PhysicsServer dimension-agnostic alias Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/types.md Resolves to 2D or 3D physics server based on compilation features. ```rust #[cfg(feature = "dim2")] pub type PhysicsServer = PhysicsServer2D; #[cfg(feature = "dim3")] pub type PhysicsServer = PhysicsServer3D; ``` -------------------------------- ### Create Raycast Query in GDScript Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/api-reference/space-queries.md Configures a ray query with specific collision parameters. ```gdscript var query = PhysicsRayQueryParameters2D.create(from_point, to_point) query.hit_from_inside = false query.hit_back_faces = false var result = space_state.intersect_ray(query) ``` -------------------------------- ### Physics Queries Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/INDEX.md Interface for performing spatial queries such as raycasts and overlap tests. ```APIDOC ## Physics Queries ### Methods - `space_get_direct_state()`: Get the query interface for the physics space. ### Query Types - Raycast queries: Find first collision along a ray. - Shapecast queries: Test shape motion. - Point queries: Find colliders containing a point. - Overlap queries: Find all colliders in a region. ``` -------------------------------- ### Joint Management Methods Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/INDEX.md Methods for creating and configuring various physics joints. ```APIDOC ## Joint Management ### Methods - `joint_create()`: Create a new joint. - `joint_set_param(joint, param, value)`: Configure joint parameters. - `joint_get_param(joint, param)`: Get joint parameter. - `joint_set_data(joint, data)`: Set joint configuration. - `joint_get_data(joint)`: Get joint configuration. ### Supported Joint Types - PIN_JOINT (2D/3D) - HINGE_JOINT / REVOLUTE_JOINT (2D/3D) - SLIDER_JOINT (3D) - CONE_TWIST_JOINT (3D) - GENERIC_6DOF_JOINT (3D) - GROOVE_JOINT (2D) - DAMPED_SPRING_JOINT (2D) ``` -------------------------------- ### body_set_param() Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/api-reference/physics-server.md Configures physical properties of a body such as mass, friction, restitution, and damping. ```APIDOC ## body_set_param() ### Description Sets a body parameter. Configures physical properties of a body such as mass, friction, restitution, and damping. ### Signature `fn body_set_param(&mut self, body: Rid, param: BodyParameter, value: Variant)` ### Parameters - **body** (Rid) - Required - The body resource identifier - **param** (BodyParameter) - Required - The parameter enum (BODY_PARAM_MASS, BODY_PARAM_INERTIA, BODY_PARAM_FRICTION, etc.) - **value** (Variant) - Required - The parameter value ``` -------------------------------- ### Physics Resource Cleanup Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/api-reference/serialization-and-advanced.md Explicitly free physics resources to prevent memory leaks. ```gdscript func cleanup_physics() -> void: var server = PhysicsServer2D.get_singleton() # Free joint resources server.free_rid(joint_rid) # Free shape resources server.free_rid(shape_rid) # Free body resources (removes from space first) server.body_set_space(body_rid, Rid()) server.free_rid(body_rid) # Free space resource server.space_set_active(space_rid, false) server.free_rid(space_rid) ``` -------------------------------- ### Configure GENERIC_6DOF_JOINT Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/api-reference/joints.md Provides independent constraints for all 6 degrees of freedom, available in 3D. ```gdscript var 6dof_data = { "bodies": [body1_rid, body2_rid], "param": { # Linear X axis "linear_limit_lower_x": -1.0, "linear_limit_upper_x": 1.0, "linear_limit_softness_x": 0.7, "linear_spring_enabled_x": false, "linear_spring_stiffness_x": 100.0, "linear_spring_damping_x": 0.1, # Linear Y axis "linear_limit_lower_y": -1.0, "linear_limit_upper_y": 1.0, "linear_limit_softness_y": 0.7, # ... similar for Z # Angular X axis (roll) "angular_limit_lower_x": -PI/4, "angular_limit_upper_x": PI/4, "angular_limit_softness_x": 0.7, "angular_spring_enabled_x": false, "angular_spring_stiffness_x": 100.0, "angular_spring_damping_x": 0.1, # ... similar for Y and Z } } server.joint_set_data(joint_rid, 6dof_data) ``` -------------------------------- ### Set area parameters Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/api-reference/bodies-and-areas.md Configures physics parameters such as gravity or damping for a specific area. ```rust fn area_set_param(&mut self, area: Rid, param: AreaParameter, value: Variant) ``` ```gdscript # Set gravity override server.area_set_param(area_rid, PhysicsServer2D.AREA_PARAM_GRAVITY_OVERRIDE_MODE, 1) server.area_set_param(area_rid, PhysicsServer2D.AREA_PARAM_GRAVITY, Vector2(0, 20)) ``` -------------------------------- ### fluid_set_points_and_velocities Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/api-reference/fluids.md Sets both the positions and velocities of particles for a given fluid. ```APIDOC ## fluid_set_points_and_velocities(fluid_rid, points, velocities) ### Description Sets the particle positions and velocities for the specified fluid. ### Parameters - **fluid_rid** (RID) - Required - The unique identifier of the fluid. - **points** (PackedVectorArray) - Required - The array of particle positions. - **velocities** (PackedVectorArray) - Required - The array of particle velocities. ``` -------------------------------- ### Convert binary data to PackedByteArray Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/types.md Converts raw binary data to Godot's PackedByteArray format. Requires the serde-serialize feature. ```rust #[cfg(feature = "serde-serialize")] pub fn bin_to_packed_byte_array(bin: Vec) -> PackedByteArray ``` -------------------------------- ### Create Shapecast Query in GDScript 2D Source: https://github.com/appsinacup/godot-rapier-physics/blob/main/_autodocs/api-reference/space-queries.md Tests a geometric shape against the physics space, optionally including motion. ```gdscript var shape = CircleShape2D.new() shape.radius = 1.0 var query = PhysicsShapeQueryParameters2D.new() query.shape = shape query.transform = Transform2D(0, Vector2(10, 10)) query.motion = Vector2(5, 0) # Optional motion vector var results = space_state.intersect_shape(query) ```