新增physics.debugDraw默认绘制

This commit is contained in:
yhh
2021-05-28 15:45:45 +08:00
parent 28145e876f
commit 8b7baf7f86
6 changed files with 13 additions and 20 deletions
+2 -6
View File
@@ -3392,12 +3392,8 @@ declare module es {
*/ */
cellAtPosition(x: number, y: number, createCellIfEmpty?: boolean): Collider[]; cellAtPosition(x: number, y: number, createCellIfEmpty?: boolean): Collider[];
} }
/**
* 包装一个Unit32,列表碰撞器字典
* 它的主要目的是将int、int x、y坐标散列到单个Uint32键中,使用O(1)查找。
*/
class NumberDictionary { class NumberDictionary {
_store: Map<number, Collider[]>; _store: Map<string, Collider[]>;
add(x: number, y: number, list: Collider[]): void; add(x: number, y: number, list: Collider[]): void;
/** /**
* 使用蛮力方法从字典存储列表中移除碰撞器 * 使用蛮力方法从字典存储列表中移除碰撞器
@@ -3405,7 +3401,7 @@ declare module es {
*/ */
remove(obj: Collider): void; remove(obj: Collider): void;
tryGetValue(x: number, y: number): Collider[]; tryGetValue(x: number, y: number): Collider[];
getKey(x: number, y: number): number; getKey(x: number, y: number): string;
/** /**
* 清除字典数据 * 清除字典数据
*/ */
+4 -6
View File
@@ -5542,6 +5542,7 @@ var es;
entity.debugRender(es.Graphics.instance.batcher); entity.debugRender(es.Graphics.instance.batcher);
} }
} }
es.Physics.debugDraw(2);
}; };
return Renderer; return Renderer;
}()); }());
@@ -5566,8 +5567,9 @@ var es;
if (renderable.enabled && renderable.isVisibleFromCamera(scene.camera)) if (renderable.enabled && renderable.isVisibleFromCamera(scene.camera))
this.renderAfterStateCheck(renderable, cam); this.renderAfterStateCheck(renderable, cam);
} }
if (this.shouldDebugRender && es.Core.debugRenderEndabled) if (this.shouldDebugRender && es.Core.debugRenderEndabled) {
this.debugRender(scene); this.debugRender(scene);
}
this.endRender(); this.endRender();
}; };
return DefaultRenderer; return DefaultRenderer;
@@ -8300,10 +8302,6 @@ var es;
return SpatialHash; return SpatialHash;
}()); }());
es.SpatialHash = SpatialHash; es.SpatialHash = SpatialHash;
/**
* 包装一个Unit32列表碰撞器字典
* 它的主要目的是将intint xy坐标散列到单个Uint32键中使用O(1)查找
*/
var NumberDictionary = /** @class */ (function () { var NumberDictionary = /** @class */ (function () {
function NumberDictionary() { function NumberDictionary() {
this._store = new Map(); this._store = new Map();
@@ -8326,7 +8324,7 @@ var es;
return this._store.get(this.getKey(x, y)); return this._store.get(this.getKey(x, y));
}; };
NumberDictionary.prototype.getKey = function (x, y) { NumberDictionary.prototype.getKey = function (x, y) {
return x << 16 | (y >>> 0); return x + "_" + y;
}; };
/** /**
* 清除字典数据 * 清除字典数据
+1 -1
View File
File diff suppressed because one or more lines are too long
@@ -15,8 +15,9 @@ module es {
this.renderAfterStateCheck(renderable, cam); this.renderAfterStateCheck(renderable, cam);
} }
if (this.shouldDebugRender && es.Core.debugRenderEndabled) if (this.shouldDebugRender && es.Core.debugRenderEndabled) {
this.debugRender(scene); this.debugRender(scene);
}
this.endRender(); this.endRender();
} }
@@ -34,6 +34,8 @@ module es {
entity.debugRender(Graphics.instance.batcher); entity.debugRender(Graphics.instance.batcher);
} }
} }
es.Physics.debugDraw(2);
} }
} }
} }
+2 -6
View File
@@ -323,12 +323,8 @@ module es {
} }
} }
/**
* Unit32
* intint xy坐标散列到单个Uint32键中使O(1)
*/
export class NumberDictionary { export class NumberDictionary {
public _store: Map<number, Collider[]> = new Map<number, Collider[]>(); public _store: Map<string, Collider[]> = new Map<string, Collider[]>();
public add(x: number, y: number, list: Collider[]) { public add(x: number, y: number, list: Collider[]) {
this._store.set(this.getKey(x, y), list); this._store.set(this.getKey(x, y), list);
@@ -351,7 +347,7 @@ module es {
} }
public getKey(x: number, y: number){ public getKey(x: number, y: number){
return x << 16 | (y >>> 0); return `${x}_${y}`;
} }
/** /**