Skip to content

[rmodels] Fix minimum rings validation in DrawCapsule and DrawCapsuleWires - #5909

Merged
raysan5 merged 1 commit into
raysan5:masterfrom
LuisR385:fix-draw-capsule-rings
Jun 6, 2026
Merged

[rmodels] Fix minimum rings validation in DrawCapsule and DrawCapsuleWires#5909
raysan5 merged 1 commit into
raysan5:masterfrom
LuisR385:fix-draw-capsule-rings

Conversation

@LuisR385

@LuisR385 LuisR385 commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Description

This PR fixes a missing validation for the rings parameter in DrawCapsule() and DrawCapsuleWires().
Currently, slices has a minimum guard (if (slices < 3) slices = 3;), but rings does not, which can cause rendering artifacts or crashes if a user passes 0 or negative values.

Changes

  • Added if (rings < 1) rings = 1; to DrawCapsule() in rmodels.c.
  • Added if (rings < 1) rings = 1; to DrawCapsuleWires() in rmodels.c.

Visuals

Info-Draw-Capsule

How to test / Reproduce

Passing 0 to slices or rings previously caused an issue.

// Example to reproduce the issue (passing 0 to slices/rings)
DrawCapsule((Vector3){0.0f, 0.5f, 7.0f}, (Vector3){0.0f, 1.5f, 7.0f}, 0.3f, 8, 0, LIME);
DrawCapsuleWires((Vector3){7.0f, 0.5f, 7.0f}, (Vector3){7.0f, 1.5f, 7.0f}, 0.3f, 8, 0, MAGENTA);

…Wires

Ensure rings is at least 1 to prevent rendering issues or crashes when 0 or negative values are passed.
@raysan5
raysan5 merged commit acfcf2f into raysan5:master Jun 6, 2026
16 checks passed
@raysan5

raysan5 commented Jun 6, 2026

Copy link
Copy Markdown
Owner

@LuisR385 I'm merging this PR but note that raylib does not validate all the input data received by users, it's expected that users provide valid data. Validating all required data will imply adding lot of code for maintainability, also, validation changes input data so results could be confusing for some users.

@LuisR385

LuisR385 commented Jun 7, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for merging this and for the clarification regarding the validation policy. It makes sense!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants