From 254ebd1e7f5842327b5f700898c058113d1f1ade Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Wed, 3 Nov 2021 10:45:00 +0100 Subject: [PATCH] Tweaks --- Source/Engine/Animations/Graph/AnimGraph.cpp | 4 ++-- Source/Engine/Animations/Graph/AnimGraph.h | 11 ----------- Source/Engine/Level/Actor.cpp | 6 ++---- Source/Engine/Level/Actor.h | 4 ++-- Source/Engine/Level/Actors/AnimatedModel.cpp | 2 +- Source/Engine/Level/Actors/AnimatedModel.h | 2 +- 6 files changed, 8 insertions(+), 21 deletions(-) diff --git a/Source/Engine/Animations/Graph/AnimGraph.cpp b/Source/Engine/Animations/Graph/AnimGraph.cpp index 128e29e59..bd4d63567 100644 --- a/Source/Engine/Animations/Graph/AnimGraph.cpp +++ b/Source/Engine/Animations/Graph/AnimGraph.cpp @@ -272,13 +272,13 @@ void AnimGraphExecutor::Update(AnimGraphInstanceData& data, float dt) if (animResult == nullptr) animResult = GetEmptyNodes(); } - Transform* nodesTransformations = animResult->Nodes.Get(); // Calculate the global poses for the skeleton nodes { ANIM_GRAPH_PROFILE_EVENT("Global Pose"); data.NodesPose.Resize(_skeletonNodesCount, false); + Transform* nodesTransformations = animResult->Nodes.Get(); // Note: this assumes that nodes are sorted (parents first) for (int32 nodeIndex = 0; nodeIndex < _skeletonNodesCount; nodeIndex++) @@ -286,7 +286,7 @@ void AnimGraphExecutor::Update(AnimGraphInstanceData& data, float dt) const int32 parentIndex = skeleton.Nodes[nodeIndex].ParentIndex; if (parentIndex != -1) { - nodesTransformations[nodeIndex] = nodesTransformations[parentIndex].LocalToWorld(nodesTransformations[nodeIndex]); + nodesTransformations[parentIndex].LocalToWorld(nodesTransformations[nodeIndex], nodesTransformations[nodeIndex]); } nodesTransformations[nodeIndex].GetWorld(data.NodesPose[nodeIndex]); } diff --git a/Source/Engine/Animations/Graph/AnimGraph.h b/Source/Engine/Animations/Graph/AnimGraph.h index d9c750cc8..3a472d223 100644 --- a/Source/Engine/Animations/Graph/AnimGraph.h +++ b/Source/Engine/Animations/Graph/AnimGraph.h @@ -300,17 +300,6 @@ public: }; }; -public: - - /// - /// Initializes a new instance of the class. - /// - /// The object that represents the instance data source. - AnimGraphInstanceData(ScriptingObject* object) - : Object(object) - { - } - public: /// diff --git a/Source/Engine/Level/Actor.cpp b/Source/Engine/Level/Actor.cpp index fd494a86b..e4aa70c7e 100644 --- a/Source/Engine/Level/Actor.cpp +++ b/Source/Engine/Level/Actor.cpp @@ -1426,18 +1426,16 @@ Actor* Actor::Intersects(const Ray& ray, float& distance, Vector3& normal) void Actor::LookAt(const Vector3& worldPos) { const Quaternion orientation = LookingAt(worldPos); - SetOrientation(orientation); } void Actor::LookAt(const Vector3& worldPos, const Vector3& worldUp) { const Quaternion orientation = LookingAt(worldPos, worldUp); - SetOrientation(orientation); } -Quaternion Actor::LookingAt(const Vector3& worldPos) +Quaternion Actor::LookingAt(const Vector3& worldPos) const { const Vector3 direction = worldPos - _transform.Translation; if (direction.LengthSquared() < ZeroTolerance) @@ -1464,7 +1462,7 @@ Quaternion Actor::LookingAt(const Vector3& worldPos) return orientation; } -Quaternion Actor::LookingAt(const Vector3& worldPos, const Vector3& worldUp) +Quaternion Actor::LookingAt(const Vector3& worldPos, const Vector3& worldUp) const { const Vector3 direction = worldPos - _transform.Translation; if (direction.LengthSquared() < ZeroTolerance) diff --git a/Source/Engine/Level/Actor.h b/Source/Engine/Level/Actor.h index 56930eccf..385a74049 100644 --- a/Source/Engine/Level/Actor.h +++ b/Source/Engine/Level/Actor.h @@ -796,14 +796,14 @@ public: /// Gets rotation of the actor oriented towards the specified world position. /// /// The world position to orient towards. - API_FUNCTION() Quaternion LookingAt(const Vector3& worldPos); + API_FUNCTION() Quaternion LookingAt(const Vector3& worldPos) const; /// /// Gets rotation of the actor oriented towards the specified world position with upwards direction. /// /// The world position to orient towards. /// The up direction that Constrains y axis orientation to a plane this vector lies on. This rule might be broken if forward and up direction are nearly parallel. - API_FUNCTION() Quaternion LookingAt(const Vector3& worldPos, const Vector3& worldUp); + API_FUNCTION() Quaternion LookingAt(const Vector3& worldPos, const Vector3& worldUp) const; public: diff --git a/Source/Engine/Level/Actors/AnimatedModel.cpp b/Source/Engine/Level/Actors/AnimatedModel.cpp index bb1f5a75f..39496156f 100644 --- a/Source/Engine/Level/Actors/AnimatedModel.cpp +++ b/Source/Engine/Level/Actors/AnimatedModel.cpp @@ -21,8 +21,8 @@ AnimatedModel::AnimatedModel(const SpawnParams& params) , _counter(0) , _lastMinDstSqr(MAX_float) , _lastUpdateFrame(0) - , GraphInstance(this) { + GraphInstance.Object = this; _world = Matrix::Identity; UpdateBounds(); diff --git a/Source/Engine/Level/Actors/AnimatedModel.h b/Source/Engine/Level/Actors/AnimatedModel.h index d584250b6..bb42913b8 100644 --- a/Source/Engine/Level/Actors/AnimatedModel.h +++ b/Source/Engine/Level/Actors/AnimatedModel.h @@ -177,7 +177,7 @@ public: /// Performs the full animation update. The actual update will be performed during gameplay tick. /// API_FUNCTION() void UpdateAnimation(); - + /// /// Called after animation gets updated (new skeleton pose). ///