camera max height/ default are calculated based on the max height of a map
This commit is contained in:
parent
12dcc54c5a
commit
91abdd3ed4
|
@ -549,6 +549,10 @@ void Game::init(bool initForPreviewOnly)
|
|||
|
||||
gameCamera.init(map->getW(), map->getH());
|
||||
|
||||
if(gameCamera.getCalculatedDefault()<map->getMaxMapHeight()+13.0f){
|
||||
gameCamera.setCalculatedDefault(map->getMaxMapHeight()+13.0f);
|
||||
}
|
||||
|
||||
if(world.getThisFaction() != NULL) {
|
||||
const Vec2i &v= map->getStartLocation(world.getThisFaction()->getStartLocationIndex());
|
||||
gameCamera.setPos(Vec2f(v.x, v.y));
|
||||
|
|
|
@ -46,6 +46,7 @@ const float GameCamera::centerOffsetZ= 8.0f;
|
|||
GameCamera::GameCamera() : pos(0.f, defaultHeight, 0.f),
|
||||
destPos(0.f, defaultHeight, 0.f), destAng(startingVAng, startingHAng) {
|
||||
Config &config = Config::getInstance();
|
||||
calculatedDefault=defaultHeight;
|
||||
state= sGame;
|
||||
|
||||
cacheVisibleQuad.clear();
|
||||
|
@ -88,6 +89,14 @@ void GameCamera::setMaxHeight(float value) {
|
|||
}
|
||||
}
|
||||
|
||||
void GameCamera::setCalculatedDefault(float calculatedDefault){
|
||||
this->calculatedDefault= calculatedDefault;
|
||||
if(maxHeight>0 && maxHeight<calculatedDefault){
|
||||
setMaxHeight(calculatedDefault);
|
||||
}
|
||||
resetPosition();
|
||||
}
|
||||
|
||||
void GameCamera::init(int limitX, int limitY){
|
||||
this->limitX= limitX;
|
||||
this->limitY= limitY;
|
||||
|
@ -239,7 +248,7 @@ void GameCamera::switchState(){
|
|||
state= sGame;
|
||||
destAng.x = startingVAng;
|
||||
destAng.y = startingHAng;
|
||||
destPos.y = defaultHeight;
|
||||
destPos.y = calculatedDefault;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -247,7 +256,7 @@ void GameCamera::resetPosition(){
|
|||
state= sGame;
|
||||
destAng.x = startingVAng;
|
||||
destAng.y = startingHAng;
|
||||
destPos.y = defaultHeight;
|
||||
destPos.y = calculatedDefault;
|
||||
}
|
||||
|
||||
void GameCamera::centerXZ(float x, float z){
|
||||
|
|
|
@ -83,6 +83,8 @@ private:
|
|||
float maxVAng;
|
||||
float fov;
|
||||
|
||||
float calculatedDefault;
|
||||
|
||||
int MaxVisibleQuadItemCache;
|
||||
|
||||
public:
|
||||
|
@ -130,6 +132,10 @@ public:
|
|||
|
||||
void setClampBounds(bool value) { clampBounds = value; }
|
||||
void setMaxHeight(float value);
|
||||
float getCalculatedDefault() const{ return calculatedDefault; }
|
||||
void setCalculatedDefault(float calculatedDefault);
|
||||
|
||||
float getMaxHeight() const {return maxHeight;}
|
||||
void setFov(float value) { fov = value; }
|
||||
void setMinVAng(float value) { minVAng = value; }
|
||||
void setMaxVAng(float value) { maxVAng = value; }
|
||||
|
|
|
@ -273,6 +273,7 @@ Checksum Map::load(const string &path, TechTree *techTree, Tileset *tileset) {
|
|||
|
||||
void Map::init(Tileset *tileset) {
|
||||
Logger::getInstance().add("Heightmap computations", true);
|
||||
maxMapHeight=0.0f;
|
||||
smoothSurface(tileset);
|
||||
computeNormals();
|
||||
computeInterpolatedHeights();
|
||||
|
@ -1094,6 +1095,7 @@ void Map::computeInterpolatedHeights(){
|
|||
|
||||
void Map::smoothSurface(Tileset *tileset) {
|
||||
float *oldHeights = new float[getSurfaceCellArraySize()];
|
||||
int arraySize=getSurfaceCellArraySize();
|
||||
|
||||
for (int i = 0; i < getSurfaceCellArraySize(); ++i) {
|
||||
oldHeights[i] = surfaceCells[i].getHeight();
|
||||
|
@ -1135,6 +1137,9 @@ void Map::smoothSurface(Tileset *tileset) {
|
|||
}
|
||||
|
||||
height /= numUsedToSmooth;
|
||||
if(maxMapHeight<height){
|
||||
maxMapHeight=height;
|
||||
}
|
||||
|
||||
getSurfaceCell(i, j)->setHeight(height);
|
||||
Object *object = getSurfaceCell(i, j)->getObject();
|
||||
|
|
|
@ -166,6 +166,7 @@ private:
|
|||
SurfaceCell *surfaceCells;
|
||||
Vec2i *startLocations;
|
||||
Checksum checksumValue;
|
||||
float maxMapHeight;
|
||||
|
||||
private:
|
||||
Map(Map&);
|
||||
|
@ -194,6 +195,7 @@ public:
|
|||
float getHeightFactor() const {return heightFactor;}
|
||||
float getWaterLevel() const {return waterLevel;}
|
||||
float getCliffLevel() const {return cliffLevel;}
|
||||
float getMaxMapHeight() const {return maxMapHeight;}
|
||||
Vec2i getStartLocation(int locationIndex) const;
|
||||
bool getSubmerged(const SurfaceCell *sc) const {return sc->getHeight()<waterLevel;}
|
||||
bool getSubmerged(const Cell *c) const {return c->getHeight()<waterLevel;}
|
||||
|
|
Loading…
Reference in New Issue