godotengine / godotengine/godot

PhysicsServer2D `shape_set_data` input format for capsule shapes is inconsistent

Open
#90,656 1 comment 0 reactions 0 assignees View on GitHub
bug documentation topic:physics
Dominant language
C++
Stars
117k
Forks
26.8k
PR merge metrics
PR metrics pending

Description

### Tested versions

- Reproducible in: 4.3.dev5, as well as every other Godot version in the history of the git repository.

### System information

Godot v4.3.dev5 - Ubuntu 22.04.4 LTS 22.04 - X11 - GLES3 (Compatibility) - NVIDIA GeForce RTX 2060 with Max-Q Design - AMD Ryzen 9 4900HS with Radeon Graphics (16 Threads)

### Issue description

The `shape_set_data` method of `PhysicsServer2D` takes a strange input format for capsule shapes:

https://github.com/godotengine/godot/blob/578d937927ea9735aa7a8e0535f57801406b0b82/servers/physics_2d/godot_shape_2d.cpp#L467-L479

That is, it takes either `[height, radius]` or `Vector2(radius, height)`. Probably one of the two was a typo (ever since Godot has been open source). The [documentation of `shape_set_data`](https://docs.godotengine.org/en/latest/classes/class_physicsserver2d.html#class-physicsserver2d-method-shape-set-data) is correct about the array input but incorrect about the vector input. Also, `shape_get_data` will return `Vector2(height, radius)`:

https://github.com/godotengine/godot/blob/578d937927ea9735aa7a8e0535f57801406b0b82/servers/physics_2d/godot_shape_2d.cpp#L485-L487

The [documentation of `shape_get_data`](https://docs.godotengine.org/en/latest/classes/class_physicsserver2d.html#class-physicsserver2d-method-shape-get-data) is incomplete here; it should be more explicit, at least about the cases where it's not clear from the documentation of `shape_set_data`.

### Steps to reproduce

```gdscript
extends Node2D

func _ready() -> void:
var shape: RID = PhysicsServer2D.capsule_shape_create()
PhysicsServer2D.shape_set_data(shape, Vector2(10, 50))
print(PhysicsServer2D.shape_get_data(shape)) # Output: (50, 10)
PhysicsServer2D.free_rid(shape)
```

### Minimal reproduction project (MRP)

[capsule-convention.zip](https://github.com/godotengine/godot/files/14970459/capsule-convention.zip)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.