Minor fixes and changes

This commit is contained in:
Wojciech Figat
2022-02-21 20:14:46 +01:00
parent 5d4c168e1e
commit 8082f5f909
6 changed files with 9 additions and 23 deletions

View File

@@ -544,14 +544,15 @@ public:
/// Ensures that collection has given capacity. /// Ensures that collection has given capacity.
/// </summary> /// </summary>
/// <param name="minCapacity">The minimum required capacity.</param> /// <param name="minCapacity">The minimum required capacity.</param>
void EnsureCapacity(int32 minCapacity) /// <param name="preserveContents">True if preserve collection data when changing its size, otherwise collection after resize will be empty.</param>
void EnsureCapacity(int32 minCapacity, bool preserveContents = true)
{ {
if (_size >= minCapacity) if (_size >= minCapacity)
return; return;
if (minCapacity < DICTIONARY_DEFAULT_CAPACITY) if (minCapacity < DICTIONARY_DEFAULT_CAPACITY)
minCapacity = DICTIONARY_DEFAULT_CAPACITY; minCapacity = DICTIONARY_DEFAULT_CAPACITY;
const int32 capacity = _allocation.CalculateCapacityGrow(_size, minCapacity); const int32 capacity = _allocation.CalculateCapacityGrow(_size, minCapacity);
SetCapacity(capacity); SetCapacity(capacity, preserveContents);
} }
/// <summary> /// <summary>

View File

@@ -1124,7 +1124,6 @@ bool CollisionsHelper::BoxIntersectsSphere(const BoundingBox& box, const Boundin
Vector3 vector; Vector3 vector;
Vector3::Clamp(sphere.Center, box.Minimum, box.Maximum, vector); Vector3::Clamp(sphere.Center, box.Minimum, box.Maximum, vector);
const float distance = Vector3::DistanceSquared(sphere.Center, vector); const float distance = Vector3::DistanceSquared(sphere.Center, vector);
return distance <= sphere.Radius * sphere.Radius; return distance <= sphere.Radius * sphere.Radius;
} }

View File

@@ -131,23 +131,6 @@ Vector3 Vector3::Frac(const Vector3& v)
); );
} }
Vector3 Vector3::Clamp(const Vector3& value, const Vector3& min, const Vector3& max)
{
float x = value.X;
x = x > max.X ? max.X : x;
x = x < min.X ? min.X : x;
float y = value.Y;
y = y > max.Y ? max.Y : y;
y = y < min.Y ? min.Y : y;
float z = value.Z;
z = z > max.Z ? max.Z : z;
z = z < min.Z ? min.Z : z;
return Vector3(x, y, z);
}
void Vector3::Hermite(const Vector3& value1, const Vector3& tangent1, const Vector3& value2, const Vector3& tangent2, float amount, Vector3& result) void Vector3::Hermite(const Vector3& value1, const Vector3& tangent1, const Vector3& value2, const Vector3& tangent2, float amount, Vector3& result)
{ {
const float squared = amount * amount; const float squared = amount * amount;

View File

@@ -593,7 +593,10 @@ public:
// @param min The minimum value, // @param min The minimum value,
// @param max The maximum value // @param max The maximum value
// @returns Clamped value // @returns Clamped value
static Vector3 Clamp(const Vector3& value, const Vector3& min, const Vector3& max); static Vector3 Clamp(const Vector3& value, const Vector3& min, const Vector3& max)
{
return Vector3(Math::Clamp(value.X, min.X, max.X), Math::Clamp(value.Y, min.Y, max.Y), Math::Clamp(value.Z, min.Z, max.Z));
}
// Restricts a value to be within a specified range // Restricts a value to be within a specified range
// @param value The value to clamp // @param value The value to clamp

View File

@@ -640,7 +640,7 @@ public:
public: public:
/// <summary> /// <summary>
/// Draws this actor. Called by Scene Rendering service. This call is more optimized than generic Draw (eg. models are rendered during all passed but other actors are invoked only during GBufferFill pass). /// Draws this actor. Called by Scene Rendering service. This call is more optimized than generic Draw (eg. geometry is rendered during all pass types but other actors are drawn only during GBufferFill pass).
/// </summary> /// </summary>
/// <param name="renderContext">The rendering context.</param> /// <param name="renderContext">The rendering context.</param>
virtual void Draw(RenderContext& renderContext); virtual void Draw(RenderContext& renderContext);

View File

@@ -258,7 +258,7 @@ void SplineModel::UpdateDeformationBuffer()
AnimationUtils::GetTangent(end.Value, end.TangentIn, length, rightTangent); AnimationUtils::GetTangent(end.Value, end.TangentIn, length, rightTangent);
for (int32 chunk = 0; chunk < chunksPerSegment; chunk++) for (int32 chunk = 0; chunk < chunksPerSegment; chunk++)
{ {
const float alpha = (chunk == chunksPerSegment - 1)? 1.0f : ((float)chunk * chunksPerSegmentInv); const float alpha = (chunk == chunksPerSegment - 1) ? 1.0f : ((float)chunk * chunksPerSegmentInv);
// Evaluate transformation at the curve // Evaluate transformation at the curve
AnimationUtils::Bezier(start.Value, leftTangent, rightTangent, end.Value, alpha, transform); AnimationUtils::Bezier(start.Value, leftTangent, rightTangent, end.Value, alpha, transform);