MCPcopy Create free account
hub / github.com/begla/Intrinsic / updateTransforms

Method updateTransforms

IntrinsicCore/src/IntrinsicCoreComponentsNode.cpp:64–140  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

62}
63
64void NodeManager::updateTransforms(const NodeRefArray& p_Nodes)
65{
66 for (uint32_t nodeIdx = 0u; nodeIdx < p_Nodes.size(); ++nodeIdx)
67 {
68 NodeRef nodeRef = p_Nodes[nodeIdx];
69 NodeRef parentNodeRef = _parent(nodeRef);
70
71 if (!parentNodeRef.isValid())
72 {
73 _worldPosition(nodeRef) = _position(nodeRef);
74 _worldOrientation(nodeRef) = _orientation(nodeRef);
75 _worldSize(nodeRef) = _size(nodeRef);
76 }
77 else
78 {
79 const glm::vec3& parentPos = _worldPosition(parentNodeRef);
80 const glm::quat& parentOrient = _worldOrientation(parentNodeRef);
81 const glm::vec3& parentSize = _worldSize(parentNodeRef);
82
83 const glm::vec3& localPos = _position(nodeRef);
84 const glm::quat& localOrient = _orientation(nodeRef);
85 const glm::vec3& localSize = _size(nodeRef);
86
87 const glm::vec3 worldPos = parentPos + (parentOrient * localPos);
88 const glm::quat worldOrient = parentOrient * localOrient;
89 const glm::vec3 worldSize = parentSize * localSize;
90
91 _worldPosition(nodeRef) = worldPos;
92 _worldOrientation(nodeRef) = worldOrient;
93 _worldSize(nodeRef) = worldSize;
94 }
95
96 glm::mat4 rot = glm::mat4_cast(NodeManager::_worldOrientation(nodeRef));
97 glm::mat4 trans =
98 glm::translate(glm::mat4(1.0f), NodeManager::_worldPosition(nodeRef));
99 glm::mat4 scale =
100 glm::scale(glm::mat4(1.0f), NodeManager::_worldSize(nodeRef));
101
102 _worldMatrix(nodeRef) = trans * rot * scale;
103 _inverseWorldMatrix(nodeRef) = glm::inverse(_worldMatrix(nodeRef));
104
105 // Update AABB
106 // TODO: Merge sub meshes
107 Components::MeshRef meshCompRef =
108 Components::MeshManager::getComponentForEntity(_entity(nodeRef));
109 if (meshCompRef.isValid())
110 {
111 Name& meshName = Components::MeshManager::_descMeshName(meshCompRef);
112 Resources::MeshRef meshRef =
113 Resources::MeshManager::_getResourceByName(meshName);
114
115 if (meshRef.isValid())
116 {
117 const uint32_t aabbCount =
118 (uint32_t)Resources::MeshManager::_aabbPerSubMesh(meshRef).size();
119
120 if (aabbCount > 0u)
121 {

Callers

nothing calls this directly

Calls 6

transformAABBAffineFunction · 0.85
calcAABBCenterFunction · 0.85
calcAABBHalfExtentFunction · 0.85
AABBClass · 0.85
sizeMethod · 0.45
isValidMethod · 0.45

Tested by

no test coverage detected