|
@@ -931,7 +931,7 @@
|
|
|
private static _s = Vector3.Zero();
|
|
|
private static _r = Quaternion.Identity();
|
|
|
private static _t = Vector3.Zero();
|
|
|
- private static _uV3 = new Vector3(1, 1, 1);
|
|
|
+ private static _iV3 = new Vector3(1, 1, 1); // Must stay identity vector3
|
|
|
/**
|
|
|
* Update the instanceDataBase level properties of a part
|
|
|
* @param part the part to update
|
|
@@ -939,12 +939,22 @@
|
|
|
*/
|
|
|
protected updateInstanceDataPart(part: InstanceDataBase, positionOffset: Vector2 = null) {
|
|
|
let t = this._globalTransform.multiply(this.renderGroup.invGlobalTransform); // Compute the transformation into the renderGroup's space
|
|
|
- let rgScale = this._areSomeFlagsSet(SmartPropertyPrim.flagDontInheritParentScale) ? RenderablePrim2D._uV : this.renderGroup.actualScale; // We still need to apply the scale of the renderGroup to our rendering, so get it.
|
|
|
+ let scl = RenderablePrim2D._s;
|
|
|
+ let rot = RenderablePrim2D._r;
|
|
|
+ let trn = RenderablePrim2D._t;
|
|
|
+ t.decompose(scl, rot, trn);
|
|
|
+ let pas = this.actualScale;
|
|
|
+ scl.x = pas.x;
|
|
|
+ scl.y = pas.y;
|
|
|
+ scl.z = 1;
|
|
|
+ t = Matrix.Compose(this.applyActualScaleOnTransform() ? scl : RenderablePrim2D._iV3, rot, trn);
|
|
|
+
|
|
|
let size = (<Size>this.renderGroup.viewportSize);
|
|
|
let zBias = this.actualZOffset;
|
|
|
|
|
|
let offX = 0;
|
|
|
let offY = 0;
|
|
|
+
|
|
|
// If there's an offset, apply the global transformation matrix on it to get a global offset
|
|
|
if (positionOffset) {
|
|
|
offX = positionOffset.x * t.m[0] + positionOffset.y * t.m[4];
|
|
@@ -960,31 +970,9 @@
|
|
|
let w = size.width;
|
|
|
let h = size.height;
|
|
|
let invZBias = 1 / zBias;
|
|
|
- let tx = new Vector4(t.m[0] * rgScale.x * 2 / w, t.m[4] * rgScale.x * 2 / w, 0/*t.m[8]*/, ((t.m[12] + offX) * rgScale.x * 2 / w) - 1);
|
|
|
- let ty = new Vector4(t.m[1] * rgScale.y * 2 / h, t.m[5] * rgScale.y * 2 / h, 0/*t.m[9]*/, ((t.m[13] + offY) * rgScale.y * 2 / h) - 1);
|
|
|
-
|
|
|
- //if (!this.applyActualScaleOnTransform()) {
|
|
|
- // t.m[0] = tx.x, t.m[4] = tx.y, t.m[12] = tx.w;
|
|
|
- // t.m[1] = ty.x, t.m[5] = ty.y, t.m[13] = ty.w;
|
|
|
- // let las = this.actualScale;
|
|
|
- // t.decompose(RenderablePrim2D._s, RenderablePrim2D._r, RenderablePrim2D._t);
|
|
|
- // let scale = new Vector3(RenderablePrim2D._s.x / las.x, RenderablePrim2D._s.y / las.y, 1);
|
|
|
- // t = Matrix.Compose(scale, RenderablePrim2D._r, RenderablePrim2D._t);
|
|
|
- // tx = new Vector4(t.m[0], t.m[4], 0, t.m[12]);
|
|
|
- // ty = new Vector4(t.m[1], t.m[5], 0, t.m[13]);
|
|
|
- //}
|
|
|
-
|
|
|
- //tx.x /= w;
|
|
|
- //tx.y /= w;
|
|
|
-
|
|
|
- //ty.x /= h;
|
|
|
- //ty.y /= h;
|
|
|
-
|
|
|
- if (!this.applyActualScaleOnTransform()) {
|
|
|
- let las = this.actualScale;
|
|
|
- tx.x /= las.x;
|
|
|
- ty.y /= las.y;
|
|
|
- }
|
|
|
+ let tx = new Vector4(t.m[0] * 2 / w, t.m[4] * 2 / w, 0, ((t.m[12] + offX) * 2 / w) - 1);
|
|
|
+ let ty = new Vector4(t.m[1] * 2 / h, t.m[5] * 2 / h, 0, ((t.m[13] + offY) * 2 / h) - 1);
|
|
|
+
|
|
|
|
|
|
part.transformX = tx;
|
|
|
part.transformY = ty;
|