summaryrefslogtreecommitdiff
path: root/honey/ecs/node.lua
diff options
context:
space:
mode:
Diffstat (limited to 'honey/ecs/node.lua')
-rw-r--r--honey/ecs/node.lua12
1 files changed, 8 insertions, 4 deletions
diff --git a/honey/ecs/node.lua b/honey/ecs/node.lua
index 39f1898..645946c 100644
--- a/honey/ecs/node.lua
+++ b/honey/ecs/node.lua
@@ -18,7 +18,7 @@ system = function(params)
end
-- helper function
- local function recursiveTransform(node)
+ local function recursiveTransform(id, node)
if node._visited then
return node._matrix
end
@@ -26,9 +26,13 @@ system = function(params)
if not node.parent then
node._matrix = node.matrix
else
- local parentTransform = self.db:getComponent(node.parent, "node")
- local parentMatrix = recursiveTransform(parentTransform)
+ local parentNode = self.db:getComponent(node.parent, "node")
+ local parentMatrix = recursiveTransform(node.parent, parentNode)
node._matrix = parentMatrix * node.matrix
+ if node.name then
+ if not parentNode._child then parentNode._child = {} end
+ parentNode._child[node.name] = honey.ecs.Accessor(self.db, id)
+ end
end
node._visited = true
return node._matrix
@@ -36,7 +40,7 @@ system = function(params)
-- compute nodes
for id, node in pairs(nodes) do
- recursiveTransform(node)
+ recursiveTransform(id, node)
end
end,
}