Skip to content

Commit

Permalink
tweaek
Browse files Browse the repository at this point in the history
  • Loading branch information
lealzhan committed Sep 25, 2023
1 parent d36b3f8 commit d467c34
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions cocos/physics/cannon/cannon-world.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import { GeometryRenderer } from '../../rendering/geometry-renderer';
import { director } from '../../game';

const aabbTemp = new geometry.AABB();
const AABB_LINE_COUNT = 12;

export class CannonWorld implements IPhysicsWorld {
get impl (): CANNON.World {
Expand Down Expand Up @@ -286,8 +287,8 @@ export class CannonWorld implements IPhysicsWorld {
const body = this.bodies[i];
for (let j = 0; j < body.wrappedShapes.length; j++) {
const shape = body.wrappedShapes[j];
if (this._debugLineCount + 12 < this._MAX_DEBUG_LINE_COUNT) {
this._debugLineCount += 12;
if (this._debugLineCount + AABB_LINE_COUNT < this._MAX_DEBUG_LINE_COUNT) {
this._debugLineCount += AABB_LINE_COUNT;
shape.getAABB(aabbTemp);
debugRenderer.addBoundingBox(aabbTemp, this._aabbColor);
}
Expand Down
5 changes: 3 additions & 2 deletions cocos/physics/cocos/builtin-world.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const TriggerEventObject = {
};

const aabbTemp = new geometry.AABB();
const AABB_LINE_COUNT = 12;

/**
* Built-in collision system, intended for use as a
Expand Down Expand Up @@ -355,8 +356,8 @@ export class BuiltInWorld implements IPhysicsWorld {
const body = this.bodies[i];
for (let j = 0; j < body.shapes.length; j++) {
const shape = body.shapes[j];
if (this._debugLineCount + 12 < this._MAX_DEBUG_LINE_COUNT) {
this._debugLineCount += 12;
if (this._debugLineCount + AABB_LINE_COUNT < this._MAX_DEBUG_LINE_COUNT) {
this._debugLineCount += AABB_LINE_COUNT;
shape.getAABB(aabbTemp);
debugRenderer.addBoundingBox(aabbTemp, this._aabbColor);
}
Expand Down

0 comments on commit d467c34

Please sign in to comment.