From 85a6f485f12804bac866fb15103feb754603db10 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Tue, 2 Feb 2021 12:52:37 +0100 Subject: [PATCH] Fixes and tweaks --- Source/Engine/Level/Actors/AnimatedModel.cpp | 16 ++++++++-------- Source/Engine/Level/Actors/AnimatedModel.h | 3 ++- Source/Engine/Level/Actors/ModelInstanceActor.h | 15 ++++++++------- Source/Engine/Level/Actors/StaticModel.h | 2 +- Source/Engine/Renderer/DrawCall.h | 2 +- 5 files changed, 20 insertions(+), 18 deletions(-) diff --git a/Source/Engine/Level/Actors/AnimatedModel.cpp b/Source/Engine/Level/Actors/AnimatedModel.cpp index 3d6450716..85ee6d333 100644 --- a/Source/Engine/Level/Actors/AnimatedModel.cpp +++ b/Source/Engine/Level/Actors/AnimatedModel.cpp @@ -327,14 +327,6 @@ void AnimatedModel::SyncParameters() } } -void AnimatedModel::UpdateBounds() -{ - UpdateLocalBounds(); - - BoundingBox::Transform(_boxLocal, _world, _box); - BoundingSphere::FromBox(_box, _sphere); -} - void AnimatedModel::BeginPlay(SceneBeginData* data) { if (SkinnedModel && SkinnedModel->IsLoaded()) @@ -401,6 +393,14 @@ void AnimatedModel::UpdateLocalBounds() _boxLocal = box; } +void AnimatedModel::UpdateBounds() +{ + UpdateLocalBounds(); + + BoundingBox::Transform(_boxLocal, _world, _box); + BoundingSphere::FromBox(_box, _sphere); +} + void AnimatedModel::OnAnimUpdate() { UpdateBounds(); diff --git a/Source/Engine/Level/Actors/AnimatedModel.h b/Source/Engine/Level/Actors/AnimatedModel.h index 641247273..d5d9b4424 100644 --- a/Source/Engine/Level/Actors/AnimatedModel.h +++ b/Source/Engine/Level/Actors/AnimatedModel.h @@ -290,6 +290,8 @@ private: /// void UpdateLocalBounds(); + void UpdateBounds(); + /// /// Called after animation graph update. /// @@ -317,7 +319,6 @@ public: void Deserialize(DeserializeStream& stream, ISerializeModifier* modifier) override; bool IntersectsEntry(int32 entryIndex, const Ray& ray, float& distance, Vector3& normal) override; bool IntersectsEntry(const Ray& ray, float& distance, Vector3& normal, int32& entryIndex) override; - void UpdateBounds() final override; protected: diff --git a/Source/Engine/Level/Actors/ModelInstanceActor.h b/Source/Engine/Level/Actors/ModelInstanceActor.h index c431429fd..7b2a08fd9 100644 --- a/Source/Engine/Level/Actors/ModelInstanceActor.h +++ b/Source/Engine/Level/Actors/ModelInstanceActor.h @@ -19,11 +19,6 @@ public: /// ModelInstanceEntries Entries; - /// - /// Updates the bounds of the actor. - /// - virtual void UpdateBounds() = 0; - /// /// Gets the model entries collection. Each entry contains data how to render meshes using this entry (transformation, material, shadows casting, etc.). /// @@ -63,7 +58,10 @@ public: /// When the method completes and returns true, contains the distance of the intersection (if any valid). /// When the method completes, contains the intersection surface normal vector (if any valid). /// True if the actor is intersected by the ray, otherwise false. - API_FUNCTION() virtual bool IntersectsEntry(int32 entryIndex, API_PARAM(Ref) const Ray& ray, API_PARAM(Out) float& distance, API_PARAM(Out) Vector3& normal) = 0; + API_FUNCTION() virtual bool IntersectsEntry(int32 entryIndex, API_PARAM(Ref) const Ray& ray, API_PARAM(Out) float& distance, API_PARAM(Out) Vector3& normal) + { + return false; + } /// /// Determines if there is an intersection between the model actor mesh entry and a ray. @@ -76,7 +74,10 @@ public: /// When the method completes, contains the intersection surface normal vector (if any valid). /// When the method completes, contains the intersection entry index (if any valid). /// True if the actor is intersected by the ray, otherwise false. - API_FUNCTION() virtual bool IntersectsEntry(API_PARAM(Ref) const Ray& ray, API_PARAM(Out) float& distance, API_PARAM(Out) Vector3& normal, API_PARAM(Out) int32& entryIndex) = 0; + API_FUNCTION() virtual bool IntersectsEntry(API_PARAM(Ref) const Ray& ray, API_PARAM(Out) float& distance, API_PARAM(Out) Vector3& normal, API_PARAM(Out) int32& entryIndex) + { + return false; + } protected: diff --git a/Source/Engine/Level/Actors/StaticModel.h b/Source/Engine/Level/Actors/StaticModel.h index 5ca6e05e4..a255ba4ab 100644 --- a/Source/Engine/Level/Actors/StaticModel.h +++ b/Source/Engine/Level/Actors/StaticModel.h @@ -181,6 +181,7 @@ private: void OnModelChanged(); void OnModelLoaded(); + void UpdateBounds(); public: @@ -193,7 +194,6 @@ public: void Deserialize(DeserializeStream& stream, ISerializeModifier* modifier) override; bool IntersectsEntry(int32 entryIndex, const Ray& ray, float& distance, Vector3& normal) override; bool IntersectsEntry(const Ray& ray, float& distance, Vector3& normal, int32& entryIndex) override; - void UpdateBounds() override; protected: diff --git a/Source/Engine/Renderer/DrawCall.h b/Source/Engine/Renderer/DrawCall.h index 7c4f4fe6d..cc35b2627 100644 --- a/Source/Engine/Renderer/DrawCall.h +++ b/Source/Engine/Renderer/DrawCall.h @@ -333,6 +333,6 @@ struct TIsPODType #define GEOMETRY_DRAW_STATE_EVENT_END(drawState, worldMatrix) \ if (drawState.PrevFrame != frame) \ { \ - drawState.PrevWorld = _world; \ + drawState.PrevWorld = worldMatrix; \ drawState.PrevFrame = frame; \ }