From 3eb2d2910e21f13a572830589675765d80175cfe Mon Sep 17 00:00:00 2001 From: NoFantasy Date: Sun, 27 Jun 2010 14:13:55 +0200 Subject: [PATCH] [10112] Rename GetObjectSize function to GetObjectBoundingRadius To reflect better what the function should actually return and also to clarify when used in misc calculations. Signed-off-by: NoFantasy --- src/game/CellImpl.h | 2 +- src/game/Level1.cpp | 4 +-- src/game/Level2.cpp | 2 +- src/game/Object.cpp | 36 +++++++++++++------------- src/game/Object.h | 12 ++++----- src/game/Pet.cpp | 2 +- src/game/Spell.cpp | 4 +-- src/game/SpellEffects.cpp | 18 ++++++------- src/game/TargetedMovementGenerator.cpp | 8 +++--- src/game/debugcmds.cpp | 2 +- src/shared/revision_nr.h | 2 +- 11 files changed, 46 insertions(+), 46 deletions(-) diff --git a/src/game/CellImpl.h b/src/game/CellImpl.h index 8e418e9e9..b15ab7e38 100644 --- a/src/game/CellImpl.h +++ b/src/game/CellImpl.h @@ -141,7 +141,7 @@ inline CellArea Cell::CalculateCellArea(const WorldObject &obj, float radius) //we should increase search radius by object's radius, otherwise //we could have problems with huge creatures, which won't attack nearest players etc - radius += obj.GetObjectSize(); + radius += obj.GetObjectBoundingRadius(); //lets calculate object coord offsets from cell borders. //TODO: add more correct/generic method for this task const float x_offset = (obj.GetPositionX() - CENTER_GRID_CELL_OFFSET)/SIZE_OF_GRID_CELL; diff --git a/src/game/Level1.cpp b/src/game/Level1.cpp index fcb819b4b..12a561480 100644 --- a/src/game/Level1.cpp +++ b/src/game/Level1.cpp @@ -440,7 +440,7 @@ bool ChatHandler::HandleNamegoCommand(const char* args) // before GM float x,y,z; - m_session->GetPlayer()->GetClosePoint(x,y,z,target->GetObjectSize()); + m_session->GetPlayer()->GetClosePoint(x, y, z, target->GetObjectBoundingRadius()); target->TeleportTo(m_session->GetPlayer()->GetMapId(),x,y,z,target->GetOrientation()); } else @@ -2180,7 +2180,7 @@ bool ChatHandler::HandleGroupgoCommand(const char* args) // before GM float x,y,z; - m_session->GetPlayer()->GetClosePoint(x,y,z,pl->GetObjectSize()); + m_session->GetPlayer()->GetClosePoint(x, y, z, pl->GetObjectBoundingRadius()); pl->TeleportTo(m_session->GetPlayer()->GetMapId(),x,y,z,pl->GetOrientation()); } diff --git a/src/game/Level2.cpp b/src/game/Level2.cpp index 10d42863d..7e8554d3f 100644 --- a/src/game/Level2.cpp +++ b/src/game/Level2.cpp @@ -1839,7 +1839,7 @@ bool ChatHandler::HandleNpcTameCommand(const char* /*args*/) // place pet before player float x,y,z; - player->GetClosePoint (x,y,z,creatureTarget->GetObjectSize (),CONTACT_DISTANCE); + player->GetClosePoint(x, y, z, creatureTarget->GetObjectBoundingRadius(), CONTACT_DISTANCE); pet->Relocate (x,y,z,M_PI_F-player->GetOrientation ()); // set pet to defensive mode by default (some classes can't control controlled pets in fact). diff --git a/src/game/Object.cpp b/src/game/Object.cpp index 4d6e45e88..2c318cce2 100644 --- a/src/game/Object.cpp +++ b/src/game/Object.cpp @@ -1156,7 +1156,7 @@ float WorldObject::GetDistance(const WorldObject* obj) const float dx = GetPositionX() - obj->GetPositionX(); float dy = GetPositionY() - obj->GetPositionY(); float dz = GetPositionZ() - obj->GetPositionZ(); - float sizefactor = GetObjectSize() + obj->GetObjectSize(); + float sizefactor = GetObjectBoundingRadius() + obj->GetObjectBoundingRadius(); float dist = sqrt((dx*dx) + (dy*dy) + (dz*dz)) - sizefactor; return ( dist > 0 ? dist : 0); } @@ -1165,7 +1165,7 @@ float WorldObject::GetDistance2d(float x, float y) const { float dx = GetPositionX() - x; float dy = GetPositionY() - y; - float sizefactor = GetObjectSize(); + float sizefactor = GetObjectBoundingRadius(); float dist = sqrt((dx*dx) + (dy*dy)) - sizefactor; return ( dist > 0 ? dist : 0); } @@ -1175,7 +1175,7 @@ float WorldObject::GetDistance(float x, float y, float z) const float dx = GetPositionX() - x; float dy = GetPositionY() - y; float dz = GetPositionZ() - z; - float sizefactor = GetObjectSize(); + float sizefactor = GetObjectBoundingRadius(); float dist = sqrt((dx*dx) + (dy*dy) + (dz*dz)) - sizefactor; return ( dist > 0 ? dist : 0); } @@ -1184,7 +1184,7 @@ float WorldObject::GetDistance2d(const WorldObject* obj) const { float dx = GetPositionX() - obj->GetPositionX(); float dy = GetPositionY() - obj->GetPositionY(); - float sizefactor = GetObjectSize() + obj->GetObjectSize(); + float sizefactor = GetObjectBoundingRadius() + obj->GetObjectBoundingRadius(); float dist = sqrt((dx*dx) + (dy*dy)) - sizefactor; return ( dist > 0 ? dist : 0); } @@ -1192,7 +1192,7 @@ float WorldObject::GetDistance2d(const WorldObject* obj) const float WorldObject::GetDistanceZ(const WorldObject* obj) const { float dz = fabs(GetPositionZ() - obj->GetPositionZ()); - float sizefactor = GetObjectSize() + obj->GetObjectSize(); + float sizefactor = GetObjectBoundingRadius() + obj->GetObjectBoundingRadius(); float dist = dz - sizefactor; return ( dist > 0 ? dist : 0); } @@ -1204,7 +1204,7 @@ bool WorldObject::IsWithinDist3d(float x, float y, float z, float dist2compare) float dz = GetPositionZ() - z; float distsq = dx*dx + dy*dy + dz*dz; - float sizefactor = GetObjectSize(); + float sizefactor = GetObjectBoundingRadius(); float maxdist = dist2compare + sizefactor; return distsq < maxdist * maxdist; @@ -1216,7 +1216,7 @@ bool WorldObject::IsWithinDist2d(float x, float y, float dist2compare) const float dy = GetPositionY() - y; float distsq = dx*dx + dy*dy; - float sizefactor = GetObjectSize(); + float sizefactor = GetObjectBoundingRadius(); float maxdist = dist2compare + sizefactor; return distsq < maxdist * maxdist; @@ -1232,7 +1232,7 @@ bool WorldObject::_IsWithinDist(WorldObject const* obj, float dist2compare, bool float dz = GetPositionZ() - obj->GetPositionZ(); distsq += dz*dz; } - float sizefactor = GetObjectSize() + obj->GetObjectSize(); + float sizefactor = GetObjectBoundingRadius() + obj->GetObjectBoundingRadius(); float maxdist = dist2compare + sizefactor; return distsq < maxdist * maxdist; @@ -1288,7 +1288,7 @@ bool WorldObject::IsInRange(WorldObject const* obj, float minRange, float maxRan distsq += dz*dz; } - float sizefactor = GetObjectSize() + obj->GetObjectSize(); + float sizefactor = GetObjectBoundingRadius() + obj->GetObjectBoundingRadius(); // check only for real range if(minRange > 0.0f) @@ -1308,7 +1308,7 @@ bool WorldObject::IsInRange2d(float x, float y, float minRange, float maxRange) float dy = GetPositionY() - y; float distsq = dx*dx + dy*dy; - float sizefactor = GetObjectSize(); + float sizefactor = GetObjectBoundingRadius(); // check only for real range if(minRange > 0.0f) @@ -1329,7 +1329,7 @@ bool WorldObject::IsInRange3d(float x, float y, float z, float minRange, float m float dz = GetPositionZ() - z; float distsq = dx*dx + dy*dy + dz*dz; - float sizefactor = GetObjectSize(); + float sizefactor = GetObjectBoundingRadius(); // check only for real range if(minRange > 0.0f) @@ -1647,7 +1647,7 @@ Creature* WorldObject::SummonCreature(uint32 id, float x, float y, float z, floa } if (x == 0.0f && y == 0.0f && z == 0.0f) - GetClosePoint(x, y, z, pCreature->GetObjectSize()); + GetClosePoint(x, y, z, pCreature->GetObjectBoundingRadius()); pCreature->Relocate(x, y, z, ang); pCreature->SetSummonPoint(x, y, z, ang); @@ -1729,7 +1729,7 @@ namespace MaNGOS // dist include size of u float dist2d = i_object.GetDistance2d(x,y); - i_selector.AddUsedPos(u->GetObjectSize(),angle,dist2d + i_object.GetObjectSize()); + i_selector.AddUsedPos(u->GetObjectBoundingRadius(), angle, dist2d + i_object.GetObjectBoundingRadius()); } private: WorldObject const& i_object; @@ -1743,16 +1743,16 @@ namespace MaNGOS void WorldObject::GetNearPoint2D(float &x, float &y, float distance2d, float absAngle ) const { - x = GetPositionX() + (GetObjectSize() + distance2d) * cos(absAngle); - y = GetPositionY() + (GetObjectSize() + distance2d) * sin(absAngle); + x = GetPositionX() + (GetObjectBoundingRadius() + distance2d) * cos(absAngle); + y = GetPositionY() + (GetObjectBoundingRadius() + distance2d) * sin(absAngle); MaNGOS::NormalizeMapCoord(x); MaNGOS::NormalizeMapCoord(y); } -void WorldObject::GetNearPoint(WorldObject const* searcher, float &x, float &y, float &z, float searcher_size, float distance2d, float absAngle ) const +void WorldObject::GetNearPoint(WorldObject const* searcher, float &x, float &y, float &z, float searcher_bounding_radius, float distance2d, float absAngle) const { - GetNearPoint2D(x,y,distance2d+searcher_size,absAngle); + GetNearPoint2D(x, y, distance2d+searcher_bounding_radius, absAngle); z = GetPositionZ(); // if detection disabled, return first point @@ -1768,7 +1768,7 @@ void WorldObject::GetNearPoint(WorldObject const* searcher, float &x, float &y, bool first_los_conflict = false; // first point LOS problems // prepare selector for work - ObjectPosSelector selector(GetPositionX(),GetPositionY(),GetObjectSize(),distance2d+searcher_size); + ObjectPosSelector selector(GetPositionX(), GetPositionY(), GetObjectBoundingRadius(), distance2d+searcher_bounding_radius); // adding used positions around object { diff --git a/src/game/Object.h b/src/game/Object.h index a1be3d9bc..76611d6a2 100644 --- a/src/game/Object.h +++ b/src/game/Object.h @@ -37,7 +37,7 @@ #define DEFAULT_VISIBILITY_INSTANCE 120.0f // default visible distance in instances, 120 yards #define DEFAULT_VISIBILITY_BGARENAS 180.0f // default visible distance in BG/Arenas, 180 yards -#define DEFAULT_WORLD_OBJECT_SIZE 0.388999998569489f // player size, also currently used (correctly?) for any non Unit world objects +#define DEFAULT_WORLD_OBJECT_SIZE 0.388999998569489f // currently used (correctly?) for any non Unit world objects. This is actually the bounding_radius, like player/creature from creature_model_data #define DEFAULT_OBJECT_SCALE 1.0f // player/item scale as default, npc/go from database, pets from dbc #define MAX_STEALTH_DETECT_RANGE 45.0f @@ -359,19 +359,19 @@ class MANGOS_DLL_SPEC WorldObject : public Object { loc.mapid = m_mapId; GetPosition(loc.coord_x, loc.coord_y, loc.coord_z); loc.orientation = GetOrientation(); } float GetOrientation( ) const { return m_orientation; } void GetNearPoint2D( float &x, float &y, float distance, float absAngle) const; - void GetNearPoint( WorldObject const* searcher, float &x, float &y, float &z, float searcher_size, float distance2d,float absAngle) const; - void GetClosePoint(float &x, float &y, float &z, float size, float distance2d = 0, float angle = 0) const + void GetNearPoint(WorldObject const* searcher, float &x, float &y, float &z, float searcher_bounding_radius, float distance2d, float absAngle) const; + void GetClosePoint(float &x, float &y, float &z, float bounding_radius, float distance2d = 0, float angle = 0) const { // angle calculated from current orientation - GetNearPoint(NULL,x,y,z,size,distance2d,GetOrientation() + angle); + GetNearPoint(NULL, x, y, z, bounding_radius, distance2d, GetOrientation() + angle); } void GetContactPoint( const WorldObject* obj, float &x, float &y, float &z, float distance2d = CONTACT_DISTANCE) const { // angle to face `obj` to `this` using distance includes size of `obj` - GetNearPoint(obj,x,y,z,obj->GetObjectSize(),distance2d,GetAngle( obj )); + GetNearPoint(obj, x, y, z, obj->GetObjectBoundingRadius(), distance2d, GetAngle(obj)); } - float GetObjectSize() const + float GetObjectBoundingRadius() const { return ( m_valuesCount > UNIT_FIELD_BOUNDINGRADIUS ) ? m_floatValues[UNIT_FIELD_BOUNDINGRADIUS] : DEFAULT_WORLD_OBJECT_SIZE; } diff --git a/src/game/Pet.cpp b/src/game/Pet.cpp index 5f947c39e..b2fc38c79 100644 --- a/src/game/Pet.cpp +++ b/src/game/Pet.cpp @@ -163,7 +163,7 @@ bool Pet::LoadPetFromDB( Player* owner, uint32 petentry, uint32 petnumber, bool } float px, py, pz; - owner->GetClosePoint(px, py, pz, GetObjectSize(), PET_FOLLOW_DIST, PET_FOLLOW_ANGLE); + owner->GetClosePoint(px, py, pz, GetObjectBoundingRadius(), PET_FOLLOW_DIST, PET_FOLLOW_ANGLE); Relocate(px, py, pz, owner->GetOrientation()); diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index 3a8abf1be..bcdca9c3b 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -2286,7 +2286,7 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList& } float _target_x, _target_y, _target_z; - pTarget->GetClosePoint(_target_x, _target_y, _target_z, pTarget->GetObjectSize(), dist, angle); + pTarget->GetClosePoint(_target_x, _target_y, _target_z, pTarget->GetObjectBoundingRadius(), dist, angle); if(pTarget->IsWithinLOS(_target_x, _target_y, _target_z)) { targetUnitMap.push_back(m_caster); @@ -2368,7 +2368,7 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList& float dist = minRange+ rand_norm_f()*(maxRange-minRange); float _target_x, _target_y, _target_z; - m_caster->GetClosePoint(_target_x, _target_y, _target_z, m_caster->GetObjectSize(), dist); + m_caster->GetClosePoint(_target_x, _target_y, _target_z, m_caster->GetObjectBoundingRadius(), dist); m_targets.setDestination(_target_x, _target_y, _target_z); } diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index 218c5b918..fda410265 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -3958,7 +3958,7 @@ void Spell::DoSummon(SpellEffectIndex eff_idx) z = m_targets.m_destZ; } else - m_caster->GetClosePoint(x, y, z, spawnCreature->GetObjectSize()); + m_caster->GetClosePoint(x, y, z, spawnCreature->GetObjectBoundingRadius()); spawnCreature->Relocate(x, y, z, -m_caster->GetOrientation()); spawnCreature->SetSummonPoint(x, y, z, -m_caster->GetOrientation()); @@ -4377,7 +4377,7 @@ void Spell::DoSummonGuardian(SpellEffectIndex eff_idx, uint32 forceFaction) } // Summon if dest location not present near caster else - m_caster->GetClosePoint(px, py, pz,spawnCreature->GetObjectSize()); + m_caster->GetClosePoint(px, py, pz,spawnCreature->GetObjectBoundingRadius()); spawnCreature->Relocate(px, py, pz, m_caster->GetOrientation()); spawnCreature->SetSummonPoint(px, py, pz, m_caster->GetOrientation()); @@ -4425,7 +4425,7 @@ void Spell::EffectTeleUnitsFaceCaster(SpellEffectIndex eff_idx) float dis = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[eff_idx])); float fx, fy, fz; - m_caster->GetClosePoint(fx, fy, fz, unitTarget->GetObjectSize(), dis); + m_caster->GetClosePoint(fx, fy, fz, unitTarget->GetObjectBoundingRadius(), dis); unitTarget->NearTeleportTo(fx, fy, fz, -m_caster->GetOrientation(), unitTarget==m_caster); } @@ -4762,7 +4762,7 @@ void Spell::EffectSummonPet(SpellEffectIndex eff_idx) OldSummon->GetMap()->Remove((Creature*)OldSummon,false); float px, py, pz; - m_caster->GetClosePoint(px, py, pz, OldSummon->GetObjectSize()); + m_caster->GetClosePoint(px, py, pz, OldSummon->GetObjectBoundingRadius()); OldSummon->Relocate(px, py, pz, OldSummon->GetOrientation()); m_caster->GetMap()->Add((Creature*)OldSummon); @@ -4812,7 +4812,7 @@ void Spell::EffectSummonPet(SpellEffectIndex eff_idx) } float px, py, pz; - m_caster->GetClosePoint(px, py, pz, NewSummon->GetObjectSize()); + m_caster->GetClosePoint(px, py, pz, NewSummon->GetObjectBoundingRadius()); NewSummon->Relocate(px, py, pz, m_caster->GetOrientation()); @@ -6639,7 +6639,7 @@ void Spell::EffectSummonPlayer(SpellEffectIndex /*eff_idx*/) return; float x, y, z; - m_caster->GetClosePoint(x, y, z, unitTarget->GetObjectSize()); + m_caster->GetClosePoint(x, y, z, unitTarget->GetObjectBoundingRadius()); ((Player*)unitTarget)->SetSummonPoint(m_caster->GetMapId(),x,y,z); @@ -6725,7 +6725,7 @@ void Spell::DoSummonTotem(SpellEffectIndex eff_idx, uint8 slot_dbc) float angle = slot < MAX_TOTEM_SLOT ? M_PI_F/MAX_TOTEM_SLOT - (slot*2*M_PI_F/MAX_TOTEM_SLOT) : 0; float x, y, z; - m_caster->GetClosePoint(x, y, z, pTotem->GetObjectSize(), 2.0f, angle); + m_caster->GetClosePoint(x, y, z, pTotem->GetObjectBoundingRadius(), 2.0f, angle); // totem must be at same Z in case swimming caster and etc. if( fabs( z - m_caster->GetPositionZ() ) > 5 ) @@ -7027,7 +7027,7 @@ void Spell::EffectLeapForward(SpellEffectIndex eff_idx) // before caster float fx, fy, fz; - unitTarget->GetClosePoint(fx, fy, fz, unitTarget->GetObjectSize(), dis); + unitTarget->GetClosePoint(fx, fy, fz, unitTarget->GetObjectBoundingRadius(), dis); float ox, oy, oz; unitTarget->GetPosition(ox, oy, oz); @@ -7234,7 +7234,7 @@ void Spell::DoSummonCritter(SpellEffectIndex eff_idx, uint32 forceFaction) } // Summon if dest location not present near caster else - m_caster->GetClosePoint(x, y, z, critter->GetObjectSize()); + m_caster->GetClosePoint(x, y, z, critter->GetObjectBoundingRadius()); critter->Relocate(x, y, z, m_caster->GetOrientation()); critter->SetSummonPoint(x, y, z, m_caster->GetOrientation()); diff --git a/src/game/TargetedMovementGenerator.cpp b/src/game/TargetedMovementGenerator.cpp index efc52bfc8..fb5607ad3 100644 --- a/src/game/TargetedMovementGenerator.cpp +++ b/src/game/TargetedMovementGenerator.cpp @@ -55,7 +55,7 @@ void TargetedMovementGeneratorMedium::_setTargetLocation(T &owner) else { // to at i_offset distance from target and i_angle from target facing - i_target->GetClosePoint(x,y,z,owner.GetObjectSize(),i_offset,i_angle); + i_target->GetClosePoint(x, y, z, owner.GetObjectBoundingRadius(), i_offset, i_angle); } /* @@ -70,7 +70,7 @@ void TargetedMovementGeneratorMedium::_setTargetLocation(T &owner) ralf //We don't update Mob Movement, if the difference between New destination and last destination is < BothObjectSize - float bothObjectSize = i_target->GetObjectSize() + owner.GetObjectSize() + CONTACT_DISTANCE; + float bothObjectSize = i_target->GetObjectBoundingRadius() + owner.GetObjectBoundingRadius() + CONTACT_DISTANCE; if( i_destinationHolder.HasDestination() && i_destinationHolder.GetDestinationDiff(x,y,z) < bothObjectSize ) return; */ @@ -158,10 +158,10 @@ bool TargetedMovementGeneratorMedium::Update(T &owner, const uint32 & time_ return true; // not expire now, but already lost // put targeted movement generators on a higher priority - if (owner.GetObjectSize()) + if (owner.GetObjectBoundingRadius()) i_destinationHolder.ResetUpdate(50); - float dist = i_target->GetObjectSize() + owner.GetObjectSize() + sWorld.getConfig(CONFIG_FLOAT_RATE_TARGET_POS_RECALCULATION_RANGE); + float dist = i_target->GetObjectBoundingRadius() + owner.GetObjectBoundingRadius() + sWorld.getConfig(CONFIG_FLOAT_RATE_TARGET_POS_RECALCULATION_RANGE); //More distance let have better performance, less distance let have more sensitive reaction at target move. diff --git a/src/game/debugcmds.cpp b/src/game/debugcmds.cpp index 6a48add66..9ea6958cd 100644 --- a/src/game/debugcmds.cpp +++ b/src/game/debugcmds.cpp @@ -643,7 +643,7 @@ bool ChatHandler::HandleDebugSpawnVehicle(const char* args) } float px, py, pz; - m_session->GetPlayer()->GetClosePoint(px, py, pz, m_session->GetPlayer()->GetObjectSize()); + m_session->GetPlayer()->GetClosePoint(px, py, pz, m_session->GetPlayer()->GetObjectBoundingRadius()); v->Relocate(px, py, pz, m_session->GetPlayer()->GetOrientation()); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 17410a5a1..8c6e5adf5 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "10111" + #define REVISION_NR "10112" #endif // __REVISION_NR_H__