Пример #1
0
        public override void Register(PhysicsWorld physics)
        {
            if (pworld == physics)
            {
                return;
            }
            pworld = physics;
            Collider cld = null;

            if (SurPath == null)  //sphere
            {
                cld = new SphereCollider(SphereRadius);
            }
            else
            {
                var mr = (ModelRenderer)Parent.RenderComponent;
                sur = new SurCollider(SurPath);
                cld = sur;
                if (Parent.RigidModel.From3db)
                {
                    sur.AddPart(PlainCrc, Matrix4x4.Identity, null);
                }
                else
                {
                    foreach (var part in Parent.RigidModel.AllParts)
                    {
                        var crc = CrcTool.FLModelCrc(part.Name);
                        if (part.Construct == null)
                        {
                            sur.AddPart(crc, Matrix4x4.Identity, part);
                        }
                        else
                        {
                            sur.AddPart(crc, part.LocalTransform, part);
                        }
                    }
                }
            }
            if (Mass < float.Epsilon)
            {
                Body = physics.AddStaticObject(Parent.GetTransform(), cld);
            }
            else
            {
                Body = physics.AddDynamicObject(Mass, Parent.GetTransform(), cld, Inertia);
            }
            Body.Tag = Parent;
            collider = cld;
        }