lib: add const qualifiers to vecmat function parameters

This commit is contained in:
Jan Engelhardt
2025-05-19 21:56:26 +02:00
parent f93e01c330
commit 9a6b5da647
6 changed files with 105 additions and 105 deletions

View File

@@ -80,7 +80,7 @@ void vm_ScaleAddVector(vector *d, const vector *p, const vector *v, const scalar
*d = *p + *v * s;
}
void vm_DivVector(vector *dest, vector *src, const scalar n) {
void vm_DivVector(vector *dest, const vector *src, const scalar n) {
// Divides a vector into n portions
// Dest can equal src
@@ -145,7 +145,7 @@ void vm_MatrixMulVector(vector *result, const vector *v, const matrix *m) {
}
// Multiply a vector times the transpose of a matrix
void vm_VectorMulTMatrix(vector *result, vector *v, matrix *m) {
void vm_VectorMulTMatrix(vector *result, const vector *v, const matrix *m) {
// assert(result != v);
*result = { vm_Dot3Vector(m->rvec.x(), m->uvec.x(), m->fvec.x(), v),
@@ -153,7 +153,7 @@ void vm_VectorMulTMatrix(vector *result, vector *v, matrix *m) {
vm_Dot3Vector(m->rvec.z(), m->uvec.z(), m->fvec.z(), v) };
}
void vm_MatrixMul(matrix *dest, matrix *src0, matrix *src1) {
void vm_MatrixMul(matrix *dest, const matrix *src0, const matrix *src1) {
// For multiplying two 3x3 matrices together
// assert((dest != src0) && (dest != src1));
@@ -172,7 +172,7 @@ void vm_MatrixMul(matrix *dest, matrix *src0, matrix *src1) {
}
// Multiply a matrix times the transpose of a matrix
void vm_MatrixMulTMatrix(matrix *dest, matrix *src0, matrix *src1) {
void vm_MatrixMulTMatrix(matrix *dest, const matrix *src0, const matrix *src1) {
// For multiplying two 3x3 matrices together
// assert((dest != src0) && (dest != src1));
@@ -190,7 +190,7 @@ void vm_MatrixMulTMatrix(matrix *dest, matrix *src0, matrix *src1) {
dest->fvec.z() = src0->rvec.z() * src1->rvec.z() + src0->uvec.z() * src1->uvec.z() + src0->fvec.z() * src1->fvec.z();
}
matrix operator*(matrix src0, matrix src1) {
matrix operator*(const matrix &src0, const matrix &src1) {
// For multiplying two 3x3 matrices together
matrix dest;
@@ -209,7 +209,7 @@ matrix operator*(matrix src0, matrix src1) {
return dest;
}
matrix operator*=(matrix &src0, matrix src1) { return (src0 = src0 * src1); }
matrix operator*=(matrix &src0, const matrix &src1) { return (src0 = src0 * src1); }
// Computes a normalized direction vector between two points
// Parameters: dest - filled in with the normalized direction vector
@@ -475,7 +475,7 @@ void vm_SinCos(uint16_t a, scalar *s, scalar *c) {
}
// extract angles from a matrix
angvec *vm_ExtractAnglesFromMatrix(angvec *a, matrix *m) {
angvec *vm_ExtractAnglesFromMatrix(angvec *a, const matrix *m) {
scalar sinh, cosh, cosp;
if (m->fvec.x() == 0 && m->fvec.z() == 0) // zero head
@@ -516,7 +516,7 @@ angvec *vm_ExtractAnglesFromMatrix(angvec *a, matrix *m) {
}
// returns the value of a determinant
scalar calc_det_value(matrix *det) {
scalar calc_det_value(const matrix *det) {
return det->rvec.x() * det->uvec.y() * det->fvec.z() - det->rvec.x() * det->uvec.z() * det->fvec.y() -
det->rvec.y() * det->uvec.x() * det->fvec.z() + det->rvec.y() * det->uvec.z() * det->fvec.x() +
det->rvec.z() * det->uvec.x() * det->fvec.y() - det->rvec.z() * det->uvec.y() * det->fvec.x();
@@ -528,7 +528,7 @@ scalar calc_det_value(matrix *det) {
// value of the angle in returned. Otherwise the angle around that vector is
// returned.
angle vm_DeltaAngVec(vector *v0, vector *v1, vector *fvec) {
angle vm_DeltaAngVec(const vector *v0, const vector *v1, const vector *fvec) {
vector t0, t1;
t0 = *v0;
@@ -541,7 +541,7 @@ angle vm_DeltaAngVec(vector *v0, vector *v1, vector *fvec) {
}
// computes the delta angle between two normalized vectors.
angle vm_DeltaAngVecNorm(vector *v0, vector *v1, vector *fvec) {
angle vm_DeltaAngVecNorm(const vector *v0, const vector *v1, const vector *fvec) {
angle a;
a = FixAcos(vm_DotProduct(v0, v1));
@@ -559,7 +559,7 @@ angle vm_DeltaAngVecNorm(vector *v0, vector *v1, vector *fvec) {
// Gets the real center of a polygon
// Returns the size of the passed in stuff
scalar vm_GetCentroid(vector *centroid, vector *src, int nv) {
scalar vm_GetCentroid(vector *centroid, const vector *src, int nv) {
// ASSERT (nv>2);
vector normal;
scalar area, total_area;
@@ -613,7 +613,7 @@ scalar vm_GetCentroid(vector *centroid, vector *src, int nv) {
// Gets the real center of a polygon, but uses fast magnitude calculation
// Returns the size of the passed in stuff
float vm_GetCentroidFast(vector *centroid, vector *src, int nv) {
float vm_GetCentroidFast(vector *centroid, const vector *src, int nv) {
// ASSERT (nv>2);
vector normal;
float area, total_area;
@@ -674,11 +674,11 @@ void vm_MakeRandomVector(vector *vec) {
}
// Given a set of points, computes the minimum bounding sphere of those points
scalar vm_ComputeBoundingSphere(vector *center, vector *vecs, int num_verts) {
scalar vm_ComputeBoundingSphere(vector *center, const vector *vecs, int num_verts) {
// This algorithm is from Graphics Gems I. There's a better algorithm in Graphics Gems III that
// we should probably implement sometime.
vector *min_x, *max_x, *min_y, *max_y, *min_z, *max_z, *vp;
const vector *min_x, *max_x, *min_y, *max_y, *min_z, *max_z, *vp;
scalar dx, dy, dz;
scalar rad, rad2;
int i;