我一直在遵循TheChernoProject有关如何制作游戏引擎的教程,但是到目前为止,我遇到了一个错误,似乎无法弄清楚如何解决它。 Here is the link to the episode where I am currently at, my problem starts at 28:40. 我继续收到错误消息“控件到达非void函数的末尾”。 我正在使用Xcode。
这是mat4.cpp
#include "mat4.h"
namespace engine { namespace maths {
mat4::mat4() {
for(int i=0;i<4*4;i++) {
elements[i] = 0.0f;
}
}
mat4::mat4(float diagonal) {
for(int i=0;i<4*4;i++) {
elements[i] = 0.0f;
elements[0 + 0 * 4] = diagonal;
elements[1 + 1 * 4] = diagonal;
elements[2 + 2 * 4] = diagonal;
elements[3 + 3 * 4] = diagonal;
}
}
mat4 mat4::identity() {
return mat4(1.0f);
}
mat4& mat4::multiply(const mat4& other) {
for(int y=0;y<4;y++) {
for(int x=0;x<4;x++) {
float sum = 0.0f;
for(int e=0;e<4;e++) {
sum += elements[x + e * 4] * other.elements[e + y * 4];
}
elements[x + y * 4] = sum;
}
}
}
} }
这是头文件mat4.h
#pragma once
#include "maths.h"
namespace engine { namespace maths {
struct mat4 {
float elements[4 * 4];
mat4();
mat4(float diagonal);
static mat4 identity();
mat4& multiply(const mat4& other);
friend mat4 operator*(mat4 left, const mat4& right);
mat4& operator*=(const mat4& other);
static mat4 orthographic(float left, float right, float bottom, float top, float near, float far);
static mat4 perspective(float fov, float aspectRatio, float near, float far);
static mat4 translation(const vec3& translation);
static mat4 rotation(float angle, const vec3& axis);
static mat4 scale(const vec3& scale);
};
} }
答案 0 :(得分:3)
mat4& mat4::multiply(const mat4& other) {
for(int y=0;y<4;y++) {
for(int x=0;x<4;x++) {
float sum = 0.0f;
for(int e=0;e<4;e++) {
sum += elements[x + e * 4] * other.elements[e + y * 4];
}
elements[x + y * 4] = sum;
}
}
}
不返回任何内容,但声明返回mat4&