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

Method UpdateGeometry

Source/Engine/Physics/Colliders/Collider.cpp:223–273  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

221}
222
223void Collider::UpdateGeometry()
224{
225 if (_shape == nullptr)
226 return;
227
228 // Setup shape geometry
229 _cachedScale = GetScale().GetAbsolute().MaxValue();
230 CollisionShape shape;
231 GetGeometry(shape);
232
233 // Recreate shape if geometry has different type
234 if (PhysicsBackend::GetShapeType(_shape) != shape.Type)
235 {
236 // Detach from the actor
237 void* actor = PhysicsBackend::GetShapeActor(_shape);
238 if (actor)
239 PhysicsBackend::DetachShape(_shape, actor);
240
241 // Release shape
242 PhysicsBackend::RemoveCollider(this);
243 PhysicsBackend::DestroyShape(_shape);
244 _shape = nullptr;
245
246 // Recreate shape
247 CreateShape();
248
249 // Reattach again (only if can, see CanAttach function)
250 if (actor)
251 {
252 const auto rigidBody = dynamic_cast<RigidBody*>(GetParent());
253 if (rigidBody && CanAttach(rigidBody))
254 {
255 Attach(rigidBody);
256 }
257 else if (_staticActor != nullptr)
258 {
259 PhysicsBackend::AttachShape(_shape, actor);
260 }
261 else
262 {
263 // Be static triangle mesh
264 CreateStaticActor();
265 }
266 }
267
268 return;
269 }
270
271 // Update shape
272 PhysicsBackend::SetShapeGeometry(_shape, shape);
273}
274
275void Collider::CreateStaticActor()
276{

Callers

nothing calls this directly

Calls 5

GetScaleFunction · 0.85
CreateShapeFunction · 0.85
GetParentFunction · 0.50
MaxValueMethod · 0.45
GetAbsoluteMethod · 0.45

Tested by

no test coverage detected