/// <summary> /// Removes a child shape. /// </summary> /// <param name="shape">The shape.</param> public void RemoveChildShape(ColliderShape shape) { colliderShapes.Remove(shape); InternalCompoundShape.RemoveChildShape(shape.InternalShape); shape.Parent = null; }
public void Dispose() { if (Shape == null) { return; } Shape.Dispose(); Shape = null; }
/// <summary> /// Adds a child shape. /// </summary> /// <param name="shape">The shape.</param> public void AddChildShape(ColliderShape shape) { colliderShapes.Add(shape); var compoundMatrix = Matrix.RotationQuaternion(shape.LocalRotation) * Matrix.Translation(shape.LocalOffset); InternalCompoundShape.AddChildShape(compoundMatrix, shape.InternalShape); shape.Parent = this; }
protected override void OnChangeShape(ColliderShape newShape) { base.OnChangeShape(newShape); if (Simulation != null && Simulation.BodyExists(StaticHandle)) { var staticReference = Simulation.GetStaticReference(StaticHandle); staticReference.SetShape(newShape.InternalShapeIndex); } }
public void Dispose() { if (Shape == null) { return; } var compound = Shape.Parent; compound?.RemoveChildShape(Shape); Shape.Dispose(); Shape = null; }
internal static ColliderShape CreateShape(IColliderShapeDesc desc) { if (desc == null) { return(null); } ColliderShape shape = desc.CreateShape(); if (shape == null) { return(null); } //shape.UpdateLocalTransformations(); shape.Description = desc; return(shape); }
internal static ColliderShape CreateShape(Simulation simulation, ContentManager content, IColliderShapeDesc desc) { if (desc == null) { return(null); } ColliderShape shape = desc.CreateShape(simulation, content); if (shape == null) { return(null); } //shape.UpdateLocalTransformations(); shape.Description = desc; return(shape); }
internal static ColliderShape Compose(Simulation simulation, ContentManager content, IReadOnlyList <IAssetColliderShapeDesc> descs) { if (descs == null) { return(null); } ColliderShape res = null; if (descs.Count == 1) //single shape case { res = CreateShape(simulation, content, descs[0]); if (res == null) { return(null); } } return(res); }
public void ComposeShape() { if (Simulation == null || Simulation.PhysicsProcessor == null) { return; } ColliderShapeChanged = false; if (ColliderShapes.Count == 1) //single shape case { if (ColliderShapes[0] == null) { return; } var content = Simulation.PhysicsProcessor.Services.GetService <ContentManager>(); colliderShape = PhysicsColliderShape.CreateShape(Simulation, content, ColliderShapes[0]); } }
internal static ColliderShape Compose(IReadOnlyList <IAssetColliderShapeDesc> descs) { if (descs == null) { return(null); } ColliderShape res = null; if (descs.Count == 1) //single shape case { res = CreateShape(descs[0]); if (res == null) { return(null); } res.IsPartOfAsset = true; } else if (descs.Count > 1) //need a compound shape in this case { var compound = new CompoundColliderShape(); foreach (var desc in descs) { var subShape = CreateShape(desc); if (subShape == null) { continue; } compound.AddChildShape(subShape); } res = compound; res.IsPartOfAsset = true; } return(res); }
protected virtual void OnChangeShape(ColliderShape shape) { }