Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v3.8.6] [2D Skew comes back] Add UISkew component support. #18212

Draft
wants to merge 18 commits into
base: v3.8.6
Choose a base branch
from

Conversation

dumganhar
Copy link
Contributor

@dumganhar dumganhar commented Jan 17, 2025

Re: #17852

Need to consider

  • Least performance overhead for Node.
  • Less code size increment.

TODO:

  • Add some UnitTests
  • Editor gizmo support

Changelog


Continuous Integration

This pull request:

  • needs automatic test cases check.

    Manual trigger with @cocos-robot run test cases afterward.

  • does not change any runtime related code or build configuration

    If any reviewer thinks the CI checks are needed, please uncheck this option, then close and reopen the issue.


Compatibility Check

This pull request:

  • changes public API, and have ensured backward compatibility with deprecated features.
  • affects platform compatibility, e.g. system version, browser version, platform sdk version, platform toolchain, language version, hardware compatibility etc.
  • affects file structure of the build package or build configuration which requires user project upgrade.
  • introduces breaking changes, please list all changes, affected features and the scope of violation.

@dumganhar dumganhar requested a review from minggo January 17, 2025 11:07
Copy link

github-actions bot commented Jan 17, 2025

⚠️ Package size ⤴ 1568 bytes, old: 5232984, new: 5234552

Interface Check Report

! WARNING this pull request has changed these public interfaces:

@@ -1756,8 +1756,64 @@
         getComputeAABB(out?: geometry.AABB): geometry.AABB;
         protected _selfBoundingBox(out: math.Rect): math.Rect;
         protected _parentChanged(node: Node): void;
     }
+    export class UISkew extends Component {
+        constructor();
+        protected __preload(): void;
+        protected onEnable(): void;
+        protected onDisable(): void;
+        protected onDestroy(): void;
+        /**
+         * @en Gets the skew on x axis. Unit is degree.
+         * @zh 获取 X 轴斜切角度。
+         */
+        get x(): number;
+        /**
+         * @en Sets the skew on x axis. Unit is degree.
+         * @zh 设置 X 轴斜切角度。
+         */
+        set x(v: number);
+        /**
+         * @en Gets the skew on y axis. Unit is degree.
+         * @zh 获取 Y 轴斜切角度。
+         */
+        get y(): number;
+        /**
+         * @en Sets the skew on y axis. Unit is degree.
+         * @zh 设置 Y 轴斜切角度。
+         */
+        set y(v: number);
+        /**
+         * @en Gets the skew value of the node. Unit is degree.
+         * @zh 获取节点斜切角度。
+         */
+        get skew(): Readonly<math.Vec2>;
+        /**
+         * @en Sets the skew value of the node. Unit is degree.
+         * @zh 设置节点斜切角度。
+         */
+        set skew(value: Readonly<math.Vec2>);
+        /**
+         * @en Sets the skew value of the node by Vec2.
+         * @zh 设置节点斜切角度。
+         * @param @en value The skew value in Vec2. @zh 斜切角度值。
+         */
+        setSkew(value: Readonly<math.IVec2Like>): void;
+        /**
+         * @en Sets the skew value of the node by x and y.
+         * @zh 设置节点斜切角度。
+         * @param x @en The skew on x axis. @zh X 轴斜切角度。
+         * @param y @en The skew on y axis. @zh Y 轴斜切角度。
+         */
+        setSkew(x: number, y: number): void;
+        /**
+         * @en Copies and returns the skew value of the node.
+         * @zh 拷贝节点斜切角度值并返回。
+         * @returns @en The skew value of the node. @zh 节点斜切角度。
+         */
+        getSkew(out?: math.Vec2): math.Vec2;
+    }
     /**
      * @en The entry node for 2D object data collection, all 2D rendering objects need to be rendered under the RenderRoot node.
      * @zh 2D 对象数据收集的入口节点,所有的 2D渲染对象需在 RenderRoot 节点下才可以被渲染。
      */
@@ -24192,8 +24248,11 @@
         protected _scene: Scene;
         protected _activeInHierarchy: boolean;
         protected _id: string;
         protected _eventProcessor: __private._cocos_scene_graph_node_event_processor__NodeEventProcessor;
+        /**
+         * @dontmangle Ensure _eventMask not to be mangled since it is visited by UISkew._updateNodeTransformFlags with 'any' conversion.
+         */
         protected _eventMask: number;
         protected _siblingIndex: number;
         /**
          * @en
@@ -24658,9 +24717,9 @@
         protected _lscale: math.Vec3;
         protected _mobility: number;
         protected _layer: number;
         protected _euler: math.Vec3;
-        protected _transformFlags: TransformBit;
+        protected _transformFlags: number;
         protected _eulerDirty: boolean;
         protected _flagChangeVersion: number;
         protected _hasChangedFlags: number;
         constructor(name?: string);
@@ -25941,13 +26000,22 @@
          * @zh 节点缩放
          */
         SCALE = 4,
         /**
+         * @en Skew changed
+         * @zh 节点斜切
+         */
+        SKEW = 8,
+        /**
          * @en Rotation or scale changed
          * @zh 节点旋转及缩放
          */
         RS = 6,
         /**
+         * @en Rotation, scale or skew changed
+         */
+        RSS = 14,
+        /**
          * @en Translation, rotation or scale changed
          * @zh 节点平移,旋转及缩放
          */
         TRS = 7,

@dumganhar dumganhar marked this pull request as draft January 17, 2025 15:51
@dumganhar
Copy link
Contributor Author

@cocos-robot run test cases

1 similar comment
@dumganhar
Copy link
Contributor Author

@cocos-robot run test cases

Copy link

@dumganhar, Please check the result of run test cases:

Task Details

Copy link

@dumganhar, Please check the result of run test cases:

Task Details

if (cur) {
if (dirtyBits & TransformBit.POSITION) {
if (positionDirty && !rotationScaleDirty) {
Vec3.transformMat4(childPos, child._lpos, cur._mat);
Copy link
Contributor Author

@dumganhar dumganhar Jan 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If position and (rotation/scale/skew) are both dirty. Doesn't need to go here to calculate world matrix since in the following if (rotationScaleSkewDirty) { logic , it will do that in Mat4.fromSRT ( get the local matrix) + Mat4.multiply ( get the world matrix = parent's world matrix * my local matrix ).

In this case, we avoid the unused Vec3.transformMat4 operation.

Mat4.fromSRT(childMat, child._lrot, child._lpos, child._lscale);
uiSkewComp = child._uiProps._uiSkewComp;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't use getter and make _uiSkewComp @engineInternal public property for fast accessing the UISkew component.

@dumganhar
Copy link
Contributor Author

@cocos-robot run test cases

Copy link

@dumganhar, Please check the result of run test cases:

Task Details

Copy link

@dumganhar, Please check the result of run test cases:

Task Details

@dumganhar
Copy link
Contributor Author

@cocos-robot run test cases

Copy link

@dumganhar, Please check the result of run test cases:

Task Details

Copy link

@dumganhar, Please check the result of run test cases:

Task Details

@dumganhar dumganhar changed the title [v3.8.6] Add UISkew component support. [v3.8.6] [2D Skew is back] Add UISkew component support. Jan 19, 2025
@dumganhar dumganhar changed the title [v3.8.6] [2D Skew is back] Add UISkew component support. [v3.8.6] [2D Skew comes back] Add UISkew component support. Jan 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant