Skip to content

Commit

Permalink
Improvements to the Animation/Physics Related data for models and te…
Browse files Browse the repository at this point in the history
…rrain (#22)

- Added Bytebuffer pool for bytes size (16777216)
- Added Reading/Writing of Physics Bytes for MapChunk and ComplexModel
- Added ReadUnorderedMapFromBuffer to Shared Util in FileFormat
- Added SetBlendTransitionOnLoad to M2
- Renamed primaryBoneIndex to keyBoneID
- Added BlendTransitionIfActive flag to Bone
- Added KeyBoneIDToBoneIndex to ComplexModel
- Changed Tabs to Space (For touched files)
- Changed LF to CRLF (For touched files)
  • Loading branch information
NixAJ committed Mar 24, 2024
1 parent 444f515 commit e4afa3c
Show file tree
Hide file tree
Showing 26 changed files with 6,195 additions and 6,079 deletions.
7 changes: 4 additions & 3 deletions Source/Base/Base/Memory/Bytebuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ SharedPool<Bytebuffer> Bytebuffer::_byteBuffer262144;
SharedPool<Bytebuffer> Bytebuffer::_byteBuffer524288;
SharedPool<Bytebuffer> Bytebuffer::_byteBuffer1048576;
SharedPool<Bytebuffer> Bytebuffer::_byteBuffer8388608;
SharedPool<Bytebuffer> Bytebuffer::_byteBuffer16777216;
SharedPool<Bytebuffer> Bytebuffer::_byteBuffer209715200;

std::shared_ptr<Bytebuffer> Bytebuffer::BorrowRuntime(size_t size)
{
std::shared_ptr<Bytebuffer> buffer = _runtimeByteBuffers.acquireOrCreate(size);
buffer->Reset();
std::shared_ptr<Bytebuffer> buffer = _runtimeByteBuffers.acquireOrCreate(size);
buffer->Reset();

return buffer;
return buffer;
}
9 changes: 9 additions & 0 deletions Source/Base/Base/Memory/Bytebuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,14 @@ class Bytebuffer

return buffer;
}
else if constexpr (size <= 16777216)
{
std::shared_ptr<Bytebuffer> buffer = _byteBuffer16777216.acquireOrCreate(nullptr, 16777216);
buffer->size = size;
buffer->Reset();

return buffer;
}
else if constexpr (size <= 209715200) // This is used for the Data Extractor, largest observed file in WOTLK is 65MB, however in BFA this has been observed to be 150MB
{
std::shared_ptr<Bytebuffer> buffer = _byteBuffer209715200.acquireOrCreate(nullptr, 209715200);
Expand Down Expand Up @@ -709,6 +717,7 @@ class Bytebuffer
static SharedPool<Bytebuffer> _byteBuffer524288;
static SharedPool<Bytebuffer> _byteBuffer1048576;
static SharedPool<Bytebuffer> _byteBuffer8388608;
static SharedPool<Bytebuffer> _byteBuffer16777216;
static SharedPool<Bytebuffer> _byteBuffer209715200;

class RuntimePool
Expand Down
6 changes: 3 additions & 3 deletions Source/FileFormat/FileFormat/ChunkHeader.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
struct ChunkHeader
{
public:
struct Token
{
struct Token
{
public:
constexpr Token(const char* fourCC) noexcept : _value(0)
{
Expand All @@ -17,7 +17,7 @@ struct ChunkHeader

private:
u32 _value;
};
};

public:
ChunkHeader(const char* fourCC) : token(fourCC) { }
Expand Down
4 changes: 2 additions & 2 deletions Source/FileFormat/FileFormat/ChunkPointer.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
struct ChunkPointer
{
public:
u32 bufferOffset = 0;
u32 numElements = 0;
u32 bufferOffset = 0;
u32 numElements = 0;
};
10 changes: 5 additions & 5 deletions Source/FileFormat/FileFormat/Novus/ClientDB/ClientDB.h
Original file line number Diff line number Diff line change
Expand Up @@ -387,10 +387,10 @@ namespace ClientDB
bool _isDirty = false;
};

template <class T>
struct Storage
{
public:
template <class T>
struct Storage
{
public:
static_assert(std::is_base_of<Definitions::Base, T>::value, "ClientDB::Storage Type must derive from Base");

Storage(StorageRaw* storage)
Expand Down Expand Up @@ -519,5 +519,5 @@ namespace ClientDB

private:
StorageRaw* _storage = nullptr;
};
};
}
52 changes: 26 additions & 26 deletions Source/FileFormat/FileFormat/Novus/FileHeader.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,36 @@
struct FileHeader
{
public:
enum class Type
{
Invalid = -1,
ClientDB,
MapHeader,
MapChunk,
MapObject,
MapObjectGroup,
ComplexModel
};
enum class Type
{
Invalid = -1,
ClientDB,
MapHeader,
MapChunk,
MapObject,
MapObjectGroup,
ComplexModel
};

public:
FileHeader() { }
FileHeader(Type inType, u32 inVersion)
{
type = inType;
version = inVersion;
}
FileHeader() { }
FileHeader(Type inType, u32 inVersion)
{
type = inType;
version = inVersion;
}

bool operator==(const FileHeader& other)
{
return type == other.type && version == other.version;
}
bool operator==(const FileHeader& other)
{
return type == other.type && version == other.version;
}

bool operator!=(const FileHeader& other)
{
return type != other.type || version != other.version;
}
bool operator!=(const FileHeader& other)
{
return type != other.type || version != other.version;
}

public:
Type type = Type::Invalid;
u32 version = 0;
Type type = Type::Invalid;
u32 version = 0;
};
14 changes: 7 additions & 7 deletions Source/FileFormat/FileFormat/Novus/Map/Map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
namespace Map
{
bool MapHeader::Save(const std::string& path)
{
std::ofstream output(path, std::ofstream::out | std::ofstream::binary);
if (!output)
{
DebugHandler::PrintError("Failed to create Map Header file. Check admin permissions {0}", path);
return false;
}
{
std::ofstream output(path, std::ofstream::out | std::ofstream::binary);
if (!output)
{
DebugHandler::PrintError("Failed to create Map Header file. Check admin permissions {0}", path);
return false;
}

output.write(reinterpret_cast<char const*>(&header), sizeof(header));
output.write(reinterpret_cast<char const*>(&flags), sizeof(flags));
Expand Down
34 changes: 17 additions & 17 deletions Source/FileFormat/FileFormat/Novus/Map/Map.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,26 @@

namespace Map
{
static const std::string HEADER_FILE_EXTENSION = ".map";
static const std::string HEADER_FILE_EXTENSION = ".map";

struct MapHeader
{
public:
static const u32 CURRENT_VERSION = 2;
struct MapHeader
{
public:
static const u32 CURRENT_VERSION = 2;

struct Flags
{
u32 UseMapObjectAsBase : 1;
};
struct Flags
{
u32 UseMapObjectAsBase : 1;
};

public:
FileHeader header = FileHeader(FileHeader::Type::MapHeader, CURRENT_VERSION);
public:
FileHeader header = FileHeader(FileHeader::Type::MapHeader, CURRENT_VERSION);

Flags flags = { };
Terrain::Placement placement = { };
Flags flags = { };
Terrain::Placement placement = { };

public:
bool Save(const std::string& path);
static bool Read(std::shared_ptr<Bytebuffer>& buffer, MapHeader& out);
};
public:
bool Save(const std::string& path);
static bool Read(std::shared_ptr<Bytebuffer>& buffer, MapHeader& out);
};
}
Loading

0 comments on commit e4afa3c

Please sign in to comment.