Skip to content

Commit

Permalink
remove unneeded import and global variables (#17694)
Browse files Browse the repository at this point in the history
  • Loading branch information
minggo authored Oct 12, 2024
1 parent 1ecdb7c commit a4f3778
Show file tree
Hide file tree
Showing 43 changed files with 50 additions and 74 deletions.
2 changes: 1 addition & 1 deletion cocos/physics-2d/box2d-wasm/joints/joint-2d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { B2, B2ObjectType, addImplPtrReference, addImplPtrReferenceWASM, getImpl
import { IJoint2D } from '../../spec/i-physics-joint';
import { Joint2D, PhysicsSystem2D, RigidBody2D } from '../../framework';
import { B2PhysicsWorld } from '../physics-world';
import { Vec2, warn } from '../../../core';
import { warn } from '../../../core';

export class B2Joint implements IJoint2D {
get impl (): B2.Joint | null {
Expand Down
1 change: 0 additions & 1 deletion cocos/physics-2d/box2d-wasm/physics-contact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import { PHYSICS_2D_PTM_RATIO } from '../framework/physics-types';
import { Collider2D, Contact2DType, PhysicsSystem2D } from '../framework';
import { B2Shape2D } from './shapes/shape-2d';
import { IPhysics2DContact, IPhysics2DImpulse, IPhysics2DManifoldPoint, IPhysics2DWorldManifold } from '../spec/i-physics-contact';
import { B2PhysicsWorld } from './physics-world';

const pools: PhysicsContact[] = [];

Expand Down
3 changes: 1 addition & 2 deletions cocos/physics-2d/box2d-wasm/physics-world.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { EDITOR_NOT_IN_PREVIEW } from 'internal:constants';
import { B2, getImplPtr, addImplPtrReference, addImplPtrReferenceWASM,
getTSObjectFromWASMObjectPtr, removeImplPtrReference, removeImplPtrReferenceWASM, B2ObjectType } from './instantiated';
import { IPhysicsWorld } from '../spec/i-physics-world';
import { IVec2Like, Vec3, Quat, toRadian, Vec2, toDegree, Rect, CCObject, js } from '../../core';
import { IVec2Like, Vec3, Quat, Vec2, toDegree, Rect, CCObject, js } from '../../core';
import { PHYSICS_2D_PTM_RATIO, ERaycast2DType, ERigidBody2DType } from '../framework/physics-types';
import { Canvas } from '../../2d/framework';
import { Graphics } from '../../2d/components';
Expand All @@ -45,7 +45,6 @@ import { director } from '../../game';
const tempVec3 = new Vec3();
const tempVec2_1 = new Vec2();
const tempVec2_2 = new Vec2();
const tempB2Vec2_1 = { x: 0, y: 0 };

// const tempB2AABB = null;//new B2.AABB();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@
THE SOFTWARE.
*/

import { B2 } from '../instantiated';
import { js, warn } from '../../../core';

export class PhysicsContactListener {
static _BeginContact: Function | null = null;
static _EndContact: Function | null = null;
Expand Down
2 changes: 1 addition & 1 deletion cocos/physics-2d/box2d-wasm/platform/physics-debug-draw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*/

import { B2, b2Mul } from '../instantiated';
import { Color, warn } from '../../../core';
import { Color } from '../../../core';
import { PHYSICS_2D_PTM_RATIO } from '../../framework';
import { Graphics } from '../../../2d';

Expand Down
4 changes: 2 additions & 2 deletions cocos/physics-2d/box2d-wasm/rigid-body.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ import { IRigidBody2D } from '../spec/i-rigid-body';
import { RigidBody2D } from '../framework/components/rigid-body-2d';
import { PhysicsSystem2D } from '../framework/physics-system';
import { B2PhysicsWorld } from './physics-world';
import { Vec2, toRadian, Vec3, Quat, IVec2Like, toDegree, TWO_PI, HALF_PI } from '../../core';
import { Vec2, toRadian, Vec3, Quat, IVec2Like, TWO_PI, HALF_PI } from '../../core';
import { PHYSICS_2D_PTM_RATIO, ERigidBody2DType } from '../framework/physics-types';

import { Node } from '../../scene-graph/node';
import { Collider2D, Joint2D } from '../framework';
import { Collider2D } from '../framework';
import { B2Shape2D } from './shapes/shape-2d';
import { B2Joint } from './joints/joint-2d';

Expand Down
1 change: 0 additions & 1 deletion cocos/physics-2d/box2d-wasm/shapes/box-shape-2d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import { IBoxShape } from '../../spec/i-physics-shape';
import { Vec2, Rect } from '../../../core';

const tempAabb = new Rect();
const tempB2Vec2_1 = { x: 0, y: 0 };

export class B2BoxShape extends B2Shape2D implements IBoxShape {
_worldPoints: Vec2[] = [new Vec2(), new Vec2(), new Vec2(), new Vec2()];
Expand Down
2 changes: 1 addition & 1 deletion cocos/physics-2d/box2d-wasm/shapes/polygon-shape-2d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import * as PolygonPartition from '../../framework/utils/polygon-partition';
import { PolygonCollider2D } from '../../framework';
import { PHYSICS_2D_PTM_RATIO } from '../../framework/physics-types';
import { IPolygonShape } from '../../spec/i-physics-shape';
import { Vec2, IVec2Like, warn } from '../../../core';
import { Vec2, warn } from '../../../core';

export class B2PolygonShape extends B2Shape2D implements IPolygonShape {
_worldPoints: Vec2[] = [];
Expand Down
1 change: 0 additions & 1 deletion cocos/physics-2d/box2d/joints/joint-2d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import b2 from '@cocos/box2d';
import { IJoint2D } from '../../spec/i-physics-joint';
import { Joint2D, PhysicsSystem2D, RigidBody2D } from '../../framework';
import { b2PhysicsWorld } from '../physics-world';
import { Vec2 } from '../../../core';

export class b2Joint implements IJoint2D {
get impl (): b2.Joint | null {
Expand Down
2 changes: 1 addition & 1 deletion cocos/physics-2d/box2d/joints/relative-joint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
THE SOFTWARE.
*/

import b2, { MotorJointDef, Vec2 } from '@cocos/box2d';
import b2, { Vec2 } from '@cocos/box2d';
import { IRelativeJoint } from '../../spec/i-physics-joint';
import { b2Joint } from './joint-2d';
import { RelativeJoint2D } from '../../framework';
Expand Down
5 changes: 1 addition & 4 deletions cocos/physics-2d/box2d/physics-world.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,8 @@ import b2 from '@cocos/box2d';
import { EDITOR_NOT_IN_PREVIEW, TEST } from 'internal:constants';

import { IPhysicsWorld } from '../spec/i-physics-world';
import { IVec2Like, Vec3, Quat, toRadian, Vec2, toDegree, Rect, CCObject, js } from '../../core';
import { IVec2Like, Vec3, Quat, Vec2, toDegree, Rect, CCObject, js } from '../../core';
import { PHYSICS_2D_PTM_RATIO, ERaycast2DType, ERigidBody2DType } from '../framework/physics-types';
// import { Canvas } from '../../2d/framework';
// import { Graphics } from '../../2d/components';

import { b2RigidBody2D } from './rigid-body';
import { PhysicsContactListener } from './platform/physics-contact-listener';
import { PhysicsAABBQueryCallback } from './platform/physics-aabb-query-callback';
Expand Down
3 changes: 1 addition & 2 deletions cocos/physics-2d/box2d/rigid-body.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,11 @@ import { IRigidBody2D } from '../spec/i-rigid-body';
import { RigidBody2D } from '../framework/components/rigid-body-2d';
import { PhysicsSystem2D } from '../framework/physics-system';
import { b2PhysicsWorld } from './physics-world';
import { Vec2, toRadian, Vec3, Quat, IVec2Like, toDegree, TWO_PI, HALF_PI } from '../../core';
import { Vec2, toRadian, Vec3, Quat, IVec2Like, TWO_PI, HALF_PI } from '../../core';
import { PHYSICS_2D_PTM_RATIO, ERigidBody2DType } from '../framework/physics-types';

import { Node } from '../../scene-graph/node';
import { Collider2D } from '../framework';
import { NodeEventType } from '../../scene-graph/node-event';

const tempVec3 = new Vec3();

Expand Down
3 changes: 1 addition & 2 deletions cocos/physics-2d/box2d/shapes/polygon-shape-2d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@

import b2 from '@cocos/box2d';
import { b2Shape2D } from './shape-2d';
import * as PolygonSeparator from '../../framework/utils/polygon-separator';
import * as PolygonPartition from '../../framework/utils/polygon-partition';
import { PolygonCollider2D } from '../../framework';
import { PHYSICS_2D_PTM_RATIO } from '../../framework/physics-types';
import { IPolygonShape } from '../../spec/i-physics-shape';
import { Vec2, IVec2Like } from '../../../core';
import { Vec2 } from '../../../core';

export class b2PolygonShape extends b2Shape2D implements IPolygonShape {
_worldPoints: Vec2[] = [];
Expand Down
2 changes: 1 addition & 1 deletion cocos/physics-2d/box2d/shapes/shape-2d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
THE SOFTWARE.
*/

import b2, { Vec2 } from '@cocos/box2d';
import b2 from '@cocos/box2d';

import { IBaseShape } from '../../spec/i-physics-shape';
import { Collider2D, PhysicsSystem2D, RigidBody2D, PHYSICS_2D_PTM_RATIO } from '../../../../exports/physics-2d-framework';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { ECollider2DType } from '../../physics-types';
import { IBoxShape } from '../../../spec/i-physics-shape';
import { help, serializable, tooltip, type } from '../../../../core/data/decorators';

const { ccclass, menu, property } = _decorator;
const { ccclass, menu } = _decorator;

@ccclass('cc.BoxCollider2D')
@help('i18n:cc.BoxCollider2D')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { ECollider2DType } from '../../physics-types';
import { ICircleShape } from '../../../spec/i-physics-shape';
import { help, serializable, tooltip, type } from '../../../../core/data/decorators';

const { ccclass, menu, property } = _decorator;
const { ccclass, menu } = _decorator;

@ccclass('cc.CircleCollider2D')
@help('i18n:cc.CircleCollider2D')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

import { EDITOR_NOT_IN_PREVIEW } from 'internal:constants';

import { Vec2, Rect, _decorator, Eventify, cclegacy, tooltip, CCInteger, serializable, CCFloat, CCBoolean } from '../../../../core';
import { Vec2, Rect, _decorator, Eventify, tooltip, serializable, CCFloat, CCBoolean } from '../../../../core';
import { PhysicsGroup } from '../../../../physics/framework/physics-enum';

import { RigidBody2D } from '../rigid-body-2d';
Expand All @@ -33,7 +33,7 @@ import { ECollider2DType } from '../../physics-types';
import { IBaseShape } from '../../../spec/i-physics-shape';
import { Component } from '../../../../scene-graph';

const { ccclass, editable, property, type } = _decorator;
const { ccclass, editable, type } = _decorator;

@ccclass('cc.Collider2D')
export class Collider2D extends Eventify(Component) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { ECollider2DType } from '../../physics-types';
import { IPolygonShape } from '../../../spec/i-physics-shape';
import { displayOrder, help, serializable, tooltip, type } from '../../../../core/data/decorators';

const { ccclass, menu, property } = _decorator;
const { ccclass, menu } = _decorator;

@ccclass('cc.PolygonCollider2D')
@help('i18n:cc.PolygonCollider2D')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { EJoint2DType } from '../../physics-types';
import { CCBoolean, CCFloat, Vec3, _decorator } from '../../../../core';
import { help, serializable, tooltip, type } from '../../../../core/data/decorators';

const { ccclass, menu, property } = _decorator;
const { ccclass, menu } = _decorator;

@ccclass('cc.DistanceJoint2D')
@help('i18n:cc.Joint2D')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { IFixedJoint } from '../../../spec/i-physics-joint';
import { EJoint2DType } from '../../physics-types';
import { help, serializable, tooltip, type } from '../../../../core/data/decorators';

const { ccclass, menu, property } = _decorator;
const { ccclass, menu } = _decorator;

@ccclass('cc.FixedJoint2D')
@help('i18n:cc.Joint2D')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { IHingeJoint } from '../../../spec/i-physics-joint';
import { EJoint2DType } from '../../physics-types';
import { help, serializable, tooltip, type } from '../../../../core/data/decorators';

const { ccclass, menu, property } = _decorator;
const { ccclass, menu } = _decorator;

@ccclass('cc.HingeJoint2D')
@help('i18n:cc.Joint2D')
Expand Down
2 changes: 1 addition & 1 deletion cocos/physics-2d/framework/components/joints/joint-2d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import { EJoint2DType } from '../../physics-types';
import { createJoint } from '../../physics-selector';
import { Component } from '../../../../scene-graph';

const { ccclass, type, property } = _decorator;
const { ccclass, type } = _decorator;

@ccclass('cc.Joint2D')
export class Joint2D extends Component {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { EJoint2DType } from '../../physics-types';
import { CCFloat, Vec2, _decorator } from '../../../../core';
import { help, serializable, tooltip, type } from '../../../../core/data/decorators';

const { ccclass, menu, property } = _decorator;
const { ccclass, menu } = _decorator;

@ccclass('cc.MouseJoint2D')
@help('i18n:cc.Joint2D')
Expand Down
16 changes: 11 additions & 5 deletions cocos/physics-2d/framework/components/joints/relative-joint-2d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import { help, serializable, tooltip, type } from '../../../../core/data/decorat
const tempVec3_1 = new Vec3();
const tempVec3_2 = new Vec3();

const { ccclass, menu, property } = _decorator;
const { ccclass, menu } = _decorator;

@ccclass('cc.RelativeJoint2D')
@help('i18n:cc.Joint2D')
Expand Down Expand Up @@ -104,11 +104,17 @@ export class RelativeJoint2D extends Joint2D {
get linearOffset (): Vec2 {
if (this._autoCalcOffset) {
if (this.connectedBody) {
return Vec2.subtract(this._linearOffset, this.connectedBody.node.worldPosition as IVec2Like,
this.node.worldPosition as IVec2Like) as Vec2;
return Vec2.subtract(
this._linearOffset,
this.connectedBody.node.worldPosition as IVec2Like,
this.node.worldPosition as IVec2Like,
) as Vec2;
} else { //if connected body is not set, use scene origin as connected body
return Vec2.subtract(this._linearOffset, new Vec2(0, 0),
this.node.worldPosition as IVec2Like) as Vec2;
return Vec2.subtract(
this._linearOffset,
new Vec2(0, 0),
this.node.worldPosition as IVec2Like,
) as Vec2;
}
}
return this._linearOffset;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { Vec2, IVec2Like, toDegree, _decorator, CCFloat, CCBoolean } from '../..
import { help, serializable, tooltip, type } from '../../../../core/data/decorators';

const tempVec2 = new Vec2();
const { ccclass, menu, property } = _decorator;
const { ccclass, menu } = _decorator;

@ccclass('cc.SliderJoint2D')
@help('i18n:cc.Joint2D')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { EJoint2DType } from '../../physics-types';
import { CCBoolean, CCFloat, Vec3, _decorator } from '../../../../core';
import { help, serializable, tooltip, type } from '../../../../core/data/decorators';

const { ccclass, property, menu } = _decorator;
const { ccclass, menu } = _decorator;

@ccclass('cc.SpringJoint2D')
@help('i18n:cc.Joint2D')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { IWheelJoint } from '../../../spec/i-physics-joint';
import { EJoint2DType } from '../../physics-types';
import { help, serializable, tooltip, type } from '../../../../core/data/decorators';

const { ccclass, menu, property } = _decorator;
const { ccclass, menu } = _decorator;

@ccclass('cc.WheelJoint2D')
@help('i18n:cc.Joint2D')
Expand Down
2 changes: 1 addition & 1 deletion cocos/physics-2d/framework/components/rigid-body-2d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import { PhysicsGroup } from '../../../physics/framework/physics-enum';
import { Component } from '../../../scene-graph';
import { help, serializable, tooltip } from '../../../core/data/decorators';

const { property, type, menu, ccclass } = _decorator;
const { type, menu, ccclass } = _decorator;

@ccclass('cc.RigidBody2D')
@help('i18n:cc.RigidBody2D')
Expand Down
2 changes: 1 addition & 1 deletion cocos/physics/bullet/bullet-world.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import { TriggerEventObject, CollisionEventObject, CC_V3_0, CC_V3_1, CC_V3_2, CC
import { bullet2CocosVec3, cocos2BulletQuat, cocos2BulletVec3 } from './bullet-utils';
import { IRaycastOptions, IPhysicsWorld } from '../spec/i-physics-world';
import { PhysicsRayResult, PhysicsMaterial, CharacterControllerContact, EPhysicsDrawFlags } from '../framework';
import { error, RecyclePool, Vec3, js, IVec3Like, geometry, IQuatLike, Quat, Color } from '../../core';
import { error, RecyclePool, Vec3, js, IVec3Like, geometry, IQuatLike, Quat } from '../../core';
import { BulletContactData } from './bullet-contact-data';
import { BulletConstraint } from './constraints/bullet-constraint';
import { BulletCharacterController } from './character-controllers/bullet-character-controller';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*/

import { error, IVec3Like, Vec3 } from '../../../core';
import { CharacterControllerContact, PhysicsSystem } from '../../framework';
import { PhysicsSystem } from '../../framework';
import { CharacterController } from '../../framework/components/character-controllers/character-controller';
import { IBaseCharacterController } from '../../spec/i-character-controller';
import { BulletCache } from '../bullet-cache';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import { BulletConstraint } from './bullet-constraint';
import { IConfigurableConstraint } from '../../spec/i-physics-constraint';
import { error, IVec3Like, Mat4, Quat, Vec3, toRadian } from '../../../core';
import { ConfigurableConstraint, EConstraintMode, EConstraintType, EDriverMode, PhysicsSystem } from '../../framework';
import { ConfigurableConstraint, EConstraintMode, EDriverMode, PhysicsSystem } from '../../framework';
import { bt } from '../instantiated';
import { BulletRigidBody } from '../bullet-rigid-body';
import { BulletCache, CC_QUAT_0, CC_QUAT_1, CC_V3_0, CC_MAT4_0, CC_V3_1 } from '../bullet-cache';
Expand Down
4 changes: 2 additions & 2 deletions cocos/physics/bullet/constraints/bullet-fixed-constraint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
/* eslint-disable new-cap */
import { BulletConstraint } from './bullet-constraint';
import { IFixedConstraint } from '../../spec/i-physics-constraint';
import { Quat, Vec3, Mat4 } from '../../../core';
import { FixedConstraint, PhysicsSystem } from '../../framework';
import { Mat4 } from '../../../core';
import { FixedConstraint } from '../../framework';
import { BulletRigidBody } from '../bullet-rigid-body';
import { BulletCache, CC_MAT4_0, CC_QUAT_0, CC_V3_0 } from '../bullet-cache';
import { bt } from '../instantiated';
Expand Down
1 change: 0 additions & 1 deletion cocos/physics/bullet/shapes/bullet-trimesh-shape.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/

import { BulletShape } from './bullet-shape';
import { warnID } from '../../../core';
import { Mesh } from '../../../3d/assets';
import { MeshCollider } from '../../../../exports/physics-framework';
import { cocos2BulletVec3, cocos2BulletTriMesh } from '../bullet-utils';
Expand Down
2 changes: 0 additions & 2 deletions cocos/physics/cannon/constraints/cannon-constraint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ import CANNON from '@cocos/cannon';
import { IBaseConstraint } from '../../spec/i-physics-constraint';
import { Constraint, RigidBody } from '../../framework';
import { CannonRigidBody } from '../cannon-rigid-body';
import { getWrap } from '../../utils/util';
import { CannonSharedBody } from '../cannon-shared-body';

(CANNON.World as any).staticBody = new CANNON.Body();
(CANNON.World as any).idToConstraintMap = {};
Expand Down
1 change: 0 additions & 1 deletion cocos/physics/cannon/constraints/cannon-lock-constraint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/

import CANNON from '@cocos/cannon';
import { IVec3Like, Vec3 } from '../../../core';
import { FixedConstraint } from '../../framework';
import { IFixedConstraint } from '../../spec/i-physics-constraint';
import { CannonConstraint } from './cannon-constraint';
Expand Down
1 change: 0 additions & 1 deletion cocos/physics/cocos/builtin-world.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import { BuiltinRigidBody } from './builtin-rigid-body';
import { Node } from '../../scene-graph';
import { GeometryRenderer } from '../../rendering/geometry-renderer';
import { director } from '../../game';
import { VEC3_0 } from '../utils/util';

const hitPoint = new Vec3();
const TriggerEventObject = {
Expand Down
2 changes: 1 addition & 1 deletion cocos/physics/framework/assets/physics-material.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

// @ts-check

import { ccclass, editable, help, menu, range, serializable, type } from 'cc.decorator';
import { ccclass, editable, range, serializable, type } from 'cc.decorator';
import { Asset } from '../../../asset/assets/asset';
import { CCFloat, math } from '../../../core';

Expand Down
Loading

0 comments on commit a4f3778

Please sign in to comment.