devkitPro / libogc

C Library for Wii and Gamecube homebrew
https://devkitpro.org/viewforum.php?f=40
Other
283 stars 69 forks source link

gu.h: add const in vector and matrix API #134

Closed mardy closed 1 year ago

mardy commented 1 year ago

Marking the immutable parameters as const can help the developer spot some errors.

I initially added const to the vector parameter of c_guMtxRotAxisRad(), but then the build failed because indeed the parameter is being modified by the function (which internally calls c_guVecNormalize() on it). This is a bit of a surprise, I'm tempted to modify the function implementation to create a copy of the vector, but first I wanted to check with you, to see if you agree. Another option is to add const and document that the vector must be normalized, but this would be a behavioural change which might break existing clients. Or we just leave it as it is :-)

DacoTaco commented 1 year ago

hm, creating a copy might not be a good idea. the wii's memory is limited as is. i'd say leave it as is