From b0c15ebe496b2e3e4f6fd0202bbf7dd2a5602609 Mon Sep 17 00:00:00 2001 From: thetime50 <1004763777@qq.com> Date: Thu, 21 Mar 2024 18:48:03 +0800 Subject: [PATCH] idastar back --- vue3-tsv/src/components/MenuTree/MenuTree.vue | 8 +- vue3-tsv/src/views/aStar/aStarMath.ts | 14 +- vue3-tsv/src/views/idaStar/idaStar.vue | 75 ++++++-- vue3-tsv/src/views/idaStar/numBoard.ts | 173 ++++++++++++++++++ vue3-tsv/src/views/splineView/splineView.vue | 17 +- 5 files changed, 264 insertions(+), 23 deletions(-) create mode 100644 vue3-tsv/src/views/idaStar/numBoard.ts diff --git a/vue3-tsv/src/components/MenuTree/MenuTree.vue b/vue3-tsv/src/components/MenuTree/MenuTree.vue index 234a010..88072cd 100644 --- a/vue3-tsv/src/components/MenuTree/MenuTree.vue +++ b/vue3-tsv/src/components/MenuTree/MenuTree.vue @@ -41,9 +41,9 @@ const attrs = useAttrs(); // eslint-disable-line const collapsed = ref(false); const selected = ref(""); -watch(selected,(selected)=>{ - console.log("selected",toRaw( selected)); -}); +// watch(selected,(selected)=>{ +// console.log("selected",toRaw( selected)); +// }); const items = ref(menuData); @@ -59,7 +59,7 @@ console.log('items',toRaw(items.value)); top:25px; left: 25px; opacity: 0.3; - z-index: 100; + z-index: 10001; &:hover{ opacity: 1; } diff --git a/vue3-tsv/src/views/aStar/aStarMath.ts b/vue3-tsv/src/views/aStar/aStarMath.ts index e62dfb6..c2e2e58 100644 --- a/vue3-tsv/src/views/aStar/aStarMath.ts +++ b/vue3-tsv/src/views/aStar/aStarMath.ts @@ -1,3 +1,4 @@ +import { clone } from "lodash"; import { init as zrInit, ZRenderType, Circle, Rect, Line, Text, Group, Element, Displayable, ElementEvent, @@ -638,7 +639,7 @@ abstract class AStarBase{ item: item, }; } - if (item.gpriority !== undefined) { + if (item.gpriority !== undefined) { // 这里需要拆分为open close return { state: 'have', item: item, @@ -648,7 +649,7 @@ abstract class AStarBase{ item: item, ... itemCoord, }; - if( this.stepTest){ + if( this.stepTest){ // 斜向跨越墙壁测试 const testRes = this.stepTest(itemInfo, parentInfo); if (testRes){ return testRes; @@ -703,6 +704,7 @@ abstract class AStarBase{ childs.forEach(child => { const res = this.setItemPriority(child,{x,y,item}); // 新的可能点 const key = child.x + '-' + child.y; + // 这里的逻辑有点问题 if (res.state === 'update' && !this.openSet[key]){ let sotIndex:number|undefined = undefined; this.openSet[key] = res.item; @@ -742,7 +744,7 @@ abstract class AStarBase{ return { stae: this.state, update: updateList, - gpriority: item.gpriority! + 1, + gpriority: item.gpriority!, }; } getPath(){ @@ -977,13 +979,13 @@ export class AStarRuntime{ gradientRow: Array> = []; maxGpriority = 0; run(){ - const update: Array> = []; + const update: Array> = []; // 按接近的已消费代价分段 let lastArr: Array< Coord > = []; - let gpriority = 0; + let gpriority = -1; for (; this.astar.state !== AStarState.Done && this.astar.state !== AStarState.Never ; ){ const res = this.astar.runStep(); if (res.update){ - if (res.gpriority !== gpriority){ + if (Math.abs( res.gpriority - gpriority) > 0.0001){ lastArr.length && update.push(lastArr); lastArr = res.update.concat(); gpriority = res.gpriority!; diff --git a/vue3-tsv/src/views/idaStar/idaStar.vue b/vue3-tsv/src/views/idaStar/idaStar.vue index 455cf96..c5f7be0 100644 --- a/vue3-tsv/src/views/idaStar/idaStar.vue +++ b/vue3-tsv/src/views/idaStar/idaStar.vue @@ -1,20 +1,28 @@