diff options
Diffstat (limited to 'core/variant/variant_internal.h')
-rw-r--r-- | core/variant/variant_internal.h | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/core/variant/variant_internal.h b/core/variant/variant_internal.h index e0cfb42e1e..583a7b56bd 100644 --- a/core/variant/variant_internal.h +++ b/core/variant/variant_internal.h @@ -36,6 +36,8 @@ // For use when you want to access the internal pointer of a Variant directly. // Use with caution. You need to be sure that the type is correct. class VariantInternal { + friend class Variant; + public: // Set type. _FORCE_INLINE_ static void initialize(Variant *v, Variant::Type p_type) { @@ -209,19 +211,23 @@ public: } _FORCE_INLINE_ static void init_transform2d(Variant *v) { - v->_data._transform2d = memnew(Transform2D); + v->_data._transform2d = (Transform2D *)Variant::Pools::_bucket_small.alloc(); + memnew_placement(v->_data._transform2d, Transform2D); v->type = Variant::TRANSFORM2D; } _FORCE_INLINE_ static void init_aabb(Variant *v) { - v->_data._aabb = memnew(AABB); + v->_data._aabb = (AABB *)Variant::Pools::_bucket_small.alloc(); + memnew_placement(v->_data._aabb, AABB); v->type = Variant::AABB; } _FORCE_INLINE_ static void init_basis(Variant *v) { - v->_data._basis = memnew(Basis); + v->_data._basis = (Basis *)Variant::Pools::_bucket_large.alloc(); + memnew_placement(v->_data._basis, Basis); v->type = Variant::BASIS; } _FORCE_INLINE_ static void init_transform(Variant *v) { - v->_data._transform3d = memnew(Transform3D); + v->_data._transform3d = (Transform3D *)Variant::Pools::_bucket_large.alloc(); + memnew_placement(v->_data._transform3d, Transform3D); v->type = Variant::TRANSFORM3D; } _FORCE_INLINE_ static void init_string_name(Variant *v) { |