Example #1
0
        /// <summary>
        /// Removes a child shape.
        /// </summary>
        /// <param name="shape">The shape.</param>
        public void RemoveChildShape(BepuColliderShape shape)
        {
            //        colliderShapes.Remove(shape);

            //        InternalCompoundShape.RemoveChildShape(shape.InternalShape);

            //        shape.Parent = null;
        }
Example #2
0
        //    private ICompoundShape internalCompoundShape;

        //    internal ICompoundShape InternalCompoundShape
        //    {
        //        get
        //        {

        //            return internalCompoundShape;
        //        }
        //        set
        //        {
        //            InternalShape = internalCompoundShape = value;
        //        }
        //    }

        /// <summary>
        /// Adds a child shape.
        /// </summary>
        /// <param name="shape">The shape.</param>
        public void AddChildShape(BepuColliderShape shape)
        {
            //        colliderShapes.Add(shape);

            //        var compoundMatrix = Matrix.RotationQuaternion(shape.LocalRotation) * Matrix.Translation(shape.LocalOffset);

            //        InternalCompoundShape.AddChildShape(compoundMatrix, shape.InternalShape);

            //        shape.Parent = this;
        }
Example #3
0
        public void Dispose()
        {
            if (Shape == null)
            {
                return;
            }

            var compound = Shape.Parent;

            compound?.RemoveChildShape(Shape);

            Shape.Dispose();
            Shape = null;
        }
Example #4
0
        internal static BepuColliderShape CreateShape(IBepuColliderShapeDesc desc, BepuUtilities.Memory.BufferPool bufferPool)
        {
            if (desc == null)
            {
                return(null);
            }

            BepuColliderShape shape = desc.CreateShape(bufferPool);

            if (shape == null)
            {
                return(null);
            }

            //shape.UpdateLocalTransformations();
            shape.Description = desc;

            return(shape);
        }
Example #5
0
        internal static BepuColliderShape Compose(IReadOnlyList <IBepuAssetColliderShapeDesc> descs, BepuUtilities.Memory.BufferPool bufferPool)
        {
            if (descs == null)
            {
                return(null);
            }

            BepuColliderShape res = null;

            if (descs.Count == 1) // Single shape case
            {
                res = CreateShape(descs[0], bufferPool);
                if (res == null)
                {
                    return(null);
                }
                res.IsPartOfAsset = true;
            }
            else if (descs.Count > 1) // Need a compound shape in this case
            {
                var compound = new BepuCompoundColliderShape();
                foreach (var desc in descs)
                {
                    var subShape = CreateShape(desc, bufferPool);
                    if (subShape == null)
                    {
                        continue;
                    }
                    compound.AddChildShape(subShape);
                }
                res = compound;
                res.IsPartOfAsset = true;
            }

            return(res);
        }
Example #6
0
 protected abstract void OnColliderShapeChanged(BepuColliderShape oldColliderShape, BepuColliderShape newColliderShape);