MCPcopy Create free account
hub / github.com/davideberly/GeometricTools / Update

Method Update

GTE/Graphics/BlendTransformController.cpp:28–107  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26}
27
28bool BlendTransformController::Update(double applicationTime)
29{
30 if (!Controller::Update(applicationTime))
31 {
32 return false;
33 }
34
35 mController0->Update(applicationTime);
36 mController1->Update(applicationTime);
37
38 Transform<float> const& xfrm0 = mController0->GetTransform();
39 Transform<float> const& xfrm1 = mController1->GetTransform();
40 float oneMinusWeight = 1.0f - mWeight;
41
42 // Compute the blended translation.
43 Vector4<float> trn0 = xfrm0.GetTranslationW1();
44 Vector4<float> trn1 = xfrm1.GetTranslationW1();
45 Vector4<float> blendTrn = oneMinusWeight * trn0 + mWeight * trn1;
46 mLocalTransform.SetTranslation(blendTrn);
47
48 // Compute the blended rotation.
49 Matrix4x4<float> const& rot0 = xfrm0.GetRotation();
50 Matrix4x4<float> const& rot1 = xfrm1.GetRotation();
51
52 Quaternion<float> quat0 = Rotation<4, float>(rot0);
53 Quaternion<float> quat1 = Rotation<4, float>(rot1);
54 if (Dot(quat0, quat1) < 0.0f)
55 {
56 quat1 = -quat1;
57 }
58
59 Quaternion<float> blendQuat;
60 if (mGeometricRotation)
61 {
62 blendQuat = Slerp(mWeight, quat0, quat1);
63 }
64 else
65 {
66 blendQuat = oneMinusWeight * quat0 + mWeight * quat1;
67 Normalize(blendQuat);
68 }
69
70 Matrix4x4<float> blendRot = Rotation<4, float>(blendQuat);
71 mLocalTransform.SetRotation(blendRot);
72
73 // Compute the blended scale.
74 Vector3<float> sca0 = xfrm0.GetScale();
75 Vector3<float> sca1 = xfrm1.GetScale();
76 Vector3<float> blendSca;
77 if (mGeometricScale)
78 {
79 for (int32_t i = 0; i < 3; ++i)
80 {
81 float s0 = sca0[i], s1 = sca1[i];
82 if (s0 != 0.0f && s1 != 0.0f)
83 {
84 float sign0 = (s0 > 0.0f ? 1.0f : -1.0f);
85 float sign1 = (s1 > 0.0f ? 1.0f : -1.0f);

Callers

nothing calls this directly

Calls 11

GetTranslationW1Method · 0.80
SetTranslationMethod · 0.80
GetRotationMethod · 0.80
SetRotationMethod · 0.80
SetScaleMethod · 0.80
DotFunction · 0.50
SlerpFunction · 0.50
NormalizeFunction · 0.50
fabsFunction · 0.50
powFunction · 0.50
GetScaleMethod · 0.45

Tested by

no test coverage detected