Scene Graph: nodes not being transformed correctly
gravestench opened this issue · comments
There likely is a bug in either the d2math.Matrix4
implementation, or in the scene graph node in d2scene.Node
.
We need to determine why node children aren't being transformed by their parent node correctly.
If you're not sure what this bug is about:
There is an abstraction for Scenes
, which are special systems in the ecs implementation (see d2systems.BaseScene
).
Scenes maintain a list of their own objects for rendering. Every object has a SceneGraphNode
component, which contains a d2scene.Node
. This Node
class is used to create a node tree, which describes a parent-child hierarchy. Each scene has a "root node", and each new object sets it's parent to this "root node".
However, in some cases, it makes sense for objects to be parents of other objects, such as when buttons have labels. In this example, the button would be the parent of the label.
The Node
s each contain 2 d2math.Matrix4
structs that describe a transformation (translation, rotation, and scale). One of these matrix4's comes from the node's parent, and the other matrix4 is local to this node. Every time a scene system's Update
method is called, all of the nodes in the scene graph are updated. Basically, all this does is recursively apply a parent node Local
matrix4 to each of it's children.