OpenClonk
StdMeshMath.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  StdMeshVector
 
struct  StdMeshVertex
 
struct  StdMeshQuaternion
 
struct  StdMeshTransformation
 
class  StdMeshMatrix
 
class  StdProjectionMatrix
 

Functions

StdMeshMatrix operator* (const StdMeshMatrix &lhs, const StdMeshMatrix &rhs)
 
StdMeshMatrix operator* (float lhs, const StdMeshMatrix &rhs)
 
StdMeshMatrix operator* (const StdMeshMatrix &lhs, float rhs)
 
StdMeshMatrixoperator*= (StdMeshMatrix &lhs, const StdMeshMatrix &rhs)
 
StdMeshMatrix operator+ (const StdMeshMatrix &lhs, const StdMeshMatrix &rhs)
 
StdProjectionMatrix operator* (const StdProjectionMatrix &lhs, const StdProjectionMatrix &rhs)
 
StdProjectionMatrixoperator*= (StdProjectionMatrix &lhs, const StdProjectionMatrix &rhs)
 
StdMeshQuaternion operator- (const StdMeshQuaternion &rhs)
 
StdMeshQuaternion operator* (const StdMeshQuaternion &lhs, const StdMeshQuaternion &rhs)
 
StdMeshQuaternionoperator*= (StdMeshQuaternion &lhs, float rhs)
 
StdMeshQuaternion operator* (const StdMeshQuaternion &lhs, float rhs)
 
StdMeshQuaternion operator* (float lhs, const StdMeshQuaternion &rhs)
 
StdMeshQuaternionoperator+= (StdMeshQuaternion &lhs, const StdMeshQuaternion &rhs)
 
StdMeshQuaternion operator+ (const StdMeshQuaternion &lhs, const StdMeshQuaternion &rhs)
 
StdMeshQuaternion operator- (const StdMeshQuaternion &lhs, const StdMeshQuaternion &rhs)
 
StdMeshTransformation operator* (const StdMeshTransformation &lhs, const StdMeshTransformation &rhs)
 
StdMeshVector operator- (const StdMeshVector &rhs)
 
StdMeshVectoroperator+= (StdMeshVector &lhs, const StdMeshVector &rhs)
 
StdMeshVector operator+ (const StdMeshVector &lhs, const StdMeshVector &rhs)
 
StdMeshVectoroperator-= (StdMeshVector &lhs, const StdMeshVector &rhs)
 
StdMeshVector operator- (const StdMeshVector &lhs, const StdMeshVector &rhs)
 
StdMeshVector operator* (const StdMeshVector &lhs, const StdMeshVector &rhs)
 
StdMeshVectoroperator*= (StdMeshVector &lhs, float rhs)
 
StdMeshVector operator* (const StdMeshVector &lhs, float rhs)
 
StdMeshVector operator* (float lhs, const StdMeshVector &rhs)
 
StdMeshVector operator/ (const StdMeshVector &lhs, const StdMeshVector &rhs)
 
StdMeshVector operator/ (float lhs, const StdMeshVector &rhs)
 
StdMeshVector operator/ (const StdMeshVector &lhs, float rhs)
 
StdMeshVector operator* (const StdMeshMatrix &lhs, const StdMeshVector &rhs)
 
StdMeshVector operator* (const StdMeshQuaternion &lhs, const StdMeshVector &rhs)
 
StdMeshVertexoperator+= (StdMeshVertex &lhs, const StdMeshVertex &rhs)
 
StdMeshVertex operator+ (const StdMeshVertex &lhs, const StdMeshVertex &rhs)
 
StdMeshVertex operator* (float lhs, const StdMeshVertex &rhs)
 
StdMeshVertex operator* (const StdMeshVertex &lhs, float rhs)
 
StdMeshVertex operator* (const StdMeshMatrix &lhs, const StdMeshVertex &rhs)
 
template<typename MatrixType >
void Translate (MatrixType &mat, float dx, float dy, float dz)
 
template<typename MatrixType >
void Scale (MatrixType &mat, float sx, float sy, float sz)
 
template<typename MatrixType >
void Rotate (MatrixType &mat, float angle, float x, float y, float z)
 
template<typename MatrixType >
void Perspective (MatrixType &mat, float cot_fovy2, float aspect, float nearVal, float farVal)
 

Function Documentation

◆ operator*() [1/16]

StdMeshMatrix operator* ( const StdMeshMatrix lhs,
const StdMeshMatrix rhs 
)

Definition at line 478 of file StdMeshMath.cpp.

Referenced by StdProjectionMatrix::data().

479 {
480  StdMeshMatrix m;
481 
482  m(0,0) = lhs(0,0)*rhs(0,0) + lhs(0,1)*rhs(1,0) + lhs(0,2)*rhs(2,0);
483  m(1,0) = lhs(1,0)*rhs(0,0) + lhs(1,1)*rhs(1,0) + lhs(1,2)*rhs(2,0);
484  m(2,0) = lhs(2,0)*rhs(0,0) + lhs(2,1)*rhs(1,0) + lhs(2,2)*rhs(2,0);
485 
486  m(0,1) = lhs(0,0)*rhs(0,1) + lhs(0,1)*rhs(1,1) + lhs(0,2)*rhs(2,1);
487  m(1,1) = lhs(1,0)*rhs(0,1) + lhs(1,1)*rhs(1,1) + lhs(1,2)*rhs(2,1);
488  m(2,1) = lhs(2,0)*rhs(0,1) + lhs(2,1)*rhs(1,1) + lhs(2,2)*rhs(2,1);
489 
490  m(0,2) = lhs(0,0)*rhs(0,2) + lhs(0,1)*rhs(1,2) + lhs(0,2)*rhs(2,2);
491  m(1,2) = lhs(1,0)*rhs(0,2) + lhs(1,1)*rhs(1,2) + lhs(1,2)*rhs(2,2);
492  m(2,2) = lhs(2,0)*rhs(0,2) + lhs(2,1)*rhs(1,2) + lhs(2,2)*rhs(2,2);
493 
494  m(0,3) = lhs(0,0)*rhs(0,3) + lhs(0,1)*rhs(1,3) + lhs(0,2)*rhs(2,3) + lhs(0,3);
495  m(1,3) = lhs(1,0)*rhs(0,3) + lhs(1,1)*rhs(1,3) + lhs(1,2)*rhs(2,3) + lhs(1,3);
496  m(2,3) = lhs(2,0)*rhs(0,3) + lhs(2,1)*rhs(1,3) + lhs(2,2)*rhs(2,3) + lhs(2,3);
497 
498  return m;
499 }
Here is the caller graph for this function:

◆ operator*() [2/16]

StdMeshMatrix operator* ( float  lhs,
const StdMeshMatrix rhs 
)

Definition at line 501 of file StdMeshMath.cpp.

502 {
503  StdMeshMatrix m;
504  m(0,0) = lhs * rhs(0,0);
505  m(1,0) = lhs * rhs(1,0);
506  m(2,0) = lhs * rhs(2,0);
507  m(0,1) = lhs * rhs(0,1);
508  m(1,1) = lhs * rhs(1,1);
509  m(2,1) = lhs * rhs(2,1);
510  m(0,2) = lhs * rhs(0,2);
511  m(1,2) = lhs * rhs(1,2);
512  m(2,2) = lhs * rhs(2,2);
513  m(0,3) = lhs * rhs(0,3);
514  m(1,3) = lhs * rhs(1,3);
515  m(2,3) = lhs * rhs(2,3);
516  return m;
517 }

◆ operator*() [3/16]

StdMeshMatrix operator* ( const StdMeshMatrix lhs,
float  rhs 
)

Definition at line 519 of file StdMeshMath.cpp.

520 {
521  return rhs * lhs;
522 }

◆ operator*() [4/16]

StdProjectionMatrix operator* ( const StdProjectionMatrix lhs,
const StdProjectionMatrix rhs 
)

Definition at line 548 of file StdMeshMath.cpp.

549 {
551 
552  m(0,0) = lhs(0,0)*rhs(0,0) + lhs(0,1)*rhs(1,0) + lhs(0,2)*rhs(2,0) + lhs(0,3)*rhs(3,0);
553  m(1,0) = lhs(1,0)*rhs(0,0) + lhs(1,1)*rhs(1,0) + lhs(1,2)*rhs(2,0) + lhs(1,3)*rhs(3,0);
554  m(2,0) = lhs(2,0)*rhs(0,0) + lhs(2,1)*rhs(1,0) + lhs(2,2)*rhs(2,0) + lhs(2,3)*rhs(3,0);
555  m(3,0) = lhs(3,0)*rhs(0,0) + lhs(3,1)*rhs(1,0) + lhs(3,2)*rhs(2,0) + lhs(3,3)*rhs(3,0);
556 
557  m(0,1) = lhs(0,0)*rhs(0,1) + lhs(0,1)*rhs(1,1) + lhs(0,2)*rhs(2,1) + lhs(0,3)*rhs(3,1);
558  m(1,1) = lhs(1,0)*rhs(0,1) + lhs(1,1)*rhs(1,1) + lhs(1,2)*rhs(2,1) + lhs(1,3)*rhs(3,1);
559  m(2,1) = lhs(2,0)*rhs(0,1) + lhs(2,1)*rhs(1,1) + lhs(2,2)*rhs(2,1) + lhs(2,3)*rhs(3,1);
560  m(3,1) = lhs(3,0)*rhs(0,1) + lhs(3,1)*rhs(1,1) + lhs(3,2)*rhs(2,1) + lhs(3,3)*rhs(3,1);
561 
562  m(0,2) = lhs(0,0)*rhs(0,2) + lhs(0,1)*rhs(1,2) + lhs(0,2)*rhs(2,2) + lhs(0,3)*rhs(3,2);
563  m(1,2) = lhs(1,0)*rhs(0,2) + lhs(1,1)*rhs(1,2) + lhs(1,2)*rhs(2,2) + lhs(1,3)*rhs(3,2);
564  m(2,2) = lhs(2,0)*rhs(0,2) + lhs(2,1)*rhs(1,2) + lhs(2,2)*rhs(2,2) + lhs(2,3)*rhs(3,2);
565  m(3,2) = lhs(3,0)*rhs(0,2) + lhs(3,1)*rhs(1,2) + lhs(3,2)*rhs(2,2) + lhs(3,3)*rhs(3,2);
566 
567  m(0,3) = lhs(0,0)*rhs(0,3) + lhs(0,1)*rhs(1,3) + lhs(0,2)*rhs(2,3) + lhs(0,3)*rhs(3,3);
568  m(1,3) = lhs(1,0)*rhs(0,3) + lhs(1,1)*rhs(1,3) + lhs(1,2)*rhs(2,3) + lhs(1,3)*rhs(3,3);
569  m(2,3) = lhs(2,0)*rhs(0,3) + lhs(2,1)*rhs(1,3) + lhs(2,2)*rhs(2,3) + lhs(2,3)*rhs(3,3);
570  m(3,3) = lhs(3,0)*rhs(0,3) + lhs(3,1)*rhs(1,3) + lhs(3,2)*rhs(2,3) + lhs(3,3)*rhs(3,3);
571 
572  return m;
573 }

◆ operator*() [5/16]

StdMeshQuaternion operator* ( const StdMeshQuaternion lhs,
const StdMeshQuaternion rhs 
)

Definition at line 591 of file StdMeshMath.cpp.

References StdMeshQuaternion::w, StdMeshQuaternion::x, StdMeshQuaternion::y, and StdMeshQuaternion::z.

592 {
594  q.w = lhs.w*rhs.w - lhs.x*rhs.x - lhs.y*rhs.y - lhs.z*rhs.z;
595  q.x = lhs.w*rhs.x + lhs.x*rhs.w + lhs.y*rhs.z - lhs.z*rhs.y;
596  q.y = lhs.w*rhs.y + lhs.y*rhs.w + lhs.z*rhs.x - lhs.x*rhs.z;
597  q.z = lhs.w*rhs.z + lhs.z*rhs.w + lhs.x*rhs.y - lhs.y*rhs.x;
598  return q;
599 }

◆ operator*() [6/16]

StdMeshQuaternion operator* ( const StdMeshQuaternion lhs,
float  rhs 
)

Definition at line 610 of file StdMeshMath.cpp.

611 {
612  StdMeshQuaternion q(lhs);
613  q *= rhs;
614  return q;
615 }

◆ operator*() [7/16]

StdMeshQuaternion operator* ( float  lhs,
const StdMeshQuaternion rhs 
)

Definition at line 617 of file StdMeshMath.cpp.

618 {
619  return rhs * lhs;
620 }

◆ operator*() [8/16]

StdMeshTransformation operator* ( const StdMeshTransformation lhs,
const StdMeshTransformation rhs 
)

Definition at line 648 of file StdMeshMath.cpp.

References StdMeshTransformation::rotate, StdMeshTransformation::scale, and StdMeshTransformation::translate.

649 {
651  t.rotate = lhs.rotate * rhs.rotate;
652  t.scale = lhs.scale * rhs.scale;
653  t.translate = lhs.translate + lhs.rotate * (lhs.scale * rhs.translate);
654  return t;
655 }
StdMeshQuaternion rotate
Definition: StdMeshMath.h:75
StdMeshVector scale
Definition: StdMeshMath.h:74
StdMeshVector translate
Definition: StdMeshMath.h:76

◆ operator*() [9/16]

StdMeshVector operator* ( const StdMeshVector lhs,
const StdMeshVector rhs 
)

Definition at line 696 of file StdMeshMath.cpp.

References StdMeshVector::x, StdMeshVector::y, and StdMeshVector::z.

697 {
698  StdMeshVector v;
699  v.x = lhs.x * rhs.x;
700  v.y = lhs.y * rhs.y;
701  v.z = lhs.z * rhs.z;
702  return v;
703 }

◆ operator*() [10/16]

StdMeshVector operator* ( const StdMeshVector lhs,
float  rhs 
)

Definition at line 713 of file StdMeshMath.cpp.

714 {
715  StdMeshVector v(lhs);
716  v *= rhs;
717  return v;
718 }

◆ operator*() [11/16]

StdMeshVector operator* ( float  lhs,
const StdMeshVector rhs 
)

Definition at line 720 of file StdMeshMath.cpp.

721 {
722  return rhs * lhs;
723 }

◆ operator*() [12/16]

StdMeshVector operator* ( const StdMeshMatrix lhs,
const StdMeshVector rhs 
)

Definition at line 752 of file StdMeshMath.cpp.

References StdMeshVector::x, StdMeshVector::y, and StdMeshVector::z.

753 {
754  StdMeshVector v;
755  v.x = lhs(0,0)*rhs.x + lhs(0,1)*rhs.y + lhs(0,2)*rhs.z;
756  v.y = lhs(1,0)*rhs.x + lhs(1,1)*rhs.y + lhs(1,2)*rhs.z;
757  v.z = lhs(2,0)*rhs.x + lhs(2,1)*rhs.y + lhs(2,2)*rhs.z;
758  return v;
759 }

◆ operator*() [13/16]

StdMeshVector operator* ( const StdMeshQuaternion lhs,
const StdMeshVector rhs 
)

Definition at line 761 of file StdMeshMath.cpp.

References StdMeshVector::Cross(), StdMeshQuaternion::w, StdMeshQuaternion::x, StdMeshQuaternion::y, and StdMeshQuaternion::z.

762 {
763  StdMeshVector v = { lhs.x, lhs.y, lhs.z };
764  StdMeshVector uv = 2.0f * StdMeshVector::Cross(v, rhs);
765  StdMeshVector uuv = StdMeshVector::Cross(v, uv);
766  return rhs + lhs.w * uv + uuv;
767 }
static StdMeshVector Cross(const StdMeshVector &lhs, const StdMeshVector &rhs)
Definition: StdMeshMath.cpp:47
Here is the call graph for this function:

◆ operator*() [14/16]

StdMeshVertex operator* ( float  lhs,
const StdMeshVertex rhs 
)

Definition at line 787 of file StdMeshMath.cpp.

References StdMeshVertex::nx, StdMeshVertex::ny, StdMeshVertex::nz, StdMeshVertex::x, StdMeshVertex::y, and StdMeshVertex::z.

788 {
789  StdMeshVertex vtx;
790  vtx.nx = lhs*rhs.nx;
791  vtx.ny = lhs*rhs.ny;
792  vtx.nz = lhs*rhs.nz;
793  vtx.x = lhs*rhs.x;
794  vtx.y = lhs*rhs.y;
795  vtx.z = lhs*rhs.z;
796  return vtx;
797 }

◆ operator*() [15/16]

StdMeshVertex operator* ( const StdMeshVertex lhs,
float  rhs 
)

Definition at line 799 of file StdMeshMath.cpp.

800 {
801  return rhs * lhs;
802 }

◆ operator*() [16/16]

StdMeshVertex operator* ( const StdMeshMatrix lhs,
const StdMeshVertex rhs 
)

Definition at line 804 of file StdMeshMath.cpp.

References StdMeshVertex::nx, StdMeshVertex::ny, StdMeshVertex::nz, StdMeshVertex::u, StdMeshVertex::v, StdMeshVertex::x, StdMeshVertex::y, and StdMeshVertex::z.

805 {
806  StdMeshVertex vtx;
807  vtx.nx = lhs(0,0)*rhs.nx + lhs(0,1)*rhs.ny + lhs(0,2)*rhs.nz;
808  vtx.ny = lhs(1,0)*rhs.nx + lhs(1,1)*rhs.ny + lhs(0,2)*rhs.nz;
809  vtx.nz = lhs(2,0)*rhs.nx + lhs(2,1)*rhs.ny + lhs(2,2)*rhs.nz;
810  vtx.x = lhs(0,0)*rhs.x + lhs(0,1)*rhs.y + lhs(0,2)*rhs.z + lhs(0,3);
811  vtx.y = lhs(1,0)*rhs.x + lhs(1,1)*rhs.y + lhs(1,2)*rhs.z + lhs(1,3);
812  vtx.z = lhs(2,0)*rhs.x + lhs(2,1)*rhs.y + lhs(2,2)*rhs.z + lhs(2,3);
813  vtx.u = rhs.u; vtx.v = rhs.v;
814  return vtx;
815 }

◆ operator*=() [1/4]

StdMeshMatrix& operator*= ( StdMeshMatrix lhs,
const StdMeshMatrix rhs 
)

Definition at line 524 of file StdMeshMath.cpp.

Referenced by StdProjectionMatrix::data().

525 {
526  lhs = lhs * rhs;
527  return lhs;
528 }
Here is the caller graph for this function:

◆ operator*=() [2/4]

StdProjectionMatrix& operator*= ( StdProjectionMatrix lhs,
const StdProjectionMatrix rhs 
)

Definition at line 575 of file StdMeshMath.cpp.

576 {
577  lhs = lhs * rhs;
578  return lhs;
579 }

◆ operator*=() [3/4]

StdMeshQuaternion& operator*= ( StdMeshQuaternion lhs,
float  rhs 
)

Definition at line 601 of file StdMeshMath.cpp.

References StdMeshQuaternion::w, StdMeshQuaternion::x, StdMeshQuaternion::y, and StdMeshQuaternion::z.

602 {
603  lhs.w *= rhs;
604  lhs.x *= rhs;
605  lhs.y *= rhs;
606  lhs.z *= rhs;
607  return lhs;
608 }

◆ operator*=() [4/4]

StdMeshVector& operator*= ( StdMeshVector lhs,
float  rhs 
)

Definition at line 705 of file StdMeshMath.cpp.

References StdMeshVector::x, StdMeshVector::y, and StdMeshVector::z.

706 {
707  lhs.x *= rhs;
708  lhs.y *= rhs;
709  lhs.z *= rhs;
710  return lhs;
711 }

◆ operator+() [1/4]

StdMeshMatrix operator+ ( const StdMeshMatrix lhs,
const StdMeshMatrix rhs 
)

Definition at line 530 of file StdMeshMath.cpp.

Referenced by StdProjectionMatrix::data().

531 {
532  StdMeshMatrix m;
533  m(0,0) = lhs(0,0) + rhs(0,0);
534  m(1,0) = lhs(1,0) + rhs(1,0);
535  m(2,0) = lhs(2,0) + rhs(2,0);
536  m(0,1) = lhs(0,1) + rhs(0,1);
537  m(1,1) = lhs(1,1) + rhs(1,1);
538  m(2,1) = lhs(2,1) + rhs(2,1);
539  m(0,2) = lhs(0,2) + rhs(0,2);
540  m(1,2) = lhs(1,2) + rhs(1,2);
541  m(2,2) = lhs(2,2) + rhs(2,2);
542  m(0,3) = lhs(0,3) + rhs(0,3);
543  m(1,3) = lhs(1,3) + rhs(1,3);
544  m(2,3) = lhs(2,3) + rhs(2,3);
545  return m;
546 }
Here is the caller graph for this function:

◆ operator+() [2/4]

StdMeshQuaternion operator+ ( const StdMeshQuaternion lhs,
const StdMeshQuaternion rhs 
)

Definition at line 631 of file StdMeshMath.cpp.

632 {
633  StdMeshQuaternion q(lhs);
634  q += rhs;
635  return q;
636 }

◆ operator+() [3/4]

StdMeshVector operator+ ( const StdMeshVector lhs,
const StdMeshVector rhs 
)

Definition at line 674 of file StdMeshMath.cpp.

675 {
676  StdMeshVector v(lhs);
677  v += rhs;
678  return v;
679 }

◆ operator+() [4/4]

StdMeshVertex operator+ ( const StdMeshVertex lhs,
const StdMeshVertex rhs 
)

Definition at line 780 of file StdMeshMath.cpp.

781 {
782  StdMeshVertex vtx(lhs);
783  vtx += rhs;
784  return vtx;
785 }

◆ operator+=() [1/3]

StdMeshQuaternion& operator+= ( StdMeshQuaternion lhs,
const StdMeshQuaternion rhs 
)

Definition at line 622 of file StdMeshMath.cpp.

References StdMeshQuaternion::w, StdMeshQuaternion::x, StdMeshQuaternion::y, and StdMeshQuaternion::z.

Referenced by StdProjectionMatrix::data().

623 {
624  lhs.w += rhs.w;
625  lhs.x += rhs.x;
626  lhs.y += rhs.y;
627  lhs.z += rhs.z;
628  return lhs;
629 }
Here is the caller graph for this function:

◆ operator+=() [2/3]

StdMeshVector& operator+= ( StdMeshVector lhs,
const StdMeshVector rhs 
)

Definition at line 666 of file StdMeshMath.cpp.

References StdMeshVector::x, StdMeshVector::y, and StdMeshVector::z.

667 {
668  lhs.x += rhs.x;
669  lhs.y += rhs.y;
670  lhs.z += rhs.z;
671  return lhs;
672 }

◆ operator+=() [3/3]

StdMeshVertex& operator+= ( StdMeshVertex lhs,
const StdMeshVertex rhs 
)

Definition at line 769 of file StdMeshMath.cpp.

References StdMeshVertex::nx, StdMeshVertex::ny, StdMeshVertex::nz, StdMeshVertex::x, StdMeshVertex::y, and StdMeshVertex::z.

770 {
771  lhs.nx += rhs.nx;
772  lhs.ny += rhs.ny;
773  lhs.nz += rhs.nz;
774  lhs.x += rhs.x;
775  lhs.y += rhs.y;
776  lhs.z += rhs.z;
777  return lhs;
778 }

◆ operator-() [1/4]

StdMeshQuaternion operator- ( const StdMeshQuaternion rhs)

Definition at line 581 of file StdMeshMath.cpp.

References StdMeshQuaternion::w, StdMeshQuaternion::x, StdMeshQuaternion::y, and StdMeshQuaternion::z.

Referenced by StdProjectionMatrix::data().

582 {
584  q.w = -rhs.w;
585  q.x = -rhs.x;
586  q.y = -rhs.y;
587  q.z = -rhs.z;
588  return q;
589 }
Here is the caller graph for this function:

◆ operator-() [2/4]

StdMeshQuaternion operator- ( const StdMeshQuaternion lhs,
const StdMeshQuaternion rhs 
)

Definition at line 638 of file StdMeshMath.cpp.

References StdMeshQuaternion::w, StdMeshQuaternion::x, StdMeshQuaternion::y, and StdMeshQuaternion::z.

639 {
641  q.w = lhs.w - rhs.w;
642  q.x = lhs.x - rhs.x;
643  q.y = lhs.y - rhs.y;
644  q.z = lhs.z - rhs.z;
645  return q;
646 }

◆ operator-() [3/4]

StdMeshVector operator- ( const StdMeshVector rhs)

Definition at line 657 of file StdMeshMath.cpp.

References StdMeshVector::x, StdMeshVector::y, and StdMeshVector::z.

658 {
659  StdMeshVector v;
660  v.x = -rhs.x;
661  v.y = -rhs.y;
662  v.z = -rhs.z;
663  return v;
664 }

◆ operator-() [4/4]

StdMeshVector operator- ( const StdMeshVector lhs,
const StdMeshVector rhs 
)

Definition at line 689 of file StdMeshMath.cpp.

690 {
691  StdMeshVector v(lhs);
692  v -= rhs;
693  return v;
694 }

◆ operator-=()

StdMeshVector& operator-= ( StdMeshVector lhs,
const StdMeshVector rhs 
)

Definition at line 681 of file StdMeshMath.cpp.

References StdMeshVector::x, StdMeshVector::y, and StdMeshVector::z.

Referenced by StdProjectionMatrix::data().

682 {
683  lhs.x -= rhs.x;
684  lhs.y -= rhs.y;
685  lhs.z -= rhs.z;
686  return lhs;
687 }
Here is the caller graph for this function:

◆ operator/() [1/3]

StdMeshVector operator/ ( const StdMeshVector lhs,
const StdMeshVector rhs 
)

Definition at line 725 of file StdMeshMath.cpp.

References StdMeshVector::x, StdMeshVector::y, and StdMeshVector::z.

Referenced by StdProjectionMatrix::data().

726 {
727  StdMeshVector v;
728  v.x = lhs.x/rhs.x;
729  v.y = lhs.y/rhs.y;
730  v.z = lhs.z/rhs.z;
731  return v;
732 }
Here is the caller graph for this function:

◆ operator/() [2/3]

StdMeshVector operator/ ( float  lhs,
const StdMeshVector rhs 
)

Definition at line 734 of file StdMeshMath.cpp.

References StdMeshVector::x, StdMeshVector::y, and StdMeshVector::z.

735 {
736  StdMeshVector v;
737  v.x = lhs/rhs.x;
738  v.y = lhs/rhs.y;
739  v.z = lhs/rhs.z;
740  return v;
741 }

◆ operator/() [3/3]

StdMeshVector operator/ ( const StdMeshVector lhs,
float  rhs 
)

Definition at line 743 of file StdMeshMath.cpp.

References StdMeshVector::x, StdMeshVector::y, and StdMeshVector::z.

744 {
745  StdMeshVector v;
746  v.x = lhs.x/rhs;
747  v.y = lhs.y/rhs;
748  v.z = lhs.z/rhs;
749  return v;
750 }

◆ Perspective()

template<typename MatrixType >
void Perspective ( MatrixType &  mat,
float  cot_fovy2,
float  aspect,
float  nearVal,
float  farVal 
)

Definition at line 216 of file StdMeshMath.h.

References z2.

Referenced by CStdGL::PerformMesh().

217 {
218  static_assert(MatrixType::NColumns >= 4, "Matrix must have at least 4 columns");
219 
220  const float fa = cot_fovy2 / aspect;
221  const float fb = cot_fovy2;
222  const float z1 = (nearVal + farVal) / (nearVal - farVal);
223  const float z2 = 2 * nearVal * farVal / (nearVal - farVal);
224 
225  for (int i = 0; i < MatrixType::NRows; ++i)
226  {
227  const float mat2 = mat(i, 2);
228  mat(i, 0) *= fa;
229  mat(i, 1) *= fb;
230  mat(i, 2) = mat2 * z1 - mat(i, 3);
231  mat(i, 3) = mat2 * z2;
232  }
233 }
#define z2
Here is the caller graph for this function:

◆ Rotate()

template<typename MatrixType >
void Rotate ( MatrixType &  mat,
float  angle,
float  x,
float  y,
float  z 
)

Definition at line 209 of file StdMeshMath.h.

Referenced by CStdGL::PrepareMaterial().

210 {
211  mat *= MatrixType::Rotate(angle, x, y, z);
212 }
void Rotate(MatrixType &mat, float angle, float x, float y, float z)
Definition: StdMeshMath.h:209
#define z
Here is the caller graph for this function:

◆ Scale()

template<typename MatrixType >
void Scale ( MatrixType &  mat,
float  sx,
float  sy,
float  sz 
)

Definition at line 195 of file StdMeshMath.h.

Referenced by StdMeshMatrix::Decompose(), C4ValueProviderRef< SourceT >::Execute(), CStdGL::PerformMesh(), CStdGL::PrepareMaterial(), and CStdGL::SetupMultiBlt().

196 {
197  static_assert(MatrixType::NColumns >= 3, "Matrix must have at least 3 columns");
198 
199  for (int i = 0; i < MatrixType::NRows; ++i)
200  {
201  mat(i, 0) *= sx;
202  mat(i, 1) *= sy;
203  mat(i, 2) *= sz;
204  }
205 }
Here is the caller graph for this function:

◆ Translate()

template<typename MatrixType >
void Translate ( MatrixType &  mat,
float  dx,
float  dy,
float  dz 
)

Definition at line 185 of file StdMeshMath.h.

Referenced by C4ParticleChunk::Draw(), C4ParticleList::Draw(), CStdGL::PerformMesh(), CStdGL::PrepareMaterial(), and CStdGL::SetupMultiBlt().

186 {
187  static_assert(MatrixType::NColumns >= 4, "Matrix must have at least 4 columns");
188 
189  for (int i = 0; i < MatrixType::NRows; ++i)
190  mat(i, 3) += mat(i,0)*dx + mat(i,1)*dy + mat(i,2)*dz;
191 }
Here is the caller graph for this function: