aboutsummaryrefslogtreecommitdiff
path: root/src/server/collision/Models
diff options
context:
space:
mode:
authorclick <none@none>2010-07-09 18:02:46 +0200
committerclick <none@none>2010-07-09 18:02:46 +0200
commit45e2a65fad6549ff93005ff166fba309c20259e0 (patch)
tree11634aa5284169cf6b7ae94f0ae95c2c4756a620 /src/server/collision/Models
parent9182ab6ead9ca4f7f08dc5741ec72496a0041e62 (diff)
Update VMap3 to "final" release (REEXTRACTION OF MAPS/VMAPS IS REQUIRED!) - thanks to Lynx3d (again)
- add magic-header to .vmtile files - calculate waterlevels for non-flat surfaces in a more correct way - make MSVC shut up about float-issues - change logging around a bit (output function that the respective logentry comes from) - remove remaining Stormlib leftovers - set indoor/outdoor check to enabled by default (more blizzlike) --HG-- branch : trunk
Diffstat (limited to 'src/server/collision/Models')
-rw-r--r--src/server/collision/Models/ModelInstance.cpp23
-rw-r--r--src/server/collision/Models/WorldModel.cpp63
2 files changed, 60 insertions, 26 deletions
diff --git a/src/server/collision/Models/ModelInstance.cpp b/src/server/collision/Models/ModelInstance.cpp
index 677a08e147a..af32d4026e7 100644
--- a/src/server/collision/Models/ModelInstance.cpp
+++ b/src/server/collision/Models/ModelInstance.cpp
@@ -1,24 +1,25 @@
/*
+ * Copyright (C) 2008-2010 TrinityCore <http://www.trinitycore.org/>
* Copyright (C) 2005-2010 MaNGOS <http://getmangos.com/>
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
*
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ModelInstance.h"
#include "WorldModel.h"
#include "MapTree.h"
+#include "VMapDefinitions.h"
using G3D::Vector3;
using G3D::Ray;
diff --git a/src/server/collision/Models/WorldModel.cpp b/src/server/collision/Models/WorldModel.cpp
index 690c77577ae..0bd156fedc2 100644
--- a/src/server/collision/Models/WorldModel.cpp
+++ b/src/server/collision/Models/WorldModel.cpp
@@ -1,19 +1,19 @@
/*
+ * Copyright (C) 2008-2010 TrinityCore <http://www.trinitycore.org/>
* Copyright (C) 2005-2010 MaNGOS <http://getmangos.com/>
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
*
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "WorldModel.h"
@@ -148,15 +148,48 @@ namespace VMAP
bool WmoLiquid::GetLiquidHeight(const Vector3 &pos, float &liqHeight) const
{
- uint32 tx = (pos.x - iCorner.x)/LIQUID_TILE_SIZE;
+ float tx_f = (pos.x - iCorner.x)/LIQUID_TILE_SIZE;
+ uint32 tx = uint32(tx_f);
if (tx<0 || tx >= iTilesX) return false;
- uint32 ty = (pos.y - iCorner.y)/LIQUID_TILE_SIZE;
+ float ty_f = (pos.y - iCorner.y)/LIQUID_TILE_SIZE;
+ uint32 ty = uint32(ty_f);
if (ty<0 || ty >= iTilesY) return false;
+
+ // check if tile shall be used for liquid level
// checking for 0x08 *might* be enough, but disabled tiles always are 0x?F:
if ((iFlags[tx + ty*iTilesX] & 0x0F) == 0x0F)
return false;
- //placeholder...use only lower left corner vertex
- liqHeight = /* iCorner.z + */ iHeight[tx + ty*(iTilesX+1)];
+
+ // (dx, dy) coordinates inside tile, in [0,1]^2
+ float dx = tx_f - (float)tx;
+ float dy = ty_f - (float)ty;
+
+ /* Tesselate tile to two triangles (not sure if client does it exactly like this)
+
+ ^ dy
+ |
+ 1 x---------x (1,1)
+ | (b) / |
+ | / |
+ | / |
+ | / (a) |
+ x---------x---> dx
+ 0 1
+ */
+
+ const uint32 rowOffset = iTilesX + 1;
+ if (dx > dy) // case (a)
+ {
+ float sx = iHeight[tx+1 + ty * rowOffset] - iHeight[tx + ty * rowOffset];
+ float sy = iHeight[tx+1 + (ty+1) * rowOffset] - iHeight[tx+1 + ty * rowOffset];
+ liqHeight = iHeight[tx + ty * rowOffset] + dx * sx + dy * sy;
+ }
+ else // case (b)
+ {
+ float sx = iHeight[tx+1 + (ty+1) * rowOffset] - iHeight[tx + (ty+1) * rowOffset];
+ float sy = iHeight[tx + (ty+1) * rowOffset] - iHeight[tx + ty * rowOffset];
+ liqHeight = iHeight[tx + ty * rowOffset] + dx * sx + dy * sy;
+ }
return true;
}