Skip to content

Hierarchical prototype #47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Nov 29, 2022
Merged

Hierarchical prototype #47

merged 9 commits into from
Nov 29, 2022

Conversation

brenocq
Copy link
Owner

@brenocq brenocq commented Nov 29, 2022

Hierarchical prototype

Now it is possible to have prototypes with children, this way more complex prototypes can be achieved (e.g. robots with multiple sensors).

image

Memory management

It is important to keep component data close in the memory to be cache-friendly when parallelizing.

Prototype without children

Let's say we want to create 2 clones, when the prototype does not have children, we would have:
photo_4916149296945015443_y
Note that when executing in parallel, the transform component of each clone is sequential in the memory, as well as the name, and mesh components. This way, when the transform for the first clone is requested, there is a bigger probability that the transform of the next clone will already be in the cache line.

Prototype with children

The same reasoning follows and we have a prototype with children.
photo_4916149296945015444_y

Note that it is like each component from the prototype is "expanded" to the component of each clone.

Extra

Limitations:

  • Not possible to create recursive prototypes yet
  • Components with EntityId will refer to prototype entity instead of clone entity (only handling cmp::Relationship now)

Changelog:

  • Feat
    • Create clones from a prototype with children
    • cmp::Camera with new captureTime field
    • cmp::Entity new methods:
      • Entity::exists()
      • Entity::getParent()
      • Entity::getChildren()
      • Entity::getChild(unsigned i)
    • cmp::Relationship new Entity get(uint32_t i) method
    • Now it is possible to get scale/position/orientation individually from mat4
      • vec3 mat4::getPosition()
      • quat mat4::getOrientation()
      • vec3 mat4::getScale()
  • Refactor
    • Quaternion UI with quaternion values instead of Euler values
    • cmp::Relationship using cmp::Entity instead of cmp::EntityId
    • Varying camera sensor drawer size according to entity size
    • Camera model matrix calculation from position and orientation instead of transform matrices to reduce numerical error
  • Fix
    • Running clone script twice per step
    • Not reloading cameras when project is open
    • Always drawing prototype camera/colliders
    • Returning invalid orientation quaternion from mat4
    • Returning wrong euler from quaternion

@brenocq brenocq marked this pull request as ready for review November 29, 2022 13:45
@brenocq brenocq merged commit f359196 into dev Nov 29, 2022
@brenocq brenocq deleted the hierarchical-prototype branch November 29, 2022 13:47
@brenocq brenocq mentioned this pull request Jan 29, 2023
@brenocq brenocq added the status:done Task completed successfully label Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:done Task completed successfully
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant