Skip to content

Commit 9eea0e3

Browse files
authored
Merge pull request #3349 from dabingnn/add_dirtyRegion
armature works on dirty region
2 parents 3e09154 + bcfa2fd commit 9eea0e3

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

extensions/cocostudio/armature/CCArmatureCanvasRenderCmd.js

+3
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,11 @@
4747
this._needDraw = true;
4848

4949
this._realAnchorPointInPoints = new cc.Point(0,0);
50+
this._canUseDirtyRegion = true;
5051
this._startRenderCmd = new cc.CustomRenderCmd(this, this._startCmdCallback);
5152
this._RestoreRenderCmd = new cc.CustomRenderCmd(this, this._RestoreCmdCallback);
53+
this._startRenderCmd._canUseDirtyRegion = true;
54+
this._RestoreRenderCmd._canUseDirtyRegion = true;
5255
};
5356

5457
var proto = ccs.Armature.CanvasRenderCmd.prototype = Object.create(cc.Node.CanvasRenderCmd.prototype);

extensions/cocostudio/armature/display/CCSkinRenderCmd.js

+19
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
(function(){
2727
ccs.Skin.RenderCmd = {
28+
_realWorldTM: null,
2829
transform: function (parentCmd, recursive) {
2930
var node = this._node,
3031
pt = parentCmd ? parentCmd._worldTransform : null,
@@ -69,6 +70,11 @@
6970
wt.tx = t.tx;
7071
wt.ty = t.ty;
7172
}
73+
var rwtm = this._realWorldTM;
74+
if(rwtm) {
75+
rwtm.a = t.a; rwtm.b = t.b; rwtm.c = t.c; rwtm.d = t.d; rwtm.tx= t.tx; rwtm.ty = t.ty;
76+
cc.affineTransformConcatIn(rwtm, this._node.bone.getArmature()._renderCmd._worldTransform);
77+
}
7278
},
7379

7480
getNodeToWorldTransform: function () {
@@ -86,12 +92,25 @@
8692

8793
ccs.Skin.CanvasRenderCmd = function(renderable){
8894
cc.Sprite.CanvasRenderCmd.call(this, renderable);
95+
this._realWorldTM = {a: 1, b: 0, c: 0, d: 1, tx: 0, ty: 0};
8996
};
9097

9198
var proto = ccs.Skin.CanvasRenderCmd.prototype = Object.create(cc.Sprite.CanvasRenderCmd.prototype);
9299
cc.inject(ccs.Skin.RenderCmd, proto);
100+
93101
proto.constructor = ccs.Skin.CanvasRenderCmd;
94102

103+
proto._updateCurrentRegions = function () {
104+
var temp = this._currentRegion;
105+
this._currentRegion = this._oldRegion;
106+
this._oldRegion = temp;
107+
//hittest will call the transform, and set region flag to DirtyDouble, and the changes need to be considered for rendering
108+
if (cc.Node.CanvasRenderCmd.RegionStatus.DirtyDouble === this._regionFlag && (!this._currentRegion.isEmpty())) {
109+
this._oldRegion.union(this._currentRegion);
110+
}
111+
this._currentRegion.updateRegion(this.getLocalBB(), this._realWorldTM);
112+
};
113+
95114
ccs.Skin.WebGLRenderCmd = function(renderable){
96115
cc.Sprite.WebGLRenderCmd.call(this, renderable);
97116
};

0 commit comments

Comments
 (0)