Skip to content

Commit

Permalink
Core/Collision: Models with flag MOD_M2 (mostly trees, among some oth…
Browse files Browse the repository at this point in the history
…er objects) should not be taken into account for LoS checks, this check does not apply to gameobjects (yet)

closes #3495

Signed-off-by: Subv <s.v.h21@hotmail.com>
  • Loading branch information
Subv committed Feb 14, 2012
1 parent 7d30b06 commit c53d722
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/server/collision/Management/VMapManager2.cpp
Expand Up @@ -245,7 +245,7 @@ namespace VMAP
return false;
}

WorldModel* VMapManager2::acquireModelInstance(const std::string& basepath, const std::string& filename)
WorldModel* VMapManager2::acquireModelInstance(const std::string& basepath, const std::string& filename, uint32 flags/* Only used when creating the model */)
{
//! Critical section, thread safe access to iLoadedModelFiles
TRINITY_GUARD(ACE_Thread_Mutex, LoadedModelFilesLock);
Expand All @@ -261,6 +261,7 @@ namespace VMAP
return NULL;
}
sLog->outDebug(LOG_FILTER_MAPS, "VMapManager2: loading file '%s%s'", basepath.c_str(), filename.c_str());
worldmodel->Flags = flags;
model = iLoadedModelFiles.insert(std::pair<std::string, ManagedModel>(filename, ManagedModel())).first;
model->second.setModel(worldmodel);
}
Expand Down
2 changes: 1 addition & 1 deletion src/server/collision/Management/VMapManager2.h
Expand Up @@ -103,7 +103,7 @@ namespace VMAP
bool getAreaInfo(unsigned int pMapId, float x, float y, float& z, uint32& flags, int32& adtId, int32& rootId, int32& groupId) const;
bool GetLiquidLevel(uint32 pMapId, float x, float y, float z, uint8 reqLiquidType, float& level, float& floor, uint32& type) const;

WorldModel* acquireModelInstance(const std::string& basepath, const std::string& filename);
WorldModel* acquireModelInstance(const std::string& basepath, const std::string& filename, uint32 flags = 0);
void releaseModelInstance(const std::string& filename);

// what's the use of this? o.O
Expand Down
4 changes: 2 additions & 2 deletions src/server/collision/Maps/MapTree.cpp
Expand Up @@ -309,7 +309,7 @@ namespace VMAP
#endif
if (!iIsTiled && ModelSpawn::readFromFile(rf, spawn))
{
WorldModel* model = vm->acquireModelInstance(iBasePath, spawn.name);
WorldModel* model = vm->acquireModelInstance(iBasePath, spawn.name, spawn.flags);
sLog->outDebug(LOG_FILTER_MAPS, "StaticMapTree::InitMap() : loading %s", spawn.name.c_str());
if (model)
{
Expand Down Expand Up @@ -380,7 +380,7 @@ namespace VMAP
if (result)
{
// acquire model instance
WorldModel* model = vm->acquireModelInstance(iBasePath, spawn.name);
WorldModel* model = vm->acquireModelInstance(iBasePath, spawn.name, spawn.flags);
if (!model)
sLog->outError("StaticMapTree::LoadMapTile() : could not acquire WorldModel pointer [%u, %u]", tileX, tileY);

Expand Down
3 changes: 3 additions & 0 deletions src/server/collision/Models/WorldModel.cpp
Expand Up @@ -420,6 +420,9 @@ namespace VMAP

bool WorldModel::IntersectRay(const G3D::Ray &ray, float &distance, bool stopAtFirstHit) const
{
// M2 models are not taken into account for LoS calculation
if (Flags & MOD_M2)
return false;
// small M2 workaround, maybe better make separate class with virtual intersection funcs
// in any case, there's no need to use a bound tree if we only have one submodel
if (groupModels.size() == 1)
Expand Down
1 change: 1 addition & 0 deletions src/server/collision/Models/WorldModel.h
Expand Up @@ -113,6 +113,7 @@ namespace VMAP
bool GetLocationInfo(const G3D::Vector3 &p, const G3D::Vector3 &down, float &dist, LocationInfo &info) const;
bool writeFile(const std::string &filename);
bool readFile(const std::string &filename);
uint32 Flags;
protected:
uint32 RootWMOID;
std::vector<GroupModel> groupModels;
Expand Down

4 comments on commit c53d722

@Subv
Copy link
Contributor Author

@Subv Subv commented on c53d722 Feb 14, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Aokromes
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this commit is reason for some client crashes:

This application has encountered a critical error:
Not enough storage is available to process this command.
Program: C:\Program Files (x86)\World Of Warcraft 3.3.5a\Wow.exe
File: WBASEOBJLINK
Line: 0
Requested 320000 bytes of memory

@Subv
Copy link
Contributor Author

@Subv Subv commented on c53d722 Feb 15, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Aokromes not related to this

@Subv
Copy link
Contributor Author

@Subv Subv commented on c53d722 Feb 18, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@axium no, you were able to cast through the trees even on WoTLK
http://eu.battle.net/wow/en/forum/topic/3225375893
http://www.wowwiki.com/Line_of_sight

Please sign in to comment.