我应该如何构造我的非常简单的物理学 simulation/renderer?

How should I structure my very simple physics simulation/renderer?

我正在尝试编写一个非常简单的刚体物理模拟程序(使用 c++ 和 OpenGL)以供学习之用(也请提前原谅我,但英语不是我的母语)。

现在,到目前为止,我的 classes 结构如下:

代理 class:

障碍class:

模拟class:

渲染器class:

现在一切正常,但我在如何进一步构建我的程序以实现以下功能方面遇到问题:

抱歉啰嗦 post 但我已经尝试解决这些问题已经两周了,但没有什么好 [=7​​7=] 能想到的。

我知道我可以使用实体组件系统架构来缓解这些问题,但我真的更喜欢让它尽可能简单。

实体/组件架构是您所需要的我 guess.There 在互联网上有很多关于此的内容,我鼓励您 google 它并在堆栈溢出和 gamedev stackexchange 上查找它.

这方面的一个例子(不是唯一的,可能对你不好,但它是一个例子)可能是这样的

struct Entity
{
    int m_Id;
};

struct PhysicsComponent {
    unsigned long m_Flags;
    // Some data
};
struct GraphicsComponent {
    Texture m_Texture;
    Mesh    m_Mesh;
    // Some other data
};

Actor actors[MAX_ACTORS];
Wall walls[MAX_WALLS];
GraphicsComponent graphics_components[MAX_GRAPHICS_COMPONENTS];

void UpdatePhysics(float dt) {
    // Do you logic stuff, using your flags and so on
}

void Render() {
    // Render your stuff by retrieving position / orientation via entities ID 
}