Skip to content

Commit bff05c5

Browse files
committed
Add missing quaternion functions
1 parent 404ea14 commit bff05c5

2 files changed

Lines changed: 32 additions & 17 deletions

File tree

include/ogc/gu.h

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -350,24 +350,26 @@ void c_guVecSub(const guVector *a,const guVector *b,guVector *ab);
350350
void c_guVecScale(const guVector *src,guVector *dst,f32 scale);
351351
void c_guVecNormalize(const guVector *src,guVector *unit);
352352
void c_guVecCross(const guVector *a,const guVector *b,guVector *axb);
353+
f32 c_guVecDotProduct(const guVector *a,const guVector *b);
353354
void c_guVecMultiply(const Mtx mt,const guVector *src,guVector *dst);
354355
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
358358
void ps_guVecAdd(const guVector *a,const guVector *b,guVector *ab);
359359
void ps_guVecSub(const guVector *a,const guVector *b,guVector *ab);
360360
void ps_guVecScale(const guVector *src,guVector *dst,f32 scale);
361361
void ps_guVecNormalize(const guVector *src,guVector *unit);
362362
void ps_guVecCross(const guVector *a,const guVector *b,guVector *axb);
363+
f32 ps_guVecDotProduct(const guVector *a,const guVector *b);
363364
void ps_guVecMultiply(const Mtx mt,const guVector *src,guVector *dst);
364365
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

368368
void c_guQuatAdd(const guQuaternion *a,const guQuaternion *b,guQuaternion *ab);
369369
void c_guQuatSub(const guQuaternion *a,const guQuaternion *b,guQuaternion *ab);
370370
void c_guQuatMultiply(const guQuaternion *a,const guQuaternion *b,guQuaternion *ab);
371+
void c_guQuatScale(const guQuaternion *src,guQuaternion *dst,f32 scale);
372+
f32 c_guQuatDotProduct(const guQuaternion *a,const guQuaternion *b);
371373
void c_guQuatNormalize(const guQuaternion *a,guQuaternion *d);
372374
void c_guQuatInverse(const guQuaternion *a,guQuaternion *d);
373375
void c_guQuatMtx(guQuaternion *a,const Mtx m);
@@ -376,6 +378,8 @@ void c_guQuatMtx(guQuaternion *a,const Mtx m);
376378
void ps_guQuatAdd(const guQuaternion *a,const guQuaternion *b,guQuaternion *ab);
377379
void ps_guQuatSub(const guQuaternion *a,const guQuaternion *b,guQuaternion *ab);
378380
void ps_guQuatMultiply(const guQuaternion *a,const guQuaternion *b,guQuaternion *ab);
381+
void ps_guQuatScale(const guQuaternion *src,guQuaternion *dst,f32 scale);
382+
f32 ps_guQuatDotProduct(const guQuaternion *a,const guQuaternion *b);
379383
void ps_guQuatNormalize(const guQuaternion *a,guQuaternion *d);
380384
void ps_guQuatInverse(const guQuaternion *a,guQuaternion *d);
381385
#endif
@@ -436,14 +440,16 @@ void guMtx44RotAxisRad(Mtx44 mt,const guVector *axis,f32 rad);
436440
#define guVecSub c_guVecSub
437441
#define guVecScale c_guVecScale
438442
#define guVecNormalize c_guVecNormalize
439-
#define guVecMultiply c_guVecMultiply
440443
#define guVecCross c_guVecCross
441-
#define guVecMultiplySR c_guVecMultiplySR
442444
#define guVecDotProduct c_guVecDotProduct
445+
#define guVecMultiply c_guVecMultiply
446+
#define guVecMultiplySR c_guVecMultiplySR
443447

444448
#define guQuatAdd c_guQuatAdd
445449
#define guQuatSub c_guQuatSub
446450
#define guQuatMultiply c_guQuatMultiply
451+
#define guQuatScale c_guQuatScale
452+
#define guQuatDotProduct c_guQuatDotProduct
447453
#define guQuatNormalize c_guQuatNormalize
448454
#define guQuatInverse c_guQuatInverse
449455
#define guQuatMtx c_guQuatMtx
@@ -472,14 +478,16 @@ void guMtx44RotAxisRad(Mtx44 mt,const guVector *axis,f32 rad);
472478
#define guVecSub ps_guVecSub
473479
#define guVecScale ps_guVecScale
474480
#define guVecNormalize ps_guVecNormalize
475-
#define guVecMultiply ps_guVecMultiply
476481
#define guVecCross ps_guVecCross
477-
#define guVecMultiplySR ps_guVecMultiplySR
478482
#define guVecDotProduct ps_guVecDotProduct
483+
#define guVecMultiply ps_guVecMultiply
484+
#define guVecMultiplySR ps_guVecMultiplySR
479485

480486
#define guQuatAdd ps_guQuatAdd
481487
#define guQuatSub ps_guQuatSub
482488
#define guQuatMultiply ps_guQuatMultiply
489+
#define guQuatScale ps_guQuatScale
490+
#define guQuatDotProduct ps_guQuatDotProduct
483491
#define guQuatNormalize ps_guQuatNormalize
484492
#define guQuatInverse ps_guQuatInverse
485493
#define guQuatMtx c_guQuatMtx

libogc/gu.c

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -903,7 +903,6 @@ void c_guMtxReflect(Mtx m,const guVector *p,const guVector *n)
903903
m[2][3] = pdotn * n->z;
904904
}
905905

906-
907906
void c_guVecAdd(const guVector *a,const guVector *b,guVector *ab)
908907
{
909908
ab->x = a->x + b->x;
@@ -925,7 +924,6 @@ void c_guVecScale(const guVector *src,guVector *dst,f32 scale)
925924
dst->z = src->z * scale;
926925
}
927926

928-
929927
void c_guVecNormalize(const guVector *src,guVector *unit)
930928
{
931929
f32 mag;
@@ -950,6 +948,11 @@ void c_guVecCross(const guVector *a,const guVector *b,guVector *axb)
950948
axb->z = vTmp.z;
951949
}
952950

951+
f32 c_guVecDotProduct(const guVector *a,const guVector *b)
952+
{
953+
return (a->x*b->x) + (a->y*b->y) + (a->z*b->z);
954+
}
955+
953956
void c_guVecMultiply(const Mtx mt,const guVector *src,guVector *dst)
954957
{
955958
guVector tmp;
@@ -977,15 +980,6 @@ void c_guVecMultiplySR(const Mtx mt,const guVector *src,guVector *dst)
977980
dst->z = tmp.z;
978981
}
979982

980-
f32 c_guVecDotProduct(const guVector *a,const guVector *b)
981-
{
982-
f32 dot;
983-
984-
dot = (a->x * b->x) + (a->y * b->y) + (a->z * b->z);
985-
986-
return dot;
987-
}
988-
989983
void c_guQuatAdd(const guQuaternion *a,const guQuaternion *b,guQuaternion *ab)
990984
{
991985
ab->x = a->x + b->x;
@@ -1096,6 +1090,19 @@ void ps_guQuatMultiply(const guQuaternion *a,const guQuaternion *b,guQuaternion
10961090
}
10971091
#endif
10981092

1093+
void c_guQuatScale(const guQuaternion *src,guQuaternion *dst,f32 scale)
1094+
{
1095+
dst->x = src->x * scale;
1096+
dst->y = src->y * scale;
1097+
dst->z = src->z * scale;
1098+
dst->w = src->w * scale;
1099+
}
1100+
1101+
f32 c_guQuatDotProduct(const guQuaternion *a,const guQuaternion *b)
1102+
{
1103+
return (a->x*b->x) + (a->y*b->y) + (a->z*b->z) + (a->w*b->w);
1104+
}
1105+
10991106
void c_guQuatNormalize(const guQuaternion *a,guQuaternion *d)
11001107
{
11011108
f32 dot,scale;

0 commit comments

Comments
 (0)