mirror of
https://github.com/mangosfour/server.git
synced 2025-12-25 13:37:02 +00:00
[10272] Add option for search distance to getHeight() functions and make Creature::FallGround() use VMaps properly.
This finally prevents flying creatures from falling to infinity (basically instantly diappearing) in several instances, aswell as prevent creatures from falling inside larger solid object around the world. Default height search is untouched, needs more research on how creature AI etc. will be affected.
This commit is contained in:
parent
747d1ebdcf
commit
730b4deaaf
10 changed files with 18 additions and 26 deletions
|
|
@ -61,7 +61,7 @@ namespace VMAP
|
|||
virtual void unloadMap(unsigned int pMapId) = 0;
|
||||
|
||||
virtual bool isInLineOfSight(unsigned int pMapId, float x1, float y1, float z1, float x2, float y2, float z2) = 0;
|
||||
virtual float getHeight(unsigned int pMapId, float x, float y, float z) = 0;
|
||||
virtual float getHeight(unsigned int pMapId, float x, float y, float z, float maxSearchDist) = 0;
|
||||
/**
|
||||
test if we hit an object. return true if we hit one. rx,ry,rz will hold the hit position or the dest position, if no intersection was found
|
||||
return a position, that is pReduceDist closer to the origin
|
||||
|
|
|
|||
|
|
@ -217,12 +217,12 @@ namespace VMAP
|
|||
|
||||
//=========================================================
|
||||
|
||||
float StaticMapTree::getHeight(const Vector3& pPos) const
|
||||
float StaticMapTree::getHeight(const Vector3& pPos, float maxSearchDist) const
|
||||
{
|
||||
float height = G3D::inf();
|
||||
Vector3 dir = Vector3(0,0,-1);
|
||||
G3D::Ray ray(pPos, dir); // direction with length of 1
|
||||
float maxDist = VMapDefinitions::getMaxCanFallDistance();
|
||||
float maxDist = maxSearchDist;
|
||||
if (getIntersectionTime(ray, maxDist, false))
|
||||
{
|
||||
height = pPos.z - maxDist;
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ namespace VMAP
|
|||
|
||||
bool isInLineOfSight(const G3D::Vector3& pos1, const G3D::Vector3& pos2) const;
|
||||
bool getObjectHitPos(const G3D::Vector3& pos1, const G3D::Vector3& pos2, G3D::Vector3& pResultHitPos, float pModifyDist) const;
|
||||
float getHeight(const G3D::Vector3& pPos) const;
|
||||
float getHeight(const G3D::Vector3& pPos, float maxSearchDist) const;
|
||||
bool getAreaInfo(G3D::Vector3 &pos, uint32 &flags, int32 &adtId, int32 &rootId, int32 &groupId) const;
|
||||
bool GetLocationInfo(const Vector3 &pos, LocationInfo &info) const;
|
||||
|
||||
|
|
|
|||
|
|
@ -24,18 +24,8 @@
|
|||
|
||||
namespace VMAP
|
||||
{
|
||||
//=====================================
|
||||
#define MAX_CAN_FALL_DISTANCE 10.0f
|
||||
const char VMAP_MAGIC[] = "VMAP_3.0";
|
||||
|
||||
class VMapDefinitions
|
||||
{
|
||||
public:
|
||||
static float getMaxCanFallDistance() { return MAX_CAN_FALL_DISTANCE; }
|
||||
};
|
||||
|
||||
//======================================
|
||||
|
||||
// defined in TileAssembler.cpp currently...
|
||||
bool readChunk(FILE *rf, char *dest, const char *compare, uint32 len);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -234,7 +234,7 @@ namespace VMAP
|
|||
get height or INVALID_HEIGHT if no height available
|
||||
*/
|
||||
|
||||
float VMapManager2::getHeight(unsigned int pMapId, float x, float y, float z)
|
||||
float VMapManager2::getHeight(unsigned int pMapId, float x, float y, float z, float maxSearchDist)
|
||||
{
|
||||
float height = VMAP_INVALID_HEIGHT_VALUE; //no height
|
||||
if (isHeightCalcEnabled())
|
||||
|
|
@ -243,7 +243,7 @@ namespace VMAP
|
|||
if (instanceTree != iInstanceMapTrees.end())
|
||||
{
|
||||
Vector3 pos = convertPositionToInternalRep(x,y,z);
|
||||
height = instanceTree->second->getHeight(pos);
|
||||
height = instanceTree->second->getHeight(pos, maxSearchDist);
|
||||
if (!(height < G3D::inf()))
|
||||
{
|
||||
height = VMAP_INVALID_HEIGHT_VALUE; //no height
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ namespace VMAP
|
|||
fill the hit pos and return true, if an object was hit
|
||||
*/
|
||||
bool getObjectHitPos(unsigned int pMapId, float x1, float y1, float z1, float x2, float y2, float z2, float& rx, float &ry, float& rz, float pModifyDist);
|
||||
float getHeight(unsigned int pMapId, float x, float y, float z);
|
||||
float getHeight(unsigned int pMapId, float x, float y, float z, float maxSearchDist);
|
||||
|
||||
bool processCommand(char *pCommand) { return false; } // for debug and extensions
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue