Skip to content

Commit

Permalink
Entity: Add comments on likely new code
Browse files Browse the repository at this point in the history
  • Loading branch information
EmosewaMC committed Sep 30, 2023
1 parent 7808a52 commit 47f62dd
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions dGame/Entity.h
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,8 @@ inline ComponentType* Entity::AddComponent(VaArgs... args) {
} else {
// In this case the block is already allocated and ready for use
// so we use a placement new to construct the component again as was requested by the caller.
// Placement new means we already have memory allocated for the object, so this just calls its constructor again.
// This is useful for when we want to create a new object in the same memory location as an old one.
new(componentToReturn) ComponentType(this, std::forward<VaArgs>(args)...);
}

Expand Down

0 comments on commit 47f62dd

Please sign in to comment.