Commit Graph

3023 Commits

Author SHA1 Message Date
luzhuang
21c6a884fd fix(core/ui): propagate reparent dirty to descendants in Transform and UITransform
Both `Transform._parentChange` and `UITransform._parentChange` relied on
internal helpers (`_updateAllWorldFlag` / `_updateWorldFlagWithParentRectChange`)
that early-exit when the self-entity already has all target world dirty flags
set. Combined with `_parentTransformCache` potentially resolved to `null` during
partial clone/instantiate construction, a reparented subtree could keep
descendants' `worldMatrix` cached at identity — e.g. a UI layer rendered at
(0, 0) instead of inheriting the new parent's world position.

Both methods now delegate to new `_propagateReparentDirty(UI)` helpers which
unconditionally recurse over the whole subtree, setting `_worldAssociatedChange`
flags and `_isParentDirty = true` on every descendant so that subsequent
`_getParentTransform()` calls re-resolve the parent chain. UITransform's
alignment-driven size/position recompute path is preserved.

Observed in Galacean engine 2.0.0-alpha.24 when a prefab was pool-instantiated,
its sub-tree world properties were accessed (caching `null` parent), then the
prefab was `addChild`-ed under a positioned parent.

Added three white-box tests in `tests/src/core/Transform.test.ts` covering
(a) reparent after clone + child world access, (b) self-has-all-world-flags-set
early-exit case, (c) descendant cached null parent case. RED → GREEN verified.
2026-04-20 20:26:23 +08:00
luzhuang
bdf54903bf fix(physics-physx): raycast 和 sweep 跳过 initial overlap
PhysX 射线/sweep 起点在碰撞体内部时会返回 distance=0 的命中,
与 Unity 行为不一致。通过启用 POST_FILTER 并在 postFilter 中
过滤 distance<=0 的结果,使 PhysX 跳过 initial overlap 并继续
查找下一个最近命中。

- 启用 POST_FILTER query flag
- raycast 和 sweep callback 添加 postFilter 过滤 distance<=0
- 更新 PhysX wasm CDN URL(对应 QueryBinding.h postFilter 改动)
- 更新本地 wasm 产物
2026-04-15 21:20:49 +08:00
luzhuang
d5b6dd9012 fix(loader): add audio extension to AudioLoader supported types 2026-04-15 19:44:32 +08:00
cptbtptpbcptdtptp
bc35a612eb fix: revert code 2026-04-15 19:43:52 +08:00
cptbtptpbcptdtptp
5d7e6af705 Merge remote-tracking branch 'origin/fix/shaderlab' into fix/shaderlab 2026-04-15 19:38:54 +08:00
cptbtptpbcptdtptp
f5be42400b fix: raycast and clone 2026-04-15 19:38:17 +08:00
luzhuang
069f182a86 fix(loader): normalize gltf wrapper and skin roots 2026-04-15 17:39:05 +08:00
luzhuang
b3bf58a816 Revert "fix(loader): restore single-root GLTF scene without GLTF_ROOT wrapper"
This reverts commit 8a86f279eca9b2bc4a2fa56f94f174236f9a5674.
2026-04-15 17:39:04 +08:00
luzhuang
5abb3f5f02 fix(loader): restore single-root GLTF scene without GLTF_ROOT wrapper
Single-root GLTF scenes no longer wrap the root node in a GLTF_ROOT
container, which avoids redundant nesting and fixes animation path
resolution for models like Mixamo characters.

- GLTFSceneParser: single-root scenes use the node directly as scene root
- GLTFAnimationParser: remove single-root path prefixing (no longer needed)
- Entity.findByPath: prefer real same-name child over legacy self-name prefix
- Add AGENTS.md to .gitignore
2026-04-15 17:39:03 +08:00
luzhuang
40734f8394 fix(e2e): update blendShape e2e tests for GLTF_ROOT nesting
- animator-blendShape: use getComponentsIncludeChildren to find
  SkinnedMeshRenderer on child entity
- animator-multiSubMeshBlendShape: place Animator on actual model
  root (children[0]) so curve bindings with empty path resolve correctly
2026-04-15 17:39:02 +08:00
luzhuang
3071f908c8 fix(loader): always create GLTF_ROOT container for consistent animation paths (#2942)
Remove single-root vs multi-root branching in GLTFSceneParser, always
creating a GLTF_ROOT wrapper entity. This ensures animation bone paths
are consistent across different glTF files, fixing cross-file animation
clip retargeting.
2026-04-15 17:39:01 +08:00
shensi.zxd
4fe4fae272 fix(shader): add missing camera_VPMat declaration in Transform.glsl 2026-04-15 16:48:27 +08:00
cptbtptpbcptdtptp
40006d952f fix: raycast collider layer 2026-04-15 16:37:08 +08:00
cptbtptpbcptdtptp
5c2edee1ec fix: clone and sibling index 2026-04-15 15:12:58 +08:00
cptbtptpbcptdtptp
ca5252a9a8 feat: supported filled 2026-04-07 16:21:59 +08:00
cptbtptpbcptdtptp
207a3811b1 feat(2d): add FilledSpriteAssembler and sprite filled mode support
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-02 16:37:45 +08:00
luzhuang
15b19affcd feat: particle bug not fix 2026-04-01 12:09:30 +08:00
luzhuang
13052d2f98 feat(ui): add SpriteSizeMode to Image component
When sizeMode is set to Automatic, the UITransform size is automatically
synchronized to the sprite's natural dimensions when the sprite changes.
This matches Cocos Creator's Sprite.SizeMode.TRIMMED behavior.

- Add SpriteSizeMode enum (Custom / Automatic)
- Add sizeMode property to Image with getter/setter
- Sync UITransform.size in set sprite and _onSpriteChange
- Export SpriteSizeMode from component index
2026-03-30 14:59:53 +08:00
luzhuang
63c715b635 fix(animation): add per-instance speed to AnimatorStatePlayData
AnimatorState.speed is part of the shared AnimatorController asset.
Modifying it at runtime pollutes all Animator instances sharing the
same controller, causing animation speed corruption after cloning.

- Add speed field to AnimatorStatePlayData, initialized from AnimatorState.speed on reset
- Add proxy properties (name/clip/wrapMode/transitions/addStateMachineScript)
- Change speed calculation to playData.speed * animator.speed
- findAnimatorState now returns per-instance AnimatorStatePlayData
- Export AnimatorStatePlayData for consumer code
2026-03-30 14:50:22 +08:00
luzhuang
d9a267477d fix(animation): normalize single-root clip binding paths 2026-03-29 20:56:45 +08:00
luzhuang
a6156ba9fb fix(clone): prefab 克隆时自动 deep clone 同类型 Object 属性,防止共享状态
CloneManager: 当 source 和 target 属性是同类型 Object 实例(如 Vector4)时,
自动升级为 DeepClone,避免 prefab 模板的引用覆盖克隆体的独立实例。
新增 Map/Set 类型的 deep clone 支持。

ModelMesh: throw string 改为 throw Error 以获得正确堆栈。
2026-03-29 19:02:38 +08:00
luzhuang
13521cc420 fix(loader): componentRef 解析支持 clone entity 子树查找
ReflectionParser 解析 IComponentRef(entityPath + componentType)时,
目标组件可能在 GLB clone 的子 entity 上而非 clone 根 entity 自身。
getComponents 找不到时 fallback 到 getComponentsIncludeChildren。
2026-03-29 18:53:54 +08:00
cptbtptpbcptdtptp
ca0d518383 fix: use project type 2026-03-28 18:45:43 +08:00
cptbtptpbcptdtptp
63dff37450 test(camera): add unit test for invViewProjMat scale consistency
Verify that screenPointToRay and viewport-world round-trip produce
correct results when the camera inherits non-identity scale from a
parent entity. Without the fix, the round-trip deviates by the
inherited scale factor (e.g. 105 -> 107.5 at scale 1.5).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-28 14:39:06 +08:00
cptbtptpbcptdtptp
41f024e1f8 fix(camera): make invViewProjMat ignore scale consistently with viewMatrix
The viewMatrix getter intentionally ignores the camera entity's world scale
(using Matrix.rotationTranslation), but _getInvViewProjMat() was using the
full entity.transform.worldMatrix which includes inherited scale. This
inconsistency causes screenPointToRay to produce incorrect world-space rays
when the camera inherits scale from a parent entity (e.g. UICanvas in
ScreenSpaceCamera mode with camera as a child of canvas).

Closes #2748

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-28 14:38:55 +08:00
shensi.zxd
3cf18831d4 fix(shader-lab): allow logical NOT operator on numeric operands in preprocessor
#if !0 and similar expressions now work correctly, matching C/GLSL preprocessor behavior.
2026-03-27 17:55:51 +08:00
cptbtptpbcptdtptp
d0dada8e52 fix: keep mesh data 2026-03-27 15:17:06 +08:00
cptbtptpbcptdtptp
c662731f2f fix: entity disable 2026-03-27 15:12:36 +08:00
cptbtptpbcptdtptp
1749077779 fix: temp 2026-03-27 12:14:57 +08:00
cptbtptpbcptdtptp
b7146090d3 fix: temp 2026-03-27 10:59:04 +08:00
cptbtptpbcptdtptp
b902c21583 feat: merge code 2026-03-27 10:41:52 +08:00
shensi.zxd
bfe4e9ea23 fix(shader-lab): add missing semicolon in GLES100 fragment return conversion
GLES100 visitJumpStatement converted `return expr;` to `gl_FragColor = expr`
without a trailing semicolon, causing WebGL compilation errors. Only triggered
when fragment entry returns vec4 (Cocos pattern), not void (standard Galacean).
2026-03-27 01:06:15 +08:00
shensi.zxd
80e6e3ebb3 fix(shader-lab): handle global struct-typed variables and simplify macro scanning
- Suppress `uniform` output for global struct-typed variables (e.g. `Varyings o;`)
- Register global struct vars in both per-function and cross-stage maps
- Unify macro member access scanning into callback-based _forEachMacroMemberAccess
- Add registerStructVar() encapsulation in VisitorContext
- Add Cocos VSOutput pattern test (global-varying-var)
2026-03-27 00:33:21 +08:00
shensi.zxd
7b18aef47c test(shader-lab): add Cocos FSInput pattern test for member access macro as builtin arg 2026-03-26 23:23:00 +08:00
shensi.zxd
828752de06 fix(shader-lab): skip type inference for member access macros in semantic analysis 2026-03-26 23:15:39 +08:00
shensi.zxd
d05187b7fc fix(shader-lab): support global #define with cross-stage struct var transform
Build a combined _globalStructVarMap in visitShaderProgram by scanning
both vertex and fragment entry functions, so global #define values like
`attr.POSITION` or `o.v_uv` are correctly transformed in all stages.

Rewrite define-struct-access tests to use snapshot file comparison
against expected/ GLSL outputs for clearer verification.
2026-03-26 23:13:18 +08:00
shensi.zxd
60480bbfb4 test(shader-lab): enrich define-struct-access tests with usage assertions
Add assertions for macro usage in expressions (not just #define transformation):
- Macro as RHS in multiplication, as LHS in assignment
- Macro as function argument in dot(), texture2D()
- Multiple varying properties (v_uv, v_normal) referenced via #define
2026-03-26 23:13:17 +08:00
shensi.zxd
a0e6fc8f4e test(shader-lab): add transformation result assertions for define-struct-access
Verify the actual CodeGen output instead of just checking GLSL compilation:
- #define values with struct member access are correctly transformed
- varying/attribute declarations are emitted for referenced properties
2026-03-26 23:13:17 +08:00
shensi.zxd
2f6712a1d9 fix(shader-lab): transform struct member access in #define values during CodeGen
When #define values contain struct member access like `o.v_uv` (where `o` is
a Varyings/Attributes/MRT struct variable), the CodeGen now correctly transforms
them to just the property name (e.g. `v_uv`), matching the behavior of direct
struct member access in regular code. Closes #2944.
2026-03-26 23:13:17 +08:00
shensi.zxd
4b3d632159 fix(shader-lab): return TypeAny for unresolved generic builtin return type
When a builtin generic function (e.g. normalize) receives TypeAny args,
resolvedReturnType stays TypeAny. Previously the else branch returned
the raw EGenType enum value (200), which is neither a concrete type nor
a wildcard, causing downstream user-function overload matching to fail.
2026-03-26 23:13:16 +08:00
shensi.zxd
2d2512940c fix(shader-lab): simplify resolveGenericReturnType, fix textureCube/texture2DLod signatures
- Simplify resolveGenericReturnType: remove genericParamType param, only
  check if return type is GVec4
- Fix textureCube/textureCubeLod return type: SAMPLER_CUBE → VEC4
- Add missing texture2DLod builtin function registration
- Add texture2DLod test cases to texture-generic.shader
2026-03-26 23:13:16 +08:00
shensi.zxd
889b096121 fix(shader-lab): resolve GVec4 generic return type for texture() builtin functions
texture(sampler2D, vec2) returns GVec4 which was incorrectly resolved to
the sampler type instead of vec4, causing "No overload function type found"
when passing the result to user-defined functions like decode32(vec4).

Add resolveGenericReturnType() to correctly map GSampler* → GVec4:
  sampler2D/sampler3D/samplerCube → vec4
  isampler2D/isampler3D/...       → ivec4
  usampler2D/usampler3D/...       → uvec4
2026-03-26 23:13:16 +08:00
shensi.zxd
8a0a605b98 fix(shader-lab): return TypeAny for unresolved generic builtin return type
When a builtin generic function (e.g. normalize) receives TypeAny args,
resolvedReturnType stays TypeAny. Previously the else branch returned
the raw EGenType enum value (200), which is neither a concrete type nor
a wildcard, causing downstream user-function overload matching to fail.
2026-03-26 17:20:00 +08:00
hhhhkrx
b69233bfd0 implement HorizontalBillboard render mode (#2938)
* feat: implement HorizontalBillboard render mode
2026-03-26 16:57:31 +08:00
shensi.zxd
727bcec6e8 fix(shader-lab): simplify resolveGenericReturnType, fix textureCube/texture2DLod signatures
- Simplify resolveGenericReturnType: remove genericParamType param, only
  check if return type is GVec4
- Fix textureCube/textureCubeLod return type: SAMPLER_CUBE → VEC4
- Add missing texture2DLod builtin function registration
- Add texture2DLod test cases to texture-generic.shader
2026-03-26 16:18:14 +08:00
shensi.zxd
5d37ccc60b fix(shader-lab): resolve GVec4 generic return type for texture() builtin functions
texture(sampler2D, vec2) returns GVec4 which was incorrectly resolved to
the sampler type instead of vec4, causing "No overload function type found"
when passing the result to user-defined functions like decode32(vec4).

Add resolveGenericReturnType() to correctly map GSampler* → GVec4:
  sampler2D/sampler3D/samplerCube → vec4
  isampler2D/isampler3D/...       → ivec4
  usampler2D/usampler3D/...       → uvec4
2026-03-26 16:18:14 +08:00
cptbtptpbcptdtptp
2f88c2fab6 chore: release v2.0.0-alpha.24 v2.0.0-alpha.24 2026-03-23 17:55:13 +08:00
hhhhkrx
73415e6ed8 implement HorizontalBillboard render mode (#2938)
* feat: implement HorizontalBillboard render mode
2026-03-23 17:29:12 +08:00
GuoLei1990
46761322ff Merge branch 'main' into dev/2.0 2026-03-20 21:25:59 +08:00
ChenMo
769d4718f6 Revert "ci: add Co-authored-by workflow (#2934)" (#2935)
This reverts commit 734f181e01.
2026-03-20 21:25:29 +08:00