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.2 physics debug draw #16325

Merged
merged 16 commits into from
Sep 25, 2023
Merged

Conversation

lealzhan
Copy link
Contributor

@lealzhan lealzhan commented Sep 25, 2023

Re: #https://github.com/cocos/3d-tasks/issues/17606

PhysicsSystem.instance.debugDrawFlags = EPhysicsDrawFlags.WIRE_FRAME | EPhysicsDrawFlags.CONSTRAINT | EPhysicsDrawFlags.AABB;
PhysicsSystem.instance.debugDrawConstraintSize = 1;
Wireframe Constraint Aabb
Builtin x
cannon.js x
Bullet x x x
PhysX x x x

image
image
image
image

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.

@lealzhan lealzhan requested a review from SantyWang September 25, 2023 06:01
@lealzhan lealzhan mentioned this pull request Sep 25, 2023
6 tasks
@github-actions
Copy link

github-actions bot commented Sep 25, 2023

Interface Check Report

! WARNING this pull request has changed these public interfaces:

@@ -47580,8 +47580,29 @@
              */
             emitEvents(): void;
             /**
              * @en
+             * Get or set debug draw flags. Default is EPhysicsDrawFlags.NONE.
+             * Refer to EPhysicsDrawFlags.
+             * Note: Since physics debug draw uses Geometry-Renderer to do drawing,
+             * make sure Geometry-Renderer is not cropped in Project Setting.
+             * @zh
+             * 获取或设置调试绘制标志。默认为 EPhysicsDrawFlags.NONE。
+             * 参考 EPhysicsDrawFlags。
+             * 注意:因为物理调试绘制使用几何渲染器来绘制,请确保项目设置中几何渲染器没有被裁剪掉。
+             */
+            get debugDrawFlags(): number;
+            set debugDrawFlags(v: number);
+            /**
+             * @en
+             * Get or set constraint debug draw size. Default is 0.3.
+             * @zh
+             * 获取或设置约束的调试绘制尺寸。默认为 0.3。
+             */
+            get debugDrawConstraintSize(): number;
+            set debugDrawConstraintSize(v: number);
+            /**
+             * @en
              * Collision detect all collider, and record all the detected results, through PhysicsSystem.Instance.RaycastResults access to the results.
              * @zh
              * 检测所有的碰撞盒,并记录所有被检测到的结果,通过 PhysicsSystem.instance.raycastResults 访问结果。
              * @param worldRay @zh 世界空间下的一条射线 @en A ray in world space
@@ -49757,8 +49778,38 @@
              * 默认分组。
              */
             DEFAULT = 1
         }
+        export enum EPhysicsDrawFlags {
+            /**
+             * @en
+             * Draw nothing.
+             * @zh
+             * 不绘制。
+             */
+            NONE = 0,
+            /**
+             * @en
+             * Draw wireframe
+             * @zh
+             * 绘制线框。
+             */
+            WIRE_FRAME = 1,
+            /**
+             * @en
+             * Draw Constraint.
+             * @zh
+             * 绘制约束
+             */
+            CONSTRAINT = 2,
+            /**
+             * @en
+             * Draw AABB.
+             * @zh
+             * 绘制包围盒。
+             */
+            AABB = 4
+        }
         export { ITriggerEvent, TriggerEventType, TriggerCallback, IContactEquation, ICollisionEvent, CollisionEventType, CollisionCallback, CharacterTriggerEventType, CharacterCollisionEventType, CharacterControllerContact };
     }
     export namespace primitives {
         /**
@@ -57624,8 +57675,9 @@
     export import CapsuleCharacterController = physics.CapsuleCharacterController;
     export import ERigidBodyType = physics.ERigidBodyType;
     export import EAxisDirection = physics.EAxisDirection;
     export import EColliderType = physics.EColliderType;
+    export import EPhysicsDrawFlags = physics.EPhysicsDrawFlags;
     export namespace __private {
         /**
          * Engine classes with this kind of signature are integrated with editor extendability.
          * @internal
@@ -66320,8 +66372,10 @@
             maxDistance: number;
         }
         export interface _cocos_physics_spec_i_physics_world__IPhysicsWorld {
             readonly impl: any;
+            debugDrawFlags: physics.EPhysicsDrawFlags;
+            debugDrawConstraintSize: number;
             setGravity: (v: math.IVec3Like) => void;
             setAllowSleep: (v: boolean) => void;
             setDefaultMaterial: (v: physics.PhysicsMaterial) => void;
             step(fixedTimeStep: number, timeSinceLastCalled?: number, maxSubSteps?: number): void;

@lealzhan lealzhan requested a review from SantyWang September 25, 2023 06:24
@lealzhan lealzhan merged commit 9a42164 into cocos:v3.8.2 Sep 25, 2023
24 checks passed
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