优化:正确的设置洞的基点

pull/1912/head
ChenX 2 years ago
parent e80e4cae75
commit 8238cfccc1

@ -184,7 +184,7 @@ export class Command_DrawHole implements Command
hole.Position = new Vector3(0, 0, 800); hole.Position = new Vector3(0, 0, 800);
JigUtils.Draw(hole); JigUtils.Draw(hole);
let jigWalls: RoomWallBase[]; let fakerWalls: RoomWallBase[];
let helper = new RoomWallPlaceLHoleHelper(); let helper = new RoomWallPlaceLHoleHelper();
if (!helper._stands.length) if (!helper._stands.length)
@ -220,7 +220,7 @@ export class Command_DrawHole implements Command
if (v) if (v)
{ {
preWalls = undefined; preWalls = undefined;
jigWalls = []; fakerWalls = [];
let breakData = RoomWallParse._CacheWallMaps[helper._standGroupIndexMap.get(v)][0]; let breakData = RoomWallParse._CacheWallMaps[helper._standGroupIndexMap.get(v)][0];
@ -254,8 +254,8 @@ export class Command_DrawHole implements Command
else else
wall2.EndPoint = wall2.GetPointAtDistance(800); wall2.EndPoint = wall2.GetPointAtDistance(800);
jigWalls.push(wall1); fakerWalls.push(wall1);
jigWalls.push(wall2); fakerWalls.push(wall2);
for (let i = 0; i < walls.length; i++) for (let i = 0; i < walls.length; i++)
{ {
@ -276,23 +276,24 @@ export class Command_DrawHole implements Command
} }
else else
{ {
if (jigWalls) if (fakerWalls)
{ {
let moveV = p.clone().sub(jigWalls[0].EndPoint); let moveV = p.clone().sub(fakerWalls[0].EndPoint);
for (let wall of jigWalls) for (let wall of fakerWalls)
wall.Move(moveV); wall.Move(moveV);
} }
else else
{ {
jigWalls = [ fakerWalls = [
new RoomWallLine(p.clone().add(new Vector3(0, 800, 0)), p.clone()), new RoomWallLine(p.clone().add(new Vector3(0, 800, 0)), p.clone()),
new RoomWallLine(p.clone(), p.clone().add(new Vector3(800, 0, 0))), new RoomWallLine(p.clone(), p.clone().add(new Vector3(800, 0, 0))),
]; ];
} }
} }
new RoomWallParse(false, undefined, false).Parse(jigWalls); new RoomWallParse(false, undefined, false).Parse(fakerWalls);
hole.FakerWalls = jigWalls; hole.Position = fakerWalls[0].StartPoint.add(new Vector3(0, 0, 800));//在设置fakerwalls时 会改变它的位置,所以我们先复制这个点
hole.FakerWalls = fakerWalls;
hole.UpdatePoints(); hole.UpdatePoints();
return v; return v;
@ -359,7 +360,7 @@ export class Command_DrawHole implements Command
hole.Position = new Vector3(0, 0, 800); hole.Position = new Vector3(0, 0, 800);
JigUtils.Draw(hole); JigUtils.Draw(hole);
let jigWalls: RoomWallBase[]; let fakerWalls: RoomWallBase[];
let preR: Route; let preR: Route;
let preWalls: RoomWallBase[]; let preWalls: RoomWallBase[];
@ -411,7 +412,7 @@ export class Command_DrawHole implements Command
else else
wall2.EndPoint = r2.to.position; wall2.EndPoint = r2.to.position;
jigWalls = [wall1, wall, wall2]; fakerWalls = [wall1, wall, wall2];
preWalls = orgWalls; preWalls = orgWalls;
for (let i = 0; i < orgWalls.length; i++) for (let i = 0; i < orgWalls.length; i++)
@ -429,24 +430,25 @@ export class Command_DrawHole implements Command
orgWall.Update(); orgWall.Update();
} }
} }
else if (jigWalls) else if (fakerWalls)
{ {
let moveV = p.clone().sub(jigWalls[1].GetPointAtParam(0.5)); let moveV = p.clone().sub(fakerWalls[1].GetPointAtParam(0.5));
for (let wall of jigWalls) for (let wall of fakerWalls)
wall.Move(moveV); wall.Move(moveV);
} }
if (!jigWalls) if (!fakerWalls)
{ {
jigWalls = [ fakerWalls = [
new RoomWallLine(p.clone().add(new Vector3(-400, 600, 0)), p.clone().add(new Vector3(-400, 0, 0))), new RoomWallLine(p.clone().add(new Vector3(-400, 600, 0)), p.clone().add(new Vector3(-400, 0, 0))),
new RoomWallLine(p.clone().add(new Vector3(-400, 0, 0)), p.clone().add(new Vector3(400, 0, 0))), new RoomWallLine(p.clone().add(new Vector3(-400, 0, 0)), p.clone().add(new Vector3(400, 0, 0))),
new RoomWallLine(p.clone().add(new Vector3(400, 0, 0)), p.clone().add(new Vector3(400, 600, 0))), new RoomWallLine(p.clone().add(new Vector3(400, 0, 0)), p.clone().add(new Vector3(400, 600, 0))),
]; ];
} }
new RoomWallParse(false, undefined, false).Parse(jigWalls); new RoomWallParse(false, undefined, false).Parse(fakerWalls);
hole.FakerWalls = jigWalls; hole.Position = fakerWalls[0].StartPoint.add(new Vector3(0, 0, 800));//在设置fakerwalls时 会改变它的位置,所以我们先复制这个点
hole.FakerWalls = fakerWalls;
hole.UpdatePoints(); hole.UpdatePoints();
return route; return route;

Loading…
Cancel
Save