Skip to content

Commit 34e1ef8

Browse files
authored
gu.h: add const in vector and matrix API (#134)
Marking the immutable parameters as const can help the developer spot some errors.
1 parent 3b7d98c commit 34e1ef8

File tree

2 files changed

+83
-83
lines changed

2 files changed

+83
-83
lines changed

gc/ogc/gu.h

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ void guLightFrustum(Mtx mt,f32 t,f32 b,f32 l,f32 r,f32 n,f32 scaleS,f32 scaleT,f
322322
*
323323
* \return none
324324
*/
325-
void guLookAt(Mtx mt,guVector *camPos,guVector *camUp,guVector *target);
325+
void guLookAt(Mtx mt,const guVector *camPos,const guVector *camUp,const guVector *target);
326326

327327

328328
/*!
@@ -343,83 +343,83 @@ void guLookAt(Mtx mt,guVector *camPos,guVector *camUp,guVector *target);
343343
*
344344
* \return none
345345
*/
346-
void guVecHalfAngle(guVector *a,guVector *b,guVector *half);
346+
void guVecHalfAngle(const guVector *a,const guVector *b,guVector *half);
347347

348-
void c_guVecAdd(guVector *a,guVector *b,guVector *ab);
349-
void c_guVecSub(guVector *a,guVector *b,guVector *ab);
350-
void c_guVecScale(guVector *src,guVector *dst,f32 scale);
348+
void c_guVecAdd(const guVector *a,const guVector *b,guVector *ab);
349+
void c_guVecSub(const guVector *a,const guVector *b,guVector *ab);
350+
void c_guVecScale(const guVector *src,guVector *dst,f32 scale);
351351
void c_guVecNormalize(guVector *v);
352-
void c_guVecMultiply(Mtx mt,guVector *src,guVector *dst);
353-
void c_guVecCross(guVector *a,guVector *b,guVector *axb);
354-
void c_guVecMultiplySR(Mtx mt,guVector *src,guVector *dst);
355-
f32 c_guVecDotProduct(guVector *a,guVector *b);
352+
void c_guVecMultiply(const Mtx mt,const guVector *src,guVector *dst);
353+
void c_guVecCross(const guVector *a,const guVector *b,guVector *axb);
354+
void c_guVecMultiplySR(const Mtx mt,const guVector *src,guVector *dst);
355+
f32 c_guVecDotProduct(const guVector *a,const guVector *b);
356356

357357
#ifdef GEKKO
358-
void ps_guVecAdd( guVector *a, guVector *b, guVector *ab);
359-
void ps_guVecSub( guVector *a, guVector *b, guVector *ab);
360-
void ps_guVecScale( guVector *src, guVector *dst,f32 scale);
358+
void ps_guVecAdd(const guVector *a, const guVector *b, guVector *ab);
359+
void ps_guVecSub(const guVector *a, const guVector *b, guVector *ab);
360+
void ps_guVecScale(const guVector *src, guVector *dst,f32 scale);
361361
void ps_guVecNormalize( guVector *v);
362-
void ps_guVecCross( guVector *a, guVector *b, guVector *axb);
363-
void ps_guVecMultiply( Mtx mt, guVector *src, guVector *dst);
364-
void ps_guVecMultiplySR( Mtx mt, guVector *src, guVector *dst);
365-
f32 ps_guVecDotProduct( guVector *a, guVector *b);
362+
void ps_guVecCross(const guVector *a, const guVector *b, guVector *axb);
363+
void ps_guVecMultiply(const Mtx mt, const guVector *src, guVector *dst);
364+
void ps_guVecMultiplySR(const Mtx mt, const guVector *src, guVector *dst);
365+
f32 ps_guVecDotProduct(const guVector *a, const guVector *b);
366366
#endif //GEKKO
367367

368-
void c_guQuatAdd(guQuaternion *a,guQuaternion *b,guQuaternion *ab);
369-
void c_guQuatSub(guQuaternion *a,guQuaternion *b,guQuaternion *ab);
370-
void c_guQuatMultiply(guQuaternion *a,guQuaternion *b,guQuaternion *ab);
371-
void c_guQuatNormalize(guQuaternion *a,guQuaternion *d);
372-
void c_guQuatInverse(guQuaternion *a,guQuaternion *d);
373-
void c_guQuatMtx(guQuaternion *a,Mtx m);
368+
void c_guQuatAdd(const guQuaternion *a,const guQuaternion *b,guQuaternion *ab);
369+
void c_guQuatSub(const guQuaternion *a,const guQuaternion *b,guQuaternion *ab);
370+
void c_guQuatMultiply(const guQuaternion *a,const guQuaternion *b,guQuaternion *ab);
371+
void c_guQuatNormalize(const guQuaternion *a,guQuaternion *d);
372+
void c_guQuatInverse(const guQuaternion *a,guQuaternion *d);
373+
void c_guQuatMtx(guQuaternion *a,const Mtx m);
374374

375375
#ifdef GEKKO
376-
void ps_guQuatAdd( guQuaternion *a, guQuaternion *b, guQuaternion *ab);
377-
void ps_guQuatSub( guQuaternion *a, guQuaternion *b, guQuaternion *ab);
378-
void ps_guQuatMultiply( guQuaternion *a, guQuaternion *b, guQuaternion *ab);
379-
void ps_guQuatNormalize( guQuaternion *a, guQuaternion *d);
380-
void ps_guQuatInverse( guQuaternion *a, guQuaternion *d);
376+
void ps_guQuatAdd(const guQuaternion *a, const guQuaternion *b, guQuaternion *ab);
377+
void ps_guQuatSub(const guQuaternion *a, const guQuaternion *b, guQuaternion *ab);
378+
void ps_guQuatMultiply(const guQuaternion *a, const guQuaternion *b, guQuaternion *ab);
379+
void ps_guQuatNormalize(const guQuaternion *a, guQuaternion *d);
380+
void ps_guQuatInverse(const guQuaternion *a, guQuaternion *d);
381381
#endif
382382

383383
void c_guMtxIdentity(Mtx mt);
384-
void c_guMtxCopy(Mtx src,Mtx dst);
385-
void c_guMtxConcat(Mtx a,Mtx b,Mtx ab);
384+
void c_guMtxCopy(const Mtx src,Mtx dst);
385+
void c_guMtxConcat(const Mtx a,const Mtx b,Mtx ab);
386386
void c_guMtxScale(Mtx mt,f32 xS,f32 yS,f32 zS);
387-
void c_guMtxScaleApply(Mtx src,Mtx dst,f32 xS,f32 yS,f32 zS);
388-
void c_guMtxApplyScale(Mtx src,Mtx dst,f32 xS,f32 yS,f32 zS);
387+
void c_guMtxScaleApply(const Mtx src,Mtx dst,f32 xS,f32 yS,f32 zS);
388+
void c_guMtxApplyScale(const Mtx src,Mtx dst,f32 xS,f32 yS,f32 zS);
389389
void c_guMtxTrans(Mtx mt,f32 xT,f32 yT,f32 zT);
390-
void c_guMtxTransApply(Mtx src,Mtx dst,f32 xT,f32 yT,f32 zT);
391-
void c_guMtxApplyTrans(Mtx src,Mtx dst,f32 xT,f32 yT,f32 zT);
392-
u32 c_guMtxInverse(Mtx src,Mtx inv);
393-
u32 c_guMtxInvXpose(Mtx src,Mtx xPose);
394-
void c_guMtxTranspose(Mtx src,Mtx xPose);
390+
void c_guMtxTransApply(const Mtx src,Mtx dst,f32 xT,f32 yT,f32 zT);
391+
void c_guMtxApplyTrans(const Mtx src,Mtx dst,f32 xT,f32 yT,f32 zT);
392+
u32 c_guMtxInverse(const Mtx src,Mtx inv);
393+
u32 c_guMtxInvXpose(const Mtx src,Mtx xPose);
394+
void c_guMtxTranspose(const Mtx src,Mtx xPose);
395395
void c_guMtxRotRad(Mtx mt,const char axis,f32 rad);
396396
void c_guMtxRotTrig(Mtx mt,const char axis,f32 sinA,f32 cosA);
397397
void c_guMtxRotAxisRad(Mtx mt,guVector *axis,f32 rad);
398-
void c_guMtxReflect(Mtx m,guVector *p,guVector *n);
399-
void c_guMtxQuat(Mtx m,guQuaternion *a);
398+
void c_guMtxReflect(Mtx m,const guVector *p,const guVector *n);
399+
void c_guMtxQuat(Mtx m,const guQuaternion *a);
400400

401401
#ifdef GEKKO
402402
void ps_guMtxIdentity( Mtx mt);
403-
void ps_guMtxCopy( Mtx src, Mtx dst);
404-
void ps_guMtxConcat( Mtx a, Mtx b, Mtx ab);
405-
void ps_guMtxTranspose( Mtx src, Mtx xPose);
406-
u32 ps_guMtxInverse( Mtx src, Mtx inv);
407-
u32 ps_guMtxInvXpose( Mtx src, Mtx xPose);
403+
void ps_guMtxCopy(const Mtx src, Mtx dst);
404+
void ps_guMtxConcat(const Mtx a, const Mtx b, Mtx ab);
405+
void ps_guMtxTranspose(const Mtx src, Mtx xPose);
406+
u32 ps_guMtxInverse(const Mtx src, Mtx inv);
407+
u32 ps_guMtxInvXpose(const Mtx src, Mtx xPose);
408408
void ps_guMtxScale( Mtx mt, f32 xS, f32 yS, f32 zS);
409-
void ps_guMtxScaleApply( Mtx src, Mtx dst, f32 xS, f32 yS, f32 zS);
410-
void ps_guMtxApplyScale( Mtx src, Mtx dst, f32 xS, f32 yS, f32 zS);
409+
void ps_guMtxScaleApply(const Mtx src, Mtx dst, f32 xS, f32 yS, f32 zS);
410+
void ps_guMtxApplyScale(const Mtx src, Mtx dst, f32 xS, f32 yS, f32 zS);
411411
void ps_guMtxTrans( Mtx mt, f32 xT, f32 yT, f32 zT);
412-
void ps_guMtxTransApply( Mtx src, Mtx dst, f32 xT, f32 yT, f32 zT);
413-
void ps_guMtxApplyTrans( Mtx src, Mtx dst, f32 xT, f32 yT, f32 zT);
412+
void ps_guMtxTransApply(const Mtx src, Mtx dst, f32 xT, f32 yT, f32 zT);
413+
void ps_guMtxApplyTrans(const Mtx src, Mtx dst, f32 xT, f32 yT, f32 zT);
414414
void ps_guMtxRotRad( Mtx mt, const char axis, f32 rad);
415415
void ps_guMtxRotTrig( Mtx mt, const char axis, f32 sinA, f32 cosA);
416416
void ps_guMtxRotAxisRad( Mtx mt, guVector *axis, f32 tmp0);
417-
void ps_guMtxReflect( Mtx m, guVector *p, guVector *n);
417+
void ps_guMtxReflect( Mtx m, const guVector *p, const guVector *n);
418418
#endif //GEKKO
419419

420420
void guMtx44Identity(Mtx44 mt);
421-
void guMtx44Copy(Mtx44 src,Mtx44 dst);
422-
u32 guMtx44Inverse(Mtx44 src,Mtx44 inv);
421+
void guMtx44Copy(const Mtx44 src,Mtx44 dst);
422+
u32 guMtx44Inverse(const Mtx44 src,Mtx44 inv);
423423

424424
#ifdef MTX_USE_C
425425

0 commit comments

Comments
 (0)