Skip to content

Commit

Permalink
feat: feat(NavMeshQuery): don't return 'polyCount' from queryPolygons…
Browse files Browse the repository at this point in the history
…, only incldue 'polyRefs' from 0 to 'polyCount'
  • Loading branch information
isaac-mason committed Nov 30, 2024
1 parent bb3e49a commit 753e4e2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/gold-hotels-cough.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@recast-navigation/core': minor
---

feat(NavMeshQuery): don't return 'polyCount' from queryPolygons, only incldue 'polyRefs' from 0 to 'polyCount'
3 changes: 1 addition & 2 deletions packages/recast-navigation-core/src/nav-mesh-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,14 +292,13 @@ export class NavMeshQuery {
const polyCount = polyCountRef.value;
Raw.destroy(polyCountRef);

const polyRefs = [...polysRefsArray.getHeapView()];
const polyRefs = [...polysRefsArray.getHeapView()].slice(0, polyCount);
polysRefsArray.destroy();

return {
success: statusSucceed(status),
status,
polyRefs,
polyCount,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,7 @@ export function ClickNearbyPolygons() {
findPolysAroundCircleResult.resultCount
);
} else {
polyRefs = queryPolygonsResult.polyRefs.slice(
0,
queryPolygonsResult.polyCount
);
polyRefs = queryPolygonsResult.polyRefs;
}

const decodedPolyRefs = polyRefs.map((polyRef) =>
Expand Down Expand Up @@ -355,7 +352,7 @@ function polyRefToGeom(
*/
function range(n: number) {
return [...Array(n)].map((_, i) => i);
};
}

const navMeshMaterial = new THREE.MeshBasicMaterial({
wireframe: true,
Expand Down

0 comments on commit 753e4e2

Please sign in to comment.