Skip to content

Commit

Permalink
Remove md5 and use xxHash128 for hashing algorithm in debug infos (#297)
Browse files Browse the repository at this point in the history
  • Loading branch information
Paulo-21 authored Dec 9, 2024
1 parent 50223ff commit 5c6f9cd
Show file tree
Hide file tree
Showing 16 changed files with 1,289 additions and 3,985 deletions.
832 changes: 416 additions & 416 deletions CHANGELOG.md

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions rapier-compat/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# tsconfig,json files:

- tsconfig.common.json - shared TypeScript options
- tsconfig.pkg2d.json - config for compiling rapier2d-compat
- tsconfig.pkg3d.json - config for compiling rapier3d-compat
- tconfig.json - for IDE (VSCode) and unit tests. Includes Jest types.
- tsconfig.common.json - shared TypeScript options
- tsconfig.pkg2d.json - config for compiling rapier2d-compat
- tsconfig.pkg3d.json - config for compiling rapier3d-compat
- tconfig.json - for IDE (VSCode) and unit tests. Includes Jest types.
2 changes: 1 addition & 1 deletion rapier2d/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion rapier2d/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
"dependencies": {
"wasm-pack": "^0.12.1"
}
}
}
2 changes: 1 addition & 1 deletion rapier3d/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion rapier3d/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
"dependencies": {
"wasm-pack": "^0.12.1"
}
}
}
85 changes: 15 additions & 70 deletions testbed2d/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions testbed2d/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@
},
"dependencies": {
"@dimforge/rapier2d": "file:../rapier2d",
"hash-wasm": "^4.12.0",
"lil-gui": "^0.17.0",
"md5": "^2.3.0",
"pixi-viewport": "^4.37.0",
"pixi.js": "^6.3.2",
"seedrandom": "^3.0.5",
"stats.js": "^0.17.0"
},
"devDependencies": {
"@types/md5": "^2.3.2",
"@types/seedrandom": "^3.0.2",
"@types/stats.js": "^0.17.0",
"copy-webpack-plugin": "^11.0.0",
Expand Down
8 changes: 6 additions & 2 deletions testbed2d/src/Gui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,12 @@ export class Gui {
text += "<br/>[Step " + infos.stepId + "]";

if (infos.worldHash) {
text += "<br/>World hash (MD5): " + infos.worldHash.toString();
text += "<br/>World hash time (MD5): " + infos.worldHashTime + "ms";
text +=
"<br/>World hash (xxHash128): " + infos.worldHash.toString();
text +=
"<br/>World hash time (xxHash128): " +
infos.worldHashTime +
"ms";
text += "<br/>Snapshot time: " + infos.snapshotTime + "ms";
}
this.debugText.innerHTML = text;
Expand Down
18 changes: 9 additions & 9 deletions testbed2d/src/Testbed.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {Graphics} from "./Graphics";
import {Gui} from "./Gui";
import type {DebugInfos} from "./Gui";
import * as md5 from "md5";
import {xxhash128} from "hash-wasm";
import type * as RAPIER from "@dimforge/rapier2d";

type RAPIER_API = typeof import("@dimforge/rapier2d");
Expand Down Expand Up @@ -164,14 +164,14 @@ export class Testbed {
snapshotTime: 0,
};
t0 = performance.now();
debugInfos.worldHash = md5(snapshot);
t1 = performance.now();
let worldHashTime = t1 - t0;

debugInfos.worldHashTime = worldHashTime;
debugInfos.snapshotTime = snapshotTime;

this.gui.setDebugInfos(debugInfos);
xxhash128(snapshot).then((hash) => {
debugInfos.worldHash = hash;
t1 = performance.now();
let worldHashTime = t1 - t0;
debugInfos.worldHashTime = worldHashTime;
debugInfos.snapshotTime = snapshotTime;
this.gui.setDebugInfos(debugInfos);
});
}
}

Expand Down
2 changes: 1 addition & 1 deletion testbed2d/static/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
Expand Down
Loading

0 comments on commit 5c6f9cd

Please sign in to comment.