From 47f62ddccb107fee84b75699c6bb9f098b1ae5d7 Mon Sep 17 00:00:00 2001 From: David Markowitz Date: Sat, 30 Sep 2023 03:11:42 -0700 Subject: [PATCH] Entity: Add comments on likely new code --- dGame/Entity.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dGame/Entity.h b/dGame/Entity.h index 251bac888..906e5e8a4 100644 --- a/dGame/Entity.h +++ b/dGame/Entity.h @@ -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(args)...); }