All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Object.cpp File Reference
#include "Object.h"
#include "Common.h"
#include "SharedDefines.h"
#include "WorldPacket.h"
#include "Opcodes.h"
#include "Log.h"
#include "World.h"
#include "Creature.h"
#include "Player.h"
#include "Vehicle.h"
#include "ObjectMgr.h"
#include "UpdateData.h"
#include "UpdateMask.h"
#include "Util.h"
#include "ObjectAccessor.h"
#include "Transport.h"
#include "VMapFactory.h"
#include "CellImpl.h"
#include "GridNotifiers.h"
#include "GridNotifiersImpl.h"
#include "SpellAuraEffects.h"
#include "UpdateFieldFlags.h"
#include "TemporarySummon.h"
#include "Totem.h"
#include "MovementPackets.h"
#include "OutdoorPvPMgr.h"
#include "Unit.h"
#include "BattlefieldMgr.h"
#include "GameObjectPackets.h"
#include "MiscPackets.h"
+ Include dependency graph for Object.cpp:


struct  WorldObjectChangeAccumulator


float NormalizeZforCollision (WorldObject *obj, float x, float y, float z)

Function Documentation

float NormalizeZforCollision ( WorldObject obj,
float  x,
float  y,
float  z 
2709 {
2710  float ground = obj->GetMap()->GetHeight(obj->GetPhaseMask(), x, y, MAX_HEIGHT, true);
2711  float floor = obj->GetMap()->GetHeight(obj->GetPhaseMask(), x, y, z + 2.0f, true);
2712  float helper = std::fabs(ground - z) <= std::fabs(floor - z) ? ground : floor;
2713  if (z > helper) // must be above ground
2714  {
2715  if (Unit* unit = obj->ToUnit())
2716  {
2717  if (unit->CanFly())
2718  return z;
2719  }
2720  LiquidData liquid_status;
2721  ZLiquidStatus res = obj->GetMap()->getLiquidStatus(x, y, z, MAP_ALL_LIQUIDS, &liquid_status);
2722  if (res && liquid_status.level > helper) // water must be above ground
2723  {
2724  if (liquid_status.level > z) // z is underwater
2725  return z;
2726  else
2727  return std::fabs(liquid_status.level - z) <= std::fabs(helper - z) ? liquid_status.level : helper;
2728  }
2729  }
2730  return helper;
2731 }
Map * GetMap() const
Definition: Object.h:543
static Vector3int16 floor(const Vector3 &v)
Definition: Map.h:151
float GetHeight(float x, float y, float z, bool checkVMap=true, float maxSearchDist=DEFAULT_HEIGHT_SEARCH) const
Definition: Map.cpp:2314
uint32 GetPhaseMask() const
Definition: Object.h:461
G3D::int16 z
Definition: Vector3int16.h:46
Definition: Map.h:146
float level
Definition: Map.h:155
G3D::int16 y
Definition: Vector2int16.h:38
Definition: Map.h:131
G3D::int16 x
Definition: Vector2int16.h:37
#define MAX_HEIGHT
Definition: Map.h:247
Definition: Unit.h:1305
ZLiquidStatus getLiquidStatus(float x, float y, float z, uint8 ReqLiquidType, LiquidData *data=nullptr) const
Definition: Map.cpp:2497
Unit * ToUnit()
Definition: Object.h:197

+ Here is the call graph for this function:

+ Here is the caller graph for this function: