mirror of
https://github.com/ApfelTeeSaft/PlanetFleet.git
synced 2026-08-26 19:33:38 +00:00
Binary file not shown.
|
Before Width: | Height: | Size: 6.9 KiB After Width: | Height: | Size: 2.9 KiB |
Executable
BIN
Binary file not shown.
|
After Width: | Height: | Size: 49 KiB |
+37324
-36468
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
Before Width: | Height: | Size: 1.0 MiB |
+61206
-61206
File diff suppressed because it is too large
Load Diff
+27
-8
@@ -438,21 +438,40 @@ namespace battleship{
|
||||
Node *nodeParent = map->getNodeParent();
|
||||
|
||||
if(u->getType() == UnitType::UNDERWATER && nodeParent->getNumChildren() > 0){
|
||||
vector<RayCaster::CollisionResult> res = map->raycastTerrain(Vector3(pos.x, 100, pos.z), Vector3(0, -1, 0), false);
|
||||
|
||||
Vector3 waterBodyPos = Vector3::VEC_ZERO;
|
||||
Vector3 cellSize = map->getCellSize();
|
||||
Vector3 cellSize = map->getCellSize(), waterBodyPos;
|
||||
bool inWater = false;
|
||||
|
||||
for(int i = 1; i < nodeParent->getNumChildren(); i++){
|
||||
Vector3 wpos = nodeParent->getChild(i)->getPosition();
|
||||
Vector3 wPos = nodeParent->getChild(i)->getPosition();
|
||||
Vector3 wSize = ((Quad*)nodeParent->getChild(i)->getMesh(0))->getSize();
|
||||
|
||||
if(fabs(wpos.x - pos.x) < .5 * cellSize.x && fabs(wpos.z - pos.z) < .5 * cellSize.z){
|
||||
waterBodyPos = wpos;
|
||||
if(fabs(wPos.x - pos.x) < .5 * wSize.x && fabs(wPos.z - pos.z) < .5 * wSize.y){
|
||||
waterBodyPos = wPos;
|
||||
inWater = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
results[0].pos.y = res[0].pos.y + depth * (waterBodyPos.y - res[0].pos.y);
|
||||
if(inWater){
|
||||
vector<RayCaster::CollisionResult> res = map->raycastTerrain(
|
||||
Vector3(results[0].pos.x, 100, results[0].pos.z),
|
||||
-Vector3::VEC_J,
|
||||
false
|
||||
);
|
||||
|
||||
vector<Map::Cell> &cells = map->getCells();
|
||||
int cid = map->getCellId(results[0].pos, false);
|
||||
int numSubmarineCells = cells[cid].underWaterCellIds.size();
|
||||
float maxDepth = cells[cid].pos.y;
|
||||
float minDepth = (numSubmarineCells > 0 ? cells[cells[cid].underWaterCellIds[numSubmarineCells - 1]].pos.y : maxDepth) - .5 * cellSize.y;
|
||||
|
||||
float newDepth = res[0].pos.y + depth * (waterBodyPos.y - res[0].pos.y);
|
||||
|
||||
if(newDepth < minDepth) newDepth = minDepth;
|
||||
else if(newDepth > maxDepth) newDepth = maxDepth;
|
||||
|
||||
results[0].pos.y = newDepth;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ namespace battleship{
|
||||
using namespace gameBase;
|
||||
|
||||
const std::string DEFAULT_TEXTURE = "Textures/defaultTexture.jpg";
|
||||
const double camPanSpeed = .5, CAMERA_DISTANCE = 100, CAMERA_ZOOM_INCREMENT = 1, cellLength = 14, cellWidth = 14, cellDepth = 7, DIST_FROM_RAY = 20;
|
||||
const double camPanSpeed = .5, CAMERA_DISTANCE = 100, CAMERA_ZOOM_INCREMENT = 1, cellLength = 7, cellWidth = 7, cellDepth = 7, DIST_FROM_RAY = 15;
|
||||
const int maxNumGroups = 10, NUM_MAX_ZOOMS = 75;
|
||||
const vb01::u32 IMPASS_NODE_VAL = 65535;
|
||||
|
||||
|
||||
Vendored
+1
-1
Submodule external/vb01 updated: 23304a10e9...21e742f930
@@ -698,6 +698,8 @@ namespace battleship{
|
||||
if(fabs(cells[cellId].pos.y - pos.y) < .5 * CELL_SIZE.y)
|
||||
return cellId;
|
||||
}
|
||||
|
||||
return cellId;
|
||||
}
|
||||
else
|
||||
return surfaceCellId;
|
||||
|
||||
@@ -333,24 +333,21 @@ namespace battleship{
|
||||
//TODO add diagnally adjacent edges to underwater cells
|
||||
vector<Map::Cell> MapEditorAppState::MapEditor::generateMapCells(){
|
||||
Vector3 mapSize = map->getMapSize();
|
||||
Vector3 startPos = -.49 * Vector3(mapSize.x, 0, mapSize.z), cellSize = map->getCellSize();
|
||||
Vector3 cellSize = map->getCellSize();
|
||||
Vector3 startPos = -.5 * (Vector3(mapSize.x, 0, mapSize.z) - Vector3(cellSize.x, 0, cellSize.z));
|
||||
|
||||
int numHorCells = int(mapSize.x / cellSize.x);
|
||||
int numVertCells = int(mapSize.z / cellSize.z);
|
||||
vector<Map::Cell> cells;
|
||||
vector<pair<int, float>> waterBodyBedPoints;
|
||||
Node *terrainNode = map->getNodeParent();
|
||||
|
||||
|
||||
for(int i = 0; i < numVertCells; i++)
|
||||
for(int j = 0; j < numHorCells; j++){
|
||||
Vector3 rayPos = startPos + Vector3(cellSize.x * j, 100, cellSize.z * i);
|
||||
vector<RayCaster::CollisionResult> res = RayCaster::cast(rayPos, -Vector3::VEC_J, terrainNode->getChild(0), 0, configData::DIST_FROM_RAY);
|
||||
|
||||
if(res.empty()){
|
||||
RayCaster::CollisionResult r;
|
||||
r.pos = Vector3(rayPos.x, 0, rayPos.z);
|
||||
res.push_back(r);
|
||||
}
|
||||
|
||||
Map::Cell::Type type = Map::Cell::Type::LAND;
|
||||
Vector3 pos = res[0].pos;
|
||||
|
||||
@@ -367,7 +364,8 @@ namespace battleship{
|
||||
}
|
||||
|
||||
vector<Map::Edge> edges = Map::generateAdjacentNodeEdges(numVertCells, i, numHorCells, j, 10);
|
||||
cells.push_back(Map::Cell(pos, type, edges));
|
||||
Map::Cell cell = Map::Cell(pos, type, edges);
|
||||
cells.push_back(cell);
|
||||
}
|
||||
|
||||
vector<Map::Cell> surfaceWaterCells;
|
||||
@@ -389,7 +387,7 @@ namespace battleship{
|
||||
|
||||
for(int i = 0; i < surfaceWaterCells.size(); i++){
|
||||
for(int j = 0; j < surfaceWaterCells[i].underWaterCellIds.size(); j++){
|
||||
int aboveCellId = (j == 0 ? surfaceWaterCells[i].edges[0].srcCellId : j - 1);
|
||||
int aboveCellId = (j == 0 ? surfaceWaterCells[i].edges[0].srcCellId : surfaceWaterCells[i].underWaterCellIds[j - 1]);
|
||||
vector<Map::Edge> edges = vector<Map::Edge>{Map::Edge(weight, surfaceWaterCells[i].underWaterCellIds[j], aboveCellId)};
|
||||
|
||||
if(surfaceWaterCells[i].underWaterCellIds.size() > j + 1)
|
||||
|
||||
+1
-1
@@ -128,7 +128,7 @@ namespace battleship{
|
||||
advance(movementAmmount);
|
||||
}
|
||||
|
||||
if(vertDist > 0.5 * height){
|
||||
if(vertDist > .1){
|
||||
float dist = pos.y - pathPoints[0].y;
|
||||
float movementAmmount = (speed > fabs(dist) ? dist : speed);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user