Skip to content
This repository has been archived by the owner on Dec 22, 2024. It is now read-only.

Commit

Permalink
#23, #1: More wrapper functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
Xaymar committed Apr 12, 2024
1 parent 0965ea6 commit 550c4db
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
33 changes: 33 additions & 0 deletions source/stingray_unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,39 @@ stingray::unit::mesh::mesh(uint8_t const* ptr)
_group_ptr = reinterpret_cast<decltype(_group_ptr)>(ptr + _ptr->group_offset);
}

size_t stingray::unit::mesh::datatype()
{
return _ptr->datatype_index;
}

size_t stingray::unit::mesh::materials()
{
return _ptr->materials;
}

stingray::thin_hash_t stingray::unit::mesh::material(size_t idx)
{
if (idx > _ptr->materials) {
throw std::out_of_range("Index out of range");
}

return _material_ptr[idx];
}

size_t stingray::unit::mesh::groups()
{
return _ptr->groups;
}

stingray::unit::mesh::group_t const* stingray::unit::mesh::group(size_t idx)
{
if (idx > _ptr->groups) {
throw std::out_of_range("Index out of range");
}

return &_group_ptr[idx];
}

stingray::unit::mesh_list::~mesh_list() {}

stingray::unit::mesh_list::mesh_list() : _ptr(), _offset_ptr(), _name_ptr(), _mesh_ptr(), _meshes(), _map() {}
Expand Down
10 changes: 10 additions & 0 deletions source/stingray_unit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,16 @@ namespace stingray {
~mesh();
mesh();
mesh(uint8_t const* ptr);

size_t datatype();

size_t materials();

stingray::thin_hash_t material(size_t idx);

size_t groups();

group_t const* group(size_t idx);
};

class mesh_list {
Expand Down

0 comments on commit 550c4db

Please sign in to comment.