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

Method Resize

Source/Engine/Physics/Colliders/CharacterController.cpp:205–245  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

203}
204
205void CharacterController::Resize(float height, float radius)
206{
207 const float heightDiff = height - _height;
208 const float radiusDiff = radius - _radius;
209 if (Math::IsZero(heightDiff) && Math::IsZero(radiusDiff))
210 return;
211 _height = height;
212 _radius = radius;
213 if (_controller)
214 {
215 float centerDiff = heightDiff * 0.5f + radiusDiff;
216
217 // Change physics size
218 GetControllerSize(height, radius);
219 PhysicsBackend::SetControllerSize(_controller, radius, height);
220 Vector3 positionDelta = _upDirection * centerDiff;
221
222 // Change physics position to maintain feet placement (base)
223 Vector3 position;
224 switch (_originMode)
225 {
226 case OriginModes::CapsuleCenter:
227 position = PhysicsBackend::GetControllerPosition(_controller);
228 position += positionDelta;
229 _center += positionDelta;
230 PhysicsBackend::SetControllerPosition(_controller, position);
231 break;
232 case OriginModes::Base:
233 position = PhysicsBackend::GetControllerBasePosition(_controller);
234 position += positionDelta;
235 PhysicsBackend::SetControllerBasePosition(_controller, position);
236 break;
237 }
238
239 // Change actor position
240 _isUpdatingTransform = true;
241 SetPosition(position - _center);
242 _isUpdatingTransform = false;
243 }
244 UpdateBounds();
245}
246
247#if USE_EDITOR
248

Callers 15

ExtractMethod · 0.45
GetGroupNamesMethod · 0.45
UpdateMethod · 0.45
InitMethod · 0.45
loadMethod · 0.45
unloadMethod · 0.45
SyncMethod · 0.45
ClearStateMethod · 0.45
InitMethod · 0.45
GetLayoutMethod · 0.45
ParticleEffect.cppFile · 0.45

Calls 2

SetPositionFunction · 0.85
IsZeroFunction · 0.50

Tested by

no test coverage detected