浏览代码

Merge pull request #7 from Unity-Technologies/siyao

transform matrix3 to matrix4
/main
GitHub 4 年前
当前提交
02c970c7
共有 36 个文件被更改,包括 1218 次插入259 次删除
  1. 3
      Samples/UIWidgetsSamples_2019_4/Assets/Editor/Widgets.cs
  2. 3
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/animation/widgets.cs
  3. 9
      com.unity.uiwidgets/Runtime/cupertino/text_selection.cs
  4. 4
      com.unity.uiwidgets/Runtime/material/bottom_navigation_bar.cs
  5. 2
      com.unity.uiwidgets/Runtime/material/flexible_space_bar.cs
  6. 4
      com.unity.uiwidgets/Runtime/material/ink_decoration.cs
  7. 4
      com.unity.uiwidgets/Runtime/material/ink_highlight.cs
  8. 4
      com.unity.uiwidgets/Runtime/material/ink_ripple.cs
  9. 4
      com.unity.uiwidgets/Runtime/material/ink_splash.cs
  10. 16
      com.unity.uiwidgets/Runtime/material/input_decorator.cs
  11. 4
      com.unity.uiwidgets/Runtime/material/material.cs
  12. 4
      com.unity.uiwidgets/Runtime/material/text_selection.cs
  13. 136
      com.unity.uiwidgets/Runtime/painting/matrix_utils.cs
  14. 20
      com.unity.uiwidgets/Runtime/rendering/box.cs
  15. 102
      com.unity.uiwidgets/Runtime/rendering/layer.cs
  16. 8
      com.unity.uiwidgets/Runtime/rendering/list_wheel_viewport.cs
  17. 23
      com.unity.uiwidgets/Runtime/rendering/object.cs
  18. 82
      com.unity.uiwidgets/Runtime/rendering/proxy_box.cs
  19. 2
      com.unity.uiwidgets/Runtime/rendering/proxy_box.mixin.gen.cs
  20. 23
      com.unity.uiwidgets/Runtime/rendering/rotated_box.cs
  21. 14
      com.unity.uiwidgets/Runtime/rendering/sliver.cs
  22. 2
      com.unity.uiwidgets/Runtime/rendering/sliver_multi_box_adaptor.cs
  23. 2
      com.unity.uiwidgets/Runtime/rendering/sliver_padding.cs
  24. 2
      com.unity.uiwidgets/Runtime/rendering/sliver_persistent_header.cs
  25. 15
      com.unity.uiwidgets/Runtime/rendering/view.cs
  26. 14
      com.unity.uiwidgets/Runtime/rendering/viewport.cs
  27. 12
      com.unity.uiwidgets/Runtime/widgets/basic.cs
  28. 8
      com.unity.uiwidgets/Runtime/widgets/container.cs
  29. 3
      com.unity.uiwidgets/Runtime/widgets/heroes.cs
  30. 46
      com.unity.uiwidgets/Runtime/widgets/implicit_animations.cs
  31. 2
      com.unity.uiwidgets/Runtime/widgets/nested_scroll_view.cs
  32. 8
      com.unity.uiwidgets/Runtime/widgets/single_child_scroll_view.cs
  33. 4
      com.unity.uiwidgets/Runtime/widgets/transitions.cs
  34. 19
      com.unity.uiwidgets/Runtime/widgets/widget_inspector.cs
  35. 858
      com.unity.uiwidgets/Runtime/ui/Matrix4.cs
  36. 11
      com.unity.uiwidgets/Runtime/ui/Matrix4.cs.meta

3
Samples/UIWidgetsSamples_2019_4/Assets/Editor/Widgets.cs


var mediaQueryData = MediaQuery.of(context);
var px = mediaQueryData.size.width / 2;
var py = mediaQueryData.size.width / 2;
transform: Matrix3.makeRotate(Mathf.PI / 180 * 5, px, py),
transform: new Matrix4().rotationZ(Mathf.PI / 180 * 5, px, py),
child:
new Column(
children: new List<Widget> {

3
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/animation/widgets.cs


);
public override Widget build(BuildContext context) {
var scale = this.scale ?? 1.0f;
transform: Matrix3.makeScale(this.scale ?? 1.0f),
transform: new Matrix4().diagonal3Values(scale, scale, scale),
alignment: Alignment.center,
child: new Stack(
children: new List<Widget> {

9
com.unity.uiwidgets/Runtime/cupertino/text_selection.cs


switch (type) {
case TextSelectionHandleType.left:
Matrix3 matrix = Matrix3.makeRotate(Mathf.PI);
matrix.preTranslate(-CupertinoTextSelectionUtils._kHandlesPadding,
Matrix4 matrix = new Matrix4().rotationZ(Mathf.PI);
matrix.translate(-CupertinoTextSelectionUtils._kHandlesPadding,
-CupertinoTextSelectionUtils._kHandlesPadding);
return new Transform(

case TextSelectionHandleType.right:
return new Transform(
transform: Matrix3.makeTrans(
transform:new Matrix4().translationValues(
-(textLineHeight + CupertinoTextSelectionUtils._kHandlesPadding)
-(textLineHeight + CupertinoTextSelectionUtils._kHandlesPadding),
0
),
child: handle
);

4
com.unity.uiwidgets/Runtime/material/bottom_navigation_bar.cs


color: this.colorTween.evaluate(this.animation)
),
child: new Transform(
transform: Matrix3.makeAll(t, 0, 0,
0, t, 0,
0, 0, 1),
transform: new Matrix4().diagonal3Values(t, t, t),
alignment: Alignment.bottomCenter,
child: this.item.title
)

2
com.unity.uiwidgets/Runtime/material/flexible_space_bar.cs


bottom: 16.0f
);
float scaleValue = new FloatTween(begin: 1.5f, end: 1.0f).lerp(t);
Matrix3 scaleTransform = Matrix3.makeScale(scaleValue, scaleValue);
Matrix4 scaleTransform = new Matrix4().diagonal3Values(scaleValue, scaleValue, 1);
Alignment titleAlignment = this._getTitleAlignment(effectiveCenterTitle);
children.Add(new Container(

4
com.unity.uiwidgets/Runtime/material/ink_decoration.cs


base.dispose();
}
protected override void paintFeature(Canvas canvas, Matrix3 transform) {
protected override void paintFeature(Canvas canvas, Matrix4 transform) {
if (this._painter == null) {
return;
}

if (originOffset == null) {
canvas.save();
canvas.concat(transform);
canvas.concat(transform.toMatrix3());
this._painter.paint(canvas, Offset.zero, sizedConfiguration);
canvas.restore();
}

4
com.unity.uiwidgets/Runtime/material/ink_highlight.cs


canvas.restore();
}
protected override void paintFeature(Canvas canvas, Matrix3 transform) {
protected override void paintFeature(Canvas canvas, Matrix4 transform) {
canvas.concat(transform);
canvas.concat(transform.toMatrix3());
this._paintHighlight(canvas, rect, paint);
canvas.restore();
}

4
com.unity.uiwidgets/Runtime/material/ink_ripple.cs


base.dispose();
}
protected override void paintFeature(Canvas canvas, Matrix3 transform) {
protected override void paintFeature(Canvas canvas, Matrix4 transform) {
int alpha = this._fadeInController.isAnimating ? this._fadeIn.value : this._fadeOut.value;
Paint paint = new Paint {color = this.color.withAlpha(alpha)};
Offset center = Offset.lerp(

Offset originOffset = transform.getAsTranslation();
canvas.save();
if (originOffset == null) {
canvas.concat(transform);
canvas.concat(transform.toMatrix3());
}
else {
canvas.translate(originOffset.dx, originOffset.dy);

4
com.unity.uiwidgets/Runtime/material/ink_splash.cs


base.dispose();
}
protected override void paintFeature(Canvas canvas, Matrix3 transform) {
protected override void paintFeature(Canvas canvas, Matrix4 transform) {
Paint paint = new Paint {color = this.color.withAlpha(this._alpha.value)};
Offset center = this._position;
if (this._repositionToReferenceBox) {

Offset originOffset = transform.getAsTranslation();
canvas.save();
if (originOffset == null) {
canvas.concat(transform);
canvas.concat(transform.toMatrix3());
}
else {
canvas.translate(originOffset.dx, originOffset.dy);

16
com.unity.uiwidgets/Runtime/material/input_decorator.cs


protected internal override Widget build(BuildContext context) {
return new Transform(
transform: Matrix3.makeTrans(this.translateX, 0.0f),
transform: new Matrix4().translationValues(this.translateX, 0, 0),
child: this.child
);
}

return _boxParentData(this.input).offset.dy + this.input.getDistanceToActualBaseline(baseline);
}
Matrix3 _labelTransform;
Matrix4 _labelTransform;
protected override void performLayout() {
this._labelTransform = null;

float scale = MathUtils.lerpFloat(1.0f, 0.75f, t);
float dx = labelOffset.dx;
float dy = MathUtils.lerpFloat(0.0f, floatingY - labelOffset.dy, t);
this._labelTransform = Matrix3.I();
this._labelTransform.preTranslate(dx, labelOffset.dy + dy);
this._labelTransform.preScale(scale, scale);
this._labelTransform = new Matrix4().identity();
this._labelTransform.translate(dx, labelOffset.dy + dy);
this._labelTransform.scale(scale, scale, 1);
context.pushTransform(this.needsCompositing, offset, this._labelTransform, this._paintLabel);
}

return false;
}
public override void applyPaintTransform(RenderObject child, Matrix3 transform) {
public override void applyPaintTransform(RenderObject child, Matrix4 transform) {
transform.preConcat(this._labelTransform);
transform.preTranslate(-labelOffset.dx, -labelOffset.dy);
transform.multiply(this._labelTransform);
transform.translate(-labelOffset.dx, -labelOffset.dy);
}
base.applyPaintTransform(child, transform);

4
com.unity.uiwidgets/Runtime/material/material.cs


descendants.Add(node);
}
Matrix3 transform = Matrix3.I();
Matrix4 transform = new Matrix4().identity();
D.assert(descendants.Count >= 2);
for (int index = descendants.Count - 1; index > 0; index -= 1) {
descendants[index].applyPaintTransform(descendants[index - 1], transform);

}
protected abstract void paintFeature(Canvas canvas, Matrix3 transform);
protected abstract void paintFeature(Canvas canvas, Matrix4 transform);
public override string ToString() {
return this.GetType() + "";

4
com.unity.uiwidgets/Runtime/material/text_selection.cs


switch (type) {
case TextSelectionHandleType.left: // points up-right
return new Transform(
transform: Matrix3.makeRotate(Mathf.PI / 2),
transform: new Matrix4().rotationZ(Mathf.PI / 2),
child: handle
);
case TextSelectionHandleType.right: // points up-left

transform: Matrix3.makeRotate(Mathf.PI / 4),
transform: new Matrix4().rotationZ(Mathf.PI / 4),
child: handle
);
}

136
com.unity.uiwidgets/Runtime/painting/matrix_utils.cs


namespace Unity.UIWidgets.painting {
public static class MatrixUtils {
public static Offset getAsTranslation(this Matrix3 matrix3) {
return matrix3.isTranslate() ? new Offset(matrix3[Matrix3.kMTransX], matrix3[Matrix3.kMTransY]) : null;
public static float dot(this Vector3 left, Vector3 right) {
return left.x * right.x + left.y * right.y + left.z * right.z;
}
public static Offset getAsTranslation(this Matrix4 values) {
if (values[0] == 1 && // col 1
values[1] == 0 &&
values[2] == 0 &&
values[3] == 0 &&
values[4] == 0 && // col 2
values[5] == 1 &&
values[6] == 0 &&
values[7] == 0 &&
values[8] == 0 && // col 3
values[9] == 0 &&
values[10] == 1 &&
values[11] == 0 &&
values[14] == 0 && // bottom of col 4 (values 12 and 13 are the x and y offsets)
values[15] == 1) {
return new Offset(values[12], values[13]);
}
else {
return null;
}
}
public static void QuaternionFromMatrix(this Matrix4 m, ref Quaternion q) {
q.w = Mathf.Sqrt( Mathf.Max( 0, 1 + m.entry(0,0) + m.entry(1,1) + m.entry(2,2) ) ) / 2;
q.x = Mathf.Sqrt( Mathf.Max( 0, 1 + m.entry(0,0) - m.entry(1,1) - m.entry(2,2) ) ) / 2;
q.y = Mathf.Sqrt( Mathf.Max( 0, 1 - m.entry(0,0) + m.entry(1,1) - m.entry(2,2) ) ) / 2;
q.z = Mathf.Sqrt( Mathf.Max( 0, 1 - m.entry(0,0) - m.entry(1,1) + m.entry(2,2) ) ) / 2;
q.x *= Mathf.Sign( q.x * ( m.entry(2,1) - m.entry(1,2) ) );
q.y *= Mathf.Sign( q.y * ( m.entry(0,2) - m.entry(2,0) ) );
q.z *= Mathf.Sign( q.z * ( m.entry(1,0) - m.entry(0,1) ) );
public static List<string> debugDescribeTransform(Matrix3 transform) {
public static Quaternion scaled(this Quaternion lhs, float scale) {
lhs.x *= scale;
lhs.y *= scale;
lhs.z *= scale;
lhs.w *= scale;
return lhs;
}
public static Quaternion add(this Quaternion lhs, Quaternion rhs) {
lhs.x += rhs.x;
lhs.y += rhs.y;
lhs.z += rhs.z;
lhs.w += rhs.w;
return lhs;
}
public static List<string> debugDescribeTransform(Matrix4 transform) {
if (transform == null) {
return new List<string> {"null"};
}

return result;
}
public static Vector3 perspectiveTransform(this Matrix4x4 m4, Vector3 arg) {
List<float> argStorage = new List<float> {arg[0], arg[1], arg[2]};
float x_ = (m4[0] * argStorage[0]) +
(m4[4] * argStorage[1]) +
(m4[8] * argStorage[2]) +
m4[12];
float y_ = (m4[1] * argStorage[0]) +
(m4[5] * argStorage[1]) +
(m4[9] * argStorage[2]) +
m4[13];
float z_ = (m4[2] * argStorage[0]) +
(m4[6] * argStorage[1]) +
(m4[10] * argStorage[2]) +
m4[14];
float w_ = 1.0f /
((m4[3] * argStorage[0]) +
(m4[7] * argStorage[1]) +
(m4[11] * argStorage[2]) +
m4[15]);
argStorage[0] = x_ * w_;
argStorage[1] = y_ * w_;
argStorage[2] = z_ * w_;
return arg;
}
public static Offset transformPoint(Matrix4x4 transform, Offset point) {
Vector3 position3 = new Vector3(point.dx, point.dy, 0.0f);
public static Offset transformPoint(Matrix4 transform, Offset point) {
Vector3 position3 = new Vector3(point.dx, point.dy, 0);
public static Rect transformRect(Matrix4x4 transform, Rect rect) {
public static Rect transformRect(Matrix4 transform, Rect rect) {
Offset point1 = transformPoint(transform, rect.topLeft);
Offset point2 = transformPoint(transform, rect.topRight);
Offset point3 = transformPoint(transform, rect.bottomLeft);

);
}
static bool isIdentity(Matrix4 a) {
D.assert(a != null);
return a[0] == 1.0 // col 1
&& a[1] == 0.0
&& a[2] == 0.0
&& a[3] == 0.0
&& a[4] == 0.0 // col 2
&& a[5] == 1.0
&& a[6] == 0.0
&& a[7] == 0.0
&& a[8] == 0.0 // col 3
&& a[9] == 0.0
&& a[10] == 1.0
&& a[11] == 0.0
&& a[12] == 0.0 // col 4
&& a[13] == 0.0
&& a[14] == 0.0
&& a[15] == 1.0;
}
public static Rect inverseTransformRect(Matrix4 transform, Rect rect) {
D.assert(rect != null);
D.assert(transform.determinant() != 0.0);
if (isIdentity(transform))
return rect;
transform = Matrix4.tryInvert(transform);
return transformRect(transform, rect);
}
static float _min4(float a, float b, float c, float d) {
return Mathf.Min(a, Mathf.Min(b, Mathf.Min(c, d)));
}

return matrix;
}
public static Matrix3 toMatrix3(this Matrix4 matrix4) {
var matrix = Matrix3.I();
matrix[0] = matrix4.entry(0, 0);
matrix[1] = matrix4.entry(0, 1);
matrix[2] = matrix4.entry(0, 3);
matrix[3] = matrix4.entry(1, 0);
matrix[4] = matrix4.entry(1, 1);
matrix[5] = matrix4.entry(1, 3);
matrix[6] = matrix4.entry(3, 0);
matrix[7] = matrix4.entry(3, 1);
matrix[8] = matrix4.entry(3, 3);
return matrix;
}
public class TransformProperty : DiagnosticsProperty<Matrix3> {
public TransformProperty(string name, Matrix3 value,
public class TransformProperty : DiagnosticsProperty<Matrix4> {
public TransformProperty(string name, Matrix4 value,
bool showName = true,
object defaultValue = null,
DiagnosticLevel level = DiagnosticLevel.info

20
com.unity.uiwidgets/Runtime/rendering/box.cs


return false;
}
public override void applyPaintTransform(RenderObject child, Matrix3 transform) {
public override void applyPaintTransform(RenderObject child, Matrix4 transform) {
D.assert(child != null);
D.assert(child.parent == this);
D.assert(() => {

var childParentData = (BoxParentData) child.parentData;
var offset = childParentData.offset;
transform.preTranslate(offset.dx, offset.dy);
transform.translate(offset.dx, offset.dy);
var inverse = Matrix3.I();
var invertible = transform.invert(inverse);
return invertible ? inverse.mapPoint(point) : Offset.zero;
float det = transform.invert();
if (det == 0) {
return Offset.zero;
}
Vector3 n = new Vector3(0, 0, 1);
Vector3 i = transform.perspectiveTransform(new Vector3(0, 0, 0));
Vector3 d = transform.perspectiveTransform(new Vector3(0, 0, 1)) - i;
Vector3 s = transform.perspectiveTransform(new Vector3(point.dx, point.dy, 0));
Vector3 p = s - d * (n.dot(s) / n.dot(d));
return new Offset(p.x, p.y);
return this.getTransformTo(ancestor).mapPoint(point);
return MatrixUtils.transformPoint(this.getTransformTo(ancestor), point);
}
public override Rect paintBounds {

102
com.unity.uiwidgets/Runtime/rendering/layer.cs


}
}
public virtual void applyTransform(Layer child, Matrix3 transform) {
public virtual void applyTransform(Layer child, Matrix4 transform) {
D.assert(child != null);
D.assert(transform != null);
}

return base.find<S>(regionOffset - this.offset);
}
public override void applyTransform(Layer child, Matrix3 transform) {
public override void applyTransform(Layer child, Matrix4 transform) {
transform.preTranslate((float) this.offset.dx, (float) this.offset.dy);
transform.translate(this.offset.dx, this.offset.dy);
}
public Scene buildScene(SceneBuilder builder) {

}
public class TransformLayer : OffsetLayer {
public TransformLayer(Matrix3 transform = null, Offset offset = null) : base(offset) {
this._transform = transform ?? Matrix3.I();
public TransformLayer(Matrix4 transform = null, Offset offset = null) : base(offset) {
this._transform = transform ?? new Matrix4().identity();
public Matrix3 transform {
public Matrix4 transform {
set {
this._transform = value;
this._inverseDirty = true;
}
Matrix3 _transform;
Matrix3 _lastEffectiveTransform;
Matrix4 _transform;
Matrix4 _lastEffectiveTransform;
readonly Matrix3 _invertedTransform = Matrix3.I();
Matrix4 _invertedTransform;
this.transform.invert(this._invertedTransform);
this._invertedTransform = Matrix4.tryInvert(this.transform);
this._inverseDirty = false;
}

Offset transform = this._invertedTransform.mapXY(regionOffset.dx, regionOffset.dy);
return base.find<S>(transform);
Vector4 vector = new Vector4(regionOffset.dx, regionOffset.dy, 0, 1);
Vector4 result = this._invertedTransform.transform(vector);
return base.find<S>(new Offset(result[0], result[1]));
}
internal override flow.Layer addToScene(SceneBuilder builder, Offset layerOffset = null) {

var totalOffset = this.offset + layerOffset;
if (totalOffset != Offset.zero) {
this._lastEffectiveTransform = Matrix3.makeTrans(totalOffset.dx, totalOffset.dy);
this._lastEffectiveTransform.preConcat(this._transform);
this._lastEffectiveTransform = new Matrix4().translationValues(totalOffset.dx, totalOffset.dy, 0);
this._lastEffectiveTransform.multiply(this.transform);
builder.pushTransform(this._lastEffectiveTransform);
builder.pushTransform(this._lastEffectiveTransform.toMatrix3());
public override void applyTransform(Layer child, Matrix3 transform) {
public override void applyTransform(Layer child, Matrix4 transform) {
transform.preConcat(this.transform);
transform.multiply(this.transform);
transform.preConcat(this._lastEffectiveTransform);
transform.multiply(this._lastEffectiveTransform);
properties.add(new DiagnosticsProperty<Matrix3>("transform", this.transform));
properties.add(new DiagnosticsProperty<Matrix4>("transform", this.transform));
}
}

D.assert(this.offset != null);
this._lastOffset = this.offset + layerOffset;
if (this._lastOffset != Offset.zero) {
builder.pushTransform(Matrix3.makeTrans(this._lastOffset));
builder.pushTransform(new Matrix4()
.translationValues(this._lastOffset.dx, this._lastOffset.dy,0)
.toMatrix3());
}
this.addChildrenToScene(builder, Offset.zero);

return null;
}
public override void applyTransform(Layer child, Matrix3 transform) {
public override void applyTransform(Layer child, Matrix4 transform) {
transform.preTranslate(this._lastOffset.dx, this._lastOffset.dy);
transform.translate(this._lastOffset.dx, this._lastOffset.dy);
}
}

public Offset linkedOffset;
Offset _lastOffset;
Matrix3 _lastTransform;
Matrix4 _lastTransform;
readonly Matrix3 _invertedTransform = Matrix3.I();
Matrix4 _invertedTransform = new Matrix4().identity();
bool _inverseDirty = true;
internal override S find<S>(Offset regionOffset) {

if (this._inverseDirty) {
this.getLastTransform().invert(this._invertedTransform);
this._invertedTransform = Matrix4.tryInvert(this.getLastTransform());
this._inverseDirty = false;
}

Offset transform = this._invertedTransform.mapXY(regionOffset.dx, regionOffset.dy);
return base.find<S>(transform - this.linkedOffset);
Vector4 vector = new Vector4(regionOffset.dx, regionOffset.dy, 0, 1);
Vector4 result = this._invertedTransform.transform(vector);
return base.find<S>(new Offset(result[0] - this.linkedOffset.dx, result[1] - this.linkedOffset.dy));
public Matrix3 getLastTransform() {
public Matrix4 getLastTransform() {
Matrix3 result = Matrix3.makeTrans(-this._lastOffset.dx, -this._lastOffset.dy);
result.preConcat(this._lastTransform);
Matrix4 result = new Matrix4().translationValues(-this._lastOffset.dx, -this._lastOffset.dy,0 );
result.multiply(this._lastTransform);
Matrix3 _collectTransformForLayerChain(List<ContainerLayer> layers) {
Matrix3 result = Matrix3.I();
Matrix4 _collectTransformForLayerChain(List<ContainerLayer> layers) {
Matrix4 result = new Matrix4().identity();
for (int index = layers.Count - 1; index > 0; index -= 1) {
layers[index].applyTransform(layers[index - 1], result);
}

inverseLayers.Add(layer);
} while (layer != ancestor);
Matrix3 forwardTransform = this._collectTransformForLayerChain(forwardLayers);
Matrix3 inverseTransform = this._collectTransformForLayerChain(inverseLayers);
var inverse = Matrix3.I();
var invertible = inverseTransform.invert(inverse);
if (!invertible) {
Matrix4 forwardTransform = this._collectTransformForLayerChain(forwardLayers);
Matrix4 inverseTransform = this._collectTransformForLayerChain(inverseLayers);
if (inverseTransform.invert() == 0) {
inverseTransform = inverse;
inverseTransform.preConcat(forwardTransform);
inverseTransform.preTranslate(this.linkedOffset.dx, this.linkedOffset.dy);
inverseTransform.multiply(forwardTransform);
inverseTransform.translate(this.linkedOffset.dx, this.linkedOffset.dy);
this._lastTransform = inverseTransform;
this._inverseDirty = true;
}

this._establishTransform();
if (this._lastTransform != null) {
builder.pushTransform(this._lastTransform);
builder.pushTransform(this._lastTransform.toMatrix3());
this.addChildrenToScene(builder);
builder.pop();
this._lastOffset = this.unlinkedOffset + layerOffset;

var matrix = Matrix3.makeTrans(this.unlinkedOffset.dx, this.unlinkedOffset.dy);
builder.pushTransform(matrix);
var matrix = new Matrix4().translationValues(this.unlinkedOffset.dx, this.unlinkedOffset.dy, 0);
builder.pushTransform(matrix.toMatrix3());
this.addChildrenToScene(builder);
builder.pop();
}

}
public override void applyTransform(Layer child, Matrix3 transform) {
public override void applyTransform(Layer child, Matrix4 transform) {
transform.preConcat(this._lastTransform);
transform.multiply(this._lastTransform);
transform.preConcat(Matrix3.makeTrans(this.unlinkedOffset.dx, this.unlinkedOffset.dy));
transform.multiply(new Matrix4().translationValues(this.unlinkedOffset.dx, this.unlinkedOffset.dy, 0));
}
}

internal Path _debugTransformedClipPath {
get {
ContainerLayer ancestor = this.parent;
Matrix3 matrix = Matrix3.I();
Matrix4 matrix = new Matrix4().identity();
return this.clipPath.transform(matrix);
return this.clipPath.transform(matrix.toMatrix3());
}
}

8
com.unity.uiwidgets/Runtime/rendering/list_wheel_viewport.cs


var radius = this.size.height * this._diameterRatio / 2.0f;
var deltaY = radius * Mathf.Sin(angle);
Matrix3 transform = Matrix3.I();
Matrix4 transform = new Matrix4().identity();
// Matrix4x4 transform2 = MatrixUtils.createCylindricalProjectionTransform(
// radius: this.size.height * this._diameterRatio / 2.0f,
// angle: angle,

Offset offset,
RenderBox child,
// Matrix4x4 cylindricalTransform,
Matrix3 cylindricalTransform,
Matrix4 cylindricalTransform,
Offset offsetToCenter,
Offset untransformedPaintingCoordinates
) {

Offset offset,
RenderBox child,
// Matrix4x4 cylindricalTransform,
Matrix3 cylindricalTransform,
Matrix4 cylindricalTransform,
Offset offsetToCenter
) {
context.pushTransform(

ListWheelParentData parentData = (ListWheelParentData) child.parentData;
float targetOffset = parentData.offset.dy;
Matrix4x4 transform = target.getTransformTo(this).toMatrix4x4();
Matrix4 transform = target.getTransformTo(this);
Rect bounds = MatrixUtils.transformRect(transform, rect);
Rect targetRect = bounds.translate(0.0f, (this.size.height - this.itemExtent) / 2);

23
com.unity.uiwidgets/Runtime/rendering/object.cs


}
}
public void pushTransform(bool needsCompositing, Offset offset, Matrix3 transform,
public void pushTransform(bool needsCompositing, Offset offset, Matrix4 transform,
Matrix3 effectiveTransform;
Matrix4 effectiveTransform;
effectiveTransform = Matrix3.makeTrans(offset.dx, offset.dy);
effectiveTransform.preConcat(transform);
effectiveTransform.preTranslate(-offset.dx, -offset.dy);
effectiveTransform = new Matrix4().translationValues(offset.dx, offset.dy, 0);
effectiveTransform.multiply(transform);
effectiveTransform.translate(-offset.dx, -offset.dy);
var inverse = Matrix3.I();
var invertible = effectiveTransform.invert(inverse);
// it could just be "scale == 0", ignore the assertion.
// D.assert(invertible);

offset,
childPaintBounds: inverse.mapRect(this.estimatedBounds)
childPaintBounds: MatrixUtils.inverseTransformRect(effectiveTransform, this.estimatedBounds)
this.canvas.concat(effectiveTransform);
this.canvas.concat(effectiveTransform.toMatrix3());
painter(this, offset);
this.canvas.restore();
}

public virtual void paint(PaintingContext context, Offset offset) {
}
public virtual void applyPaintTransform(RenderObject child, Matrix3 transform) {
public virtual void applyPaintTransform(RenderObject child, Matrix4 transform) {
public Matrix3 getTransformTo(RenderObject ancestor) {
public Matrix4 getTransformTo(RenderObject ancestor) {
D.assert(this.attached);
if (ancestor == null) {

renderers.Add(renderer);
}
var transform = Matrix3.I();
var transform = new Matrix4().identity();
for (int index = renderers.Count - 1; index > 0; index -= 1) {
renderers[index].applyPaintTransform(renderers[index - 1], transform);
}

82
com.unity.uiwidgets/Runtime/rendering/proxy_box.cs


public class RenderTransform : RenderProxyBox {
public RenderTransform(
Matrix3 transform,
Matrix4 transform,
Offset origin = null,
Alignment alignment = null,
bool transformHitTests = true,

public bool transformHitTests;
public Matrix3 transform {
public Matrix4 transform {
set {
if (this._transform == value) {
return;

}
}
Matrix3 _transform;
Matrix4 _transform;
this._transform = Matrix3.I();
this._transform = new Matrix4().identity();
this.markNeedsPaint();
}

}
public void rotateZ(float degrees) {
this._transform.preRotate(degrees);
this._transform.rotateZ(degrees);
this._transform.preTranslate(x, y);
this._transform.translationValues(x, y, 0);
this._transform.preScale(x, y);
this._transform.scale(x, y, 1);
Matrix3 _effectiveTransform {
Matrix4 _effectiveTransform {
get {
Alignment resolvedAlignment = this.alignment;
if (this._origin == null && resolvedAlignment == null) {

var result = Matrix3.I();
var result = new Matrix4().identity();
result.preTranslate(this._origin.dx, this._origin.dy);
result.translate(this._origin.dx, this._origin.dy);
result.preTranslate(translation.dx, translation.dy);
result.translate(translation.dx, translation.dy);
result.preConcat(this._transform);
result.multiply(this._transform);
result.preTranslate(-translation.dx, -translation.dy);
result.translate(-translation.dx, -translation.dy);
result.preTranslate(-this._origin.dx, -this._origin.dy);
result.translate(-this._origin.dx, -this._origin.dy);
}
return result;

protected override bool hitTestChildren(HitTestResult result, Offset position = null) {
if (this.transformHitTests) {
var transform = this._effectiveTransform;
var inverse = Matrix3.I();
var invertible = transform.invert(inverse);
var inverse = Matrix4.tryInvert(transform);
if (!invertible) {
if (inverse == null) {
position = inverse.mapPoint(position);
position = MatrixUtils.transformPoint(inverse, position);
}
return base.hitTestChildren(result, position: position);

}
}
public override void applyPaintTransform(RenderObject child, Matrix3 transform) {
transform.preConcat(this._effectiveTransform);
public override void applyPaintTransform(RenderObject child, Matrix4 transform) {
transform.multiply(this._effectiveTransform);
properties.add(new DiagnosticsProperty<Matrix3>("transform matrix", this._transform));
properties.add(new DiagnosticsProperty<Matrix4>("transform matrix", this._transform));
properties.add(new DiagnosticsProperty<Offset>("origin", this.origin));
properties.add(new DiagnosticsProperty<Alignment>("alignment", this.alignment));
properties.add(new DiagnosticsProperty<bool>("transformHitTests", this.transformHitTests));

}
bool? _hasVisualOverflow;
Matrix3 _transform;
Matrix4 _transform;
void _clearPaintData() {
this._hasVisualOverflow = null;

if (this.child == null) {
this._hasVisualOverflow = false;
this._transform = Matrix3.I();
this._transform = new Matrix4().identity();
}
else {
this._resolve();

Rect sourceRect = this._resolvedAlignment.inscribe(sizes.source, Offset.zero & childSize);
Rect destinationRect = this._resolvedAlignment.inscribe(sizes.destination, Offset.zero & this.size);
this._hasVisualOverflow = sourceRect.width < childSize.width || sourceRect.height < childSize.height;
this._transform = Matrix3.makeTrans(destinationRect.left, destinationRect.top);
this._transform.postScale(scaleX, scaleY);
this._transform.postTranslate(-sourceRect.left, -sourceRect.top);
this._transform = new Matrix4().translationValues(destinationRect.left, destinationRect.top, 0);
this._transform.scale(scaleX, scaleY, 1);
this._transform.translate(-sourceRect.left, -sourceRect.top);
}
}

}
this._updatePaintData();
Matrix3 inverse = Matrix3.I();
if (!this._transform.invert(inverse)) {
Matrix4 inverse = Matrix4.tryInvert(this._transform);
if (inverse == null) {
position = inverse.mapPoint(position);
position = MatrixUtils.transformPoint(inverse, position);
public override void applyPaintTransform(RenderObject child, Matrix3 transform) {
public override void applyPaintTransform(RenderObject child, Matrix4 transform) {
transform.setAll(0, 0, 0, 0, 0, 0, 0, 0, 0);
transform.setZero();
transform.postConcat(this._transform);
transform.multiply(this._transform);
}
}

}
}
public override void applyPaintTransform(RenderObject child, Matrix3 transform) {
transform.preTranslate(this.translation.dx * this.size.width,
public override void applyPaintTransform(RenderObject child, Matrix4 transform) {
transform.translate(this.translation.dx * this.size.width,
this.translation.dy * this.size.height);
}

new FollowerLayer _layer;
Matrix3 getCurrentTransform() {
return this._layer?.getLastTransform() ?? Matrix3.I();
Matrix4 getCurrentTransform() {
return this._layer?.getLastTransform() ?? new Matrix4().identity();
}
public override bool hitTest(HitTestResult result, Offset position) {

protected override bool hitTestChildren(HitTestResult result, Offset position) {
Matrix3 inverse = Matrix3.I();
if (!this.getCurrentTransform().invert(inverse)) {
Matrix4 inverse = Matrix4.tryInvert(this.getCurrentTransform());
if (inverse == null) {
position = inverse.mapPoint(position);
position = MatrixUtils.transformPoint(inverse, position);
return base.hitTestChildren(result, position: position);
}

);
}
public override void applyPaintTransform(RenderObject child, Matrix3 transform) {
transform.preConcat(this.getCurrentTransform());
public override void applyPaintTransform(RenderObject child, Matrix4 transform) {
transform.multiply(this.getCurrentTransform());
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {

2
com.unity.uiwidgets/Runtime/rendering/proxy_box.mixin.gen.cs


return false;
}
public override void applyPaintTransform(RenderObject child, Matrix3 transform) {
public override void applyPaintTransform(RenderObject child, Matrix4 transform) {
}
public override void paint(PaintingContext context, Offset offset) {

23
com.unity.uiwidgets/Runtime/rendering/rotated_box.cs


using Unity.UIWidgets.foundation;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;
using UnityEngine;

return this._isVertical ? this.child.getMaxIntrinsicWidth(width) : this.child.getMaxIntrinsicHeight(width);
}
Matrix3 _paintTransform;
Matrix4 _paintTransform;
protected override void performLayout() {
this._paintTransform = null;

? new Size(this.child.size.height, this.child.size.width)
: this.child.size;
this._paintTransform = Matrix3.I();
this._paintTransform.preTranslate(this.size.width / 2.0f, this.size.height / 2.0f);
this._paintTransform.preRotate(RotatedBoxUtils._kQuarterTurnsInRadians * (this.quarterTurns % 4));
this._paintTransform.preTranslate(-this.child.size.width / 2.0f, -this.child.size.height / 2.0f);
this._paintTransform = new Matrix4().identity();
this._paintTransform.translate(this.size.width / 2.0f, this.size.height / 2.0f);
this._paintTransform.rotateZ(RotatedBoxUtils._kQuarterTurnsInRadians * (this.quarterTurns % 4));
this._paintTransform.translate(-this.child.size.width / 2.0f, -this.child.size.height / 2.0f);
}
else {
this.performResize();

if (this.child == null || this._paintTransform == null) {
return false;
}
Matrix3 inverse = Matrix3.I();
this._paintTransform.invert(inverse);
return this.child.hitTest(result, position: inverse.mapPoint(position));
var inverse = new Matrix4().inverted(this._paintTransform);
return this.child.hitTest(result, position:MatrixUtils.transformPoint(inverse, position));
}
void _paintChild(PaintingContext context, Offset offset) {

}
}
public override void applyPaintTransform(RenderObject child, Matrix3 transform) {
public override void applyPaintTransform(RenderObject child, Matrix4 transform) {
transform.preConcat(this._paintTransform);
transform.multiply(this._paintTransform);
}
base.applyPaintTransform(child, transform);

14
com.unity.uiwidgets/Runtime/rendering/sliver.cs


public class SliverPhysicalParentData : ParentData {
public Offset paintOffset = Offset.zero;
public void applyPaintTransform(Matrix3 transform) {
transform.preTranslate(this.paintOffset.dx, this.paintOffset.dy);
public void applyPaintTransform(Matrix4 transform) {
transform.translate(this.paintOffset.dx, this.paintOffset.dy);
}
public override string ToString() {

return 0.0f;
}
public override void applyPaintTransform(RenderObject child, Matrix3 transform) {
public override void applyPaintTransform(RenderObject child, Matrix4 transform) {
D.assert(() => { throw new UIWidgetsError(this.GetType() + " does not implement applyPaintTransform."); });
}

}
public static void applyPaintTransformForBoxChild(this RenderSliver it, RenderBox child,
Matrix3 transform) {
Matrix4 transform) {
bool rightWayUp = _getRightWayUp(it.constraints);
float delta = it.childMainAxisPosition(child);
float crossAxisDelta = it.childCrossAxisPosition(child);

delta = it.geometry.paintExtent - child.size.width - delta;
}
transform.preTranslate(delta, crossAxisDelta);
transform.translate(delta, crossAxisDelta);
break;
case Axis.vertical:
if (!rightWayUp) {

transform.preTranslate(crossAxisDelta, delta);
transform.translate(crossAxisDelta, delta);
break;
}
}

return -this.constraints.scrollOffset;
}
public override void applyPaintTransform(RenderObject child, Matrix3 transform) {
public override void applyPaintTransform(RenderObject child, Matrix4 transform) {
D.assert(child != null);
D.assert(child == this.child);

2
com.unity.uiwidgets/Runtime/rendering/sliver_multi_box_adaptor.cs


return childParentData.layoutOffset;
}
public override void applyPaintTransform(RenderObject child, Matrix3 transform) {
public override void applyPaintTransform(RenderObject child, Matrix4 transform) {
this.applyPaintTransformForBoxChild((RenderBox) child, transform);
}

2
com.unity.uiwidgets/Runtime/rendering/sliver_padding.cs


return this.beforePadding;
}
public override void applyPaintTransform(RenderObject child, Matrix3 transform) {
public override void applyPaintTransform(RenderObject child, Matrix4 transform) {
D.assert(child != null);
D.assert(child == this.child);

2
com.unity.uiwidgets/Runtime/rendering/sliver_persistent_header.cs


return false;
}
public override void applyPaintTransform(RenderObject child, Matrix3 transform) {
public override void applyPaintTransform(RenderObject child, Matrix4 transform) {
D.assert(child != null);
D.assert(child == this.child);
RenderSliverHelpers.applyPaintTransformForBoxChild(this, this.child, transform);

15
com.unity.uiwidgets/Runtime/rendering/view.cs


using Unity.UIWidgets.foundation;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.painting;
using Rect = Unity.UIWidgets.ui.Rect;
namespace Unity.UIWidgets.rendering {
public class ViewConfiguration {

public readonly float devicePixelRatio;
public Matrix3 toMatrix() {
return Matrix3.I();
public Matrix4 toMatrix() {
// return new Matrix4().diagonal3Values(this.devicePixelRatio, this.devicePixelRatio, 0);
return new Matrix4().identity();
}
public override string ToString() {

this.owner.requestVisualUpdate();
}
Matrix3 _rootTransform;
Matrix4 _rootTransform;
public Layer _updateMatricesAndCreateNewRootLayer() {
this._rootTransform = this.configuration.toMatrix();

}
}
public override void applyPaintTransform(RenderObject child, Matrix3 transform) {
transform.preConcat(this._rootTransform);
public override void applyPaintTransform(RenderObject child, Matrix4 transform) {
transform.multiply(this._rootTransform);
base.applyPaintTransform(child, transform);
}

public override Rect semanticBounds {
get {
D.assert(this._rootTransform != null);
return this._rootTransform.mapRect(Offset.zero & this.size);
return MatrixUtils.transformRect(this._rootTransform, Offset.zero & this.size);
}
}

14
com.unity.uiwidgets/Runtime/rendering/viewport.cs


float targetMainAxisExtent = 0.0f;
rect = rect ?? target.paintBounds;
Matrix3 transform;
Matrix4 transform;
RenderObject child = target;
RenderBox pivot = null;

RenderSliver pivotParent = (RenderSliver) pivot.parent;
transform = target.getTransformTo(pivot);
Rect bounds = transform.mapRect(rect);
Rect bounds = MatrixUtils.transformRect(transform, rect);
float offset = 0.0f;

transform = target.getTransformTo(this);
this.applyPaintTransform(child, transform);
Rect targetRect = transform.mapRect(rect);
Rect targetRect = MatrixUtils.transformRect(transform, rect);
switch (this.axisDirection) {
case AxisDirection.down:

}
else {
var transform = descendant.getTransformTo(viewport.parent);
return transform.mapRect(rect ?? descendant.paintBounds);
return MatrixUtils.transformRect(transform, rect ?? descendant.paintBounds);
}
D.assert(targetOffset != null);

return 0.0f;
}
public override void applyPaintTransform(RenderObject child, Matrix3 transform) {
public override void applyPaintTransform(RenderObject child, Matrix4 transform) {
D.assert(child != null);
var childParentData = (SliverPhysicalParentData) child.parentData;

return pinnedExtent;
}
public override void applyPaintTransform(RenderObject child, Matrix3 transform) {
public override void applyPaintTransform(RenderObject child, Matrix4 transform) {
transform.preTranslate(offset.dx, offset.dy);
transform.translate(offset.dx, offset.dy);
}
protected override float computeChildMainAxisPosition(RenderSliver child, float parentMainAxisPosition) {

12
com.unity.uiwidgets/Runtime/widgets/basic.cs


public class Transform : SingleChildRenderObjectWidget {
public Transform(
Key key = null,
Matrix3 transform = null,
Matrix4 transform = null,
Offset origin = null,
Alignment alignment = null,
bool transformHitTests = true,

this.transform = new Matrix3(transform);
this.transform = new Matrix4(transform);
this.origin = origin;
this.alignment = alignment;
this.transformHitTests = transformHitTests;

Widget child = null,
float degree = 0.0f
) : base(key: key, child: child) {
this.transform = Matrix3.makeRotate(degree);
this.transform = new Matrix4().rotationZ(degree);
this.origin = origin;
this.alignment = alignment;
this.transformHitTests = transformHitTests;

Widget child = null
) : base(key: key, child: child) {
D.assert(offset != null);
this.transform = Matrix3.makeTrans(offset.dx, offset.dy);
this.transform = new Matrix4().translationValues(offset.dx, offset.dy, 0);
this.origin = null;
this.alignment = null;
this.transformHitTests = transformHitTests;

bool transformHitTests = true,
Widget child = null
) : base(key: key, child: child) {
this.transform = Matrix3.makeScale(scale, scale);
this.transform = new Matrix4().translationValues(scale, scale, scale);
this.origin = origin;
this.alignment = alignment;
this.transformHitTests = transformHitTests;

return new Transform(key, scale, origin, alignment, transformHitTests, child);
}
public readonly Matrix3 transform;
public readonly Matrix4 transform;
public readonly Offset origin;
public readonly Alignment alignment;
public readonly bool transformHitTests;

8
com.unity.uiwidgets/Runtime/widgets/container.cs


float? height = null,
BoxConstraints constraints = null,
EdgeInsets margin = null,
Matrix3 transfrom = null,
Matrix4 transfrom = null,
Widget child = null
) : base(key) {
D.assert(margin == null || margin.isNonNegative);

public readonly Decoration foregroundDecoration;
public readonly BoxConstraints constraints;
public readonly EdgeInsets margin;
public readonly Matrix3 transform;
public readonly Matrix4 transform;
EdgeInsets _paddingIncludingDecoration {
get {

}
if (this.transform != null) {
current = new Transform(transform: new Matrix3(this.transform), child: current);
current = new Transform(transform: new Matrix4(this.transform), child: current);
}
return current;

this.constraints, defaultValue: Diagnostics.kNullDefaultValue));
properties.add(new DiagnosticsProperty<EdgeInsets>("margin",
this.margin, defaultValue: Diagnostics.kNullDefaultValue));
properties.add(ObjectFlagProperty<Matrix3>.has("transform",
properties.add(ObjectFlagProperty<Matrix4>.has("transform",
this.transform));
}
}

3
com.unity.uiwidgets/Runtime/widgets/heroes.cs


using System.Collections.Generic;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;

public static Rect _globalBoundingBoxFor(BuildContext context) {
RenderBox box = (RenderBox) context.findRenderObject();
D.assert(box != null && box.hasSize);
return box.getTransformTo(null).mapRect(Offset.zero & box.size);
return MatrixUtils.transformRect( box.getTransformTo(null), Offset.zero & box.size);
}
}

46
com.unity.uiwidgets/Runtime/widgets/implicit_animations.cs


using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;
using UnityEngine;
using Color = Unity.UIWidgets.ui.Color;
using Rect = Unity.UIWidgets.ui.Rect;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
namespace Unity.UIWidgets.widgets {

}
public class Matrix3Tween : Tween<Matrix3> {
public Matrix3Tween(
Matrix3 begin = null,
Matrix3 end = null) : base(begin: begin, end: end) {
public class Matrix4Tween : Tween<Matrix4> {
public Matrix4Tween(
Matrix4 begin = null,
Matrix4 end = null) : base(begin: begin, end: end) {
//todo:xingwei.zhu implement full matrix3 lerp
public override Matrix3 lerp(float t) {
public override Matrix4 lerp(float t) {
return t < 0.5 ? this.begin : this.end;
Vector3 beginTranslation = Vector3.zero;
Vector3 endTranslation = Vector3.zero;
Quaternion beginRotation = Quaternion.identity;
Quaternion endRotation = Quaternion.identity;
Vector3 beginScale = Vector3.zero;
Vector3 endScale = Vector3.zero;
this.begin.decompose(ref beginTranslation, ref beginRotation, ref beginScale);
this.end.decompose(ref endTranslation, ref endRotation, ref endScale);
Vector3 lerpTranslation =
beginTranslation * (1.0f - t) + endTranslation * t;
// TODO(alangardner): Implement slerp for constant rotation
Quaternion lerpRotation =
beginRotation
.scaled(1.0f - t)
.add(endRotation.scaled(t)).normalized;
Vector3 lerpScale = beginScale * (1.0f - t) + endScale * t;
return new Matrix4().compose(lerpTranslation, lerpRotation, lerpScale);
}
}

float? height = null,
BoxConstraints constraints = null,
EdgeInsets margin = null,
Matrix3 transform = null,
Matrix4 transform = null,
Widget child = null,
Curve curve = null,
TimeSpan? duration = null

public readonly EdgeInsets margin;
public readonly Matrix3 transform;
public readonly Matrix4 transform;
public override State createState() {

defaultValue: null,
showName: false));
properties.add(new DiagnosticsProperty<EdgeInsets>("margin", this.margin, defaultValue: null));
properties.add(ObjectFlagProperty<Matrix3>.has("transform", this.transform));
properties.add(ObjectFlagProperty<Matrix4>.has("transform", this.transform));
}
}

DecorationTween _foregroundDecoration;
BoxConstraintsTween _constraints;
EdgeInsetsTween _margin;
Matrix3Tween _transform;
Matrix4Tween _transform;
protected override void forEachTween(TweenVisitor visitor) {

(BoxConstraints value) => new BoxConstraintsTween(begin: value));
this._margin = (EdgeInsetsTween) visitor.visit(this, this._margin, this.widget.margin,
(EdgeInsets value) => new EdgeInsetsTween(begin: value));
this._transform = (Matrix3Tween) visitor.visit(this, this._transform, this.widget.transform,
(Matrix3 value) => new Matrix3Tween(begin: value));
this._transform = (Matrix4Tween) visitor.visit(this, this._transform, this.widget.transform,
(Matrix4 value) => new Matrix4Tween(begin: value));
}

description.add(new DiagnosticsProperty<BoxConstraintsTween>("constraints", this._constraints,
showName: false, defaultValue: null));
description.add(new DiagnosticsProperty<EdgeInsetsTween>("margin", this._margin, defaultValue: null));
description.add(ObjectFlagProperty<Matrix3Tween>.has("transform", this._transform));
description.add(ObjectFlagProperty<Matrix4Tween>.has("transform", this._transform));
}
}

2
com.unity.uiwidgets/Runtime/widgets/nested_scroll_view.cs


childLayoutGeometry.maxScrollObstructionExtent);
}
public override void applyPaintTransform(RenderObject child, Matrix3 transform) {
public override void applyPaintTransform(RenderObject child, Matrix4 transform) {
}
protected override bool hitTestChildren(

8
com.unity.uiwidgets/Runtime/widgets/single_child_scroll_view.cs


}
}
public override void applyPaintTransform(RenderObject child, Matrix3 transform) {
public override void applyPaintTransform(RenderObject child, Matrix4 transform) {
transform.preTranslate(paintOffset.dx, paintOffset.dy);
transform.translate(paintOffset.dx, paintOffset.dy);
}
public override Rect describeApproximatePaintClip(RenderObject child) {

}
RenderBox targetBox = (RenderBox) target;
Matrix3 transform = targetBox.getTransformTo(this);
Rect bounds = transform.mapRect(rect);
Matrix4 transform = targetBox.getTransformTo(this);
Rect bounds = MatrixUtils.transformRect(transform, rect);
Size contentSize = this.child.size;
float leadingScrollOffset = 0.0f;

4
com.unity.uiwidgets/Runtime/widgets/transitions.cs


protected internal override Widget build(BuildContext context) {
float scaleValue = this.scale.value;
Matrix3 transform = Matrix3.makeScale(scaleValue, scaleValue);
Matrix4 transform = new Matrix4().diagonal3Values(scaleValue, scaleValue, 1);
return new Transform(
transform: transform,
alignment: this.alignment,

protected internal override Widget build(BuildContext context) {
float turnsValue = this.turns.value;
Matrix3 transform = Matrix3.makeRotate((turnsValue * Mathf.PI * 2.0f));
Matrix4 transform = new Matrix4().rotationZ((turnsValue * Mathf.PI * 2.0f));
return new Transform(
transform: transform,
alignment: this.alignment,

19
com.unity.uiwidgets/Runtime/widgets/widget_inspector.cs


using RSG;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.scheduler;
using Unity.UIWidgets.ui;

List<RenderObject> edgeHits,
Offset position,
RenderObject renderObject,
Matrix3 transform
Matrix4 transform
var inverse = Matrix3.I();
var invertible = transform.invert(inverse);
if (!invertible) {
var inverse = new Matrix4().inverted(transform);
if (inverse == null) {
var localPosition = inverse.mapPoint(position);
var localPosition = MatrixUtils.transformPoint(inverse, position);
List<DiagnosticsNode> children = renderObject.debugDescribeChildren();
for (int i = children.Count - 1; i >= 0; --i) {

continue;
}
var childTransform = new Matrix3(transform);
var childTransform = new Matrix4(transform);
renderObject.applyPaintTransform(child, childTransform);
if (this._hitTestHelper(hits, edgeHits, position, child, childTransform)) {
hit = true;

class _TransformedRect : IEquatable<_TransformedRect> {
public readonly Rect rect;
public readonly Matrix3 transform;
public readonly Matrix4 transform;
public _TransformedRect(RenderObject obj) {
this.rect = obj.semanticBounds;

};
Rect selectedPaintRect = state.selected.rect.deflate(0.5f);
canvas.save();
canvas.setMatrix(state.selected.transform);
canvas.setMatrix(state.selected.transform.toMatrix3());
canvas.drawRect(selectedPaintRect, fillPaint);
canvas.drawRect(selectedPaintRect, borderPaint);
canvas.restore();

canvas.setMatrix(transformedRect.transform);
canvas.setMatrix(transformedRect.transform.toMatrix3());
canvas.drawRect(transformedRect.rect.deflate(0.5f), borderPaint);
canvas.restore();
}

858
com.unity.uiwidgets/Runtime/ui/Matrix4.cs


using System;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.painting;
using UnityEngine;
namespace Unity.UIWidgets.ui {
public class Matrix4 : IEquatable<Matrix4> {
internal readonly float[] _m4storage;
int dimension {
get { return 4; }
}
public Matrix4() {
this._m4storage = new float[16];
}
public Matrix4(Matrix4 other) {
this._m4storage = new float[16];
this.setFrom(other);
}
public static Matrix4 tryInvert(Matrix4 other) {
Matrix4 r = new Matrix4();
float determinant = r.copyInverse(other);
if (determinant == 0) {
return null;
}
return r;
}
public Matrix4(
float arg0,
float arg1,
float arg2,
float arg3,
float arg4,
float arg5,
float arg6,
float arg7,
float arg8,
float arg9,
float arg10,
float arg11,
float arg12,
float arg13,
float arg14,
float arg15) {
this._m4storage = new float[16];
this.setValues(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9,
arg10, arg11, arg12, arg13, arg14, arg15);
}
public Matrix4 fromList(
float arg0,
float arg1,
float arg2,
float arg3,
float arg4,
float arg5,
float arg6,
float arg7,
float arg8,
float arg9,
float arg10,
float arg11,
float arg12,
float arg13,
float arg14,
float arg15) {
this.setValues(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9,
arg10, arg11, arg12, arg13, arg14, arg15);
return this;
}
public Matrix4 identity() {
this.setIdentity();
return this;
}
public Matrix4 inverted(Matrix4 other) {
double determinant = this.copyInverse(other);
if (determinant == 0) {
// throw new Exception("input matrix cannot be inverted");
return null;
}
return this;
}
public Matrix4 copy(Matrix4 other) {
this.setFrom(other);
return this;
}
public Matrix4 compose(Vector3 translation, Quaternion rotation, Vector3 scale) {
this.setFromTranslationRotationScale(translation, rotation, scale);
return this;
}
public Matrix4 clone() => new Matrix4().copy(this);
public static Matrix4 operator *(Matrix4 a, Matrix4 b) {
var result = a.clone();
result.multiply(b);
return result;
}
void setFromTranslationRotationScale(
Vector3 translation, Quaternion rotation, Vector3 scale) {
this.setFromTranslationRotation(translation, rotation);
this.scale(scale);
}
void setFromTranslationRotation(Vector3 arg0, Quaternion arg1) {
float x = arg1[0];
float y = arg1[1];
float z = arg1[2];
float w = arg1[3];
float x2 = x + x;
float y2 = y + y;
float z2 = z + z;
float xx = x * x2;
float xy = x * y2;
float xz = x * z2;
float yy = y * y2;
float yz = y * z2;
float zz = z * z2;
float wx = w * x2;
float wy = w * y2;
float wz = w * z2;
this._m4storage[0] = 1.0f - (yy + zz);
this._m4storage[1] = xy + wz;
this._m4storage[2] = xz - wy;
this._m4storage[3] = 0;
this._m4storage[4] = xy - wz;
this._m4storage[5] = 1.0f - (xx + zz);
this._m4storage[6] = yz + wx;
this._m4storage[7] = 0;
this._m4storage[8] = xz + wy;
this._m4storage[9] = yz - wx;
this._m4storage[10] = 1.0f - (xx + yy);
this._m4storage[11] = 0;
this._m4storage[12] = arg0[0];
this._m4storage[13] = arg0[1];
this._m4storage[14] = arg0[2];
this._m4storage[15] = 1.0f;
}
void setFrom(Matrix4 arg) {
this._m4storage[15] = arg[15];
this._m4storage[14] = arg[14];
this._m4storage[13] = arg[13];
this._m4storage[12] = arg[12];
this._m4storage[11] = arg[11];
this._m4storage[10] = arg[10];
this._m4storage[9] = arg[9];
this._m4storage[8] = arg[8];
this._m4storage[7] = arg[7];
this._m4storage[6] = arg[6];
this._m4storage[5] = arg[5];
this._m4storage[4] = arg[4];
this._m4storage[3] = arg[3];
this._m4storage[2] = arg[2];
this._m4storage[1] = arg[1];
this._m4storage[0] = arg[0];
}
void setValues(
float arg0,
float arg1,
float arg2,
float arg3,
float arg4,
float arg5,
float arg6,
float arg7,
float arg8,
float arg9,
float arg10,
float arg11,
float arg12,
float arg13,
float arg14,
float arg15) {
this._m4storage[15] = arg15;
this._m4storage[14] = arg14;
this._m4storage[13] = arg13;
this._m4storage[12] = arg12;
this._m4storage[11] = arg11;
this._m4storage[10] = arg10;
this._m4storage[9] = arg9;
this._m4storage[8] = arg8;
this._m4storage[7] = arg7;
this._m4storage[6] = arg6;
this._m4storage[5] = arg5;
this._m4storage[4] = arg4;
this._m4storage[3] = arg3;
this._m4storage[2] = arg2;
this._m4storage[1] = arg1;
this._m4storage[0] = arg0;
}
public void setZero() {
this._m4storage[0] = 0;
this._m4storage[1] = 0;
this._m4storage[2] = 0;
this._m4storage[3] = 0;
this._m4storage[4] = 0;
this._m4storage[5] = 0;
this._m4storage[6] = 0;
this._m4storage[7] = 0;
this._m4storage[8] = 0;
this._m4storage[9] = 0;
this._m4storage[10] = 0;
this._m4storage[11] = 0;
this._m4storage[12] = 0;
this._m4storage[13] = 0;
this._m4storage[14] = 0;
this._m4storage[15] = 0;
}
void setIdentity() {
this._m4storage[0] = 1;
this._m4storage[1] = 0;
this._m4storage[2] = 0;
this._m4storage[3] = 0;
this._m4storage[4] = 0;
this._m4storage[5] = 1;
this._m4storage[6] = 0;
this._m4storage[7] = 0;
this._m4storage[8] = 0;
this._m4storage[9] = 0;
this._m4storage[10] = 1;
this._m4storage[11] = 0;
this._m4storage[12] = 0;
this._m4storage[13] = 0;
this._m4storage[14] = 0;
this._m4storage[15] = 1;
}
Matrix4 absolute() {
Matrix4 r = new Matrix4();
this[0] = this._m4storage[0].abs();
this[1] = this._m4storage[1].abs();
this[2] = this._m4storage[2].abs();
this[3] = this._m4storage[3].abs();
this[4] = this._m4storage[4].abs();
this[5] = this._m4storage[5].abs();
this[6] = this._m4storage[6].abs();
this[7] = this._m4storage[7].abs();
this[8] = this._m4storage[8].abs();
this[9] = this._m4storage[9].abs();
this[10] = this._m4storage[10].abs();
this[11] = this._m4storage[11].abs();
this[12] = this._m4storage[12].abs();
this[13] = this._m4storage[13].abs();
this[14] = this._m4storage[14].abs();
this[15] = this._m4storage[15].abs();
return r;
}
public float determinant() {
float det2_01_01 =
this._m4storage[0] * this._m4storage[5] - this._m4storage[1] * this._m4storage[4];
float det2_01_02 =
this._m4storage[0] * this._m4storage[6] - this._m4storage[2] * this._m4storage[4];
float det2_01_03 =
this._m4storage[0] * this._m4storage[7] - this._m4storage[3] * this._m4storage[4];
float det2_01_12 =
this._m4storage[1] * this._m4storage[6] - this._m4storage[2] * this._m4storage[5];
float det2_01_13 =
this._m4storage[1] * this._m4storage[7] - this._m4storage[3] * this._m4storage[5];
float det2_01_23 =
this._m4storage[2] * this._m4storage[7] - this._m4storage[3] * this._m4storage[6];
float det3_201_012 = this._m4storage[8] * det2_01_12 -
this._m4storage[9] * det2_01_02 +
this._m4storage[10] * det2_01_01;
float det3_201_013 = this._m4storage[8] * det2_01_13 -
this._m4storage[9] * det2_01_03 +
this._m4storage[11] * det2_01_01;
float det3_201_023 = this._m4storage[8] * det2_01_23 -
this._m4storage[10] * det2_01_03 +
this._m4storage[11] * det2_01_02;
float det3_201_123 = this._m4storage[9] * det2_01_23 -
this._m4storage[10] * det2_01_13 +
this._m4storage[11] * det2_01_12;
return -det3_201_123 * this._m4storage[12] +
det3_201_023 * this._m4storage[13] -
det3_201_013 * this._m4storage[14] +
det3_201_012 * this._m4storage[15];
}
float invertRotation() {
float det = this.determinant();
if (det == 0) {
return 0;
}
float invDet = 1.0f / det;
float ix;
float iy;
float iz;
float jx;
float jy;
float jz;
float kx;
float ky;
float kz;
ix = invDet *
(this._m4storage[5] * this._m4storage[10] - this._m4storage[6] * this._m4storage[9]);
iy = invDet *
(this._m4storage[2] * this._m4storage[9] - this._m4storage[1] * this._m4storage[10]);
iz = invDet *
(this._m4storage[1] * this._m4storage[6] - this._m4storage[2] * this._m4storage[5]);
jx = invDet *
(this._m4storage[6] * this._m4storage[8] - this._m4storage[4] * this._m4storage[10]);
jy = invDet *
(this._m4storage[0] * this._m4storage[10] - this._m4storage[2] * this._m4storage[8]);
jz = invDet *
(this._m4storage[2] * this._m4storage[4] - this._m4storage[0] * this._m4storage[6]);
kx = invDet *
(this._m4storage[4] * this._m4storage[9] - this._m4storage[5] * this._m4storage[8]);
ky = invDet *
(this._m4storage[1] * this._m4storage[8] - this._m4storage[0] * this._m4storage[9]);
kz = invDet *
(this._m4storage[0] * this._m4storage[5] - this._m4storage[1] * this._m4storage[4]);
this._m4storage[0] = ix;
this._m4storage[1] = iy;
this._m4storage[2] = iz;
this._m4storage[4] = jx;
this._m4storage[5] = jy;
this._m4storage[6] = jz;
this._m4storage[8] = kx;
this._m4storage[9] = ky;
this._m4storage[10] = kz;
return det;
}
public Vector4 transform(Vector4 arg) {
float x_ = (this._m4storage[0] * arg[0]) +
(this._m4storage[4] * arg[1]) +
(this._m4storage[8] * arg[2]) +
(this._m4storage[12] * arg[3]);
float y_ = (this._m4storage[1] * arg[0]) +
(this._m4storage[5] * arg[1]) +
(this._m4storage[9] * arg[2]) +
(this._m4storage[13] * arg[3]);
float z_ = (this._m4storage[2] * arg[0]) +
(this._m4storage[6] * arg[1]) +
(this._m4storage[10] * arg[2]) +
(this._m4storage[14] * arg[3]);
float w_ = (this._m4storage[3] * arg[0]) +
(this._m4storage[7] * arg[1]) +
(this._m4storage[11] * arg[2]) +
(this._m4storage[15] * arg[3]);
arg[0] = x_;
arg[1] = y_;
arg[2] = z_;
arg[3] = w_;
return arg;
}
public Vector3 perspectiveTransform(Vector3 arg) {
float x_ = (this._m4storage[0] * arg[0]) +
(this._m4storage[4] * arg[1]) +
(this._m4storage[8] * arg[2]) +
this._m4storage[12];
float y_ = (this._m4storage[1] * arg[0]) +
(this._m4storage[5] * arg[1]) +
(this._m4storage[9] * arg[2]) +
this._m4storage[13];
float z_ = (this._m4storage[2] * arg[0]) +
(this._m4storage[6] * arg[1]) +
(this._m4storage[10] * arg[2]) +
this._m4storage[14];
float w_ = 1.0f /
((this._m4storage[3] * arg[0]) +
(this._m4storage[7] * arg[1]) +
(this._m4storage[11] * arg[2]) +
this._m4storage[15]);
arg[0] = x_ * w_;
arg[1] = y_ * w_;
arg[2] = z_ * w_;
return arg;
}
public void translate(float tx, float ty = 0, float tz = 0, float tw = 1) {
float t1 = this._m4storage[0] * tx +
this._m4storage[4] * ty +
this._m4storage[8] * tz +
this._m4storage[12] * tw;
float t2 = this._m4storage[1] * tx +
this._m4storage[5] * ty +
this._m4storage[9] * tz +
this._m4storage[13] * tw;
float t3 = this._m4storage[2] * tx +
this._m4storage[6] * ty +
this._m4storage[10] * tz +
this._m4storage[14] * tw;
float t4 = this._m4storage[3] * tx +
this._m4storage[7] * ty +
this._m4storage[11] * tz +
this._m4storage[15] * tw;
this._m4storage[12] = t1;
this._m4storage[13] = t2;
this._m4storage[14] = t3;
this._m4storage[15] = t4;
}
public Matrix4 rotationX(float radians) {
this._m4storage[15] = 1.0f;
this.setRotationX(radians);
return this;
}
public Matrix4 rotationY(float radians) {
this._m4storage[15] = 1.0f;
this.setRotationY(radians);
return this;
}
public Matrix4 rotationZ(float radians) {
this._m4storage[15] = 1.0f;
this.setRotationZ(radians);
return this;
}
public Matrix4 rotationZ(float radians, float px, float py) {
this._m4storage[15] = 1.0f;
this.setRotationZ(radians, px, py);
return this;
}
public Matrix4 diagonal3Values(float x, float y, float z) {
this._m4storage[15] = 1;
this._m4storage[10] = z;
this._m4storage[5] = y;
this._m4storage[0] = x;
return this;
}
public void scale(float sx, float sy, float sz, float sw = 1) {
this._m4storage[0] *= sx;
this._m4storage[1] *= sx;
this._m4storage[2] *= sx;
this._m4storage[3] *= sx;
this._m4storage[4] *= sy;
this._m4storage[5] *= sy;
this._m4storage[6] *= sy;
this._m4storage[7] *= sy;
this._m4storage[8] *= sz;
this._m4storage[9] *= sz;
this._m4storage[10] *= sz;
this._m4storage[11] *= sz;
this._m4storage[12] *= sw;
this._m4storage[13] *= sw;
this._m4storage[14] *= sw;
this._m4storage[15] *= sw;
}
public void scale(Vector3 s) {
float sx = s.x;
float sy = s.y;
float sz = s.z;
float sw = 1;
this._m4storage[0] *= sx;
this._m4storage[1] *= sx;
this._m4storage[2] *= sx;
this._m4storage[3] *= sx;
this._m4storage[4] *= sy;
this._m4storage[5] *= sy;
this._m4storage[6] *= sy;
this._m4storage[7] *= sy;
this._m4storage[8] *= sz;
this._m4storage[9] *= sz;
this._m4storage[10] *= sz;
this._m4storage[11] *= sz;
this._m4storage[12] *= sw;
this._m4storage[13] *= sw;
this._m4storage[14] *= sw;
this._m4storage[15] *= sw;
}
Matrix4 scaled(float sx, float sy, float sz, float sw = 1) {
var result = this.clone();
result.scale(sx, sy, sz, sw);
return result;
}
public Matrix4 translationValues(float x, float y, float z) {
this.identity();
this.setTranslationRaw(x, y, z);
return this;
}
public void rotateX(float angle) {
float cosAngle = Mathf.Cos(angle);
float sinAngle = Mathf.Sin(angle);
float t1 = this._m4storage[4] * cosAngle + this._m4storage[8] * sinAngle;
float t2 = this._m4storage[5] * cosAngle + this._m4storage[9] * sinAngle;
float t3 = this._m4storage[6] * cosAngle + this._m4storage[10] * sinAngle;
float t4 = this._m4storage[7] * cosAngle + this._m4storage[11] * sinAngle;
float t5 = this._m4storage[4] * -sinAngle + this._m4storage[8] * cosAngle;
float t6 = this._m4storage[5] * -sinAngle + this._m4storage[9] * cosAngle;
float t7 = this._m4storage[6] * -sinAngle + this._m4storage[10] * cosAngle;
float t8 = this._m4storage[7] * -sinAngle + this._m4storage[11] * cosAngle;
this._m4storage[4] = t1;
this._m4storage[5] = t2;
this._m4storage[6] = t3;
this._m4storage[7] = t4;
this._m4storage[8] = t5;
this._m4storage[9] = t6;
this._m4storage[10] = t7;
this._m4storage[11] = t8;
}
public void rotateY(float angle) {
float cosAngle = Mathf.Cos(angle);
float sinAngle = Mathf.Sin(angle);
float t1 = this._m4storage[0] * cosAngle + this._m4storage[8] * -sinAngle;
float t2 = this._m4storage[1] * cosAngle + this._m4storage[9] * -sinAngle;
float t3 = this._m4storage[2] * cosAngle + this._m4storage[10] * -sinAngle;
float t4 = this._m4storage[3] * cosAngle + this._m4storage[11] * -sinAngle;
float t5 = this._m4storage[0] * sinAngle + this._m4storage[8] * cosAngle;
float t6 = this._m4storage[1] * sinAngle + this._m4storage[9] * cosAngle;
float t7 = this._m4storage[2] * sinAngle + this._m4storage[10] * cosAngle;
float t8 = this._m4storage[3] * sinAngle + this._m4storage[11] * cosAngle;
this._m4storage[0] = t1;
this._m4storage[1] = t2;
this._m4storage[2] = t3;
this._m4storage[3] = t4;
this._m4storage[8] = t5;
this._m4storage[9] = t6;
this._m4storage[10] = t7;
this._m4storage[11] = t8;
}
public void rotateZ(float angle) {
float cosAngle = Mathf.Cos(angle);
float sinAngle = Mathf.Sin(angle);
float t1 = this._m4storage[0] * cosAngle + this._m4storage[4] * sinAngle;
float t2 = this._m4storage[1] * cosAngle + this._m4storage[5] * sinAngle;
float t3 = this._m4storage[2] * cosAngle + this._m4storage[6] * sinAngle;
float t4 = this._m4storage[3] * cosAngle + this._m4storage[7] * sinAngle;
float t5 = this._m4storage[0] * -sinAngle + this._m4storage[4] * cosAngle;
float t6 = this._m4storage[1] * -sinAngle + this._m4storage[5] * cosAngle;
float t7 = this._m4storage[2] * -sinAngle + this._m4storage[6] * cosAngle;
float t8 = this._m4storage[3] * -sinAngle + this._m4storage[7] * cosAngle;
this._m4storage[0] = t1;
this._m4storage[1] = t2;
this._m4storage[2] = t3;
this._m4storage[3] = t4;
this._m4storage[4] = t5;
this._m4storage[5] = t6;
this._m4storage[6] = t7;
this._m4storage[7] = t8;
}
public void multiply(Matrix4 arg) {
float m00 = this._m4storage[0];
float m01 = this._m4storage[4];
float m02 = this._m4storage[8];
float m03 = this._m4storage[12];
float m10 = this._m4storage[1];
float m11 = this._m4storage[5];
float m12 = this._m4storage[9];
float m13 = this._m4storage[13];
float m20 = this._m4storage[2];
float m21 = this._m4storage[6];
float m22 = this._m4storage[10];
float m23 = this._m4storage[14];
float m30 = this._m4storage[3];
float m31 = this._m4storage[7];
float m32 = this._m4storage[11];
float m33 = this._m4storage[15];
float[] argStorage = arg._m4storage;
float n00 = argStorage[0];
float n01 = argStorage[4];
float n02 = argStorage[8];
float n03 = argStorage[12];
float n10 = argStorage[1];
float n11 = argStorage[5];
float n12 = argStorage[9];
float n13 = argStorage[13];
float n20 = argStorage[2];
float n21 = argStorage[6];
float n22 = argStorage[10];
float n23 = argStorage[14];
float n30 = argStorage[3];
float n31 = argStorage[7];
float n32 = argStorage[11];
float n33 = argStorage[15];
this._m4storage[0] = (m00 * n00) + (m01 * n10) + (m02 * n20) + (m03 * n30);
this._m4storage[4] = (m00 * n01) + (m01 * n11) + (m02 * n21) + (m03 * n31);
this._m4storage[8] = (m00 * n02) + (m01 * n12) + (m02 * n22) + (m03 * n32);
this._m4storage[12] = (m00 * n03) + (m01 * n13) + (m02 * n23) + (m03 * n33);
this._m4storage[1] = (m10 * n00) + (m11 * n10) + (m12 * n20) + (m13 * n30);
this._m4storage[5] = (m10 * n01) + (m11 * n11) + (m12 * n21) + (m13 * n31);
this._m4storage[9] = (m10 * n02) + (m11 * n12) + (m12 * n22) + (m13 * n32);
this._m4storage[13] = (m10 * n03) + (m11 * n13) + (m12 * n23) + (m13 * n33);
this._m4storage[2] = (m20 * n00) + (m21 * n10) + (m22 * n20) + (m23 * n30);
this._m4storage[6] = (m20 * n01) + (m21 * n11) + (m22 * n21) + (m23 * n31);
this._m4storage[10] = (m20 * n02) + (m21 * n12) + (m22 * n22) + (m23 * n32);
this._m4storage[14] = (m20 * n03) + (m21 * n13) + (m22 * n23) + (m23 * n33);
this._m4storage[3] = (m30 * n00) + (m31 * n10) + (m32 * n20) + (m33 * n30);
this._m4storage[7] = (m30 * n01) + (m31 * n11) + (m32 * n21) + (m33 * n31);
this._m4storage[11] = (m30 * n02) + (m31 * n12) + (m32 * n22) + (m33 * n32);
this._m4storage[15] = (m30 * n03) + (m31 * n13) + (m32 * n23) + (m33 * n33);
}
public void decompose(ref Vector3 translation, ref Quaternion rotation, ref Vector3 scale) {
Vector3 v = Vector3.zero;
v.Set(this._m4storage[0], this._m4storage[1], this._m4storage[2]);
float sx = v.sqrMagnitude;
v.Set(this._m4storage[4], this._m4storage[5], this._m4storage[6]);
float sy = v.sqrMagnitude;
v.Set(this._m4storage[8], this._m4storage[9], this._m4storage[10]);
float sz = v.sqrMagnitude;
if (this.determinant() < 0) {
sx = -sx;
}
translation[0] = this._m4storage[12];
translation[1] = this._m4storage[13];
translation[2] = this._m4storage[14];
float invSX = 1.0f / sx;
float invSY = 1.0f / sy;
float invSZ = 1.0f / sz;
Matrix4 m = new Matrix4().copy(this);
m._m4storage[0] *= invSX;
m._m4storage[1] *= invSX;
m._m4storage[2] *= invSX;
m._m4storage[4] *= invSY;
m._m4storage[5] *= invSY;
m._m4storage[6] *= invSY;
m._m4storage[8] *= invSZ;
m._m4storage[9] *= invSZ;
m._m4storage[10] *= invSZ;
m.QuaternionFromMatrix(ref rotation);
scale[0] = sx;
scale[1] = sy;
scale[2] = sz;
}
void setTranslationRaw(float x, float y, float z) {
this._m4storage[14] = z;
this._m4storage[13] = y;
this._m4storage[12] = x;
}
void setRotationX(float radians) {
float c = Mathf.Cos(radians);
float s = Mathf.Sin(radians);
this._m4storage[0] = 1.0f;
this._m4storage[1] = 0;
this._m4storage[2] = 0;
this._m4storage[4] = 0;
this._m4storage[5] = c;
this._m4storage[6] = s;
this._m4storage[8] = 0;
this._m4storage[9] = -s;
this._m4storage[10] = c;
this._m4storage[3] = 0;
this._m4storage[7] = 0;
this._m4storage[11] = 0;
}
void setRotationY(float radians) {
float c = Mathf.Cos(radians);
float s = Mathf.Sin(radians);
this._m4storage[0] = c;
this._m4storage[1] = 0;
this._m4storage[2] = -s;
this._m4storage[4] = 0;
this._m4storage[5] = 1.0f;
this._m4storage[6] = 0;
this._m4storage[8] = s;
this._m4storage[9] = 0;
this._m4storage[10] = c;
this._m4storage[3] = 0;
this._m4storage[7] = 0;
this._m4storage[11] = 0;
}
void setRotationZ(float radians) {
float c = Mathf.Cos(radians);
float s = Mathf.Sin(radians);
this._m4storage[0] = c;
this._m4storage[1] = s;
this._m4storage[2] = 0;
this._m4storage[4] = -s;
this._m4storage[5] = c;
this._m4storage[6] = 0;
this._m4storage[8] = 0;
this._m4storage[9] = 0;
this._m4storage[10] = 1.0f;
this._m4storage[3] = 0;
this._m4storage[7] = 0;
this._m4storage[11] = 0;
}
void setRotationZ(float radians, float px, float py) {
float c = Mathf.Cos(radians);
float s = Mathf.Sin(radians);
this._m4storage[0] = c;
this._m4storage[1] = s;
this._m4storage[2] = 0;
this._m4storage[4] = -s;
this._m4storage[5] = c;
this._m4storage[6] = 0;
this._m4storage[8] = 0;
this._m4storage[9] = 0;
this._m4storage[10] = 1.0f;
this._m4storage[3] = 0;
this._m4storage[7] = 0;
this._m4storage[11] = 0;
this._m4storage[12] = s * py + (1 - c) * px;
this._m4storage[13] = -s * px + (1 - c) * py;
}
public float invert() => this.copyInverse(this);
float copyInverse(Matrix4 arg) {
float a00 = arg[0];
float a01 = arg[1];
float a02 = arg[2];
float a03 = arg[3];
float a10 = arg[4];
float a11 = arg[5];
float a12 = arg[6];
float a13 = arg[7];
float a20 = arg[8];
float a21 = arg[9];
float a22 = arg[10];
float a23 = arg[11];
float a30 = arg[12];
float a31 = arg[13];
float a32 = arg[14];
float a33 = arg[15];
float b00 = a00 * a11 - a01 * a10;
float b01 = a00 * a12 - a02 * a10;
float b02 = a00 * a13 - a03 * a10;
float b03 = a01 * a12 - a02 * a11;
float b04 = a01 * a13 - a03 * a11;
float b05 = a02 * a13 - a03 * a12;
float b06 = a20 * a31 - a21 * a30;
float b07 = a20 * a32 - a22 * a30;
float b08 = a20 * a33 - a23 * a30;
float b09 = a21 * a32 - a22 * a31;
float b10 = a21 * a33 - a23 * a31;
float b11 = a22 * a33 - a23 * a32;
float det =
(b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06);
if (det == 0) {
this.setFrom(arg);
return 0;
}
float invDet = 1.0f / det;
this._m4storage[0] = (a11 * b11 - a12 * b10 + a13 * b09) * invDet;
this._m4storage[1] = (-a01 * b11 + a02 * b10 - a03 * b09) * invDet;
this._m4storage[2] = (a31 * b05 - a32 * b04 + a33 * b03) * invDet;
this._m4storage[3] = (-a21 * b05 + a22 * b04 - a23 * b03) * invDet;
this._m4storage[4] = (-a10 * b11 + a12 * b08 - a13 * b07) * invDet;
this._m4storage[5] = (a00 * b11 - a02 * b08 + a03 * b07) * invDet;
this._m4storage[6] = (-a30 * b05 + a32 * b02 - a33 * b01) * invDet;
this._m4storage[7] = (a20 * b05 - a22 * b02 + a23 * b01) * invDet;
this._m4storage[8] = (a10 * b10 - a11 * b08 + a13 * b06) * invDet;
this._m4storage[9] = (-a00 * b10 + a01 * b08 - a03 * b06) * invDet;
this._m4storage[10] = (a30 * b04 - a31 * b02 + a33 * b00) * invDet;
this._m4storage[11] = (-a20 * b04 + a21 * b02 - a23 * b00) * invDet;
this._m4storage[12] = (-a10 * b09 + a11 * b07 - a12 * b06) * invDet;
this._m4storage[13] = (a00 * b09 - a01 * b07 + a02 * b06) * invDet;
this._m4storage[14] = (-a30 * b03 + a31 * b01 - a32 * b00) * invDet;
this._m4storage[15] = (a20 * b03 - a21 * b01 + a22 * b00) * invDet;
return det;
}
public int index(int row, int col) => (col * 4) + row;
public float entry(int row, int col) {
D.assert((row >= 0) && (row < this.dimension));
D.assert((col >= 0) && (col < this.dimension));
return this._m4storage[this.index(row, col)];
}
public float this[int index] {
get {
D.assert((uint) index < 16);
return this._m4storage[index];
}
set {
D.assert((uint) index < 16);
this._m4storage[index] = value;
}
}
public bool Equals(Matrix4 other) {
if (ReferenceEquals(null, other)) {
return false;
}
if (ReferenceEquals(this, other)) {
return true;
}
return (this._m4storage[0] == other._m4storage[0]) &&
(this._m4storage[1] == other._m4storage[1]) &&
(this._m4storage[2] == other._m4storage[2]) &&
(this._m4storage[3] == other._m4storage[3]) &&
(this._m4storage[4] == other._m4storage[4]) &&
(this._m4storage[5] == other._m4storage[5]) &&
(this._m4storage[6] == other._m4storage[6]) &&
(this._m4storage[7] == other._m4storage[7]) &&
(this._m4storage[8] == other._m4storage[8]) &&
(this._m4storage[9] == other._m4storage[9]) &&
(this._m4storage[10] == other._m4storage[10]) &&
(this._m4storage[11] == other._m4storage[11]) &&
(this._m4storage[12] == other._m4storage[12]) &&
(this._m4storage[13] == other._m4storage[13]) &&
(this._m4storage[14] == other._m4storage[14]) &&
(this._m4storage[15] == other._m4storage[15]);
}
public override bool Equals(object obj) {
if (ReferenceEquals(null, obj)) {
return false;
}
if (ReferenceEquals(this, obj)) {
return true;
}
if (obj.GetType() != this.GetType()) {
return false;
}
return this.Equals((Matrix4) obj);
}
public override int GetHashCode() {
return (this._m4storage != null ? this._m4storage.GetHashCode() : 0);
}
}
}

11
com.unity.uiwidgets/Runtime/ui/Matrix4.cs.meta


fileFormatVersion: 2
guid: 9b1bb0f304684e3faa19f8d70942198d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存