Circle Collider's offset does not apply to its bounding box

When i set for example a circle collider in a node, it creates a bounding box around automatically, but this bounding box is connected to the anchor point, is there a way to move this bounding box without modifying the anchor?

The example above shows a circle collider (white circle) and a bounding box (blue rect) with a (0.5, 0) anchor.

I want to keep the bounding box centralized relative to the white circle with an anchor of (0.5, 0), how do i do this? Like this:

Maybe it is a bug, right, @pandamicro, @nantas2, @zhangbin ? The blue rect should or must follow the white circle, but it is not happening.

1 Like

I think it is a bug of circle collider because box and polygon colliders work no problem, their bounding boxes are centralized relatively to their offsets.

Maybe it is not applying the offset to the bounding box (aabb) here at this part of the code (source)

updateCollider: function (collider) {
   ...
   else if (collider instanceof cc.CircleCollider) {
        var p = cc.pointApplyAffineTransform(collider.offset, t);

        var tmpX = t.tx, tmpY = t.ty;
        t.tx = t.ty = 0;

        var tempP = cc.pointApplyAffineTransform(cc.v2(collider.radius, 0), t);
        var d = cc.v2(tempP).mag();

        world.radius = d;
        world.position = cc.v2(p);

        t.tx = tmpX;
        t.ty = tmpY;

        aabb.x = tmpX - d;
        aabb.y = tmpY - d;
        aabb.width = d * 2;
        aabb.height = d * 2;
    }
    ...
}

My question is: collider.offset is being applied to tmpX and tmpY? Could someone explain this code?

Perhaps we can ask @nantas2 to help

1 Like

So? Maybe the last developer who committed this source code might help. Do you know him?

I do. I have pinged him to help.

2 Likes

Thanks for your feedback.
This fixed in https://github.com/cocos-creator/engine/pull/1281.

2 Likes

Thanks! So will it be released for the next beta of cocos creator 1.3.x?

Yes, it will be released for 1.3.x.

2 Likes