Пример #1
0
        public override void Update(float dt)
        {
            base.Update(dt);

            if (CCMouse.Instance.rightclick)
            {
                cpPointQueryInfo info    = null;
                cpShape          nearest = space.PointQueryNearest(CCMouse.Instance.Position, 0.0f, GRAB_FILTER, ref info);
                if (nearest != null)
                {
                    cpBody body = nearest.GetBody();                    // cpShapeGetBody();
                    if (body.bodyType == cpBodyType.STATIC)
                    {
                        body.SetBodyType(cpBodyType.DYNAMIC);
                        body.SetMass(pentagon_mass);
                        body.SetMoment(pentagon_moment);
                    }
                    else if (body.bodyType == cpBodyType.DYNAMIC)
                    {
                        body.SetBodyType(cpBodyType.STATIC);
                    }
                }
            }



            space.EachBody(eachBody, null);

            space.Step(dt);
        }
Пример #2
0
        public void SliceShapePostStep(cpSpace space, cpShape shape, SliceContext context)
        {
            cpVect a = context.a;
            cpVect b = context.b;

            // Clipping plane normal and distance.
            cpVect n    = cpVect.cpvnormalize(cpVect.cpvperp(cpVect.cpvsub(b, a)));
            float  dist = cpVect.cpvdot(a, n);

            ClipPoly(space, shape, n, dist);
            ClipPoly(space, shape, cpVect.cpvneg(n), -dist);

            cpBody body = shape.GetBody();

            space.RemoveShape(shape);
            space.RemoveBody(body);
        }