C++ 游戏引擎矩阵乘法

C++ 游戏引擎矩阵乘法,c++,xcode,function,matrix,game-engine,C++,Xcode,Function,Matrix,Game Engine,我一直在关注chernoproject关于如何制作游戏引擎的教程,但到目前为止,我遇到了一个错误,我似乎不知道如何解决它。 我不断得到错误“控件到达非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; } }

我一直在关注chernoproject关于如何制作游戏引擎的教程,但到目前为止,我遇到了一个错误,我似乎不知道如何解决它。 我不断得到错误“控件到达非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和mat4::乘法(常量mat4和其他){

对于(int y=0;I)我收到一个错误,说明控件到达非void函数的末尾,如何解决此错误?请看我从代码中提取的函数。它说它应该返回一个
mat4&
。或者返回要乘法的对象,或者将函数更改为
void mat4::multiply(const mat46 other)
#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);
};

} }
    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;

        }

    }

}