Skip to content

Commit

Permalink
Rename velocity multiplier
Browse files Browse the repository at this point in the history
  • Loading branch information
Sopiro committed Jul 27, 2024
1 parent 5e3e7f8 commit 153b5c6
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ <h5 class="modal-title" id="exampleModalLabel">How to use</h5>
- Drag to create box
</div>
<div class="row">
- Drag the box to move
- Drag box to move
</div>
<div class="row">
- Right click or wheel drag to remove box
Expand Down Expand Up @@ -95,7 +95,7 @@ <h5 class="modal-title" id="exampleModalLabel">How to use</h5>
</div>

<div class="row">
<label for="margin" class="form-label col-9 p-0 m-0">AABB multiplier</label>
<label for="margin" class="form-label col-9 p-0 m-0">Velocity multiplier</label>
<div class="col text-end p-0 m-0" id="multiplier_label">0</div>
<input type="range" class="form-range " id="multiplier">
</div>
Expand Down
2 changes: 1 addition & 1 deletion out/aabbtree.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class AABBTree {
return false;
}
let enlargedAABB = newAABB.copy();
let d = displacement.mul(Settings.aabbMultiplier);
let d = displacement.mul(Settings.velocityMultiplier);
if (d.x > 0.0) {
enlargedAABB.max.x += d.x;
}
Expand Down
6 changes: 3 additions & 3 deletions out/game.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ export class Game {
let nSquared = (this.entityCount * this.entityCount - this.entityCount) / 2.0;
let bvh = nSquared / debugCount;
this.efficiencyCheckLabel.innerHTML = "Box count: " + this.entityCount + "<br>"
+ "BruteForce: " + nSquared + "<br>"
+ "Dynamic BVH: " + debugCount + "<br>"
+ "Dynamic BVH is " + (isNaN(bvh) ? "0" : bvh.toFixed(2)) + " times more efficient";
+ "- BruteForce: " + nSquared + "<br>"
+ "- Dynamic BVH: " + debugCount + "<br>"
+ "Dynamic BVH is " + (isNaN(bvh) ? "0" : bvh.toFixed(2)) + "\n times more efficient";
}
handleInput(delta) {
const mx = Input.isKeyDown("ArrowLeft") ? -1 : Input.isKeyDown("ArrowRight") ? 1 : 0;
Expand Down
10 changes: 5 additions & 5 deletions out/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ export const Settings = {
genSpeed: 50,
colorize: true,
applyRotation: true,
// These two options are actually tree member variables..
// These two options are actually a tree member variables..
aabbMargin: 0.1,
aabbMultiplier: 4.0,
velocityMultiplier: 3.0,
};
// Remove the default pop-up context menu
let cvs = document.querySelector("#canvas");
Expand Down Expand Up @@ -66,9 +66,9 @@ margin.addEventListener("input", () => {
updateSetting("margin", mappedValue);
});
const multiplier = document.querySelector("#multiplier");
multiplier.value = String(Util.map(Settings.aabbMultiplier, multiplierRange.p1, multiplierRange.p2, 0, 100));
multiplier.value = String(Util.map(Settings.velocityMultiplier, multiplierRange.p1, multiplierRange.p2, 0, 100));
const multiplierLabel = document.querySelector("#multiplier_label");
multiplierLabel.innerHTML = String(Settings.aabbMultiplier);
multiplierLabel.innerHTML = String(Settings.velocityMultiplier);
multiplier.addEventListener("input", () => {
let mappedValue = Util.map(Number(multiplier.value), 0, 100, multiplierRange.p1, multiplierRange.p2);
mappedValue = Math.trunc(mappedValue);
Expand All @@ -95,7 +95,7 @@ export function updateSetting(id, content) {
case "margin":
Settings.aabbMargin = content;
case "multiplier":
Settings.aabbMultiplier = content;
Settings.velocityMultiplier = content;
default:
break;
}
Expand Down
2 changes: 1 addition & 1 deletion src/aabbtree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export class AABBTree
}

let enlargedAABB = newAABB.copy();
let d = displacement.mul(Settings.aabbMultiplier);
let d = displacement.mul(Settings.velocityMultiplier);

if (d.x > 0.0)
{
Expand Down
6 changes: 3 additions & 3 deletions src/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ export class Game
let bvh = nSquared / debugCount;

this.efficiencyCheckLabel.innerHTML = "Box count: " + this.entityCount + "<br>"
+ "BruteForce: " + nSquared + "<br>"
+ "Dynamic BVH: " + debugCount + "<br>"
+ "Dynamic BVH is " + (isNaN(bvh) ? "0" : bvh.toFixed(2)) + " times more efficient";
+ "- BruteForce: " + nSquared + "<br>"
+ "- Dynamic BVH: " + debugCount + "<br>"
+ "Dynamic BVH is " + (isNaN(bvh) ? "0" : bvh.toFixed(2)) + "\n times more efficient";
}

private handleInput(delta: number): void
Expand Down
10 changes: 5 additions & 5 deletions src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ export const Settings = {
genSpeed: 50,
colorize: true,
applyRotation: true,
// These two options are actually tree member variables..
// These two options are actually a tree member variables..
aabbMargin: 0.1,
aabbMultiplier: 4.0,
velocityMultiplier: 3.0,
}

// Remove the default pop-up context menu
Expand Down Expand Up @@ -82,9 +82,9 @@ margin.addEventListener("input", () =>
});

const multiplier = document.querySelector("#multiplier")! as HTMLInputElement;
multiplier.value = String(Util.map(Settings.aabbMultiplier, multiplierRange.p1, multiplierRange.p2, 0, 100));
multiplier.value = String(Util.map(Settings.velocityMultiplier, multiplierRange.p1, multiplierRange.p2, 0, 100));
const multiplierLabel = document.querySelector("#multiplier_label")! as HTMLLabelElement;
multiplierLabel.innerHTML = String(Settings.aabbMultiplier);
multiplierLabel.innerHTML = String(Settings.velocityMultiplier);
multiplier.addEventListener("input", () =>
{
let mappedValue = Util.map(Number(multiplier.value), 0, 100, multiplierRange.p1, multiplierRange.p2);
Expand Down Expand Up @@ -118,7 +118,7 @@ export function updateSetting(id: string, content?: any)
case "margin":
Settings.aabbMargin = content!;
case "multiplier":
Settings.aabbMultiplier = content!;
Settings.velocityMultiplier = content!;
default:
break;
}
Expand Down

0 comments on commit 153b5c6

Please sign in to comment.