enabled depth_test for colorpicking
To do it many changes were needed, because mouse position on map was calculated using the depth buffer with current rendering state
This commit is contained in:
parent
4e0c96adae
commit
ab02478096
|
@ -4122,8 +4122,7 @@ void Game::mouseDownLeft(int x, int y) {
|
|||
if(setMarker) {
|
||||
Vec2i targetPos;
|
||||
Vec2i screenPos(x,y-60);
|
||||
Renderer &renderer= Renderer::getInstance();
|
||||
renderer.computePosition(screenPos, targetPos);
|
||||
targetPos=getMouseCellPos();
|
||||
//Vec2i surfaceCellPos = map->toSurfCoords(targetPos);
|
||||
|
||||
|
||||
|
@ -4137,8 +4136,7 @@ void Game::mouseDownLeft(int x, int y) {
|
|||
if(originalIsMarkCellEnabled == true && isMarkCellEnabled == true) {
|
||||
Vec2i targetPos;
|
||||
Vec2i screenPos(x,y-60);
|
||||
Renderer &renderer= Renderer::getInstance();
|
||||
renderer.computePosition(screenPos, targetPos);
|
||||
targetPos=getMouseCellPos();
|
||||
Vec2i surfaceCellPos = map->toSurfCoords(targetPos);
|
||||
|
||||
MarkedCell mc(targetPos,world.getThisFaction(),"placeholder for note",world.getThisFaction()->getStartLocationIndex());
|
||||
|
@ -4152,14 +4150,13 @@ void Game::mouseDownLeft(int x, int y) {
|
|||
chatManager.switchOnEdit(this,500);
|
||||
|
||||
//renderer.updateMarkedCellScreenPosQuadCache(surfaceCellPos);
|
||||
renderer.forceQuadCacheUpdate();
|
||||
Renderer::getInstance().forceQuadCacheUpdate();
|
||||
}
|
||||
|
||||
if(originalIsUnMarkCellEnabled == true && isUnMarkCellEnabled == true) {
|
||||
Vec2i targetPos;
|
||||
Vec2i screenPos(x,y-35);
|
||||
Renderer &renderer= Renderer::getInstance();
|
||||
renderer.computePosition(screenPos, targetPos);
|
||||
targetPos=getMouseCellPos();
|
||||
Vec2i surfaceCellPos = map->toSurfCoords(targetPos);
|
||||
|
||||
// if(mapMarkedCellList.find(surfaceCellPos) != mapMarkedCellList.end()) {
|
||||
|
@ -4177,7 +4174,7 @@ void Game::mouseDownLeft(int x, int y) {
|
|||
|
||||
//Renderer &renderer= Renderer::getInstance();
|
||||
//renderer.updateMarkedCellScreenPosQuadCache(surfaceCellPos);
|
||||
renderer.forceQuadCacheUpdate();
|
||||
Renderer::getInstance().forceQuadCacheUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4259,9 +4256,8 @@ void Game::mouseDownRight(int x, int y) {
|
|||
else {
|
||||
Vec2i targetPos;
|
||||
Vec2i screenPos(x,y);
|
||||
Renderer &renderer= Renderer::getInstance();
|
||||
renderer.computePosition(screenPos, targetPos);
|
||||
if(renderer.computePosition(screenPos, targetPos) == true &&
|
||||
targetPos=getMouseCellPos();
|
||||
if(isValidMouseCellPos() == true &&
|
||||
map->isInsideSurface(map->toSurfCoords(targetPos)) == true) {
|
||||
gui.mouseDownRightGraphics(x, y,false);
|
||||
}
|
||||
|
@ -4521,7 +4517,7 @@ void Game::mouseMove(int x, int y, const MouseState *ms) {
|
|||
lastMousePos.y = mouseY;
|
||||
|
||||
Renderer &renderer= Renderer::getInstance();
|
||||
renderer.computePosition(Vec2i(mouseX, mouseY), mouseCellPos);
|
||||
renderer.ccomputePosition(Vec2i(mouseX, mouseY), mouseCellPos);
|
||||
}
|
||||
catch(const exception &ex) {
|
||||
char szBuf[8096]="";
|
||||
|
@ -4541,6 +4537,15 @@ void Game::mouseMove(int x, int y, const MouseState *ms) {
|
|||
}
|
||||
}
|
||||
|
||||
bool Game::isValidMouseCellPos() const{
|
||||
if(world.getMap() == NULL){
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
return world.getMap()->isInside(mouseCellPos);
|
||||
}
|
||||
}
|
||||
|
||||
void Game::eventMouseWheel(int x, int y, int zDelta) {
|
||||
if(this->masterserverMode == true) {
|
||||
return;
|
||||
|
|
|
@ -257,6 +257,9 @@ public:
|
|||
|
||||
Program *getProgram() {return program;}
|
||||
|
||||
Vec2i getMouseCellPos() const {return mouseCellPos;}
|
||||
bool isValidMouseCellPos() const;
|
||||
|
||||
void removeUnitFromSelection(const Unit *unit);
|
||||
bool addUnitToSelection(Unit *unit);
|
||||
void addUnitToGroupSelection(Unit *unit,int groupIndex);
|
||||
|
|
|
@ -1648,11 +1648,11 @@ void Renderer::renderMouse2d(int x, int y, int anim, float fade) {
|
|||
|
||||
if(game->isMarkCellMode() == true) {
|
||||
const Texture2D *texture= game->getMarkCellTexture();
|
||||
renderTextureQuad(x-18,y-50,texture->getTextureWidth(),texture->getTextureHeight(),texture,0.8f);
|
||||
renderTextureQuad(x,y,texture->getTextureWidth(),texture->getTextureHeight(),texture,0.8f);
|
||||
}
|
||||
if(game->isUnMarkCellMode() == true) {
|
||||
const Texture2D *texture= game->getUnMarkCellTexture();
|
||||
renderTextureQuad(x-18,y-50,texture->getTextureWidth(),texture->getTextureHeight(),texture,0.8f);
|
||||
renderTextureQuad(x,y,texture->getTextureWidth(),texture->getTextureHeight(),texture,0.8f);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6274,7 +6274,7 @@ void Renderer::renderHighlightedCellsOnMinimap() {
|
|||
|
||||
|
||||
//int mx= metrics.getMinimapX();
|
||||
int my= metrics.getMinimapY();
|
||||
//int my= metrics.getMinimapY();
|
||||
int mw= metrics.getMinimapW();
|
||||
int mh= metrics.getMinimapH();
|
||||
|
||||
|
@ -6297,7 +6297,8 @@ void Renderer::renderHighlightedCellsOnMinimap() {
|
|||
if(texture != NULL) {
|
||||
//float alpha = 0.49f+0.5f/(mc->getAliveCount()%15);
|
||||
float alpha=1.0f;
|
||||
renderTextureQuad((int)(pos.x*zoom.x)+pointersize, my + mh-(int)(pos.y*zoom.y), pointersize, pointersize, texture, alpha,&myColor);
|
||||
renderTextureQuad((int)(pos.x*zoom.x),(int)(pos.y*zoom.y), pointersize, pointersize, texture, alpha,&myColor);
|
||||
//renderTextureQuad((int)(pos.x*zoom.x)+pointersize, my + mh-(int)(pos.y*zoom.y), pointersize, pointersize, texture, alpha,&myColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6394,7 +6395,7 @@ void Renderer::renderVisibleMarkedCells(bool renderTextHint,int x, int y) {
|
|||
std::map<Vec2i, MarkedCell> markedCells = game->getMapMarkedCellList();
|
||||
if(markedCells.empty() == false) {
|
||||
const Texture2D *texture= game->getMarkCellTexture();
|
||||
const int yOffset = 10;
|
||||
const int yOffset = -40;
|
||||
|
||||
for(std::map<Vec2i, MarkedCell>::iterator iterMap =markedCells.begin();
|
||||
iterMap != markedCells.end(); ++iterMap) {
|
||||
|
@ -6885,7 +6886,7 @@ void Renderer::renderMenuBackground(Camera *camera, float fade, Model *mainModel
|
|||
|
||||
// ==================== computing ====================
|
||||
|
||||
bool Renderer::computePosition(const Vec2i &screenPos, Vec2i &worldPos, bool exactCoords) {
|
||||
bool Renderer::ccomputePosition(const Vec2i &screenPos, Vec2i &worldPos, bool exactCoords) {
|
||||
assertGl();
|
||||
const Map* map= game->getWorld()->getMap();
|
||||
const Metrics &metrics= Metrics::getInstance();
|
||||
|
|
|
@ -568,7 +568,7 @@ public:
|
|||
void renderMenuBackground(Camera *camera, float fade, Model *mainModel, vector<Model *> characterModels,const Vec3f characterPosition, float anim);
|
||||
|
||||
//computing
|
||||
bool computePosition(const Vec2i &screenPos, Vec2i &worldPos,bool exactCoords=false);
|
||||
bool ccomputePosition(const Vec2i &screenPos, Vec2i &worldPos,bool exactCoords=false);
|
||||
void computeSelected(Selection::UnitContainer &units, const Object *&obj, const bool withObjectSelection, const Vec2i &posDown, const Vec2i &posUp);
|
||||
void selectUsingColorPicking(Selection::UnitContainer &units, const Object *&obj,const bool withObjectSelection,const Vec2i &posDown, const Vec2i &posUp);
|
||||
void selectUsingSelectionBuffer(Selection::UnitContainer &units,const Object *&obj, const bool withObjectSelection,const Vec2i &posDown, const Vec2i &posUp);
|
||||
|
|
|
@ -256,8 +256,8 @@ void Gui::mouseMoveOutsideDisplay() {
|
|||
void Gui::mouseDownLeftGraphics(int x, int y, bool prepared) {
|
||||
if(selectingPos) {
|
||||
//give standard orders
|
||||
Vec2i targetPos;
|
||||
if(Renderer::getInstance().computePosition(Vec2i(x, y), targetPos) &&
|
||||
Vec2i targetPos=game->getMouseCellPos();
|
||||
if(game->isValidMouseCellPos() &&
|
||||
world->getMap()->isInsideSurface(world->getMap()->toSurfCoords(targetPos)) == true) {
|
||||
giveTwoClickOrders(x, y, prepared);
|
||||
}
|
||||
|
@ -266,8 +266,8 @@ void Gui::mouseDownLeftGraphics(int x, int y, bool prepared) {
|
|||
//set meeting point
|
||||
else if(selectingMeetingPoint) {
|
||||
if(selection.isCommandable()) {
|
||||
Vec2i targetPos;
|
||||
if(Renderer::getInstance().computePosition(Vec2i(x, y), targetPos) &&
|
||||
Vec2i targetPos=game->getMouseCellPos();
|
||||
if(game->isValidMouseCellPos() &&
|
||||
world->getMap()->isInsideSurface(world->getMap()->toSurfCoords(targetPos)) == true) {
|
||||
commander->trySetMeetingPoint(selection.getFrontUnit(), targetPos);
|
||||
}
|
||||
|
@ -287,15 +287,15 @@ void Gui::mouseDownRightGraphics(int x, int y , bool prepared) {
|
|||
}
|
||||
else if(selection.isCommandable()) {
|
||||
if(prepared) {
|
||||
Vec2i targetPos;
|
||||
if(Renderer::getInstance().computePosition(Vec2i(x, y), targetPos) &&
|
||||
Vec2i targetPos=game->getMouseCellPos();
|
||||
if(game->isValidMouseCellPos() &&
|
||||
world->getMap()->isInsideSurface(world->getMap()->toSurfCoords(targetPos)) == true) {
|
||||
givePreparedDefaultOrders(x, y);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Vec2i targetPos;
|
||||
if(Renderer::getInstance().computePosition(Vec2i(x, y), targetPos) &&
|
||||
Vec2i targetPos=game->getMouseCellPos();
|
||||
if(game->isValidMouseCellPos() &&
|
||||
world->getMap()->isInsideSurface(world->getMap()->toSurfCoords(targetPos)) == true) {
|
||||
giveDefaultOrders(x, y);
|
||||
}
|
||||
|
@ -331,7 +331,8 @@ void Gui::mouseMoveGraphics(int x, int y) {
|
|||
|
||||
//compute position for building
|
||||
if(isPlacingBuilding()){
|
||||
validPosObjWorld= Renderer::getInstance().computePosition(Vec2i(x,y), posObjWorld);
|
||||
posObjWorld=game->getMouseCellPos();
|
||||
validPosObjWorld= game->isValidMouseCellPos();
|
||||
}
|
||||
|
||||
display.setInfoText("");
|
||||
|
@ -1160,8 +1161,7 @@ bool Gui::computeTarget(const Vec2i &screenPos, Vec2i &targetPos, const Unit *&t
|
|||
if(selObj != NULL) {
|
||||
selObj->resetHighlight();
|
||||
// get real click pos
|
||||
renderer.computePosition(screenPos, targetPos);
|
||||
|
||||
targetPos=game->getMouseCellPos();
|
||||
//validPosObjWorld= true;
|
||||
//posObjWorld = targetPos;
|
||||
|
||||
|
@ -1252,7 +1252,8 @@ bool Gui::computeTarget(const Vec2i &screenPos, Vec2i &targetPos, const Unit *&t
|
|||
}
|
||||
else{
|
||||
targetUnit= NULL;
|
||||
if(renderer.computePosition(screenPos, targetPos)){
|
||||
targetPos=game->getMouseCellPos();
|
||||
if(game->isValidMouseCellPos()){
|
||||
validPosObjWorld= true;
|
||||
posObjWorld= targetPos;
|
||||
|
||||
|
|
|
@ -2068,6 +2068,10 @@ void BaseColorPickEntity::beginPicking() {
|
|||
glDisable(GL_POLYGON_OFFSET_FILL);
|
||||
glDisable(GL_NORMALIZE);
|
||||
|
||||
// all off, but we want depth test
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
//glPushAttrib(GL_TEXTURE_2D | GL_LIGHTING | GL_BLEND | GL_MULTISAMPLE | GL_DITHER);
|
||||
//glPushAttrib(GL_ENABLE_BIT | GL_LIGHTING_BIT | GL_POLYGON_BIT | GL_CURRENT_BIT | GL_TEXTURE_BIT | GL_NORMALIZE | GL_BLEND | GL_POLYGON_OFFSET_FILL);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue