bugfixes in sub pathfinding, water body node generation and seabed

calculation
This commit is contained in:
devZoGok
2022-10-29 16:33:47 +03:00
parent 6837d3770d
commit 7473e2d8f1
4 changed files with 9 additions and 10 deletions
+2 -6
View File
@@ -27,7 +27,7 @@ def createCells(cellSize, mapSize, height, land):
for i in range(numCells):
xId = i % cellsByDim[0]
yId = i / (cellsByDim[0] * cellsByDim[2])
yId = int(i / (cellsByDim[0] * cellsByDim[2]))
zId = (int(i / cellsByDim[0])) % cellsByDim[2]
cp = initPos + np.array([xId * cellSize[0], -yId * cellSize[1], zId * cellSize[2]])
cellPos.append(cp)
@@ -37,10 +37,6 @@ def createCells(cellSize, mapSize, height, land):
cellsStr += '},\nimpassible = {\n'
for i in range(numCells):
xId = i % cellsByDim[0]
yId = i / (cellsByDim[0] * cellsByDim[2])
zId = (i / cellsByDim[0]) % cellsByDim[2]
waterbodyId = -1
impassible = False
@@ -131,7 +127,7 @@ content += '\t\talbedoMap = "' + baseFilename + '.jpg",\n'
terrDim = np.array([terrain.dimensions.x, terrain.dimensions.z, terrain.dimensions.y]);
maxTurnAngles = [.1]
sizes = [(14, 0, 14), (14, 6, 14)]
sizes = [(7, 0, 7), (7, 6, 7)]
content += '\t\tsize = {x = ' + str(terrDim[0]) + ', y = ' + str(terrDim[1]) + ', z = ' + str(terrDim[2]) + '},\n'
content += '\t\t' + createCells(sizes[0], terrDim, 0, True) + '\n'
+2 -1
View File
@@ -247,7 +247,8 @@ namespace battleship{
for(int j = 1; j < map->getNumTerrainObjects(); j++){
if(map->isPointWithinTerrainObject(u->getPos(), j) && map->isPointWithinTerrainObject(o.targets[i].pos, j)){
vector<Ray::CollisionResult> res;
Ray::retrieveCollisions(u->getPos(), Vector3(0, -1, 0), map->getTerrainObject(0).node->getChild(0), res);
Vector3 pos = u->getPos();
Ray::retrieveCollisions(Vector3(pos.x, 100, pos.z), Vector3(0, -1, 0), map->getTerrainObject(0).node->getChild(0), res);
Ray::sortResults(res);
o.targets[i].pos.y = res[0].pos.y + depth * (map->getTerrainObject(j).pos.y - res[0].pos.y);
break;
+1 -1
View File
@@ -172,7 +172,7 @@ namespace battleship{
}
void Map::load(string mapName) {
cellSize = Vector3(14, 6, 14);
cellSize = Vector3(7, 6, 7);
this->mapName = mapName;
LuaManager *luaManager = LuaManager::getSingleton();
+4 -2
View File
@@ -175,7 +175,7 @@ namespace battleship{
advance(movementAmmount);
}
if(fabs(pos.y - pathPoints[0].y) > destOffset){
if(fabs(pos.y - pathPoints[0].y) > 0.5 * height){
float dist = pos.y - pathPoints[0].y;
float movementAmmount = (speed > fabs(dist) ? dist : speed);
@@ -185,7 +185,9 @@ namespace battleship{
advance(movementAmmount, MoveDir::UP);
}
if(pos.getDistanceFrom(type != UnitType::UNDERWATER ? linDest : pathPoints[0]) <= destOffset)
if(type != UnitType::UNDERWATER && pos.getDistanceFrom(linDest) <= destOffset)
pathPoints.erase(pathPoints.begin());
else if(type == UnitType::UNDERWATER && fabs(pos.y - pathPoints[0].y) < 0.5 * height && pos.getDistanceFrom(linDest) <= destOffset)
pathPoints.erase(pathPoints.begin());
}