예제 #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(ColliderShapeAssetDesc))
                {
                    CanScaleShape = false;
                }

                ColliderShape = PhysicsColliderShape.CreateShape(ColliderShapes[0]);

                ColliderShape?.UpdateLocalTransformations();
            }
            else if (ColliderShapes.Count > 1) //need a compound shape in this case
            {
                var compound = new CompoundColliderShape();
                foreach (var desc in ColliderShapes)
                {
                    if (desc == null)
                    {
                        continue;
                    }
                    if (desc.GetType() == typeof(ColliderShapeAssetDesc))
                    {
                        CanScaleShape = false;
                    }

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

                ColliderShape = compound;

                ColliderShape.UpdateLocalTransformations();
            }
        }
예제 #2
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;
            }
        }
예제 #3
0
        public void ComposeShape()
        {
            ColliderShapeChanged = false;

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

            CanScaleShape = true;
            foreach (var desc in ColliderShapes)
            {
                if (desc is ColliderShapeAssetDesc)
                {
                    CanScaleShape = false;
                }
            }

            var services = Entity?.EntityManager?.Services;

            if (ColliderShapes.Count == 1) //single shape case
            {
                ColliderShape = ColliderShapes[0]?.CreateShape(services);
            }
            else if (ColliderShapes.Count > 1) //need a compound shape in this case
            {
                var compound = new CompoundColliderShape();
                foreach (var desc in ColliderShapes)
                {
                    if (desc == null)
                    {
                        continue;
                    }

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

                ColliderShape = compound;
            }

            if (ColliderShape != null)
            {
                // Force update internal shape and gizmo scaling
                ColliderShape.Scaling = ColliderShape.Scaling;
            }
        }
예제 #4
0
        internal void Detach()
        {
            Data = null;

            //this is mostly required for the game studio gizmos
            if (Simulation.DisableSimulation)
            {
                return;
            }

            // Actually call the detach
            OnDetach();

            if (ColliderShape != null && !ColliderShape.IsPartOfAsset)
            {
                ColliderShape.Dispose();
            }
        }
예제 #5
0
        internal void Detach()
        {
            if (!DoNotDispose)
            {
                Data = null;
            }

            //this is mostly required for the game studio gizmos
            if (Simulation.DisableSimulation)
            {
                return;
            }

            // Actually call the detach
            OnDetach();

            if (ColliderShape != null && !ColliderShape.DoNotDispose && !Xenko.Engine.SceneSystem.physicsDoNotDisposeNextRemoval)
            {
                ColliderShape.Dispose();
                ColliderShape = null;
            }
        }
예제 #6
0
        internal void Detach()
        {
            if (DoNotDispose)
            {
                Data = null;
            }

            //this is mostly required for the game studio gizmos
            if (Simulation.DisableSimulation)
            {
                return;
            }

            // Actually call the detach
            OnDetach();

            if (ColliderShape != null && !ColliderShape.DoNotDispose && !ColliderShape.DoNotDisposeAnyOnNextDetach)
            {
                ColliderShape.Dispose();
                ColliderShape = null;
            }
        }
예제 #7
0
        public void ComposeShape()
        {
            ColliderShapeChanged = false;

            if (ColliderShape != null)
            {
                if (!ColliderShape.DoNotDispose && !SceneSystem.physicsDoNotDisposeNextRemoval)
                {
                    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(ColliderShapeAssetDesc))
                {
                    CanScaleShape = false;
                }

                ColliderShape = PhysicsColliderShape.CreateShape(ColliderShapes[0]);
            }
            else if (ColliderShapes.Count > 1) //need a compound shape in this case
            {
                var compound = new CompoundColliderShape();
                foreach (var desc in ColliderShapes)
                {
                    if (desc == null)
                    {
                        continue;
                    }
                    if (desc.GetType() == typeof(ColliderShapeAssetDesc))
                    {
                        CanScaleShape = false;
                    }

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

                ColliderShape = compound;
            }

            if (ColliderShape != null)
            {
                // Force update internal shape and gizmo scaling
                ColliderShape.Scaling = ColliderShape.Scaling;
            }
        }