Skip to content

Conversation

ankith26
Copy link
Member

@ankith26 ankith26 commented Jun 8, 2025

Whenever is PySequence_AsVectorCoords is called without calling pgVectorCompatible_Check beforehand, currently the code gives undefined behaviour when expected dim is 3 and a Vector2 is passed. If expected dim is 2 and Vector3 is passed the 3rd component gets ignored. For now I fixed the undefined behaviour case to ensure consistent 0-ing.

I renamed this function to pg_VectorCoordsFromObjOldDontUseInNewCode so that new API doesn't end up using this function. New API should just use pg_VectorCoordsFromObj directly.

Wherever pgVectorCompatible_Check was already being called before PySequence_AsVectorCoords we can safely use the new pg_VectorCoordsFromObj API

@ankith26 ankith26 requested a review from a team as a code owner June 8, 2025 07:06
@ankith26 ankith26 force-pushed the ankith26-math-api branch from 0b596da to 92b99c6 Compare June 8, 2025 07:12
@ankith26 ankith26 force-pushed the ankith26-math-api branch from 92b99c6 to fd2bcae Compare June 8, 2025 07:17
Copy link
Member

@MyreMylar MyreMylar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, LGTM. Might prevent some edge cases issues when using 2 dimensional vectors. All the tests still pass locally as well.

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