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

raycast result includes closest hit fraction #17710

Merged
merged 2 commits into from
Oct 17, 2024

Conversation

minggo
Copy link
Contributor

@minggo minggo commented Oct 14, 2024

@minggo minggo requested a review from dumganhar October 14, 2024 10:08
@minggo minggo marked this pull request as draft October 14, 2024 10:13
@minggo minggo removed the request for review from dumganhar October 14, 2024 10:13
@minggo
Copy link
Contributor Author

minggo commented Oct 14, 2024

Have to change other physics engines implementation.

Copy link

github-actions bot commented Oct 14, 2024

Interface Check Report

! WARNING this pull request has changed these public interfaces:

@@ -48803,21 +48803,36 @@
              * @zh
              * 在世界坐标系下击中面的法线。
              */
             get hitNormal(): math.Vec3;
+            /**
+             * @en
+             * Represents the fraction (range: 0.0 to 1.0) along the ray's path where the closest collision occurs.
+             * A value of 0.0 indicates an immediate collision at the ray's starting point,
+             * while a value of 1.0 means no collision along the entire ray length.
+             * Intermediate values indicate the fraction of the ray distance at which the closest hit is detected.
+             * Warning: only take effect with Bullet.
+             * @zh
+             * 表示射线路径上最近碰撞发生的位置,以百分比形式(范围:0.0 到 1.0)。
+             * 0.0 表示射线在起点处立即发生碰撞,1.0 表示射线在整个路径上未发生碰撞。
+             * 中间值表示碰撞点在射线总长度上的比例位置。
+             * 注意:只在 Bullet 引擎起效.
+             */
+            get closestHitFraction(): number;
             protected _hitPoint: math.Vec3;
             protected _hitNormal: math.Vec3;
             protected _distance: number;
             protected _collider: Collider | null;
+            protected _closestHitFraction: number;
             /**
              * @en
              * internal methods.
              * @zh
              * 设置射线,此方法由引擎内部使用,请勿在外部脚本调用。
              *
              * @deprecated since v3.5.0, this is an engine private interface that will be removed in the future.
              */
-            _assign(hitPoint: math.IVec3Like, distance: number, collider: Collider, hitNormal: math.IVec3Like): void;
+            _assign(hitPoint: math.IVec3Like, distance: number, collider: Collider, hitNormal: math.IVec3Like, closestHitFraction?: number): void;
             /**
              * @en
              * clone.
              * @zh

@minggo minggo marked this pull request as ready for review October 15, 2024 08:41
@minggo minggo requested a review from dumganhar October 15, 2024 08:42
@minggo minggo merged commit 1f2a63d into cocos:v3.8.5 Oct 17, 2024
26 checks passed
@minggo minggo deleted the return-closest-hit-fraction-for-raycast branch October 17, 2024 01:49
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.

2 participants