Skip to content

Commit

Permalink
feat: expose duDebugDraw debug drawing utilities
Browse files Browse the repository at this point in the history
  • Loading branch information
isaac-mason committed Apr 24, 2024
1 parent c1fca72 commit 01e41fd
Show file tree
Hide file tree
Showing 28 changed files with 1,092 additions and 480 deletions.
6 changes: 6 additions & 0 deletions .changeset/mighty-birds-kneel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@recast-navigation/generators": minor
"recast-navigation": minor
---

feat: expose and correctly cleanup polyMesh and polyMeshDetail
8 changes: 8 additions & 0 deletions .changeset/wild-plums-design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@recast-navigation/three": minor
"@recast-navigation/core": minor
"@recast-navigation/wasm": minor
"recast-navigation": minor
---

feat: expose duDebugDraw recast and detour debug drawing utilities
214 changes: 95 additions & 119 deletions apps/navmesh-website/src/features/controls/controls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { button, useControls } from 'leva';
import { levaText } from './leva-text';
import { NavMesh } from 'recast-navigation';
import { useState } from 'react';
import { DebugDrawerOption } from '../recast';

export const useActionsControls = ({
navMesh,
Expand Down Expand Up @@ -34,84 +35,87 @@ export const useActionsControls = ({
};

export const useNavMeshGenerationControls = () => {
const { keepIntermediates, ...navMeshConfig } = useControls('NavMesh Generation Config', {
cs: {
label: 'Cell Size',
value: 0.2,
},
ch: {
label: 'Cell Height',
value: 0.2,
},
tileSize: {
label: 'Tile Size',
value: 0,
step: 1,
},
borderSize: {
label: 'Border Size',
value: 0,
},
walkableSlopeAngle: {
label: 'Walkable Slope Angle',
value: 60,
},
walkableHeight: {
label: 'Walkable Height',
value: 2,
},
walkableClimb: {
label: 'Walkable Climb',
value: 2,
},
walkableRadius: {
label: 'Walkable Radius',
value: 1,
},
maxEdgeLen: {
label: 'Max Edge Length',
value: 12,
},
maxSimplificationError: {
label: 'Max Simplification Error',
value: 1.3,
},
minRegionArea: {
label: 'Min Region Area',
value: 8,
},
mergeRegionArea: {
label: 'Merge Region Area',
value: 20,
},
maxVertsPerPoly: {
label: 'Max Verts Per Poly',
value: 6,
step: 1,
},
detailSampleDist: {
label: 'Detail Sample Dist',
value: 6,
},
detailSampleMaxError: {
label: 'Detail Sample Max Error',
value: 1,
},
expectedLayersPerTile: {
label: 'Expected Layers Per Tile',
value: 4,
step: 1,
},
maxLayers: {
label: 'Max Layers',
value: 32,
step: 1,
},
keepIntermediates: {
label: 'Keep Intermediates',
value: true,
},
});
const { keepIntermediates, ...navMeshConfig } = useControls(
'NavMesh Generation Config',
{
cs: {
label: 'Cell Size',
value: 0.2,
},
ch: {
label: 'Cell Height',
value: 0.2,
},
tileSize: {
label: 'Tile Size',
value: 0,
step: 1,
},
borderSize: {
label: 'Border Size',
value: 0,
},
walkableSlopeAngle: {
label: 'Walkable Slope Angle',
value: 60,
},
walkableHeight: {
label: 'Walkable Height',
value: 2,
},
walkableClimb: {
label: 'Walkable Climb',
value: 2,
},
walkableRadius: {
label: 'Walkable Radius',
value: 1,
},
maxEdgeLen: {
label: 'Max Edge Length',
value: 12,
},
maxSimplificationError: {
label: 'Max Simplification Error',
value: 1.3,
},
minRegionArea: {
label: 'Min Region Area',
value: 8,
},
mergeRegionArea: {
label: 'Merge Region Area',
value: 20,
},
maxVertsPerPoly: {
label: 'Max Verts Per Poly',
value: 6,
step: 1,
},
detailSampleDist: {
label: 'Detail Sample Dist',
value: 6,
},
detailSampleMaxError: {
label: 'Detail Sample Max Error',
value: 1,
},
expectedLayersPerTile: {
label: 'Expected Layers Per Tile',
value: 4,
step: 1,
},
maxLayers: {
label: 'Max Layers',
value: 32,
step: 1,
},
keepIntermediates: {
label: 'Keep Intermediates',
value: true,
},
}
);

useControls('NavMesh Generation Config.Tips', {
_: levaText(
Expand Down Expand Up @@ -166,58 +170,30 @@ export const useDisplayOptionsControls = () => {
},
});

const [navMeshHelperDebugColor, setNavMeshHelperDebugColor] =
useState('#ffa500');

const {
opacity: navMeshDebugOpacity,
wireframe: navMeshDebugWireframe,
displayNavMeshHelper,
} = useControls('Display Options.NavMesh', {
_: levaText('The computed navigation mesh.'),
displayNavMeshHelper: {
label: 'Show NavMesh',
value: true,
},
color: {
label: 'Color',
value: navMeshHelperDebugColor,
onEditEnd: setNavMeshHelperDebugColor,
},
opacity: {
label: 'Opacity',
value: 0.65,
min: 0,
max: 1,
},
wireframe: {
label: 'Wireframe',
value: false,
},
});

const { heightfieldHelperEnabled } = useControls(
'Display Options.Heightfield',
const { navMeshDebugDraw, navMeshDebugDrawOption } = useControls(
'Display Options.NavMesh',
{
_: levaText("Visualises Recast's voxelization process. Note that 'Keep Intermediates' must be checked."),
heightfieldHelperEnabled: {
value: false,
label: 'Show Heightfield',
_: levaText('The computed navigation mesh.'),
navMeshDebugDraw: {
label: 'Show NavMesh Debug Drawer',
value: true,
},
navMeshDebugDrawOption: {
label: 'Display',
value: 'navmesh',
options: Object.values(DebugDrawerOption),
},
}
);

return {
displayModel,
heightfieldHelperEnabled,
navMeshGeneratorInputDebugColor,
displayNavMeshGenerationInput,
navMeshGeneratorInputWireframe,
navMeshGeneratorInputOpacity,
navMeshHelperDebugColor,
navMeshDebugOpacity,
navMeshDebugWireframe,
displayNavMeshHelper,
navMeshDebugDraw,
navMeshDebugDrawOption,
};
};

Expand Down

This file was deleted.

Loading

0 comments on commit 01e41fd

Please sign in to comment.