Example #1
0
        public void ComposeShape()
        {
            ColliderShapeChanged = false;

            if (ColliderShape != null)
            {
                if (!ColliderShape.IsPartOfAsset)
                {
                    ColliderShape.Dispose();
                    ColliderShape = null;
                }
                else
                {
                    ColliderShape = null;
                }
            }

            CanScaleShape = true;

            if (ColliderShapes.Count == 1) // Single shape case
            {
                if (ColliderShapes[0] == null)
                {
                    return;
                }
                if (ColliderShapes[0].GetType() == typeof(BepuColliderShapeAssetDesc))
                {
                    CanScaleShape = false;
                }

                ColliderShape = BepuPhysicsColliderShape.CreateShape(ColliderShapes[0], Simulation.BufferPool);
            }
            else if (ColliderShapes.Count > 1) // Need a compound shape in this case
            {
                //var compound = new BepuCompoundColliderShape();
                //foreach (var desc in ColliderShapes)
                //{
                //    if (desc == null) continue;
                //    if (desc.GetType() == typeof(BepuColliderShapeAssetDesc))
                //    {
                //        CanScaleShape = false;
                //    }

                //    var subShape = BepuPhysicsColliderShape.CreateShape(desc);
                //    if (subShape != null)
                //    {
                //        compound.AddChildShape(subShape);
                //    }
                //}

                //ColliderShape = compound;
            }

            if (ColliderShape != null)
            {
                // Force update internal shape and gizmo scaling
                ColliderShape.Scaling = ColliderShape.Scaling;
            }
        }
Example #2
0
        public BepuColliderShape CreateShape(BepuUtilities.Memory.BufferPool bufferPool)
        {
            if (Shape == null)
            {
                return(null);
            }

            if (Shape.Shape == null)
            {
                Shape.Shape = BepuPhysicsColliderShape.Compose(Shape.Descriptions, bufferPool);
            }

            return(Shape.Shape);
        }