MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / Merge

Method Merge

Source/Engine/Core/Math/BoundingSphere.cpp:157–197  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

155}
156
157void BoundingSphere::Merge(const BoundingSphere& value1, const BoundingSphere& value2, BoundingSphere& result)
158{
159 // Pre-exit if one of the bounding sphere by assuming that a merge with an empty sphere is equivalent at taking the non-empty sphere
160 if (value1 == Empty)
161 {
162 result = value2;
163 return;
164 }
165 if (value2 == Empty)
166 {
167 result = value1;
168 return;
169 }
170
171 const Vector3 difference = value2.Center - value1.Center;
172 const Real length = difference.Length();
173 const Real radius = value1.Radius;
174 const Real radius2 = value2.Radius;
175
176 if (radius + radius2 >= length)
177 {
178 if (radius - radius2 >= length)
179 {
180 result = value1;
181 return;
182 }
183
184 if (radius2 - radius >= length)
185 {
186 result = value2;
187 return;
188 }
189 }
190
191 const Vector3 vector = difference * (1.0f / length);
192 const Real min = Math::Min(-radius, length - radius2);
193 const Real max = (Math::Max(radius, length + radius2) - min) * 0.5f;
194
195 result.Center = value1.Center + vector * (max + min);
196 result.Radius = max;
197}
198
199void BoundingSphere::Merge(const BoundingSphere& value1, const Vector3& value2, BoundingSphere& result)
200{

Callers 14

UpdateBoundsMethod · 0.45
UpdateSplineMethod · 0.45
InitializeMethod · 0.45
ImportModelMethod · 0.45
BuildBVHMethod · 0.45
GetEditorSphereMethod · 0.45
InvalidateBoundsMethod · 0.45
SnapToGroundMethod · 0.45
TransformGizmoBaseClass · 0.45
PrepareMethod · 0.45

Calls 3

MinFunction · 0.70
MaxFunction · 0.70
LengthMethod · 0.45

Tested by

no test coverage detected