Release Healer Man 0.1.34
This commit is contained in:
1 parent
05b25c4341
commit
46c272f889
19 files changed
+568
-121
No files matched your search
@@ -1,5 +1,6 @@
|
||||
import { BufferGeometry, Float32BufferAttribute, type Group, type Mesh } from "three";
|
||||
import type { DungeonNavigationLink } from "./dungeonTypes";
|
||||
import type { DungeonNavigationLink, DungeonTraversalRamp } from "./dungeonTypes";
|
||||
import { bridgeDungeonStairNavigation, smoothDungeonStairGeometry } from "./dungeonTraversalRamps";
|
||||
import {
|
||||
buildPartyNavigationGraph,
|
||||
type PartyNavigationGraph,
|
||||
@@ -9,14 +10,18 @@ import { MAX_SYNCHRONOUS_PARTY_NAVIGATION_TRIANGLES } from "./partyNavigationPol
|
||||
const MAX_CACHED_NAVIGATION_GRAPHS = 8;
|
||||
const graphCache = new Map<string, PartyNavigationGraph>();
|
||||
|
||||
function graphCacheKey(url: string, offMeshLinks: readonly DungeonNavigationLink[]): string {
|
||||
function graphCacheKey(
|
||||
url: string,
|
||||
offMeshLinks: readonly DungeonNavigationLink[],
|
||||
ramps: readonly DungeonTraversalRamp[],
|
||||
): string {
|
||||
const links = offMeshLinks.map((link) => [
|
||||
link.id,
|
||||
link.start,
|
||||
link.end,
|
||||
link.bidirectional,
|
||||
]);
|
||||
return `${url}:${JSON.stringify(links)}`;
|
||||
return `${url}:${JSON.stringify([links, ramps])}`;
|
||||
}
|
||||
|
||||
function navigationGeometry(scene: Group): BufferGeometry {
|
||||
@@ -54,8 +59,9 @@ export function preparePartyNavigationGraph(
|
||||
url: string,
|
||||
scene: Group,
|
||||
offMeshLinks: readonly DungeonNavigationLink[],
|
||||
ramps: readonly DungeonTraversalRamp[] = [],
|
||||
): PartyNavigationGraph {
|
||||
const cacheKey = graphCacheKey(url, offMeshLinks);
|
||||
const cacheKey = graphCacheKey(url, offMeshLinks, ramps);
|
||||
const cached = graphCache.get(cacheKey);
|
||||
if (cached) {
|
||||
graphCache.delete(cacheKey);
|
||||
@@ -66,9 +72,15 @@ export function preparePartyNavigationGraph(
|
||||
const geometry = navigationGeometry(scene);
|
||||
let graph: PartyNavigationGraph;
|
||||
try {
|
||||
if (ramps.length) {
|
||||
// Recast normally lifts its walkable surface slightly above collision.
|
||||
smoothDungeonStairGeometry(geometry, ramps, 0.05);
|
||||
bridgeDungeonStairNavigation(geometry, ramps, 0.05);
|
||||
}
|
||||
const bridgedLinks = new Set(ramps.map((ramp) => ramp.navigationBridge.linkId));
|
||||
graph = buildPartyNavigationGraph(geometry, {
|
||||
maxSourceTriangles: MAX_SYNCHRONOUS_PARTY_NAVIGATION_TRIANGLES,
|
||||
offMeshLinks,
|
||||
offMeshLinks: offMeshLinks.filter((link) => !bridgedLinks.has(link.id)),
|
||||
});
|
||||
} finally {
|
||||
geometry.dispose();
|
||||
|
||||
Reference in new issue
Block a user