mirror of
https://github.com/recastnavigation/recastnavigation.git
synced 2026-11-18 13:56:00 +00:00
Refactored sample code. Separated navmesh test code to a tool class.
This commit is contained in:
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@@ -280,14 +280,14 @@
|
||||
<key>PBXSmartGroupTreeModuleOutlineStateSelectionKey</key>
|
||||
<array>
|
||||
<array>
|
||||
<integer>38</integer>
|
||||
<integer>42</integer>
|
||||
<integer>34</integer>
|
||||
<integer>1</integer>
|
||||
<integer>0</integer>
|
||||
</array>
|
||||
</array>
|
||||
<key>PBXSmartGroupTreeModuleOutlineStateVisibleRectKey</key>
|
||||
<string>{{0, 192}, {282, 660}}</string>
|
||||
<string>{{0, 460}, {282, 660}}</string>
|
||||
</dict>
|
||||
<key>PBXTopSmartGroupGIDs</key>
|
||||
<array/>
|
||||
@@ -322,7 +322,7 @@
|
||||
<key>PBXProjectModuleGUID</key>
|
||||
<string>6B8632A30F78115100E2684A</string>
|
||||
<key>PBXProjectModuleLabel</key>
|
||||
<string>Sample_SoloMesh.cpp</string>
|
||||
<string>Sample_TileMesh.cpp</string>
|
||||
<key>PBXSplitModuleInNavigatorKey</key>
|
||||
<dict>
|
||||
<key>Split0</key>
|
||||
@@ -330,39 +330,28 @@
|
||||
<key>PBXProjectModuleGUID</key>
|
||||
<string>6B8632A40F78115100E2684A</string>
|
||||
<key>PBXProjectModuleLabel</key>
|
||||
<string>Sample_SoloMesh.cpp</string>
|
||||
<string>Sample_TileMesh.cpp</string>
|
||||
<key>_historyCapacity</key>
|
||||
<integer>0</integer>
|
||||
<key>bookmark</key>
|
||||
<string>6B98694A10DF8982007D8D84</string>
|
||||
<string>6BBB89A710EAC398008FEA1F</string>
|
||||
<key>history</key>
|
||||
<array>
|
||||
<string>6B57D358108C66B200DDD053</string>
|
||||
<string>6B7FB74D1091EBDE001BA51A</string>
|
||||
<string>6B8DE70D10B01BBF00DF20FB</string>
|
||||
<string>6B8DE76D10B0243500DF20FB</string>
|
||||
<string>6B8DE7F110B0517A00DF20FB</string>
|
||||
<string>6B8DE84910B0584400DF20FB</string>
|
||||
<string>6B8DEA3810B6CBC200DF20FB</string>
|
||||
<string>6B8DEAA110BC7BCD00DF20FB</string>
|
||||
<string>6BF2589310BE6F220061DCC9</string>
|
||||
<string>6BA1E63A10C1DB5B008007F6</string>
|
||||
<string>6BA1E7F210C7B3FF008007F6</string>
|
||||
<string>6BA1E89310C7C227008007F6</string>
|
||||
<string>6BA1E8B010C7C5D1008007F6</string>
|
||||
<string>6BA1E8DB10C7CB62008007F6</string>
|
||||
<string>6BA1E8E410C7D2FA008007F6</string>
|
||||
<string>6BA1E8F210C7D4D9008007F6</string>
|
||||
<string>6BB4964510C8ECF300BC0805</string>
|
||||
<string>6BB4965E10C8F2AE00BC0805</string>
|
||||
<string>6BB4965F10C8F2AE00BC0805</string>
|
||||
<string>6BB4966110C8F2AE00BC0805</string>
|
||||
<string>6BB4966510C8F2AE00BC0805</string>
|
||||
<string>6BB4966810C8F2AE00BC0805</string>
|
||||
<string>6BB4967C10C8F8F500BC0805</string>
|
||||
<string>6BB93CCF10CFEA7A00F74F2B</string>
|
||||
<string>6BB93CD010CFEA7A00F74F2B</string>
|
||||
<string>6BB93CD210CFEA7A00F74F2B</string>
|
||||
<string>6BB93CE710CFEB5D00F74F2B</string>
|
||||
<string>6BB93CEB10CFEB5D00F74F2B</string>
|
||||
<string>6BB93D0510CFFC1300F74F2B</string>
|
||||
@@ -370,25 +359,217 @@
|
||||
<string>6BB93D0A10CFFC1300F74F2B</string>
|
||||
<string>6BB93D1510CFFC6D00F74F2B</string>
|
||||
<string>6BB93D1B10CFFD7600F74F2B</string>
|
||||
<string>6B98692510DF824E007D8D84</string>
|
||||
<string>6B98693110DF8929007D8D84</string>
|
||||
<string>6B98693210DF8929007D8D84</string>
|
||||
<string>6B98693310DF8929007D8D84</string>
|
||||
<string>6B98693410DF8929007D8D84</string>
|
||||
<string>6B98694710DF8982007D8D84</string>
|
||||
<string>6B98694810DF8982007D8D84</string>
|
||||
<string>6B9869F710DFFA98007D8D84</string>
|
||||
<string>6B9869F810DFFA98007D8D84</string>
|
||||
<string>6BBB87D710EA97CC008FEA1F</string>
|
||||
<string>6BBB87D910EA97CC008FEA1F</string>
|
||||
<string>6BBB87DA10EA97CC008FEA1F</string>
|
||||
<string>6BBB883C10EA9B6F008FEA1F</string>
|
||||
<string>6BBB884E10EA9ECC008FEA1F</string>
|
||||
<string>6BBB889B10EAA094008FEA1F</string>
|
||||
<string>6BBB894510EAAB73008FEA1F</string>
|
||||
<string>6BBB898310EAB1AA008FEA1F</string>
|
||||
<string>6BBB898810EAB225008FEA1F</string>
|
||||
<string>6BBB898E10EABB10008FEA1F</string>
|
||||
<string>6BBB898F10EABB10008FEA1F</string>
|
||||
<string>6BBB899110EABB10008FEA1F</string>
|
||||
<string>6BBB899210EABB10008FEA1F</string>
|
||||
<string>6BBB899D10EABD34008FEA1F</string>
|
||||
<string>6BBB899E10EABD34008FEA1F</string>
|
||||
<string>6BBB899F10EABD34008FEA1F</string>
|
||||
<string>6BBB89A010EABD34008FEA1F</string>
|
||||
</array>
|
||||
<key>prevStack</key>
|
||||
<array>
|
||||
<string>6B98692710DF824E007D8D84</string>
|
||||
<string>6B98693710DF8929007D8D84</string>
|
||||
<string>6B98693810DF8929007D8D84</string>
|
||||
<string>6B98693910DF8929007D8D84</string>
|
||||
<string>6B98693A10DF8929007D8D84</string>
|
||||
<string>6B98693B10DF8929007D8D84</string>
|
||||
<string>6B98693C10DF8929007D8D84</string>
|
||||
<string>6B98693D10DF8929007D8D84</string>
|
||||
<string>6B98694910DF8982007D8D84</string>
|
||||
<string>6B9869FC10DFFA98007D8D84</string>
|
||||
<string>6BBB87E310EA97CC008FEA1F</string>
|
||||
<string>6BBB87E410EA97CC008FEA1F</string>
|
||||
<string>6BBB87E510EA97CC008FEA1F</string>
|
||||
<string>6BBB87E610EA97CC008FEA1F</string>
|
||||
<string>6BBB87E710EA97CC008FEA1F</string>
|
||||
<string>6BBB87E810EA97CC008FEA1F</string>
|
||||
<string>6BBB87E910EA97CC008FEA1F</string>
|
||||
<string>6BBB87EB10EA97CC008FEA1F</string>
|
||||
<string>6BBB87EC10EA97CC008FEA1F</string>
|
||||
<string>6BBB87EF10EA97CC008FEA1F</string>
|
||||
<string>6BBB87F010EA97CC008FEA1F</string>
|
||||
<string>6BBB87F110EA97CC008FEA1F</string>
|
||||
<string>6BBB87F410EA97CC008FEA1F</string>
|
||||
<string>6BBB87F510EA97CC008FEA1F</string>
|
||||
<string>6BBB87F610EA97CC008FEA1F</string>
|
||||
<string>6BBB87F710EA97CC008FEA1F</string>
|
||||
<string>6BBB87F810EA97CC008FEA1F</string>
|
||||
<string>6BBB87FA10EA97CC008FEA1F</string>
|
||||
<string>6BBB87FB10EA97CC008FEA1F</string>
|
||||
<string>6BBB87FC10EA97CC008FEA1F</string>
|
||||
<string>6BBB87FD10EA97CC008FEA1F</string>
|
||||
<string>6BBB87FE10EA97CC008FEA1F</string>
|
||||
<string>6BBB87FF10EA97CC008FEA1F</string>
|
||||
<string>6BBB880010EA97CC008FEA1F</string>
|
||||
<string>6BBB880110EA97CC008FEA1F</string>
|
||||
<string>6BBB880210EA97CC008FEA1F</string>
|
||||
<string>6BBB880310EA97CC008FEA1F</string>
|
||||
<string>6BBB880510EA97CC008FEA1F</string>
|
||||
<string>6BBB880610EA97CC008FEA1F</string>
|
||||
<string>6BBB880710EA97CC008FEA1F</string>
|
||||
<string>6BBB880810EA97CC008FEA1F</string>
|
||||
<string>6BBB880910EA97CC008FEA1F</string>
|
||||
<string>6BBB880A10EA97CC008FEA1F</string>
|
||||
<string>6BBB880B10EA97CC008FEA1F</string>
|
||||
<string>6BBB880C10EA97CC008FEA1F</string>
|
||||
<string>6BBB880D10EA97CC008FEA1F</string>
|
||||
<string>6BBB880E10EA97CC008FEA1F</string>
|
||||
<string>6BBB880F10EA97CC008FEA1F</string>
|
||||
<string>6BBB881010EA97CC008FEA1F</string>
|
||||
<string>6BBB881110EA97CC008FEA1F</string>
|
||||
<string>6BBB881210EA97CC008FEA1F</string>
|
||||
<string>6BBB881310EA97CC008FEA1F</string>
|
||||
<string>6BBB881410EA97CC008FEA1F</string>
|
||||
<string>6BBB881510EA97CC008FEA1F</string>
|
||||
<string>6BBB881610EA97CC008FEA1F</string>
|
||||
<string>6BBB881710EA97CC008FEA1F</string>
|
||||
<string>6BBB881810EA97CC008FEA1F</string>
|
||||
<string>6BBB882710EA99CA008FEA1F</string>
|
||||
<string>6BBB882810EA99CA008FEA1F</string>
|
||||
<string>6BBB882910EA99CA008FEA1F</string>
|
||||
<string>6BBB882A10EA99CA008FEA1F</string>
|
||||
<string>6BBB883610EA9B3D008FEA1F</string>
|
||||
<string>6BBB883710EA9B3D008FEA1F</string>
|
||||
<string>6BBB883E10EA9B6F008FEA1F</string>
|
||||
<string>6BBB883F10EA9B6F008FEA1F</string>
|
||||
<string>6BBB885510EA9ECC008FEA1F</string>
|
||||
<string>6BBB885610EA9ECC008FEA1F</string>
|
||||
<string>6BBB885710EA9ECC008FEA1F</string>
|
||||
<string>6BBB885810EA9ECC008FEA1F</string>
|
||||
<string>6BBB885910EA9ECC008FEA1F</string>
|
||||
<string>6BBB885A10EA9ECC008FEA1F</string>
|
||||
<string>6BBB885B10EA9ECC008FEA1F</string>
|
||||
<string>6BBB885C10EA9ECC008FEA1F</string>
|
||||
<string>6BBB885D10EA9ECC008FEA1F</string>
|
||||
<string>6BBB885E10EA9ECC008FEA1F</string>
|
||||
<string>6BBB885F10EA9ECC008FEA1F</string>
|
||||
<string>6BBB886010EA9ECC008FEA1F</string>
|
||||
<string>6BBB886110EA9ECC008FEA1F</string>
|
||||
<string>6BBB886210EA9ECC008FEA1F</string>
|
||||
<string>6BBB886310EA9ECC008FEA1F</string>
|
||||
<string>6BBB886410EA9ECC008FEA1F</string>
|
||||
<string>6BBB886510EA9ECC008FEA1F</string>
|
||||
<string>6BBB886610EA9ECC008FEA1F</string>
|
||||
<string>6BBB886710EA9ECC008FEA1F</string>
|
||||
<string>6BBB886810EA9ECC008FEA1F</string>
|
||||
<string>6BBB886910EA9ECC008FEA1F</string>
|
||||
<string>6BBB886A10EA9ECC008FEA1F</string>
|
||||
<string>6BBB886B10EA9ECC008FEA1F</string>
|
||||
<string>6BBB886C10EA9ECC008FEA1F</string>
|
||||
<string>6BBB886D10EA9ECC008FEA1F</string>
|
||||
<string>6BBB886E10EA9ECC008FEA1F</string>
|
||||
<string>6BBB886F10EA9ECC008FEA1F</string>
|
||||
<string>6BBB887010EA9ECC008FEA1F</string>
|
||||
<string>6BBB887110EA9ECC008FEA1F</string>
|
||||
<string>6BBB887210EA9ECC008FEA1F</string>
|
||||
<string>6BBB887310EA9ECC008FEA1F</string>
|
||||
<string>6BBB887410EA9ECC008FEA1F</string>
|
||||
<string>6BBB887E10EA9FE6008FEA1F</string>
|
||||
<string>6BBB887F10EA9FE6008FEA1F</string>
|
||||
<string>6BBB888010EA9FE6008FEA1F</string>
|
||||
<string>6BBB888110EA9FE6008FEA1F</string>
|
||||
<string>6BBB888210EA9FE6008FEA1F</string>
|
||||
<string>6BBB888310EA9FE6008FEA1F</string>
|
||||
<string>6BBB888410EA9FE6008FEA1F</string>
|
||||
<string>6BBB889610EAA050008FEA1F</string>
|
||||
<string>6BBB889D10EAA094008FEA1F</string>
|
||||
<string>6BBB88B410EAA316008FEA1F</string>
|
||||
<string>6BBB88B510EAA316008FEA1F</string>
|
||||
<string>6BBB88B610EAA316008FEA1F</string>
|
||||
<string>6BBB88B710EAA316008FEA1F</string>
|
||||
<string>6BBB88B810EAA316008FEA1F</string>
|
||||
<string>6BBB88B910EAA316008FEA1F</string>
|
||||
<string>6BBB88BA10EAA316008FEA1F</string>
|
||||
<string>6BBB88BB10EAA316008FEA1F</string>
|
||||
<string>6BBB88BC10EAA316008FEA1F</string>
|
||||
<string>6BBB88BD10EAA316008FEA1F</string>
|
||||
<string>6BBB88C110EAA316008FEA1F</string>
|
||||
<string>6BBB88C210EAA316008FEA1F</string>
|
||||
<string>6BBB88C310EAA316008FEA1F</string>
|
||||
<string>6BBB88C510EAA316008FEA1F</string>
|
||||
<string>6BBB88C610EAA316008FEA1F</string>
|
||||
<string>6BBB88C710EAA316008FEA1F</string>
|
||||
<string>6BBB88C810EAA316008FEA1F</string>
|
||||
<string>6BBB88D310EAA384008FEA1F</string>
|
||||
<string>6BBB88D410EAA384008FEA1F</string>
|
||||
<string>6BBB88D510EAA384008FEA1F</string>
|
||||
<string>6BBB88DA10EAA39C008FEA1F</string>
|
||||
<string>6BBB88E410EAA3D9008FEA1F</string>
|
||||
<string>6BBB88E510EAA3D9008FEA1F</string>
|
||||
<string>6BBB88E610EAA3D9008FEA1F</string>
|
||||
<string>6BBB88E710EAA3D9008FEA1F</string>
|
||||
<string>6BBB88E810EAA3D9008FEA1F</string>
|
||||
<string>6BBB88E910EAA3D9008FEA1F</string>
|
||||
<string>6BBB88F010EAA44E008FEA1F</string>
|
||||
<string>6BBB88F410EAA4E6008FEA1F</string>
|
||||
<string>6BBB88FC10EAA614008FEA1F</string>
|
||||
<string>6BBB88FD10EAA614008FEA1F</string>
|
||||
<string>6BBB88FE10EAA614008FEA1F</string>
|
||||
<string>6BBB88FF10EAA614008FEA1F</string>
|
||||
<string>6BBB890010EAA614008FEA1F</string>
|
||||
<string>6BBB890110EAA614008FEA1F</string>
|
||||
<string>6BBB890210EAA614008FEA1F</string>
|
||||
<string>6BBB890310EAA614008FEA1F</string>
|
||||
<string>6BBB890A10EAA6C2008FEA1F</string>
|
||||
<string>6BBB890D10EAA6C2008FEA1F</string>
|
||||
<string>6BBB890E10EAA6C2008FEA1F</string>
|
||||
<string>6BBB891B10EAA87B008FEA1F</string>
|
||||
<string>6BBB891C10EAA87B008FEA1F</string>
|
||||
<string>6BBB891D10EAA87B008FEA1F</string>
|
||||
<string>6BBB891F10EAA87B008FEA1F</string>
|
||||
<string>6BBB892310EAA87B008FEA1F</string>
|
||||
<string>6BBB892510EAA87B008FEA1F</string>
|
||||
<string>6BBB892710EAA87B008FEA1F</string>
|
||||
<string>6BBB892810EAA87B008FEA1F</string>
|
||||
<string>6BBB892910EAA87B008FEA1F</string>
|
||||
<string>6BBB892A10EAA87B008FEA1F</string>
|
||||
<string>6BBB892B10EAA87B008FEA1F</string>
|
||||
<string>6BBB892F10EAA899008FEA1F</string>
|
||||
<string>6BBB893A10EAAADC008FEA1F</string>
|
||||
<string>6BBB893C10EAAADC008FEA1F</string>
|
||||
<string>6BBB893D10EAAADC008FEA1F</string>
|
||||
<string>6BBB893E10EAAADC008FEA1F</string>
|
||||
<string>6BBB894A10EAAB73008FEA1F</string>
|
||||
<string>6BBB894C10EAAB73008FEA1F</string>
|
||||
<string>6BBB894E10EAAB73008FEA1F</string>
|
||||
<string>6BBB895010EAAB73008FEA1F</string>
|
||||
<string>6BBB895210EAAB73008FEA1F</string>
|
||||
<string>6BBB895310EAAB73008FEA1F</string>
|
||||
<string>6BBB895510EAAB73008FEA1F</string>
|
||||
<string>6BBB896010EAAE6C008FEA1F</string>
|
||||
<string>6BBB896110EAAE6C008FEA1F</string>
|
||||
<string>6BBB896310EAAE6C008FEA1F</string>
|
||||
<string>6BBB896C10EAB179008FEA1F</string>
|
||||
<string>6BBB896E10EAB179008FEA1F</string>
|
||||
<string>6BBB897010EAB179008FEA1F</string>
|
||||
<string>6BBB897210EAB179008FEA1F</string>
|
||||
<string>6BBB897410EAB179008FEA1F</string>
|
||||
<string>6BBB897610EAB179008FEA1F</string>
|
||||
<string>6BBB897810EAB179008FEA1F</string>
|
||||
<string>6BBB897A10EAB179008FEA1F</string>
|
||||
<string>6BBB897C10EAB179008FEA1F</string>
|
||||
<string>6BBB898510EAB1AA008FEA1F</string>
|
||||
<string>6BBB898610EAB1AA008FEA1F</string>
|
||||
<string>6BBB898A10EAB225008FEA1F</string>
|
||||
<string>6BBB899410EABB10008FEA1F</string>
|
||||
<string>6BBB899510EABB10008FEA1F</string>
|
||||
<string>6BBB899610EABB10008FEA1F</string>
|
||||
<string>6BBB899710EABB10008FEA1F</string>
|
||||
<string>6BBB899810EABB10008FEA1F</string>
|
||||
<string>6BBB899910EABB10008FEA1F</string>
|
||||
<string>6BBB89A110EABD34008FEA1F</string>
|
||||
<string>6BBB89A210EABD34008FEA1F</string>
|
||||
<string>6BBB89A310EABD34008FEA1F</string>
|
||||
</array>
|
||||
</dict>
|
||||
<key>SplitCount</key>
|
||||
@@ -402,18 +583,18 @@
|
||||
<key>GeometryConfiguration</key>
|
||||
<dict>
|
||||
<key>Frame</key>
|
||||
<string>{{0, 0}, {976, 524}}</string>
|
||||
<string>{{0, 0}, {976, 515}}</string>
|
||||
<key>RubberWindowFrame</key>
|
||||
<string>0 59 1280 719 0 0 1280 778 </string>
|
||||
</dict>
|
||||
<key>Module</key>
|
||||
<string>PBXNavigatorGroup</string>
|
||||
<key>Proportion</key>
|
||||
<string>524pt</string>
|
||||
<string>515pt</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>Proportion</key>
|
||||
<string>149pt</string>
|
||||
<string>158pt</string>
|
||||
<key>Tabs</key>
|
||||
<array>
|
||||
<dict>
|
||||
@@ -427,7 +608,7 @@
|
||||
<key>GeometryConfiguration</key>
|
||||
<dict>
|
||||
<key>Frame</key>
|
||||
<string>{{10, 27}, {976, 122}}</string>
|
||||
<string>{{10, 27}, {976, 194}}</string>
|
||||
</dict>
|
||||
<key>Module</key>
|
||||
<string>XCDetailModule</string>
|
||||
@@ -481,7 +662,7 @@
|
||||
<key>GeometryConfiguration</key>
|
||||
<dict>
|
||||
<key>Frame</key>
|
||||
<string>{{10, 27}, {976, 122}}</string>
|
||||
<string>{{10, 27}, {976, 131}}</string>
|
||||
<key>RubberWindowFrame</key>
|
||||
<string>0 59 1280 719 0 0 1280 778 </string>
|
||||
</dict>
|
||||
@@ -511,11 +692,11 @@
|
||||
</array>
|
||||
<key>TableOfContents</key>
|
||||
<array>
|
||||
<string>6B98692910DF824E007D8D84</string>
|
||||
<string>6BBB881A10EA97CC008FEA1F</string>
|
||||
<string>1CA23ED40692098700951B8B</string>
|
||||
<string>6B98692A10DF824E007D8D84</string>
|
||||
<string>6BBB881B10EA97CC008FEA1F</string>
|
||||
<string>6B8632A30F78115100E2684A</string>
|
||||
<string>6B98692B10DF824E007D8D84</string>
|
||||
<string>6BBB881C10EA97CC008FEA1F</string>
|
||||
<string>1CA23EDF0692099D00951B8B</string>
|
||||
<string>1CA23EE00692099D00951B8B</string>
|
||||
<string>1CA23EE10692099D00951B8B</string>
|
||||
@@ -664,14 +845,14 @@
|
||||
</array>
|
||||
<key>TableOfContents</key>
|
||||
<array>
|
||||
<string>6B98693F10DF8929007D8D84</string>
|
||||
<string>6BBB882C10EA99CA008FEA1F</string>
|
||||
<string>1CCC7628064C1048000F2A68</string>
|
||||
<string>1CCC7629064C1048000F2A68</string>
|
||||
<string>6B98694010DF8929007D8D84</string>
|
||||
<string>6B98694110DF8929007D8D84</string>
|
||||
<string>6B98694210DF8929007D8D84</string>
|
||||
<string>6B98694310DF8929007D8D84</string>
|
||||
<string>6B98694410DF8929007D8D84</string>
|
||||
<string>6BBB882D10EA99CA008FEA1F</string>
|
||||
<string>6BBB882E10EA99CA008FEA1F</string>
|
||||
<string>6BBB882F10EA99CA008FEA1F</string>
|
||||
<string>6BBB883010EA99CA008FEA1F</string>
|
||||
<string>6BBB883110EA99CA008FEA1F</string>
|
||||
</array>
|
||||
<key>ToolbarConfigUserDefaultsMinorVersion</key>
|
||||
<string>2</string>
|
||||
@@ -703,6 +884,8 @@
|
||||
<integer>5</integer>
|
||||
<key>WindowOrderList</key>
|
||||
<array>
|
||||
<string>6BBB888F10EAA01C008FEA1F</string>
|
||||
<string>6BBB889010EAA01C008FEA1F</string>
|
||||
<string>/Users/memon/Code/recastnavigation/RecastDemo/Build/Xcode/Recast.xcodeproj</string>
|
||||
</array>
|
||||
<key>WindowString</key>
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
6B8632DC0F78123E00E2684A /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6B8632DB0F78123E00E2684A /* OpenGL.framework */; };
|
||||
6B8DE88910B69E3E00DF20FB /* DetourNavMesh.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6B8DE88710B69E3E00DF20FB /* DetourNavMesh.cpp */; };
|
||||
6B8DE88A10B69E3E00DF20FB /* DetourNavMeshBuilder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6B8DE88810B69E3E00DF20FB /* DetourNavMeshBuilder.cpp */; };
|
||||
6BA1E88A10C7BFC9008007F6 /* Sample_SoloMesh.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6BA1E88710C7BFC9008007F6 /* Sample_SoloMesh.cpp */; };
|
||||
6BA1E88B10C7BFC9008007F6 /* Sample_SoloMeshSimple.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6BA1E88810C7BFC9008007F6 /* Sample_SoloMeshSimple.cpp */; };
|
||||
6BA1E88C10C7BFC9008007F6 /* Sample_SoloMeshTiled.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6BA1E88910C7BFC9008007F6 /* Sample_SoloMeshTiled.cpp */; };
|
||||
6BB788170FC0472B003C24DB /* ChunkyTriMesh.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6BB788160FC0472B003C24DB /* ChunkyTriMesh.cpp */; };
|
||||
@@ -39,6 +38,7 @@
|
||||
6BB93C7E10CFE1D500F74F2B /* DetourDebugDraw.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6BB93C7B10CFE1D500F74F2B /* DetourDebugDraw.cpp */; };
|
||||
6BB93C7F10CFE1D500F74F2B /* RecastDebugDraw.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6BB93C7C10CFE1D500F74F2B /* RecastDebugDraw.cpp */; };
|
||||
6BB93CF610CFEC4500F74F2B /* RecastDump.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6BB93CF510CFEC4500F74F2B /* RecastDump.cpp */; };
|
||||
6BBB87D010EA8EFA008FEA1F /* NavMeshTesterTool.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6BBB87CF10EA8EFA008FEA1F /* NavMeshTesterTool.cpp */; };
|
||||
8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */; };
|
||||
8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; };
|
||||
/* End PBXBuildFile section */
|
||||
@@ -88,10 +88,8 @@
|
||||
6B8DE88810B69E3E00DF20FB /* DetourNavMeshBuilder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DetourNavMeshBuilder.cpp; path = ../../../Detour/Source/DetourNavMeshBuilder.cpp; sourceTree = SOURCE_ROOT; };
|
||||
6B8DE88B10B69E4C00DF20FB /* DetourNavMesh.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DetourNavMesh.h; path = ../../../Detour/Include/DetourNavMesh.h; sourceTree = SOURCE_ROOT; };
|
||||
6B8DE88C10B69E4C00DF20FB /* DetourNavMeshBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DetourNavMeshBuilder.h; path = ../../../Detour/Include/DetourNavMeshBuilder.h; sourceTree = SOURCE_ROOT; };
|
||||
6BA1E88710C7BFC9008007F6 /* Sample_SoloMesh.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Sample_SoloMesh.cpp; path = ../../Source/Sample_SoloMesh.cpp; sourceTree = SOURCE_ROOT; };
|
||||
6BA1E88810C7BFC9008007F6 /* Sample_SoloMeshSimple.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Sample_SoloMeshSimple.cpp; path = ../../Source/Sample_SoloMeshSimple.cpp; sourceTree = SOURCE_ROOT; };
|
||||
6BA1E88910C7BFC9008007F6 /* Sample_SoloMeshTiled.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Sample_SoloMeshTiled.cpp; path = ../../Source/Sample_SoloMeshTiled.cpp; sourceTree = SOURCE_ROOT; };
|
||||
6BA1E88D10C7BFD3008007F6 /* Sample_SoloMesh.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Sample_SoloMesh.h; path = ../../Include/Sample_SoloMesh.h; sourceTree = SOURCE_ROOT; };
|
||||
6BA1E88E10C7BFD3008007F6 /* Sample_SoloMeshSimple.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Sample_SoloMeshSimple.h; path = ../../Include/Sample_SoloMeshSimple.h; sourceTree = SOURCE_ROOT; };
|
||||
6BA1E88F10C7BFD3008007F6 /* Sample_SoloMeshTiled.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Sample_SoloMeshTiled.h; path = ../../Include/Sample_SoloMeshTiled.h; sourceTree = SOURCE_ROOT; };
|
||||
6BB788160FC0472B003C24DB /* ChunkyTriMesh.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ChunkyTriMesh.cpp; path = ../../Source/ChunkyTriMesh.cpp; sourceTree = SOURCE_ROOT; };
|
||||
@@ -104,6 +102,8 @@
|
||||
6BB93C7C10CFE1D500F74F2B /* RecastDebugDraw.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RecastDebugDraw.cpp; path = ../../../DebugUtils/Source/RecastDebugDraw.cpp; sourceTree = SOURCE_ROOT; };
|
||||
6BB93CF410CFEC4500F74F2B /* RecastDump.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RecastDump.h; path = ../../../DebugUtils/Include/RecastDump.h; sourceTree = SOURCE_ROOT; };
|
||||
6BB93CF510CFEC4500F74F2B /* RecastDump.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RecastDump.cpp; path = ../../../DebugUtils/Source/RecastDump.cpp; sourceTree = SOURCE_ROOT; };
|
||||
6BBB87CE10EA8EF2008FEA1F /* NavMeshTesterTool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NavMeshTesterTool.h; sourceTree = "<group>"; };
|
||||
6BBB87CF10EA8EFA008FEA1F /* NavMeshTesterTool.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NavMeshTesterTool.cpp; sourceTree = "<group>"; };
|
||||
8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
8D1107320486CEB800E47090 /* Recast.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Recast.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
/* End PBXFileReference section */
|
||||
@@ -235,16 +235,16 @@
|
||||
6B555DF5100B25FC00247EA3 /* Samples */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
6BA1E88D10C7BFD3008007F6 /* Sample_SoloMesh.h */,
|
||||
6BA1E88E10C7BFD3008007F6 /* Sample_SoloMeshSimple.h */,
|
||||
6BA1E88F10C7BFD3008007F6 /* Sample_SoloMeshTiled.h */,
|
||||
6BA1E88710C7BFC9008007F6 /* Sample_SoloMesh.cpp */,
|
||||
6BA1E88810C7BFC9008007F6 /* Sample_SoloMeshSimple.cpp */,
|
||||
6BA1E88910C7BFC9008007F6 /* Sample_SoloMeshTiled.cpp */,
|
||||
6B25B6100FFA62AD004F1BC4 /* Sample.h */,
|
||||
6B25B6140FFA62BE004F1BC4 /* Sample.cpp */,
|
||||
6BA1E88E10C7BFD3008007F6 /* Sample_SoloMeshSimple.h */,
|
||||
6BA1E88810C7BFC9008007F6 /* Sample_SoloMeshSimple.cpp */,
|
||||
6BA1E88F10C7BFD3008007F6 /* Sample_SoloMeshTiled.h */,
|
||||
6BA1E88910C7BFC9008007F6 /* Sample_SoloMeshTiled.cpp */,
|
||||
6B2AEC510FFB8946005BE9CC /* Sample_TileMesh.h */,
|
||||
6B2AEC520FFB8958005BE9CC /* Sample_TileMesh.cpp */,
|
||||
6BBB87CE10EA8EF2008FEA1F /* NavMeshTesterTool.h */,
|
||||
6BBB87CF10EA8EFA008FEA1F /* NavMeshTesterTool.cpp */,
|
||||
);
|
||||
name = Samples;
|
||||
sourceTree = "<group>";
|
||||
@@ -356,13 +356,13 @@
|
||||
6B62416A103434880002E346 /* RecastMeshDetail.cpp in Sources */,
|
||||
6B8DE88910B69E3E00DF20FB /* DetourNavMesh.cpp in Sources */,
|
||||
6B8DE88A10B69E3E00DF20FB /* DetourNavMeshBuilder.cpp in Sources */,
|
||||
6BA1E88A10C7BFC9008007F6 /* Sample_SoloMesh.cpp in Sources */,
|
||||
6BA1E88B10C7BFC9008007F6 /* Sample_SoloMeshSimple.cpp in Sources */,
|
||||
6BA1E88C10C7BFC9008007F6 /* Sample_SoloMeshTiled.cpp in Sources */,
|
||||
6BB93C7D10CFE1D500F74F2B /* DebugDraw.cpp in Sources */,
|
||||
6BB93C7E10CFE1D500F74F2B /* DetourDebugDraw.cpp in Sources */,
|
||||
6BB93C7F10CFE1D500F74F2B /* RecastDebugDraw.cpp in Sources */,
|
||||
6BB93CF610CFEC4500F74F2B /* RecastDump.cpp in Sources */,
|
||||
6BBB87D010EA8EFA008FEA1F /* NavMeshTesterTool.cpp in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
||||
@@ -11,6 +11,25 @@ struct DebugDrawGL : public duDebugDraw
|
||||
virtual void end();
|
||||
};
|
||||
|
||||
enum SampleToolType
|
||||
{
|
||||
TOOL_NONE = 0,
|
||||
TOOL_TILE_EDIT,
|
||||
TOOL_NAVMESH_TESTER,
|
||||
};
|
||||
|
||||
struct SampleTool
|
||||
{
|
||||
virtual ~SampleTool() {}
|
||||
virtual int type() = 0;
|
||||
virtual void init(class Sample* sample) = 0;
|
||||
virtual void reset() = 0;
|
||||
virtual void handleMenu() = 0;
|
||||
virtual void handleClick(const float* p, bool shift) = 0;
|
||||
virtual void handleRender() = 0;
|
||||
virtual void handleRenderOverlay(double* proj, double* model, int* view) = 0;
|
||||
};
|
||||
|
||||
|
||||
class Sample
|
||||
{
|
||||
@@ -36,17 +55,18 @@ protected:
|
||||
float m_detailSampleDist;
|
||||
float m_detailSampleMaxError;
|
||||
|
||||
SampleTool* m_tool;
|
||||
|
||||
public:
|
||||
Sample();
|
||||
virtual ~Sample();
|
||||
|
||||
void setTool(SampleTool* tool);
|
||||
|
||||
virtual void handleSettings();
|
||||
virtual void handleTools();
|
||||
virtual void handleDebugMode();
|
||||
|
||||
virtual void setToolStartPos(const float* p);
|
||||
virtual void setToolEndPos(const float* p);
|
||||
|
||||
virtual void handleClick(const float* p, bool shift);
|
||||
virtual void handleRender();
|
||||
virtual void handleRenderOverlay(double* proj, double* model, int* view);
|
||||
virtual void handleMeshChanged(const float* verts, int nverts,
|
||||
@@ -54,6 +74,10 @@ public:
|
||||
const float* bmin, const float* bmax);
|
||||
virtual bool handleBuild();
|
||||
|
||||
virtual class dtNavMesh* getNavMesh() { return 0; }
|
||||
virtual float getAgentRadius() { return m_agentRadius; }
|
||||
virtual float getAgentHeight() { return m_agentHeight; }
|
||||
|
||||
void resetCommonSettings();
|
||||
void handleCommonSettings();
|
||||
};
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
#ifndef RECASTSAMPLESOLOMESH_H
|
||||
#define RECASTSAMPLESOLOMESH_H
|
||||
|
||||
#include "Sample.h"
|
||||
#include "DetourNavMesh.h"
|
||||
#include "Recast.h"
|
||||
#include "RecastLog.h"
|
||||
|
||||
class Sample_SoloMesh : public Sample
|
||||
{
|
||||
protected:
|
||||
|
||||
dtNavMesh* m_navMesh;
|
||||
|
||||
enum ToolMode
|
||||
{
|
||||
TOOLMODE_PATHFIND,
|
||||
TOOLMODE_RAYCAST,
|
||||
TOOLMODE_DISTANCE_TO_WALL,
|
||||
TOOLMODE_FIND_POLYS_AROUND,
|
||||
};
|
||||
|
||||
ToolMode m_toolMode;
|
||||
|
||||
static const int MAX_POLYS = 256;
|
||||
static const int MAX_SMOOTH = 2048;
|
||||
|
||||
dtPolyRef m_startRef;
|
||||
dtPolyRef m_endRef;
|
||||
dtPolyRef m_polys[MAX_POLYS];
|
||||
dtPolyRef m_parent[MAX_POLYS];
|
||||
int m_npolys;
|
||||
float m_straightPath[MAX_POLYS*3];
|
||||
int m_nstraightPath;
|
||||
float m_polyPickExt[3];
|
||||
float m_smoothPath[MAX_SMOOTH*3];
|
||||
int m_nsmoothPath;
|
||||
|
||||
float m_spos[3];
|
||||
float m_epos[3];
|
||||
float m_hitPos[3];
|
||||
float m_hitNormal[3];
|
||||
float m_distanceToWall;
|
||||
bool m_sposSet;
|
||||
bool m_eposSet;
|
||||
|
||||
enum ToolRenderFlags
|
||||
{
|
||||
NAVMESH_POLYS = 0x01,
|
||||
NAVMESH_BVTREE = 0x02,
|
||||
NAVMESH_TOOLS = 0x04,
|
||||
};
|
||||
|
||||
void toolCleanup();
|
||||
void toolReset();
|
||||
void toolRecalc();
|
||||
void toolRender(int flags);
|
||||
void toolRenderOverlay(double* proj, double* model, int* view);
|
||||
|
||||
void drawAgent(const float* pos, float r, float h, float c, const float* col);
|
||||
|
||||
|
||||
public:
|
||||
Sample_SoloMesh();
|
||||
virtual ~Sample_SoloMesh();
|
||||
|
||||
virtual void handleTools();
|
||||
virtual void setToolStartPos(const float* p);
|
||||
virtual void setToolEndPos(const float* p);
|
||||
};
|
||||
|
||||
|
||||
#endif // RECASTSAMPLESOLOMESH_H
|
||||
@@ -1,15 +1,15 @@
|
||||
#ifndef RECASTSAMPLESOLOMESHSIMPLE_H
|
||||
#define RECASTSAMPLESOLOMESHSIMPLE_H
|
||||
|
||||
#include "Sample_SoloMesh.h"
|
||||
#include "Sample.h"
|
||||
#include "DetourNavMesh.h"
|
||||
#include "Recast.h"
|
||||
#include "RecastLog.h"
|
||||
|
||||
|
||||
class Sample_SoloMeshSimple : public Sample_SoloMesh
|
||||
class Sample_SoloMeshSimple : public Sample //Sample_SoloMesh
|
||||
{
|
||||
protected:
|
||||
dtNavMesh* m_navMesh;
|
||||
|
||||
bool m_keepInterResults;
|
||||
rcBuildTimes m_buildTimes;
|
||||
@@ -52,6 +52,7 @@ public:
|
||||
virtual ~Sample_SoloMeshSimple();
|
||||
|
||||
virtual void handleSettings();
|
||||
virtual void handleTools();
|
||||
virtual void handleDebugMode();
|
||||
|
||||
virtual void handleRender();
|
||||
@@ -60,6 +61,8 @@ public:
|
||||
const int* tris, const float* trinorms, int ntris,
|
||||
const float* bmin, const float* bmax);
|
||||
virtual bool handleBuild();
|
||||
|
||||
virtual class dtNavMesh* getNavMesh() { return m_navMesh; }
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
#ifndef RECASTSAMPLESOLOMESHTILED_H
|
||||
#define RECASTSAMPLESOLOMESHTILED_H
|
||||
|
||||
#include "Sample_SoloMesh.h"
|
||||
#include "Sample.h"
|
||||
#include "DetourNavMesh.h"
|
||||
#include "Recast.h"
|
||||
#include "RecastLog.h"
|
||||
#include "ChunkyTriMesh.h"
|
||||
|
||||
class Sample_SoloMeshTiled : public Sample_SoloMesh
|
||||
class Sample_SoloMeshTiled : public Sample
|
||||
{
|
||||
protected:
|
||||
dtNavMesh* m_navMesh;
|
||||
|
||||
struct Tile
|
||||
{
|
||||
@@ -81,6 +82,7 @@ public:
|
||||
virtual ~Sample_SoloMeshTiled();
|
||||
|
||||
virtual void handleSettings();
|
||||
virtual void handleTools();
|
||||
virtual void handleDebugMode();
|
||||
|
||||
virtual void handleRender();
|
||||
@@ -89,6 +91,8 @@ public:
|
||||
const int* tris, const float* trinorms, int ntris,
|
||||
const float* bmin, const float* bmax);
|
||||
virtual bool handleBuild();
|
||||
|
||||
virtual class dtNavMesh* getNavMesh() { return m_navMesh; }
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -24,12 +24,14 @@
|
||||
#include "Recast.h"
|
||||
#include "RecastLog.h"
|
||||
#include "ChunkyTriMesh.h"
|
||||
#include "NavMeshTesterTool.h"
|
||||
|
||||
class Sample_TileMesh : public Sample
|
||||
{
|
||||
protected:
|
||||
|
||||
bool m_keepInterResults;
|
||||
bool m_buildAll;
|
||||
rcBuildTimes m_buildTimes;
|
||||
|
||||
dtNavMesh* m_navMesh;
|
||||
@@ -44,52 +46,15 @@ protected:
|
||||
|
||||
int m_maxTiles;
|
||||
int m_maxPolysPerTile;
|
||||
|
||||
float m_tileSize;
|
||||
|
||||
float m_spos[3];
|
||||
float m_epos[3];
|
||||
bool m_sposSet;
|
||||
bool m_eposSet;
|
||||
|
||||
float m_tileCol[4];
|
||||
float m_tileBmin[3];
|
||||
float m_tileBmax[3];
|
||||
float m_tileBuildTime;
|
||||
float m_tileMemUsage;
|
||||
int m_tileTriCount;
|
||||
|
||||
enum ToolMode
|
||||
{
|
||||
TOOLMODE_CREATE_TILES,
|
||||
TOOLMODE_PATHFIND,
|
||||
TOOLMODE_RAYCAST,
|
||||
TOOLMODE_DISTANCE_TO_WALL,
|
||||
TOOLMODE_FIND_POLYS_AROUND,
|
||||
};
|
||||
|
||||
dtPolyRef m_startRef;
|
||||
dtPolyRef m_endRef;
|
||||
float m_polyPickExt[3];
|
||||
|
||||
static const int MAX_POLYS = 256;
|
||||
|
||||
dtPolyRef m_polys[MAX_POLYS];
|
||||
dtPolyRef m_parent[MAX_POLYS];
|
||||
int m_npolys;
|
||||
float m_straightPath[MAX_POLYS*3];
|
||||
int m_nstraightPath;
|
||||
float m_hitPos[3];
|
||||
float m_hitNormal[3];
|
||||
float m_distanceToWall;
|
||||
|
||||
ToolMode m_toolMode;
|
||||
|
||||
void toolRecalc();
|
||||
|
||||
void buildTile(const float* pos);
|
||||
void removeTile(const float* pos);
|
||||
|
||||
|
||||
unsigned char* buildTileMesh(const float* bmin, const float* bmax, int& dataSize);
|
||||
|
||||
void cleanup();
|
||||
@@ -101,16 +66,19 @@ public:
|
||||
virtual void handleSettings();
|
||||
virtual void handleTools();
|
||||
virtual void handleDebugMode();
|
||||
|
||||
virtual void setToolStartPos(const float* p);
|
||||
virtual void setToolEndPos(const float* p);
|
||||
|
||||
virtual void handleRender();
|
||||
virtual void handleRenderOverlay(double* proj, double* model, int* view);
|
||||
virtual void handleMeshChanged(const float* verts, int nverts,
|
||||
const int* tris, const float* trinorms, int ntris,
|
||||
const float* bmin, const float* bmax);
|
||||
virtual bool handleBuild();
|
||||
|
||||
virtual class dtNavMesh* getNavMesh() { return m_navMesh; }
|
||||
|
||||
void buildTile(const float* pos);
|
||||
void removeTile(const float* pos);
|
||||
void buildAllTiles();
|
||||
void removeAllTiles();
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -55,13 +55,27 @@ void DebugDrawGL::end()
|
||||
|
||||
|
||||
Sample::Sample() :
|
||||
m_verts(0), m_nverts(0), m_tris(0), m_trinorms(0), m_ntris(0)
|
||||
m_verts(0),
|
||||
m_nverts(0),
|
||||
m_tris(0),
|
||||
m_trinorms(0),
|
||||
m_ntris(0),
|
||||
m_tool(0)
|
||||
{
|
||||
resetCommonSettings();
|
||||
}
|
||||
|
||||
Sample::~Sample()
|
||||
{
|
||||
delete m_tool;
|
||||
}
|
||||
|
||||
void Sample::setTool(SampleTool* tool)
|
||||
{
|
||||
delete m_tool;
|
||||
m_tool = tool;
|
||||
if (tool)
|
||||
m_tool->init(this);
|
||||
}
|
||||
|
||||
void Sample::handleSettings()
|
||||
@@ -162,12 +176,10 @@ void Sample::handleCommonSettings()
|
||||
imguiSeparator();
|
||||
}
|
||||
|
||||
void Sample::setToolStartPos(const float* p)
|
||||
{
|
||||
}
|
||||
|
||||
void Sample::setToolEndPos(const float* p)
|
||||
void Sample::handleClick(const float* p, bool shift)
|
||||
{
|
||||
if (m_tool)
|
||||
m_tool->handleClick(p, shift);
|
||||
}
|
||||
|
||||
bool Sample::handleBuild()
|
||||
|
||||
@@ -1,445 +0,0 @@
|
||||
#define _USE_MATH_DEFINES
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "SDL.h"
|
||||
#include "SDL_opengl.h"
|
||||
#include "imgui.h"
|
||||
#include "Sample.h"
|
||||
#include "Sample_SoloMesh.h"
|
||||
#include "Recast.h"
|
||||
#include "RecastTimer.h"
|
||||
#include "RecastDebugDraw.h"
|
||||
#include "DetourNavMesh.h"
|
||||
#include "DetourNavMeshBuilder.h"
|
||||
#include "DetourDebugDraw.h"
|
||||
|
||||
#ifdef WIN32
|
||||
# define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
inline bool inRange(const float* v1, const float* v2, const float r, const float h)
|
||||
{
|
||||
const float dx = v2[0] - v1[0];
|
||||
const float dy = v2[1] - v1[1];
|
||||
const float dz = v2[2] - v1[2];
|
||||
return (dx*dx + dz*dz) < r*r && fabsf(dy) < h;
|
||||
}
|
||||
|
||||
|
||||
Sample_SoloMesh::Sample_SoloMesh() :
|
||||
m_navMesh(0),
|
||||
m_toolMode(TOOLMODE_PATHFIND),
|
||||
m_startRef(0),
|
||||
m_endRef(0),
|
||||
m_npolys(0),
|
||||
m_nstraightPath(0),
|
||||
m_nsmoothPath(0),
|
||||
m_distanceToWall(0),
|
||||
m_sposSet(false),
|
||||
m_eposSet(false)
|
||||
{
|
||||
toolReset();
|
||||
m_polyPickExt[0] = 2;
|
||||
m_polyPickExt[1] = 4;
|
||||
m_polyPickExt[2] = 2;
|
||||
}
|
||||
|
||||
Sample_SoloMesh::~Sample_SoloMesh()
|
||||
{
|
||||
toolCleanup();
|
||||
}
|
||||
|
||||
void Sample_SoloMesh::handleTools()
|
||||
{
|
||||
if (imguiCheck("Pathfind", m_toolMode == TOOLMODE_PATHFIND))
|
||||
{
|
||||
m_toolMode = TOOLMODE_PATHFIND;
|
||||
toolRecalc();
|
||||
}
|
||||
if (imguiCheck("Distance to Wall", m_toolMode == TOOLMODE_DISTANCE_TO_WALL))
|
||||
{
|
||||
m_toolMode = TOOLMODE_DISTANCE_TO_WALL;
|
||||
toolRecalc();
|
||||
}
|
||||
if (imguiCheck("Raycast", m_toolMode == TOOLMODE_RAYCAST))
|
||||
{
|
||||
m_toolMode = TOOLMODE_RAYCAST;
|
||||
toolRecalc();
|
||||
}
|
||||
if (imguiCheck("Find Polys Around", m_toolMode == TOOLMODE_FIND_POLYS_AROUND))
|
||||
{
|
||||
m_toolMode = TOOLMODE_FIND_POLYS_AROUND;
|
||||
toolRecalc();
|
||||
}
|
||||
}
|
||||
|
||||
void Sample_SoloMesh::setToolStartPos(const float* p)
|
||||
{
|
||||
m_sposSet = true;
|
||||
vcopy(m_spos, p);
|
||||
toolRecalc();
|
||||
}
|
||||
|
||||
void Sample_SoloMesh::setToolEndPos(const float* p)
|
||||
{
|
||||
m_eposSet = true;
|
||||
vcopy(m_epos, p);
|
||||
toolRecalc();
|
||||
}
|
||||
|
||||
void Sample_SoloMesh::toolCleanup()
|
||||
{
|
||||
delete m_navMesh;
|
||||
m_navMesh = 0;
|
||||
}
|
||||
|
||||
void Sample_SoloMesh::toolReset()
|
||||
{
|
||||
m_startRef = 0;
|
||||
m_endRef = 0;
|
||||
m_npolys = 0;
|
||||
m_nstraightPath = 0;
|
||||
m_nsmoothPath = 0;
|
||||
memset(m_hitPos, 0, sizeof(m_hitPos));
|
||||
memset(m_hitNormal, 0, sizeof(m_hitNormal));
|
||||
m_distanceToWall = 0;
|
||||
}
|
||||
|
||||
void Sample_SoloMesh::toolRecalc()
|
||||
{
|
||||
if (!m_navMesh)
|
||||
return;
|
||||
|
||||
if (m_sposSet)
|
||||
m_startRef = m_navMesh->findNearestPoly(m_spos, m_polyPickExt);
|
||||
else
|
||||
m_startRef = 0;
|
||||
|
||||
if (m_eposSet)
|
||||
m_endRef = m_navMesh->findNearestPoly(m_epos, m_polyPickExt);
|
||||
else
|
||||
m_endRef = 0;
|
||||
|
||||
if (m_toolMode == TOOLMODE_PATHFIND)
|
||||
{
|
||||
if (m_sposSet && m_eposSet && m_startRef && m_endRef)
|
||||
{
|
||||
m_npolys = m_navMesh->findPath(m_startRef, m_endRef, m_spos, m_epos, m_polys, MAX_POLYS);
|
||||
if (m_npolys)
|
||||
{
|
||||
m_nstraightPath = m_navMesh->findStraightPath(m_spos, m_epos, m_polys, m_npolys, m_straightPath, MAX_POLYS);
|
||||
|
||||
// Iterate over the path to find smooth path on the detail mesh surface.
|
||||
const dtPolyRef* polys = m_polys;
|
||||
int npolys = m_npolys;
|
||||
|
||||
float iterPos[3], targetPos[3];
|
||||
m_navMesh->closestPointOnPolyBoundary(m_startRef, m_spos, iterPos);
|
||||
m_navMesh->closestPointOnPolyBoundary(polys[npolys-1], m_epos, targetPos);
|
||||
|
||||
static const float STEP_SIZE = 0.5f;
|
||||
static const float SLOP = 0.01f;
|
||||
|
||||
m_nsmoothPath = 0;
|
||||
|
||||
vcopy(&m_smoothPath[m_nsmoothPath*3], iterPos);
|
||||
m_nsmoothPath++;
|
||||
|
||||
while (npolys && m_nsmoothPath < MAX_SMOOTH)
|
||||
{
|
||||
// Find steer target.
|
||||
static const int MAX_STEER = 3;
|
||||
float steerPath[MAX_STEER*3];
|
||||
int nsteerPath = m_navMesh->findStraightPath(iterPos, m_epos, polys, npolys, steerPath, MAX_STEER);
|
||||
if (!nsteerPath)
|
||||
break;
|
||||
// Find vertex far enough to steer to.
|
||||
int ns = 0;
|
||||
while (ns < nsteerPath)
|
||||
{
|
||||
if (!inRange(&steerPath[ns*3], iterPos, SLOP, 1000.0f))
|
||||
break;
|
||||
ns++;
|
||||
}
|
||||
if (ns >= nsteerPath)
|
||||
break;
|
||||
bool endOfPath = inRange(&steerPath[ns*3], targetPos, SLOP*SLOP, 1.0f);
|
||||
|
||||
// Find movement delta.
|
||||
float delta[3], len;
|
||||
vsub(delta, &steerPath[ns*3], iterPos);
|
||||
len = sqrtf(vdot(delta,delta));
|
||||
if (endOfPath && len < STEP_SIZE)
|
||||
len = 1;
|
||||
else
|
||||
len = STEP_SIZE / len;
|
||||
float moveTgt[3];
|
||||
vmad(moveTgt, iterPos, delta, len);
|
||||
|
||||
// Move
|
||||
float result[3];
|
||||
int n = m_navMesh->moveAlongPathCorridor(iterPos, moveTgt, result, polys, npolys);
|
||||
float h = 0;
|
||||
m_navMesh->getPolyHeight(polys[n], result, &h);
|
||||
result[1] = h;
|
||||
// Shrink path corridor of possible.
|
||||
polys += n;
|
||||
npolys -= n;
|
||||
|
||||
vcopy(iterPos, result);
|
||||
|
||||
// Close enough to the target.
|
||||
if (inRange(iterPos, targetPos, SLOP, 1.0f))
|
||||
{
|
||||
vcopy(iterPos, targetPos);
|
||||
npolys = 0;
|
||||
}
|
||||
|
||||
// Store results.
|
||||
if (m_nsmoothPath < MAX_SMOOTH)
|
||||
{
|
||||
vcopy(&m_smoothPath[m_nsmoothPath*3], iterPos);
|
||||
m_nsmoothPath++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_npolys = 0;
|
||||
m_nstraightPath = 0;
|
||||
}
|
||||
}
|
||||
else if (m_toolMode == TOOLMODE_RAYCAST)
|
||||
{
|
||||
m_nstraightPath = 0;
|
||||
if (m_sposSet && m_eposSet && m_startRef)
|
||||
{
|
||||
float t = 0;
|
||||
m_npolys = 0;
|
||||
m_nstraightPath = 2;
|
||||
m_straightPath[0] = m_spos[0];
|
||||
m_straightPath[1] = m_spos[1];
|
||||
m_straightPath[2] = m_spos[2];
|
||||
vcopy(m_hitPos, m_epos);
|
||||
m_npolys = m_navMesh->raycast(m_startRef, m_spos, m_epos, t, m_hitNormal, m_polys, MAX_POLYS);
|
||||
if (m_npolys && t < 1)
|
||||
{
|
||||
m_hitPos[0] = m_spos[0] + (m_epos[0] - m_spos[0]) * t;
|
||||
m_hitPos[1] = m_spos[1] + (m_epos[1] - m_spos[1]) * t;
|
||||
m_hitPos[2] = m_spos[2] + (m_epos[2] - m_spos[2]) * t;
|
||||
}
|
||||
vcopy(&m_straightPath[3], m_hitPos);
|
||||
}
|
||||
}
|
||||
else if (m_toolMode == TOOLMODE_DISTANCE_TO_WALL)
|
||||
{
|
||||
m_distanceToWall = 0;
|
||||
if (m_sposSet && m_startRef)
|
||||
m_distanceToWall = m_navMesh->findDistanceToWall(m_startRef, m_spos, 100.0f, m_hitPos, m_hitNormal);
|
||||
}
|
||||
else if (m_toolMode == TOOLMODE_FIND_POLYS_AROUND)
|
||||
{
|
||||
if (m_sposSet && m_startRef && m_eposSet)
|
||||
{
|
||||
const float dx = m_epos[0] - m_spos[0];
|
||||
const float dz = m_epos[2] - m_spos[2];
|
||||
float dist = sqrtf(dx*dx + dz*dz);
|
||||
m_npolys = m_navMesh->findPolysAround(m_startRef, m_spos, dist, m_polys, m_parent, 0, MAX_POLYS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void getPolyCenter(dtNavMesh* navMesh, dtPolyRef ref, float* center)
|
||||
{
|
||||
const dtPoly* p = navMesh->getPolyByRef(ref);
|
||||
if (!p) return;
|
||||
const float* verts = navMesh->getPolyVertsByRef(ref);
|
||||
center[0] = 0;
|
||||
center[1] = 0;
|
||||
center[2] = 0;
|
||||
for (int i = 0; i < (int)p->nv; ++i)
|
||||
{
|
||||
const float* v = &verts[p->v[i]*3];
|
||||
center[0] += v[0];
|
||||
center[1] += v[1];
|
||||
center[2] += v[2];
|
||||
}
|
||||
const float s = 1.0f / p->nv;
|
||||
center[0] *= s;
|
||||
center[1] *= s;
|
||||
center[2] *= s;
|
||||
}
|
||||
|
||||
void Sample_SoloMesh::toolRender(int flags)
|
||||
{
|
||||
if (!m_navMesh)
|
||||
return;
|
||||
|
||||
DebugDrawGL dd;
|
||||
|
||||
static const float startCol[4] = { 0.5f, 0.1f, 0.0f, 0.75f };
|
||||
static const float endCol[4] = { 0.2f, 0.4f, 0.0f, 0.75f };
|
||||
static const float pathCol[4] = {0,0,0,0.25f};
|
||||
|
||||
glDepthMask(GL_FALSE);
|
||||
|
||||
if (flags & NAVMESH_POLYS)
|
||||
duDebugDrawNavMesh(&dd, m_navMesh, m_toolMode == TOOLMODE_PATHFIND);
|
||||
|
||||
if (flags & NAVMESH_BVTREE)
|
||||
duDebugDrawNavMeshBVTree(&dd, m_navMesh);
|
||||
|
||||
if (flags & NAVMESH_TOOLS)
|
||||
{
|
||||
if (m_toolMode == TOOLMODE_PATHFIND)
|
||||
{
|
||||
duDebugDrawNavMeshPoly(&dd, m_navMesh, m_startRef, startCol);
|
||||
duDebugDrawNavMeshPoly(&dd, m_navMesh, m_endRef, endCol);
|
||||
|
||||
if (m_npolys)
|
||||
{
|
||||
for (int i = 1; i < m_npolys-1; ++i)
|
||||
duDebugDrawNavMeshPoly(&dd, m_navMesh, m_polys[i], pathCol);
|
||||
}
|
||||
if (m_nstraightPath)
|
||||
{
|
||||
glColor4ub(64,16,0,64);
|
||||
glLineWidth(2.0f);
|
||||
glBegin(GL_LINE_STRIP);
|
||||
for (int i = 0; i < m_nstraightPath; ++i)
|
||||
glVertex3f(m_straightPath[i*3], m_straightPath[i*3+1]+0.4f, m_straightPath[i*3+2]);
|
||||
glEnd();
|
||||
glLineWidth(1.0f);
|
||||
glColor4ub(64,16,0,128);
|
||||
glPointSize(3.0f);
|
||||
glBegin(GL_POINTS);
|
||||
for (int i = 0; i < m_nstraightPath; ++i)
|
||||
glVertex3f(m_straightPath[i*3], m_straightPath[i*3+1]+0.4f, m_straightPath[i*3+2]);
|
||||
glEnd();
|
||||
glPointSize(1.0f);
|
||||
}
|
||||
if (m_nsmoothPath)
|
||||
{
|
||||
glColor4ub(0,0,0,220);
|
||||
glLineWidth(3.0f);
|
||||
glBegin(GL_LINES);
|
||||
for (int i = 0; i < m_nsmoothPath; ++i)
|
||||
glVertex3f(m_smoothPath[i*3], m_smoothPath[i*3+1], m_smoothPath[i*3+2]);
|
||||
glEnd();
|
||||
glLineWidth(1.0f);
|
||||
}
|
||||
}
|
||||
else if (m_toolMode == TOOLMODE_RAYCAST)
|
||||
{
|
||||
duDebugDrawNavMeshPoly(&dd, m_navMesh, m_startRef, startCol);
|
||||
|
||||
if (m_nstraightPath)
|
||||
{
|
||||
for (int i = 1; i < m_npolys; ++i)
|
||||
duDebugDrawNavMeshPoly(&dd, m_navMesh, m_polys[i], pathCol);
|
||||
|
||||
glColor4ub(64,16,0,220);
|
||||
glLineWidth(3.0f);
|
||||
glBegin(GL_LINE_STRIP);
|
||||
for (int i = 0; i < m_nstraightPath; ++i)
|
||||
glVertex3f(m_straightPath[i*3], m_straightPath[i*3+1]+0.4f, m_straightPath[i*3+2]);
|
||||
glEnd();
|
||||
glLineWidth(1.0f);
|
||||
glPointSize(4.0f);
|
||||
glBegin(GL_POINTS);
|
||||
for (int i = 0; i < m_nstraightPath; ++i)
|
||||
glVertex3f(m_straightPath[i*3], m_straightPath[i*3+1]+0.4f, m_straightPath[i*3+2]);
|
||||
glEnd();
|
||||
glPointSize(1.0f);
|
||||
|
||||
glColor4ub(255,255,255,128);
|
||||
glBegin(GL_LINES);
|
||||
glVertex3f(m_hitPos[0], m_hitPos[1] + 0.4f, m_hitPos[2]);
|
||||
glVertex3f(m_hitPos[0] + m_hitNormal[0]*m_agentRadius, m_hitPos[1] + 0.4f + m_hitNormal[1]*m_agentRadius, m_hitPos[2] + m_hitNormal[2]*m_agentRadius);
|
||||
glEnd();
|
||||
}
|
||||
}
|
||||
else if (m_toolMode == TOOLMODE_DISTANCE_TO_WALL)
|
||||
{
|
||||
duDebugDrawNavMeshPoly(&dd, m_navMesh, m_startRef, startCol);
|
||||
const float col[4] = {1,1,1,0.5f};
|
||||
duDebugDrawCylinderWire(&dd, m_spos[0]-m_distanceToWall, m_spos[1]+0.02f, m_spos[2]-m_distanceToWall,
|
||||
m_spos[0]+m_distanceToWall, m_spos[1]+m_agentHeight, m_spos[2]+m_distanceToWall, col);
|
||||
glLineWidth(3.0f);
|
||||
glColor4fv(col);
|
||||
glBegin(GL_LINES);
|
||||
glVertex3f(m_hitPos[0], m_hitPos[1] + 0.02f, m_hitPos[2]);
|
||||
glVertex3f(m_hitPos[0], m_hitPos[1] + m_agentHeight, m_hitPos[2]);
|
||||
glEnd();
|
||||
glLineWidth(1.0f);
|
||||
}
|
||||
else if (m_toolMode == TOOLMODE_FIND_POLYS_AROUND)
|
||||
{
|
||||
const float cola[4] = {0,0,0,0.5f};
|
||||
for (int i = 0; i < m_npolys; ++i)
|
||||
{
|
||||
duDebugDrawNavMeshPoly(&dd, m_navMesh, m_polys[i], pathCol);
|
||||
if (m_parent[i])
|
||||
{
|
||||
float p0[3], p1[3];
|
||||
getPolyCenter(m_navMesh, m_polys[i], p0);
|
||||
getPolyCenter(m_navMesh, m_parent[i], p1);
|
||||
duDebugDrawArc(&dd, p0, p1, cola, 2.0f);
|
||||
}
|
||||
}
|
||||
|
||||
const float dx = m_epos[0] - m_spos[0];
|
||||
const float dz = m_epos[2] - m_spos[2];
|
||||
float dist = sqrtf(dx*dx + dz*dz);
|
||||
const float col[4] = {1,1,1,0.5f};
|
||||
duDebugDrawCylinderWire(&dd, m_spos[0]-dist, m_spos[1]+0.02f, m_spos[2]-dist,
|
||||
m_spos[0]+dist, m_spos[1]+m_agentHeight, m_spos[2]+dist, col);
|
||||
}
|
||||
}
|
||||
|
||||
glDepthMask(GL_TRUE);
|
||||
}
|
||||
|
||||
void Sample_SoloMesh::toolRenderOverlay(double* proj, double* model, int* view)
|
||||
{
|
||||
GLdouble x, y, z;
|
||||
|
||||
// Draw start and end point labels
|
||||
if (m_sposSet && gluProject((GLdouble)m_spos[0], (GLdouble)m_spos[1], (GLdouble)m_spos[2],
|
||||
model, proj, view, &x, &y, &z))
|
||||
{
|
||||
imguiDrawText((int)x, (int)(y-25), IMGUI_ALIGN_CENTER, "Start", imguiRGBA(0,0,0,220));
|
||||
}
|
||||
if (m_eposSet && gluProject((GLdouble)m_epos[0], (GLdouble)m_epos[1], (GLdouble)m_epos[2],
|
||||
model, proj, view, &x, &y, &z))
|
||||
{
|
||||
imguiDrawText((int)x, (int)(y-25), IMGUI_ALIGN_CENTER, "End", imguiRGBA(0,0,0,220));
|
||||
}
|
||||
}
|
||||
|
||||
void Sample_SoloMesh::drawAgent(const float* pos, float r, float h, float c, const float* col)
|
||||
{
|
||||
DebugDrawGL dd;
|
||||
|
||||
glDepthMask(GL_FALSE);
|
||||
|
||||
// Agent dimensions.
|
||||
glLineWidth(2.0f);
|
||||
duDebugDrawCylinderWire(&dd, pos[0]-r, pos[1]+0.02f, pos[2]-r, pos[0]+r, pos[1]+h, pos[2]+r, col);
|
||||
glLineWidth(1.0f);
|
||||
|
||||
glColor4ub(0,0,0,196);
|
||||
glBegin(GL_LINES);
|
||||
glVertex3f(pos[0], pos[1]-c, pos[2]);
|
||||
glVertex3f(pos[0], pos[1]+c, pos[2]);
|
||||
glVertex3f(pos[0]-r/2, pos[1]+0.02f, pos[2]);
|
||||
glVertex3f(pos[0]+r/2, pos[1]+0.02f, pos[2]);
|
||||
glVertex3f(pos[0], pos[1]+0.02f, pos[2]-r/2);
|
||||
glVertex3f(pos[0], pos[1]+0.02f, pos[2]+r/2);
|
||||
glEnd();
|
||||
|
||||
glDepthMask(GL_TRUE);
|
||||
}
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "DetourNavMesh.h"
|
||||
#include "DetourNavMeshBuilder.h"
|
||||
#include "DetourDebugDraw.h"
|
||||
#include "NavMeshTesterTool.h"
|
||||
|
||||
#ifdef WIN32
|
||||
# define snprintf _snprintf
|
||||
@@ -21,6 +22,7 @@
|
||||
|
||||
|
||||
Sample_SoloMeshSimple::Sample_SoloMeshSimple() :
|
||||
m_navMesh(0),
|
||||
m_keepInterResults(false),
|
||||
m_triflags(0),
|
||||
m_solid(0),
|
||||
@@ -30,6 +32,7 @@ Sample_SoloMeshSimple::Sample_SoloMeshSimple() :
|
||||
m_dmesh(0),
|
||||
m_drawMode(DRAWMODE_NAVMESH)
|
||||
{
|
||||
setTool(new NavMeshTesterTool);
|
||||
}
|
||||
|
||||
Sample_SoloMeshSimple::~Sample_SoloMeshSimple()
|
||||
@@ -51,7 +54,8 @@ void Sample_SoloMeshSimple::cleanup()
|
||||
m_pmesh = 0;
|
||||
delete m_dmesh;
|
||||
m_dmesh = 0;
|
||||
toolCleanup();
|
||||
delete m_navMesh;
|
||||
m_navMesh = 0;
|
||||
}
|
||||
|
||||
void Sample_SoloMeshSimple::handleSettings()
|
||||
@@ -64,6 +68,12 @@ void Sample_SoloMeshSimple::handleSettings()
|
||||
imguiSeparator();
|
||||
}
|
||||
|
||||
void Sample_SoloMeshSimple::handleTools()
|
||||
{
|
||||
if (m_tool)
|
||||
m_tool->handleMenu();
|
||||
}
|
||||
|
||||
void Sample_SoloMeshSimple::handleDebugMode()
|
||||
{
|
||||
// Check which modes are valid.
|
||||
@@ -175,12 +185,10 @@ void Sample_SoloMeshSimple::handleRender()
|
||||
m_drawMode == DRAWMODE_NAVMESH_BVTREE ||
|
||||
m_drawMode == DRAWMODE_NAVMESH_INVIS))
|
||||
{
|
||||
int flags = NAVMESH_TOOLS;
|
||||
if (m_drawMode != DRAWMODE_NAVMESH_INVIS)
|
||||
flags |= NAVMESH_POLYS;
|
||||
duDebugDrawNavMesh(&dd, m_navMesh); //, m_toolMode == TOOLMODE_PATHFIND);
|
||||
if (m_drawMode == DRAWMODE_NAVMESH_BVTREE)
|
||||
flags |= NAVMESH_BVTREE;
|
||||
toolRender(flags);
|
||||
duDebugDrawNavMeshBVTree(&dd, m_navMesh);
|
||||
}
|
||||
|
||||
glDepthMask(GL_TRUE);
|
||||
@@ -244,19 +252,23 @@ void Sample_SoloMeshSimple::handleRender()
|
||||
glDepthMask(GL_TRUE);
|
||||
}
|
||||
|
||||
static const float startCol[4] = { 0.5f, 0.1f, 0.0f, 0.75f };
|
||||
/* static const float startCol[4] = { 0.5f, 0.1f, 0.0f, 0.75f };
|
||||
static const float endCol[4] = { 0.2f, 0.4f, 0.0f, 0.75f };
|
||||
if (m_sposSet)
|
||||
drawAgent(m_spos, m_agentRadius, m_agentHeight, m_agentMaxClimb, startCol);
|
||||
if (m_eposSet)
|
||||
drawAgent(m_epos, m_agentRadius, m_agentHeight, m_agentMaxClimb, endCol);
|
||||
drawAgent(m_epos, m_agentRadius, m_agentHeight, m_agentMaxClimb, endCol);*/
|
||||
|
||||
if (m_tool)
|
||||
m_tool->handleRender();
|
||||
|
||||
glDepthMask(GL_TRUE);
|
||||
}
|
||||
|
||||
void Sample_SoloMeshSimple::handleRenderOverlay(double* proj, double* model, int* view)
|
||||
{
|
||||
toolRenderOverlay(proj, model, view);
|
||||
if (m_tool)
|
||||
m_tool->handleRenderOverlay(proj, model, view);
|
||||
}
|
||||
|
||||
void Sample_SoloMeshSimple::handleMeshChanged(const float* verts, int nverts,
|
||||
@@ -264,8 +276,13 @@ void Sample_SoloMeshSimple::handleMeshChanged(const float* verts, int nverts,
|
||||
const float* bmin, const float* bmax)
|
||||
{
|
||||
Sample::handleMeshChanged(verts, nverts, tris, trinorms, ntris, bmin, bmax);
|
||||
toolCleanup();
|
||||
toolReset();
|
||||
delete m_navMesh;
|
||||
m_navMesh = 0;
|
||||
if (m_tool)
|
||||
{
|
||||
m_tool->reset();
|
||||
m_tool->init(this);
|
||||
}
|
||||
}
|
||||
|
||||
bool Sample_SoloMeshSimple::handleBuild()
|
||||
@@ -278,7 +295,6 @@ bool Sample_SoloMeshSimple::handleBuild()
|
||||
}
|
||||
|
||||
cleanup();
|
||||
toolCleanup();
|
||||
|
||||
//
|
||||
// Step 1. Initialize build config.
|
||||
@@ -560,7 +576,8 @@ bool Sample_SoloMeshSimple::handleBuild()
|
||||
rcGetLog()->log(RC_LOG_PROGRESS, "TOTAL: %.1fms", rcGetDeltaTimeUsec(totStartTime, totEndTime)/1000.0f);
|
||||
}
|
||||
|
||||
toolRecalc();
|
||||
if (m_tool)
|
||||
m_tool->init(this);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -13,12 +13,14 @@
|
||||
#include "DetourNavMesh.h"
|
||||
#include "DetourNavMeshBuilder.h"
|
||||
#include "DetourDebugDraw.h"
|
||||
#include "NavMeshTesterTool.h"
|
||||
|
||||
#ifdef WIN32
|
||||
# define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
Sample_SoloMeshTiled::Sample_SoloMeshTiled() :
|
||||
m_navMesh(0),
|
||||
m_measurePerTileTimings(false),
|
||||
m_keepInterResults(false),
|
||||
m_tileSize(64),
|
||||
@@ -30,6 +32,7 @@ Sample_SoloMeshTiled::Sample_SoloMeshTiled() :
|
||||
m_statTimePerTileSamples(0),
|
||||
m_drawMode(DRAWMODE_NAVMESH)
|
||||
{
|
||||
setTool(new NavMeshTesterTool);
|
||||
}
|
||||
|
||||
Sample_SoloMeshTiled::~Sample_SoloMeshTiled()
|
||||
@@ -47,7 +50,8 @@ void Sample_SoloMeshTiled::cleanup()
|
||||
m_pmesh = 0;
|
||||
delete m_dmesh;
|
||||
m_dmesh = 0;
|
||||
toolCleanup();
|
||||
delete m_navMesh;
|
||||
m_navMesh = 0;
|
||||
m_statTimePerTileSamples = 0;
|
||||
m_statPolysPerTileSamples = 0;
|
||||
}
|
||||
@@ -77,6 +81,12 @@ void Sample_SoloMeshTiled::handleSettings()
|
||||
imguiSeparator();
|
||||
}
|
||||
|
||||
void Sample_SoloMeshTiled::handleTools()
|
||||
{
|
||||
if (m_tool)
|
||||
m_tool->handleMenu();
|
||||
}
|
||||
|
||||
void Sample_SoloMeshTiled::handleDebugMode()
|
||||
{
|
||||
// Check which modes are valid.
|
||||
@@ -245,12 +255,10 @@ void Sample_SoloMeshTiled::handleRender()
|
||||
m_drawMode == DRAWMODE_NAVMESH_BVTREE ||
|
||||
m_drawMode == DRAWMODE_NAVMESH_INVIS))
|
||||
{
|
||||
int flags = NAVMESH_TOOLS;
|
||||
if (m_drawMode != DRAWMODE_NAVMESH_INVIS)
|
||||
flags |= NAVMESH_POLYS;
|
||||
duDebugDrawNavMesh(&dd, m_navMesh); //, m_toolMode == TOOLMODE_PATHFIND);
|
||||
if (m_drawMode == DRAWMODE_NAVMESH_BVTREE)
|
||||
flags |= NAVMESH_BVTREE;
|
||||
toolRender(flags);
|
||||
duDebugDrawNavMeshBVTree(&dd, m_navMesh);
|
||||
}
|
||||
|
||||
glDepthMask(GL_TRUE);
|
||||
@@ -389,13 +397,16 @@ void Sample_SoloMeshTiled::handleRender()
|
||||
}
|
||||
}
|
||||
|
||||
static const float startCol[4] = { 0.5f, 0.1f, 0.0f, 0.75f };
|
||||
/* static const float startCol[4] = { 0.5f, 0.1f, 0.0f, 0.75f };
|
||||
static const float endCol[4] = { 0.2f, 0.4f, 0.0f, 0.75f };
|
||||
if (m_sposSet)
|
||||
drawAgent(m_spos, m_agentRadius, m_agentHeight, m_agentMaxClimb, startCol);
|
||||
if (m_eposSet)
|
||||
drawAgent(m_epos, m_agentRadius, m_agentHeight, m_agentMaxClimb, endCol);
|
||||
|
||||
*/
|
||||
|
||||
if (m_tool)
|
||||
m_tool->handleRender();
|
||||
}
|
||||
|
||||
static float nicenum(float x, int round)
|
||||
@@ -506,8 +517,6 @@ static void drawGraph(const char* name, int x, int y, int w, int h, float sd,
|
||||
|
||||
void Sample_SoloMeshTiled::handleRenderOverlay(double* proj, double* model, int* view)
|
||||
{
|
||||
toolRenderOverlay(proj, model, view);
|
||||
|
||||
if (m_measurePerTileTimings)
|
||||
{
|
||||
if (m_statTimePerTileSamples)
|
||||
@@ -529,6 +538,9 @@ void Sample_SoloMeshTiled::handleRenderOverlay(double* proj, double* model, int*
|
||||
snprintf(text,64,"Tiles %d\n", validTiles);
|
||||
imguiDrawText(10, 240, IMGUI_ALIGN_LEFT, text, imguiRGBA(255,255,255));
|
||||
}
|
||||
|
||||
if (m_tool)
|
||||
m_tool->handleRenderOverlay(proj, model, view);
|
||||
}
|
||||
|
||||
void Sample_SoloMeshTiled::handleMeshChanged(const float* verts, int nverts,
|
||||
@@ -536,10 +548,13 @@ void Sample_SoloMeshTiled::handleMeshChanged(const float* verts, int nverts,
|
||||
const float* bmin, const float* bmax)
|
||||
{
|
||||
Sample::handleMeshChanged(verts, nverts, tris, trinorms, ntris, bmin, bmax);
|
||||
toolCleanup();
|
||||
toolReset();
|
||||
m_statTimePerTileSamples = 0;
|
||||
m_statPolysPerTileSamples = 0;
|
||||
if (m_tool)
|
||||
{
|
||||
m_tool->reset();
|
||||
m_tool->init(this);
|
||||
}
|
||||
}
|
||||
|
||||
bool Sample_SoloMeshTiled::handleBuild()
|
||||
@@ -560,8 +575,6 @@ bool Sample_SoloMeshTiled::handleBuild()
|
||||
}
|
||||
|
||||
cleanup();
|
||||
toolCleanup();
|
||||
toolReset();
|
||||
|
||||
// Init build configuration from GUI
|
||||
memset(&m_cfg, 0, sizeof(m_cfg));
|
||||
@@ -980,7 +993,8 @@ bool Sample_SoloMeshTiled::handleBuild()
|
||||
rcGetLog()->log(RC_LOG_PROGRESS, "TOTAL: %.1fms", rcGetDeltaTimeUsec(totStartTime, totEndTime)/1000.0f);
|
||||
}
|
||||
|
||||
toolRecalc();
|
||||
if (m_tool)
|
||||
m_tool->init(this);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -61,9 +61,95 @@ inline unsigned int ilog2(unsigned int v)
|
||||
return r;
|
||||
}
|
||||
|
||||
class NavMeshTileTool : public SampleTool
|
||||
{
|
||||
Sample_TileMesh* m_sample;
|
||||
float m_hitPos[3];
|
||||
bool m_hitPosSet;
|
||||
float m_agentRadius;
|
||||
|
||||
public:
|
||||
|
||||
NavMeshTileTool() :
|
||||
m_sample(0),
|
||||
m_hitPosSet(false),
|
||||
m_agentRadius(0)
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~NavMeshTileTool()
|
||||
{
|
||||
}
|
||||
|
||||
virtual int type() { return TOOL_TILE_EDIT; }
|
||||
|
||||
virtual void init(Sample* sample)
|
||||
{
|
||||
m_sample = (Sample_TileMesh*)sample;
|
||||
}
|
||||
|
||||
virtual void reset() {}
|
||||
|
||||
virtual void handleMenu()
|
||||
{
|
||||
imguiLabel("Create Tiles");
|
||||
if (imguiButton("Create All"))
|
||||
{
|
||||
if (m_sample)
|
||||
m_sample->buildAllTiles();
|
||||
}
|
||||
if (imguiButton("Remove All"))
|
||||
{
|
||||
if (m_sample)
|
||||
m_sample->removeAllTiles();
|
||||
}
|
||||
imguiValue("Click LMB to create a tile.");
|
||||
imguiValue("Shift+LMB to remove a tile.");
|
||||
}
|
||||
|
||||
virtual void handleClick(const float* p, bool shift)
|
||||
{
|
||||
m_hitPosSet = true;
|
||||
vcopy(m_hitPos,p);
|
||||
if (m_sample)
|
||||
{
|
||||
if (shift)
|
||||
m_sample->removeTile(m_hitPos);
|
||||
else
|
||||
m_sample->buildTile(m_hitPos);
|
||||
}
|
||||
}
|
||||
|
||||
virtual void handleRender()
|
||||
{
|
||||
if (m_hitPosSet)
|
||||
{
|
||||
const float s = m_sample->getAgentRadius();
|
||||
glColor4ub(0,0,0,128);
|
||||
glLineWidth(2.0f);
|
||||
glBegin(GL_LINES);
|
||||
glVertex3f(m_hitPos[0]-s,m_hitPos[1]+0.1f,m_hitPos[2]);
|
||||
glVertex3f(m_hitPos[0]+s,m_hitPos[1]+0.1f,m_hitPos[2]);
|
||||
glVertex3f(m_hitPos[0],m_hitPos[1]-s+0.1f,m_hitPos[2]);
|
||||
glVertex3f(m_hitPos[0],m_hitPos[1]+s+0.1f,m_hitPos[2]);
|
||||
glVertex3f(m_hitPos[0],m_hitPos[1]+0.1f,m_hitPos[2]-s);
|
||||
glVertex3f(m_hitPos[0],m_hitPos[1]+0.1f,m_hitPos[2]+s);
|
||||
glEnd();
|
||||
glLineWidth(1.0f);
|
||||
}
|
||||
}
|
||||
|
||||
virtual void handleRenderOverlay(double* proj, double* model, int* view)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
Sample_TileMesh::Sample_TileMesh() :
|
||||
m_keepInterResults(false),
|
||||
m_buildAll(true),
|
||||
m_navMesh(0),
|
||||
m_chunkyMesh(0),
|
||||
m_triflags(0),
|
||||
@@ -75,24 +161,15 @@ Sample_TileMesh::Sample_TileMesh() :
|
||||
m_maxTiles(0),
|
||||
m_maxPolysPerTile(0),
|
||||
m_tileSize(32),
|
||||
m_sposSet(false),
|
||||
m_eposSet(false),
|
||||
m_tileBuildTime(0),
|
||||
m_tileMemUsage(0),
|
||||
m_tileTriCount(0),
|
||||
m_startRef(0),
|
||||
m_endRef(0),
|
||||
m_npolys(0),
|
||||
m_nstraightPath(0),
|
||||
m_distanceToWall(0),
|
||||
m_toolMode(TOOLMODE_CREATE_TILES)
|
||||
m_tileTriCount(0)
|
||||
{
|
||||
resetCommonSettings();
|
||||
memset(m_tileBmin, 0, sizeof(m_tileBmin));
|
||||
memset(m_tileBmax, 0, sizeof(m_tileBmax));
|
||||
m_polyPickExt[0] = 2;
|
||||
m_polyPickExt[1] = 4;
|
||||
m_polyPickExt[2] = 2;
|
||||
|
||||
setTool(new NavMeshTileTool);
|
||||
}
|
||||
|
||||
Sample_TileMesh::~Sample_TileMesh()
|
||||
@@ -121,6 +198,12 @@ void Sample_TileMesh::cleanup()
|
||||
void Sample_TileMesh::handleSettings()
|
||||
{
|
||||
Sample::handleCommonSettings();
|
||||
|
||||
if (imguiCheck("Keep Itermediate Results", m_keepInterResults))
|
||||
m_keepInterResults = !m_keepInterResults;
|
||||
|
||||
if (imguiCheck("Build All Tiles", m_buildAll))
|
||||
m_buildAll = !m_buildAll;
|
||||
|
||||
imguiLabel("Tiling");
|
||||
imguiSlider("TileSize", &m_tileSize, 16.0f, 1024.0f, 16.0f);
|
||||
@@ -147,141 +230,23 @@ void Sample_TileMesh::handleSettings()
|
||||
imguiValue(text);
|
||||
}
|
||||
|
||||
void Sample_TileMesh::toolRecalc()
|
||||
{
|
||||
m_startRef = 0;
|
||||
if (m_sposSet)
|
||||
m_startRef = m_navMesh->findNearestPoly(m_spos, m_polyPickExt);
|
||||
|
||||
m_endRef = 0;
|
||||
if (m_eposSet)
|
||||
m_endRef = m_navMesh->findNearestPoly(m_epos, m_polyPickExt);
|
||||
|
||||
if (m_toolMode == TOOLMODE_PATHFIND)
|
||||
{
|
||||
if (m_sposSet && m_eposSet && m_startRef && m_endRef)
|
||||
{
|
||||
m_npolys = m_navMesh->findPath(m_startRef, m_endRef, m_spos, m_epos, m_polys, MAX_POLYS);
|
||||
if (m_npolys)
|
||||
m_nstraightPath = m_navMesh->findStraightPath(m_spos, m_epos, m_polys, m_npolys, m_straightPath, MAX_POLYS);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_npolys = 0;
|
||||
m_nstraightPath = 0;
|
||||
}
|
||||
}
|
||||
else if (m_toolMode == TOOLMODE_RAYCAST)
|
||||
{
|
||||
m_nstraightPath = 0;
|
||||
if (m_sposSet && m_eposSet && m_startRef)
|
||||
{
|
||||
float t = 0;
|
||||
m_npolys = 0;
|
||||
m_nstraightPath = 2;
|
||||
m_straightPath[0] = m_spos[0];
|
||||
m_straightPath[1] = m_spos[1];
|
||||
m_straightPath[2] = m_spos[2];
|
||||
vcopy(m_hitPos, m_epos);
|
||||
m_npolys = m_navMesh->raycast(m_startRef, m_spos, m_epos, t, m_hitNormal, m_polys, MAX_POLYS);
|
||||
if (m_npolys && t < 1)
|
||||
{
|
||||
m_hitPos[0] = m_spos[0] + (m_epos[0] - m_spos[0]) * t;
|
||||
m_hitPos[1] = m_spos[1] + (m_epos[1] - m_spos[1]) * t;
|
||||
m_hitPos[2] = m_spos[2] + (m_epos[2] - m_spos[2]) * t;
|
||||
}
|
||||
vcopy(&m_straightPath[3], m_hitPos);
|
||||
}
|
||||
}
|
||||
else if (m_toolMode == TOOLMODE_DISTANCE_TO_WALL)
|
||||
{
|
||||
m_distanceToWall = 0;
|
||||
if (m_sposSet && m_startRef)
|
||||
m_distanceToWall = m_navMesh->findDistanceToWall(m_startRef, m_spos, 100.0f, m_hitPos, m_hitNormal);
|
||||
}
|
||||
else if (m_toolMode == TOOLMODE_FIND_POLYS_AROUND)
|
||||
{
|
||||
if (m_sposSet && m_startRef && m_eposSet)
|
||||
{
|
||||
const float dx = m_epos[0] - m_spos[0];
|
||||
const float dz = m_epos[2] - m_spos[2];
|
||||
float dist = sqrtf(dx*dx + dz*dz);
|
||||
m_npolys = m_navMesh->findPolysAround(m_startRef, m_spos, dist, m_polys, m_parent, 0, MAX_POLYS);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Sample_TileMesh::handleTools()
|
||||
{
|
||||
if (imguiCheck("Create Tiles", m_toolMode == TOOLMODE_CREATE_TILES))
|
||||
{
|
||||
m_toolMode = TOOLMODE_CREATE_TILES;
|
||||
toolRecalc();
|
||||
}
|
||||
int type = !m_tool ? TOOL_NONE : m_tool->type();
|
||||
|
||||
imguiIndent();
|
||||
|
||||
if (imguiButton("Create All"))
|
||||
if (imguiCheck("Create Tiles", type == TOOL_TILE_EDIT))
|
||||
{
|
||||
int gw = 0, gh = 0;
|
||||
rcCalcGridSize(m_bmin, m_bmax, m_cellSize, &gw, &gh);
|
||||
const int ts = (int)m_tileSize;
|
||||
const int tw = (gw + ts-1) / ts;
|
||||
const int th = (gh + ts-1) / ts;
|
||||
const float tcs = m_tileSize*m_cellSize;
|
||||
|
||||
for (int y = 0; y < th; ++y)
|
||||
{
|
||||
for (int x = 0; x < tw; ++x)
|
||||
{
|
||||
m_tileBmin[0] = m_bmin[0] + x*tcs;
|
||||
m_tileBmin[1] = m_bmin[1];
|
||||
m_tileBmin[2] = m_bmin[2] + y*tcs;
|
||||
|
||||
m_tileBmax[0] = m_bmin[0] + (x+1)*tcs;
|
||||
m_tileBmax[1] = m_bmax[1];
|
||||
m_tileBmax[2] = m_bmin[2] + (y+1)*tcs;
|
||||
|
||||
int dataSize = 0;
|
||||
unsigned char* data = buildTileMesh(m_tileBmin, m_tileBmax, dataSize);
|
||||
if (data)
|
||||
{
|
||||
// Remove any previous data (navmesh owns and deletes the data).
|
||||
m_navMesh->removeTileAt(x,y,0,0);
|
||||
// Let the navmesh own the data.
|
||||
if (!m_navMesh->addTileAt(x,y,data,dataSize,true))
|
||||
delete [] data;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
toolRecalc();
|
||||
setTool(new NavMeshTileTool);
|
||||
}
|
||||
if (imguiCheck("Test Navmesh", type == TOOL_NAVMESH_TESTER))
|
||||
{
|
||||
setTool(new NavMeshTesterTool);
|
||||
}
|
||||
imguiUnindent();
|
||||
|
||||
imguiSeparator();
|
||||
|
||||
if (imguiCheck("Pathfind", m_toolMode == TOOLMODE_PATHFIND))
|
||||
{
|
||||
m_toolMode = TOOLMODE_PATHFIND;
|
||||
toolRecalc();
|
||||
}
|
||||
if (imguiCheck("Distance to Wall", m_toolMode == TOOLMODE_DISTANCE_TO_WALL))
|
||||
{
|
||||
m_toolMode = TOOLMODE_DISTANCE_TO_WALL;
|
||||
toolRecalc();
|
||||
}
|
||||
if (imguiCheck("Raycast", m_toolMode == TOOLMODE_RAYCAST))
|
||||
{
|
||||
m_toolMode = TOOLMODE_RAYCAST;
|
||||
toolRecalc();
|
||||
}
|
||||
if (imguiCheck("Find Polys Around", m_toolMode == TOOLMODE_FIND_POLYS_AROUND))
|
||||
{
|
||||
m_toolMode = TOOLMODE_FIND_POLYS_AROUND;
|
||||
toolRecalc();
|
||||
}
|
||||
if (m_tool)
|
||||
m_tool->handleMenu();
|
||||
}
|
||||
|
||||
void Sample_TileMesh::handleDebugMode()
|
||||
@@ -329,10 +294,7 @@ void Sample_TileMesh::handleRender()
|
||||
DebugDrawGL dd;
|
||||
|
||||
// Draw mesh
|
||||
if (m_navMesh)
|
||||
duDebugDrawTriMesh(&dd, m_verts, m_nverts, m_tris, m_trinorms, m_ntris, 0);
|
||||
else
|
||||
duDebugDrawTriMeshSlope(&dd, m_verts, m_nverts, m_tris, m_trinorms, m_ntris, m_agentMaxSlope);
|
||||
duDebugDrawTriMesh(&dd, m_verts, m_nverts, m_tris, m_trinorms, m_ntris, 0);
|
||||
|
||||
glDepthMask(GL_FALSE);
|
||||
|
||||
@@ -383,138 +345,10 @@ void Sample_TileMesh::handleRender()
|
||||
if (m_navMesh)
|
||||
duDebugDrawNavMesh(&dd, m_navMesh);
|
||||
|
||||
if (m_sposSet)
|
||||
{
|
||||
const float s = 0.5f;
|
||||
glColor4ub(64,16,0,255);
|
||||
glLineWidth(3.0f);
|
||||
glBegin(GL_LINES);
|
||||
glVertex3f(m_spos[0]-s,m_spos[1]+m_cellHeight,m_spos[2]);
|
||||
glVertex3f(m_spos[0]+s,m_spos[1]+m_cellHeight,m_spos[2]);
|
||||
glVertex3f(m_spos[0],m_spos[1]-s+m_cellHeight,m_spos[2]);
|
||||
glVertex3f(m_spos[0],m_spos[1]+s+m_cellHeight,m_spos[2]);
|
||||
glVertex3f(m_spos[0],m_spos[1]+m_cellHeight,m_spos[2]-s);
|
||||
glVertex3f(m_spos[0],m_spos[1]+m_cellHeight,m_spos[2]+s);
|
||||
glEnd();
|
||||
glLineWidth(1.0f);
|
||||
}
|
||||
if (m_eposSet)
|
||||
{
|
||||
const float s = 0.5f;
|
||||
glColor4ub(16,64,0,255);
|
||||
glLineWidth(3.0f);
|
||||
glBegin(GL_LINES);
|
||||
glVertex3f(m_epos[0]-s,m_epos[1]+m_cellHeight,m_epos[2]);
|
||||
glVertex3f(m_epos[0]+s,m_epos[1]+m_cellHeight,m_epos[2]);
|
||||
glVertex3f(m_epos[0],m_epos[1]-s+m_cellHeight,m_epos[2]);
|
||||
glVertex3f(m_epos[0],m_epos[1]+s+m_cellHeight,m_epos[2]);
|
||||
glVertex3f(m_epos[0],m_epos[1]+m_cellHeight,m_epos[2]-s);
|
||||
glVertex3f(m_epos[0],m_epos[1]+m_cellHeight,m_epos[2]+s);
|
||||
glEnd();
|
||||
glLineWidth(1.0f);
|
||||
}
|
||||
|
||||
static const float startCol[4] = { 0.5f, 0.1f, 0.0f, 0.75f };
|
||||
static const float endCol[4] = { 0.2f, 0.4f, 0.0f, 0.75f };
|
||||
static const float pathCol[4] = {0,0,0,0.25f};
|
||||
|
||||
if (m_toolMode == TOOLMODE_PATHFIND)
|
||||
{
|
||||
duDebugDrawNavMeshPoly(&dd, m_navMesh, m_startRef, startCol);
|
||||
duDebugDrawNavMeshPoly(&dd, m_navMesh, m_endRef, endCol);
|
||||
|
||||
if (m_npolys)
|
||||
{
|
||||
for (int i = 1; i < m_npolys-1; ++i)
|
||||
duDebugDrawNavMeshPoly(&dd, m_navMesh, m_polys[i], pathCol);
|
||||
}
|
||||
if (m_nstraightPath)
|
||||
{
|
||||
glColor4ub(64,16,0,220);
|
||||
glLineWidth(3.0f);
|
||||
glBegin(GL_LINE_STRIP);
|
||||
for (int i = 0; i < m_nstraightPath; ++i)
|
||||
glVertex3f(m_straightPath[i*3], m_straightPath[i*3+1]+0.4f, m_straightPath[i*3+2]);
|
||||
glEnd();
|
||||
glLineWidth(1.0f);
|
||||
glPointSize(4.0f);
|
||||
glBegin(GL_POINTS);
|
||||
for (int i = 0; i < m_nstraightPath; ++i)
|
||||
glVertex3f(m_straightPath[i*3], m_straightPath[i*3+1]+0.4f, m_straightPath[i*3+2]);
|
||||
glEnd();
|
||||
glPointSize(1.0f);
|
||||
}
|
||||
}
|
||||
else if (m_toolMode == TOOLMODE_RAYCAST)
|
||||
{
|
||||
duDebugDrawNavMeshPoly(&dd, m_navMesh, m_startRef, startCol);
|
||||
|
||||
if (m_nstraightPath)
|
||||
{
|
||||
for (int i = 1; i < m_npolys; ++i)
|
||||
duDebugDrawNavMeshPoly(&dd, m_navMesh, m_polys[i], pathCol);
|
||||
|
||||
glColor4ub(64,16,0,220);
|
||||
glLineWidth(3.0f);
|
||||
glBegin(GL_LINE_STRIP);
|
||||
for (int i = 0; i < m_nstraightPath; ++i)
|
||||
glVertex3f(m_straightPath[i*3], m_straightPath[i*3+1]+0.4f, m_straightPath[i*3+2]);
|
||||
glEnd();
|
||||
glLineWidth(1.0f);
|
||||
glPointSize(4.0f);
|
||||
glBegin(GL_POINTS);
|
||||
for (int i = 0; i < m_nstraightPath; ++i)
|
||||
glVertex3f(m_straightPath[i*3], m_straightPath[i*3+1]+0.4f, m_straightPath[i*3+2]);
|
||||
glEnd();
|
||||
glPointSize(1.0f);
|
||||
|
||||
glColor4ub(255,255,255,128);
|
||||
glBegin(GL_LINES);
|
||||
glVertex3f(m_hitPos[0], m_hitPos[1] + 0.4f, m_hitPos[2]);
|
||||
glVertex3f(m_hitPos[0] + m_hitNormal[0]*m_agentRadius, m_hitPos[1] + 0.4f + m_hitNormal[1]*m_agentRadius, m_hitPos[2] + m_hitNormal[2]*m_agentRadius);
|
||||
glEnd();
|
||||
}
|
||||
}
|
||||
else if (m_toolMode == TOOLMODE_DISTANCE_TO_WALL)
|
||||
{
|
||||
duDebugDrawNavMeshPoly(&dd, m_navMesh, m_startRef, startCol);
|
||||
const float col[4] = {1,1,1,0.5f};
|
||||
duDebugDrawCylinderWire(&dd, m_spos[0]-m_distanceToWall, m_spos[1]+0.02f, m_spos[2]-m_distanceToWall,
|
||||
m_spos[0]+m_distanceToWall, m_spos[1]+m_agentHeight, m_spos[2]+m_distanceToWall, col);
|
||||
glLineWidth(3.0f);
|
||||
glColor4fv(col);
|
||||
glBegin(GL_LINES);
|
||||
glVertex3f(m_hitPos[0], m_hitPos[1] + 0.02f, m_hitPos[2]);
|
||||
glVertex3f(m_hitPos[0], m_hitPos[1] + m_agentHeight, m_hitPos[2]);
|
||||
glEnd();
|
||||
glLineWidth(1.0f);
|
||||
}
|
||||
else if (m_toolMode == TOOLMODE_FIND_POLYS_AROUND)
|
||||
{
|
||||
const float cola[4] = {0,0,0,0.5f};
|
||||
for (int i = 0; i < m_npolys; ++i)
|
||||
{
|
||||
duDebugDrawNavMeshPoly(&dd, m_navMesh, m_polys[i], pathCol);
|
||||
if (m_parent[i])
|
||||
{
|
||||
float p0[3], p1[3];
|
||||
getPolyCenter(m_navMesh, m_polys[i], p0);
|
||||
getPolyCenter(m_navMesh, m_parent[i], p1);
|
||||
glColor4ub(0,0,0,128);
|
||||
duDebugDrawArc(&dd, p0, p1, cola, 2.0f);
|
||||
}
|
||||
}
|
||||
|
||||
const float dx = m_epos[0] - m_spos[0];
|
||||
const float dz = m_epos[2] - m_spos[2];
|
||||
float dist = sqrtf(dx*dx + dz*dz);
|
||||
const float col[4] = {1,1,1,0.5f};
|
||||
duDebugDrawCylinderWire(&dd, m_spos[0]-dist, m_spos[1]+0.02f, m_spos[2]-dist,
|
||||
m_spos[0]+dist, m_spos[1]+m_agentHeight, m_spos[2]+dist, col);
|
||||
}
|
||||
|
||||
glDepthMask(GL_TRUE);
|
||||
if (m_tool)
|
||||
m_tool->handleRender();
|
||||
|
||||
glDepthMask(GL_TRUE);
|
||||
}
|
||||
|
||||
void Sample_TileMesh::handleRenderOverlay(double* proj, double* model, int* view)
|
||||
@@ -529,6 +363,9 @@ void Sample_TileMesh::handleRenderOverlay(double* proj, double* model, int* view
|
||||
snprintf(text,32,"%.3fms / %dTris / %.1fkB", m_tileBuildTime, m_tileTriCount, m_tileMemUsage);
|
||||
imguiDrawText((int)x, (int)y-25, IMGUI_ALIGN_CENTER, text, imguiRGBA(0,0,0,220));
|
||||
}
|
||||
|
||||
if (m_tool)
|
||||
m_tool->handleRenderOverlay(proj, model, view);
|
||||
}
|
||||
|
||||
void Sample_TileMesh::handleMeshChanged(const float* verts, int nverts,
|
||||
@@ -548,31 +385,12 @@ void Sample_TileMesh::handleMeshChanged(const float* verts, int nverts,
|
||||
delete m_navMesh;
|
||||
m_navMesh = 0;
|
||||
cleanup();
|
||||
}
|
||||
|
||||
void Sample_TileMesh::setToolStartPos(const float* p)
|
||||
{
|
||||
m_sposSet = true;
|
||||
vcopy(m_spos, p);
|
||||
|
||||
if (m_toolMode == TOOLMODE_CREATE_TILES)
|
||||
removeTile(m_spos);
|
||||
else
|
||||
toolRecalc();
|
||||
}
|
||||
|
||||
void Sample_TileMesh::setToolEndPos(const float* p)
|
||||
{
|
||||
if (!m_navMesh)
|
||||
return;
|
||||
|
||||
m_eposSet = true;
|
||||
vcopy(m_epos, p);
|
||||
|
||||
if (m_toolMode == TOOLMODE_CREATE_TILES)
|
||||
buildTile(m_epos);
|
||||
else
|
||||
toolRecalc();
|
||||
if (m_tool)
|
||||
{
|
||||
m_tool->reset();
|
||||
m_tool->init(this);
|
||||
}
|
||||
}
|
||||
|
||||
bool Sample_TileMesh::handleBuild()
|
||||
@@ -614,7 +432,13 @@ bool Sample_TileMesh::handleBuild()
|
||||
rcGetLog()->log(RC_LOG_ERROR, "buildTiledNavigation: Could not build chunky mesh.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_buildAll)
|
||||
buildAllTiles();
|
||||
|
||||
if (m_tool)
|
||||
m_tool->init(this);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -678,6 +502,54 @@ void Sample_TileMesh::removeTile(const float* pos)
|
||||
delete [] rdata;
|
||||
}
|
||||
|
||||
void Sample_TileMesh::buildAllTiles()
|
||||
{
|
||||
int gw = 0, gh = 0;
|
||||
rcCalcGridSize(m_bmin, m_bmax, m_cellSize, &gw, &gh);
|
||||
const int ts = (int)m_tileSize;
|
||||
const int tw = (gw + ts-1) / ts;
|
||||
const int th = (gh + ts-1) / ts;
|
||||
const float tcs = m_tileSize*m_cellSize;
|
||||
|
||||
for (int y = 0; y < th; ++y)
|
||||
{
|
||||
for (int x = 0; x < tw; ++x)
|
||||
{
|
||||
m_tileBmin[0] = m_bmin[0] + x*tcs;
|
||||
m_tileBmin[1] = m_bmin[1];
|
||||
m_tileBmin[2] = m_bmin[2] + y*tcs;
|
||||
|
||||
m_tileBmax[0] = m_bmin[0] + (x+1)*tcs;
|
||||
m_tileBmax[1] = m_bmax[1];
|
||||
m_tileBmax[2] = m_bmin[2] + (y+1)*tcs;
|
||||
|
||||
int dataSize = 0;
|
||||
unsigned char* data = buildTileMesh(m_tileBmin, m_tileBmax, dataSize);
|
||||
if (data)
|
||||
{
|
||||
// Remove any previous data (navmesh owns and deletes the data).
|
||||
m_navMesh->removeTileAt(x,y,0,0);
|
||||
// Let the navmesh own the data.
|
||||
if (!m_navMesh->addTileAt(x,y,data,dataSize,true))
|
||||
delete [] data;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Sample_TileMesh::removeAllTiles()
|
||||
{
|
||||
int gw = 0, gh = 0;
|
||||
rcCalcGridSize(m_bmin, m_bmax, m_cellSize, &gw, &gh);
|
||||
const int ts = (int)m_tileSize;
|
||||
const int tw = (gw + ts-1) / ts;
|
||||
const int th = (gh + ts-1) / ts;
|
||||
|
||||
for (int y = 0; y < th; ++y)
|
||||
for (int x = 0; x < tw; ++x)
|
||||
m_navMesh->removeTileAt(x,y,0,0);
|
||||
}
|
||||
|
||||
unsigned char* Sample_TileMesh::buildTileMesh(const float* bmin, const float* bmax, int& dataSize)
|
||||
{
|
||||
if (!m_verts || ! m_tris)
|
||||
|
||||
@@ -350,11 +350,8 @@ int main(int argc, char *argv[])
|
||||
pos[0] = rays[0] + (raye[0] - rays[0])*t;
|
||||
pos[1] = rays[1] + (raye[1] - rays[1])*t;
|
||||
pos[2] = rays[2] + (raye[2] - rays[2])*t;
|
||||
|
||||
if (SDL_GetModState() & KMOD_SHIFT)
|
||||
sample->setToolStartPos(pos);
|
||||
else
|
||||
sample->setToolEndPos(pos);
|
||||
bool shift = (SDL_GetModState() & KMOD_SHIFT) ? true : false;
|
||||
sample->handleClick(pos, shift);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -700,7 +697,7 @@ int main(int argc, char *argv[])
|
||||
// Tools
|
||||
if (showTools && showMenu && mesh && sample)
|
||||
{
|
||||
if (imguiBeginScrollArea("Tools", 10, height - 10 - 200, 150, 200, &toolsScroll))
|
||||
if (imguiBeginScrollArea("Tools", 10, height - 10 - 250, 200, 250, &toolsScroll))
|
||||
mouseOverMenu = true;
|
||||
|
||||
sample->handleTools();
|
||||
|
||||
Reference in New Issue
Block a user