Пример #1
0
    protected override void Awake()
    {
        if (_handle != IntPtr.Zero)
        {
            return;
        }
        base.Awake();

        // in case no vertices have been set yet
        if (_verts == null)
        {
            _verts = defaultVerts;
        }

        Vector2[] transformed = MakeVerts();
        _handle = CP.NewConvexPolyShapeWithVerts(transformed.Length, transformed);
        CP.cpPolyShapeSetRadius(_handle, _maxScale * _radius);
        if (body != null)
        {
            body._AddMassForShape(this);
        }

        GCHandle gch = GCHandle.Alloc(this);

        CP._cpShapeSetUserData(_handle, GCHandle.ToIntPtr(gch));
    }
Пример #2
0
    protected override void Awake()
    {
        if (_handle != IntPtr.Zero)
        {
            return;
        }
        base.Awake();

        Vector2 offset = BodyRelativeMatrix(body).MultiplyPoint(_center);

        _handle = CP.cpCircleShapeNew(IntPtr.Zero, _maxScale * _radius, offset);
        if (body != null)
        {
            body._AddMassForShape(this);
        }

        var gch = GCHandle.Alloc(this);

        CP._cpShapeSetUserData(_handle, GCHandle.ToIntPtr(gch));
    }
Пример #3
0
    protected override void Awake()
    {
        if (_handle != IntPtr.Zero)
        {
            return;
        }
        base.Awake();

        var verts = MakeVerts();

        _handle = CP.NewConvexPolyShapeWithVerts(verts.Length, verts);
        CP.cpPolyShapeSetRadius(_handle, _maxScale * _radius);
        if (body != null)
        {
            body._AddMassForShape(this);
        }

        var gch = GCHandle.Alloc(this);

        CP._cpShapeSetUserData(_handle, GCHandle.ToIntPtr(gch));
    }
Пример #4
0
    protected override void Awake()
    {
        if (_handle != IntPtr.Zero)
        {
            return;
        }
        base.Awake();

        Matrix4x4 bmatrix = BodyRelativeMatrix(body);
        Vector2   pointA  = bmatrix.MultiplyPoint(_center - _endPoint);
        Vector2   pointB  = bmatrix.MultiplyPoint(_center + _endPoint);

        _handle = CP.cpSegmentShapeNew(IntPtr.Zero, pointA, pointB, _maxScale * _radius);
        if (body != null)
        {
            body._AddMassForShape(this);
        }

        var gch = GCHandle.Alloc(this);

        CP._cpShapeSetUserData(_handle, GCHandle.ToIntPtr(gch));
    }
Пример #5
0
    protected override void Awake()
    {
        if (_handle != IntPtr.Zero)
        {
            return;
        }
        base.Awake();

        // Force generating the hull.
        this.verts = _verts;

        var transformed = MakeVerts();

        _handle = CP.NewConvexPolyShapeWithVerts(transformed.Length, transformed);
        CP.cpPolyShapeSetRadius(_handle, _maxScale * _radius);
        if (body != null)
        {
            body._AddMassForShape(this);
        }

        var gch = GCHandle.Alloc(this);

        CP._cpShapeSetUserData(_handle, GCHandle.ToIntPtr(gch));
    }