Fixes and tweaks

This commit is contained in:
Wojtek Figat
2021-02-02 12:52:37 +01:00
parent d2dba5680b
commit 85a6f485f1
5 changed files with 20 additions and 18 deletions

View File

@@ -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();

View File

@@ -290,6 +290,8 @@ private:
/// </summary>
void UpdateLocalBounds();
void UpdateBounds();
/// <summary>
/// Called after animation graph update.
/// </summary>
@@ -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:

View File

@@ -19,11 +19,6 @@ public:
/// </summary>
ModelInstanceEntries Entries;
/// <summary>
/// Updates the bounds of the actor.
/// </summary>
virtual void UpdateBounds() = 0;
/// <summary>
/// Gets the model entries collection. Each entry contains data how to render meshes using this entry (transformation, material, shadows casting, etc.).
/// </summary>
@@ -63,7 +58,10 @@ public:
/// <param name="distance">When the method completes and returns true, contains the distance of the intersection (if any valid).</param>
/// <param name="normal">When the method completes, contains the intersection surface normal vector (if any valid).</param>
/// <returns>True if the actor is intersected by the ray, otherwise false.</returns>
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;
}
/// <summary>
/// Determines if there is an intersection between the model actor mesh entry and a ray.
@@ -76,7 +74,10 @@ public:
/// <param name="normal">When the method completes, contains the intersection surface normal vector (if any valid).</param>
/// <param name="entryIndex">When the method completes, contains the intersection entry index (if any valid).</param>
/// <returns>True if the actor is intersected by the ray, otherwise false.</returns>
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:

View File

@@ -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: