Skip to content

[Question] Directly accessing packed array #1301

@HexitCZ

Description

@HexitCZ

Hi,
I recently stumbled upon this library and so far I am loving it!
But I managed to find a problem I am not able to resolve.
In short, I am trying to make a 2D game in raylib with many entities (thousands) and I pretty much have to utilize instanced rendering for it, but I am unable to manage to get a contiguous array (of transforms for the drawcall) from EnTT and I am still unsure if it's even possible.

  1. I have entities with CustomTransform component (which is just a struct with a matrix member variable).
  2. I get the storage_type object from the registry of the CustomTransform component.
  3. Then I get the packed array with data() from the storage.
  • And this is where my tries fail. I need the packed array of the transforms (matrices) to pass into the drawcall function. I tried casting it to const pointer array of the component, but then if I read the data with a loop for example, I get garbage data.
            auto& transform_storage = registry.storage<CustomTransform>();
            const auto* transformData = (const CustomTransform*)(transform_storage.data());
            //transformData contains only garbage or seemingly random/uninitialized data

I tried sorting, doing the same with groups, but to no avail.

Thank you and sorry in advance if this is dumb question, but I had to ask for my own sanity.

Metadata

Metadata

Assignees

Labels

questionopen questionsolvedavailable upstream or in a branch

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions