MCPcopy Create free account
hub / github.com/defold/defold / UpdateLocalTransform

Function UpdateLocalTransform

engine/gui/src/gui.cpp:3076–3108  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3074 }
3075
3076 void UpdateLocalTransform(HScene scene, InternalNode* n)
3077 {
3078 Node& node = n->m_Node;
3079
3080 // Check if the euler has been animated/altered, and we need to update rotation
3081 CheckEuler(node);
3082
3083 Vector4 position = node.m_Properties[dmGui::PROPERTY_POSITION];
3084 Vector4 prop_scale = node.m_Properties[dmGui::PROPERTY_SCALE];
3085 Vector4 reference_scale = Vector4(1.0, 1.0, 1.0, 1.0);
3086 node.m_LocalAdjustScale = reference_scale;
3087 if (scene->m_AdjustReference != ADJUST_REFERENCE_DISABLED) {
3088 reference_scale = CalculateReferenceScale(scene, n);
3089 AdjustPosScale(scene, n, reference_scale, position, node.m_LocalAdjustScale);
3090 }
3091
3092 // const Vector3& rotation = node.m_Properties[dmGui::PROPERTY_ROTATION].getXYZ();
3093 // Quat r = dmVMath::EulerToQuat(rotation);
3094 // r = normalize(r);
3095 Quat r(node.m_Properties[dmGui::PROPERTY_ROTATION]);
3096
3097 node.m_LocalTransform.setUpper3x3(Matrix3::rotation(r) * Matrix3::scale( mulPerElem(node.m_LocalAdjustScale, prop_scale).getXYZ() ));
3098 node.m_LocalTransform.setTranslation(position.getXYZ());
3099
3100 if (scene->m_AdjustReference == ADJUST_REFERENCE_PARENT && n->m_ParentIndex != INVALID_INDEX)
3101 {
3102 // undo parent scale (if node has parent)
3103 Vector3 inv_ref_scale = Vector3(1.0f / reference_scale.getX(), 1.0f / reference_scale.getY(), 1.0f / reference_scale.getZ());
3104 node.m_LocalTransform = Matrix4::scale( inv_ref_scale ) * node.m_LocalTransform;
3105 }
3106
3107 node.m_DirtyLocal = 0;
3108 }
3109
3110 void ResetNodes(HScene scene)
3111 {

Calls 11

AdjustPosScaleFunction · 0.85
CheckEulerFunction · 0.70
CalculateReferenceScaleFunction · 0.70
Vector4Class · 0.50
scaleFunction · 0.50
mulPerElemFunction · 0.50
Vector3Class · 0.50
getXYZMethod · 0.45
getXMethod · 0.45
getYMethod · 0.45
getZMethod · 0.45

Tested by

no test coverage detected