Tools/vmap_extractor: Move information about model type from spawns in vmap tiles to model file itself
Port From (https://github.com/TrinityCore/TrinityCore/commit/a70e758ba5eef1e8aa966cbabaee020630d2c872)
This commit is contained in:
@@ -56,7 +56,7 @@ namespace Framework.Constants
|
||||
public const uint mmapMagic = 0x4D4D4150; // 'MMAP'
|
||||
public const int mmapVersion = 15;
|
||||
|
||||
public const string VMapMagic = "VMAP_4.B";
|
||||
public const string VMapMagic = "VMAP_4.C";
|
||||
public const float VMAPInvalidHeightValue = -200000.0f;
|
||||
|
||||
public const uint MaxDungeonEncountersPerBoss = 4;
|
||||
|
||||
@@ -229,7 +229,7 @@ namespace Game.Collision
|
||||
return data;
|
||||
}
|
||||
|
||||
public WorldModel AcquireModelInstance(string filename, uint flags = 0)
|
||||
public WorldModel AcquireModelInstance(string filename)
|
||||
{
|
||||
lock (LoadedModelFilesLock)
|
||||
{
|
||||
@@ -245,7 +245,6 @@ namespace Game.Collision
|
||||
}
|
||||
|
||||
Log.outDebug(LogFilter.Maps, "VMapManager: loading file '{0}'", filename);
|
||||
model.GetModel().Flags = flags;
|
||||
|
||||
iLoadedModelFiles.Add(filename, model);
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ namespace Game.Collision
|
||||
if (ModelSpawn.ReadFromFile(reader, out ModelSpawn spawn))
|
||||
{
|
||||
// acquire model instance
|
||||
WorldModel model = vm.AcquireModelInstance(spawn.name, spawn.flags);
|
||||
WorldModel model = vm.AcquireModelInstance(spawn.name);
|
||||
if (model == null)
|
||||
Log.outError(LogFilter.Server, "StaticMapTree.LoadMapTile() : could not acquire WorldModel [{0}, {1}]", tileX, tileY);
|
||||
|
||||
|
||||
@@ -61,7 +61,6 @@ namespace Game.Collision
|
||||
|
||||
iBound = rotated_bounds + iPos;
|
||||
owner = modelOwner;
|
||||
isWmo = modelData.isWmo;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -74,6 +73,12 @@ namespace Game.Collision
|
||||
return mdl;
|
||||
}
|
||||
|
||||
public bool IsMapObject()
|
||||
{
|
||||
return !iModel.IsM2();
|
||||
}
|
||||
|
||||
|
||||
public override bool IntersectRay(Ray ray, ref float maxDist, bool stopAtFirstHit, PhaseShift phaseShift, ModelIgnoreFlags ignoreFlags)
|
||||
{
|
||||
if (!IsCollisionEnabled() || !owner.IsSpawned())
|
||||
@@ -172,7 +177,7 @@ namespace Game.Collision
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public bool UpdatePosition()
|
||||
{
|
||||
if (iModel == null)
|
||||
@@ -210,9 +215,8 @@ namespace Game.Collision
|
||||
|
||||
public void EnableCollision(bool enable) { _collisionEnabled = enable; }
|
||||
bool IsCollisionEnabled() { return _collisionEnabled; }
|
||||
public bool IsMapObject() { return isWmo; }
|
||||
public byte GetNameSetId() { return owner.GetNameSetId(); }
|
||||
|
||||
|
||||
public static bool LoadGameObjectModelList()
|
||||
{
|
||||
uint oldMSTime = Time.GetMSTime();
|
||||
@@ -239,13 +243,12 @@ namespace Game.Collision
|
||||
break;
|
||||
|
||||
uint displayId = reader.ReadUInt32();
|
||||
bool isWmo = reader.ReadBoolean();
|
||||
int name_length = reader.ReadInt32();
|
||||
string name = reader.ReadString(name_length);
|
||||
Vector3 v1 = reader.Read<Vector3>();
|
||||
Vector3 v2 = reader.Read<Vector3>();
|
||||
|
||||
StaticModelList.models.Add(displayId, new GameobjectModelData(name, v1, v2, isWmo));
|
||||
StaticModelList.models.Add(displayId, new GameobjectModelData(name, v1, v2));
|
||||
}
|
||||
}
|
||||
catch (EndOfStreamException ex)
|
||||
@@ -265,20 +268,17 @@ namespace Game.Collision
|
||||
float iScale;
|
||||
WorldModel iModel;
|
||||
GameObjectModelOwnerBase owner;
|
||||
bool isWmo;
|
||||
}
|
||||
public class GameobjectModelData
|
||||
{
|
||||
public GameobjectModelData(string name_, Vector3 lowBound, Vector3 highBound, bool isWmo_)
|
||||
public GameobjectModelData(string name_, Vector3 lowBound, Vector3 highBound)
|
||||
{
|
||||
bound = new AxisAlignedBox(lowBound, highBound);
|
||||
name = name_;
|
||||
isWmo = isWmo_;
|
||||
}
|
||||
|
||||
public AxisAlignedBox bound;
|
||||
public string name;
|
||||
public bool isWmo;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -9,11 +9,10 @@ using System.Numerics;
|
||||
|
||||
namespace Game.Collision
|
||||
{
|
||||
public enum ModelFlags
|
||||
public enum ModelInstanceFlags
|
||||
{
|
||||
M2 = 1,
|
||||
HasBound = 1 << 1,
|
||||
ParentSpawn = 1 << 2
|
||||
HasBound = 1 << 0,
|
||||
ParentSpawn = 1 << 1
|
||||
}
|
||||
|
||||
public class ModelMinimalData
|
||||
@@ -56,7 +55,7 @@ namespace Game.Collision
|
||||
spawn.iRot = reader.Read<Vector3>();
|
||||
spawn.iScale = reader.ReadSingle();
|
||||
|
||||
bool has_bound = Convert.ToBoolean(spawn.flags & (uint)ModelFlags.HasBound);
|
||||
bool has_bound = Convert.ToBoolean(spawn.flags & (uint)ModelInstanceFlags.HasBound);
|
||||
if (has_bound) // only WMOs have bound in MPQ, only available after computation
|
||||
{
|
||||
Vector3 bLow = reader.Read<Vector3>();
|
||||
@@ -127,10 +126,12 @@ namespace Game.Collision
|
||||
return;
|
||||
|
||||
// M2 files don't contain area info, only WMO files
|
||||
if (Convert.ToBoolean(flags & (uint)ModelFlags.M2))
|
||||
if (iModel.IsM2())
|
||||
return;
|
||||
|
||||
if (!iBound.contains(p))
|
||||
return;
|
||||
|
||||
// child bounds are defined in object space:
|
||||
Vector3 pModel = iInvRot.Multiply(p - iPos) * iInvScale;
|
||||
Vector3 zDirModel = iInvRot.Multiply(new Vector3(0.0f, 0.0f, -1.0f));
|
||||
@@ -172,10 +173,12 @@ namespace Game.Collision
|
||||
return false;
|
||||
|
||||
// M2 files don't contain area info, only WMO files
|
||||
if (Convert.ToBoolean(flags & (uint)ModelFlags.M2))
|
||||
if (iModel.IsM2())
|
||||
return false;
|
||||
|
||||
if (!iBound.contains(p))
|
||||
return false;
|
||||
|
||||
// child bounds are defined in object space:
|
||||
Vector3 pModel = iInvRot.Multiply(p - iPos) * iInvScale;
|
||||
Vector3 zDirModel = iInvRot.Multiply(new Vector3(0.0f, 0.0f, -1.0f));
|
||||
|
||||
@@ -290,8 +290,7 @@ namespace Game.Collision
|
||||
|
||||
public class WorldModel : IModel
|
||||
{
|
||||
public uint Flags;
|
||||
|
||||
ModelFlags Flags;
|
||||
uint RootWMOID;
|
||||
List<GroupModel> groupModels = new();
|
||||
BIH groupTree = new();
|
||||
@@ -302,7 +301,7 @@ namespace Game.Collision
|
||||
if ((ignoreFlags & ModelIgnoreFlags.M2) != ModelIgnoreFlags.Nothing)
|
||||
{
|
||||
// M2 models are not taken into account for LoS calculation if caller requested their ignoring.
|
||||
if ((Flags & (uint)ModelFlags.M2) != 0)
|
||||
if (Flags.HasFlag(ModelFlags.None))
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -371,6 +370,7 @@ namespace Game.Collision
|
||||
return false;
|
||||
|
||||
reader.ReadUInt32(); //chunkSize notused
|
||||
Flags = (ModelFlags)reader.ReadUInt32();
|
||||
RootWMOID = reader.ReadUInt32();
|
||||
|
||||
// read group models
|
||||
@@ -391,5 +391,14 @@ namespace Game.Collision
|
||||
|
||||
return groupTree.ReadFromFile(reader);
|
||||
}
|
||||
|
||||
public bool IsM2() { return Flags.HasFlag(ModelFlags.IsM2); }
|
||||
}
|
||||
|
||||
[Flags]
|
||||
enum ModelFlags
|
||||
{
|
||||
None = 0x0,
|
||||
IsM2 = 0x1
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user